@superdurable/connector-box 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +6 -2
- package/dex-connector.json +129 -0
- package/dist/chunk-F5T3YIDN.js +299 -0
- package/dist/connection-BzNkxQQZ.d.ts +118 -0
- package/dist/index.d.ts +179 -0
- package/dist/index.js +528 -0
- package/dist/mock.d.ts +58 -0
- package/dist/mock.js +48 -0
- package/package.json +62 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { D as DownloadFileInput, a as DownloadedFile, U as UploadFileInput, b as UploadedFile, C as Config, c as Credentials, d as Connection, O as Operations } from './connection-BzNkxQQZ.js';
|
|
2
|
+
export { e as ConfigSchema, f as CredentialSource, g as DownloadFileInputSchema, h as DownloadedFileSchema, i as UploadFileInputSchema, j as UploadedFileSchema, k as decodeCredentials, l as decodeSharedCredentials, n as newConnection, m as newConnectionWithOperations } from './connection-BzNkxQQZ.js';
|
|
3
|
+
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
|
+
import { QueryDefinition, MutationDefinition, Query, Call, QueryAttempt, Mutation, MutationAttempt, CredentialProvider, CredentialRefreshDriver, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
|
|
5
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
6
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
7
|
+
import { StepTarget } from '@superdurable/dex';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
/** Stable connector identity. */
|
|
11
|
+
declare const ConnectorID = "box";
|
|
12
|
+
/** Provider identity for named connections. */
|
|
13
|
+
declare const ProviderID = "box";
|
|
14
|
+
/** Branch IDs for downloadFile. */
|
|
15
|
+
declare const DownloadFileBranch: {
|
|
16
|
+
readonly Downloaded: "downloaded";
|
|
17
|
+
readonly NotFound: "notFound";
|
|
18
|
+
readonly TooLarge: "tooLarge";
|
|
19
|
+
readonly ProviderRejected: "providerRejected";
|
|
20
|
+
readonly InvalidResponse: "invalidResponse";
|
|
21
|
+
readonly Defect: "defect";
|
|
22
|
+
};
|
|
23
|
+
/** Box returned the selected file content. */
|
|
24
|
+
declare const DownloadFileBranchDownloaded: "downloaded";
|
|
25
|
+
/** Box did not find this file or the user lacks access. */
|
|
26
|
+
declare const DownloadFileBranchNotFound: "notFound";
|
|
27
|
+
/** The file exceeds the configured download limit. */
|
|
28
|
+
declare const DownloadFileBranchTooLarge: "tooLarge";
|
|
29
|
+
/** Box conclusively rejected the download. */
|
|
30
|
+
declare const DownloadFileBranchProviderRejected: "providerRejected";
|
|
31
|
+
/** Box returned an invalid or oversized response. */
|
|
32
|
+
declare const DownloadFileBranchInvalidResponse: "invalidResponse";
|
|
33
|
+
/** Local input or connection credentials are invalid. */
|
|
34
|
+
declare const DownloadFileBranchDefect: "defect";
|
|
35
|
+
/** Manifest definition for downloadFile. */
|
|
36
|
+
declare const DownloadFileDefinition: QueryDefinition;
|
|
37
|
+
/** Manifest metadata for downloadFile. */
|
|
38
|
+
declare const DownloadFileMetadata: {
|
|
39
|
+
readonly kind: "query";
|
|
40
|
+
readonly idempotency: "none";
|
|
41
|
+
readonly authorization: "required";
|
|
42
|
+
};
|
|
43
|
+
/** Branch IDs for uploadFile. */
|
|
44
|
+
declare const UploadFileBranch: {
|
|
45
|
+
readonly Uploaded: "uploaded";
|
|
46
|
+
readonly NotFound: "notFound";
|
|
47
|
+
readonly ProviderRejected: "providerRejected";
|
|
48
|
+
readonly InvalidResponse: "invalidResponse";
|
|
49
|
+
readonly Defect: "defect";
|
|
50
|
+
};
|
|
51
|
+
/** The existing Box file now has the requested content. */
|
|
52
|
+
declare const UploadFileBranchUploaded: "uploaded";
|
|
53
|
+
/** Box did not find the file or the user lacks access. */
|
|
54
|
+
declare const UploadFileBranchNotFound: "notFound";
|
|
55
|
+
/** Box conclusively rejected the replacement. */
|
|
56
|
+
declare const UploadFileBranchProviderRejected: "providerRejected";
|
|
57
|
+
/** Box returned malformed or oversized file metadata. */
|
|
58
|
+
declare const UploadFileBranchInvalidResponse: "invalidResponse";
|
|
59
|
+
/** Local input or connection credentials are invalid. */
|
|
60
|
+
declare const UploadFileBranchDefect: "defect";
|
|
61
|
+
/** Manifest definition for uploadFile. */
|
|
62
|
+
declare const UploadFileDefinition: MutationDefinition;
|
|
63
|
+
/** Manifest metadata for uploadFile. */
|
|
64
|
+
declare const UploadFileMetadata: {
|
|
65
|
+
readonly kind: "mutation";
|
|
66
|
+
readonly idempotency: "required";
|
|
67
|
+
readonly authorization: "required";
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** One bounded Box file-content Query. */
|
|
71
|
+
declare class DownloadFileOperation implements Query<DownloadFileInput, DownloadedFile> {
|
|
72
|
+
private readonly client;
|
|
73
|
+
/** Bind the provider client. */ constructor(client: BoxClient);
|
|
74
|
+
/** Return stable manifest metadata. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
75
|
+
/** Download bytes, classify provider responses, and encode bounded content. */
|
|
76
|
+
invoke(call: Call, input: DownloadFileInput): Promise<QueryAttempt<DownloadedFile>>;
|
|
77
|
+
}
|
|
78
|
+
/** One bounded Box file-version replacement Mutation. */
|
|
79
|
+
declare class UploadFileOperation implements Mutation<UploadFileInput, UploadedFile> {
|
|
80
|
+
private readonly client;
|
|
81
|
+
/** Bind the provider client. */ constructor(client: BoxClient);
|
|
82
|
+
/** Return stable manifest metadata. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
83
|
+
/** Record stable call identity; Box receives no request key. */ idempotencyKey(callID: string, _input: UploadFileInput): string;
|
|
84
|
+
/** Compare current content, replace once, and read back ambiguous outcomes. */
|
|
85
|
+
invoke(call: Call, input: UploadFileInput): Promise<MutationAttempt<UploadedFile>>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** One bounded provider response or classified transport failure. */
|
|
89
|
+
interface BoxExchange {
|
|
90
|
+
/** HTTP status, or zero before response headers. */ status: number;
|
|
91
|
+
/** Bounded provider body, never placed directly into Flow state. */ body: Uint8Array;
|
|
92
|
+
/** Retry delay in milliseconds. */ retryAfterMs: number;
|
|
93
|
+
/** Local failure reason. */ error?: 'credential' | 'refresh' | 'request' | 'read' | 'tooLarge' | 'invalidRedirect';
|
|
94
|
+
/** Whether the request may have reached Box. */ requestSent: boolean;
|
|
95
|
+
/** Redirect location, kept only in transport memory. */ location?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Injectable HTTP and credential dependencies. */
|
|
98
|
+
interface BoxClientOptions {
|
|
99
|
+
/** Provider sender; omitted uses the SDK transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
100
|
+
/** OAuth refresh driver; omitted uses the manifest declaration. */ refreshDriver?: CredentialRefreshDriver<Credentials>;
|
|
101
|
+
/** Clock for Retry-After HTTP dates. */ now?: () => Date;
|
|
102
|
+
}
|
|
103
|
+
/** Box HTTP transport bound to a renewable credential source. */
|
|
104
|
+
declare class BoxClient {
|
|
105
|
+
/** Validated API endpoint. */ readonly baseURL: string;
|
|
106
|
+
/** Validated upload endpoint. */ readonly uploadBaseURL: string;
|
|
107
|
+
/** Timeout for one request. */ readonly timeoutMs: number;
|
|
108
|
+
/** Error and metadata response limit. */ readonly maxResponseBytes: number;
|
|
109
|
+
/** Download content limit. */ readonly maxDownloadBytes: number;
|
|
110
|
+
/** Replacement content limit. */ readonly maxUploadBytes: number;
|
|
111
|
+
private readonly credentials;
|
|
112
|
+
private readonly refreshDriver;
|
|
113
|
+
private readonly send;
|
|
114
|
+
private readonly now;
|
|
115
|
+
/** Validate configuration and inject dependencies without network access. */
|
|
116
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: BoxClientOptions);
|
|
117
|
+
/** Bind the bounded download Query. */ downloadFile(): DownloadFileOperation;
|
|
118
|
+
/** Bind the bounded replacement Mutation. */ uploadFile(): UploadFileOperation;
|
|
119
|
+
/** Download one file, following only Box's signed HTTPS content URL. */
|
|
120
|
+
download(call: Call, fileID: string): Promise<BoxExchange>;
|
|
121
|
+
/** Read one file's current identity and digest. */
|
|
122
|
+
getFileMetadata(call: Call, fileID: string): Promise<BoxExchange>;
|
|
123
|
+
/** Replace current content with Box's attributes-first multipart request. */
|
|
124
|
+
upload(call: Call, fileID: string, name: string, content: Uint8Array): Promise<BoxExchange>;
|
|
125
|
+
private resolveToken;
|
|
126
|
+
private request;
|
|
127
|
+
}
|
|
128
|
+
/** Read one response header without depending on provider casing. */
|
|
129
|
+
declare function header(headers: ProviderResponse['headers'], name: string): string;
|
|
130
|
+
|
|
131
|
+
/** Open one statically named renewable Box connection from Dex project configuration. */
|
|
132
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string, options?: BoxClientOptions): Connection<Operations>;
|
|
133
|
+
|
|
134
|
+
/** Configuration for the downloadFile connector Step. */
|
|
135
|
+
interface DownloadFileStepConfig<StepInput, OperationInput = DownloadFileInput, OperationOutput = DownloadedFile> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
136
|
+
/** Named connection supplying this operation. */
|
|
137
|
+
connection: Connection<{
|
|
138
|
+
downloadFile(): Query<OperationInput, OperationOutput>;
|
|
139
|
+
}>;
|
|
140
|
+
/** Name matching the bound connection. */
|
|
141
|
+
connectionName: string;
|
|
142
|
+
/** Box returned the selected file content. */
|
|
143
|
+
downloaded: StepTarget<QueryResult<OperationOutput>>;
|
|
144
|
+
/** Box did not find this file or the user lacks access. */
|
|
145
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
146
|
+
/** The file exceeds the configured download limit. */
|
|
147
|
+
tooLarge?: StepTarget<QueryResult<OperationOutput>>;
|
|
148
|
+
/** Box conclusively rejected the download. */
|
|
149
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
150
|
+
/** Box returned an invalid or oversized response. */
|
|
151
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
152
|
+
/** Local input or connection credentials are invalid. */
|
|
153
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
154
|
+
}
|
|
155
|
+
/** Build the downloadFile Step from a named connection. */
|
|
156
|
+
declare function newDownloadFileStep<StepInput, OperationInput = DownloadFileInput, OperationOutput = DownloadedFile>(configuration: DownloadFileStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
157
|
+
/** Configuration for the uploadFile connector Step. */
|
|
158
|
+
interface UploadFileStepConfig<StepInput, OperationInput = UploadFileInput, OperationOutput = UploadedFile> extends Omit<MutationStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
159
|
+
/** Named connection supplying this operation. */
|
|
160
|
+
connection: Connection<{
|
|
161
|
+
uploadFile(): Mutation<OperationInput, OperationOutput>;
|
|
162
|
+
}>;
|
|
163
|
+
/** Name matching the bound connection. */
|
|
164
|
+
connectionName: string;
|
|
165
|
+
/** The existing Box file now has the requested content. */
|
|
166
|
+
uploaded: StepTarget<MutationResult<OperationOutput>>;
|
|
167
|
+
/** Box did not find the file or the user lacks access. */
|
|
168
|
+
notFound?: StepTarget<MutationResult<OperationOutput>>;
|
|
169
|
+
/** Box conclusively rejected the replacement. */
|
|
170
|
+
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
171
|
+
/** Box returned malformed or oversized file metadata. */
|
|
172
|
+
invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
|
|
173
|
+
/** Local input or connection credentials are invalid. */
|
|
174
|
+
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
175
|
+
}
|
|
176
|
+
/** Build the uploadFile Step from a named connection. */
|
|
177
|
+
declare function newUploadFileStep<StepInput, OperationInput = UploadFileInput, OperationOutput = UploadedFile>(configuration: UploadFileStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
|
|
178
|
+
|
|
179
|
+
export { BoxClient, type BoxClientOptions, type BoxExchange, Config, Connection, ConnectorID, Credentials, DownloadFileBranch, DownloadFileBranchDefect, DownloadFileBranchDownloaded, DownloadFileBranchInvalidResponse, DownloadFileBranchNotFound, DownloadFileBranchProviderRejected, DownloadFileBranchTooLarge, DownloadFileDefinition, DownloadFileInput, DownloadFileMetadata, DownloadFileOperation, type DownloadFileStepConfig, DownloadedFile, ProviderID, UploadFileBranch, UploadFileBranchDefect, UploadFileBranchInvalidResponse, UploadFileBranchNotFound, UploadFileBranchProviderRejected, UploadFileBranchUploaded, UploadFileDefinition, UploadFileInput, UploadFileMetadata, UploadFileOperation, type UploadFileStepConfig, UploadedFile, header, newDownloadFileStep, newProjectConnection, newUploadFileStep };
|