@lightdash-tools/client 0.6.0 → 0.7.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 (237) hide show
  1. package/README.md +2 -2
  2. package/dist/agentops/apply-agent-change.d.ts +3 -0
  3. package/dist/agentops/apply-agent-change.js +63 -0
  4. package/dist/agentops/apply-bundle-diff.d.ts +13 -0
  5. package/dist/agentops/apply-bundle-diff.js +44 -0
  6. package/dist/agentops/apply-bundle-diff.test.d.ts +1 -0
  7. package/dist/agentops/apply-bundle-diff.test.js +397 -0
  8. package/dist/agentops/apply-context.d.ts +14 -0
  9. package/dist/agentops/apply-context.js +6 -0
  10. package/dist/agentops/apply-evaluation-change.d.ts +3 -0
  11. package/dist/agentops/apply-evaluation-change.js +78 -0
  12. package/dist/agentops/fetch-bundle-state.d.ts +6 -0
  13. package/dist/agentops/fetch-bundle-state.js +20 -0
  14. package/dist/agentops/fetch-bundle-state.test.d.ts +1 -0
  15. package/dist/agentops/fetch-bundle-state.test.js +44 -0
  16. package/dist/agentops/index.d.ts +3 -0
  17. package/dist/agentops/index.js +9 -0
  18. package/dist/agentops/resolve-evaluation-run.d.ts +15 -0
  19. package/dist/agentops/resolve-evaluation-run.js +48 -0
  20. package/dist/api/v1/ai-agents/admin.d.ts +16 -0
  21. package/dist/api/v1/ai-agents/admin.js +29 -0
  22. package/dist/api/v1/ai-agents/agents.d.ts +18 -0
  23. package/dist/api/v1/ai-agents/agents.js +31 -0
  24. package/dist/api/v1/ai-agents/artifacts.d.ts +26 -0
  25. package/dist/api/v1/ai-agents/artifacts.js +41 -0
  26. package/dist/api/v1/ai-agents/artifacts.test.d.ts +1 -0
  27. package/dist/api/v1/ai-agents/artifacts.test.js +69 -0
  28. package/dist/api/v1/ai-agents/discovery.d.ts +28 -0
  29. package/dist/api/v1/ai-agents/discovery.js +46 -0
  30. package/dist/api/v1/ai-agents/discovery.test.d.ts +1 -0
  31. package/dist/api/v1/ai-agents/discovery.test.js +90 -0
  32. package/dist/api/v1/ai-agents/evaluations.d.ts +39 -0
  33. package/dist/api/v1/ai-agents/evaluations.js +70 -0
  34. package/dist/api/v1/ai-agents/facade.d.ts +79 -0
  35. package/dist/api/v1/ai-agents/facade.js +193 -0
  36. package/dist/api/v1/ai-agents/feedback.d.ts +10 -0
  37. package/dist/api/v1/ai-agents/feedback.js +15 -0
  38. package/dist/api/v1/ai-agents/feedback.test.d.ts +1 -0
  39. package/dist/api/v1/ai-agents/feedback.test.js +23 -0
  40. package/dist/api/v1/ai-agents/index.d.ts +1 -0
  41. package/dist/api/v1/ai-agents/index.js +5 -0
  42. package/dist/api/v1/ai-agents/mcp-servers.d.ts +20 -0
  43. package/dist/api/v1/ai-agents/mcp-servers.js +35 -0
  44. package/dist/api/v1/ai-agents/mcp-servers.test.d.ts +1 -0
  45. package/dist/api/v1/ai-agents/mcp-servers.test.js +66 -0
  46. package/dist/api/v1/ai-agents/request-options.d.ts +12 -0
  47. package/dist/api/v1/ai-agents/request-options.js +20 -0
  48. package/dist/api/v1/ai-agents/sql-approval.d.ts +10 -0
  49. package/dist/api/v1/ai-agents/sql-approval.js +15 -0
  50. package/dist/api/v1/ai-agents/sql-approval.test.d.ts +1 -0
  51. package/dist/api/v1/ai-agents/sql-approval.test.js +25 -0
  52. package/dist/api/v1/ai-agents/threads.d.ts +56 -0
  53. package/dist/api/v1/ai-agents/threads.js +97 -0
  54. package/dist/api/v1/ai-agents/threads.test.d.ts +1 -0
  55. package/dist/api/v1/ai-agents/threads.test.js +39 -0
  56. package/dist/api/v1/ai-agents.test.js +172 -89
  57. package/dist/api/v1/analytics.d.ts +10 -0
  58. package/dist/api/v1/analytics.js +14 -0
  59. package/dist/api/v1/analytics.test.d.ts +4 -0
  60. package/dist/api/v1/analytics.test.js +27 -0
  61. package/dist/api/v1/charts.d.ts +5 -2
  62. package/dist/api/v1/charts.js +18 -30
  63. package/dist/api/v1/charts.test.js +19 -28
  64. package/dist/api/v1/dashboards.d.ts +11 -2
  65. package/dist/api/v1/dashboards.js +19 -14
  66. package/dist/api/v1/dashboards.test.js +54 -12
  67. package/dist/api/v1/explores.d.ts +4 -2
  68. package/dist/api/v1/explores.js +20 -29
  69. package/dist/api/v1/explores.test.js +31 -21
  70. package/dist/api/v1/groups.d.ts +1 -1
  71. package/dist/api/v1/groups.js +25 -51
  72. package/dist/api/v1/groups.test.js +15 -24
  73. package/dist/api/v1/metrics.d.ts +2 -2
  74. package/dist/api/v1/metrics.js +4 -17
  75. package/dist/api/v1/metrics.test.js +6 -15
  76. package/dist/api/v1/organizations.d.ts +1 -1
  77. package/dist/api/v1/organizations.js +2 -13
  78. package/dist/api/v1/organizations.test.js +3 -12
  79. package/dist/api/v1/project-access.d.ts +1 -1
  80. package/dist/api/v1/project-access.js +18 -45
  81. package/dist/api/v1/project-access.test.js +27 -36
  82. package/dist/api/v1/projects.d.ts +1 -1
  83. package/dist/api/v1/projects.js +6 -21
  84. package/dist/api/v1/projects.test.js +9 -18
  85. package/dist/api/v1/query.d.ts +5 -2
  86. package/dist/api/v1/query.js +8 -18
  87. package/dist/api/v1/query.test.js +6 -15
  88. package/dist/api/v1/schedulers.d.ts +2 -2
  89. package/dist/api/v1/schedulers.js +4 -17
  90. package/dist/api/v1/schedulers.test.js +6 -15
  91. package/dist/api/v1/spaces.d.ts +1 -1
  92. package/dist/api/v1/spaces.js +18 -45
  93. package/dist/api/v1/spaces.test.js +27 -36
  94. package/dist/api/v1/tags.d.ts +1 -1
  95. package/dist/api/v1/tags.js +4 -17
  96. package/dist/api/v1/tags.test.js +6 -15
  97. package/dist/api/v1/users.d.ts +3 -1
  98. package/dist/api/v1/users.js +22 -39
  99. package/dist/api/v1/users.test.js +44 -30
  100. package/dist/api/v1/validation.d.ts +5 -2
  101. package/dist/api/v1/validation.js +8 -18
  102. package/dist/api/v1/validation.test.js +6 -15
  103. package/dist/api/v2/content.d.ts +2 -2
  104. package/dist/api/v2/content.js +3 -14
  105. package/dist/api/v2/content.test.js +3 -12
  106. package/dist/api/v2/dashboards.d.ts +10 -0
  107. package/dist/api/v2/dashboards.js +14 -0
  108. package/dist/api/v2/dashboards.test.d.ts +4 -0
  109. package/dist/api/v2/dashboards.test.js +27 -0
  110. package/dist/api/v2/organization-roles.d.ts +1 -1
  111. package/dist/api/v2/organization-roles.js +21 -50
  112. package/dist/api/v2/organization-roles.test.js +33 -42
  113. package/dist/api/v2/project-role-assignments.d.ts +1 -1
  114. package/dist/api/v2/project-role-assignments.js +12 -33
  115. package/dist/api/v2/project-role-assignments.test.js +18 -27
  116. package/dist/api/v2/query.d.ts +1 -1
  117. package/dist/api/v2/query.js +10 -29
  118. package/dist/api/v2/query.test.js +15 -24
  119. package/dist/api/v2/validation.d.ts +28 -0
  120. package/dist/api/v2/validation.js +23 -0
  121. package/dist/client.d.ts +20 -14
  122. package/dist/client.js +22 -16
  123. package/dist/config.d.ts +35 -10
  124. package/dist/http/axios-client.d.ts +4 -4
  125. package/dist/http/http-client.d.ts +3 -3
  126. package/dist/http/http-client.js +19 -40
  127. package/dist/http/interceptors.d.ts +3 -3
  128. package/dist/http/interceptors.js +16 -3
  129. package/dist/http/rate-limiter.js +2 -13
  130. package/dist/http/rate-limiter.test.js +15 -24
  131. package/dist/index.d.ts +7 -2
  132. package/dist/index.js +12 -1
  133. package/dist/index.test.js +13 -5
  134. package/dist/pagination/fetch-all-pages.js +18 -29
  135. package/dist/pagination/fetch-all-pages.test.js +15 -24
  136. package/dist/types/api.d.ts +1 -1
  137. package/dist/utils/env.d.ts +11 -2
  138. package/dist/utils/env.js +41 -8
  139. package/dist/utils/env.test.js +14 -4
  140. package/dist/utils/logger.js +5 -4
  141. package/dist/utils/retry.js +17 -28
  142. package/dist/utils/retry.test.js +9 -18
  143. package/dist/utils/secret-string.test.d.ts +1 -0
  144. package/dist/utils/secret-string.test.js +25 -0
  145. package/package.json +12 -4
  146. package/src/agentops/apply-agent-change.ts +82 -0
  147. package/src/agentops/apply-bundle-diff.test.ts +453 -0
  148. package/src/agentops/apply-bundle-diff.ts +63 -0
  149. package/src/agentops/apply-context.ts +23 -0
  150. package/src/agentops/apply-evaluation-change.ts +125 -0
  151. package/src/agentops/fetch-bundle-state.test.ts +51 -0
  152. package/src/agentops/fetch-bundle-state.ts +33 -0
  153. package/src/agentops/index.ts +11 -0
  154. package/src/agentops/resolve-evaluation-run.ts +94 -0
  155. package/src/api/v1/ai-agents/admin.ts +41 -0
  156. package/src/api/v1/ai-agents/agents.ts +40 -0
  157. package/src/api/v1/ai-agents/artifacts.test.ts +84 -0
  158. package/src/api/v1/ai-agents/artifacts.ts +92 -0
  159. package/src/api/v1/ai-agents/discovery.test.ts +102 -0
  160. package/src/api/v1/ai-agents/discovery.ts +79 -0
  161. package/src/api/v1/ai-agents/evaluations.ts +152 -0
  162. package/src/api/v1/ai-agents/facade.ts +489 -0
  163. package/src/api/v1/ai-agents/feedback.test.ts +30 -0
  164. package/src/api/v1/ai-agents/feedback.ts +24 -0
  165. package/src/api/v1/ai-agents/index.ts +1 -0
  166. package/src/api/v1/ai-agents/mcp-servers.test.ts +81 -0
  167. package/src/api/v1/ai-agents/mcp-servers.ts +67 -0
  168. package/src/api/v1/ai-agents/request-options.ts +32 -0
  169. package/src/api/v1/ai-agents/sql-approval.test.ts +32 -0
  170. package/src/api/v1/ai-agents/sql-approval.ts +24 -0
  171. package/src/api/v1/ai-agents/threads.test.ts +55 -0
  172. package/src/api/v1/ai-agents/threads.ts +216 -0
  173. package/src/api/v1/ai-agents.test.ts +189 -13
  174. package/src/api/v1/analytics.test.ts +32 -0
  175. package/src/api/v1/analytics.ts +16 -0
  176. package/src/api/v1/charts.test.ts +8 -6
  177. package/src/api/v1/charts.ts +8 -4
  178. package/src/api/v1/dashboards.test.ts +57 -0
  179. package/src/api/v1/dashboards.ts +41 -2
  180. package/src/api/v1/explores.test.ts +22 -0
  181. package/src/api/v1/explores.ts +13 -2
  182. package/src/api/v1/groups.test.ts +2 -0
  183. package/src/api/v1/groups.ts +9 -7
  184. package/src/api/v1/metrics.test.ts +2 -0
  185. package/src/api/v1/metrics.ts +3 -2
  186. package/src/api/v1/organizations.test.ts +2 -0
  187. package/src/api/v1/organizations.ts +2 -1
  188. package/src/api/v1/project-access.test.ts +3 -1
  189. package/src/api/v1/project-access.ts +2 -1
  190. package/src/api/v1/projects.test.ts +2 -0
  191. package/src/api/v1/projects.ts +2 -1
  192. package/src/api/v1/query.test.ts +2 -0
  193. package/src/api/v1/query.ts +6 -2
  194. package/src/api/v1/schedulers.test.ts +2 -0
  195. package/src/api/v1/schedulers.ts +3 -2
  196. package/src/api/v1/spaces.test.ts +2 -0
  197. package/src/api/v1/spaces.ts +2 -1
  198. package/src/api/v1/tags.test.ts +2 -0
  199. package/src/api/v1/tags.ts +2 -1
  200. package/src/api/v1/users.test.ts +26 -0
  201. package/src/api/v1/users.ts +8 -2
  202. package/src/api/v1/validation.test.ts +2 -0
  203. package/src/api/v1/validation.ts +6 -2
  204. package/src/api/v2/content.test.ts +2 -0
  205. package/src/api/v2/content.ts +3 -2
  206. package/src/api/v2/dashboards.test.ts +32 -0
  207. package/src/api/v2/dashboards.ts +18 -0
  208. package/src/api/v2/organization-roles.test.ts +2 -0
  209. package/src/api/v2/organization-roles.ts +2 -1
  210. package/src/api/v2/project-role-assignments.test.ts +2 -0
  211. package/src/api/v2/project-role-assignments.ts +2 -1
  212. package/src/api/v2/query.test.ts +2 -0
  213. package/src/api/v2/query.ts +2 -1
  214. package/src/api/v2/validation.ts +48 -0
  215. package/src/client.test.ts +1 -0
  216. package/src/client.ts +27 -17
  217. package/src/config.ts +38 -10
  218. package/src/errors.test.ts +1 -0
  219. package/src/http/axios-client.ts +8 -5
  220. package/src/http/http-client.ts +8 -6
  221. package/src/http/interceptors.ts +23 -10
  222. package/src/http/rate-limiter.test.ts +1 -0
  223. package/src/http/rate-limiter.ts +3 -1
  224. package/src/index.test.ts +16 -7
  225. package/src/index.ts +16 -1
  226. package/src/pagination/fetch-all-pages.test.ts +2 -0
  227. package/src/types/api.ts +1 -1
  228. package/src/utils/env.test.ts +16 -4
  229. package/src/utils/env.ts +61 -10
  230. package/src/utils/logger.ts +6 -4
  231. package/src/utils/retry.test.ts +1 -0
  232. package/src/utils/retry.ts +2 -1
  233. package/src/utils/secret-string.test.ts +27 -0
  234. package/tsconfig.json +4 -2
  235. package/dist/api/v1/ai-agents.d.ts +0 -63
  236. package/dist/api/v1/ai-agents.js +0 -173
  237. package/src/api/v1/ai-agents.ts +0 -252
package/dist/client.js CHANGED
@@ -4,29 +4,32 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LightdashClient = exports.V2ApiClients = exports.V1ApiClients = void 0;
7
- const env_1 = require("./utils/env");
8
- const axios_client_1 = require("./http/axios-client");
9
- const rate_limiter_1 = require("./http/rate-limiter");
10
- const http_client_1 = require("./http/http-client");
11
- const projects_1 = require("./api/v1/projects");
12
- const organizations_1 = require("./api/v1/organizations");
7
+ const ai_agents_1 = require("./api/v1/ai-agents");
8
+ const analytics_1 = require("./api/v1/analytics");
13
9
  const charts_1 = require("./api/v1/charts");
14
10
  const dashboards_1 = require("./api/v1/dashboards");
15
- const spaces_1 = require("./api/v1/spaces");
16
- const query_1 = require("./api/v1/query");
17
- const query_2 = require("./api/v2/query");
18
- const organization_roles_1 = require("./api/v2/organization-roles");
19
- const project_role_assignments_1 = require("./api/v2/project-role-assignments");
20
- const users_1 = require("./api/v1/users");
21
- const groups_1 = require("./api/v1/groups");
22
- const ai_agents_1 = require("./api/v1/ai-agents");
23
- const project_access_1 = require("./api/v1/project-access");
24
11
  const explores_1 = require("./api/v1/explores");
25
- const validation_1 = require("./api/v1/validation");
12
+ const groups_1 = require("./api/v1/groups");
26
13
  const metrics_1 = require("./api/v1/metrics");
14
+ const organizations_1 = require("./api/v1/organizations");
15
+ const project_access_1 = require("./api/v1/project-access");
16
+ const projects_1 = require("./api/v1/projects");
17
+ const query_1 = require("./api/v1/query");
27
18
  const schedulers_1 = require("./api/v1/schedulers");
19
+ const spaces_1 = require("./api/v1/spaces");
28
20
  const tags_1 = require("./api/v1/tags");
21
+ const users_1 = require("./api/v1/users");
22
+ const validation_1 = require("./api/v1/validation");
29
23
  const content_1 = require("./api/v2/content");
24
+ const dashboards_2 = require("./api/v2/dashboards");
25
+ const organization_roles_1 = require("./api/v2/organization-roles");
26
+ const project_role_assignments_1 = require("./api/v2/project-role-assignments");
27
+ const query_2 = require("./api/v2/query");
28
+ const validation_2 = require("./api/v2/validation");
29
+ const axios_client_1 = require("./http/axios-client");
30
+ const http_client_1 = require("./http/http-client");
31
+ const rate_limiter_1 = require("./http/rate-limiter");
32
+ const env_1 = require("./utils/env");
30
33
  /**
31
34
  * V1 API clients namespace. Contains all v1 API clients.
32
35
  */
@@ -47,6 +50,7 @@ class V1ApiClients {
47
50
  this.metrics = new metrics_1.MetricsClient(http);
48
51
  this.schedulers = new schedulers_1.SchedulersClient(http);
49
52
  this.tags = new tags_1.TagsClient(http);
53
+ this.analytics = new analytics_1.AnalyticsClient(http);
50
54
  }
51
55
  }
52
56
  exports.V1ApiClients = V1ApiClients;
@@ -59,6 +63,8 @@ class V2ApiClients {
59
63
  this.organizationRoles = new organization_roles_1.OrganizationRolesClient(http);
60
64
  this.projectRoleAssignments = new project_role_assignments_1.ProjectRoleAssignmentsClient(http);
61
65
  this.content = new content_1.ContentClient(http);
66
+ this.validation = new validation_2.ValidationClientV2(http);
67
+ this.dashboards = new dashboards_2.DashboardsClientV2(http);
62
68
  }
63
69
  }
64
70
  exports.V2ApiClients = V2ApiClients;
package/dist/config.d.ts CHANGED
@@ -49,15 +49,17 @@ export interface ObservabilityHooks {
49
49
  error?: Error;
50
50
  }): void;
51
51
  }
52
- /**
53
- * Full configuration for the Lightdash HTTP client.
54
- * All fields except rateLimit, timeout, retry, and logger can be provided via environment variables.
55
- */
56
- export interface LightdashClientConfig {
52
+ /** Upstream Lightdash authentication scheme. */
53
+ export type LightdashAuthConfig = {
54
+ type: 'api-key';
55
+ token: SecretString;
56
+ } | {
57
+ type: 'bearer';
58
+ token: SecretString;
59
+ };
60
+ interface LightdashClientConfigBase {
57
61
  /** Lightdash server base URL (e.g. https://app.lightdash.cloud). */
58
62
  baseUrl: string;
59
- /** Personal access token for API authentication (without ldpat_ prefix). */
60
- personalAccessToken: SecretString;
61
63
  /** Optional proxy authorization header value for proxied access. */
62
64
  proxyAuthorization?: SecretString;
63
65
  /** Override default rate limits. */
@@ -71,13 +73,35 @@ export interface LightdashClientConfig {
71
73
  /** Optional hooks for metrics/telemetry. */
72
74
  observability?: ObservabilityHooks;
73
75
  }
76
+ /**
77
+ * Resolved client configuration after mergeConfig().
78
+ * Runtime code paths always receive this shape with auth populated.
79
+ */
80
+ export type ResolvedLightdashClientConfig = LightdashClientConfigBase & {
81
+ auth: LightdashAuthConfig;
82
+ /**
83
+ * @deprecated Use `auth: { type: 'api-key', token }`. Retained when auth is api-key.
84
+ */
85
+ personalAccessToken?: SecretString;
86
+ };
87
+ /**
88
+ * Full configuration for the Lightdash HTTP client.
89
+ * Accepts explicit auth or deprecated personalAccessToken-only input.
90
+ */
91
+ export type LightdashClientConfig = ResolvedLightdashClientConfig | (LightdashClientConfigBase & {
92
+ personalAccessToken: SecretString;
93
+ });
74
94
  /**
75
95
  * Partial config for merging with environment variables.
76
96
  * Used when constructing the client with optional explicit overrides.
77
97
  */
78
- export type PartialLightdashClientConfig = Partial<Omit<LightdashClientConfig, 'personalAccessToken' | 'proxyAuthorization'>> & {
79
- personalAccessToken?: string | SecretString;
80
- proxyAuthorization?: string | SecretString;
98
+ export type PartialLightdashClientConfig = Partial<Omit<LightdashClientConfigBase, 'proxyAuthorization'>> & {
99
+ auth?: LightdashAuthConfig | {
100
+ type: 'api-key' | 'bearer';
101
+ token: SecretString | string;
102
+ };
103
+ personalAccessToken?: SecretString | string;
104
+ proxyAuthorization?: SecretString | string;
81
105
  };
82
106
  /** Default rate limit: 10 req/sec, 5 concurrent, token bucket. */
83
107
  export declare const DEFAULT_RATE_LIMIT: Required<RateLimitConfig>;
@@ -85,3 +109,4 @@ export declare const DEFAULT_RATE_LIMIT: Required<RateLimitConfig>;
85
109
  export declare const DEFAULT_TIMEOUT = 30000;
86
110
  /** Default retry config. */
87
111
  export declare const DEFAULT_RETRY: Required<RetryConfig>;
112
+ export {};
@@ -2,7 +2,7 @@
2
2
  * Axios instance setup with base URL, timeout, and interceptors.
3
3
  */
4
4
  import { type AxiosInstance } from 'axios';
5
- import type { LightdashClientConfig } from '../config';
5
+ import type { ResolvedLightdashClientConfig } from '../config';
6
6
  /**
7
7
  * API version type.
8
8
  */
@@ -10,13 +10,13 @@ export type ApiVersion = 'v1' | 'v2';
10
10
  /**
11
11
  * Creates a configured Axios instance for the Lightdash API v1.
12
12
  */
13
- export declare function createAxiosInstanceV1(config: LightdashClientConfig): AxiosInstance;
13
+ export declare function createAxiosInstanceV1(config: ResolvedLightdashClientConfig): AxiosInstance;
14
14
  /**
15
15
  * Creates a configured Axios instance for the Lightdash API v2.
16
16
  */
17
- export declare function createAxiosInstanceV2(config: LightdashClientConfig): AxiosInstance;
17
+ export declare function createAxiosInstanceV2(config: ResolvedLightdashClientConfig): AxiosInstance;
18
18
  /**
19
19
  * Creates a configured Axios instance for the Lightdash API v1.
20
20
  * @deprecated Use `createAxiosInstanceV1` instead. This function is kept for backward compatibility.
21
21
  */
22
- export declare function createAxiosInstance(config: LightdashClientConfig): AxiosInstance;
22
+ export declare function createAxiosInstance(config: ResolvedLightdashClientConfig): AxiosInstance;
@@ -2,10 +2,10 @@
2
2
  * HTTP client wrapper: rate limiter + axios + retry.
3
3
  * All requests go through the rate limiter; retry applies to 5xx and network errors.
4
4
  */
5
- import type { AxiosInstance, AxiosRequestConfig } from 'axios';
6
- import type { LightdashClientConfig } from '../config';
7
5
  import { type ApiErrorPayload } from '../errors';
8
6
  import { type RateLimiter } from './rate-limiter';
7
+ import type { ResolvedLightdashClientConfig } from '../config';
8
+ import type { AxiosInstance, AxiosRequestConfig } from 'axios';
9
9
  /** Lightdash API success response shape. */
10
10
  export interface ApiSuccessBody<T = unknown> {
11
11
  status: 'ok';
@@ -23,7 +23,7 @@ export declare class HttpClient {
23
23
  private readonly axiosInstance;
24
24
  private readonly rateLimiter;
25
25
  private readonly config;
26
- constructor(axiosInstance: AxiosInstance, rateLimiter: RateLimiter, config: LightdashClientConfig);
26
+ constructor(axiosInstance: AxiosInstance, rateLimiter: RateLimiter, config: ResolvedLightdashClientConfig);
27
27
  private request;
28
28
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
29
29
  post<T>(url: string, body?: unknown, config?: AxiosRequestConfig): Promise<T>;
@@ -3,15 +3,6 @@
3
3
  * HTTP client wrapper: rate limiter + axios + retry.
4
4
  * All requests go through the rate limiter; retry applies to 5xx and network errors.
5
5
  */
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  Object.defineProperty(exports, "__esModule", { value: true });
16
7
  exports.HttpClient = void 0;
17
8
  const errors_1 = require("../errors");
@@ -28,42 +19,30 @@ class HttpClient {
28
19
  this.rateLimiter = rateLimiter;
29
20
  this.config = config;
30
21
  }
31
- request(method, url, config) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const doRequest = () => this.axiosInstance.request(Object.assign(Object.assign({}, config), { method,
34
- url }));
35
- const response = yield this.rateLimiter.schedule(() => (0, retry_1.withRetry)(doRequest, this.config.retry));
36
- const data = response.data;
37
- if (!assertSuccess(data)) {
38
- throw new errors_1.LightdashApiError(data.error.statusCode, data.error, response.config, response);
39
- }
40
- return data.results;
41
- });
22
+ async request(method, url, config) {
23
+ const doRequest = () => this.axiosInstance.request(Object.assign(Object.assign({}, config), { method,
24
+ url }));
25
+ const response = await this.rateLimiter.schedule(() => (0, retry_1.withRetry)(doRequest, this.config.retry));
26
+ const data = response.data;
27
+ if (!assertSuccess(data)) {
28
+ throw new errors_1.LightdashApiError(data.error.statusCode, data.error, response.config, response);
29
+ }
30
+ return data.results;
42
31
  }
43
- get(url, config) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- return this.request('GET', url, config);
46
- });
32
+ async get(url, config) {
33
+ return this.request('GET', url, config);
47
34
  }
48
- post(url, body, config) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return this.request('POST', url, Object.assign(Object.assign({}, config), { data: body }));
51
- });
35
+ async post(url, body, config) {
36
+ return this.request('POST', url, Object.assign(Object.assign({}, config), { data: body }));
52
37
  }
53
- put(url, body, config) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return this.request('PUT', url, Object.assign(Object.assign({}, config), { data: body }));
56
- });
38
+ async put(url, body, config) {
39
+ return this.request('PUT', url, Object.assign(Object.assign({}, config), { data: body }));
57
40
  }
58
- patch(url, body, config) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- return this.request('PATCH', url, Object.assign(Object.assign({}, config), { data: body }));
61
- });
41
+ async patch(url, body, config) {
42
+ return this.request('PATCH', url, Object.assign(Object.assign({}, config), { data: body }));
62
43
  }
63
- delete(url, config) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- return this.request('DELETE', url, config);
66
- });
44
+ async delete(url, config) {
45
+ return this.request('DELETE', url, config);
67
46
  }
68
47
  }
69
48
  exports.HttpClient = HttpClient;
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Request and response interceptors for auth, proxy, and error handling.
3
3
  */
4
+ import type { ResolvedLightdashClientConfig } from '../config';
4
5
  import type { AxiosInstance } from 'axios';
5
- import type { LightdashClientConfig } from '../config';
6
6
  /**
7
7
  * Attaches request interceptors: Authorization, Proxy-Authorization, optional request ID and logging.
8
8
  */
9
- export declare function attachRequestInterceptors(axiosInstance: AxiosInstance, config: LightdashClientConfig): void;
9
+ export declare function attachRequestInterceptors(axiosInstance: AxiosInstance, config: ResolvedLightdashClientConfig): void;
10
10
  /**
11
11
  * Attaches response interceptors: parse API responses, transform errors to LightdashApiError / RateLimitError.
12
12
  */
13
- export declare function attachResponseInterceptors(axiosInstance: AxiosInstance, config?: Pick<LightdashClientConfig, 'logger' | 'observability'>): void;
13
+ export declare function attachResponseInterceptors(axiosInstance: AxiosInstance, config?: Pick<ResolvedLightdashClientConfig, 'logger' | 'observability'>): void;
@@ -18,9 +18,22 @@ function getRetryAfterSeconds(value) {
18
18
  function attachRequestInterceptors(axiosInstance, config) {
19
19
  axiosInstance.interceptors.request.use((req) => {
20
20
  var _a;
21
- const rawToken = config.personalAccessToken.expose();
22
- const token = rawToken.startsWith('ldpat_') ? rawToken : `ldpat_${rawToken}`;
23
- req.headers.Authorization = `ApiKey ${token}`;
21
+ switch (config.auth.type) {
22
+ case 'api-key': {
23
+ const rawToken = config.auth.token.expose();
24
+ const token = rawToken.startsWith('ldpat_') ? rawToken : `ldpat_${rawToken}`;
25
+ req.headers.Authorization = `ApiKey ${token}`;
26
+ break;
27
+ }
28
+ case 'bearer': {
29
+ req.headers.Authorization = `Bearer ${config.auth.token.expose()}`;
30
+ break;
31
+ }
32
+ default: {
33
+ const _exhaustive = config.auth;
34
+ throw new Error(`Unsupported auth type: ${_exhaustive.type}`);
35
+ }
36
+ }
24
37
  if (config.proxyAuthorization) {
25
38
  req.headers['Proxy-Authorization'] = config.proxyAuthorization.expose();
26
39
  }
@@ -3,15 +3,6 @@
3
3
  * Rate limiter wrapping Bottleneck for centralized request throttling.
4
4
  * Uses token bucket algorithm; handles 429 retries via Bottleneck options.
5
5
  */
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
6
  var __importDefault = (this && this.__importDefault) || function (mod) {
16
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
8
  };
@@ -51,10 +42,8 @@ class RateLimiter {
51
42
  return (...args) => this.limiter.schedule(() => fn(...args));
52
43
  }
53
44
  /** Stops the limiter and drains remaining jobs. */
54
- disconnect() {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- return this.limiter.disconnect(true);
57
- });
45
+ async disconnect() {
46
+ return this.limiter.disconnect(true);
58
47
  }
59
48
  }
60
49
  exports.RateLimiter = RateLimiter;
@@ -1,40 +1,31 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const vitest_1 = require("vitest");
13
4
  const rate_limiter_1 = require("./rate-limiter");
14
5
  (0, vitest_1.describe)('RateLimiter', () => {
15
- (0, vitest_1.it)('should schedule and run a single task', () => __awaiter(void 0, void 0, void 0, function* () {
6
+ (0, vitest_1.it)('should schedule and run a single task', async () => {
16
7
  const limiter = new rate_limiter_1.RateLimiter({ minTime: 0, maxConcurrent: 1 });
17
- const result = yield limiter.schedule(() => __awaiter(void 0, void 0, void 0, function* () { return 42; }));
8
+ const result = await limiter.schedule(async () => 42);
18
9
  (0, vitest_1.expect)(result).toBe(42);
19
- yield limiter.disconnect();
20
- }));
21
- (0, vitest_1.it)('should run tasks sequentially when maxConcurrent is 1', () => __awaiter(void 0, void 0, void 0, function* () {
10
+ await limiter.disconnect();
11
+ });
12
+ (0, vitest_1.it)('should run tasks sequentially when maxConcurrent is 1', async () => {
22
13
  const limiter = new rate_limiter_1.RateLimiter({ minTime: 10, maxConcurrent: 1 });
23
14
  const order = [];
24
- const promises = [1, 2, 3].map((n) => limiter.schedule(() => __awaiter(void 0, void 0, void 0, function* () {
15
+ const promises = [1, 2, 3].map((n) => limiter.schedule(async () => {
25
16
  order.push(n);
26
17
  return n;
27
- })));
28
- const results = yield Promise.all(promises);
18
+ }));
19
+ const results = await Promise.all(promises);
29
20
  (0, vitest_1.expect)(results).toEqual([1, 2, 3]);
30
21
  (0, vitest_1.expect)(order).toEqual([1, 2, 3]);
31
- yield limiter.disconnect();
32
- }));
33
- (0, vitest_1.it)('should wrap a function', () => __awaiter(void 0, void 0, void 0, function* () {
22
+ await limiter.disconnect();
23
+ });
24
+ (0, vitest_1.it)('should wrap a function', async () => {
34
25
  const limiter = new rate_limiter_1.RateLimiter({ minTime: 0 });
35
- const wrapped = limiter.wrap((a, b) => __awaiter(void 0, void 0, void 0, function* () { return a + b; }));
36
- const result = yield wrapped(1, 2);
26
+ const wrapped = limiter.wrap(async (a, b) => a + b);
27
+ const result = await wrapped(1, 2);
37
28
  (0, vitest_1.expect)(result).toBe(3);
38
- yield limiter.disconnect();
39
- }));
29
+ await limiter.disconnect();
30
+ });
40
31
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { LightdashClient, V1ApiClients, V2ApiClients } from './client';
2
+ export { fetchBundleCurrentState, applyBundleDiff, resolveEvaluationRun, type ApplyBundleDiffFailure, type ApplyBundleDiffResult, type ResolveEvaluationRunOptions, type ResolveEvaluationRunResult, } from './agentops';
2
3
  export { UsersClient } from './api/v1/users';
3
4
  export { GroupsClient } from './api/v1/groups';
4
5
  export { OrganizationRolesClient } from './api/v2/organization-roles';
@@ -6,24 +7,28 @@ export { ProjectRoleAssignmentsClient } from './api/v2/project-role-assignments'
6
7
  export { AiAgentsClient } from './api/v1/ai-agents';
7
8
  export { ProjectAccessClient } from './api/v1/project-access';
8
9
  export { ValidationClient } from './api/v1/validation';
10
+ export { ValidationClientV2 } from './api/v2/validation';
9
11
  export { MetricsClient } from './api/v1/metrics';
10
12
  export { SchedulersClient } from './api/v1/schedulers';
11
13
  export { TagsClient } from './api/v1/tags';
14
+ export { AnalyticsClient } from './api/v1/analytics';
12
15
  export { ContentClient } from './api/v2/content';
16
+ export { DashboardsClientV2 } from './api/v2/dashboards';
13
17
  export type { ListMembersParams, ListAllMembersParams } from './api/v1/users';
14
18
  export type { GetValidationResultsParams, ValidateProjectBody } from './api/v1/validation';
19
+ export type { ListValidationResultsParams } from './api/v2/validation';
15
20
  export type { ListMetricsParams } from './api/v1/metrics';
16
21
  export type { ListSchedulersParams } from './api/v1/schedulers';
17
22
  export type { SearchContentParams } from './api/v2/content';
18
23
  export type { ListGroupsParams, ListAllGroupsParams, GetGroupParams, GroupOrGroupWithMembers, } from './api/v1/groups';
19
24
  export type { GetRolesResult, GetRolesParams, AssignOrgRoleToUserBody, } from './api/v2/organization-roles';
20
25
  export type { PartialLightdashClientConfig } from './config';
21
- export type { LightdashClientConfig, RateLimitConfig, RetryConfig, Logger, ObservabilityHooks, } from './config';
26
+ export type { LightdashClientConfig, LightdashAuthConfig, ResolvedLightdashClientConfig, RateLimitConfig, RetryConfig, Logger, ObservabilityHooks, } from './config';
22
27
  export { noopLogger, consoleLogger } from './utils/logger';
23
28
  export { DEFAULT_RATE_LIMIT, DEFAULT_TIMEOUT, DEFAULT_RETRY } from './config';
24
29
  export { LightdashApiError, RateLimitError, NetworkError } from './errors';
25
30
  export type { ApiErrorPayload } from './errors';
26
- export { loadConfigFromEnv, mergeConfig } from './utils/env';
31
+ export { loadConfigFromEnv, mergeConfig, createBearerConfig } from './utils/env';
27
32
  export { ENV_LIGHTDASH_API_KEY, ENV_LIGHTDASH_URL, ENV_LIGHTDASH_PROXY_AUTHORIZATION, } from './utils/env';
28
33
  export { HttpClient } from './http/http-client';
29
34
  export { RateLimiter } from './http/rate-limiter';
package/dist/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SecretString = exports.RateLimiter = exports.HttpClient = exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION = exports.ENV_LIGHTDASH_URL = exports.ENV_LIGHTDASH_API_KEY = exports.mergeConfig = exports.loadConfigFromEnv = exports.NetworkError = exports.RateLimitError = exports.LightdashApiError = exports.DEFAULT_RETRY = exports.DEFAULT_TIMEOUT = exports.DEFAULT_RATE_LIMIT = exports.consoleLogger = exports.noopLogger = exports.ContentClient = exports.TagsClient = exports.SchedulersClient = exports.MetricsClient = exports.ValidationClient = exports.ProjectAccessClient = exports.AiAgentsClient = exports.ProjectRoleAssignmentsClient = exports.OrganizationRolesClient = exports.GroupsClient = exports.UsersClient = exports.V2ApiClients = exports.V1ApiClients = exports.LightdashClient = void 0;
3
+ exports.SecretString = exports.RateLimiter = exports.HttpClient = exports.ENV_LIGHTDASH_PROXY_AUTHORIZATION = exports.ENV_LIGHTDASH_URL = exports.ENV_LIGHTDASH_API_KEY = exports.createBearerConfig = exports.mergeConfig = exports.loadConfigFromEnv = exports.NetworkError = exports.RateLimitError = exports.LightdashApiError = exports.DEFAULT_RETRY = exports.DEFAULT_TIMEOUT = exports.DEFAULT_RATE_LIMIT = exports.consoleLogger = exports.noopLogger = exports.DashboardsClientV2 = exports.ContentClient = exports.AnalyticsClient = exports.TagsClient = exports.SchedulersClient = exports.MetricsClient = exports.ValidationClientV2 = exports.ValidationClient = exports.ProjectAccessClient = exports.AiAgentsClient = exports.ProjectRoleAssignmentsClient = exports.OrganizationRolesClient = exports.GroupsClient = exports.UsersClient = exports.resolveEvaluationRun = exports.applyBundleDiff = exports.fetchBundleCurrentState = exports.V2ApiClients = exports.V1ApiClients = exports.LightdashClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "LightdashClient", { enumerable: true, get: function () { return client_1.LightdashClient; } });
6
6
  Object.defineProperty(exports, "V1ApiClients", { enumerable: true, get: function () { return client_1.V1ApiClients; } });
7
7
  Object.defineProperty(exports, "V2ApiClients", { enumerable: true, get: function () { return client_1.V2ApiClients; } });
8
+ var agentops_1 = require("./agentops");
9
+ Object.defineProperty(exports, "fetchBundleCurrentState", { enumerable: true, get: function () { return agentops_1.fetchBundleCurrentState; } });
10
+ Object.defineProperty(exports, "applyBundleDiff", { enumerable: true, get: function () { return agentops_1.applyBundleDiff; } });
11
+ Object.defineProperty(exports, "resolveEvaluationRun", { enumerable: true, get: function () { return agentops_1.resolveEvaluationRun; } });
8
12
  var users_1 = require("./api/v1/users");
9
13
  Object.defineProperty(exports, "UsersClient", { enumerable: true, get: function () { return users_1.UsersClient; } });
10
14
  var groups_1 = require("./api/v1/groups");
@@ -19,14 +23,20 @@ var project_access_1 = require("./api/v1/project-access");
19
23
  Object.defineProperty(exports, "ProjectAccessClient", { enumerable: true, get: function () { return project_access_1.ProjectAccessClient; } });
20
24
  var validation_1 = require("./api/v1/validation");
21
25
  Object.defineProperty(exports, "ValidationClient", { enumerable: true, get: function () { return validation_1.ValidationClient; } });
26
+ var validation_2 = require("./api/v2/validation");
27
+ Object.defineProperty(exports, "ValidationClientV2", { enumerable: true, get: function () { return validation_2.ValidationClientV2; } });
22
28
  var metrics_1 = require("./api/v1/metrics");
23
29
  Object.defineProperty(exports, "MetricsClient", { enumerable: true, get: function () { return metrics_1.MetricsClient; } });
24
30
  var schedulers_1 = require("./api/v1/schedulers");
25
31
  Object.defineProperty(exports, "SchedulersClient", { enumerable: true, get: function () { return schedulers_1.SchedulersClient; } });
26
32
  var tags_1 = require("./api/v1/tags");
27
33
  Object.defineProperty(exports, "TagsClient", { enumerable: true, get: function () { return tags_1.TagsClient; } });
34
+ var analytics_1 = require("./api/v1/analytics");
35
+ Object.defineProperty(exports, "AnalyticsClient", { enumerable: true, get: function () { return analytics_1.AnalyticsClient; } });
28
36
  var content_1 = require("./api/v2/content");
29
37
  Object.defineProperty(exports, "ContentClient", { enumerable: true, get: function () { return content_1.ContentClient; } });
38
+ var dashboards_1 = require("./api/v2/dashboards");
39
+ Object.defineProperty(exports, "DashboardsClientV2", { enumerable: true, get: function () { return dashboards_1.DashboardsClientV2; } });
30
40
  var logger_1 = require("./utils/logger");
31
41
  Object.defineProperty(exports, "noopLogger", { enumerable: true, get: function () { return logger_1.noopLogger; } });
32
42
  Object.defineProperty(exports, "consoleLogger", { enumerable: true, get: function () { return logger_1.consoleLogger; } });
@@ -41,6 +51,7 @@ Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function
41
51
  var env_1 = require("./utils/env");
42
52
  Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: function () { return env_1.loadConfigFromEnv; } });
43
53
  Object.defineProperty(exports, "mergeConfig", { enumerable: true, get: function () { return env_1.mergeConfig; } });
54
+ Object.defineProperty(exports, "createBearerConfig", { enumerable: true, get: function () { return env_1.createBearerConfig; } });
44
55
  var env_2 = require("./utils/env");
45
56
  Object.defineProperty(exports, "ENV_LIGHTDASH_API_KEY", { enumerable: true, get: function () { return env_2.ENV_LIGHTDASH_API_KEY; } });
46
57
  Object.defineProperty(exports, "ENV_LIGHTDASH_URL", { enumerable: true, get: function () { return env_2.ENV_LIGHTDASH_URL; } });
@@ -18,8 +18,16 @@ const index_1 = require("./index");
18
18
  });
19
19
  (0, vitest_1.expect)(client.getHttpClientV1()).toBeDefined();
20
20
  });
21
- (0, vitest_1.it)('should throw when baseUrl and personalAccessToken are missing and not in env', () => {
22
- (0, vitest_1.expect)(() => new index_1.LightdashClient({})).toThrow(/baseUrl and personalAccessToken|LIGHTDASH_URL and LIGHTDASH_API_KEY/);
21
+ (0, vitest_1.it)('allows deprecated personalAccessToken-only exported config shape', () => {
22
+ var _a;
23
+ const cfg = {
24
+ baseUrl: 'https://app.lightdash.cloud',
25
+ personalAccessToken: new index_1.SecretString('pat'),
26
+ };
27
+ (0, vitest_1.expect)((_a = cfg.personalAccessToken) === null || _a === void 0 ? void 0 : _a.expose()).toBe('pat');
28
+ });
29
+ (0, vitest_1.it)('should throw when baseUrl and auth credentials are missing and not in env', () => {
30
+ (0, vitest_1.expect)(() => new index_1.LightdashClient({})).toThrow(/baseUrl|auth credentials|LIGHTDASH_URL/);
23
31
  });
24
32
  (0, vitest_1.it)('should merge explicit config with env (explicit wins)', () => {
25
33
  vitest_1.vi.stubEnv(index_1.ENV_LIGHTDASH_URL, 'https://env.example.com');
@@ -30,8 +38,8 @@ const index_1 = require("./index");
30
38
  };
31
39
  const merged = (0, index_1.mergeConfig)(explicit);
32
40
  (0, vitest_1.expect)(merged.baseUrl).toBe('https://custom.example.com');
33
- (0, vitest_1.expect)(merged.personalAccessToken).toBeInstanceOf(index_1.SecretString);
34
- (0, vitest_1.expect)(merged.personalAccessToken.expose()).toBe('explicit-token');
41
+ (0, vitest_1.expect)(merged.auth.token).toBeInstanceOf(index_1.SecretString);
42
+ (0, vitest_1.expect)(merged.auth.token.expose()).toBe('explicit-token');
35
43
  });
36
44
  });
37
45
  (0, vitest_1.describe)('mergeConfig', () => {
@@ -40,7 +48,7 @@ const index_1 = require("./index");
40
48
  vitest_1.vi.stubEnv(index_1.ENV_LIGHTDASH_URL, '');
41
49
  vitest_1.vi.stubEnv(index_1.ENV_LIGHTDASH_PROXY_AUTHORIZATION, '');
42
50
  });
43
- (0, vitest_1.it)('should require baseUrl and personalAccessToken', () => {
51
+ (0, vitest_1.it)('should require baseUrl and auth credentials', () => {
44
52
  (0, vitest_1.expect)(() => (0, index_1.mergeConfig)({})).toThrow();
45
53
  (0, vitest_1.expect)(() => (0, index_1.mergeConfig)({ baseUrl: 'https://x.com' })).toThrow();
46
54
  (0, vitest_1.expect)(() => (0, index_1.mergeConfig)({ personalAccessToken: 't' })).toThrow();
@@ -2,15 +2,6 @@
2
2
  /**
3
3
  * Generic helper to fetch all pages of a Knex-paginated API and return a single array.
4
4
  */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.fetchAllPages = fetchAllPages;
16
7
  const DEFAULT_PAGE_SIZE = 100;
@@ -18,24 +9,22 @@ const DEFAULT_PAGE_SIZE = 100;
18
9
  * Fetches all pages by repeatedly calling fetchPage until no more pages, then returns
19
10
  * the concatenated data array.
20
11
  */
21
- function fetchAllPages(options) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- var _a;
24
- const pageSize = (_a = options.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_PAGE_SIZE;
25
- const all = [];
26
- let page = 1;
27
- let totalPageCount;
28
- do {
29
- const result = yield options.fetchPage(page, pageSize);
30
- all.push(...result.data);
31
- if (result.pagination) {
32
- totalPageCount = result.pagination.totalPageCount;
33
- page += 1;
34
- }
35
- else {
36
- totalPageCount = undefined;
37
- }
38
- } while (totalPageCount !== undefined && page <= totalPageCount);
39
- return all;
40
- });
12
+ async function fetchAllPages(options) {
13
+ var _a;
14
+ const pageSize = (_a = options.pageSize) !== null && _a !== void 0 ? _a : DEFAULT_PAGE_SIZE;
15
+ const all = [];
16
+ let page = 1;
17
+ let totalPageCount;
18
+ do {
19
+ const result = await options.fetchPage(page, pageSize);
20
+ all.push(...result.data);
21
+ if (result.pagination) {
22
+ totalPageCount = result.pagination.totalPageCount;
23
+ page += 1;
24
+ }
25
+ else {
26
+ totalPageCount = undefined;
27
+ }
28
+ } while (totalPageCount !== undefined && page <= totalPageCount);
29
+ return all;
41
30
  }