@kombo-api/sdk 0.2.3 → 0.3.2
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.
- package/README.md +7 -7
- package/_speakeasy/.github/action-inputs-config.json +53 -0
- package/_speakeasy/.github/action-security-config.json +88 -0
- package/esm/funcs/assessmentGetOpenOrders.js +1 -1
- package/esm/funcs/assessmentGetOpenOrders.js.map +1 -1
- package/esm/funcs/atsGetApplicationStages.js +1 -1
- package/esm/funcs/atsGetApplicationStages.js.map +1 -1
- package/esm/funcs/atsGetApplications.js +1 -1
- package/esm/funcs/atsGetApplications.js.map +1 -1
- package/esm/funcs/atsGetCandidates.js +1 -1
- package/esm/funcs/atsGetCandidates.js.map +1 -1
- package/esm/funcs/atsGetInterviews.js +1 -1
- package/esm/funcs/atsGetInterviews.js.map +1 -1
- package/esm/funcs/atsGetJobs.js +1 -1
- package/esm/funcs/atsGetJobs.js.map +1 -1
- package/esm/funcs/atsGetOffers.js +1 -1
- package/esm/funcs/atsGetOffers.js.map +1 -1
- package/esm/funcs/atsGetRejectionReasons.js +1 -1
- package/esm/funcs/atsGetRejectionReasons.js.map +1 -1
- package/esm/funcs/atsGetTags.js +1 -1
- package/esm/funcs/atsGetTags.js.map +1 -1
- package/esm/funcs/atsGetUsers.js +1 -1
- package/esm/funcs/atsGetUsers.js.map +1 -1
- package/esm/funcs/generalGetCustomFields.js +1 -1
- package/esm/funcs/generalGetCustomFields.js.map +1 -1
- package/esm/funcs/generalGetIntegrationFields.js +1 -1
- package/esm/funcs/generalGetIntegrationFields.js.map +1 -1
- package/esm/funcs/generalSendPassthroughRequest.d.ts +9 -1
- package/esm/funcs/generalSendPassthroughRequest.d.ts.map +1 -1
- package/esm/funcs/generalSendPassthroughRequest.js +9 -1
- package/esm/funcs/generalSendPassthroughRequest.js.map +1 -1
- package/esm/funcs/hrisGetAbsenceTypes.js +1 -1
- package/esm/funcs/hrisGetAbsenceTypes.js.map +1 -1
- package/esm/funcs/hrisGetAbsences.js +1 -1
- package/esm/funcs/hrisGetAbsences.js.map +1 -1
- package/esm/funcs/hrisGetEmployeeDocumentCategories.js +1 -1
- package/esm/funcs/hrisGetEmployeeDocumentCategories.js.map +1 -1
- package/esm/funcs/hrisGetEmployees.js +1 -1
- package/esm/funcs/hrisGetEmployees.js.map +1 -1
- package/esm/funcs/hrisGetEmployments.js +1 -1
- package/esm/funcs/hrisGetEmployments.js.map +1 -1
- package/esm/funcs/hrisGetGroups.js +1 -1
- package/esm/funcs/hrisGetGroups.js.map +1 -1
- package/esm/funcs/hrisGetLegalEntities.js +1 -1
- package/esm/funcs/hrisGetLegalEntities.js.map +1 -1
- package/esm/funcs/hrisGetLocations.js +1 -1
- package/esm/funcs/hrisGetLocations.js.map +1 -1
- package/esm/funcs/hrisGetPerformanceReviewCycles.js +1 -1
- package/esm/funcs/hrisGetPerformanceReviewCycles.js.map +1 -1
- package/esm/funcs/hrisGetPerformanceReviews.js +1 -1
- package/esm/funcs/hrisGetPerformanceReviews.js.map +1 -1
- package/esm/funcs/hrisGetTimeOffBalances.js +1 -1
- package/esm/funcs/hrisGetTimeOffBalances.js.map +1 -1
- package/esm/funcs/hrisGetTimesheets.js +1 -1
- package/esm/funcs/hrisGetTimesheets.js.map +1 -1
- package/esm/funcs/validateWebhook.d.ts +13 -0
- package/esm/funcs/validateWebhook.d.ts.map +1 -0
- package/esm/funcs/validateWebhook.js +34 -0
- package/esm/funcs/validateWebhook.js.map +1 -0
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/encodings.d.ts +1 -0
- package/esm/lib/encodings.d.ts.map +1 -1
- package/esm/lib/encodings.js +12 -1
- package/esm/lib/encodings.js.map +1 -1
- package/esm/models/assessmentorderreceivedwebhookpayload.d.ts +5 -5
- package/esm/models/assessmentorderreceivedwebhookpayload.d.ts.map +1 -1
- package/esm/models/assessmentorderreceivedwebhookpayload.js +2 -2
- package/esm/models/assessmentorderreceivedwebhookpayload.js.map +1 -1
- package/esm/models/connectionflowfailedwebhookpayload.d.ts +4 -3
- package/esm/models/connectionflowfailedwebhookpayload.d.ts.map +1 -1
- package/esm/models/connectionflowfailedwebhookpayload.js +2 -1
- package/esm/models/connectionflowfailedwebhookpayload.js.map +1 -1
- package/esm/models/datachangedwebhookpayload.d.ts +11 -3
- package/esm/models/datachangedwebhookpayload.d.ts.map +1 -1
- package/esm/models/datachangedwebhookpayload.js +9 -1
- package/esm/models/datachangedwebhookpayload.js.map +1 -1
- package/esm/models/getassessmentordersopenpositiveresponse.d.ts +4 -4
- package/esm/models/getassessmentordersopenpositiveresponse.d.ts.map +1 -1
- package/esm/models/getassessmentordersopenpositiveresponse.js +1 -1
- package/esm/models/getassessmentordersopenpositiveresponse.js.map +1 -1
- package/esm/models/getatsjobspositiveresponse.d.ts +3 -3
- package/esm/models/getatsjobspositiveresponse.d.ts.map +1 -1
- package/esm/models/getatsjobspositiveresponse.js +4 -4
- package/esm/models/getatsjobspositiveresponse.js.map +1 -1
- package/esm/models/gethrisemployeesformpositiveresponse.d.ts +2 -2
- package/esm/models/gethrisemployeesformpositiveresponse.d.ts.map +1 -1
- package/esm/models/gethrisemployeesformpositiveresponse.js +8 -8
- package/esm/models/gethrisemployeesformpositiveresponse.js.map +1 -1
- package/esm/models/getintegrationsintegrationidpositiveresponse.d.ts +158 -16
- package/esm/models/getintegrationsintegrationidpositiveresponse.d.ts.map +1 -1
- package/esm/models/getintegrationsintegrationidpositiveresponse.js +87 -13
- package/esm/models/getintegrationsintegrationidpositiveresponse.js.map +1 -1
- package/esm/models/gettoolscategoryparametercategory.d.ts +1 -0
- package/esm/models/gettoolscategoryparametercategory.d.ts.map +1 -1
- package/esm/models/gettoolscategoryparametercategory.js +1 -0
- package/esm/models/gettoolscategoryparametercategory.js.map +1 -1
- package/esm/models/gettoolscategorypositiveresponse.d.ts +66 -16
- package/esm/models/gettoolscategorypositiveresponse.d.ts.map +1 -1
- package/esm/models/gettoolscategorypositiveresponse.js +41 -14
- package/esm/models/gettoolscategorypositiveresponse.js.map +1 -1
- package/esm/models/inlineassessmentorderreceivedwebhookpayload.d.ts +5 -5
- package/esm/models/inlineassessmentorderreceivedwebhookpayload.d.ts.map +1 -1
- package/esm/models/inlineassessmentorderreceivedwebhookpayload.js +2 -2
- package/esm/models/inlineassessmentorderreceivedwebhookpayload.js.map +1 -1
- package/esm/models/integrationcreatedwebhookpayload.d.ts +1 -0
- package/esm/models/integrationcreatedwebhookpayload.d.ts.map +1 -1
- package/esm/models/integrationcreatedwebhookpayload.js +1 -0
- package/esm/models/integrationcreatedwebhookpayload.js.map +1 -1
- package/esm/models/integrationdeletedwebhookpayload.d.ts +1 -0
- package/esm/models/integrationdeletedwebhookpayload.d.ts.map +1 -1
- package/esm/models/integrationdeletedwebhookpayload.js +1 -0
- package/esm/models/integrationdeletedwebhookpayload.js.map +1 -1
- package/esm/models/integrationstatechangedwebhookpayload.d.ts +4 -3
- package/esm/models/integrationstatechangedwebhookpayload.d.ts.map +1 -1
- package/esm/models/integrationstatechangedwebhookpayload.js +2 -1
- package/esm/models/integrationstatechangedwebhookpayload.js.map +1 -1
- package/esm/models/kombohriserror.d.ts +1 -0
- package/esm/models/kombohriserror.d.ts.map +1 -1
- package/esm/models/kombohriserror.js +1 -0
- package/esm/models/kombohriserror.js.map +1 -1
- package/esm/models/postatscandidatesrequestbody.d.ts +27 -0
- package/esm/models/postatscandidatesrequestbody.d.ts.map +1 -1
- package/esm/models/postatscandidatesrequestbody.js +10 -0
- package/esm/models/postatscandidatesrequestbody.js.map +1 -1
- package/esm/models/postatsjobsjobidapplicationsrequestbody.d.ts +27 -0
- package/esm/models/postatsjobsjobidapplicationsrequestbody.d.ts.map +1 -1
- package/esm/models/postatsjobsjobidapplicationsrequestbody.js +9 -0
- package/esm/models/postatsjobsjobidapplicationsrequestbody.js.map +1 -1
- package/esm/models/postconnectcreatelinkrequestbody.d.ts +5 -0
- package/esm/models/postconnectcreatelinkrequestbody.d.ts.map +1 -1
- package/esm/models/postconnectcreatelinkrequestbody.js +5 -0
- package/esm/models/postconnectcreatelinkrequestbody.js.map +1 -1
- package/esm/models/posthrisemployeesformpositiveresponse.d.ts +15 -3
- package/esm/models/posthrisemployeesformpositiveresponse.d.ts.map +1 -1
- package/esm/models/posthrisemployeesformpositiveresponse.js +8 -1
- package/esm/models/posthrisemployeesformpositiveresponse.js.map +1 -1
- package/esm/models/putassessmentordersassessmentorderidresultrequestbody.d.ts +4 -4
- package/esm/models/putassessmentordersassessmentorderidresultrequestbody.d.ts.map +1 -1
- package/esm/models/putassessmentordersassessmentorderidresultrequestbody.js +2 -2
- package/esm/models/putassessmentordersassessmentorderidresultrequestbody.js.map +1 -1
- package/esm/models/schema1union1.d.ts +1 -1
- package/esm/models/schema1union1.d.ts.map +1 -1
- package/esm/models/schema1union1.js +4 -4
- package/esm/models/schema1union1.js.map +1 -1
- package/esm/models/schema1union2.d.ts +1 -1
- package/esm/models/schema1union2.d.ts.map +1 -1
- package/esm/models/schema1union2.js +4 -4
- package/esm/models/schema1union2.js.map +1 -1
- package/esm/models/schema2union1.d.ts +2 -2
- package/esm/models/schema2union1.d.ts.map +1 -1
- package/esm/models/schema2union1.js +8 -8
- package/esm/models/schema2union1.js.map +1 -1
- package/esm/models/schema2union2.d.ts +2 -2
- package/esm/models/schema2union2.d.ts.map +1 -1
- package/esm/models/schema2union2.js +8 -8
- package/esm/models/schema2union2.js.map +1 -1
- package/esm/models/syncfinishedwebhookpayload.d.ts +4 -3
- package/esm/models/syncfinishedwebhookpayload.d.ts.map +1 -1
- package/esm/models/syncfinishedwebhookpayload.js +2 -1
- package/esm/models/syncfinishedwebhookpayload.js.map +1 -1
- package/esm/sdk/general.d.ts +9 -1
- package/esm/sdk/general.d.ts.map +1 -1
- package/esm/sdk/general.js +9 -1
- package/esm/sdk/general.js.map +1 -1
- package/esm/sdk/sdk.d.ts +9 -0
- package/esm/sdk/sdk.d.ts.map +1 -1
- package/esm/sdk/sdk.js +5 -0
- package/esm/sdk/sdk.js.map +1 -1
- package/esm/types/enums.d.ts +1 -8
- package/esm/types/enums.d.ts.map +1 -1
- package/esm/types/enums.js +1 -18
- package/esm/types/enums.js.map +1 -1
- package/esm/types/index.d.ts +2 -1
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/index.js +1 -0
- package/esm/types/index.js.map +1 -1
- package/esm/types/unrecognized.d.ts +16 -0
- package/esm/types/unrecognized.d.ts.map +1 -0
- package/esm/types/unrecognized.js +31 -0
- package/esm/types/unrecognized.js.map +1 -0
- package/examples/package-lock.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/assessmentGetOpenOrders.ts +1 -1
- package/src/funcs/atsGetApplicationStages.ts +1 -1
- package/src/funcs/atsGetApplications.ts +1 -1
- package/src/funcs/atsGetCandidates.ts +1 -1
- package/src/funcs/atsGetInterviews.ts +1 -1
- package/src/funcs/atsGetJobs.ts +1 -1
- package/src/funcs/atsGetOffers.ts +1 -1
- package/src/funcs/atsGetRejectionReasons.ts +1 -1
- package/src/funcs/atsGetTags.ts +1 -1
- package/src/funcs/atsGetUsers.ts +1 -1
- package/src/funcs/generalGetCustomFields.ts +1 -1
- package/src/funcs/generalGetIntegrationFields.ts +1 -1
- package/src/funcs/generalSendPassthroughRequest.ts +9 -1
- package/src/funcs/hrisGetAbsenceTypes.ts +1 -1
- package/src/funcs/hrisGetAbsences.ts +1 -1
- package/src/funcs/hrisGetEmployeeDocumentCategories.ts +1 -1
- package/src/funcs/hrisGetEmployees.ts +1 -1
- package/src/funcs/hrisGetEmployments.ts +1 -1
- package/src/funcs/hrisGetGroups.ts +1 -1
- package/src/funcs/hrisGetLegalEntities.ts +1 -1
- package/src/funcs/hrisGetLocations.ts +1 -1
- package/src/funcs/hrisGetPerformanceReviewCycles.ts +1 -1
- package/src/funcs/hrisGetPerformanceReviews.ts +1 -1
- package/src/funcs/hrisGetTimeOffBalances.ts +1 -1
- package/src/funcs/hrisGetTimesheets.ts +1 -1
- package/src/funcs/validateWebhook.ts +74 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/encodings.ts +17 -3
- package/src/models/assessmentorderreceivedwebhookpayload.ts +7 -7
- package/src/models/connectionflowfailedwebhookpayload.ts +4 -3
- package/src/models/datachangedwebhookpayload.ts +11 -3
- package/src/models/getassessmentordersopenpositiveresponse.ts +5 -5
- package/src/models/getatsjobspositiveresponse.ts +9 -9
- package/src/models/gethrisemployeesformpositiveresponse.ts +18 -18
- package/src/models/getintegrationsintegrationidpositiveresponse.ts +292 -44
- package/src/models/gettoolscategoryparametercategory.ts +1 -0
- package/src/models/gettoolscategorypositiveresponse.ts +160 -48
- package/src/models/inlineassessmentorderreceivedwebhookpayload.ts +7 -7
- package/src/models/integrationcreatedwebhookpayload.ts +1 -0
- package/src/models/integrationdeletedwebhookpayload.ts +1 -0
- package/src/models/integrationstatechangedwebhookpayload.ts +4 -3
- package/src/models/kombohriserror.ts +1 -0
- package/src/models/postatscandidatesrequestbody.ts +44 -0
- package/src/models/postatsjobsjobidapplicationsrequestbody.ts +49 -0
- package/src/models/postconnectcreatelinkrequestbody.ts +5 -0
- package/src/models/posthrisemployeesformpositiveresponse.ts +30 -4
- package/src/models/putassessmentordersassessmentorderidresultrequestbody.ts +7 -7
- package/src/models/schema1union1.ts +9 -9
- package/src/models/schema1union2.ts +9 -9
- package/src/models/schema2union1.ts +18 -18
- package/src/models/schema2union2.ts +18 -18
- package/src/models/syncfinishedwebhookpayload.ts +4 -3
- package/src/sdk/general.ts +9 -1
- package/src/sdk/sdk.ts +28 -0
- package/src/types/enums.ts +1 -21
- package/src/types/index.ts +2 -1
- package/src/types/unrecognized.ts +35 -0
- package/tests/basic-behavior.spec.ts +355 -2
- package/tests/helpers/test-context.ts +5 -2
- package/tsconfig.json +1 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { it, expect } from "vitest";
|
|
1
|
+
import { it, expect, describe } from "vitest";
|
|
2
2
|
import { TestContext, describeSdkSuite } from "./helpers/test-context";
|
|
3
3
|
|
|
4
|
-
// TODO: test basic error handling behavior
|
|
5
4
|
describeSdkSuite("Basic SDK Behavior", () => {
|
|
6
5
|
it("should include API key in Authorization header", async () => {
|
|
7
6
|
const ctx = new TestContext({ apiKey: "my-custom-api-key" });
|
|
@@ -159,4 +158,358 @@ describeSdkSuite("Basic SDK Behavior", () => {
|
|
|
159
158
|
const requestWithoutDeleted = ctx.getLastRequest();
|
|
160
159
|
expect(requestWithoutDeleted.path).toContain("include_deleted=false");
|
|
161
160
|
});
|
|
161
|
+
|
|
162
|
+
describe("Pagination Behavior", () => {
|
|
163
|
+
it("should iterate through multiple pages", async () => {
|
|
164
|
+
const ctx = new TestContext();
|
|
165
|
+
|
|
166
|
+
// Mock 3 pages of results
|
|
167
|
+
ctx.mockEndpoint({
|
|
168
|
+
method: "GET",
|
|
169
|
+
path: "/v1/ats/tags",
|
|
170
|
+
response: {
|
|
171
|
+
body: {
|
|
172
|
+
status: "success",
|
|
173
|
+
data: {
|
|
174
|
+
results: [
|
|
175
|
+
{
|
|
176
|
+
id: "tag1",
|
|
177
|
+
remote_id: null,
|
|
178
|
+
name: "Tag 1",
|
|
179
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
180
|
+
remote_deleted_at: null,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "tag2",
|
|
184
|
+
remote_id: null,
|
|
185
|
+
name: "Tag 2",
|
|
186
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
187
|
+
remote_deleted_at: null,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
next: "cursor_page2",
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
ctx.mockEndpoint({
|
|
197
|
+
method: "GET",
|
|
198
|
+
path: "/v1/ats/tags",
|
|
199
|
+
response: {
|
|
200
|
+
body: {
|
|
201
|
+
status: "success",
|
|
202
|
+
data: {
|
|
203
|
+
results: [
|
|
204
|
+
{
|
|
205
|
+
id: "tag3",
|
|
206
|
+
remote_id: null,
|
|
207
|
+
name: "Tag 3",
|
|
208
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
209
|
+
remote_deleted_at: null,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "tag4",
|
|
213
|
+
remote_id: null,
|
|
214
|
+
name: "Tag 4",
|
|
215
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
216
|
+
remote_deleted_at: null,
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
next: "cursor_page3",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
ctx.mockEndpoint({
|
|
226
|
+
method: "GET",
|
|
227
|
+
path: "/v1/ats/tags",
|
|
228
|
+
response: {
|
|
229
|
+
body: {
|
|
230
|
+
status: "success",
|
|
231
|
+
data: {
|
|
232
|
+
results: [
|
|
233
|
+
{
|
|
234
|
+
id: "tag5",
|
|
235
|
+
remote_id: null,
|
|
236
|
+
name: "Tag 5",
|
|
237
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
238
|
+
remote_deleted_at: null,
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
next: null,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const tags = await ctx.kombo.ats.getTags({});
|
|
248
|
+
const allResults: unknown[] = [];
|
|
249
|
+
|
|
250
|
+
for await (const page of tags) {
|
|
251
|
+
allResults.push(...page.result.data.results);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Verify all 5 tags were collected
|
|
255
|
+
expect(allResults).toHaveLength(5);
|
|
256
|
+
expect(allResults.map((r: any) => r.id)).toEqual([
|
|
257
|
+
"tag1",
|
|
258
|
+
"tag2",
|
|
259
|
+
"tag3",
|
|
260
|
+
"tag4",
|
|
261
|
+
"tag5",
|
|
262
|
+
]);
|
|
263
|
+
|
|
264
|
+
// Verify 3 HTTP requests were made
|
|
265
|
+
const requests = ctx.getRequests();
|
|
266
|
+
expect(requests).toHaveLength(3);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("should pass cursor parameter to subsequent requests", async () => {
|
|
270
|
+
const ctx = new TestContext();
|
|
271
|
+
|
|
272
|
+
ctx.mockEndpoint({
|
|
273
|
+
method: "GET",
|
|
274
|
+
path: "/v1/ats/tags",
|
|
275
|
+
response: {
|
|
276
|
+
body: {
|
|
277
|
+
status: "success",
|
|
278
|
+
data: {
|
|
279
|
+
results: [
|
|
280
|
+
{
|
|
281
|
+
id: "tag1",
|
|
282
|
+
remote_id: null,
|
|
283
|
+
name: "Tag 1",
|
|
284
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
285
|
+
remote_deleted_at: null,
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
next: "test_cursor_abc123",
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
ctx.mockEndpoint({
|
|
295
|
+
method: "GET",
|
|
296
|
+
path: "/v1/ats/tags",
|
|
297
|
+
response: {
|
|
298
|
+
body: {
|
|
299
|
+
status: "success",
|
|
300
|
+
data: {
|
|
301
|
+
results: [
|
|
302
|
+
{
|
|
303
|
+
id: "tag2",
|
|
304
|
+
remote_id: null,
|
|
305
|
+
name: "Tag 2",
|
|
306
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
307
|
+
remote_deleted_at: null,
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
next: null,
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const tags = await ctx.kombo.ats.getTags({});
|
|
317
|
+
for await (const _page of tags) {
|
|
318
|
+
// Iterate through all pages
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const requests = ctx.getRequests();
|
|
322
|
+
expect(requests).toHaveLength(2);
|
|
323
|
+
|
|
324
|
+
// First request should NOT include cursor
|
|
325
|
+
expect(requests[0].path).not.toContain("cursor=");
|
|
326
|
+
|
|
327
|
+
// Second request SHOULD include cursor
|
|
328
|
+
expect(requests[1].path).toContain("cursor=test_cursor_abc123");
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it("should stop pagination when next is null", async () => {
|
|
332
|
+
const ctx = new TestContext();
|
|
333
|
+
|
|
334
|
+
ctx.mockEndpoint({
|
|
335
|
+
method: "GET",
|
|
336
|
+
path: "/v1/ats/tags",
|
|
337
|
+
response: {
|
|
338
|
+
body: {
|
|
339
|
+
status: "success",
|
|
340
|
+
data: {
|
|
341
|
+
results: [
|
|
342
|
+
{
|
|
343
|
+
id: "tag1",
|
|
344
|
+
remote_id: null,
|
|
345
|
+
name: "Tag 1",
|
|
346
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
347
|
+
remote_deleted_at: null,
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
id: "tag2",
|
|
351
|
+
remote_id: null,
|
|
352
|
+
name: "Tag 2",
|
|
353
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
354
|
+
remote_deleted_at: null,
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
next: null,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
const tags = await ctx.kombo.ats.getTags({});
|
|
364
|
+
const pageCount: number[] = [];
|
|
365
|
+
|
|
366
|
+
for await (const _page of tags) {
|
|
367
|
+
pageCount.push(1);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Verify only 1 page was returned
|
|
371
|
+
expect(pageCount).toHaveLength(1);
|
|
372
|
+
|
|
373
|
+
// Verify only 1 HTTP request was made
|
|
374
|
+
const requests = ctx.getRequests();
|
|
375
|
+
expect(requests).toHaveLength(1);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it("should preserve query parameters across paginated requests", async () => {
|
|
379
|
+
const ctx = new TestContext();
|
|
380
|
+
|
|
381
|
+
ctx.mockEndpoint({
|
|
382
|
+
method: "GET",
|
|
383
|
+
path: "/v1/ats/tags",
|
|
384
|
+
response: {
|
|
385
|
+
body: {
|
|
386
|
+
status: "success",
|
|
387
|
+
data: {
|
|
388
|
+
results: [
|
|
389
|
+
{
|
|
390
|
+
id: "tag1",
|
|
391
|
+
remote_id: null,
|
|
392
|
+
name: "Tag 1",
|
|
393
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
394
|
+
remote_deleted_at: null,
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
next: "cursor_for_page2",
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
ctx.mockEndpoint({
|
|
404
|
+
method: "GET",
|
|
405
|
+
path: "/v1/ats/tags",
|
|
406
|
+
response: {
|
|
407
|
+
body: {
|
|
408
|
+
status: "success",
|
|
409
|
+
data: {
|
|
410
|
+
results: [
|
|
411
|
+
{
|
|
412
|
+
id: "tag2",
|
|
413
|
+
remote_id: null,
|
|
414
|
+
name: "Tag 2",
|
|
415
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
416
|
+
remote_deleted_at: null,
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
next: null,
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
const tags = await ctx.kombo.ats.getTags({
|
|
426
|
+
updated_after: new Date("2024-01-01T00:00:00.000Z"),
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
for await (const _page of tags) {
|
|
430
|
+
// Iterate through all pages
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const requests = ctx.getRequests();
|
|
434
|
+
expect(requests).toHaveLength(2);
|
|
435
|
+
|
|
436
|
+
// Both requests should include the original query parameters
|
|
437
|
+
// Check that updated_after parameter is present (URL encoded)
|
|
438
|
+
expect(requests[0].path).toMatch(/updated_after=2024-01-01T00%3A00%3A00\.000Z/);
|
|
439
|
+
expect(requests[0].path).not.toContain("cursor=");
|
|
440
|
+
|
|
441
|
+
expect(requests[1].path).toMatch(/updated_after=2024-01-01T00%3A00%3A00\.000Z/);
|
|
442
|
+
expect(requests[1].path).toContain("cursor=cursor_for_page2");
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("should support manual pagination with next()", async () => {
|
|
446
|
+
const ctx = new TestContext();
|
|
447
|
+
|
|
448
|
+
ctx.mockEndpoint({
|
|
449
|
+
method: "GET",
|
|
450
|
+
path: "/v1/ats/tags",
|
|
451
|
+
response: {
|
|
452
|
+
body: {
|
|
453
|
+
status: "success",
|
|
454
|
+
data: {
|
|
455
|
+
results: [
|
|
456
|
+
{
|
|
457
|
+
id: "tag1",
|
|
458
|
+
remote_id: null,
|
|
459
|
+
name: "Tag 1",
|
|
460
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
461
|
+
remote_deleted_at: null,
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
next: "manual_cursor_xyz",
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
ctx.mockEndpoint({
|
|
471
|
+
method: "GET",
|
|
472
|
+
path: "/v1/ats/tags",
|
|
473
|
+
response: {
|
|
474
|
+
body: {
|
|
475
|
+
status: "success",
|
|
476
|
+
data: {
|
|
477
|
+
results: [
|
|
478
|
+
{
|
|
479
|
+
id: "tag2",
|
|
480
|
+
remote_id: null,
|
|
481
|
+
name: "Tag 2",
|
|
482
|
+
changed_at: "2024-01-01T00:00:00.000Z",
|
|
483
|
+
remote_deleted_at: null,
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
next: null,
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
const page1 = await ctx.kombo.ats.getTags({});
|
|
493
|
+
|
|
494
|
+
// Verify first page was fetched
|
|
495
|
+
expect(page1.result.data.results).toBeDefined();
|
|
496
|
+
expect(page1.result.data.results).toHaveLength(1);
|
|
497
|
+
|
|
498
|
+
// Manually call next()
|
|
499
|
+
const page2Result = await page1.next();
|
|
500
|
+
|
|
501
|
+
// Verify second page was fetched (should not be null if cursor was read correctly)
|
|
502
|
+
// This will fail if cursor extraction bug exists
|
|
503
|
+
expect(page2Result).not.toBeNull();
|
|
504
|
+
if (page2Result) {
|
|
505
|
+
expect(page2Result.result.data.results).toHaveLength(1);
|
|
506
|
+
expect(page2Result.result.data.results[0].id).toBe("tag2");
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Verify 2 HTTP requests were made
|
|
510
|
+
const requests = ctx.getRequests();
|
|
511
|
+
expect(requests).toHaveLength(2);
|
|
512
|
+
expect(requests[1].path).toContain("cursor=manual_cursor_xyz");
|
|
513
|
+
});
|
|
514
|
+
});
|
|
162
515
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, beforeAll, afterAll } from "vitest";
|
|
1
|
+
import { describe, beforeAll, afterAll, afterEach } from "vitest";
|
|
2
2
|
import nock from "nock";
|
|
3
3
|
import { Kombo } from "../../src/index";
|
|
4
4
|
|
|
@@ -137,8 +137,11 @@ export function describeSdkSuite(name: string, fn: () => void) {
|
|
|
137
137
|
nock.disableNetConnect();
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
afterEach(() => {
|
|
141
141
|
nock.cleanAll();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
afterAll(() => {
|
|
142
145
|
nock.enableNetConnect();
|
|
143
146
|
});
|
|
144
147
|
|