@trulyfinal/sdk 0.0.0-stage → 1.0.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/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +59 -2
- package/dist/index.d.ts +596 -0
- package/dist/index.js +196 -0
- package/dist/schema.d.ts +5694 -0
- package/dist/schema.js +1 -0
- package/package.json +57 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @trulyfinal/sdk
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
First public release: projects, files (multipart uploads over 100 MB), reviews, comments, approvals and webhooks for the TrulyFinal API, typed from its OpenAPI document. No dependencies; Node 18+, Deno, Bun, Cloudflare Workers and browsers.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agentic Flow LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @trulyfinal/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The [TrulyFinal](https://trulyfinal.com) API for JavaScript and TypeScript: create projects, upload
|
|
4
|
+
files, send them for review, read the comments and hear back when they're approved.
|
|
5
|
+
|
|
6
|
+
- Every request and answer is typed from the API's OpenAPI document.
|
|
7
|
+
- No dependencies. Node 18+, Deno, Bun, Cloudflare Workers and browsers.
|
|
8
|
+
- Lists page themselves, files over 100 MB go up in parts, and a rate-limited call waits and retries.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @trulyfinal/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Create a key in TrulyFinal under **Settings → Integrations**.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { TrulyFinal } from "@trulyfinal/sdk";
|
|
18
|
+
|
|
19
|
+
const tf = new TrulyFinal({ apiKey: process.env.TRULYFINAL_API_KEY! });
|
|
20
|
+
|
|
21
|
+
const project = await tf.projects.create({ name: "Spring campaign", reference: "PO-1042" });
|
|
22
|
+
const { file, version } = await tf.files.upload(project.id, { file: await readFile("brochure.pdf"), filename: "brochure.pdf" });
|
|
23
|
+
await tf.projects.inviteReviewers(project.id, { reviewers: [{ email: "anna@client.com", name: "Anna" }], fileIds: [file.id] });
|
|
24
|
+
|
|
25
|
+
for await (const c of tf.versions.allComments(version.id)) console.log(`#${c.number} ${c.author.name}: ${c.body}`);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A new version of a file: `tf.files.upload(projectId, { file, filename, fileId })`.
|
|
29
|
+
|
|
30
|
+
## Errors
|
|
31
|
+
|
|
32
|
+
Failed calls throw `TrulyFinalError` with the HTTP `status`, the API's `code` (`not_found`,
|
|
33
|
+
`invalid_request`, `rate_limited`…) and a `message` you can show.
|
|
34
|
+
|
|
35
|
+
## Webhooks
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { verifyWebhook } from "@trulyfinal/sdk";
|
|
39
|
+
|
|
40
|
+
const ok = await verifyWebhook(secret, rawBody, request.headers.get("TrulyFinal-Signature"));
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pass the body exactly as received. Deliveries older than five minutes are refused.
|
|
44
|
+
|
|
45
|
+
## Anything else
|
|
46
|
+
|
|
47
|
+
`tf.request(method, path, { query, body })` calls any endpoint of the
|
|
48
|
+
[API reference](https://trulyfinal.com/docs/sdk/), and `tf.paginate(path)` walks any list.
|
|
49
|
+
|
|
50
|
+
## Maintaining
|
|
51
|
+
|
|
52
|
+
`src/schema.ts` is generated from `openapi.json`. When the API changes:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
npm run generate # refresh openapi.json and src/schema.ts from the live API
|
|
56
|
+
npm test # TF_APP_URL=https://app.trulyfinal.com npm test also compares openapi.json with that API
|
|
57
|
+
npm run build # dist/, what npm gets
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Releases: add a changeset (`npx changeset`) in the pull request; merging the "Version packages" pull request publishes to npm from CI with provenance.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import type { components, paths } from "./schema.js";
|
|
2
|
+
export type { components, paths } from "./schema.js";
|
|
3
|
+
type S = components["schemas"];
|
|
4
|
+
export type Project = S["Project"];
|
|
5
|
+
export type Client = S["Client"];
|
|
6
|
+
export type Member = S["Member"];
|
|
7
|
+
export type Invitation = S["Invitation"];
|
|
8
|
+
export type Step = S["Step"];
|
|
9
|
+
export type Reviewer = S["Reviewer"];
|
|
10
|
+
export type File = S["File"];
|
|
11
|
+
export type FileDetail = S["FileDetail"];
|
|
12
|
+
export type Version = S["Version"];
|
|
13
|
+
export type Uploaded = S["Uploaded"];
|
|
14
|
+
export type Review = S["Review"];
|
|
15
|
+
export type Comment = S["Comment"];
|
|
16
|
+
export type Attachment = S["Attachment"];
|
|
17
|
+
export type Template = S["Template"];
|
|
18
|
+
export type Webhook = S["Webhook"];
|
|
19
|
+
type Method = "get" | "post" | "put" | "patch" | "delete";
|
|
20
|
+
type Op<P extends keyof paths, M extends Method> = NonNullable<paths[P][M]>;
|
|
21
|
+
/** The JSON body an operation takes. */
|
|
22
|
+
export type BodyOf<P extends keyof paths, M extends Method> = Op<P, M> extends {
|
|
23
|
+
requestBody?: {
|
|
24
|
+
content: {
|
|
25
|
+
"application/json": infer B;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
} ? B : never;
|
|
29
|
+
/** Its query parameters. */
|
|
30
|
+
export type QueryOf<P extends keyof paths, M extends Method> = Op<P, M> extends {
|
|
31
|
+
parameters: {
|
|
32
|
+
query?: infer Q;
|
|
33
|
+
};
|
|
34
|
+
} ? NonNullable<Q> : never;
|
|
35
|
+
/** What it answers on success. */
|
|
36
|
+
export type ResultOf<P extends keyof paths, M extends Method> = Op<P, M> extends {
|
|
37
|
+
responses: infer R;
|
|
38
|
+
} ? R extends {
|
|
39
|
+
200: {
|
|
40
|
+
content: {
|
|
41
|
+
"application/json": infer J;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
} ? J : R extends {
|
|
45
|
+
201: {
|
|
46
|
+
content: {
|
|
47
|
+
"application/json": infer J;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
} ? J : never : never;
|
|
51
|
+
type ItemOf<P extends keyof paths> = ResultOf<P, "get"> extends {
|
|
52
|
+
data: (infer T)[];
|
|
53
|
+
} ? T : never;
|
|
54
|
+
export type Page<T> = {
|
|
55
|
+
data: T[];
|
|
56
|
+
nextCursor: string | null;
|
|
57
|
+
};
|
|
58
|
+
export type ErrorCode = S["Error"]["error"]["code"];
|
|
59
|
+
/** Every failed call: the HTTP status, the API's error code and its message. */
|
|
60
|
+
export declare class TrulyFinalError extends Error {
|
|
61
|
+
readonly status: number;
|
|
62
|
+
readonly code: ErrorCode | (string & {});
|
|
63
|
+
constructor(status: number, code: string, message: string);
|
|
64
|
+
}
|
|
65
|
+
export type Options = {
|
|
66
|
+
/** A key from Settings → Integrations (tf_…). */
|
|
67
|
+
apiKey: string;
|
|
68
|
+
/** Default https://app.trulyfinal.com/api */
|
|
69
|
+
baseUrl?: string;
|
|
70
|
+
/** Rate-limited calls (429) wait for Retry-After and try again this many times. Default 2. */
|
|
71
|
+
maxRetries?: number;
|
|
72
|
+
fetch?: typeof fetch;
|
|
73
|
+
};
|
|
74
|
+
type RequestOptions = {
|
|
75
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
76
|
+
body?: unknown;
|
|
77
|
+
bytes?: {
|
|
78
|
+
data: BodyInit;
|
|
79
|
+
contentType: string;
|
|
80
|
+
};
|
|
81
|
+
raw?: boolean;
|
|
82
|
+
};
|
|
83
|
+
type Bytes = Blob | ArrayBuffer | Uint8Array;
|
|
84
|
+
export declare class TrulyFinal {
|
|
85
|
+
#private;
|
|
86
|
+
readonly baseUrl: string;
|
|
87
|
+
constructor(opts: Options);
|
|
88
|
+
/** Any endpoint, for what the helpers below don't cover. `path` starts with /v1/. */
|
|
89
|
+
request<T = unknown>(method: string, path: string, opts?: RequestOptions): Promise<T>;
|
|
90
|
+
/** Every item of a paged list, fetching pages as you go. */
|
|
91
|
+
paginate<T>(path: string, query?: Record<string, string | number | boolean | undefined | null>): AsyncGenerator<T>;
|
|
92
|
+
/** The key and its studio (and, for an app someone connected, the person). */
|
|
93
|
+
me: () => Promise<{
|
|
94
|
+
studio: {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
plan: string;
|
|
98
|
+
};
|
|
99
|
+
key: {
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
user: {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
email: string;
|
|
107
|
+
} | null;
|
|
108
|
+
}>;
|
|
109
|
+
members: {
|
|
110
|
+
list: (q?: QueryOf<"/v1/members", "get">) => Promise<Page<{
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
email: string;
|
|
114
|
+
role: "owner" | "admin" | "member";
|
|
115
|
+
joinedAt: string;
|
|
116
|
+
}>>;
|
|
117
|
+
all: () => AsyncGenerator<{
|
|
118
|
+
id: string;
|
|
119
|
+
name: string;
|
|
120
|
+
email: string;
|
|
121
|
+
role: "owner" | "admin" | "member";
|
|
122
|
+
joinedAt: string;
|
|
123
|
+
}, any, any>;
|
|
124
|
+
setRole: (userId: string, role: "admin" | "member") => Promise<{
|
|
125
|
+
ok: boolean;
|
|
126
|
+
}>;
|
|
127
|
+
/** Their projects go to `transferTo`, or to the first owner. */
|
|
128
|
+
remove: (userId: string, opts?: {
|
|
129
|
+
transferTo?: string;
|
|
130
|
+
}) => Promise<{
|
|
131
|
+
ok: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
invite: (body: BodyOf<"/v1/members/invitations", "post">) => Promise<{
|
|
134
|
+
invited: string[];
|
|
135
|
+
skipped: {
|
|
136
|
+
email: string;
|
|
137
|
+
reason: string;
|
|
138
|
+
}[];
|
|
139
|
+
}>;
|
|
140
|
+
invitations: () => Promise<{
|
|
141
|
+
data: Invitation[];
|
|
142
|
+
}>;
|
|
143
|
+
cancelInvitation: (id: string) => Promise<{
|
|
144
|
+
ok: boolean;
|
|
145
|
+
}>;
|
|
146
|
+
};
|
|
147
|
+
clients: {
|
|
148
|
+
list: (q?: QueryOf<"/v1/clients", "get">) => Promise<Page<{
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
createdAt: string;
|
|
152
|
+
}>>;
|
|
153
|
+
all: () => AsyncGenerator<{
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
createdAt: string;
|
|
157
|
+
}, any, any>;
|
|
158
|
+
create: (body: BodyOf<"/v1/clients", "post">) => Promise<{
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
createdAt: string;
|
|
162
|
+
}>;
|
|
163
|
+
};
|
|
164
|
+
projects: {
|
|
165
|
+
list: (q?: QueryOf<"/v1/projects", "get">) => Promise<Page<{
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
reference: string | null;
|
|
169
|
+
status: "active" | "completed" | "archived";
|
|
170
|
+
client: {
|
|
171
|
+
id: string;
|
|
172
|
+
name: string;
|
|
173
|
+
} | null;
|
|
174
|
+
dueAt: string | null;
|
|
175
|
+
createdAt: string;
|
|
176
|
+
updatedAt: string;
|
|
177
|
+
url: string;
|
|
178
|
+
}>>;
|
|
179
|
+
all: (q?: Omit<QueryOf<"/v1/projects", "get">, "cursor">) => AsyncGenerator<{
|
|
180
|
+
id: string;
|
|
181
|
+
name: string;
|
|
182
|
+
reference: string | null;
|
|
183
|
+
status: "active" | "completed" | "archived";
|
|
184
|
+
client: {
|
|
185
|
+
id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
} | null;
|
|
188
|
+
dueAt: string | null;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
updatedAt: string;
|
|
191
|
+
url: string;
|
|
192
|
+
}, any, any>;
|
|
193
|
+
get: (id: string) => Promise<{
|
|
194
|
+
id: string;
|
|
195
|
+
name: string;
|
|
196
|
+
reference: string | null;
|
|
197
|
+
status: "active" | "completed" | "archived";
|
|
198
|
+
client: {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
} | null;
|
|
202
|
+
dueAt: string | null;
|
|
203
|
+
createdAt: string;
|
|
204
|
+
updatedAt: string;
|
|
205
|
+
url: string;
|
|
206
|
+
}>;
|
|
207
|
+
create: (body: BodyOf<"/v1/projects", "post">) => Promise<{
|
|
208
|
+
id: string;
|
|
209
|
+
name: string;
|
|
210
|
+
reference: string | null;
|
|
211
|
+
status: "active" | "completed" | "archived";
|
|
212
|
+
client: {
|
|
213
|
+
id: string;
|
|
214
|
+
name: string;
|
|
215
|
+
} | null;
|
|
216
|
+
dueAt: string | null;
|
|
217
|
+
createdAt: string;
|
|
218
|
+
updatedAt: string;
|
|
219
|
+
url: string;
|
|
220
|
+
}>;
|
|
221
|
+
update: (id: string, body: BodyOf<"/v1/projects/{id}", "patch">) => Promise<{
|
|
222
|
+
id: string;
|
|
223
|
+
name: string;
|
|
224
|
+
reference: string | null;
|
|
225
|
+
status: "active" | "completed" | "archived";
|
|
226
|
+
client: {
|
|
227
|
+
id: string;
|
|
228
|
+
name: string;
|
|
229
|
+
} | null;
|
|
230
|
+
dueAt: string | null;
|
|
231
|
+
createdAt: string;
|
|
232
|
+
updatedAt: string;
|
|
233
|
+
url: string;
|
|
234
|
+
}>;
|
|
235
|
+
/** To Recently deleted, restorable in the app for 30 days. */
|
|
236
|
+
delete: (id: string) => Promise<{
|
|
237
|
+
ok: boolean;
|
|
238
|
+
}>;
|
|
239
|
+
sections: (id: string) => Promise<{
|
|
240
|
+
data: string[];
|
|
241
|
+
}>;
|
|
242
|
+
setSections: (id: string, body: BodyOf<"/v1/projects/{id}/sections", "put">) => Promise<{
|
|
243
|
+
data: string[];
|
|
244
|
+
}>;
|
|
245
|
+
steps: (id: string) => Promise<{
|
|
246
|
+
data: Step[];
|
|
247
|
+
}>;
|
|
248
|
+
setSteps: (id: string, body: BodyOf<"/v1/projects/{id}/steps", "put">) => Promise<{
|
|
249
|
+
data: Step[];
|
|
250
|
+
}>;
|
|
251
|
+
/** Adds reviewers to the client stage (emailing each their link) and, with `fileIds`, sends those files. */
|
|
252
|
+
inviteReviewers: (id: string, body: BodyOf<"/v1/projects/{id}/reviewers", "post">) => Promise<{
|
|
253
|
+
invited: string[];
|
|
254
|
+
started: number;
|
|
255
|
+
queued: number;
|
|
256
|
+
reviewers: components["schemas"]["Reviewer"][];
|
|
257
|
+
link: string | null;
|
|
258
|
+
}>;
|
|
259
|
+
removeReviewer: (id: string, reviewerId: string) => Promise<{
|
|
260
|
+
ok: boolean;
|
|
261
|
+
}>;
|
|
262
|
+
/** Downloads, password, invited-only and expiry of the project's review link. */
|
|
263
|
+
updateLink: (id: string, body: BodyOf<"/v1/projects/{id}/link", "patch">) => Promise<{
|
|
264
|
+
ok: boolean;
|
|
265
|
+
}>;
|
|
266
|
+
files: (id: string, q?: QueryOf<"/v1/projects/{id}/files", "get">) => Promise<Page<{
|
|
267
|
+
id: string;
|
|
268
|
+
projectId: string;
|
|
269
|
+
name: string;
|
|
270
|
+
kind: "pdf" | "image" | "video";
|
|
271
|
+
status: string;
|
|
272
|
+
externalId: string | null;
|
|
273
|
+
section: string | null;
|
|
274
|
+
latestVersion: components["schemas"]["Version"];
|
|
275
|
+
openComments: number;
|
|
276
|
+
createdAt: string;
|
|
277
|
+
updatedAt: string;
|
|
278
|
+
url: string;
|
|
279
|
+
}>>;
|
|
280
|
+
allFiles: (id: string) => AsyncGenerator<{
|
|
281
|
+
id: string;
|
|
282
|
+
projectId: string;
|
|
283
|
+
name: string;
|
|
284
|
+
kind: "pdf" | "image" | "video";
|
|
285
|
+
status: string;
|
|
286
|
+
externalId: string | null;
|
|
287
|
+
section: string | null;
|
|
288
|
+
latestVersion: components["schemas"]["Version"];
|
|
289
|
+
openComments: number;
|
|
290
|
+
createdAt: string;
|
|
291
|
+
updatedAt: string;
|
|
292
|
+
url: string;
|
|
293
|
+
}, any, any>;
|
|
294
|
+
};
|
|
295
|
+
files: {
|
|
296
|
+
get: (id: string) => Promise<{
|
|
297
|
+
id: string;
|
|
298
|
+
projectId: string;
|
|
299
|
+
name: string;
|
|
300
|
+
kind: "pdf" | "image" | "video";
|
|
301
|
+
status: string;
|
|
302
|
+
externalId: string | null;
|
|
303
|
+
section: string | null;
|
|
304
|
+
latestVersion: components["schemas"]["Version"];
|
|
305
|
+
openComments: number;
|
|
306
|
+
createdAt: string;
|
|
307
|
+
updatedAt: string;
|
|
308
|
+
url: string;
|
|
309
|
+
} & {
|
|
310
|
+
versions: components["schemas"]["Version"][];
|
|
311
|
+
}>;
|
|
312
|
+
/** Files whose `externalId` (your own id) matches, across projects. */
|
|
313
|
+
findByExternalId: (externalId: string) => AsyncGenerator<{
|
|
314
|
+
id: string;
|
|
315
|
+
projectId: string;
|
|
316
|
+
name: string;
|
|
317
|
+
kind: "pdf" | "image" | "video";
|
|
318
|
+
status: string;
|
|
319
|
+
externalId: string | null;
|
|
320
|
+
section: string | null;
|
|
321
|
+
latestVersion: components["schemas"]["Version"];
|
|
322
|
+
openComments: number;
|
|
323
|
+
createdAt: string;
|
|
324
|
+
updatedAt: string;
|
|
325
|
+
url: string;
|
|
326
|
+
}, any, any>;
|
|
327
|
+
update: (id: string, body: BodyOf<"/v1/files/{id}", "patch">) => Promise<{
|
|
328
|
+
id: string;
|
|
329
|
+
projectId: string;
|
|
330
|
+
name: string;
|
|
331
|
+
kind: "pdf" | "image" | "video";
|
|
332
|
+
status: string;
|
|
333
|
+
externalId: string | null;
|
|
334
|
+
section: string | null;
|
|
335
|
+
latestVersion: components["schemas"]["Version"];
|
|
336
|
+
openComments: number;
|
|
337
|
+
createdAt: string;
|
|
338
|
+
updatedAt: string;
|
|
339
|
+
url: string;
|
|
340
|
+
} & {
|
|
341
|
+
versions: components["schemas"]["Version"][];
|
|
342
|
+
}>;
|
|
343
|
+
delete: (id: string) => Promise<{
|
|
344
|
+
ok: boolean;
|
|
345
|
+
}>;
|
|
346
|
+
/**
|
|
347
|
+
* A new file in a project, or with `fileId` a new version of that file. Up to 100 MB in one call;
|
|
348
|
+
* bigger files go up in parts automatically.
|
|
349
|
+
*/
|
|
350
|
+
upload: (projectId: string, input: {
|
|
351
|
+
file: Bytes;
|
|
352
|
+
filename: string;
|
|
353
|
+
mime?: string;
|
|
354
|
+
fileId?: string;
|
|
355
|
+
externalId?: string;
|
|
356
|
+
note?: string;
|
|
357
|
+
}) => Promise<Uploaded>;
|
|
358
|
+
/** TrulyFinal downloads the file from a public URL. */
|
|
359
|
+
uploadFromUrl: (projectId: string, input: {
|
|
360
|
+
url: string;
|
|
361
|
+
filename?: string;
|
|
362
|
+
fileId?: string;
|
|
363
|
+
externalId?: string;
|
|
364
|
+
note?: string;
|
|
365
|
+
}) => Promise<{
|
|
366
|
+
file: components["schemas"]["FileDetail"];
|
|
367
|
+
version: components["schemas"]["Version"];
|
|
368
|
+
}>;
|
|
369
|
+
};
|
|
370
|
+
versions: {
|
|
371
|
+
/** The original file, as uploaded. */
|
|
372
|
+
download: (id: string) => Promise<Response>;
|
|
373
|
+
reviews: (id: string) => Promise<{
|
|
374
|
+
data: Review[];
|
|
375
|
+
}>;
|
|
376
|
+
/** To the first stage, or with `stepId` straight to that stage. */
|
|
377
|
+
sendForReview: (id: string, body?: BodyOf<"/v1/versions/{id}/reviews", "post">) => Promise<{
|
|
378
|
+
data: Review[];
|
|
379
|
+
}>;
|
|
380
|
+
comments: (id: string, q?: QueryOf<"/v1/versions/{id}/comments", "get">) => Promise<Page<{
|
|
381
|
+
id: string;
|
|
382
|
+
versionId: string;
|
|
383
|
+
parentId: string | null;
|
|
384
|
+
number: number | null;
|
|
385
|
+
body: string;
|
|
386
|
+
internal: boolean;
|
|
387
|
+
status: "open" | "resolved" | "dismissed" | "reopened" | null;
|
|
388
|
+
page: number | null;
|
|
389
|
+
x: number | null;
|
|
390
|
+
y: number | null;
|
|
391
|
+
timeMs: number | null;
|
|
392
|
+
timeEndMs: number | null;
|
|
393
|
+
author: {
|
|
394
|
+
type: "member" | "reviewer" | "integration" | "ai";
|
|
395
|
+
name: string | null;
|
|
396
|
+
email: string | null;
|
|
397
|
+
};
|
|
398
|
+
attachments: components["schemas"]["Attachment"][];
|
|
399
|
+
createdAt: string;
|
|
400
|
+
editedAt: string | null;
|
|
401
|
+
}>>;
|
|
402
|
+
allComments: (id: string) => AsyncGenerator<{
|
|
403
|
+
id: string;
|
|
404
|
+
versionId: string;
|
|
405
|
+
parentId: string | null;
|
|
406
|
+
number: number | null;
|
|
407
|
+
body: string;
|
|
408
|
+
internal: boolean;
|
|
409
|
+
status: "open" | "resolved" | "dismissed" | "reopened" | null;
|
|
410
|
+
page: number | null;
|
|
411
|
+
x: number | null;
|
|
412
|
+
y: number | null;
|
|
413
|
+
timeMs: number | null;
|
|
414
|
+
timeEndMs: number | null;
|
|
415
|
+
author: {
|
|
416
|
+
type: "member" | "reviewer" | "integration" | "ai";
|
|
417
|
+
name: string | null;
|
|
418
|
+
email: string | null;
|
|
419
|
+
};
|
|
420
|
+
attachments: components["schemas"]["Attachment"][];
|
|
421
|
+
createdAt: string;
|
|
422
|
+
editedAt: string | null;
|
|
423
|
+
}, any, any>;
|
|
424
|
+
};
|
|
425
|
+
reviews: {
|
|
426
|
+
setDueDate: (id: string, dueAt: string | null) => Promise<{
|
|
427
|
+
ok: boolean;
|
|
428
|
+
dueAt: string | null;
|
|
429
|
+
}>;
|
|
430
|
+
/** A decision the client made outside TrulyFinal, recorded with how and why. */
|
|
431
|
+
recordDecision: (id: string, body: BodyOf<"/v1/reviews/{id}/decision", "post">) => Promise<{
|
|
432
|
+
data: Review[];
|
|
433
|
+
}>;
|
|
434
|
+
};
|
|
435
|
+
comments: {
|
|
436
|
+
/** Team-only unless `internal: false`. Attach files uploaded with `attach` first. */
|
|
437
|
+
create: (versionId: string, body: BodyOf<"/v1/versions/{id}/comments", "post">) => Promise<{
|
|
438
|
+
id: string;
|
|
439
|
+
versionId: string;
|
|
440
|
+
parentId: string | null;
|
|
441
|
+
number: number | null;
|
|
442
|
+
body: string;
|
|
443
|
+
internal: boolean;
|
|
444
|
+
status: "open" | "resolved" | "dismissed" | "reopened" | null;
|
|
445
|
+
page: number | null;
|
|
446
|
+
x: number | null;
|
|
447
|
+
y: number | null;
|
|
448
|
+
timeMs: number | null;
|
|
449
|
+
timeEndMs: number | null;
|
|
450
|
+
author: {
|
|
451
|
+
type: "member" | "reviewer" | "integration" | "ai";
|
|
452
|
+
name: string | null;
|
|
453
|
+
email: string | null;
|
|
454
|
+
};
|
|
455
|
+
attachments: components["schemas"]["Attachment"][];
|
|
456
|
+
createdAt: string;
|
|
457
|
+
editedAt: string | null;
|
|
458
|
+
}>;
|
|
459
|
+
update: (id: string, body: BodyOf<"/v1/comments/{id}", "patch">) => Promise<{
|
|
460
|
+
id: string;
|
|
461
|
+
versionId: string;
|
|
462
|
+
parentId: string | null;
|
|
463
|
+
number: number | null;
|
|
464
|
+
body: string;
|
|
465
|
+
internal: boolean;
|
|
466
|
+
status: "open" | "resolved" | "dismissed" | "reopened" | null;
|
|
467
|
+
page: number | null;
|
|
468
|
+
x: number | null;
|
|
469
|
+
y: number | null;
|
|
470
|
+
timeMs: number | null;
|
|
471
|
+
timeEndMs: number | null;
|
|
472
|
+
author: {
|
|
473
|
+
type: "member" | "reviewer" | "integration" | "ai";
|
|
474
|
+
name: string | null;
|
|
475
|
+
email: string | null;
|
|
476
|
+
};
|
|
477
|
+
attachments: components["schemas"]["Attachment"][];
|
|
478
|
+
createdAt: string;
|
|
479
|
+
editedAt: string | null;
|
|
480
|
+
}>;
|
|
481
|
+
resolve: (id: string) => Promise<{
|
|
482
|
+
id: string;
|
|
483
|
+
versionId: string;
|
|
484
|
+
parentId: string | null;
|
|
485
|
+
number: number | null;
|
|
486
|
+
body: string;
|
|
487
|
+
internal: boolean;
|
|
488
|
+
status: "open" | "resolved" | "dismissed" | "reopened" | null;
|
|
489
|
+
page: number | null;
|
|
490
|
+
x: number | null;
|
|
491
|
+
y: number | null;
|
|
492
|
+
timeMs: number | null;
|
|
493
|
+
timeEndMs: number | null;
|
|
494
|
+
author: {
|
|
495
|
+
type: "member" | "reviewer" | "integration" | "ai";
|
|
496
|
+
name: string | null;
|
|
497
|
+
email: string | null;
|
|
498
|
+
};
|
|
499
|
+
attachments: components["schemas"]["Attachment"][];
|
|
500
|
+
createdAt: string;
|
|
501
|
+
editedAt: string | null;
|
|
502
|
+
}>;
|
|
503
|
+
reopen: (id: string) => Promise<{
|
|
504
|
+
id: string;
|
|
505
|
+
versionId: string;
|
|
506
|
+
parentId: string | null;
|
|
507
|
+
number: number | null;
|
|
508
|
+
body: string;
|
|
509
|
+
internal: boolean;
|
|
510
|
+
status: "open" | "resolved" | "dismissed" | "reopened" | null;
|
|
511
|
+
page: number | null;
|
|
512
|
+
x: number | null;
|
|
513
|
+
y: number | null;
|
|
514
|
+
timeMs: number | null;
|
|
515
|
+
timeEndMs: number | null;
|
|
516
|
+
author: {
|
|
517
|
+
type: "member" | "reviewer" | "integration" | "ai";
|
|
518
|
+
name: string | null;
|
|
519
|
+
email: string | null;
|
|
520
|
+
};
|
|
521
|
+
attachments: components["schemas"]["Attachment"][];
|
|
522
|
+
createdAt: string;
|
|
523
|
+
editedAt: string | null;
|
|
524
|
+
}>;
|
|
525
|
+
delete: (id: string) => Promise<{
|
|
526
|
+
ok: boolean;
|
|
527
|
+
}>;
|
|
528
|
+
/** Upload a file to attach to a comment on this version (up to 25 MB); returns its id. */
|
|
529
|
+
attach: (versionId: string, input: {
|
|
530
|
+
file: Bytes;
|
|
531
|
+
filename: string;
|
|
532
|
+
mime?: string;
|
|
533
|
+
}) => Promise<{
|
|
534
|
+
id: string;
|
|
535
|
+
filename: string;
|
|
536
|
+
mime: string;
|
|
537
|
+
byteSize: number;
|
|
538
|
+
}>;
|
|
539
|
+
downloadAttachment: (id: string) => Promise<Response>;
|
|
540
|
+
/** Share team comments with the client's review of the same version. */
|
|
541
|
+
copyToClient: (versionId: string, commentIds: string[]) => Promise<{
|
|
542
|
+
copied: number;
|
|
543
|
+
numbers: number[];
|
|
544
|
+
}>;
|
|
545
|
+
};
|
|
546
|
+
templates: {
|
|
547
|
+
list: () => Promise<{
|
|
548
|
+
data: Template[];
|
|
549
|
+
}>;
|
|
550
|
+
create: (body: BodyOf<"/v1/templates", "post">) => Promise<{
|
|
551
|
+
id: string;
|
|
552
|
+
name: string;
|
|
553
|
+
description: string | null;
|
|
554
|
+
stages: components["schemas"]["StagesInput"];
|
|
555
|
+
projects: number;
|
|
556
|
+
createdAt: string;
|
|
557
|
+
}>;
|
|
558
|
+
delete: (id: string) => Promise<{
|
|
559
|
+
ok: boolean;
|
|
560
|
+
}>;
|
|
561
|
+
};
|
|
562
|
+
webhooks: {
|
|
563
|
+
events: () => Promise<{
|
|
564
|
+
data: {
|
|
565
|
+
type: string;
|
|
566
|
+
group: string;
|
|
567
|
+
label: string;
|
|
568
|
+
}[];
|
|
569
|
+
}>;
|
|
570
|
+
list: () => Promise<{
|
|
571
|
+
data: Webhook[];
|
|
572
|
+
}>;
|
|
573
|
+
/** Keep `secret` to check each delivery with verifyWebhook(). */
|
|
574
|
+
create: (body: BodyOf<"/v1/webhooks", "post">) => Promise<{
|
|
575
|
+
id: string;
|
|
576
|
+
url: string;
|
|
577
|
+
events: string[] | null;
|
|
578
|
+
secret: string | null;
|
|
579
|
+
createdAt: string;
|
|
580
|
+
}>;
|
|
581
|
+
delete: (id: string) => Promise<{
|
|
582
|
+
ok: boolean;
|
|
583
|
+
}>;
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
/** The item type of a list endpoint, e.g. ListItem<"/v1/projects">. */
|
|
587
|
+
export type ListItem<P extends keyof paths> = ItemOf<P>;
|
|
588
|
+
/**
|
|
589
|
+
* Checks a webhook delivery: `TrulyFinal-Signature: t=<unix time>,v1=<hex HMAC-SHA256 of "t.body">`.
|
|
590
|
+
* Pass the raw body exactly as received. Deliveries older than `toleranceSec` (5 minutes) are refused,
|
|
591
|
+
* so a captured one can't be replayed later.
|
|
592
|
+
*/
|
|
593
|
+
export declare function verifyWebhook(secret: string, rawBody: string, signatureHeader: string | null | undefined, opts?: {
|
|
594
|
+
toleranceSec?: number;
|
|
595
|
+
now?: number;
|
|
596
|
+
}): Promise<boolean>;
|