Skip to content

Commit 9ec6627

Browse files
feat(api): manual updates
1 parent e964875 commit 9ec6627

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,
@@ -856,7 +856,7 @@ export declare namespace ImageKit {
856856
type File as File,
857857
type Folder as Folder,
858858
type Metadata as Metadata,
859-
type UpdateFileDetailsRequest as UpdateFileDetailsRequest,
859+
type UpdateFileRequest as UpdateFileRequest,
860860
type FileUpdateResponse as FileUpdateResponse,
861861
type FileCopyResponse as FileCopyResponse,
862862
type FileMoveResponse as FileMoveResponse,

src/resources/files/files.ts

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

@@ -629,11 +605,12 @@ export namespace Metadata {
629605
}
630606
}
631607

632-
export type UpdateFileDetailsRequest =
633-
| UpdateFileDetailsRequest.UpdateFileDetails
634-
| UpdateFileDetailsRequest.ChangePublicationStatus;
608+
/**
609+
* Schema for update file update request.
610+
*/
611+
export type UpdateFileRequest = UpdateFileRequest.UpdateFileDetails | unknown;
635612

636-
export namespace UpdateFileDetailsRequest {
613+
export namespace UpdateFileRequest {
637614
export interface UpdateFileDetails {
638615
/**
639616
* Define an important area in the image in the format `x,y,width,height` e.g.
@@ -685,31 +662,6 @@ export namespace UpdateFileDetailsRequest {
685662
*/
686663
webhookUrl?: string;
687664
}
688-
689-
export interface ChangePublicationStatus {
690-
/**
691-
* Configure the publication status of a file and its versions.
692-
*/
693-
publish?: ChangePublicationStatus.Publish;
694-
}
695-
696-
export namespace ChangePublicationStatus {
697-
/**
698-
* Configure the publication status of a file and its versions.
699-
*/
700-
export interface Publish {
701-
/**
702-
* Set to `true` to publish the file. Set to `false` to unpublish the file.
703-
*/
704-
isPublished: boolean;
705-
706-
/**
707-
* Set to `true` to publish/unpublish all versions of the file. Set to `false` to
708-
* publish/unpublish only the current version of the file.
709-
*/
710-
includeFileVersions?: boolean;
711-
}
712-
}
713665
}
714666

715667
/**
@@ -1008,28 +960,7 @@ export declare namespace FileUpdateParams {
1008960
}
1009961

1010962
export interface ChangePublicationStatus {
1011-
/**
1012-
* Configure the publication status of a file and its versions.
1013-
*/
1014-
publish?: ChangePublicationStatus.Publish;
1015-
}
1016-
1017-
export namespace ChangePublicationStatus {
1018-
/**
1019-
* Configure the publication status of a file and its versions.
1020-
*/
1021-
export interface Publish {
1022-
/**
1023-
* Set to `true` to publish the file. Set to `false` to unpublish the file.
1024-
*/
1025-
isPublished: boolean;
1026-
1027-
/**
1028-
* Set to `true` to publish/unpublish all versions of the file. Set to `false` to
1029-
* publish/unpublish only the current version of the file.
1030-
*/
1031-
includeFileVersions?: boolean;
1032-
}
963+
body: unknown;
1033964
}
1034965
}
1035966

@@ -1411,7 +1342,7 @@ export declare namespace Files {
14111342
type File as File,
14121343
type Folder as Folder,
14131344
type Metadata as Metadata,
1414-
type UpdateFileDetailsRequest as UpdateFileDetailsRequest,
1345+
type UpdateFileRequest as UpdateFileRequest,
14151346
type FileUpdateResponse as FileUpdateResponse,
14161347
type FileCopyResponse as FileCopyResponse,
14171348
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)