Skip to content

Commit d50cbcf

Browse files
feat(api): add path policy related non-breaking changes
1 parent dcdc0b7 commit d50cbcf

File tree

10 files changed

+33
-5
lines changed

10 files changed

+33
-5
lines changed

.eslintcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"/home/tempuser-ntg79m/run/codegen-output/imagekit-inc/imagekit-typescript/packages/mcp-server/src/options.ts":"1"},{"size":17015,"mtime":1759200729406,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"uatmab","/home/tempuser-ntg79m/run/codegen-output/imagekit-inc/imagekit-typescript/packages/mcp-server/src/options.ts",[],[]]
1+
[{"/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/packages/mcp-server/src/tools/beta/v2/files/upload-v2-beta-files.ts":"1","/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/packages/mcp-server/src/tools/custom-metadata-fields/list-custom-metadata-fields.ts":"2","/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/packages/mcp-server/src/tools/files/upload-files.ts":"3","/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/src/resources/beta/v2/files.ts":"4","/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/src/resources/custom-metadata-fields.ts":"5","/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/src/resources/files/files.ts":"6","/home/tempuser-8f1dic/run/codegen-output/imagekit-inc/imagekit-typescript/tests/api-resources/custom-metadata-fields.test.ts":"7"},{"size":15178,"mtime":1759216900495},{"size":7344,"mtime":1759216900495},{"size":16142,"mtime":1759216900495},{"size":16692,"mtime":1759216900495},{"size":11809,"mtime":1759216900495},{"size":38731,"mtime":1759216900499},{"size":3928,"mtime":1759216900499}]

.stats.yml

Lines changed: 2 additions & 2 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-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml
3-
openapi_spec_hash: 1d382866fce3284f26d341f112988d9d
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1499148ce5fc81b4d8c8b3eaadf7adfaf54df5fa0b3a0452c3f5ef0dfe884a95.yml
3+
openapi_spec_hash: e91526b143d3e696bef2b4d0ea3aa2b4
44
config_hash: e42d7fc3a8c92c35099cc283f9a4467a

packages/mcp-server/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ The following tools are available in this MCP server.
212212
- `create_custom_metadata_fields` (`write`): This API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.
213213
- `update_custom_metadata_fields` (`write`): This API updates the label or schema of an existing custom metadata field.
214214
- `list_custom_metadata_fields` (`read`): This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.
215+
216+
You can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.
217+
215218
- `delete_custom_metadata_fields` (`write`): This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.
216219

217220
### Resource `files`:

packages/mcp-server/src/tools/beta/v2/files/upload-v2-beta-files.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export const tool: Tool = {
106106
'isPublished',
107107
'customMetadata',
108108
'metadata',
109+
'selectedFieldsSchema',
109110
],
110111
},
111112
},

packages/mcp-server/src/tools/custom-metadata-fields/list-custom-metadata-fields.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ export const metadata: Metadata = {
1818
export const tool: Tool = {
1919
name: 'list_custom_metadata_fields',
2020
description:
21-
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\n# Response Schema\n```json\n{\n type: 'array',\n items: {\n $ref: '#/$defs/custom_metadata_field'\n },\n $defs: {\n custom_metadata_field: {\n type: 'object',\n description: 'Object containing details of a custom metadata field.',\n properties: {\n id: {\n type: 'string',\n description: 'Unique identifier for the custom metadata field. Use this to update the field.'\n },\n label: {\n type: 'string',\n description: 'Human readable name of the custom metadata field. This name is displayed as form field label to the users while setting field value on the asset in the media library UI.\\n'\n },\n name: {\n type: 'string',\n description: 'API name of the custom metadata field. This becomes the key while setting `customMetadata` (key-value object) for an asset using upload or update API.\\n'\n },\n schema: {\n type: 'object',\n description: 'An object that describes the rules for the custom metadata field value.',\n properties: {\n type: {\n type: 'string',\n description: 'Type of the custom metadata field.',\n enum: [ 'Text',\n 'Textarea',\n 'Number',\n 'Date',\n 'Boolean',\n 'SingleSelect',\n 'MultiSelect'\n ]\n },\n defaultValue: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n },\n {\n type: 'boolean'\n },\n {\n type: 'array',\n title: 'Mixed',\n description: 'Default value should be of type array when custom metadata field type is set to `MultiSelect`.\\n',\n items: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n },\n {\n type: 'boolean'\n }\n ]\n }\n }\n ],\n description: 'The default value for this custom metadata field. Date type of default value depends on the field type.\\n'\n },\n isValueRequired: {\n type: 'boolean',\n description: 'Specifies if the this custom metadata field is required or not.\\n'\n },\n maxLength: {\n type: 'number',\n description: 'Maximum length of string. Only set if `type` is set to `Text` or `Textarea`.\\n'\n },\n maxValue: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n }\n ],\n description: 'Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value.\\n'\n },\n minLength: {\n type: 'number',\n description: 'Minimum length of string. Only set if `type` is set to `Text` or `Textarea`.\\n'\n },\n minValue: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n }\n ],\n description: 'Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value.\\n'\n },\n selectOptions: {\n type: 'array',\n description: 'An array of allowed values when field type is `SingleSelect` or `MultiSelect`.\\n',\n items: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n },\n {\n type: 'boolean'\n }\n ]\n }\n }\n },\n required: [ 'type'\n ]\n }\n },\n required: [ 'id',\n 'label',\n 'name',\n 'schema'\n ]\n }\n }\n}\n```",
21+
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n\n\n# Response Schema\n```json\n{\n type: 'array',\n items: {\n $ref: '#/$defs/custom_metadata_field'\n },\n $defs: {\n custom_metadata_field: {\n type: 'object',\n description: 'Object containing details of a custom metadata field.',\n properties: {\n id: {\n type: 'string',\n description: 'Unique identifier for the custom metadata field. Use this to update the field.'\n },\n label: {\n type: 'string',\n description: 'Human readable name of the custom metadata field. This name is displayed as form field label to the users while setting field value on the asset in the media library UI.\\n'\n },\n name: {\n type: 'string',\n description: 'API name of the custom metadata field. This becomes the key while setting `customMetadata` (key-value object) for an asset using upload or update API.\\n'\n },\n schema: {\n type: 'object',\n description: 'An object that describes the rules for the custom metadata field value.',\n properties: {\n type: {\n type: 'string',\n description: 'Type of the custom metadata field.',\n enum: [ 'Text',\n 'Textarea',\n 'Number',\n 'Date',\n 'Boolean',\n 'SingleSelect',\n 'MultiSelect'\n ]\n },\n defaultValue: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n },\n {\n type: 'boolean'\n },\n {\n type: 'array',\n title: 'Mixed',\n description: 'Default value should be of type array when custom metadata field type is set to `MultiSelect`.\\n',\n items: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n },\n {\n type: 'boolean'\n }\n ]\n }\n }\n ],\n description: 'The default value for this custom metadata field. Date type of default value depends on the field type.\\n'\n },\n isValueRequired: {\n type: 'boolean',\n description: 'Specifies if the this custom metadata field is required or not.\\n'\n },\n maxLength: {\n type: 'number',\n description: 'Maximum length of string. Only set if `type` is set to `Text` or `Textarea`.\\n'\n },\n maxValue: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n }\n ],\n description: 'Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value.\\n'\n },\n minLength: {\n type: 'number',\n description: 'Minimum length of string. Only set if `type` is set to `Text` or `Textarea`.\\n'\n },\n minValue: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n }\n ],\n description: 'Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type field, the value will be in ISO8601 string format. For `Number` type field, it will be a numeric value.\\n'\n },\n selectOptions: {\n type: 'array',\n description: 'An array of allowed values when field type is `SingleSelect` or `MultiSelect`.\\n',\n items: {\n anyOf: [ {\n type: 'string'\n },\n {\n type: 'number'\n },\n {\n type: 'boolean'\n }\n ]\n }\n }\n },\n required: [ 'type'\n ]\n }\n },\n required: [ 'id',\n 'label',\n 'name',\n 'schema'\n ]\n }\n }\n}\n```",
2222
inputSchema: {
2323
type: 'object',
2424
properties: {
25+
folderPath: {
26+
type: 'string',
27+
description:
28+
'The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. \nUseful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.\n',
29+
},
2530
includeDeleted: {
2631
type: 'boolean',
2732
description: 'Set it to `true` to include deleted field objects in the API response.\n',

packages/mcp-server/src/tools/files/upload-files.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const tool: Tool = {
117117
'isPublished',
118118
'customMetadata',
119119
'metadata',
120+
'selectedFieldsSchema',
120121
],
121122
},
122123
},

src/resources/beta/v2/files.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ export interface FileUploadParams {
403403
| 'isPublished'
404404
| 'customMetadata'
405405
| 'metadata'
406+
| 'selectedFieldsSchema'
406407
>;
407408

408409
/**

src/resources/custom-metadata-fields.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export class CustomMetadataFields extends APIResource {
5959
* the API returns only non deleted field objects, but you can include deleted
6060
* fields in the API response.
6161
*
62+
* You can also filter results by a specific folder path to retrieve custom
63+
* metadata fields applicable at that location. This path-specific filtering is
64+
* useful when using the **Path policy** feature to determine which custom metadata
65+
* fields are selected for a given path.
66+
*
6267
* @example
6368
* ```ts
6469
* const customMetadataFields =
@@ -319,6 +324,14 @@ export namespace CustomMetadataFieldUpdateParams {
319324
}
320325

321326
export interface CustomMetadataFieldListParams {
327+
/**
328+
* The folder path (e.g., `/path/to/folder`) for which to retrieve applicable
329+
* custom metadata fields.
330+
* Useful for determining path-specific field selections when the
331+
* [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.
332+
*/
333+
folderPath?: string;
334+
322335
/**
323336
* Set it to `true` to include deleted field objects in the API response.
324337
*/

src/resources/files/files.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ export interface FileUploadParams {
12361236
| 'isPublished'
12371237
| 'customMetadata'
12381238
| 'metadata'
1239+
| 'selectedFieldsSchema'
12391240
>;
12401241

12411242
/**

tests/api-resources/custom-metadata-fields.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ describe('resource customMetadataFields', () => {
9494
test.skip('list: request options and params are passed correctly', async () => {
9595
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
9696
await expect(
97-
client.customMetadataFields.list({ includeDeleted: true }, { path: '/_stainless_unknown_path' }),
97+
client.customMetadataFields.list(
98+
{ folderPath: 'folderPath', includeDeleted: true },
99+
{ path: '/_stainless_unknown_path' },
100+
),
98101
).rejects.toThrow(ImageKit.NotFoundError);
99102
});
100103

0 commit comments

Comments
 (0)