@doist/twist-sdk 2.7.0 → 2.9.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/dist/cjs/clients/add-comment-helper.js +1 -2
- package/dist/cjs/clients/attachments-client.js +124 -0
- package/dist/cjs/clients/base-client.js +10 -0
- package/dist/cjs/clients/channels-client.js +9 -6
- package/dist/cjs/clients/comments-client.js +16 -6
- package/dist/cjs/clients/conversation-messages-client.js +9 -8
- package/dist/cjs/clients/conversations-client.js +11 -8
- package/dist/cjs/clients/inbox-client.js +6 -3
- package/dist/cjs/clients/threads-client.js +18 -9
- package/dist/cjs/clients/workspace-users-client.js +9 -2
- package/dist/cjs/clients/workspaces-client.js +7 -3
- package/dist/cjs/consts/endpoints.js +2 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/twist-api.js +2 -0
- package/dist/cjs/types/entities.js +99 -79
- package/dist/cjs/utils/multipart-upload.js +154 -0
- package/dist/esm/clients/add-comment-helper.js +1 -2
- package/dist/esm/clients/attachments-client.js +121 -0
- package/dist/esm/clients/base-client.js +10 -0
- package/dist/esm/clients/channels-client.js +10 -7
- package/dist/esm/clients/comments-client.js +17 -7
- package/dist/esm/clients/conversation-messages-client.js +10 -9
- package/dist/esm/clients/conversations-client.js +12 -9
- package/dist/esm/clients/inbox-client.js +7 -4
- package/dist/esm/clients/threads-client.js +19 -10
- package/dist/esm/clients/workspace-users-client.js +9 -2
- package/dist/esm/clients/workspaces-client.js +8 -4
- package/dist/esm/consts/endpoints.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/twist-api.js +2 -0
- package/dist/esm/types/entities.js +92 -78
- package/dist/esm/utils/multipart-upload.js +150 -0
- package/dist/types/clients/add-comment-helper.d.ts +3 -1
- package/dist/types/clients/attachments-client.d.ts +39 -0
- package/dist/types/clients/base-client.d.ts +4 -0
- package/dist/types/clients/channels-client.d.ts +1 -0
- package/dist/types/clients/comments-client.d.ts +1 -0
- package/dist/types/clients/conversation-messages-client.d.ts +1 -0
- package/dist/types/clients/conversations-client.d.ts +1 -0
- package/dist/types/clients/inbox-client.d.ts +1 -0
- package/dist/types/clients/threads-client.d.ts +2 -0
- package/dist/types/clients/workspace-users-client.d.ts +5 -0
- package/dist/types/clients/workspaces-client.d.ts +1 -0
- package/dist/types/consts/endpoints.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/twist-api.d.ts +2 -0
- package/dist/types/types/entities.d.ts +1539 -185
- package/dist/types/types/requests.d.ts +22 -0
- package/dist/types/utils/multipart-upload.d.ts +53 -0
- package/package.json +6 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { UploadFile } from '../utils/multipart-upload.js';
|
|
2
3
|
import { type Attachment } from './entities.js';
|
|
3
4
|
export declare const CreateChannelArgsSchema: z.ZodObject<{
|
|
4
5
|
workspaceId: z.ZodNumber;
|
|
@@ -353,6 +354,11 @@ export type RemoveGroupUsersArgs = {
|
|
|
353
354
|
export type GetWorkspaceUsersArgs = {
|
|
354
355
|
workspaceId: number;
|
|
355
356
|
archived?: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Include users who have been removed from the workspace. Defaults to `false`.
|
|
359
|
+
* The Twist API always returns removed users, so the SDK filters them client-side.
|
|
360
|
+
*/
|
|
361
|
+
includeRemoved?: boolean;
|
|
356
362
|
};
|
|
357
363
|
export type GetUserByIdArgs = {
|
|
358
364
|
workspaceId: number;
|
|
@@ -370,4 +376,20 @@ export type GetUserLocalTimeArgs = {
|
|
|
370
376
|
workspaceId: number;
|
|
371
377
|
userId: number;
|
|
372
378
|
};
|
|
379
|
+
export type UploadAttachmentArgs = {
|
|
380
|
+
/**
|
|
381
|
+
* The file to upload. Accepts a `Blob`/`File` (browser) or a `Uint8Array` of raw
|
|
382
|
+
* bytes. A Node `Buffer` is a `Uint8Array`, so `await readFile(path)` works directly.
|
|
383
|
+
*/
|
|
384
|
+
file: UploadFile;
|
|
385
|
+
/**
|
|
386
|
+
* File name. Required when `file` is a `Uint8Array`; inferred from the `File.name`
|
|
387
|
+
* otherwise.
|
|
388
|
+
*/
|
|
389
|
+
fileName?: string;
|
|
390
|
+
/** MIME type. Defaults to the `Blob`'s type or one inferred from the file extension. */
|
|
391
|
+
contentType?: string;
|
|
392
|
+
/** Attachment ID to use. A random UUID is generated when omitted. */
|
|
393
|
+
attachmentId?: string;
|
|
394
|
+
};
|
|
373
395
|
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CustomFetch } from '../types/http.js';
|
|
2
|
+
/**
|
|
3
|
+
* File content accepted by the upload helpers.
|
|
4
|
+
*
|
|
5
|
+
* - `Blob`/`File` — browser, or any runtime with a global `Blob` (Node 18+).
|
|
6
|
+
* - `Uint8Array` — raw bytes (requires `fileName`). A Node `Buffer` is a `Uint8Array`,
|
|
7
|
+
* so reading a file with `fs` and passing the result works without conversion.
|
|
8
|
+
*
|
|
9
|
+
* Both are universal types, so the published `.d.ts` stays free of Node-only globals
|
|
10
|
+
* (`Buffer`, `NodeJS.*`) and the helper pulls in no Node built-ins — keeping the browser
|
|
11
|
+
* bundle clean.
|
|
12
|
+
*/
|
|
13
|
+
export type UploadFile = Blob | Uint8Array;
|
|
14
|
+
type UploadMultipartFileArgs = {
|
|
15
|
+
/** Base API URI with trailing slash, e.g. `https://api.twist.com/api/v3/`. */
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
/** API token used for `Authorization: Bearer`. */
|
|
18
|
+
authToken: string;
|
|
19
|
+
/** Relative endpoint path, e.g. `attachments/upload`. */
|
|
20
|
+
endpoint: string;
|
|
21
|
+
/** File content to upload. */
|
|
22
|
+
file: UploadFile;
|
|
23
|
+
/** File name. Required for raw `Uint8Array` bytes; inferred from a `File`. */
|
|
24
|
+
fileName?: string;
|
|
25
|
+
/** MIME type. Defaults to the `Blob`'s type or one inferred from the file extension. */
|
|
26
|
+
contentType?: string;
|
|
27
|
+
/** Extra multipart fields to send alongside the file metadata fields. */
|
|
28
|
+
additionalFields?: Record<string, string | number | boolean | undefined | null>;
|
|
29
|
+
/** Optional request ID for tracing. */
|
|
30
|
+
requestId?: string;
|
|
31
|
+
/** Optional custom fetch implementation. */
|
|
32
|
+
customFetch?: CustomFetch;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Determine a content-type from a filename extension. Falls back to
|
|
36
|
+
* `application/octet-stream` for unknown extensions.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getContentTypeFromFileName(fileName: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Upload a file using `multipart/form-data`.
|
|
41
|
+
*
|
|
42
|
+
* Builds the request body with the global `FormData`/`Blob` so it works unchanged in the
|
|
43
|
+
* browser and in Node.js (via `undici`). The `file` part is sent alongside `file_name`,
|
|
44
|
+
* `file_size`, and `underlying_type` fields (the canonical Twist upload shape); any
|
|
45
|
+
* `additionalFields` are merged in and override the derived values. Authentication uses
|
|
46
|
+
* `Authorization: Bearer`, matching every other Twist SDK client, and `Content-Type` is
|
|
47
|
+
* intentionally left unset so the runtime adds the correct multipart boundary.
|
|
48
|
+
*
|
|
49
|
+
* The response is JSON-parsed and camel-cased by {@link fetchWithRetry}; callers validate
|
|
50
|
+
* the returned shape with the appropriate schema.
|
|
51
|
+
*/
|
|
52
|
+
export declare function uploadMultipartFile<T>(args: UploadMultipartFileArgs): Promise<T>;
|
|
53
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/twist-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "A TypeScript wrapper for the Twist REST API.",
|
|
5
5
|
"author": "Doist developers",
|
|
6
6
|
"homepage": "https://doist.github.io/twist-sdk-typescript/",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"type-check": "npx tsc --noEmit",
|
|
37
37
|
"check": "oxlint src && oxfmt --check",
|
|
38
38
|
"check:fix": "oxlint src --fix && oxfmt",
|
|
39
|
-
"attw": "
|
|
39
|
+
"attw": "attw --pack --ignore-rules fallback-condition false-esm",
|
|
40
40
|
"audit": "npm audit --audit-level=moderate",
|
|
41
41
|
"integrity-checks": "npm-run-all clean check test build attw",
|
|
42
42
|
"prepublishOnly": "npm run integrity-checks",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"zod": "4.1.12"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@arethetypeswrong/cli": "0.18.2",
|
|
53
54
|
"@semantic-release/changelog": "6.0.3",
|
|
54
55
|
"@semantic-release/git": "10.0.1",
|
|
55
56
|
"conventional-changelog-conventionalcommits": "9.3.0",
|
|
@@ -70,6 +71,9 @@
|
|
|
70
71
|
"peerDependencies": {
|
|
71
72
|
"type-fest": "^4.12.0 || ^5.1.0"
|
|
72
73
|
},
|
|
74
|
+
"overrides": {
|
|
75
|
+
"fflate": "0.8.2"
|
|
76
|
+
},
|
|
73
77
|
"husky": {
|
|
74
78
|
"hooks": {
|
|
75
79
|
"pre-commit": "npx lint-staged && npm run build"
|