@air/api-rest 0.7.0 → 0.8.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
@@ -601,4 +651,4 @@ declare class AirApi extends AirBase {
601
651
  constructor(options?: AirApiOptions);
602
652
  }
603
653
 
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 };
654
+ 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
@@ -601,4 +651,4 @@ declare class AirApi extends AirBase {
601
651
  constructor(options?: AirApiOptions);
602
652
  }
603
653
 
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 };
654
+ 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.8.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.8.0"
33
33
  },
34
34
  "engines": {
35
35
  "node": ">=18"