Skip to content

Commit f4c8f10

Browse files
fix(credential-groups): accept signed enrollment cursors
1 parent 15e92c2 commit f4c8f10

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

apps/sim/lib/api/contracts/credential-groups.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CREDENTIAL_GROUP_PROVIDER_IDS,
66
CREDENTIAL_GROUP_STANDARD_OAUTH_PROVIDER_IDS,
77
} from '@/lib/credential-groups/providers'
8+
import { CREDENTIAL_GROUP_ENROLLMENT_CURSOR_MAX_LENGTH } from '@/lib/credential-groups/types'
89

910
export const credentialGroupProviderSchema = z.enum(CREDENTIAL_GROUP_PROVIDER_IDS)
1011
export const credentialGroupStatusSchema = z.enum(['active', 'disabled'])
@@ -169,7 +170,11 @@ export const slackCredentialGroupConfigurationCallbackQuerySchema =
169170
credentialGroupOAuthCallbackQuerySchema
170171

171172
export const credentialGroupEnrollmentListQuerySchema = z.object({
172-
cursor: z.string().min(1, 'Enrollment cursor cannot be empty').max(128).optional(),
173+
cursor: z
174+
.string()
175+
.min(1, 'Enrollment cursor cannot be empty')
176+
.max(CREDENTIAL_GROUP_ENROLLMENT_CURSOR_MAX_LENGTH)
177+
.optional(),
173178
limit: z.coerce.number().int().min(1).max(100).default(50),
174179
})
175180

apps/sim/lib/credential-groups/enrollments.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { dbChainMockFns, queueTableRows, resetDbChainMock, schemaMock } from '@sim/testing'
55
import { inArray } from 'drizzle-orm'
66
import { beforeEach, describe, expect, it, vi } from 'vitest'
7+
import { credentialGroupEnrollmentListQuerySchema } from '@/lib/api/contracts/credential-groups'
78

89
const { adapter } = vi.hoisted(() => ({
910
adapter: {
@@ -151,6 +152,9 @@ describe('listCredentialGroupEnrollments', () => {
151152
statuses: ['invited', 'in_progress', 'completed', 'delivery_failed'],
152153
})
153154
if (!firstPage.nextCursor) throw new Error('Expected a next enrollment cursor')
155+
expect(
156+
credentialGroupEnrollmentListQuerySchema.parse({ cursor: firstPage.nextCursor }).cursor
157+
).toBe(firstPage.nextCursor)
154158
const result = await listCredentialGroupEnrollments(
155159
'workspace-1',
156160
'group-1',

apps/sim/lib/credential-groups/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { CredentialGroupProvider } from '@/lib/credential-groups/providers'
22

3+
export const CREDENTIAL_GROUP_ENROLLMENT_CURSOR_MAX_LENGTH = 256
4+
35
interface CredentialGroupOptionInputBase {
46
label: string
57
required: boolean

0 commit comments

Comments
 (0)