Skip to content

Commit 2ac7656

Browse files
feat(api): manual updates
1 parent 66e3b81 commit 2ac7656

File tree

7 files changed

+19
-120
lines changed

7 files changed

+19
-120
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml
3-
openapi_spec_hash: 1bfde02a63416c036e9545927f727459
4-
config_hash: b415c06a3b29485af4601beb94ae1aeb
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml
3+
openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9
4+
config_hash: 54c05a157f2cc730fac9e1df5dc3ca29

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Types:
4242
- <code><a href="./src/resources/files/files.ts">File</a></code>
4343
- <code><a href="./src/resources/files/files.ts">Folder</a></code>
4444
- <code><a href="./src/resources/files/files.ts">Metadata</a></code>
45-
- <code><a href="./src/resources/files/files.ts">UpdateFileDetailsRequest</a></code>
45+
- <code><a href="./src/resources/files/files.ts">UpdateFileRequest</a></code>
4646
- <code><a href="./src/resources/files/files.ts">FileUpdateResponse</a></code>
4747
- <code><a href="./src/resources/files/files.ts">FileCopyResponse</a></code>
4848
- <code><a href="./src/resources/files/files.ts">FileMoveResponse</a></code>

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
Files,
5858
Folder,
5959
Metadata,
60-
UpdateFileDetailsRequest,
60+
UpdateFileRequest,
6161
} from './resources/files/files';
6262
import {
6363
FolderCopyParams,
@@ -857,7 +857,7 @@ export declare namespace ImageKit {
857857
type File as File,
858858
type Folder as Folder,
859859
type Metadata as Metadata,
860-
type UpdateFileDetailsRequest as UpdateFileDetailsRequest,
860+
type UpdateFileRequest as UpdateFileRequest,
861861
type FileUpdateResponse as FileUpdateResponse,
862862
type FileCopyResponse as FileCopyResponse,
863863
type FileMoveResponse as FileMoveResponse,

src/resources/files/files.ts

Lines changed: 10 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,11 @@ export class Files extends APIResource {
4545
*
4646
* @example
4747
* ```ts
48-
* const file = await client.files.update('fileId', {
49-
* customCoordinates: '10,10,100,100',
50-
* customMetadata: { brand: 'Nike', color: 'red' },
51-
* extensions: [
52-
* { name: 'remove-bg', options: { add_shadow: true } },
53-
* {
54-
* name: 'google-auto-tagging',
55-
* minConfidence: 80,
56-
* maxTags: 10,
57-
* },
58-
* {
59-
* name: 'aws-auto-tagging',
60-
* minConfidence: 80,
61-
* maxTags: 10,
62-
* },
63-
* { name: 'ai-auto-description' },
64-
* ],
65-
* removeAITags: ['car', 'vehicle', 'motorsports'],
66-
* tags: ['tag1', 'tag2'],
67-
* webhookUrl:
68-
* 'https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a',
69-
* });
48+
* const file = await client.files.update('fileId');
7049
* ```
7150
*/
72-
update(
73-
fileID: string,
74-
body: FileUpdateParams | null | undefined = {},
75-
options?: RequestOptions,
76-
): APIPromise<FileUpdateResponse> {
51+
update(fileID: string, params: FileUpdateParams, options?: RequestOptions): APIPromise<FileUpdateResponse> {
52+
const body = 'body' in params ? params.body : params;
7753
return this._client.patch(path`/v1/files/${fileID}/details`, { body, ...options });
7854
}
7955

@@ -632,11 +608,12 @@ export namespace Metadata {
632608
}
633609
}
634610

635-
export type UpdateFileDetailsRequest =
636-
| UpdateFileDetailsRequest.UpdateFileDetails
637-
| UpdateFileDetailsRequest.ChangePublicationStatus;
611+
/**
612+
* Schema for update file update request.
613+
*/
614+
export type UpdateFileRequest = UpdateFileRequest.UpdateFileDetails | unknown;
638615

639-
export namespace UpdateFileDetailsRequest {
616+
export namespace UpdateFileRequest {
640617
export interface UpdateFileDetails {
641618
/**
642619
* Define an important area in the image in the format `x,y,width,height` e.g.
@@ -688,31 +665,6 @@ export namespace UpdateFileDetailsRequest {
688665
*/
689666
webhookUrl?: string;
690667
}
691-
692-
export interface ChangePublicationStatus {
693-
/**
694-
* Configure the publication status of a file and its versions.
695-
*/
696-
publish?: ChangePublicationStatus.Publish;
697-
}
698-
699-
export namespace ChangePublicationStatus {
700-
/**
701-
* Configure the publication status of a file and its versions.
702-
*/
703-
export interface Publish {
704-
/**
705-
* Set to `true` to publish the file. Set to `false` to unpublish the file.
706-
*/
707-
isPublished: boolean;
708-
709-
/**
710-
* Set to `true` to publish/unpublish all versions of the file. Set to `false` to
711-
* publish/unpublish only the current version of the file.
712-
*/
713-
includeFileVersions?: boolean;
714-
}
715-
}
716668
}
717669

718670
/**
@@ -1011,28 +963,7 @@ export declare namespace FileUpdateParams {
1011963
}
1012964

1013965
export interface ChangePublicationStatus {
1014-
/**
1015-
* Configure the publication status of a file and its versions.
1016-
*/
1017-
publish?: ChangePublicationStatus.Publish;
1018-
}
1019-
1020-
export namespace ChangePublicationStatus {
1021-
/**
1022-
* Configure the publication status of a file and its versions.
1023-
*/
1024-
export interface Publish {
1025-
/**
1026-
* Set to `true` to publish the file. Set to `false` to unpublish the file.
1027-
*/
1028-
isPublished: boolean;
1029-
1030-
/**
1031-
* Set to `true` to publish/unpublish all versions of the file. Set to `false` to
1032-
* publish/unpublish only the current version of the file.
1033-
*/
1034-
includeFileVersions?: boolean;
1035-
}
966+
body: unknown;
1036967
}
1037968
}
1038969

@@ -1414,7 +1345,7 @@ export declare namespace Files {
14141345
type File as File,
14151346
type Folder as Folder,
14161347
type Metadata as Metadata,
1417-
type UpdateFileDetailsRequest as UpdateFileDetailsRequest,
1348+
type UpdateFileRequest as UpdateFileRequest,
14181349
type FileUpdateResponse as FileUpdateResponse,
14191350
type FileCopyResponse as FileCopyResponse,
14201351
type FileMoveResponse as FileMoveResponse,

src/resources/files/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export {
1616
type File,
1717
type Folder,
1818
type Metadata,
19-
type UpdateFileDetailsRequest,
19+
type UpdateFileRequest,
2020
type FileUpdateResponse,
2121
type FileCopyResponse,
2222
type FileMoveResponse,

src/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export {
1919
type File,
2020
type Folder,
2121
type Metadata,
22-
type UpdateFileDetailsRequest,
22+
type UpdateFileRequest,
2323
type FileUpdateResponse,
2424
type FileCopyResponse,
2525
type FileMoveResponse,

tests/api-resources/files/files.test.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const client = new ImageKit({
1111
describe('resource files', () => {
1212
// Prism tests are disabled
1313
test.skip('update', async () => {
14-
const responsePromise = client.files.update('fileId');
14+
const responsePromise = client.files.update('fileId', {});
1515
const rawResponse = await responsePromise.asResponse();
1616
expect(rawResponse).toBeInstanceOf(Response);
1717
const response = await responsePromise;
@@ -21,38 +21,6 @@ describe('resource files', () => {
2121
expect(dataAndResponse.response).toBe(rawResponse);
2222
});
2323

24-
// Prism tests are disabled
25-
test.skip('update: request options and params are passed correctly', async () => {
26-
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
27-
await expect(
28-
client.files.update(
29-
'fileId',
30-
{
31-
customCoordinates: 'customCoordinates',
32-
customMetadata: { foo: 'bar' },
33-
description: 'description',
34-
extensions: [
35-
{
36-
name: 'remove-bg',
37-
options: {
38-
add_shadow: true,
39-
bg_color: 'bg_color',
40-
bg_image_url: 'bg_image_url',
41-
semitransparency: true,
42-
},
43-
},
44-
{ maxTags: 5, minConfidence: 95, name: 'google-auto-tagging' },
45-
{ name: 'ai-auto-description' },
46-
],
47-
removeAITags: ['string'],
48-
tags: ['tag1', 'tag2'],
49-
webhookUrl: 'https://example.com',
50-
},
51-
{ path: '/_stainless_unknown_path' },
52-
),
53-
).rejects.toThrow(ImageKit.NotFoundError);
54-
});
55-
5624
// Prism tests are disabled
5725
test.skip('delete', async () => {
5826
const responsePromise = client.files.delete('fileId');

0 commit comments

Comments
 (0)