@air/api-rest 0.6.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/README.md +1 -1
- package/dist/index.cjs +56 -1
- package/dist/index.d.cts +86 -2
- package/dist/index.d.ts +86 -2
- package/dist/index.js +56 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npm install @air/api-rest
|
|
|
22
22
|
|
|
23
23
|
- Resource classes: `BoardsResource`, `AssetsResource`, `TagsResource`, `CustomFieldsResource`, `UploadsResource`, `ImportsResource`, `RolesResource`
|
|
24
24
|
- Asset CDN link helpers: `listCdnLinks`, `createCdnLink`, and `updateCdnLink`
|
|
25
|
-
- Share
|
|
25
|
+
- Share links: `listShareLinks`, `createShareLink`, and `updateShareLink` on assets and boards
|
|
26
26
|
- Full TypeScript types for all API request/response shapes
|
|
27
27
|
- `AirApi` client class that composes all resources
|
|
28
28
|
|
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]"];
|
|
@@ -181,6 +208,20 @@ var Assets = class {
|
|
|
181
208
|
query
|
|
182
209
|
);
|
|
183
210
|
}
|
|
211
|
+
async createShareLink(assetId, params) {
|
|
212
|
+
return this.client.request({
|
|
213
|
+
method: "POST",
|
|
214
|
+
path: `/assets/${assetId}/share-links`,
|
|
215
|
+
body: params
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async updateShareLink(assetId, shareLinkId, params) {
|
|
219
|
+
return this.client.request({
|
|
220
|
+
method: "PATCH",
|
|
221
|
+
path: `/assets/${assetId}/share-links/${shareLinkId}`,
|
|
222
|
+
body: params
|
|
223
|
+
});
|
|
224
|
+
}
|
|
184
225
|
listBoards(assetId, params = {}) {
|
|
185
226
|
const query = {
|
|
186
227
|
limit: params.limit,
|
|
@@ -267,6 +308,20 @@ var Boards = class {
|
|
|
267
308
|
path: `/boards/${boardId}/share-links`
|
|
268
309
|
});
|
|
269
310
|
}
|
|
311
|
+
async createShareLink(boardId, params = {}) {
|
|
312
|
+
return this.client.request({
|
|
313
|
+
method: "POST",
|
|
314
|
+
path: `/boards/${boardId}/share-links`,
|
|
315
|
+
body: params
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async updateShareLink(boardId, shareLinkId, params) {
|
|
319
|
+
return this.client.request({
|
|
320
|
+
method: "PATCH",
|
|
321
|
+
path: `/boards/${boardId}/share-links/${shareLinkId}`,
|
|
322
|
+
body: params
|
|
323
|
+
});
|
|
324
|
+
}
|
|
270
325
|
async addGuest(boardId, params) {
|
|
271
326
|
return this.client.request({
|
|
272
327
|
method: "POST",
|
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
|
-
|
|
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
|
|
@@ -238,6 +288,36 @@ type AssetShareLinkListParams = CursorPageParams;
|
|
|
238
288
|
interface BoardShareLinkListResponse extends CursorPageResponse<BoardShareLink> {
|
|
239
289
|
total: number;
|
|
240
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Settings accepted on share-link create and update.
|
|
293
|
+
* Omitted fields follow the workspace Share Link Defaults on create,
|
|
294
|
+
* and stay unchanged on update.
|
|
295
|
+
*/
|
|
296
|
+
interface ShareLinkWriteSettings {
|
|
297
|
+
active?: boolean;
|
|
298
|
+
allowDownload?: boolean;
|
|
299
|
+
}
|
|
300
|
+
/** Asset links also accept `showAllVersions`. */
|
|
301
|
+
interface AssetShareLinkWriteSettings extends ShareLinkWriteSettings {
|
|
302
|
+
showAllVersions?: boolean;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Body for `POST /assets/:assetId/share-links`.
|
|
306
|
+
* Exactly one of `followsDefaultVersion: true` or `versionId`.
|
|
307
|
+
*/
|
|
308
|
+
type AssetShareLinkCreateParams = AssetShareLinkWriteSettings & ({
|
|
309
|
+
followsDefaultVersion: true;
|
|
310
|
+
versionId?: never;
|
|
311
|
+
} | {
|
|
312
|
+
versionId: string;
|
|
313
|
+
followsDefaultVersion?: never;
|
|
314
|
+
});
|
|
315
|
+
/** Body for `PATCH /assets/:assetId/share-links/:shareLinkId`. */
|
|
316
|
+
type AssetShareLinkUpdateParams = AssetShareLinkWriteSettings;
|
|
317
|
+
/** Body for `POST /boards/:boardId/share-links`. */
|
|
318
|
+
type BoardShareLinkCreateParams = ShareLinkWriteSettings;
|
|
319
|
+
/** Body for `PATCH /boards/:boardId/share-links/:shareLinkId`. */
|
|
320
|
+
type BoardShareLinkUpdateParams = ShareLinkWriteSettings;
|
|
241
321
|
|
|
242
322
|
declare class Assets {
|
|
243
323
|
private client;
|
|
@@ -256,6 +336,8 @@ declare class Assets {
|
|
|
256
336
|
addVersionTag(assetId: string, versionId: string, params: AddVersionTagParams): Promise<AssetVersion>;
|
|
257
337
|
removeVersionTag(assetId: string, versionId: string, tagId: string): Promise<void>;
|
|
258
338
|
listShareLinks(assetId: string, params?: AssetShareLinkListParams): PagePromise<AssetShareLink>;
|
|
339
|
+
createShareLink(assetId: string, params: AssetShareLinkCreateParams): Promise<AssetShareLink>;
|
|
340
|
+
updateShareLink(assetId: string, shareLinkId: string, params: AssetShareLinkUpdateParams): Promise<void>;
|
|
259
341
|
listBoards(assetId: string, params?: AssetBoardListParams): PagePromise<Board>;
|
|
260
342
|
}
|
|
261
343
|
|
|
@@ -271,6 +353,8 @@ declare class Boards {
|
|
|
271
353
|
removeAsset(boardId: string, assetId: string): Promise<void>;
|
|
272
354
|
setCustomField(boardId: string, customFieldId: string, params: SetBoardCustomFieldParams): Promise<void>;
|
|
273
355
|
listShareLinks(boardId: string): Promise<BoardShareLinkListResponse>;
|
|
356
|
+
createShareLink(boardId: string, params?: BoardShareLinkCreateParams): Promise<BoardShareLink>;
|
|
357
|
+
updateShareLink(boardId: string, shareLinkId: string, params: BoardShareLinkUpdateParams): Promise<void>;
|
|
274
358
|
addGuest(boardId: string, params: AddGuestParams): Promise<Guest>;
|
|
275
359
|
listGuests(boardId: string, params?: GuestListParams): Promise<Guest[]>;
|
|
276
360
|
updateGuest(boardId: string, guestId: string, params: UpdateGuestParams): Promise<void>;
|
|
@@ -567,4 +651,4 @@ declare class AirApi extends AirBase {
|
|
|
567
651
|
constructor(options?: AirApiOptions);
|
|
568
652
|
}
|
|
569
653
|
|
|
570
|
-
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 AssetShareLinkListParams, type AssetVersion, type AssetVersionDownloadUrl, type AssetVersionListResponse, type AssetVersionUpdateParams, type AssetVersionUrls, Assets, type Board, type BoardCreateParams, type BoardListParams, type BoardShareLink, type BoardShareLinkListResponse, 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 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
|
-
|
|
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
|
|
@@ -238,6 +288,36 @@ type AssetShareLinkListParams = CursorPageParams;
|
|
|
238
288
|
interface BoardShareLinkListResponse extends CursorPageResponse<BoardShareLink> {
|
|
239
289
|
total: number;
|
|
240
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Settings accepted on share-link create and update.
|
|
293
|
+
* Omitted fields follow the workspace Share Link Defaults on create,
|
|
294
|
+
* and stay unchanged on update.
|
|
295
|
+
*/
|
|
296
|
+
interface ShareLinkWriteSettings {
|
|
297
|
+
active?: boolean;
|
|
298
|
+
allowDownload?: boolean;
|
|
299
|
+
}
|
|
300
|
+
/** Asset links also accept `showAllVersions`. */
|
|
301
|
+
interface AssetShareLinkWriteSettings extends ShareLinkWriteSettings {
|
|
302
|
+
showAllVersions?: boolean;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Body for `POST /assets/:assetId/share-links`.
|
|
306
|
+
* Exactly one of `followsDefaultVersion: true` or `versionId`.
|
|
307
|
+
*/
|
|
308
|
+
type AssetShareLinkCreateParams = AssetShareLinkWriteSettings & ({
|
|
309
|
+
followsDefaultVersion: true;
|
|
310
|
+
versionId?: never;
|
|
311
|
+
} | {
|
|
312
|
+
versionId: string;
|
|
313
|
+
followsDefaultVersion?: never;
|
|
314
|
+
});
|
|
315
|
+
/** Body for `PATCH /assets/:assetId/share-links/:shareLinkId`. */
|
|
316
|
+
type AssetShareLinkUpdateParams = AssetShareLinkWriteSettings;
|
|
317
|
+
/** Body for `POST /boards/:boardId/share-links`. */
|
|
318
|
+
type BoardShareLinkCreateParams = ShareLinkWriteSettings;
|
|
319
|
+
/** Body for `PATCH /boards/:boardId/share-links/:shareLinkId`. */
|
|
320
|
+
type BoardShareLinkUpdateParams = ShareLinkWriteSettings;
|
|
241
321
|
|
|
242
322
|
declare class Assets {
|
|
243
323
|
private client;
|
|
@@ -256,6 +336,8 @@ declare class Assets {
|
|
|
256
336
|
addVersionTag(assetId: string, versionId: string, params: AddVersionTagParams): Promise<AssetVersion>;
|
|
257
337
|
removeVersionTag(assetId: string, versionId: string, tagId: string): Promise<void>;
|
|
258
338
|
listShareLinks(assetId: string, params?: AssetShareLinkListParams): PagePromise<AssetShareLink>;
|
|
339
|
+
createShareLink(assetId: string, params: AssetShareLinkCreateParams): Promise<AssetShareLink>;
|
|
340
|
+
updateShareLink(assetId: string, shareLinkId: string, params: AssetShareLinkUpdateParams): Promise<void>;
|
|
259
341
|
listBoards(assetId: string, params?: AssetBoardListParams): PagePromise<Board>;
|
|
260
342
|
}
|
|
261
343
|
|
|
@@ -271,6 +353,8 @@ declare class Boards {
|
|
|
271
353
|
removeAsset(boardId: string, assetId: string): Promise<void>;
|
|
272
354
|
setCustomField(boardId: string, customFieldId: string, params: SetBoardCustomFieldParams): Promise<void>;
|
|
273
355
|
listShareLinks(boardId: string): Promise<BoardShareLinkListResponse>;
|
|
356
|
+
createShareLink(boardId: string, params?: BoardShareLinkCreateParams): Promise<BoardShareLink>;
|
|
357
|
+
updateShareLink(boardId: string, shareLinkId: string, params: BoardShareLinkUpdateParams): Promise<void>;
|
|
274
358
|
addGuest(boardId: string, params: AddGuestParams): Promise<Guest>;
|
|
275
359
|
listGuests(boardId: string, params?: GuestListParams): Promise<Guest[]>;
|
|
276
360
|
updateGuest(boardId: string, guestId: string, params: UpdateGuestParams): Promise<void>;
|
|
@@ -567,4 +651,4 @@ declare class AirApi extends AirBase {
|
|
|
567
651
|
constructor(options?: AirApiOptions);
|
|
568
652
|
}
|
|
569
653
|
|
|
570
|
-
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 AssetShareLinkListParams, type AssetVersion, type AssetVersionDownloadUrl, type AssetVersionListResponse, type AssetVersionUpdateParams, type AssetVersionUrls, Assets, type Board, type BoardCreateParams, type BoardListParams, type BoardShareLink, type BoardShareLinkListResponse, 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 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]"];
|
|
@@ -120,6 +147,20 @@ var Assets = class {
|
|
|
120
147
|
query
|
|
121
148
|
);
|
|
122
149
|
}
|
|
150
|
+
async createShareLink(assetId, params) {
|
|
151
|
+
return this.client.request({
|
|
152
|
+
method: "POST",
|
|
153
|
+
path: `/assets/${assetId}/share-links`,
|
|
154
|
+
body: params
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async updateShareLink(assetId, shareLinkId, params) {
|
|
158
|
+
return this.client.request({
|
|
159
|
+
method: "PATCH",
|
|
160
|
+
path: `/assets/${assetId}/share-links/${shareLinkId}`,
|
|
161
|
+
body: params
|
|
162
|
+
});
|
|
163
|
+
}
|
|
123
164
|
listBoards(assetId, params = {}) {
|
|
124
165
|
const query = {
|
|
125
166
|
limit: params.limit,
|
|
@@ -206,6 +247,20 @@ var Boards = class {
|
|
|
206
247
|
path: `/boards/${boardId}/share-links`
|
|
207
248
|
});
|
|
208
249
|
}
|
|
250
|
+
async createShareLink(boardId, params = {}) {
|
|
251
|
+
return this.client.request({
|
|
252
|
+
method: "POST",
|
|
253
|
+
path: `/boards/${boardId}/share-links`,
|
|
254
|
+
body: params
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async updateShareLink(boardId, shareLinkId, params) {
|
|
258
|
+
return this.client.request({
|
|
259
|
+
method: "PATCH",
|
|
260
|
+
path: `/boards/${boardId}/share-links/${shareLinkId}`,
|
|
261
|
+
body: params
|
|
262
|
+
});
|
|
263
|
+
}
|
|
209
264
|
async addGuest(boardId, params) {
|
|
210
265
|
return this.client.request({
|
|
211
266
|
method: "POST",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@air/api-rest",
|
|
3
|
-
"version": "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.
|
|
32
|
+
"@air/api-core": "0.8.0"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=18"
|