@air/api-rest 0.7.0 → 0.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/index.cjs CHANGED
@@ -62,6 +62,33 @@ module.exports = __toCommonJS(index_exports);
62
62
  // src/api.ts
63
63
  var import_api_core = require("@air/api-core");
64
64
 
65
+ // src/resources/serialize-asset-custom-field-filter.ts
66
+ var INVALID_ASSET_CUSTOM_FIELD_FILTER = "Asset custom field filter must be a select { id, valueId } or an operator { id, operator, value }";
67
+ var readOwn = (filter, key) => Object.hasOwn(filter, key) ? filter[key] : void 0;
68
+ var isSelectFilter = (filter) => {
69
+ const valueId = readOwn(filter, "valueId");
70
+ const operator = readOwn(filter, "operator");
71
+ return typeof filter.id === "string" && typeof valueId === "string" && operator === void 0;
72
+ };
73
+ var isOperatorFilter = (filter) => {
74
+ const valueId = readOwn(filter, "valueId");
75
+ const operator = readOwn(filter, "operator");
76
+ const value = readOwn(filter, "value");
77
+ return typeof filter.id === "string" && valueId === void 0 && typeof operator === "string" && typeof value === "string";
78
+ };
79
+ var serializeAssetCustomFieldFilter = (filter) => {
80
+ if (typeof filter === "string") {
81
+ return filter;
82
+ }
83
+ if (isSelectFilter(filter)) {
84
+ return `${filter.id}:${filter.valueId}`;
85
+ }
86
+ if (isOperatorFilter(filter)) {
87
+ return `${filter.id}:${filter.operator}:${filter.value}`;
88
+ }
89
+ throw new Error(INVALID_ASSET_CUSTOM_FIELD_FILTER);
90
+ };
91
+
65
92
  // src/resources/assets.ts
66
93
  var Assets = class {
67
94
  constructor(client) {
@@ -84,7 +111,7 @@ var Assets = class {
84
111
  query.tag = params.tag;
85
112
  }
86
113
  if (params.customField) {
87
- query.customField = params.customField;
114
+ query.customField = Array.isArray(params.customField) ? params.customField.map(serializeAssetCustomFieldFilter) : serializeAssetCustomFieldFilter(params.customField);
88
115
  }
89
116
  if (params["createdAt[gte]"]) {
90
117
  query["createdAt[gte]"] = params["createdAt[gte]"];
package/dist/index.d.cts CHANGED
@@ -56,11 +56,56 @@ interface Asset {
56
56
  customFields: AssetCustomFieldValue[] | undefined;
57
57
  coverVersion: AssetVersion;
58
58
  }
59
+ type AssetCustomFieldTextOperator = "text" | "textPrefix" | "textNot";
60
+ type AssetCustomFieldDateOperator = "dateGte" | "dateLte";
61
+ interface AssetCustomFieldSelectFilter {
62
+ id: string;
63
+ valueId: string;
64
+ }
65
+ interface AssetCustomFieldTextFilter {
66
+ id: string;
67
+ operator: AssetCustomFieldTextOperator;
68
+ value: string;
69
+ }
70
+ interface AssetCustomFieldDateFilter {
71
+ id: string;
72
+ operator: AssetCustomFieldDateOperator;
73
+ value: string;
74
+ }
75
+ /**
76
+ * One `customField` query value for `assets.list`.
77
+ *
78
+ * A string is sent unchanged (`fieldId:valueId`, or an operator string the
79
+ * caller already formatted). A structured filter is serialized to that same
80
+ * query value. Repeats become repeated query params.
81
+ */
82
+ type AssetCustomFieldFilter = string | AssetCustomFieldSelectFilter | AssetCustomFieldTextFilter | AssetCustomFieldDateFilter;
59
83
  interface AssetListParams extends CursorPageParams {
60
84
  parentBoardId?: string;
61
85
  includeNestedAssets?: boolean;
62
86
  tag?: string | string[];
63
- customField?: string | string[];
87
+ /**
88
+ * Filter by custom field. Select filters are `{ id, valueId }` (or the
89
+ * `fieldId:valueId` string). Repeats of one field are OR, and different
90
+ * fields are AND.
91
+ *
92
+ * Plain text is `{ id, operator: "text" | "textPrefix" | "textNot", value }`.
93
+ * `text` repeats are OR, `textPrefix` is one prefix, and `textNot` excludes.
94
+ * The value keeps colons and surrounding spaces. Empty text, more than 256
95
+ * characters, and more than 20 values are rejected with 400.
96
+ *
97
+ * Dates are `{ id, operator: "dateGte" | "dateLte", value }`. `dateGte` is an
98
+ * inclusive start and `dateLte` is an inclusive end, one of each per field.
99
+ * A `YYYY-MM-DD` value is that UTC day (`dateGte` at `T00:00:00.000Z`,
100
+ * `dateLte` at `T23:59:59.999Z`). The app stores a picked date as the
101
+ * viewer's local midnight converted to UTC, so match that shown day with an
102
+ * ISO-8601 instant (`T` and `Z` or `±HH:MM`). A start after the end is 400.
103
+ *
104
+ * One field accepts one operator kind. A mix of select, `text`, `textPrefix`,
105
+ * `textNot`, and date bounds on that field is 400. `boards.list` accepts
106
+ * select strings only. `semantic: true` rejects `customField`.
107
+ */
108
+ customField?: AssetCustomFieldFilter | AssetCustomFieldFilter[];
64
109
  search?: string;
65
110
  /**
66
111
  * When true, `search` is used for semantic search via AI embeddings.
@@ -136,6 +181,11 @@ interface Board {
136
181
  interface BoardListParams extends CursorPageParams {
137
182
  name?: string;
138
183
  parentBoardId?: string;
184
+ /**
185
+ * Select filters only, as `fieldId:valueId`. Repeats of one field are OR, and
186
+ * different fields are AND. Plain-text and date operators are rejected with
187
+ * 400; use `assets.list` for those.
188
+ */
139
189
  customField?: string | string[];
140
190
  /**
141
191
  * Only return boards in this library. Mutually exclusive with
@@ -188,9 +238,15 @@ interface GuestListResponse {
188
238
  data: Guest[];
189
239
  }
190
240
 
191
- /** Visitor comment access on a share link. */
241
+ /**
242
+ * Visitor comment access on a share link.
243
+ * `allowed` lets anyone with the link post comments.
244
+ */
192
245
  type ShareLinkCommentsAccess = "hidden" | "read_only" | "allowed";
193
- /** Visitor custom field access on a share link. */
246
+ /**
247
+ * Visitor custom field access on a share link.
248
+ * `editable` lets anyone with the link change custom field values.
249
+ */
194
250
  type ShareLinkCustomFieldsAccess = "hidden" | "read_only" | "editable";
195
251
  /**
196
252
  * Public share link fields shared by assets and boards.
@@ -242,10 +298,31 @@ interface BoardShareLinkListResponse extends CursorPageResponse<BoardShareLink>
242
298
  * Settings accepted on share-link create and update.
243
299
  * Omitted fields follow the workspace Share Link Defaults on create,
244
300
  * and stay unchanged on update.
301
+ *
302
+ * `password` is write only; reads return `hasPassword`. `null` clears
303
+ * `password` and `expiresAt`. An empty password is rejected. `expiresAt`
304
+ * must be an ISO 8601 date-time in the future.
305
+ *
306
+ * Turning `password`, `expiresAt`, `requireAccount`, `comments`, or
307
+ * `customFields` on needs the workspace `shareLinks` add-on. Otherwise the
308
+ * API returns 422 `ADDON_DISABLED` and applies nothing in the request.
309
+ * Raising `comments` from `read_only` to `allowed`, or `customFields` from
310
+ * `read_only` to `editable`, counts as turning it on, so a link that already
311
+ * shows comments or custom fields can still get that 422.
312
+ * `extra.settings` names the rejected settings, and uses `expiration` for
313
+ * `expiresAt`. Re-sending a value the link already has, changing an existing
314
+ * password or expiration, and turning a setting off are accepted.
245
315
  */
246
316
  interface ShareLinkWriteSettings {
247
317
  active?: boolean;
248
318
  allowDownload?: boolean;
319
+ /** Write only. `null` removes the password. */
320
+ password?: string | null;
321
+ /** ISO 8601 date-time in the future. `null` removes the expiration. */
322
+ expiresAt?: string | null;
323
+ requireAccount?: boolean;
324
+ comments?: ShareLinkCommentsAccess;
325
+ customFields?: ShareLinkCustomFieldsAccess;
249
326
  }
250
327
  /** Asset links also accept `showAllVersions`. */
251
328
  interface AssetShareLinkWriteSettings extends ShareLinkWriteSettings {
@@ -601,4 +678,4 @@ declare class AirApi extends AirBase {
601
678
  constructor(options?: AirApiOptions);
602
679
  }
603
680
 
604
- export { type AddBoardAssetsParams, type AddGuestParams, type AddVersionTagParams, AirApi, type AirApiOptions, type Asset, type AssetBoardListParams, type AssetCdnLinkCreateParams, type AssetCdnLinkListResponse, type AssetCdnLinkUpdateParams, type AssetCustomFieldValue, type AssetListParams, type AssetShareLink, type AssetShareLinkCreateParams, type AssetShareLinkListParams, type AssetShareLinkUpdateParams, type AssetShareLinkWriteSettings, type AssetVersion, type AssetVersionDownloadUrl, type AssetVersionListResponse, type AssetVersionUpdateParams, type AssetVersionUrls, Assets, type Board, type BoardCreateParams, type BoardListParams, type BoardShareLink, type BoardShareLinkCreateParams, type BoardShareLinkListResponse, type BoardShareLinkUpdateParams, type BoardUpdateParams, Boards, type CdnLink, type CompleteMultipartParams, type CustomField, type CustomFieldCreateParams, type CustomFieldListParams, type CustomFieldType, type CustomFieldUpdateParams, type CustomFieldValue, type CustomFieldValueCreateParams, type CustomFieldValueUpdateParams, CustomFields, type FileMeta, type FileSource, type GetPartUploadUrlParams, type GetPartUploadUrlResponse, type Guest, type GuestListParams, type GuestListResponse, type ImportCreateParams, type ImportCreateResponse, type ImportStatus, type ImportStatusResponse, Imports, type LargeUploadResponse, Libraries, type Library, type LibraryCreateParams, type LibraryListParams, type LibraryUpdateParams, type Role, type RoleListParams, type RoleListResponse, Roles, type SetBoardCustomFieldParams, type SetCustomFieldParams, type ShareLink, type ShareLinkCommentsAccess, type ShareLinkCustomFieldsAccess, type ShareLinkWriteSettings, type SmallUploadResponse, type SmartTag, type Tag, type TagCreateParams, type TagListParams, type TagUpdateParams, Tags, type UpdateGuestParams, type UploadCreateParams, type UploadCreateResponse, type UploadFileOptions, type UploadFileParams, type UploadFileResponse, Uploads, type Workspace, type WorkspaceListResponse, Workspaces };
681
+ export { type AddBoardAssetsParams, type AddGuestParams, type AddVersionTagParams, AirApi, type AirApiOptions, type Asset, type AssetBoardListParams, type AssetCdnLinkCreateParams, type AssetCdnLinkListResponse, type AssetCdnLinkUpdateParams, type AssetCustomFieldDateFilter, type AssetCustomFieldDateOperator, type AssetCustomFieldFilter, type AssetCustomFieldSelectFilter, type AssetCustomFieldTextFilter, type AssetCustomFieldTextOperator, type AssetCustomFieldValue, type AssetListParams, type AssetShareLink, type AssetShareLinkCreateParams, type AssetShareLinkListParams, type AssetShareLinkUpdateParams, type AssetShareLinkWriteSettings, type AssetVersion, type AssetVersionDownloadUrl, type AssetVersionListResponse, type AssetVersionUpdateParams, type AssetVersionUrls, Assets, type Board, type BoardCreateParams, type BoardListParams, type BoardShareLink, type BoardShareLinkCreateParams, type BoardShareLinkListResponse, type BoardShareLinkUpdateParams, type BoardUpdateParams, Boards, type CdnLink, type CompleteMultipartParams, type CustomField, type CustomFieldCreateParams, type CustomFieldListParams, type CustomFieldType, type CustomFieldUpdateParams, type CustomFieldValue, type CustomFieldValueCreateParams, type CustomFieldValueUpdateParams, CustomFields, type FileMeta, type FileSource, type GetPartUploadUrlParams, type GetPartUploadUrlResponse, type Guest, type GuestListParams, type GuestListResponse, type ImportCreateParams, type ImportCreateResponse, type ImportStatus, type ImportStatusResponse, Imports, type LargeUploadResponse, Libraries, type Library, type LibraryCreateParams, type LibraryListParams, type LibraryUpdateParams, type Role, type RoleListParams, type RoleListResponse, Roles, type SetBoardCustomFieldParams, type SetCustomFieldParams, type ShareLink, type ShareLinkCommentsAccess, type ShareLinkCustomFieldsAccess, type ShareLinkWriteSettings, type SmallUploadResponse, type SmartTag, type Tag, type TagCreateParams, type TagListParams, type TagUpdateParams, Tags, type UpdateGuestParams, type UploadCreateParams, type UploadCreateResponse, type UploadFileOptions, type UploadFileParams, type UploadFileResponse, Uploads, type Workspace, type WorkspaceListResponse, Workspaces };
package/dist/index.d.ts CHANGED
@@ -56,11 +56,56 @@ interface Asset {
56
56
  customFields: AssetCustomFieldValue[] | undefined;
57
57
  coverVersion: AssetVersion;
58
58
  }
59
+ type AssetCustomFieldTextOperator = "text" | "textPrefix" | "textNot";
60
+ type AssetCustomFieldDateOperator = "dateGte" | "dateLte";
61
+ interface AssetCustomFieldSelectFilter {
62
+ id: string;
63
+ valueId: string;
64
+ }
65
+ interface AssetCustomFieldTextFilter {
66
+ id: string;
67
+ operator: AssetCustomFieldTextOperator;
68
+ value: string;
69
+ }
70
+ interface AssetCustomFieldDateFilter {
71
+ id: string;
72
+ operator: AssetCustomFieldDateOperator;
73
+ value: string;
74
+ }
75
+ /**
76
+ * One `customField` query value for `assets.list`.
77
+ *
78
+ * A string is sent unchanged (`fieldId:valueId`, or an operator string the
79
+ * caller already formatted). A structured filter is serialized to that same
80
+ * query value. Repeats become repeated query params.
81
+ */
82
+ type AssetCustomFieldFilter = string | AssetCustomFieldSelectFilter | AssetCustomFieldTextFilter | AssetCustomFieldDateFilter;
59
83
  interface AssetListParams extends CursorPageParams {
60
84
  parentBoardId?: string;
61
85
  includeNestedAssets?: boolean;
62
86
  tag?: string | string[];
63
- customField?: string | string[];
87
+ /**
88
+ * Filter by custom field. Select filters are `{ id, valueId }` (or the
89
+ * `fieldId:valueId` string). Repeats of one field are OR, and different
90
+ * fields are AND.
91
+ *
92
+ * Plain text is `{ id, operator: "text" | "textPrefix" | "textNot", value }`.
93
+ * `text` repeats are OR, `textPrefix` is one prefix, and `textNot` excludes.
94
+ * The value keeps colons and surrounding spaces. Empty text, more than 256
95
+ * characters, and more than 20 values are rejected with 400.
96
+ *
97
+ * Dates are `{ id, operator: "dateGte" | "dateLte", value }`. `dateGte` is an
98
+ * inclusive start and `dateLte` is an inclusive end, one of each per field.
99
+ * A `YYYY-MM-DD` value is that UTC day (`dateGte` at `T00:00:00.000Z`,
100
+ * `dateLte` at `T23:59:59.999Z`). The app stores a picked date as the
101
+ * viewer's local midnight converted to UTC, so match that shown day with an
102
+ * ISO-8601 instant (`T` and `Z` or `±HH:MM`). A start after the end is 400.
103
+ *
104
+ * One field accepts one operator kind. A mix of select, `text`, `textPrefix`,
105
+ * `textNot`, and date bounds on that field is 400. `boards.list` accepts
106
+ * select strings only. `semantic: true` rejects `customField`.
107
+ */
108
+ customField?: AssetCustomFieldFilter | AssetCustomFieldFilter[];
64
109
  search?: string;
65
110
  /**
66
111
  * When true, `search` is used for semantic search via AI embeddings.
@@ -136,6 +181,11 @@ interface Board {
136
181
  interface BoardListParams extends CursorPageParams {
137
182
  name?: string;
138
183
  parentBoardId?: string;
184
+ /**
185
+ * Select filters only, as `fieldId:valueId`. Repeats of one field are OR, and
186
+ * different fields are AND. Plain-text and date operators are rejected with
187
+ * 400; use `assets.list` for those.
188
+ */
139
189
  customField?: string | string[];
140
190
  /**
141
191
  * Only return boards in this library. Mutually exclusive with
@@ -188,9 +238,15 @@ interface GuestListResponse {
188
238
  data: Guest[];
189
239
  }
190
240
 
191
- /** Visitor comment access on a share link. */
241
+ /**
242
+ * Visitor comment access on a share link.
243
+ * `allowed` lets anyone with the link post comments.
244
+ */
192
245
  type ShareLinkCommentsAccess = "hidden" | "read_only" | "allowed";
193
- /** Visitor custom field access on a share link. */
246
+ /**
247
+ * Visitor custom field access on a share link.
248
+ * `editable` lets anyone with the link change custom field values.
249
+ */
194
250
  type ShareLinkCustomFieldsAccess = "hidden" | "read_only" | "editable";
195
251
  /**
196
252
  * Public share link fields shared by assets and boards.
@@ -242,10 +298,31 @@ interface BoardShareLinkListResponse extends CursorPageResponse<BoardShareLink>
242
298
  * Settings accepted on share-link create and update.
243
299
  * Omitted fields follow the workspace Share Link Defaults on create,
244
300
  * and stay unchanged on update.
301
+ *
302
+ * `password` is write only; reads return `hasPassword`. `null` clears
303
+ * `password` and `expiresAt`. An empty password is rejected. `expiresAt`
304
+ * must be an ISO 8601 date-time in the future.
305
+ *
306
+ * Turning `password`, `expiresAt`, `requireAccount`, `comments`, or
307
+ * `customFields` on needs the workspace `shareLinks` add-on. Otherwise the
308
+ * API returns 422 `ADDON_DISABLED` and applies nothing in the request.
309
+ * Raising `comments` from `read_only` to `allowed`, or `customFields` from
310
+ * `read_only` to `editable`, counts as turning it on, so a link that already
311
+ * shows comments or custom fields can still get that 422.
312
+ * `extra.settings` names the rejected settings, and uses `expiration` for
313
+ * `expiresAt`. Re-sending a value the link already has, changing an existing
314
+ * password or expiration, and turning a setting off are accepted.
245
315
  */
246
316
  interface ShareLinkWriteSettings {
247
317
  active?: boolean;
248
318
  allowDownload?: boolean;
319
+ /** Write only. `null` removes the password. */
320
+ password?: string | null;
321
+ /** ISO 8601 date-time in the future. `null` removes the expiration. */
322
+ expiresAt?: string | null;
323
+ requireAccount?: boolean;
324
+ comments?: ShareLinkCommentsAccess;
325
+ customFields?: ShareLinkCustomFieldsAccess;
249
326
  }
250
327
  /** Asset links also accept `showAllVersions`. */
251
328
  interface AssetShareLinkWriteSettings extends ShareLinkWriteSettings {
@@ -601,4 +678,4 @@ declare class AirApi extends AirBase {
601
678
  constructor(options?: AirApiOptions);
602
679
  }
603
680
 
604
- export { type AddBoardAssetsParams, type AddGuestParams, type AddVersionTagParams, AirApi, type AirApiOptions, type Asset, type AssetBoardListParams, type AssetCdnLinkCreateParams, type AssetCdnLinkListResponse, type AssetCdnLinkUpdateParams, type AssetCustomFieldValue, type AssetListParams, type AssetShareLink, type AssetShareLinkCreateParams, type AssetShareLinkListParams, type AssetShareLinkUpdateParams, type AssetShareLinkWriteSettings, type AssetVersion, type AssetVersionDownloadUrl, type AssetVersionListResponse, type AssetVersionUpdateParams, type AssetVersionUrls, Assets, type Board, type BoardCreateParams, type BoardListParams, type BoardShareLink, type BoardShareLinkCreateParams, type BoardShareLinkListResponse, type BoardShareLinkUpdateParams, type BoardUpdateParams, Boards, type CdnLink, type CompleteMultipartParams, type CustomField, type CustomFieldCreateParams, type CustomFieldListParams, type CustomFieldType, type CustomFieldUpdateParams, type CustomFieldValue, type CustomFieldValueCreateParams, type CustomFieldValueUpdateParams, CustomFields, type FileMeta, type FileSource, type GetPartUploadUrlParams, type GetPartUploadUrlResponse, type Guest, type GuestListParams, type GuestListResponse, type ImportCreateParams, type ImportCreateResponse, type ImportStatus, type ImportStatusResponse, Imports, type LargeUploadResponse, Libraries, type Library, type LibraryCreateParams, type LibraryListParams, type LibraryUpdateParams, type Role, type RoleListParams, type RoleListResponse, Roles, type SetBoardCustomFieldParams, type SetCustomFieldParams, type ShareLink, type ShareLinkCommentsAccess, type ShareLinkCustomFieldsAccess, type ShareLinkWriteSettings, type SmallUploadResponse, type SmartTag, type Tag, type TagCreateParams, type TagListParams, type TagUpdateParams, Tags, type UpdateGuestParams, type UploadCreateParams, type UploadCreateResponse, type UploadFileOptions, type UploadFileParams, type UploadFileResponse, Uploads, type Workspace, type WorkspaceListResponse, Workspaces };
681
+ export { type AddBoardAssetsParams, type AddGuestParams, type AddVersionTagParams, AirApi, type AirApiOptions, type Asset, type AssetBoardListParams, type AssetCdnLinkCreateParams, type AssetCdnLinkListResponse, type AssetCdnLinkUpdateParams, type AssetCustomFieldDateFilter, type AssetCustomFieldDateOperator, type AssetCustomFieldFilter, type AssetCustomFieldSelectFilter, type AssetCustomFieldTextFilter, type AssetCustomFieldTextOperator, type AssetCustomFieldValue, type AssetListParams, type AssetShareLink, type AssetShareLinkCreateParams, type AssetShareLinkListParams, type AssetShareLinkUpdateParams, type AssetShareLinkWriteSettings, type AssetVersion, type AssetVersionDownloadUrl, type AssetVersionListResponse, type AssetVersionUpdateParams, type AssetVersionUrls, Assets, type Board, type BoardCreateParams, type BoardListParams, type BoardShareLink, type BoardShareLinkCreateParams, type BoardShareLinkListResponse, type BoardShareLinkUpdateParams, type BoardUpdateParams, Boards, type CdnLink, type CompleteMultipartParams, type CustomField, type CustomFieldCreateParams, type CustomFieldListParams, type CustomFieldType, type CustomFieldUpdateParams, type CustomFieldValue, type CustomFieldValueCreateParams, type CustomFieldValueUpdateParams, CustomFields, type FileMeta, type FileSource, type GetPartUploadUrlParams, type GetPartUploadUrlResponse, type Guest, type GuestListParams, type GuestListResponse, type ImportCreateParams, type ImportCreateResponse, type ImportStatus, type ImportStatusResponse, Imports, type LargeUploadResponse, Libraries, type Library, type LibraryCreateParams, type LibraryListParams, type LibraryUpdateParams, type Role, type RoleListParams, type RoleListResponse, Roles, type SetBoardCustomFieldParams, type SetCustomFieldParams, type ShareLink, type ShareLinkCommentsAccess, type ShareLinkCustomFieldsAccess, type ShareLinkWriteSettings, type SmallUploadResponse, type SmartTag, type Tag, type TagCreateParams, type TagListParams, type TagUpdateParams, Tags, type UpdateGuestParams, type UploadCreateParams, type UploadCreateResponse, type UploadFileOptions, type UploadFileParams, type UploadFileResponse, Uploads, type Workspace, type WorkspaceListResponse, Workspaces };
package/dist/index.js CHANGED
@@ -1,6 +1,33 @@
1
1
  // src/api.ts
2
2
  import { AirBase } from "@air/api-core";
3
3
 
4
+ // src/resources/serialize-asset-custom-field-filter.ts
5
+ var INVALID_ASSET_CUSTOM_FIELD_FILTER = "Asset custom field filter must be a select { id, valueId } or an operator { id, operator, value }";
6
+ var readOwn = (filter, key) => Object.hasOwn(filter, key) ? filter[key] : void 0;
7
+ var isSelectFilter = (filter) => {
8
+ const valueId = readOwn(filter, "valueId");
9
+ const operator = readOwn(filter, "operator");
10
+ return typeof filter.id === "string" && typeof valueId === "string" && operator === void 0;
11
+ };
12
+ var isOperatorFilter = (filter) => {
13
+ const valueId = readOwn(filter, "valueId");
14
+ const operator = readOwn(filter, "operator");
15
+ const value = readOwn(filter, "value");
16
+ return typeof filter.id === "string" && valueId === void 0 && typeof operator === "string" && typeof value === "string";
17
+ };
18
+ var serializeAssetCustomFieldFilter = (filter) => {
19
+ if (typeof filter === "string") {
20
+ return filter;
21
+ }
22
+ if (isSelectFilter(filter)) {
23
+ return `${filter.id}:${filter.valueId}`;
24
+ }
25
+ if (isOperatorFilter(filter)) {
26
+ return `${filter.id}:${filter.operator}:${filter.value}`;
27
+ }
28
+ throw new Error(INVALID_ASSET_CUSTOM_FIELD_FILTER);
29
+ };
30
+
4
31
  // src/resources/assets.ts
5
32
  var Assets = class {
6
33
  constructor(client) {
@@ -23,7 +50,7 @@ var Assets = class {
23
50
  query.tag = params.tag;
24
51
  }
25
52
  if (params.customField) {
26
- query.customField = params.customField;
53
+ query.customField = Array.isArray(params.customField) ? params.customField.map(serializeAssetCustomFieldFilter) : serializeAssetCustomFieldFilter(params.customField);
27
54
  }
28
55
  if (params["createdAt[gte]"]) {
29
56
  query["createdAt[gte]"] = params["createdAt[gte]"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@air/api-rest",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "Typed REST client for Air API",
6
6
  "main": "./dist/index.cjs",
@@ -29,7 +29,7 @@
29
29
  "clean": "rm -rf dist .tsc-out tsconfig.tsbuildinfo"
30
30
  },
31
31
  "dependencies": {
32
- "@air/api-core": "0.7.0"
32
+ "@air/api-core": "0.9.0"
33
33
  },
34
34
  "engines": {
35
35
  "node": ">=18"