@opengeni/documents 0.5.18 → 0.5.38
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/dist/atlassian.d.ts +78 -0
- package/dist/atlassian.js +140 -0
- package/dist/atlassian.js.map +1 -0
- package/dist/google-drive.d.ts +2 -0
- package/dist/google-drive.js +12 -1
- package/dist/google-drive.js.map +1 -1
- package/dist/index.d.ts +74 -4
- package/dist/index.js +645 -27
- package/dist/index.js.map +1 -1
- package/dist/knowledge-projection.d.ts +14 -0
- package/package.json +10 -6
- package/src/atlassian.ts +250 -0
- package/src/google-drive.ts +21 -1
- package/src/index.ts +674 -26
- package/src/knowledge-projection.ts +214 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ScopedKnowledgeScope } from "@opengeni/contracts";
|
|
2
|
+
import { type ConnectorDocumentDestination } from "@opengeni/contracts/connector-destinations";
|
|
3
|
+
import type { AtlassianSelectedSource } from "@opengeni/contracts/atlassian";
|
|
4
|
+
export declare const ATLASSIAN_PROVIDER_KEY: "atlassian";
|
|
5
|
+
export type AtlassianKnowledgeSourceIdentity = {
|
|
6
|
+
providerKey: typeof ATLASSIAN_PROVIDER_KEY;
|
|
7
|
+
externalTenantId: string;
|
|
8
|
+
externalSourceId: string;
|
|
9
|
+
sourceKind: "atlassian-jira-project" | "atlassian-confluence-space";
|
|
10
|
+
sourceUri: string;
|
|
11
|
+
scope: ScopedKnowledgeScope;
|
|
12
|
+
};
|
|
13
|
+
export type AtlassianInventoryProviderItem = {
|
|
14
|
+
id: string;
|
|
15
|
+
key: string;
|
|
16
|
+
title: string;
|
|
17
|
+
version: string | null;
|
|
18
|
+
createdAt: string | null;
|
|
19
|
+
updatedAt: string | null;
|
|
20
|
+
webUrl: string;
|
|
21
|
+
};
|
|
22
|
+
export type AtlassianInventoryPage = {
|
|
23
|
+
items: AtlassianInventoryProviderItem[];
|
|
24
|
+
nextCursor: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type AtlassianInventoryEntry = {
|
|
27
|
+
externalObjectId: string;
|
|
28
|
+
externalVersionId: string | null;
|
|
29
|
+
sourceId: string;
|
|
30
|
+
parentFolderId: string;
|
|
31
|
+
driveId: null;
|
|
32
|
+
title: string;
|
|
33
|
+
mimeType: "text/markdown";
|
|
34
|
+
modifiedTime: string | null;
|
|
35
|
+
createdTime: string | null;
|
|
36
|
+
sourceUri: string;
|
|
37
|
+
transfer: {
|
|
38
|
+
action: "download";
|
|
39
|
+
contentType: "text/markdown";
|
|
40
|
+
filename: string;
|
|
41
|
+
declaredBytes: null;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type AtlassianInventoryStopReason = "api_request_limit" | "elapsed_time_limit" | "item_limit" | "provider_error";
|
|
45
|
+
export type AtlassianInventoryCheckpoint = {
|
|
46
|
+
version: 1;
|
|
47
|
+
cloudId: string;
|
|
48
|
+
sourceId: string;
|
|
49
|
+
cursor: string | null;
|
|
50
|
+
itemCount: number;
|
|
51
|
+
apiRequestCount: number;
|
|
52
|
+
};
|
|
53
|
+
export declare function atlassianKnowledgeScope(destination: ConnectorDocumentDestination): ScopedKnowledgeScope;
|
|
54
|
+
export declare function atlassianKnowledgeSourceIdentity(input: {
|
|
55
|
+
source: AtlassianSelectedSource;
|
|
56
|
+
accountId: string;
|
|
57
|
+
workspaceId: string;
|
|
58
|
+
connectionSubjectId: string;
|
|
59
|
+
}): AtlassianKnowledgeSourceIdentity;
|
|
60
|
+
export declare function inventoryAtlassianSource(input: {
|
|
61
|
+
cloudId: string;
|
|
62
|
+
source: AtlassianSelectedSource;
|
|
63
|
+
limits: {
|
|
64
|
+
maxItems: number;
|
|
65
|
+
maxApiRequests: number;
|
|
66
|
+
maxElapsedMs: number;
|
|
67
|
+
pageSize: number;
|
|
68
|
+
};
|
|
69
|
+
checkpoint: Record<string, unknown> | null;
|
|
70
|
+
listPage: (cursor: string | null, pageSize: number) => Promise<AtlassianInventoryPage>;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
status: "complete" | "paused";
|
|
73
|
+
stopReason: AtlassianInventoryStopReason | null;
|
|
74
|
+
entries: AtlassianInventoryEntry[];
|
|
75
|
+
checkpoint: AtlassianInventoryCheckpoint | null;
|
|
76
|
+
providerRequests: number;
|
|
77
|
+
elapsedMs: number;
|
|
78
|
+
}>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// src/atlassian.ts
|
|
2
|
+
import {
|
|
3
|
+
connectorDestinationDocumentAuthority,
|
|
4
|
+
resolveConnectorDocumentDestination
|
|
5
|
+
} from "@opengeni/contracts/connector-destinations";
|
|
6
|
+
var ATLASSIAN_PROVIDER_KEY = "atlassian";
|
|
7
|
+
function atlassianKnowledgeScope(destination) {
|
|
8
|
+
const authority = connectorDestinationDocumentAuthority(destination);
|
|
9
|
+
if (authority.authorityKind === "organization") {
|
|
10
|
+
return { kind: "organization", workspaceId: null, subjectId: null };
|
|
11
|
+
}
|
|
12
|
+
if (authority.authorityKind === "workspace") {
|
|
13
|
+
if (!authority.authorityWorkspaceId) throw new Error("workspace authority is missing");
|
|
14
|
+
return { kind: "workspace", workspaceId: authority.authorityWorkspaceId, subjectId: null };
|
|
15
|
+
}
|
|
16
|
+
if (!authority.authorityWorkspaceId || !authority.authoritySubjectId) {
|
|
17
|
+
throw new Error("personal authority is missing");
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
kind: "personal",
|
|
21
|
+
workspaceId: authority.authorityWorkspaceId,
|
|
22
|
+
subjectId: authority.authoritySubjectId
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function atlassianKnowledgeSourceIdentity(input) {
|
|
26
|
+
const destination = resolveConnectorDocumentDestination(input.source.destination, {
|
|
27
|
+
accountId: input.accountId,
|
|
28
|
+
workspaceId: input.workspaceId,
|
|
29
|
+
connectionSubjectId: input.connectionSubjectId
|
|
30
|
+
});
|
|
31
|
+
const siteUrl = new URL(input.source.siteUrl);
|
|
32
|
+
const sourceUri = input.source.kind === "jira_project" ? new URL(`/jira/software/c/projects/${encodeURIComponent(input.source.key)}`, siteUrl) : new URL(`/wiki/spaces/${encodeURIComponent(input.source.key)}`, siteUrl);
|
|
33
|
+
return {
|
|
34
|
+
providerKey: ATLASSIAN_PROVIDER_KEY,
|
|
35
|
+
externalTenantId: bounded(input.source.cloudId, 256, "cloudId"),
|
|
36
|
+
externalSourceId: bounded(input.source.id, 300, "source.id"),
|
|
37
|
+
sourceKind: input.source.kind === "jira_project" ? "atlassian-jira-project" : "atlassian-confluence-space",
|
|
38
|
+
sourceUri: sourceUri.toString(),
|
|
39
|
+
scope: atlassianKnowledgeScope(destination)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function inventoryAtlassianSource(input) {
|
|
43
|
+
const startedAt = Date.now();
|
|
44
|
+
const restored = parseCheckpoint(input.checkpoint, input.cloudId, input.source.id);
|
|
45
|
+
let cursor = restored?.cursor ?? null;
|
|
46
|
+
let itemCount = restored?.itemCount ?? 0;
|
|
47
|
+
let apiRequestCount = restored?.apiRequestCount ?? 0;
|
|
48
|
+
const entries = [];
|
|
49
|
+
while (true) {
|
|
50
|
+
if (Date.now() - startedAt >= input.limits.maxElapsedMs) return paused("elapsed_time_limit");
|
|
51
|
+
if (apiRequestCount >= input.limits.maxApiRequests) return paused("api_request_limit");
|
|
52
|
+
if (itemCount >= input.limits.maxItems) return paused("item_limit");
|
|
53
|
+
let page;
|
|
54
|
+
try {
|
|
55
|
+
page = await input.listPage(
|
|
56
|
+
cursor,
|
|
57
|
+
Math.min(input.limits.pageSize, input.limits.maxItems - itemCount)
|
|
58
|
+
);
|
|
59
|
+
} catch {
|
|
60
|
+
return paused("provider_error");
|
|
61
|
+
}
|
|
62
|
+
apiRequestCount += 1;
|
|
63
|
+
for (const item of page.items) {
|
|
64
|
+
if (itemCount >= input.limits.maxItems) return paused("item_limit");
|
|
65
|
+
entries.push(atlassianEntry(input.source, item));
|
|
66
|
+
itemCount += 1;
|
|
67
|
+
}
|
|
68
|
+
cursor = page.nextCursor;
|
|
69
|
+
if (!cursor) {
|
|
70
|
+
return {
|
|
71
|
+
status: "complete",
|
|
72
|
+
stopReason: null,
|
|
73
|
+
entries,
|
|
74
|
+
checkpoint: null,
|
|
75
|
+
providerRequests: apiRequestCount - (restored?.apiRequestCount ?? 0),
|
|
76
|
+
elapsedMs: Date.now() - startedAt
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function paused(stopReason) {
|
|
81
|
+
return {
|
|
82
|
+
status: "paused",
|
|
83
|
+
stopReason,
|
|
84
|
+
entries,
|
|
85
|
+
checkpoint: {
|
|
86
|
+
version: 1,
|
|
87
|
+
cloudId: input.cloudId,
|
|
88
|
+
sourceId: input.source.id,
|
|
89
|
+
cursor,
|
|
90
|
+
itemCount,
|
|
91
|
+
apiRequestCount
|
|
92
|
+
},
|
|
93
|
+
providerRequests: apiRequestCount - (restored?.apiRequestCount ?? 0),
|
|
94
|
+
elapsedMs: Date.now() - startedAt
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function atlassianEntry(source, item) {
|
|
99
|
+
const title = bounded(item.title, 1024, "title");
|
|
100
|
+
return {
|
|
101
|
+
externalObjectId: bounded(`${source.kind}:${item.id}`, 512, "item.id"),
|
|
102
|
+
externalVersionId: item.version,
|
|
103
|
+
sourceId: source.id,
|
|
104
|
+
parentFolderId: source.resourceId,
|
|
105
|
+
driveId: null,
|
|
106
|
+
title,
|
|
107
|
+
mimeType: "text/markdown",
|
|
108
|
+
modifiedTime: item.updatedAt,
|
|
109
|
+
createdTime: item.createdAt,
|
|
110
|
+
sourceUri: new URL(item.webUrl).toString(),
|
|
111
|
+
transfer: {
|
|
112
|
+
action: "download",
|
|
113
|
+
contentType: "text/markdown",
|
|
114
|
+
filename: `${safeFilename(item.key || title)}.md`,
|
|
115
|
+
declaredBytes: null
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function parseCheckpoint(value, cloudId, sourceId) {
|
|
120
|
+
if (!value) return null;
|
|
121
|
+
if (value.version !== 1 || value.cloudId !== cloudId || value.sourceId !== sourceId || value.cursor !== null && typeof value.cursor !== "string" || !Number.isSafeInteger(value.itemCount) || !Number.isSafeInteger(value.apiRequestCount)) {
|
|
122
|
+
throw new Error("invalid Atlassian inventory checkpoint");
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function bounded(value, max, label) {
|
|
127
|
+
const normalized = value.trim();
|
|
128
|
+
if (!normalized || normalized.length > max) throw new Error(`invalid ${label}`);
|
|
129
|
+
return normalized;
|
|
130
|
+
}
|
|
131
|
+
function safeFilename(value) {
|
|
132
|
+
return value.normalize("NFKC").replace(/[\\/:*?"<>|\0-\x1f]/g, "_").trim().slice(0, 220) || "item";
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
ATLASSIAN_PROVIDER_KEY,
|
|
136
|
+
atlassianKnowledgeScope,
|
|
137
|
+
atlassianKnowledgeSourceIdentity,
|
|
138
|
+
inventoryAtlassianSource
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=atlassian.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/atlassian.ts"],"sourcesContent":["import type { ScopedKnowledgeScope } from \"@opengeni/contracts\";\nimport {\n connectorDestinationDocumentAuthority,\n resolveConnectorDocumentDestination,\n type ConnectorDocumentDestination,\n} from \"@opengeni/contracts/connector-destinations\";\nimport type { AtlassianSelectedSource } from \"@opengeni/contracts/atlassian\";\n\nexport const ATLASSIAN_PROVIDER_KEY = \"atlassian\" as const;\n\nexport type AtlassianKnowledgeSourceIdentity = {\n providerKey: typeof ATLASSIAN_PROVIDER_KEY;\n externalTenantId: string;\n externalSourceId: string;\n sourceKind: \"atlassian-jira-project\" | \"atlassian-confluence-space\";\n sourceUri: string;\n scope: ScopedKnowledgeScope;\n};\n\nexport type AtlassianInventoryProviderItem = {\n id: string;\n key: string;\n title: string;\n version: string | null;\n createdAt: string | null;\n updatedAt: string | null;\n webUrl: string;\n};\n\nexport type AtlassianInventoryPage = {\n items: AtlassianInventoryProviderItem[];\n nextCursor: string | null;\n};\n\nexport type AtlassianInventoryEntry = {\n externalObjectId: string;\n externalVersionId: string | null;\n sourceId: string;\n parentFolderId: string;\n driveId: null;\n title: string;\n mimeType: \"text/markdown\";\n modifiedTime: string | null;\n createdTime: string | null;\n sourceUri: string;\n transfer: {\n action: \"download\";\n contentType: \"text/markdown\";\n filename: string;\n declaredBytes: null;\n };\n};\n\nexport type AtlassianInventoryStopReason =\n | \"api_request_limit\"\n | \"elapsed_time_limit\"\n | \"item_limit\"\n | \"provider_error\";\n\nexport type AtlassianInventoryCheckpoint = {\n version: 1;\n cloudId: string;\n sourceId: string;\n cursor: string | null;\n itemCount: number;\n apiRequestCount: number;\n};\n\nexport function atlassianKnowledgeScope(\n destination: ConnectorDocumentDestination,\n): ScopedKnowledgeScope {\n const authority = connectorDestinationDocumentAuthority(destination);\n if (authority.authorityKind === \"organization\") {\n return { kind: \"organization\", workspaceId: null, subjectId: null };\n }\n if (authority.authorityKind === \"workspace\") {\n if (!authority.authorityWorkspaceId) throw new Error(\"workspace authority is missing\");\n return { kind: \"workspace\", workspaceId: authority.authorityWorkspaceId, subjectId: null };\n }\n if (!authority.authorityWorkspaceId || !authority.authoritySubjectId) {\n throw new Error(\"personal authority is missing\");\n }\n return {\n kind: \"personal\",\n workspaceId: authority.authorityWorkspaceId,\n subjectId: authority.authoritySubjectId,\n };\n}\n\nexport function atlassianKnowledgeSourceIdentity(input: {\n source: AtlassianSelectedSource;\n accountId: string;\n workspaceId: string;\n connectionSubjectId: string;\n}): AtlassianKnowledgeSourceIdentity {\n const destination = resolveConnectorDocumentDestination(input.source.destination, {\n accountId: input.accountId,\n workspaceId: input.workspaceId,\n connectionSubjectId: input.connectionSubjectId,\n });\n const siteUrl = new URL(input.source.siteUrl);\n const sourceUri =\n input.source.kind === \"jira_project\"\n ? new URL(`/jira/software/c/projects/${encodeURIComponent(input.source.key)}`, siteUrl)\n : new URL(`/wiki/spaces/${encodeURIComponent(input.source.key)}`, siteUrl);\n return {\n providerKey: ATLASSIAN_PROVIDER_KEY,\n externalTenantId: bounded(input.source.cloudId, 256, \"cloudId\"),\n externalSourceId: bounded(input.source.id, 300, \"source.id\"),\n sourceKind:\n input.source.kind === \"jira_project\"\n ? \"atlassian-jira-project\"\n : \"atlassian-confluence-space\",\n sourceUri: sourceUri.toString(),\n scope: atlassianKnowledgeScope(destination),\n };\n}\n\nexport async function inventoryAtlassianSource(input: {\n cloudId: string;\n source: AtlassianSelectedSource;\n limits: { maxItems: number; maxApiRequests: number; maxElapsedMs: number; pageSize: number };\n checkpoint: Record<string, unknown> | null;\n listPage: (cursor: string | null, pageSize: number) => Promise<AtlassianInventoryPage>;\n}): Promise<{\n status: \"complete\" | \"paused\";\n stopReason: AtlassianInventoryStopReason | null;\n entries: AtlassianInventoryEntry[];\n checkpoint: AtlassianInventoryCheckpoint | null;\n providerRequests: number;\n elapsedMs: number;\n}> {\n const startedAt = Date.now();\n const restored = parseCheckpoint(input.checkpoint, input.cloudId, input.source.id);\n let cursor = restored?.cursor ?? null;\n let itemCount = restored?.itemCount ?? 0;\n let apiRequestCount = restored?.apiRequestCount ?? 0;\n const entries: AtlassianInventoryEntry[] = [];\n\n while (true) {\n if (Date.now() - startedAt >= input.limits.maxElapsedMs) return paused(\"elapsed_time_limit\");\n if (apiRequestCount >= input.limits.maxApiRequests) return paused(\"api_request_limit\");\n if (itemCount >= input.limits.maxItems) return paused(\"item_limit\");\n\n let page: AtlassianInventoryPage;\n try {\n page = await input.listPage(\n cursor,\n Math.min(input.limits.pageSize, input.limits.maxItems - itemCount),\n );\n } catch {\n return paused(\"provider_error\");\n }\n apiRequestCount += 1;\n for (const item of page.items) {\n if (itemCount >= input.limits.maxItems) return paused(\"item_limit\");\n entries.push(atlassianEntry(input.source, item));\n itemCount += 1;\n }\n cursor = page.nextCursor;\n if (!cursor) {\n return {\n status: \"complete\",\n stopReason: null,\n entries,\n checkpoint: null,\n providerRequests: apiRequestCount - (restored?.apiRequestCount ?? 0),\n elapsedMs: Date.now() - startedAt,\n };\n }\n }\n\n function paused(stopReason: AtlassianInventoryStopReason) {\n return {\n status: \"paused\" as const,\n stopReason,\n entries,\n checkpoint: {\n version: 1 as const,\n cloudId: input.cloudId,\n sourceId: input.source.id,\n cursor,\n itemCount,\n apiRequestCount,\n },\n providerRequests: apiRequestCount - (restored?.apiRequestCount ?? 0),\n elapsedMs: Date.now() - startedAt,\n };\n }\n}\n\nfunction atlassianEntry(\n source: AtlassianSelectedSource,\n item: AtlassianInventoryProviderItem,\n): AtlassianInventoryEntry {\n const title = bounded(item.title, 1024, \"title\");\n return {\n externalObjectId: bounded(`${source.kind}:${item.id}`, 512, \"item.id\"),\n externalVersionId: item.version,\n sourceId: source.id,\n parentFolderId: source.resourceId,\n driveId: null,\n title,\n mimeType: \"text/markdown\",\n modifiedTime: item.updatedAt,\n createdTime: item.createdAt,\n sourceUri: new URL(item.webUrl).toString(),\n transfer: {\n action: \"download\",\n contentType: \"text/markdown\",\n filename: `${safeFilename(item.key || title)}.md`,\n declaredBytes: null,\n },\n };\n}\n\nfunction parseCheckpoint(\n value: Record<string, unknown> | null,\n cloudId: string,\n sourceId: string,\n): AtlassianInventoryCheckpoint | null {\n if (!value) return null;\n if (\n value.version !== 1 ||\n value.cloudId !== cloudId ||\n value.sourceId !== sourceId ||\n (value.cursor !== null && typeof value.cursor !== \"string\") ||\n !Number.isSafeInteger(value.itemCount) ||\n !Number.isSafeInteger(value.apiRequestCount)\n ) {\n throw new Error(\"invalid Atlassian inventory checkpoint\");\n }\n return value as AtlassianInventoryCheckpoint;\n}\n\nfunction bounded(value: string, max: number, label: string): string {\n const normalized = value.trim();\n if (!normalized || normalized.length > max) throw new Error(`invalid ${label}`);\n return normalized;\n}\n\nfunction safeFilename(value: string): string {\n return (\n value\n .normalize(\"NFKC\")\n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AAK,EAAE;AAC9E,SAAO;AACT;AAEA,SAAS,aAAa,OAAuB;AAC3C,SACE,MACG,UAAU,MAAM,EAChB,QAAQ,wBAAwB,GAAG,EACnC,KAAK,EACL,MAAM,GAAG,GAAG,KAAK;AAExB;","names":[]}
|
package/dist/google-drive.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ export declare class GoogleDriveInventoryProviderError extends Error {
|
|
|
143
143
|
export declare function googleDriveKnowledgeScope(destination: ConnectorDocumentDestination): ScopedKnowledgeScope;
|
|
144
144
|
export declare function googleDriveKnowledgeSourceIdentity(input: {
|
|
145
145
|
googlePermissionId: string;
|
|
146
|
+
googleEmail?: string | undefined;
|
|
146
147
|
source: Pick<GoogleDriveSelectedSource, "id" | "driveId" | "destination" | "targetScope">;
|
|
147
148
|
accountId?: string | undefined;
|
|
148
149
|
workspaceId: string;
|
|
@@ -153,6 +154,7 @@ export declare function googleDriveKnowledgeSourceIdentity(input: {
|
|
|
153
154
|
export declare function planGoogleDriveTransfer(item: GoogleDriveInventoryProviderItem, maxFileBytes: number): GoogleDriveTransferPlan;
|
|
154
155
|
export declare function inventoryGoogleDriveSource(input: {
|
|
155
156
|
googlePermissionId: string;
|
|
157
|
+
googleEmail?: string | undefined;
|
|
156
158
|
source: GoogleDriveSelectedSource;
|
|
157
159
|
accountId?: string | undefined;
|
|
158
160
|
workspaceId: string;
|
package/dist/google-drive.js
CHANGED
|
@@ -94,7 +94,7 @@ function googleDriveKnowledgeScope(destination) {
|
|
|
94
94
|
}
|
|
95
95
|
function googleDriveKnowledgeSourceIdentity(input) {
|
|
96
96
|
const sourceId = driveId(input.source.id, "source.id");
|
|
97
|
-
const externalTenantId =
|
|
97
|
+
const externalTenantId = googleTenantIdentity(input.googleEmail);
|
|
98
98
|
const sourceDriveId = nullableDriveId(input.source.driveId, "source.driveId");
|
|
99
99
|
const destination = resolveConnectorDocumentDestination(input.source.destination, {
|
|
100
100
|
accountId: input.accountId ?? input.workspaceId,
|
|
@@ -110,6 +110,16 @@ function googleDriveKnowledgeSourceIdentity(input) {
|
|
|
110
110
|
scope: googleDriveKnowledgeScope(destination)
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
+
function googleTenantIdentity(email) {
|
|
114
|
+
if (email === void 0) return "google-consumer";
|
|
115
|
+
const normalized = email.trim().toLowerCase();
|
|
116
|
+
const separator = normalized.lastIndexOf("@");
|
|
117
|
+
if (separator <= 0 || separator === normalized.length - 1) {
|
|
118
|
+
throw new Error("googleEmail must be a normalized email address");
|
|
119
|
+
}
|
|
120
|
+
const domain = normalized.slice(separator + 1);
|
|
121
|
+
return domain === "gmail.com" || domain === "googlemail.com" ? "google-consumer" : `google-workspace:${domain}`;
|
|
122
|
+
}
|
|
113
123
|
function planGoogleDriveTransfer(item, maxFileBytes) {
|
|
114
124
|
const normalized = validatedProviderItem(item);
|
|
115
125
|
const byteLimit = safePositiveInteger(maxFileBytes, "maxFileBytes");
|
|
@@ -154,6 +164,7 @@ async function inventoryGoogleDriveSource(input) {
|
|
|
154
164
|
const googlePermissionId = normalizedGooglePermissionId(input.googlePermissionId);
|
|
155
165
|
const source = googleDriveKnowledgeSourceIdentity({
|
|
156
166
|
googlePermissionId,
|
|
167
|
+
googleEmail: input.googleEmail,
|
|
157
168
|
source: input.source,
|
|
158
169
|
...input.accountId ? { accountId: input.accountId } : {},
|
|
159
170
|
workspaceId: input.workspaceId,
|
package/dist/google-drive.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/google-drive.ts"],"sourcesContent":["import type { ScopedKnowledgeScope } from \"@opengeni/contracts\";\nimport {\n connectorDestinationDocumentAuthority,\n resolveConnectorDocumentDestination,\n type ConnectorDocumentDestination,\n} from \"@opengeni/contracts/connector-destinations\";\nimport type { GoogleDriveSelectedSource } from \"@opengeni/contracts/google-drive\";\n\nexport const GOOGLE_DRIVE_PROVIDER_KEY = \"google-drive\" as const;\nexport const GOOGLE_DRIVE_FOLDER_MIME_TYPE = \"application/vnd.google-apps.folder\" as const;\nexport const GOOGLE_DRIVE_SHORTCUT_MIME_TYPE = \"application/vnd.google-apps.shortcut\" as const;\n\nconst GOOGLE_DRIVE_NATIVE_MIME_PREFIX = \"application/vnd.google-apps.\";\nconst GOOGLE_DRIVE_MAX_ID_CHARS = 256;\nconst GOOGLE_DRIVE_MAX_NAME_CHARS = 1024;\nconst GOOGLE_DRIVE_MAX_MIME_CHARS = 256;\nconst GOOGLE_DRIVE_MAX_PAGE_TOKEN_CHARS = 4096;\nconst GOOGLE_DRIVE_MAX_PAGE_ITEMS = 100;\nconst GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS = 2_000;\nconst GOOGLE_DRIVE_MAX_CHECKPOINT_BYTES = 2 * 1024 * 1024;\n\nconst GOOGLE_DRIVE_NATIVE_EXPORTS = new Map<string, { contentType: string; extension: string }>([\n [\n \"application/vnd.google-apps.document\",\n {\n contentType: \"application/pdf\",\n extension: \".pdf\",\n },\n ],\n [\n \"application/vnd.google-apps.spreadsheet\",\n {\n contentType: \"application/pdf\",\n extension: \".pdf\",\n },\n ],\n [\n \"application/vnd.google-apps.presentation\",\n {\n contentType: \"application/pdf\",\n extension: \".pdf\",\n },\n ],\n [\"application/vnd.google-apps.drawing\", { contentType: \"application/pdf\", extension: \".pdf\" }],\n]);\n\nconst DEPENDENCY_FREE_ORDINARY_CONTENT_TYPES = new Set([\n \"application/json\",\n \"application/pdf\",\n \"application/xml\",\n \"application/x-yaml\",\n \"application/yaml\",\n]);\n\nconst GENERIC_BINARY_CONTENT_TYPES = new Set([\"application/octet-stream\", \"binary/octet-stream\"]);\n\nconst DEPENDENCY_FREE_EXTENSION_CONTENT_TYPES = new Map([\n [\".csv\", \"text/csv\"],\n [\".htm\", \"text/html\"],\n [\".html\", \"text/html\"],\n [\".json\", \"application/json\"],\n [\".markdown\", \"text/markdown\"],\n [\".md\", \"text/markdown\"],\n [\".pdf\", \"application/pdf\"],\n [\".text\", \"text/plain\"],\n [\".tsv\", \"text/tab-separated-values\"],\n [\".txt\", \"text/plain\"],\n [\".xml\", \"application/xml\"],\n [\".yaml\", \"application/x-yaml\"],\n [\".yml\", \"application/x-yaml\"],\n]);\n\nexport type GoogleDriveKnowledgeSourceIdentity = {\n providerKey: typeof GOOGLE_DRIVE_PROVIDER_KEY;\n externalTenantId: string;\n externalSourceId: string;\n sourceKind: \"google-drive-my-drive\" | \"google-drive-shared-drive\" | \"google-drive-folder\";\n sourceUri: string;\n scope: ScopedKnowledgeScope;\n};\n\n/**\n * Normalized item metadata expected from a bounded Drive files.list adapter.\n * The adapter owns provider JSON validation; this planner owns traversal,\n * checkpointing, resource limits, stable identity, and transfer classification.\n */\nexport type GoogleDriveInventoryProviderItem = {\n id: string;\n name: string;\n mimeType: string;\n driveId: string | null;\n parents: string[];\n modifiedTime: string | null;\n createdTime: string | null;\n version: string | null;\n md5Checksum: string | null;\n size: string | null;\n webViewLink: string | null;\n trashed: boolean;\n};\n\nexport type GoogleDriveInventoryPage = {\n items: GoogleDriveInventoryProviderItem[];\n nextPageToken: string | null;\n incompleteSearch: boolean;\n};\n\nexport type GoogleDriveInventoryLimits = {\n /** Hard cumulative provider-item discovery limit for this checkpoint. */\n maxItems: number;\n /** Hard cumulative known-byte limit for ordinary file downloads. */\n maxKnownBytes: number;\n /** Hard cumulative Drive list request/cost limit for this checkpoint. */\n maxApiRequests: number;\n /** Wall-clock budget for one invocation; checkpoint counters remain cumulative. */\n maxElapsedMs: number;\n /** Per-file byte ceiling. Unknown/export sizes must be enforced again while streaming. */\n maxFileBytes: number;\n /** Cycle/graph explosion guard for traversed folders. */\n maxFolders: number;\n /** Requested Drive page size. */\n pageSize: number;\n};\n\nexport type GoogleDriveTransferSkipReason =\n | \"file_too_large\"\n | \"folder_limit\"\n | \"folder_loop\"\n | \"shortcut_unsupported\"\n | \"trashed\"\n | \"unsupported_file_type\"\n | \"unsupported_native_type\";\n\nexport type GoogleDriveTransferPlan =\n | { action: \"traverse\" }\n | {\n action: \"export\";\n contentType: string;\n filename: string;\n declaredBytes: null;\n }\n | {\n action: \"download\";\n contentType: string;\n filename: string;\n declaredBytes: string | null;\n }\n | { action: \"skip\"; reason: GoogleDriveTransferSkipReason };\n\nexport type GoogleDriveInventoryEntry = {\n externalObjectId: string;\n externalVersionId: string | null;\n sourceId: string;\n parentFolderId: string;\n driveId: string | null;\n title: string;\n mimeType: string;\n modifiedTime: string | null;\n createdTime: string | null;\n sourceUri: string;\n transfer: GoogleDriveTransferPlan;\n};\n\nexport type GoogleDriveInventoryIssue = {\n code: \"incomplete_search\" | \"invalid_page\" | \"provider_error\";\n folderId: string;\n providerCode: string | null;\n};\n\nexport type GoogleDriveInventoryStopReason =\n | \"api_request_limit\"\n | \"elapsed_time_limit\"\n | \"incomplete_search\"\n | \"item_limit\"\n | \"known_byte_limit\"\n | \"provider_error\";\n\nexport type GoogleDriveInventoryTotals = {\n itemCount: number;\n folderCount: number;\n plannedFileCount: number;\n skippedItemCount: number;\n exportFileCount: number;\n downloadFileCount: number;\n unknownSizeFileCount: number;\n apiRequestCount: number;\n knownBytes: string;\n};\n\ntype GoogleDriveInventoryFrame = {\n folderId: string;\n driveId: string | null;\n pageToken: string | null;\n loaded: boolean;\n bufferedItems: GoogleDriveInventoryProviderItem[];\n nextPageToken: string | null;\n};\n\nexport type GoogleDriveInventoryCheckpoint = {\n version: 2;\n googlePermissionId: string;\n externalTenantId: string;\n sourceId: string;\n sourceDriveId: string | null;\n scope: ScopedKnowledgeScope;\n pendingFolders: GoogleDriveInventoryFrame[];\n seenFolderIds: string[];\n totals: GoogleDriveInventoryTotals;\n};\n\nexport type GoogleDriveInventoryResult = {\n status: \"complete\" | \"paused\";\n stopReason: GoogleDriveInventoryStopReason | null;\n source: GoogleDriveKnowledgeSourceIdentity;\n entries: GoogleDriveInventoryEntry[];\n issues: GoogleDriveInventoryIssue[];\n totals: GoogleDriveInventoryTotals;\n run: GoogleDriveInventoryTotals & { elapsedMs: number };\n checkpoint: GoogleDriveInventoryCheckpoint | null;\n};\n\nexport type GoogleDriveListChildren = (input: {\n folderId: string;\n driveId: string | null;\n pageToken: string | null;\n pageSize: number;\n}) => Promise<GoogleDriveInventoryPage>;\n\nexport class GoogleDriveInventoryProviderError extends Error {\n constructor(readonly providerCode: string) {\n super(providerCode);\n this.name = \"GoogleDriveInventoryProviderError\";\n }\n}\n\nexport function googleDriveKnowledgeScope(\n destination: ConnectorDocumentDestination,\n): ScopedKnowledgeScope {\n const authority = connectorDestinationDocumentAuthority(destination);\n if (authority.authorityKind === \"organization\") {\n return { kind: \"organization\", workspaceId: null, subjectId: null };\n }\n if (authority.authorityKind === \"workspace\") {\n if (!authority.authorityWorkspaceId) {\n throw new Error(\"workspace connector destination is missing workspace authority\");\n }\n return {\n kind: \"workspace\",\n workspaceId: authority.authorityWorkspaceId,\n subjectId: null,\n };\n }\n if (!authority.authorityWorkspaceId || !authority.authoritySubjectId) {\n throw new Error(\"personal connector destination is missing immutable authority\");\n }\n return {\n kind: \"personal\",\n workspaceId: authority.authorityWorkspaceId,\n subjectId: authority.authoritySubjectId,\n };\n}\n\nexport function googleDriveKnowledgeSourceIdentity(input: {\n googlePermissionId: string;\n source: Pick<GoogleDriveSelectedSource, \"id\" | \"driveId\" | \"destination\" | \"targetScope\">;\n accountId?: string | undefined;\n workspaceId: string;\n connectionSubjectId?: string | null | undefined;\n /** @deprecated Used only to validate old callers while source destinations migrate. */\n initiatingSubjectId?: string | undefined;\n}): GoogleDriveKnowledgeSourceIdentity {\n const sourceId = driveId(input.source.id, \"source.id\");\n const externalTenantId = normalizedGooglePermissionId(input.googlePermissionId);\n const sourceDriveId = nullableDriveId(input.source.driveId, \"source.driveId\");\n const destination = resolveConnectorDocumentDestination(input.source.destination, {\n accountId: input.accountId ?? input.workspaceId,\n workspaceId: input.workspaceId,\n connectionSubjectId:\n input.connectionSubjectId !== undefined\n ? input.connectionSubjectId\n : (input.initiatingSubjectId ?? null),\n });\n return {\n providerKey: GOOGLE_DRIVE_PROVIDER_KEY,\n externalTenantId,\n externalSourceId: sourceId,\n sourceKind:\n sourceId === \"root\"\n ? \"google-drive-my-drive\"\n : sourceDriveId === sourceId\n ? \"google-drive-shared-drive\"\n : \"google-drive-folder\",\n sourceUri: googleDriveSourceUri(sourceId),\n scope: googleDriveKnowledgeScope(destination),\n };\n}\n\nexport function planGoogleDriveTransfer(\n item: GoogleDriveInventoryProviderItem,\n maxFileBytes: number,\n): GoogleDriveTransferPlan {\n const normalized = validatedProviderItem(item);\n const byteLimit = safePositiveInteger(maxFileBytes, \"maxFileBytes\");\n if (normalized.trashed) {\n return { action: \"skip\", reason: \"trashed\" };\n }\n if (normalized.mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE) {\n return { action: \"traverse\" };\n }\n if (normalized.mimeType === GOOGLE_DRIVE_SHORTCUT_MIME_TYPE) {\n return { action: \"skip\", reason: \"shortcut_unsupported\" };\n }\n const nativeExport = GOOGLE_DRIVE_NATIVE_EXPORTS.get(normalized.mimeType);\n if (nativeExport) {\n return {\n action: \"export\",\n contentType: nativeExport.contentType,\n filename: exportedFilename(normalized.name, nativeExport.extension),\n declaredBytes: null,\n };\n }\n if (normalized.mimeType.startsWith(GOOGLE_DRIVE_NATIVE_MIME_PREFIX)) {\n return { action: \"skip\", reason: \"unsupported_native_type\" };\n }\n const declaredBytes = fileSize(normalized.size);\n if (declaredBytes !== null && declaredBytes > BigInt(byteLimit)) {\n return { action: \"skip\", reason: \"file_too_large\" };\n }\n const contentType = dependencyFreeOrdinaryContentType(normalized.name, normalized.mimeType);\n if (!contentType) {\n return { action: \"skip\", reason: \"unsupported_file_type\" };\n }\n return {\n action: \"download\",\n contentType,\n filename: safeFilename(normalized.name),\n declaredBytes: declaredBytes?.toString() ?? null,\n };\n}\n\nexport async function inventoryGoogleDriveSource(input: {\n googlePermissionId: string;\n source: GoogleDriveSelectedSource;\n accountId?: string | undefined;\n workspaceId: string;\n connectionSubjectId?: string | null | undefined;\n /** @deprecated Used only to validate old callers while source destinations migrate. */\n initiatingSubjectId?: string | undefined;\n limits: GoogleDriveInventoryLimits;\n listChildren: GoogleDriveListChildren;\n checkpoint?: GoogleDriveInventoryCheckpoint | null;\n now?: (() => number) | undefined;\n}): Promise<GoogleDriveInventoryResult> {\n const limits = validatedLimits(input.limits);\n const googlePermissionId = normalizedGooglePermissionId(input.googlePermissionId);\n const source = googleDriveKnowledgeSourceIdentity({\n googlePermissionId,\n source: input.source,\n ...(input.accountId ? { accountId: input.accountId } : {}),\n workspaceId: input.workspaceId,\n ...(input.connectionSubjectId !== undefined\n ? { connectionSubjectId: input.connectionSubjectId }\n : {}),\n ...(input.initiatingSubjectId ? { initiatingSubjectId: input.initiatingSubjectId } : {}),\n });\n const checkpointIdentity: GoogleDriveInventoryCheckpointIdentity = {\n googlePermissionId,\n externalTenantId: source.externalTenantId,\n sourceId: source.externalSourceId,\n sourceDriveId: nullableDriveId(input.source.driveId, \"source.driveId\"),\n scope: source.scope,\n };\n const now = input.now ?? Date.now;\n const startedAt = now();\n const checkpoint = input.checkpoint\n ? validatedCheckpoint(input.checkpoint, checkpointIdentity, limits)\n : initialCheckpoint(checkpointIdentity);\n const initialTotals = cloneTotals(checkpoint.totals);\n const entries: GoogleDriveInventoryEntry[] = [];\n const issues: GoogleDriveInventoryIssue[] = [];\n let stopReason: GoogleDriveInventoryStopReason | null = null;\n\n while (checkpoint.pendingFolders.length > 0) {\n if (now() - startedAt >= limits.maxElapsedMs) {\n stopReason = \"elapsed_time_limit\";\n break;\n }\n const frame = checkpoint.pendingFolders[0]!;\n if (frame.loaded && frame.bufferedItems.length === 0) {\n if (frame.nextPageToken) {\n frame.pageToken = frame.nextPageToken;\n frame.nextPageToken = null;\n frame.loaded = false;\n } else {\n checkpoint.pendingFolders.shift();\n }\n continue;\n }\n if (checkpoint.totals.itemCount >= limits.maxItems) {\n stopReason = \"item_limit\";\n break;\n }\n\n if (!frame.loaded) {\n if (checkpoint.totals.apiRequestCount >= limits.maxApiRequests) {\n stopReason = \"api_request_limit\";\n break;\n }\n const remainingItems = limits.maxItems - checkpoint.totals.itemCount;\n const requestedPageSize = Math.min(limits.pageSize, remainingItems);\n let page: GoogleDriveInventoryPage;\n try {\n page = await input.listChildren({\n folderId: frame.folderId,\n driveId: frame.driveId,\n pageToken: frame.pageToken,\n pageSize: requestedPageSize,\n });\n } catch (error) {\n checkpoint.totals.apiRequestCount += 1;\n issues.push({\n code: \"provider_error\",\n folderId: frame.folderId,\n providerCode: providerErrorCode(error),\n });\n stopReason = \"provider_error\";\n break;\n }\n checkpoint.totals.apiRequestCount += 1;\n if (!validPage(page, requestedPageSize)) {\n issues.push({ code: \"invalid_page\", folderId: frame.folderId, providerCode: null });\n stopReason = \"provider_error\";\n break;\n }\n if (page.incompleteSearch) {\n issues.push({ code: \"incomplete_search\", folderId: frame.folderId, providerCode: null });\n stopReason = \"incomplete_search\";\n break;\n }\n frame.loaded = true;\n frame.bufferedItems = page.items.map(validatedProviderItem);\n frame.nextPageToken = page.nextPageToken;\n if (now() - startedAt >= limits.maxElapsedMs) {\n stopReason = \"elapsed_time_limit\";\n break;\n }\n }\n\n if (frame.bufferedItems.length === 0) {\n if (frame.nextPageToken) {\n frame.pageToken = frame.nextPageToken;\n frame.nextPageToken = null;\n frame.loaded = false;\n } else {\n checkpoint.pendingFolders.shift();\n }\n continue;\n }\n\n const item = validatedProviderItem(frame.bufferedItems[0]!);\n let transfer = planGoogleDriveTransfer(item, limits.maxFileBytes);\n if (transfer.action === \"download\" && transfer.declaredBytes !== null) {\n const nextKnownBytes = BigInt(checkpoint.totals.knownBytes) + BigInt(transfer.declaredBytes);\n if (nextKnownBytes > BigInt(limits.maxKnownBytes)) {\n stopReason = \"known_byte_limit\";\n break;\n }\n }\n\n frame.bufferedItems.shift();\n checkpoint.totals.itemCount += 1;\n const effectiveDriveId = item.driveId ?? frame.driveId;\n if (transfer.action === \"traverse\") {\n if (checkpoint.seenFolderIds.includes(item.id)) {\n transfer = { action: \"skip\", reason: \"folder_loop\" };\n } else if (checkpoint.seenFolderIds.length >= limits.maxFolders) {\n transfer = { action: \"skip\", reason: \"folder_limit\" };\n } else {\n checkpoint.seenFolderIds.push(item.id);\n checkpoint.totals.folderCount += 1;\n checkpoint.pendingFolders.push({\n folderId: item.id,\n driveId: effectiveDriveId,\n pageToken: null,\n loaded: false,\n bufferedItems: [],\n nextPageToken: null,\n });\n }\n }\n\n if (transfer.action === \"skip\") {\n checkpoint.totals.skippedItemCount += 1;\n } else if (transfer.action === \"download\") {\n checkpoint.totals.plannedFileCount += 1;\n checkpoint.totals.downloadFileCount += 1;\n if (transfer.declaredBytes === null) {\n checkpoint.totals.unknownSizeFileCount += 1;\n } else {\n checkpoint.totals.knownBytes = (\n BigInt(checkpoint.totals.knownBytes) + BigInt(transfer.declaredBytes)\n ).toString();\n }\n } else if (transfer.action === \"export\") {\n checkpoint.totals.plannedFileCount += 1;\n checkpoint.totals.exportFileCount += 1;\n checkpoint.totals.unknownSizeFileCount += 1;\n }\n\n entries.push({\n externalObjectId: item.id,\n externalVersionId: item.version ?? item.md5Checksum ?? item.modifiedTime,\n sourceId: source.externalSourceId,\n parentFolderId: frame.folderId,\n driveId: effectiveDriveId,\n title: item.name,\n mimeType: item.mimeType,\n modifiedTime: item.modifiedTime,\n createdTime: item.createdTime,\n sourceUri: item.webViewLink ?? googleDriveFileUri(item.id),\n transfer,\n });\n }\n\n const elapsedMs = Math.max(0, now() - startedAt);\n const complete = checkpoint.pendingFolders.length === 0;\n const outputCheckpoint = complete ? null : cloneCheckpoint(checkpoint);\n if (outputCheckpoint) assertCheckpointBytes(outputCheckpoint);\n return {\n status: complete ? \"complete\" : \"paused\",\n stopReason: complete ? null : stopReason,\n source,\n entries,\n issues,\n totals: cloneTotals(checkpoint.totals),\n run: {\n ...subtractTotals(checkpoint.totals, initialTotals),\n elapsedMs,\n },\n checkpoint: outputCheckpoint,\n };\n}\n\ntype GoogleDriveInventoryCheckpointIdentity = Pick<\n GoogleDriveInventoryCheckpoint,\n \"googlePermissionId\" | \"externalTenantId\" | \"sourceId\" | \"sourceDriveId\" | \"scope\"\n>;\n\nfunction initialCheckpoint(\n identity: GoogleDriveInventoryCheckpointIdentity,\n): GoogleDriveInventoryCheckpoint {\n return {\n version: 2,\n googlePermissionId: identity.googlePermissionId,\n externalTenantId: identity.externalTenantId,\n sourceId: identity.sourceId,\n sourceDriveId: identity.sourceDriveId,\n scope: cloneScope(identity.scope),\n pendingFolders: [\n {\n folderId: identity.sourceId,\n driveId: identity.sourceDriveId,\n pageToken: null,\n loaded: false,\n bufferedItems: [],\n nextPageToken: null,\n },\n ],\n seenFolderIds: [identity.sourceId],\n totals: emptyTotals(),\n };\n}\n\nfunction validatedCheckpoint(\n value: GoogleDriveInventoryCheckpoint,\n identity: GoogleDriveInventoryCheckpointIdentity,\n limits: GoogleDriveInventoryLimits,\n): GoogleDriveInventoryCheckpoint {\n if (!value || typeof value !== \"object\" || value.version !== 2) {\n throw new Error(\"unsupported Google Drive inventory checkpoint\");\n }\n if (\n value.googlePermissionId !== identity.googlePermissionId ||\n value.externalTenantId !== identity.externalTenantId ||\n value.sourceId !== identity.sourceId ||\n value.sourceDriveId !== identity.sourceDriveId ||\n !sameScope(value.scope, identity.scope)\n ) {\n throw new Error(\"Google Drive inventory checkpoint does not match the selected source\");\n }\n const checkpoint = cloneCheckpoint(value);\n if (checkpoint.pendingFolders.length === 0) {\n throw new Error(\"Google Drive inventory checkpoint is already complete\");\n }\n if (\n checkpoint.pendingFolders.length > GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS ||\n checkpoint.seenFolderIds.length > GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS ||\n checkpoint.seenFolderIds.length > limits.maxFolders\n ) {\n throw new Error(\"Google Drive inventory checkpoint exceeds the folder limit\");\n }\n if (!checkpoint.seenFolderIds.includes(identity.sourceId)) {\n throw new Error(\"Google Drive inventory checkpoint lost its source boundary\");\n }\n if (new Set(checkpoint.seenFolderIds).size !== checkpoint.seenFolderIds.length) {\n throw new Error(\"Google Drive inventory checkpoint contains duplicate folder identity\");\n }\n for (const folderId of checkpoint.seenFolderIds) driveId(folderId, \"checkpoint.folderId\");\n const pendingFolderIds = new Set<string>();\n for (const frame of checkpoint.pendingFolders) {\n driveId(frame.folderId, \"checkpoint.pending.folderId\");\n if (\n !checkpoint.seenFolderIds.includes(frame.folderId) ||\n pendingFolderIds.has(frame.folderId)\n ) {\n throw new Error(\"Google Drive inventory checkpoint contains an invalid pending folder\");\n }\n pendingFolderIds.add(frame.folderId);\n nullableDriveId(frame.driveId, \"checkpoint.pending.driveId\");\n pageToken(frame.pageToken, \"checkpoint.pending.pageToken\");\n pageToken(frame.nextPageToken, \"checkpoint.pending.nextPageToken\");\n if (\n typeof frame.loaded !== \"boolean\" ||\n frame.bufferedItems.length > GOOGLE_DRIVE_MAX_PAGE_ITEMS\n ) {\n throw new Error(\"Google Drive inventory checkpoint contains an invalid page frame\");\n }\n if (!frame.loaded && (frame.bufferedItems.length > 0 || frame.nextPageToken !== null)) {\n throw new Error(\"Google Drive inventory checkpoint contains an uncommitted page frame\");\n }\n frame.bufferedItems = frame.bufferedItems.map(validatedProviderItem);\n }\n validatedTotals(checkpoint.totals);\n if (\n checkpoint.totals.folderCount !== checkpoint.seenFolderIds.length ||\n checkpoint.totals.plannedFileCount !==\n checkpoint.totals.exportFileCount + checkpoint.totals.downloadFileCount ||\n checkpoint.totals.unknownSizeFileCount > checkpoint.totals.plannedFileCount ||\n checkpoint.totals.itemCount !==\n checkpoint.totals.skippedItemCount +\n checkpoint.totals.plannedFileCount +\n checkpoint.totals.folderCount -\n 1\n ) {\n throw new Error(\"Google Drive inventory checkpoint totals are inconsistent\");\n }\n if (\n checkpoint.totals.itemCount > limits.maxItems ||\n checkpoint.totals.apiRequestCount > limits.maxApiRequests ||\n BigInt(checkpoint.totals.knownBytes) > BigInt(limits.maxKnownBytes)\n ) {\n throw new Error(\"Google Drive inventory checkpoint exceeds the supplied limits\");\n }\n assertCheckpointBytes(checkpoint);\n return checkpoint;\n}\n\nfunction validatedLimits(value: GoogleDriveInventoryLimits): GoogleDriveInventoryLimits {\n const limits = {\n maxItems: safePositiveInteger(value.maxItems, \"limits.maxItems\"),\n maxKnownBytes: safePositiveInteger(value.maxKnownBytes, \"limits.maxKnownBytes\"),\n maxApiRequests: safePositiveInteger(value.maxApiRequests, \"limits.maxApiRequests\"),\n maxElapsedMs: safePositiveInteger(value.maxElapsedMs, \"limits.maxElapsedMs\"),\n maxFileBytes: safePositiveInteger(value.maxFileBytes, \"limits.maxFileBytes\"),\n maxFolders: safePositiveInteger(value.maxFolders, \"limits.maxFolders\"),\n pageSize: safePositiveInteger(value.pageSize, \"limits.pageSize\"),\n };\n if (limits.pageSize > GOOGLE_DRIVE_MAX_PAGE_ITEMS) {\n throw new Error(`limits.pageSize must be <= ${GOOGLE_DRIVE_MAX_PAGE_ITEMS}`);\n }\n if (limits.maxFolders > GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS) {\n throw new Error(`limits.maxFolders must be <= ${GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS}`);\n }\n return limits;\n}\n\nfunction validPage(value: GoogleDriveInventoryPage, expectedMaxItems: number): boolean {\n if (\n !value ||\n !Array.isArray(value.items) ||\n value.items.length > expectedMaxItems ||\n value.items.length > GOOGLE_DRIVE_MAX_PAGE_ITEMS\n ) {\n return false;\n }\n try {\n pageToken(value.nextPageToken, \"page.nextPageToken\");\n value.items.forEach(validatedProviderItem);\n return typeof value.incompleteSearch === \"boolean\";\n } catch {\n return false;\n }\n}\n\nfunction validatedProviderItem(\n item: GoogleDriveInventoryProviderItem,\n): GoogleDriveInventoryProviderItem {\n const id = driveId(item.id, \"item.id\");\n const name = boundedText(item.name, \"item.name\", GOOGLE_DRIVE_MAX_NAME_CHARS);\n const mimeType = boundedText(item.mimeType, \"item.mimeType\", GOOGLE_DRIVE_MAX_MIME_CHARS);\n const parents = Array.isArray(item.parents)\n ? item.parents.map((parent) => driveId(parent, \"item.parent\"))\n : [];\n if (parents.length > 100) throw new Error(\"item.parents exceeds the supported bound\");\n return {\n id,\n name,\n mimeType,\n driveId: nullableDriveId(item.driveId, \"item.driveId\"),\n parents,\n modifiedTime: nullableBoundedText(item.modifiedTime, \"item.modifiedTime\", 128),\n createdTime: nullableBoundedText(item.createdTime, \"item.createdTime\", 128),\n version: nullableBoundedText(item.version, \"item.version\", 256),\n md5Checksum: nullableBoundedText(item.md5Checksum, \"item.md5Checksum\", 128),\n size: fileSize(item.size)?.toString() ?? null,\n webViewLink: nullableHttpsUrl(item.webViewLink, \"item.webViewLink\"),\n trashed: item.trashed === true,\n };\n}\n\nfunction dependencyFreeOrdinaryContentType(name: string, mimeType: string): string | null {\n const normalizedMime = mimeType.trim().toLowerCase();\n if (normalizedMime.startsWith(\"text/\")) return normalizedMime;\n if (DEPENDENCY_FREE_ORDINARY_CONTENT_TYPES.has(normalizedMime)) return normalizedMime;\n if (!GENERIC_BINARY_CONTENT_TYPES.has(normalizedMime)) return null;\n const lowerName = name.toLowerCase();\n for (const [extension, contentType] of DEPENDENCY_FREE_EXTENSION_CONTENT_TYPES) {\n if (lowerName.endsWith(extension)) return contentType;\n }\n return null;\n}\n\nfunction exportedFilename(name: string, extension: string): string {\n const filename = safeFilename(name);\n return filename.toLowerCase().endsWith(extension) ? filename : `${filename}${extension}`;\n}\n\nfunction safeFilename(value: string): string {\n const cleaned = value\n .normalize(\"NFKC\")\n .replace(/[\\u0000-\\u001f\\u007f/\\\\]/gu, \" \")\n .replace(/\\s+/gu, \" \")\n .trim()\n .slice(0, 512);\n return cleaned || \"untitled\";\n}\n\nfunction googleDriveSourceUri(id: string): string {\n return id === \"root\"\n ? \"https://drive.google.com/drive/my-drive\"\n : `https://drive.google.com/drive/folders/${encodeURIComponent(id)}`;\n}\n\nfunction googleDriveFileUri(id: string): string {\n return `https://drive.google.com/open?id=${encodeURIComponent(id)}`;\n}\n\nfunction fileSize(value: string | null): bigint | null {\n if (value === null) return null;\n if (!/^\\d{1,40}$/u.test(value)) throw new Error(\"item.size is invalid\");\n return BigInt(value);\n}\n\nfunction providerErrorCode(error: unknown): string | null {\n if (!(error instanceof GoogleDriveInventoryProviderError)) return null;\n const normalized = error.providerCode.trim().toLowerCase();\n return /^[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$/u.test(normalized) ? normalized : null;\n}\n\nfunction driveId(value: string, label: string): string {\n const candidate = boundedText(value, label, GOOGLE_DRIVE_MAX_ID_CHARS);\n if (candidate === \"root\" || /^[A-Za-z0-9_-]+$/u.test(candidate)) return candidate;\n throw new Error(`${label} is invalid`);\n}\n\nfunction normalizedGooglePermissionId(value: string): string {\n return boundedText(value, \"googlePermissionId\", GOOGLE_DRIVE_MAX_ID_CHARS);\n}\n\nfunction nullableDriveId(value: string | null, label: string): string | null {\n return value === null ? null : driveId(value, label);\n}\n\nfunction pageToken(value: string | null, label: string): string | null {\n if (value === null) return null;\n return boundedText(value, label, GOOGLE_DRIVE_MAX_PAGE_TOKEN_CHARS);\n}\n\nfunction boundedText(value: string, label: string, maxChars: number): string {\n if (typeof value !== \"string\") throw new Error(`${label} must be a string`);\n const trimmed = value.trim();\n if (!trimmed || trimmed.length > maxChars || /[\\u0000-\\u001f\\u007f]/u.test(trimmed)) {\n throw new Error(`${label} is invalid`);\n }\n return trimmed;\n}\n\nfunction nullableBoundedText(value: string | null, label: string, maxChars: number): string | null {\n return value === null ? null : boundedText(value, label, maxChars);\n}\n\nfunction nullableHttpsUrl(value: string | null, label: string): string | null {\n if (value === null) return null;\n const bounded = boundedText(value, label, 4096);\n const parsed = new URL(bounded);\n if (parsed.protocol !== \"https:\") throw new Error(`${label} must use https`);\n return parsed.toString();\n}\n\nfunction safePositiveInteger(value: number, label: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new Error(`${label} must be a positive safe integer`);\n }\n return value;\n}\n\nfunction validatedTotals(totals: GoogleDriveInventoryTotals): void {\n for (const [key, value] of Object.entries(totals)) {\n if (key === \"knownBytes\") continue;\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) {\n throw new Error(`checkpoint.totals.${key} is invalid`);\n }\n }\n if (!/^\\d+$/u.test(totals.knownBytes)) {\n throw new Error(\"checkpoint.totals.knownBytes is invalid\");\n }\n}\n\nfunction emptyTotals(): GoogleDriveInventoryTotals {\n return {\n itemCount: 0,\n folderCount: 1,\n plannedFileCount: 0,\n skippedItemCount: 0,\n exportFileCount: 0,\n downloadFileCount: 0,\n unknownSizeFileCount: 0,\n apiRequestCount: 0,\n knownBytes: \"0\",\n };\n}\n\nfunction cloneTotals(value: GoogleDriveInventoryTotals): GoogleDriveInventoryTotals {\n return { ...value };\n}\n\nfunction subtractTotals(\n value: GoogleDriveInventoryTotals,\n initial: GoogleDriveInventoryTotals,\n): GoogleDriveInventoryTotals {\n return {\n itemCount: value.itemCount - initial.itemCount,\n folderCount: value.folderCount - initial.folderCount,\n plannedFileCount: value.plannedFileCount - initial.plannedFileCount,\n skippedItemCount: value.skippedItemCount - initial.skippedItemCount,\n exportFileCount: value.exportFileCount - initial.exportFileCount,\n downloadFileCount: value.downloadFileCount - initial.downloadFileCount,\n unknownSizeFileCount: value.unknownSizeFileCount - initial.unknownSizeFileCount,\n apiRequestCount: value.apiRequestCount - initial.apiRequestCount,\n knownBytes: (BigInt(value.knownBytes) - BigInt(initial.knownBytes)).toString(),\n };\n}\n\nfunction cloneProviderItem(\n value: GoogleDriveInventoryProviderItem,\n): GoogleDriveInventoryProviderItem {\n return { ...value, parents: [...value.parents] };\n}\n\nfunction cloneScope(scope: ScopedKnowledgeScope): ScopedKnowledgeScope {\n return { ...scope };\n}\n\nfunction cloneCheckpoint(value: GoogleDriveInventoryCheckpoint): GoogleDriveInventoryCheckpoint {\n return {\n version: 2,\n googlePermissionId: value.googlePermissionId,\n externalTenantId: value.externalTenantId,\n sourceId: value.sourceId,\n sourceDriveId: value.sourceDriveId,\n scope: cloneScope(value.scope),\n pendingFolders: value.pendingFolders.map((frame) => ({\n ...frame,\n bufferedItems: frame.bufferedItems.map(cloneProviderItem),\n })),\n seenFolderIds: [...value.seenFolderIds],\n totals: cloneTotals(value.totals),\n };\n}\n\nfunction sameScope(\n left: ScopedKnowledgeScope | null | undefined,\n right: ScopedKnowledgeScope,\n): boolean {\n return (\n !!left &&\n typeof left === \"object\" &&\n left.kind === right.kind &&\n left.workspaceId === right.workspaceId &&\n left.subjectId === right.subjectId\n );\n}\n\nfunction assertCheckpointBytes(checkpoint: GoogleDriveInventoryCheckpoint): void {\n if (Buffer.byteLength(JSON.stringify(checkpoint), \"utf8\") > GOOGLE_DRIVE_MAX_CHECKPOINT_BYTES) {\n throw new Error(\"Google Drive inventory checkpoint exceeds the serialized byte limit\");\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAGA,IAAM,4BAA4B;AAClC,IAAM,gCAAgC;AACtC,IAAM,kCAAkC;AAE/C,IAAM,kCAAkC;AACxC,IAAM,4BAA4B;AAClC,IAAM,8BAA8B;AACpC,IAAM,8BAA8B;AACpC,IAAM,oCAAoC;AAC1C,IAAM,8BAA8B;AACpC,IAAM,sCAAsC;AAC5C,IAAM,oCAAoC,IAAI,OAAO;AAErD,IAAM,8BAA8B,oBAAI,IAAwD;AAAA,EAC9F;AAAA,IACE;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA;AAAA,IACE;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA;AAAA,IACE;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,WAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,CAAC,uCAAuC,EAAE,aAAa,mBAAmB,WAAW,OAAO,CAAC;AAC/F,CAAC;AAED,IAAM,yCAAyC,oBAAI,IAAI;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,+BAA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AA,EACvF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/google-drive.ts"],"sourcesContent":["import type { ScopedKnowledgeScope } from \"@opengeni/contracts\";\nimport {\n connectorDestinationDocumentAuthority,\n resolveConnectorDocumentDestination,\n type ConnectorDocumentDestination,\n} from \"@opengeni/contracts/connector-destinations\";\nimport type { GoogleDriveSelectedSource } from \"@opengeni/contracts/google-drive\";\n\nexport const GOOGLE_DRIVE_PROVIDER_KEY = \"google-drive\" as const;\nexport const GOOGLE_DRIVE_FOLDER_MIME_TYPE = \"application/vnd.google-apps.folder\" as const;\nexport const GOOGLE_DRIVE_SHORTCUT_MIME_TYPE = \"application/vnd.google-apps.shortcut\" as const;\n\nconst GOOGLE_DRIVE_NATIVE_MIME_PREFIX = \"application/vnd.google-apps.\";\nconst GOOGLE_DRIVE_MAX_ID_CHARS = 256;\nconst GOOGLE_DRIVE_MAX_NAME_CHARS = 1024;\nconst GOOGLE_DRIVE_MAX_MIME_CHARS = 256;\nconst GOOGLE_DRIVE_MAX_PAGE_TOKEN_CHARS = 4096;\nconst GOOGLE_DRIVE_MAX_PAGE_ITEMS = 100;\nconst GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS = 2_000;\nconst GOOGLE_DRIVE_MAX_CHECKPOINT_BYTES = 2 * 1024 * 1024;\n\nconst GOOGLE_DRIVE_NATIVE_EXPORTS = new Map<string, { contentType: string; extension: string }>([\n [\n \"application/vnd.google-apps.document\",\n {\n contentType: \"application/pdf\",\n extension: \".pdf\",\n },\n ],\n [\n \"application/vnd.google-apps.spreadsheet\",\n {\n contentType: \"application/pdf\",\n extension: \".pdf\",\n },\n ],\n [\n \"application/vnd.google-apps.presentation\",\n {\n contentType: \"application/pdf\",\n extension: \".pdf\",\n },\n ],\n [\"application/vnd.google-apps.drawing\", { contentType: \"application/pdf\", extension: \".pdf\" }],\n]);\n\nconst DEPENDENCY_FREE_ORDINARY_CONTENT_TYPES = new Set([\n \"application/json\",\n \"application/pdf\",\n \"application/xml\",\n \"application/x-yaml\",\n \"application/yaml\",\n]);\n\nconst GENERIC_BINARY_CONTENT_TYPES = new Set([\"application/octet-stream\", \"binary/octet-stream\"]);\n\nconst DEPENDENCY_FREE_EXTENSION_CONTENT_TYPES = new Map([\n [\".csv\", \"text/csv\"],\n [\".htm\", \"text/html\"],\n [\".html\", \"text/html\"],\n [\".json\", \"application/json\"],\n [\".markdown\", \"text/markdown\"],\n [\".md\", \"text/markdown\"],\n [\".pdf\", \"application/pdf\"],\n [\".text\", \"text/plain\"],\n [\".tsv\", \"text/tab-separated-values\"],\n [\".txt\", \"text/plain\"],\n [\".xml\", \"application/xml\"],\n [\".yaml\", \"application/x-yaml\"],\n [\".yml\", \"application/x-yaml\"],\n]);\n\nexport type GoogleDriveKnowledgeSourceIdentity = {\n providerKey: typeof GOOGLE_DRIVE_PROVIDER_KEY;\n externalTenantId: string;\n externalSourceId: string;\n sourceKind: \"google-drive-my-drive\" | \"google-drive-shared-drive\" | \"google-drive-folder\";\n sourceUri: string;\n scope: ScopedKnowledgeScope;\n};\n\n/**\n * Normalized item metadata expected from a bounded Drive files.list adapter.\n * The adapter owns provider JSON validation; this planner owns traversal,\n * checkpointing, resource limits, stable identity, and transfer classification.\n */\nexport type GoogleDriveInventoryProviderItem = {\n id: string;\n name: string;\n mimeType: string;\n driveId: string | null;\n parents: string[];\n modifiedTime: string | null;\n createdTime: string | null;\n version: string | null;\n md5Checksum: string | null;\n size: string | null;\n webViewLink: string | null;\n trashed: boolean;\n};\n\nexport type GoogleDriveInventoryPage = {\n items: GoogleDriveInventoryProviderItem[];\n nextPageToken: string | null;\n incompleteSearch: boolean;\n};\n\nexport type GoogleDriveInventoryLimits = {\n /** Hard cumulative provider-item discovery limit for this checkpoint. */\n maxItems: number;\n /** Hard cumulative known-byte limit for ordinary file downloads. */\n maxKnownBytes: number;\n /** Hard cumulative Drive list request/cost limit for this checkpoint. */\n maxApiRequests: number;\n /** Wall-clock budget for one invocation; checkpoint counters remain cumulative. */\n maxElapsedMs: number;\n /** Per-file byte ceiling. Unknown/export sizes must be enforced again while streaming. */\n maxFileBytes: number;\n /** Cycle/graph explosion guard for traversed folders. */\n maxFolders: number;\n /** Requested Drive page size. */\n pageSize: number;\n};\n\nexport type GoogleDriveTransferSkipReason =\n | \"file_too_large\"\n | \"folder_limit\"\n | \"folder_loop\"\n | \"shortcut_unsupported\"\n | \"trashed\"\n | \"unsupported_file_type\"\n | \"unsupported_native_type\";\n\nexport type GoogleDriveTransferPlan =\n | { action: \"traverse\" }\n | {\n action: \"export\";\n contentType: string;\n filename: string;\n declaredBytes: null;\n }\n | {\n action: \"download\";\n contentType: string;\n filename: string;\n declaredBytes: string | null;\n }\n | { action: \"skip\"; reason: GoogleDriveTransferSkipReason };\n\nexport type GoogleDriveInventoryEntry = {\n externalObjectId: string;\n externalVersionId: string | null;\n sourceId: string;\n parentFolderId: string;\n driveId: string | null;\n title: string;\n mimeType: string;\n modifiedTime: string | null;\n createdTime: string | null;\n sourceUri: string;\n transfer: GoogleDriveTransferPlan;\n};\n\nexport type GoogleDriveInventoryIssue = {\n code: \"incomplete_search\" | \"invalid_page\" | \"provider_error\";\n folderId: string;\n providerCode: string | null;\n};\n\nexport type GoogleDriveInventoryStopReason =\n | \"api_request_limit\"\n | \"elapsed_time_limit\"\n | \"incomplete_search\"\n | \"item_limit\"\n | \"known_byte_limit\"\n | \"provider_error\";\n\nexport type GoogleDriveInventoryTotals = {\n itemCount: number;\n folderCount: number;\n plannedFileCount: number;\n skippedItemCount: number;\n exportFileCount: number;\n downloadFileCount: number;\n unknownSizeFileCount: number;\n apiRequestCount: number;\n knownBytes: string;\n};\n\ntype GoogleDriveInventoryFrame = {\n folderId: string;\n driveId: string | null;\n pageToken: string | null;\n loaded: boolean;\n bufferedItems: GoogleDriveInventoryProviderItem[];\n nextPageToken: string | null;\n};\n\nexport type GoogleDriveInventoryCheckpoint = {\n version: 2;\n googlePermissionId: string;\n externalTenantId: string;\n sourceId: string;\n sourceDriveId: string | null;\n scope: ScopedKnowledgeScope;\n pendingFolders: GoogleDriveInventoryFrame[];\n seenFolderIds: string[];\n totals: GoogleDriveInventoryTotals;\n};\n\nexport type GoogleDriveInventoryResult = {\n status: \"complete\" | \"paused\";\n stopReason: GoogleDriveInventoryStopReason | null;\n source: GoogleDriveKnowledgeSourceIdentity;\n entries: GoogleDriveInventoryEntry[];\n issues: GoogleDriveInventoryIssue[];\n totals: GoogleDriveInventoryTotals;\n run: GoogleDriveInventoryTotals & { elapsedMs: number };\n checkpoint: GoogleDriveInventoryCheckpoint | null;\n};\n\nexport type GoogleDriveListChildren = (input: {\n folderId: string;\n driveId: string | null;\n pageToken: string | null;\n pageSize: number;\n}) => Promise<GoogleDriveInventoryPage>;\n\nexport class GoogleDriveInventoryProviderError extends Error {\n constructor(readonly providerCode: string) {\n super(providerCode);\n this.name = \"GoogleDriveInventoryProviderError\";\n }\n}\n\nexport function googleDriveKnowledgeScope(\n destination: ConnectorDocumentDestination,\n): ScopedKnowledgeScope {\n const authority = connectorDestinationDocumentAuthority(destination);\n if (authority.authorityKind === \"organization\") {\n return { kind: \"organization\", workspaceId: null, subjectId: null };\n }\n if (authority.authorityKind === \"workspace\") {\n if (!authority.authorityWorkspaceId) {\n throw new Error(\"workspace connector destination is missing workspace authority\");\n }\n return {\n kind: \"workspace\",\n workspaceId: authority.authorityWorkspaceId,\n subjectId: null,\n };\n }\n if (!authority.authorityWorkspaceId || !authority.authoritySubjectId) {\n throw new Error(\"personal connector destination is missing immutable authority\");\n }\n return {\n kind: \"personal\",\n workspaceId: authority.authorityWorkspaceId,\n subjectId: authority.authoritySubjectId,\n };\n}\n\nexport function googleDriveKnowledgeSourceIdentity(input: {\n googlePermissionId: string;\n googleEmail?: string | undefined;\n source: Pick<GoogleDriveSelectedSource, \"id\" | \"driveId\" | \"destination\" | \"targetScope\">;\n accountId?: string | undefined;\n workspaceId: string;\n connectionSubjectId?: string | null | undefined;\n /** @deprecated Used only to validate old callers while source destinations migrate. */\n initiatingSubjectId?: string | undefined;\n}): GoogleDriveKnowledgeSourceIdentity {\n const sourceId = driveId(input.source.id, \"source.id\");\n // permissionId identifies a principal, not a Google tenant. Consumer\n // accounts intentionally share one provider tenant partition; Workspace\n // accounts use their normalized hosted domain. Per-principal authority stays\n // on the immutable connection owner binding.\n const externalTenantId = googleTenantIdentity(input.googleEmail);\n const sourceDriveId = nullableDriveId(input.source.driveId, \"source.driveId\");\n const destination = resolveConnectorDocumentDestination(input.source.destination, {\n accountId: input.accountId ?? input.workspaceId,\n workspaceId: input.workspaceId,\n connectionSubjectId:\n input.connectionSubjectId !== undefined\n ? input.connectionSubjectId\n : (input.initiatingSubjectId ?? null),\n });\n return {\n providerKey: GOOGLE_DRIVE_PROVIDER_KEY,\n externalTenantId,\n externalSourceId: sourceId,\n sourceKind:\n sourceId === \"root\"\n ? \"google-drive-my-drive\"\n : sourceDriveId === sourceId\n ? \"google-drive-shared-drive\"\n : \"google-drive-folder\",\n sourceUri: googleDriveSourceUri(sourceId),\n scope: googleDriveKnowledgeScope(destination),\n };\n}\n\nfunction googleTenantIdentity(email: string | undefined): string {\n if (email === undefined) return \"google-consumer\";\n const normalized = email.trim().toLowerCase();\n const separator = normalized.lastIndexOf(\"@\");\n if (separator <= 0 || separator === normalized.length - 1) {\n throw new Error(\"googleEmail must be a normalized email address\");\n }\n const domain = normalized.slice(separator + 1);\n return domain === \"gmail.com\" || domain === \"googlemail.com\"\n ? \"google-consumer\"\n : `google-workspace:${domain}`;\n}\n\nexport function planGoogleDriveTransfer(\n item: GoogleDriveInventoryProviderItem,\n maxFileBytes: number,\n): GoogleDriveTransferPlan {\n const normalized = validatedProviderItem(item);\n const byteLimit = safePositiveInteger(maxFileBytes, \"maxFileBytes\");\n if (normalized.trashed) {\n return { action: \"skip\", reason: \"trashed\" };\n }\n if (normalized.mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE) {\n return { action: \"traverse\" };\n }\n if (normalized.mimeType === GOOGLE_DRIVE_SHORTCUT_MIME_TYPE) {\n return { action: \"skip\", reason: \"shortcut_unsupported\" };\n }\n const nativeExport = GOOGLE_DRIVE_NATIVE_EXPORTS.get(normalized.mimeType);\n if (nativeExport) {\n return {\n action: \"export\",\n contentType: nativeExport.contentType,\n filename: exportedFilename(normalized.name, nativeExport.extension),\n declaredBytes: null,\n };\n }\n if (normalized.mimeType.startsWith(GOOGLE_DRIVE_NATIVE_MIME_PREFIX)) {\n return { action: \"skip\", reason: \"unsupported_native_type\" };\n }\n const declaredBytes = fileSize(normalized.size);\n if (declaredBytes !== null && declaredBytes > BigInt(byteLimit)) {\n return { action: \"skip\", reason: \"file_too_large\" };\n }\n const contentType = dependencyFreeOrdinaryContentType(normalized.name, normalized.mimeType);\n if (!contentType) {\n return { action: \"skip\", reason: \"unsupported_file_type\" };\n }\n return {\n action: \"download\",\n contentType,\n filename: safeFilename(normalized.name),\n declaredBytes: declaredBytes?.toString() ?? null,\n };\n}\n\nexport async function inventoryGoogleDriveSource(input: {\n googlePermissionId: string;\n googleEmail?: string | undefined;\n source: GoogleDriveSelectedSource;\n accountId?: string | undefined;\n workspaceId: string;\n connectionSubjectId?: string | null | undefined;\n /** @deprecated Used only to validate old callers while source destinations migrate. */\n initiatingSubjectId?: string | undefined;\n limits: GoogleDriveInventoryLimits;\n listChildren: GoogleDriveListChildren;\n checkpoint?: GoogleDriveInventoryCheckpoint | null;\n now?: (() => number) | undefined;\n}): Promise<GoogleDriveInventoryResult> {\n const limits = validatedLimits(input.limits);\n const googlePermissionId = normalizedGooglePermissionId(input.googlePermissionId);\n const source = googleDriveKnowledgeSourceIdentity({\n googlePermissionId,\n googleEmail: input.googleEmail,\n source: input.source,\n ...(input.accountId ? { accountId: input.accountId } : {}),\n workspaceId: input.workspaceId,\n ...(input.connectionSubjectId !== undefined\n ? { connectionSubjectId: input.connectionSubjectId }\n : {}),\n ...(input.initiatingSubjectId ? { initiatingSubjectId: input.initiatingSubjectId } : {}),\n });\n const checkpointIdentity: GoogleDriveInventoryCheckpointIdentity = {\n googlePermissionId,\n externalTenantId: source.externalTenantId,\n sourceId: source.externalSourceId,\n sourceDriveId: nullableDriveId(input.source.driveId, \"source.driveId\"),\n scope: source.scope,\n };\n const now = input.now ?? Date.now;\n const startedAt = now();\n const checkpoint = input.checkpoint\n ? validatedCheckpoint(input.checkpoint, checkpointIdentity, limits)\n : initialCheckpoint(checkpointIdentity);\n const initialTotals = cloneTotals(checkpoint.totals);\n const entries: GoogleDriveInventoryEntry[] = [];\n const issues: GoogleDriveInventoryIssue[] = [];\n let stopReason: GoogleDriveInventoryStopReason | null = null;\n\n while (checkpoint.pendingFolders.length > 0) {\n if (now() - startedAt >= limits.maxElapsedMs) {\n stopReason = \"elapsed_time_limit\";\n break;\n }\n const frame = checkpoint.pendingFolders[0]!;\n if (frame.loaded && frame.bufferedItems.length === 0) {\n if (frame.nextPageToken) {\n frame.pageToken = frame.nextPageToken;\n frame.nextPageToken = null;\n frame.loaded = false;\n } else {\n checkpoint.pendingFolders.shift();\n }\n continue;\n }\n if (checkpoint.totals.itemCount >= limits.maxItems) {\n stopReason = \"item_limit\";\n break;\n }\n\n if (!frame.loaded) {\n if (checkpoint.totals.apiRequestCount >= limits.maxApiRequests) {\n stopReason = \"api_request_limit\";\n break;\n }\n const remainingItems = limits.maxItems - checkpoint.totals.itemCount;\n const requestedPageSize = Math.min(limits.pageSize, remainingItems);\n let page: GoogleDriveInventoryPage;\n try {\n page = await input.listChildren({\n folderId: frame.folderId,\n driveId: frame.driveId,\n pageToken: frame.pageToken,\n pageSize: requestedPageSize,\n });\n } catch (error) {\n checkpoint.totals.apiRequestCount += 1;\n issues.push({\n code: \"provider_error\",\n folderId: frame.folderId,\n providerCode: providerErrorCode(error),\n });\n stopReason = \"provider_error\";\n break;\n }\n checkpoint.totals.apiRequestCount += 1;\n if (!validPage(page, requestedPageSize)) {\n issues.push({ code: \"invalid_page\", folderId: frame.folderId, providerCode: null });\n stopReason = \"provider_error\";\n break;\n }\n if (page.incompleteSearch) {\n issues.push({ code: \"incomplete_search\", folderId: frame.folderId, providerCode: null });\n stopReason = \"incomplete_search\";\n break;\n }\n frame.loaded = true;\n frame.bufferedItems = page.items.map(validatedProviderItem);\n frame.nextPageToken = page.nextPageToken;\n if (now() - startedAt >= limits.maxElapsedMs) {\n stopReason = \"elapsed_time_limit\";\n break;\n }\n }\n\n if (frame.bufferedItems.length === 0) {\n if (frame.nextPageToken) {\n frame.pageToken = frame.nextPageToken;\n frame.nextPageToken = null;\n frame.loaded = false;\n } else {\n checkpoint.pendingFolders.shift();\n }\n continue;\n }\n\n const item = validatedProviderItem(frame.bufferedItems[0]!);\n let transfer = planGoogleDriveTransfer(item, limits.maxFileBytes);\n if (transfer.action === \"download\" && transfer.declaredBytes !== null) {\n const nextKnownBytes = BigInt(checkpoint.totals.knownBytes) + BigInt(transfer.declaredBytes);\n if (nextKnownBytes > BigInt(limits.maxKnownBytes)) {\n stopReason = \"known_byte_limit\";\n break;\n }\n }\n\n frame.bufferedItems.shift();\n checkpoint.totals.itemCount += 1;\n const effectiveDriveId = item.driveId ?? frame.driveId;\n if (transfer.action === \"traverse\") {\n if (checkpoint.seenFolderIds.includes(item.id)) {\n transfer = { action: \"skip\", reason: \"folder_loop\" };\n } else if (checkpoint.seenFolderIds.length >= limits.maxFolders) {\n transfer = { action: \"skip\", reason: \"folder_limit\" };\n } else {\n checkpoint.seenFolderIds.push(item.id);\n checkpoint.totals.folderCount += 1;\n checkpoint.pendingFolders.push({\n folderId: item.id,\n driveId: effectiveDriveId,\n pageToken: null,\n loaded: false,\n bufferedItems: [],\n nextPageToken: null,\n });\n }\n }\n\n if (transfer.action === \"skip\") {\n checkpoint.totals.skippedItemCount += 1;\n } else if (transfer.action === \"download\") {\n checkpoint.totals.plannedFileCount += 1;\n checkpoint.totals.downloadFileCount += 1;\n if (transfer.declaredBytes === null) {\n checkpoint.totals.unknownSizeFileCount += 1;\n } else {\n checkpoint.totals.knownBytes = (\n BigInt(checkpoint.totals.knownBytes) + BigInt(transfer.declaredBytes)\n ).toString();\n }\n } else if (transfer.action === \"export\") {\n checkpoint.totals.plannedFileCount += 1;\n checkpoint.totals.exportFileCount += 1;\n checkpoint.totals.unknownSizeFileCount += 1;\n }\n\n entries.push({\n externalObjectId: item.id,\n externalVersionId: item.version ?? item.md5Checksum ?? item.modifiedTime,\n sourceId: source.externalSourceId,\n parentFolderId: frame.folderId,\n driveId: effectiveDriveId,\n title: item.name,\n mimeType: item.mimeType,\n modifiedTime: item.modifiedTime,\n createdTime: item.createdTime,\n sourceUri: item.webViewLink ?? googleDriveFileUri(item.id),\n transfer,\n });\n }\n\n const elapsedMs = Math.max(0, now() - startedAt);\n const complete = checkpoint.pendingFolders.length === 0;\n const outputCheckpoint = complete ? null : cloneCheckpoint(checkpoint);\n if (outputCheckpoint) assertCheckpointBytes(outputCheckpoint);\n return {\n status: complete ? \"complete\" : \"paused\",\n stopReason: complete ? null : stopReason,\n source,\n entries,\n issues,\n totals: cloneTotals(checkpoint.totals),\n run: {\n ...subtractTotals(checkpoint.totals, initialTotals),\n elapsedMs,\n },\n checkpoint: outputCheckpoint,\n };\n}\n\ntype GoogleDriveInventoryCheckpointIdentity = Pick<\n GoogleDriveInventoryCheckpoint,\n \"googlePermissionId\" | \"externalTenantId\" | \"sourceId\" | \"sourceDriveId\" | \"scope\"\n>;\n\nfunction initialCheckpoint(\n identity: GoogleDriveInventoryCheckpointIdentity,\n): GoogleDriveInventoryCheckpoint {\n return {\n version: 2,\n googlePermissionId: identity.googlePermissionId,\n externalTenantId: identity.externalTenantId,\n sourceId: identity.sourceId,\n sourceDriveId: identity.sourceDriveId,\n scope: cloneScope(identity.scope),\n pendingFolders: [\n {\n folderId: identity.sourceId,\n driveId: identity.sourceDriveId,\n pageToken: null,\n loaded: false,\n bufferedItems: [],\n nextPageToken: null,\n },\n ],\n seenFolderIds: [identity.sourceId],\n totals: emptyTotals(),\n };\n}\n\nfunction validatedCheckpoint(\n value: GoogleDriveInventoryCheckpoint,\n identity: GoogleDriveInventoryCheckpointIdentity,\n limits: GoogleDriveInventoryLimits,\n): GoogleDriveInventoryCheckpoint {\n if (!value || typeof value !== \"object\" || value.version !== 2) {\n throw new Error(\"unsupported Google Drive inventory checkpoint\");\n }\n if (\n value.googlePermissionId !== identity.googlePermissionId ||\n value.externalTenantId !== identity.externalTenantId ||\n value.sourceId !== identity.sourceId ||\n value.sourceDriveId !== identity.sourceDriveId ||\n !sameScope(value.scope, identity.scope)\n ) {\n throw new Error(\"Google Drive inventory checkpoint does not match the selected source\");\n }\n const checkpoint = cloneCheckpoint(value);\n if (checkpoint.pendingFolders.length === 0) {\n throw new Error(\"Google Drive inventory checkpoint is already complete\");\n }\n if (\n checkpoint.pendingFolders.length > GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS ||\n checkpoint.seenFolderIds.length > GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS ||\n checkpoint.seenFolderIds.length > limits.maxFolders\n ) {\n throw new Error(\"Google Drive inventory checkpoint exceeds the folder limit\");\n }\n if (!checkpoint.seenFolderIds.includes(identity.sourceId)) {\n throw new Error(\"Google Drive inventory checkpoint lost its source boundary\");\n }\n if (new Set(checkpoint.seenFolderIds).size !== checkpoint.seenFolderIds.length) {\n throw new Error(\"Google Drive inventory checkpoint contains duplicate folder identity\");\n }\n for (const folderId of checkpoint.seenFolderIds) driveId(folderId, \"checkpoint.folderId\");\n const pendingFolderIds = new Set<string>();\n for (const frame of checkpoint.pendingFolders) {\n driveId(frame.folderId, \"checkpoint.pending.folderId\");\n if (\n !checkpoint.seenFolderIds.includes(frame.folderId) ||\n pendingFolderIds.has(frame.folderId)\n ) {\n throw new Error(\"Google Drive inventory checkpoint contains an invalid pending folder\");\n }\n pendingFolderIds.add(frame.folderId);\n nullableDriveId(frame.driveId, \"checkpoint.pending.driveId\");\n pageToken(frame.pageToken, \"checkpoint.pending.pageToken\");\n pageToken(frame.nextPageToken, \"checkpoint.pending.nextPageToken\");\n if (\n typeof frame.loaded !== \"boolean\" ||\n frame.bufferedItems.length > GOOGLE_DRIVE_MAX_PAGE_ITEMS\n ) {\n throw new Error(\"Google Drive inventory checkpoint contains an invalid page frame\");\n }\n if (!frame.loaded && (frame.bufferedItems.length > 0 || frame.nextPageToken !== null)) {\n throw new Error(\"Google Drive inventory checkpoint contains an uncommitted page frame\");\n }\n frame.bufferedItems = frame.bufferedItems.map(validatedProviderItem);\n }\n validatedTotals(checkpoint.totals);\n if (\n checkpoint.totals.folderCount !== checkpoint.seenFolderIds.length ||\n checkpoint.totals.plannedFileCount !==\n checkpoint.totals.exportFileCount + checkpoint.totals.downloadFileCount ||\n checkpoint.totals.unknownSizeFileCount > checkpoint.totals.plannedFileCount ||\n checkpoint.totals.itemCount !==\n checkpoint.totals.skippedItemCount +\n checkpoint.totals.plannedFileCount +\n checkpoint.totals.folderCount -\n 1\n ) {\n throw new Error(\"Google Drive inventory checkpoint totals are inconsistent\");\n }\n if (\n checkpoint.totals.itemCount > limits.maxItems ||\n checkpoint.totals.apiRequestCount > limits.maxApiRequests ||\n BigInt(checkpoint.totals.knownBytes) > BigInt(limits.maxKnownBytes)\n ) {\n throw new Error(\"Google Drive inventory checkpoint exceeds the supplied limits\");\n }\n assertCheckpointBytes(checkpoint);\n return checkpoint;\n}\n\nfunction validatedLimits(value: GoogleDriveInventoryLimits): GoogleDriveInventoryLimits {\n const limits = {\n maxItems: safePositiveInteger(value.maxItems, \"limits.maxItems\"),\n maxKnownBytes: safePositiveInteger(value.maxKnownBytes, \"limits.maxKnownBytes\"),\n maxApiRequests: safePositiveInteger(value.maxApiRequests, \"limits.maxApiRequests\"),\n maxElapsedMs: safePositiveInteger(value.maxElapsedMs, \"limits.maxElapsedMs\"),\n maxFileBytes: safePositiveInteger(value.maxFileBytes, \"limits.maxFileBytes\"),\n maxFolders: safePositiveInteger(value.maxFolders, \"limits.maxFolders\"),\n pageSize: safePositiveInteger(value.pageSize, \"limits.pageSize\"),\n };\n if (limits.pageSize > GOOGLE_DRIVE_MAX_PAGE_ITEMS) {\n throw new Error(`limits.pageSize must be <= ${GOOGLE_DRIVE_MAX_PAGE_ITEMS}`);\n }\n if (limits.maxFolders > GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS) {\n throw new Error(`limits.maxFolders must be <= ${GOOGLE_DRIVE_MAX_CHECKPOINT_FOLDERS}`);\n }\n return limits;\n}\n\nfunction validPage(value: GoogleDriveInventoryPage, expectedMaxItems: number): boolean {\n if (\n !value ||\n !Array.isArray(value.items) ||\n value.items.length > expectedMaxItems ||\n value.items.length > GOOGLE_DRIVE_MAX_PAGE_ITEMS\n ) {\n return false;\n }\n try {\n pageToken(value.nextPageToken, \"page.nextPageToken\");\n value.items.forEach(validatedProviderItem);\n return typeof value.incompleteSearch === \"boolean\";\n } catch {\n return false;\n }\n}\n\nfunction validatedProviderItem(\n item: GoogleDriveInventoryProviderItem,\n): GoogleDriveInventoryProviderItem {\n const id = driveId(item.id, \"item.id\");\n const name = boundedText(item.name, \"item.name\", GOOGLE_DRIVE_MAX_NAME_CHARS);\n const mimeType = boundedText(item.mimeType, \"item.mimeType\", GOOGLE_DRIVE_MAX_MIME_CHARS);\n const parents = Array.isArray(item.parents)\n ? item.parents.map((parent) => driveId(parent, \"item.parent\"))\n : [];\n if (parents.length > 100) throw new Error(\"item.parents exceeds the supported bound\");\n return {\n id,\n name,\n mimeType,\n driveId: nullableDriveId(item.driveId, \"item.driveId\"),\n parents,\n modifiedTime: nullableBoundedText(item.modifiedTime, \"item.modifiedTime\", 128),\n createdTime: nullableBoundedText(item.createdTime, \"item.createdTime\", 128),\n version: nullableBoundedText(item.version, \"item.version\", 256),\n md5Checksum: nullableBoundedText(item.md5Checksum, \"item.md5Checksum\", 128),\n size: fileSize(item.size)?.toString() ?? null,\n webViewLink: nullableHttpsUrl(item.webViewLink, \"item.webViewLink\"),\n trashed: item.trashed === true,\n };\n}\n\nfunction dependencyFreeOrdinaryContentType(name: string, mimeType: string): string | null {\n const normalizedMime = mimeType.trim().toLowerCase();\n if (normalizedMime.startsWith(\"text/\")) return normalizedMime;\n if (DEPENDENCY_FREE_ORDINARY_CONTENT_TYPES.has(normalizedMime)) return normalizedMime;\n if (!GENERIC_BINARY_CONTENT_TYPES.has(normalizedMime)) return null;\n const lowerName = name.toLowerCase();\n for (const [extension, contentType] of DEPENDENCY_FREE_EXTENSION_CONTENT_TYPES) {\n if (lowerName.endsWith(extension)) return contentType;\n }\n return null;\n}\n\nfunction exportedFilename(name: string, extension: string): string {\n const filename = safeFilename(name);\n return filename.toLowerCase().endsWith(extension) ? filename : `${filename}${extension}`;\n}\n\nfunction safeFilename(value: string): string {\n const cleaned = value\n .normalize(\"NFKC\")\n .replace(/[\\u0000-\\u001f\\u007f/\\\\]/gu, \" \")\n .replace(/\\s+/gu, \" \")\n .trim()\n .slice(0, 512);\n return cleaned || \"untitled\";\n}\n\nfunction googleDriveSourceUri(id: string): string {\n return id === \"root\"\n ? \"https://drive.google.com/drive/my-drive\"\n : `https://drive.google.com/drive/folders/${encodeURIComponent(id)}`;\n}\n\nfunction googleDriveFileUri(id: string): string {\n return `https://drive.google.com/open?id=${encodeURIComponent(id)}`;\n}\n\nfunction fileSize(value: string | null): bigint | null {\n if (value === null) return null;\n if (!/^\\d{1,40}$/u.test(value)) throw new Error(\"item.size is invalid\");\n return BigInt(value);\n}\n\nfunction providerErrorCode(error: unknown): string | null {\n if (!(error instanceof GoogleDriveInventoryProviderError)) return null;\n const normalized = error.providerCode.trim().toLowerCase();\n return /^[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$/u.test(normalized) ? normalized : null;\n}\n\nfunction driveId(value: string, label: string): string {\n const candidate = boundedText(value, label, GOOGLE_DRIVE_MAX_ID_CHARS);\n if (candidate === \"root\" || /^[A-Za-z0-9_-]+$/u.test(candidate)) return candidate;\n throw new Error(`${label} is invalid`);\n}\n\nfunction normalizedGooglePermissionId(value: string): string {\n return boundedText(value, \"googlePermissionId\", GOOGLE_DRIVE_MAX_ID_CHARS);\n}\n\nfunction nullableDriveId(value: string | null, label: string): string | null {\n return value === null ? null : driveId(value, label);\n}\n\nfunction pageToken(value: string | null, label: string): string | null {\n if (value === null) return null;\n return boundedText(value, label, GOOGLE_DRIVE_MAX_PAGE_TOKEN_CHARS);\n}\n\nfunction boundedText(value: string, label: string, maxChars: number): string {\n if (typeof value !== \"string\") throw new Error(`${label} must be a string`);\n const trimmed = value.trim();\n if (!trimmed || trimmed.length > maxChars || /[\\u0000-\\u001f\\u007f]/u.test(trimmed)) {\n throw new Error(`${label} is invalid`);\n }\n return trimmed;\n}\n\nfunction nullableBoundedText(value: string | null, label: string, maxChars: number): string | null {\n return value === null ? null : boundedText(value, label, maxChars);\n}\n\nfunction nullableHttpsUrl(value: string | null, label: string): string | null {\n if (value === null) return null;\n const bounded = boundedText(value, label, 4096);\n const parsed = new URL(bounded);\n if (parsed.protocol !== \"https:\") throw new Error(`${label} must use https`);\n return parsed.toString();\n}\n\nfunction safePositiveInteger(value: number, label: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new Error(`${label} must be a positive safe integer`);\n }\n return value;\n}\n\nfunction validatedTotals(totals: GoogleDriveInventoryTotals): void {\n for (const [key, value] of Object.entries(totals)) {\n if (key === \"knownBytes\") continue;\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) {\n throw new Error(`checkpoint.totals.${key} is invalid`);\n }\n }\n if (!/^\\d+$/u.test(totals.knownBytes)) {\n throw new Error(\"checkpoint.totals.knownBytes is invalid\");\n }\n}\n\nfunction emptyTotals(): GoogleDriveInventoryTotals {\n return {\n itemCount: 0,\n folderCount: 1,\n plannedFileCount: 0,\n skippedItemCount: 0,\n exportFileCount: 0,\n downloadFileCount: 0,\n unknownSizeFileCount: 0,\n apiRequestCount: 0,\n knownBytes: \"0\",\n };\n}\n\nfunction cloneTotals(value: GoogleDriveInventoryTotals): GoogleDriveInventoryTotals {\n return { ...value };\n}\n\nfunction subtractTotals(\n value: GoogleDriveInventoryTotals,\n initial: GoogleDriveInventoryTotals,\n): GoogleDriveInventoryTotals {\n return {\n itemCount: value.itemCount - initial.itemCount,\n folderCount: value.folderCount - initial.folderCount,\n plannedFileCount: value.plannedFileCount - initial.plannedFileCount,\n skippedItemCount: value.skippedItemCount - initial.skippedItemCount,\n exportFileCount: value.exportFileCount - initial.exportFileCount,\n downloadFileCount: value.downloadFileCount - initial.downloadFileCount,\n unknownSizeFileCount: value.unknownSizeFileCount - initial.unknownSizeFileCount,\n apiRequestCount: value.apiRequestCount - initial.apiRequestCount,\n knownBytes: (BigInt(value.knownBytes) - BigInt(initial.knownBytes)).toString(),\n };\n}\n\nfunction cloneProviderItem(\n value: GoogleDriveInventoryProviderItem,\n): GoogleDriveInventoryProviderItem {\n return { ...value, parents: [...value.parents] };\n}\n\nfunction cloneScope(scope: ScopedKnowledgeScope): ScopedKnowledgeScope {\n return { ...scope };\n}\n\nfunction cloneCheckpoint(value: GoogleDriveInventoryCheckpoint): GoogleDriveInventoryCheckpoint {\n return {\n version: 2,\n googlePermissionId: value.googlePermissionId,\n externalTenantId: value.externalTenantId,\n sourceId: value.sourceId,\n sourceDriveId: value.sourceDriveId,\n scope: cloneScope(value.scope),\n pendingFolders: value.pendingFolders.map((frame) => ({\n ...frame,\n bufferedItems: frame.bufferedItems.map(cloneProviderItem),\n })),\n seenFolderIds: [...value.seenFolderIds],\n totals: cloneTotals(value.totals),\n };\n}\n\nfunction sameScope(\n left: ScopedKnowledgeScope | null | undefined,\n right: ScopedKnowledgeScope,\n): boolean {\n return (\n !!left &&\n typeof left === \"object\" &&\n left.kind === right.kind &&\n left.workspaceId === right.workspaceId &&\n left.subjectId === right.subjectId\n );\n}\n\nfunction assertCheckpointBytes(checkpoint: GoogleDriveInventoryCheckpoint): void {\n if (Buffer.byteLength(JSON.stringify(checkpoint), \"utf8\") > GOOGLE_DRIVE_MAX_CHECKPOINT_BYTES) {\n throw new Error(\"Google Drive inventory checkpoint exceeds the serialized byte limit\");\n }\n}\n"],"mapp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