@opengeni/documents 0.2.66 → 0.2.69

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.
@@ -0,0 +1,160 @@
1
+ import type { ScopedKnowledgeScope } from "@opengeni/contracts";
2
+ import type { GoogleDriveSelectedSource, GoogleDriveTargetScope } from "@opengeni/contracts/google-drive";
3
+ export declare const GOOGLE_DRIVE_PROVIDER_KEY: "google-drive";
4
+ export declare const GOOGLE_DRIVE_FOLDER_MIME_TYPE: "application/vnd.google-apps.folder";
5
+ export declare const GOOGLE_DRIVE_SHORTCUT_MIME_TYPE: "application/vnd.google-apps.shortcut";
6
+ export type GoogleDriveKnowledgeSourceIdentity = {
7
+ providerKey: typeof GOOGLE_DRIVE_PROVIDER_KEY;
8
+ externalTenantId: string;
9
+ externalSourceId: string;
10
+ sourceKind: "google-drive-my-drive" | "google-drive-shared-drive" | "google-drive-folder";
11
+ sourceUri: string;
12
+ scope: ScopedKnowledgeScope;
13
+ };
14
+ /**
15
+ * Normalized item metadata expected from a bounded Drive files.list adapter.
16
+ * The adapter owns provider JSON validation; this planner owns traversal,
17
+ * checkpointing, resource limits, stable identity, and transfer classification.
18
+ */
19
+ export type GoogleDriveInventoryProviderItem = {
20
+ id: string;
21
+ name: string;
22
+ mimeType: string;
23
+ driveId: string | null;
24
+ parents: string[];
25
+ modifiedTime: string | null;
26
+ createdTime: string | null;
27
+ version: string | null;
28
+ md5Checksum: string | null;
29
+ size: string | null;
30
+ webViewLink: string | null;
31
+ trashed: boolean;
32
+ };
33
+ export type GoogleDriveInventoryPage = {
34
+ items: GoogleDriveInventoryProviderItem[];
35
+ nextPageToken: string | null;
36
+ incompleteSearch: boolean;
37
+ };
38
+ export type GoogleDriveInventoryLimits = {
39
+ /** Hard cumulative provider-item discovery limit for this checkpoint. */
40
+ maxItems: number;
41
+ /** Hard cumulative known-byte limit for ordinary file downloads. */
42
+ maxKnownBytes: number;
43
+ /** Hard cumulative Drive list request/cost limit for this checkpoint. */
44
+ maxApiRequests: number;
45
+ /** Wall-clock budget for one invocation; checkpoint counters remain cumulative. */
46
+ maxElapsedMs: number;
47
+ /** Per-file byte ceiling. Unknown/export sizes must be enforced again while streaming. */
48
+ maxFileBytes: number;
49
+ /** Cycle/graph explosion guard for traversed folders. */
50
+ maxFolders: number;
51
+ /** Requested Drive page size. */
52
+ pageSize: number;
53
+ };
54
+ export type GoogleDriveTransferSkipReason = "file_too_large" | "folder_limit" | "folder_loop" | "shortcut_unsupported" | "trashed" | "unsupported_file_type" | "unsupported_native_type";
55
+ export type GoogleDriveTransferPlan = {
56
+ action: "traverse";
57
+ } | {
58
+ action: "export";
59
+ contentType: string;
60
+ filename: string;
61
+ declaredBytes: null;
62
+ } | {
63
+ action: "download";
64
+ contentType: string;
65
+ filename: string;
66
+ declaredBytes: string | null;
67
+ } | {
68
+ action: "skip";
69
+ reason: GoogleDriveTransferSkipReason;
70
+ };
71
+ export type GoogleDriveInventoryEntry = {
72
+ externalObjectId: string;
73
+ externalVersionId: string | null;
74
+ sourceId: string;
75
+ parentFolderId: string;
76
+ driveId: string | null;
77
+ title: string;
78
+ mimeType: string;
79
+ modifiedTime: string | null;
80
+ createdTime: string | null;
81
+ sourceUri: string;
82
+ transfer: GoogleDriveTransferPlan;
83
+ };
84
+ export type GoogleDriveInventoryIssue = {
85
+ code: "incomplete_search" | "invalid_page" | "provider_error";
86
+ folderId: string;
87
+ providerCode: string | null;
88
+ };
89
+ export type GoogleDriveInventoryStopReason = "api_request_limit" | "elapsed_time_limit" | "incomplete_search" | "item_limit" | "known_byte_limit" | "provider_error";
90
+ export type GoogleDriveInventoryTotals = {
91
+ itemCount: number;
92
+ folderCount: number;
93
+ plannedFileCount: number;
94
+ skippedItemCount: number;
95
+ exportFileCount: number;
96
+ downloadFileCount: number;
97
+ unknownSizeFileCount: number;
98
+ apiRequestCount: number;
99
+ knownBytes: string;
100
+ };
101
+ type GoogleDriveInventoryFrame = {
102
+ folderId: string;
103
+ driveId: string | null;
104
+ pageToken: string | null;
105
+ loaded: boolean;
106
+ bufferedItems: GoogleDriveInventoryProviderItem[];
107
+ nextPageToken: string | null;
108
+ };
109
+ export type GoogleDriveInventoryCheckpoint = {
110
+ version: 2;
111
+ googlePermissionId: string;
112
+ externalTenantId: string;
113
+ sourceId: string;
114
+ sourceDriveId: string | null;
115
+ scope: ScopedKnowledgeScope;
116
+ pendingFolders: GoogleDriveInventoryFrame[];
117
+ seenFolderIds: string[];
118
+ totals: GoogleDriveInventoryTotals;
119
+ };
120
+ export type GoogleDriveInventoryResult = {
121
+ status: "complete" | "paused";
122
+ stopReason: GoogleDriveInventoryStopReason | null;
123
+ source: GoogleDriveKnowledgeSourceIdentity;
124
+ entries: GoogleDriveInventoryEntry[];
125
+ issues: GoogleDriveInventoryIssue[];
126
+ totals: GoogleDriveInventoryTotals;
127
+ run: GoogleDriveInventoryTotals & {
128
+ elapsedMs: number;
129
+ };
130
+ checkpoint: GoogleDriveInventoryCheckpoint | null;
131
+ };
132
+ export type GoogleDriveListChildren = (input: {
133
+ folderId: string;
134
+ driveId: string | null;
135
+ pageToken: string | null;
136
+ pageSize: number;
137
+ }) => Promise<GoogleDriveInventoryPage>;
138
+ export declare class GoogleDriveInventoryProviderError extends Error {
139
+ readonly providerCode: string;
140
+ constructor(providerCode: string);
141
+ }
142
+ export declare function googleDriveKnowledgeScope(targetScope: GoogleDriveTargetScope, workspaceId: string, initiatingSubjectId: string): ScopedKnowledgeScope;
143
+ export declare function googleDriveKnowledgeSourceIdentity(input: {
144
+ googlePermissionId: string;
145
+ source: Pick<GoogleDriveSelectedSource, "id" | "driveId" | "targetScope">;
146
+ workspaceId: string;
147
+ initiatingSubjectId: string;
148
+ }): GoogleDriveKnowledgeSourceIdentity;
149
+ export declare function planGoogleDriveTransfer(item: GoogleDriveInventoryProviderItem, maxFileBytes: number): GoogleDriveTransferPlan;
150
+ export declare function inventoryGoogleDriveSource(input: {
151
+ googlePermissionId: string;
152
+ source: GoogleDriveSelectedSource;
153
+ workspaceId: string;
154
+ initiatingSubjectId: string;
155
+ limits: GoogleDriveInventoryLimits;
156
+ listChildren: GoogleDriveListChildren;
157
+ checkpoint?: GoogleDriveInventoryCheckpoint | null;
158
+ now?: (() => number) | undefined;
159
+ }): Promise<GoogleDriveInventoryResult>;
160
+ export {};