Skip to content

Commit e07224b

Browse files
committed
improvement(search): generalize connector partition progress
1 parent bd64ce3 commit e07224b

19 files changed

Lines changed: 1153 additions & 837 deletions

.github/workflows/test-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ jobs:
238238
lib/knowledge/__integration__/connector-lifecycle-locks.integration.ts
239239
lib/knowledge/__integration__/connector-deferral.integration.ts
240240
lib/knowledge/__integration__/stored-document-recovery.integration.ts
241-
lib/knowledge/__integration__/google-company-work.integration.ts
241+
lib/knowledge/__integration__/connector-partition-work.integration.ts
242242
lib/knowledge/__integration__/listing-continuation.integration.ts
243243
lib/knowledge/__integration__/kb-block-search.integration.ts
244244
lib/core/outbox/service.integration.ts

apps/sim/connectors/google-drive/company-crawl.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {
66
GOOGLE_WORKSPACE_DRIVES_PAGE_SIZE,
77
listGoogleWorkspaceDrives,
88
} from '@/connectors/google-drive/workspace-drives'
9-
import type { GoogleCompanyCursorAdapter } from '@/connectors/google-workspace/company-work'
9+
import {
10+
type GoogleCompanyCursorAdapter,
11+
googleCompanyUserContextSchema,
12+
} from '@/connectors/google-workspace/company-work'
1013
import {
1114
GOOGLE_WORKSPACE_USERS_PAGE_SIZE,
1215
getGoogleWorkspaceUser,
@@ -19,15 +22,7 @@ import { parseOptionalUnlimitedSafeInteger } from '@/connectors/utils'
1922
const CURSOR_PREFIX = 'gdrive-company:v1:'
2023
const MAX_CURSOR_BYTES = 384 * 1024
2124
const cursorSchema = z.object({
22-
users: z
23-
.array(
24-
z.object({
25-
id: z.string().min(1).max(256),
26-
email: z.string().email().max(254),
27-
customerId: z.string().min(1).max(256),
28-
})
29-
)
30-
.max(GOOGLE_WORKSPACE_USERS_PAGE_SIZE),
25+
users: z.array(googleCompanyUserContextSchema).max(GOOGLE_WORKSPACE_USERS_PAGE_SIZE),
3126
nextUsersPageToken: z.string().min(1).max(8192).optional(),
3227
scope: z.discriminatedUnion('kind', [
3328
z.object({

apps/sim/connectors/google-workspace/company-crawl.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { normalizeEmail } from '@sim/utils/string'
33
import { z } from 'zod'
44
import { mapWithConcurrency } from '@/lib/core/utils/concurrency'
55
import { GoogleApiError } from '@/connectors/google-workspace/api-errors'
6-
import type { GoogleCompanyCursorAdapter } from '@/connectors/google-workspace/company-work'
6+
import {
7+
type GoogleCompanyCursorAdapter,
8+
googleCompanyUserContextSchema,
9+
} from '@/connectors/google-workspace/company-work'
710
import {
811
GOOGLE_WORKSPACE_USERS_PAGE_SIZE,
912
type GoogleWorkspaceUser,
@@ -29,15 +32,7 @@ const MAX_PROVIDER_CURSOR_BYTES = 256 * 1024
2932
const MAX_PAGE_DOCUMENTS = 2500
3033
const cursorSchema = z.object({
3134
provider: z.enum(['gmail', 'google_calendar']),
32-
users: z
33-
.array(
34-
z.object({
35-
id: z.string().min(1).max(256),
36-
email: z.string().email().max(254),
37-
customerId: z.string().min(1).max(256),
38-
})
39-
)
40-
.max(GOOGLE_WORKSPACE_USERS_PAGE_SIZE),
35+
users: z.array(googleCompanyUserContextSchema).max(GOOGLE_WORKSPACE_USERS_PAGE_SIZE),
4136
nextUsersPageToken: z.string().min(1).max(8192).optional(),
4237
providerCursor: z.string().min(1).max(MAX_PROVIDER_CURSOR_BYTES).optional(),
4338
listingFailures: listingFailuresSchema.optional(),

apps/sim/connectors/google-workspace/company-work.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { z } from 'zod'
12
import type { GoogleWorkspaceUser } from '@/connectors/google-workspace/users'
23

34
/** Directory identity and provider continuation are persisted separately from delegated credentials. */
@@ -11,3 +12,10 @@ export interface GoogleCompanyCursorAdapter {
1112
/** Retains the exact active page when adopting the former single-user-at-a-time cursor. */
1213
resume: (cursor: string) => GoogleCompanyUserWork[]
1314
}
15+
16+
/** Validates Google Directory identity before persisted partition context is used for delegation. */
17+
export const googleCompanyUserContextSchema = z.object({
18+
id: z.string().min(1).max(256),
19+
email: z.string().email().max(254),
20+
customerId: z.string().min(1).max(256),
21+
})

0 commit comments

Comments
 (0)