@uniformdev/assets 20.50.2-alpha.1 → 20.50.2-alpha.109

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.d.mts CHANGED
@@ -904,6 +904,8 @@ interface components$1 {
904
904
  };
905
905
  /** @enum {string} */
906
906
  ReleaseState: "open" | "locked" | "queued" | "launching" | "launched" | "deleting";
907
+ /** @enum {string} */
908
+ ReleaseScheduleState: "scheduled" | "unscheduled";
907
909
  ProjectMapNodeAllowedQueryString: {
908
910
  /** @description The name of the query string parameter */
909
911
  name: string;
@@ -967,13 +969,27 @@ interface paths {
967
969
  * This is a list query parameter, and cannot be used with any primary query parameters
968
970
  * */
969
971
  keyword?: components["parameters"]["keyword"];
972
+ /**
973
+ * @deprecated
974
+ * @description BETA: Semantic search using vector similarity to find assets by meaning.
975
+ * Use this for "images of mountains" style queries.
976
+ * Requires AI credits.
977
+ *
978
+ */
979
+ searchSemantic?: components["parameters"]["searchSemantic"];
970
980
  /** @description Max number of records to return */
971
981
  limit?: components["parameters"]["limit"];
972
982
  /** @description Number of records to skip */
973
983
  offset?: components["parameters"]["offset"];
974
- /** @description Sets the sorting of the results. If unspecified, results are sorted by name ascending
984
+ /** @description Sets the sorting of the results. If unspecified, results are sorted by creation date ascending.
985
+ * Allowed values are: updated_at_DESC, updated_at_ASC, created_at_DESC, created_at_ASC, name_DESC, name_ASC, slug_DESC, slug_ASC, relevance_DESC (when searching).
975
986
  * */
976
987
  orderBy?: components["parameters"]["orderBy"];
988
+ /**
989
+ * @deprecated
990
+ * @description Returns counts for distinct values of the specified field or fields (provided as comma-separated IDs).
991
+ */
992
+ facetBy?: components["parameters"]["facetBy"];
977
993
  /** @description The project the asset/assets are on */
978
994
  projectId: components["parameters"]["projectId"];
979
995
  /** @description The asset type ID to filter by */
@@ -993,6 +1009,18 @@ interface paths {
993
1009
  * Content copied to a release can be differentiated from base content by the `releaseId` property on the content. If the content is not copied to the release, this property will be undefined
994
1010
  * */
995
1011
  releaseId?: components["parameters"]["releaseId"];
1012
+ /** @description When true, includes full label entities in the response for UI rendering.
1013
+ * The assignedLabels array includes the label and its parent group (if any).
1014
+ * This parameter is not supported with uniform.global.
1015
+ * */
1016
+ withAssignedLabels?: components["parameters"]["withAssignedLabels"];
1017
+ /**
1018
+ * @deprecated
1019
+ * @description Returns additional author and creator metadata for the asset.
1020
+ * This internal status is subject to change without notice and is thus marked deprecated to discourage use of internal data
1021
+ *
1022
+ */
1023
+ withUIStatus?: components["parameters"]["withUIStatus"];
996
1024
  };
997
1025
  header?: never;
998
1026
  path?: never;
@@ -1155,6 +1183,12 @@ interface components {
1155
1183
  _name: string;
1156
1184
  /** @description Name of the author of the most recent change */
1157
1185
  _author?: string;
1186
+ /** @description Identity subject of the author of the most recent change */
1187
+ _authorSubject?: string;
1188
+ /** @description Name of the original creator */
1189
+ _creator?: string;
1190
+ /** @description Identity subject of the original creator */
1191
+ _creatorSubject?: string;
1158
1192
  fields?: {
1159
1193
  title?: {
1160
1194
  value: string;
@@ -1211,6 +1245,8 @@ interface components {
1211
1245
  };
1212
1246
  };
1213
1247
  _dataResources?: components["schemas"]["DataResourceDefinitions"];
1248
+ /** @description Array of label public IDs assigned to this asset (max 30) */
1249
+ labels?: string[];
1214
1250
  };
1215
1251
  /** @description Defines the shape of the asset input */
1216
1252
  AssetInput: {
@@ -1250,6 +1286,8 @@ interface components {
1250
1286
  };
1251
1287
  };
1252
1288
  _dataResources?: components["schemas"]["DataResourceDefinitions"];
1289
+ /** @description Array of label public IDs assigned to this asset (max 30) */
1290
+ labels?: string[];
1253
1291
  };
1254
1292
  AssetApiResponse: {
1255
1293
  /**
@@ -1273,11 +1311,46 @@ interface components {
1273
1311
  */
1274
1312
  releaseId?: string;
1275
1313
  asset: components["schemas"]["Asset"];
1314
+ /** @description Full label entities for UI rendering (only present when withAssignedLabels=true). Read-only. */
1315
+ assignedLabels?: {
1316
+ [key: string]: {
1317
+ /** Format: uuid */
1318
+ projectId: string;
1319
+ label: {
1320
+ /** @description Public ID of the label (cannot be changed after creation) */
1321
+ publicId: string;
1322
+ /** @description Human readable name of the label */
1323
+ displayName: string;
1324
+ /** @description Whether this label is a group label (cannot be changed after creation) */
1325
+ isGroup: boolean;
1326
+ /** @description Public ID of the parent group label */
1327
+ parent?: string;
1328
+ /** @description Human readable color identifier */
1329
+ color: string;
1330
+ /** @description Short description of what the label is about */
1331
+ description?: string;
1332
+ /** @description Scope of the label (currently unused) */
1333
+ scope: string[];
1334
+ };
1335
+ /** Format: date-time */
1336
+ created: string;
1337
+ /** Format: date-time */
1338
+ modified: string;
1339
+ createdBy?: string;
1340
+ modifiedBy?: string;
1341
+ };
1342
+ };
1276
1343
  };
1277
1344
  AssetListResponse: {
1278
1345
  assets: components["schemas"]["AssetApiResponse"][];
1279
1346
  /** @description Total number of assets that match the query. Only present when `withTotalCount` option is true */
1280
1347
  totalCount?: number;
1348
+ /** @description Per-field counts for distinct values */
1349
+ facets?: {
1350
+ [key: string]: {
1351
+ [key: string]: number;
1352
+ };
1353
+ };
1281
1354
  };
1282
1355
  /** @description Defines a connection to a dynamic token on a data resource
1283
1356
  * */
@@ -1482,9 +1555,23 @@ interface components {
1482
1555
  * This is a list query parameter, and cannot be used with any primary query parameters
1483
1556
  * */
1484
1557
  keyword: string;
1485
- /** @description Sets the sorting of the results. If unspecified, results are sorted by name ascending
1558
+ /**
1559
+ * @deprecated
1560
+ * @description BETA: Semantic search using vector similarity to find assets by meaning.
1561
+ * Use this for "images of mountains" style queries.
1562
+ * Requires AI credits.
1563
+ *
1564
+ */
1565
+ searchSemantic: string;
1566
+ /** @description Sets the sorting of the results. If unspecified, results are sorted by creation date ascending.
1567
+ * Allowed values are: updated_at_DESC, updated_at_ASC, created_at_DESC, created_at_ASC, name_DESC, name_ASC, slug_DESC, slug_ASC, relevance_DESC (when searching).
1486
1568
  * */
1487
- orderBy: ("updated_at_DESC" | "updated_at_ASC" | "created_at_DESC" | "created_at_ASC" | "name_DESC" | "name_ASC")[];
1569
+ orderBy: string[];
1570
+ /**
1571
+ * @deprecated
1572
+ * @description Returns counts for distinct values of the specified field or fields (provided as comma-separated IDs).
1573
+ */
1574
+ facetBy: string;
1488
1575
  /** @description Filters asset lists by the user who created them. The user is specified by their identity subject
1489
1576
  * */
1490
1577
  createdBy: string;
@@ -1503,6 +1590,18 @@ interface components {
1503
1590
  * Content copied to a release can be differentiated from base content by the `releaseId` property on the content. If the content is not copied to the release, this property will be undefined
1504
1591
  * */
1505
1592
  releaseId: string;
1593
+ /** @description When true, includes full label entities in the response for UI rendering.
1594
+ * The assignedLabels array includes the label and its parent group (if any).
1595
+ * This parameter is not supported with uniform.global.
1596
+ * */
1597
+ withAssignedLabels: boolean;
1598
+ /**
1599
+ * @deprecated
1600
+ * @description Returns additional author and creator metadata for the asset.
1601
+ * This internal status is subject to change without notice and is thus marked deprecated to discourage use of internal data
1602
+ *
1603
+ */
1604
+ withUIStatus: boolean;
1506
1605
  };
1507
1606
  requestBodies: never;
1508
1607
  headers: never;
@@ -1601,8 +1700,12 @@ declare class AssetClient extends ApiClient {
1601
1700
  constructor(options: ClientOptions & {
1602
1701
  projectId: NonNullable<ClientOptions['projectId']>;
1603
1702
  });
1604
- get(options: WithoutProjectId<AssetGetRequestSingle>): Promise<AssetGetResponseSingle>;
1605
- get(options: WithoutProjectId<AssetGetRequestList>): Promise<AssetGetResponseList>;
1703
+ get(options: WithoutProjectId<AssetGetRequestSingle> & {
1704
+ filters?: never;
1705
+ }): Promise<AssetGetResponseSingle>;
1706
+ get(options: WithoutProjectId<AssetGetRequestList> & {
1707
+ filters?: Record<string, unknown>;
1708
+ }): Promise<AssetGetResponseList>;
1606
1709
  upsert(options: WithoutProjectId<AssetUpsertRequest>): Promise<void>;
1607
1710
  delete(options: WithoutProjectId<AssetDeleteRequest>): Promise<void>;
1608
1711
  }
@@ -1619,6 +1722,7 @@ type AssetDefinition = {
1619
1722
  namePlural: string;
1620
1723
  };
1621
1724
  declare const assetDefinitions: Record<AssetDefinitionType, AssetDefinition>;
1725
+ declare const getAssetDefinitionType: (mimeType: string) => AssetDefinitionType;
1622
1726
 
1623
1727
  /**
1624
1728
  * A union type of possible query parameters for the image delivery API.
@@ -1676,6 +1780,9 @@ declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => {
1676
1780
  * Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
1677
1781
  * Removes things like author, stats, etc.
1678
1782
  */
1679
- declare function convertAssetToPutAsset(asset: AssetGetResponseSingle): AssetUpsertRequest;
1783
+ declare function convertAssetToPutAsset(asset: {
1784
+ asset: Pick<AssetGetResponseSingle['asset'], '_id' | '_dataResources' | '_name' | 'type' | 'labels' | 'fields'>;
1785
+ projectId: string;
1786
+ }): AssetUpsertRequest;
1680
1787
 
1681
- export { type Asset, AssetClient, type AssetDefinitionType, type AssetDeleteRequest, type AssetGetRequest, type AssetGetRequestList, type AssetGetRequestSingle, type AssetGetResponse, type AssetGetResponseList, type AssetGetResponseSingle, type AssetParamValue, type AssetParamValueItem, type AssetUpsertRequest, type ImageDeliveryParams, type ImageFromTransformProps, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset, imageFrom };
1788
+ export { type Asset, AssetClient, type AssetDefinitionType, type AssetDeleteRequest, type AssetGetRequest, type AssetGetRequestList, type AssetGetRequestSingle, type AssetGetResponse, type AssetGetResponseList, type AssetGetResponseSingle, type AssetParamValue, type AssetParamValueItem, type AssetUpsertRequest, type ImageDeliveryParams, type ImageFromTransformProps, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset, getAssetDefinitionType, imageFrom };
package/dist/index.d.ts CHANGED
@@ -904,6 +904,8 @@ interface components$1 {
904
904
  };
905
905
  /** @enum {string} */
906
906
  ReleaseState: "open" | "locked" | "queued" | "launching" | "launched" | "deleting";
907
+ /** @enum {string} */
908
+ ReleaseScheduleState: "scheduled" | "unscheduled";
907
909
  ProjectMapNodeAllowedQueryString: {
908
910
  /** @description The name of the query string parameter */
909
911
  name: string;
@@ -967,13 +969,27 @@ interface paths {
967
969
  * This is a list query parameter, and cannot be used with any primary query parameters
968
970
  * */
969
971
  keyword?: components["parameters"]["keyword"];
972
+ /**
973
+ * @deprecated
974
+ * @description BETA: Semantic search using vector similarity to find assets by meaning.
975
+ * Use this for "images of mountains" style queries.
976
+ * Requires AI credits.
977
+ *
978
+ */
979
+ searchSemantic?: components["parameters"]["searchSemantic"];
970
980
  /** @description Max number of records to return */
971
981
  limit?: components["parameters"]["limit"];
972
982
  /** @description Number of records to skip */
973
983
  offset?: components["parameters"]["offset"];
974
- /** @description Sets the sorting of the results. If unspecified, results are sorted by name ascending
984
+ /** @description Sets the sorting of the results. If unspecified, results are sorted by creation date ascending.
985
+ * Allowed values are: updated_at_DESC, updated_at_ASC, created_at_DESC, created_at_ASC, name_DESC, name_ASC, slug_DESC, slug_ASC, relevance_DESC (when searching).
975
986
  * */
976
987
  orderBy?: components["parameters"]["orderBy"];
988
+ /**
989
+ * @deprecated
990
+ * @description Returns counts for distinct values of the specified field or fields (provided as comma-separated IDs).
991
+ */
992
+ facetBy?: components["parameters"]["facetBy"];
977
993
  /** @description The project the asset/assets are on */
978
994
  projectId: components["parameters"]["projectId"];
979
995
  /** @description The asset type ID to filter by */
@@ -993,6 +1009,18 @@ interface paths {
993
1009
  * Content copied to a release can be differentiated from base content by the `releaseId` property on the content. If the content is not copied to the release, this property will be undefined
994
1010
  * */
995
1011
  releaseId?: components["parameters"]["releaseId"];
1012
+ /** @description When true, includes full label entities in the response for UI rendering.
1013
+ * The assignedLabels array includes the label and its parent group (if any).
1014
+ * This parameter is not supported with uniform.global.
1015
+ * */
1016
+ withAssignedLabels?: components["parameters"]["withAssignedLabels"];
1017
+ /**
1018
+ * @deprecated
1019
+ * @description Returns additional author and creator metadata for the asset.
1020
+ * This internal status is subject to change without notice and is thus marked deprecated to discourage use of internal data
1021
+ *
1022
+ */
1023
+ withUIStatus?: components["parameters"]["withUIStatus"];
996
1024
  };
997
1025
  header?: never;
998
1026
  path?: never;
@@ -1155,6 +1183,12 @@ interface components {
1155
1183
  _name: string;
1156
1184
  /** @description Name of the author of the most recent change */
1157
1185
  _author?: string;
1186
+ /** @description Identity subject of the author of the most recent change */
1187
+ _authorSubject?: string;
1188
+ /** @description Name of the original creator */
1189
+ _creator?: string;
1190
+ /** @description Identity subject of the original creator */
1191
+ _creatorSubject?: string;
1158
1192
  fields?: {
1159
1193
  title?: {
1160
1194
  value: string;
@@ -1211,6 +1245,8 @@ interface components {
1211
1245
  };
1212
1246
  };
1213
1247
  _dataResources?: components["schemas"]["DataResourceDefinitions"];
1248
+ /** @description Array of label public IDs assigned to this asset (max 30) */
1249
+ labels?: string[];
1214
1250
  };
1215
1251
  /** @description Defines the shape of the asset input */
1216
1252
  AssetInput: {
@@ -1250,6 +1286,8 @@ interface components {
1250
1286
  };
1251
1287
  };
1252
1288
  _dataResources?: components["schemas"]["DataResourceDefinitions"];
1289
+ /** @description Array of label public IDs assigned to this asset (max 30) */
1290
+ labels?: string[];
1253
1291
  };
1254
1292
  AssetApiResponse: {
1255
1293
  /**
@@ -1273,11 +1311,46 @@ interface components {
1273
1311
  */
1274
1312
  releaseId?: string;
1275
1313
  asset: components["schemas"]["Asset"];
1314
+ /** @description Full label entities for UI rendering (only present when withAssignedLabels=true). Read-only. */
1315
+ assignedLabels?: {
1316
+ [key: string]: {
1317
+ /** Format: uuid */
1318
+ projectId: string;
1319
+ label: {
1320
+ /** @description Public ID of the label (cannot be changed after creation) */
1321
+ publicId: string;
1322
+ /** @description Human readable name of the label */
1323
+ displayName: string;
1324
+ /** @description Whether this label is a group label (cannot be changed after creation) */
1325
+ isGroup: boolean;
1326
+ /** @description Public ID of the parent group label */
1327
+ parent?: string;
1328
+ /** @description Human readable color identifier */
1329
+ color: string;
1330
+ /** @description Short description of what the label is about */
1331
+ description?: string;
1332
+ /** @description Scope of the label (currently unused) */
1333
+ scope: string[];
1334
+ };
1335
+ /** Format: date-time */
1336
+ created: string;
1337
+ /** Format: date-time */
1338
+ modified: string;
1339
+ createdBy?: string;
1340
+ modifiedBy?: string;
1341
+ };
1342
+ };
1276
1343
  };
1277
1344
  AssetListResponse: {
1278
1345
  assets: components["schemas"]["AssetApiResponse"][];
1279
1346
  /** @description Total number of assets that match the query. Only present when `withTotalCount` option is true */
1280
1347
  totalCount?: number;
1348
+ /** @description Per-field counts for distinct values */
1349
+ facets?: {
1350
+ [key: string]: {
1351
+ [key: string]: number;
1352
+ };
1353
+ };
1281
1354
  };
1282
1355
  /** @description Defines a connection to a dynamic token on a data resource
1283
1356
  * */
@@ -1482,9 +1555,23 @@ interface components {
1482
1555
  * This is a list query parameter, and cannot be used with any primary query parameters
1483
1556
  * */
1484
1557
  keyword: string;
1485
- /** @description Sets the sorting of the results. If unspecified, results are sorted by name ascending
1558
+ /**
1559
+ * @deprecated
1560
+ * @description BETA: Semantic search using vector similarity to find assets by meaning.
1561
+ * Use this for "images of mountains" style queries.
1562
+ * Requires AI credits.
1563
+ *
1564
+ */
1565
+ searchSemantic: string;
1566
+ /** @description Sets the sorting of the results. If unspecified, results are sorted by creation date ascending.
1567
+ * Allowed values are: updated_at_DESC, updated_at_ASC, created_at_DESC, created_at_ASC, name_DESC, name_ASC, slug_DESC, slug_ASC, relevance_DESC (when searching).
1486
1568
  * */
1487
- orderBy: ("updated_at_DESC" | "updated_at_ASC" | "created_at_DESC" | "created_at_ASC" | "name_DESC" | "name_ASC")[];
1569
+ orderBy: string[];
1570
+ /**
1571
+ * @deprecated
1572
+ * @description Returns counts for distinct values of the specified field or fields (provided as comma-separated IDs).
1573
+ */
1574
+ facetBy: string;
1488
1575
  /** @description Filters asset lists by the user who created them. The user is specified by their identity subject
1489
1576
  * */
1490
1577
  createdBy: string;
@@ -1503,6 +1590,18 @@ interface components {
1503
1590
  * Content copied to a release can be differentiated from base content by the `releaseId` property on the content. If the content is not copied to the release, this property will be undefined
1504
1591
  * */
1505
1592
  releaseId: string;
1593
+ /** @description When true, includes full label entities in the response for UI rendering.
1594
+ * The assignedLabels array includes the label and its parent group (if any).
1595
+ * This parameter is not supported with uniform.global.
1596
+ * */
1597
+ withAssignedLabels: boolean;
1598
+ /**
1599
+ * @deprecated
1600
+ * @description Returns additional author and creator metadata for the asset.
1601
+ * This internal status is subject to change without notice and is thus marked deprecated to discourage use of internal data
1602
+ *
1603
+ */
1604
+ withUIStatus: boolean;
1506
1605
  };
1507
1606
  requestBodies: never;
1508
1607
  headers: never;
@@ -1601,8 +1700,12 @@ declare class AssetClient extends ApiClient {
1601
1700
  constructor(options: ClientOptions & {
1602
1701
  projectId: NonNullable<ClientOptions['projectId']>;
1603
1702
  });
1604
- get(options: WithoutProjectId<AssetGetRequestSingle>): Promise<AssetGetResponseSingle>;
1605
- get(options: WithoutProjectId<AssetGetRequestList>): Promise<AssetGetResponseList>;
1703
+ get(options: WithoutProjectId<AssetGetRequestSingle> & {
1704
+ filters?: never;
1705
+ }): Promise<AssetGetResponseSingle>;
1706
+ get(options: WithoutProjectId<AssetGetRequestList> & {
1707
+ filters?: Record<string, unknown>;
1708
+ }): Promise<AssetGetResponseList>;
1606
1709
  upsert(options: WithoutProjectId<AssetUpsertRequest>): Promise<void>;
1607
1710
  delete(options: WithoutProjectId<AssetDeleteRequest>): Promise<void>;
1608
1711
  }
@@ -1619,6 +1722,7 @@ type AssetDefinition = {
1619
1722
  namePlural: string;
1620
1723
  };
1621
1724
  declare const assetDefinitions: Record<AssetDefinitionType, AssetDefinition>;
1725
+ declare const getAssetDefinitionType: (mimeType: string) => AssetDefinitionType;
1622
1726
 
1623
1727
  /**
1624
1728
  * A union type of possible query parameters for the image delivery API.
@@ -1676,6 +1780,9 @@ declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => {
1676
1780
  * Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
1677
1781
  * Removes things like author, stats, etc.
1678
1782
  */
1679
- declare function convertAssetToPutAsset(asset: AssetGetResponseSingle): AssetUpsertRequest;
1783
+ declare function convertAssetToPutAsset(asset: {
1784
+ asset: Pick<AssetGetResponseSingle['asset'], '_id' | '_dataResources' | '_name' | 'type' | 'labels' | 'fields'>;
1785
+ projectId: string;
1786
+ }): AssetUpsertRequest;
1680
1787
 
1681
- export { type Asset, AssetClient, type AssetDefinitionType, type AssetDeleteRequest, type AssetGetRequest, type AssetGetRequestList, type AssetGetRequestSingle, type AssetGetResponse, type AssetGetResponseList, type AssetGetResponseSingle, type AssetParamValue, type AssetParamValueItem, type AssetUpsertRequest, type ImageDeliveryParams, type ImageFromTransformProps, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset, imageFrom };
1788
+ export { type Asset, AssetClient, type AssetDefinitionType, type AssetDeleteRequest, type AssetGetRequest, type AssetGetRequestList, type AssetGetRequestSingle, type AssetGetResponse, type AssetGetResponseList, type AssetGetResponseSingle, type AssetParamValue, type AssetParamValueItem, type AssetUpsertRequest, type ImageDeliveryParams, type ImageFromTransformProps, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset, getAssetDefinitionType, imageFrom };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/AssetClient.ts
2
- import { ApiClient } from "@uniformdev/context/api";
2
+ import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
3
3
  var ASSET_BASE_PATH = "/api/v1/assets";
4
4
  var AssetClient = class extends ApiClient {
5
5
  constructor(options) {
@@ -7,9 +7,12 @@ var AssetClient = class extends ApiClient {
7
7
  }
8
8
  async get(options) {
9
9
  const { projectId } = this.options;
10
+ const { filters, ...params } = options;
11
+ const rewrittenFilters = rewriteFiltersForApi(filters);
10
12
  const fetchUri = this.createUrl(ASSET_BASE_PATH, {
11
- ...options,
12
- projectId
13
+ ...params,
14
+ projectId,
15
+ ...rewrittenFilters
13
16
  });
14
17
  return this.apiClient(fetchUri);
15
18
  }
@@ -39,6 +42,7 @@ var UncachedAssetClient = class extends AssetClient {
39
42
  };
40
43
 
41
44
  // src/definitions.ts
45
+ import { FILE_MIME_TYPES_AUDIO, FILE_MIME_TYPES_IMAGE, FILE_MIME_TYPES_VIDEO } from "@uniformdev/files";
42
46
  var assetDefinitions = {
43
47
  image: {
44
48
  id: "image",
@@ -61,6 +65,18 @@ var assetDefinitions = {
61
65
  namePlural: "Other Assets"
62
66
  }
63
67
  };
68
+ var getAssetDefinitionType = (mimeType) => {
69
+ if (FILE_MIME_TYPES_IMAGE.includes(mimeType)) {
70
+ return assetDefinitions.image.id;
71
+ }
72
+ if (FILE_MIME_TYPES_VIDEO.includes(mimeType)) {
73
+ return assetDefinitions.video.id;
74
+ }
75
+ if (FILE_MIME_TYPES_AUDIO.includes(mimeType)) {
76
+ return assetDefinitions.audio.id;
77
+ }
78
+ return assetDefinitions.other.id;
79
+ };
64
80
 
65
81
  // src/imageDelivery.ts
66
82
  var isUniformImageUrl = (imageUrl) => {
@@ -68,7 +84,7 @@ var isUniformImageUrl = (imageUrl) => {
68
84
  if (typeof imageUrl !== "string") {
69
85
  return false;
70
86
  }
71
- return /(img)\.(eu\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
87
+ return /(img)\.(eu([1-9]\d*)?\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
72
88
  } catch (e) {
73
89
  return false;
74
90
  }
@@ -142,6 +158,7 @@ function convertAssetToPutAsset(asset) {
142
158
  _dataResources: asset.asset._dataResources,
143
159
  _name: asset.asset._name,
144
160
  type: asset.asset.type,
161
+ labels: asset.asset.labels,
145
162
  fields: {
146
163
  title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
147
164
  description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
@@ -157,5 +174,6 @@ export {
157
174
  UncachedAssetClient,
158
175
  assetDefinitions,
159
176
  convertAssetToPutAsset,
177
+ getAssetDefinitionType,
160
178
  imageFrom
161
179
  };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(src_exports, {
24
24
  UncachedAssetClient: () => UncachedAssetClient,
25
25
  assetDefinitions: () => assetDefinitions,
26
26
  convertAssetToPutAsset: () => convertAssetToPutAsset,
27
+ getAssetDefinitionType: () => getAssetDefinitionType,
27
28
  imageFrom: () => imageFrom
28
29
  });
29
30
  module.exports = __toCommonJS(src_exports);
@@ -37,9 +38,12 @@ var AssetClient = class extends import_api.ApiClient {
37
38
  }
38
39
  async get(options) {
39
40
  const { projectId } = this.options;
41
+ const { filters, ...params } = options;
42
+ const rewrittenFilters = (0, import_api.rewriteFiltersForApi)(filters);
40
43
  const fetchUri = this.createUrl(ASSET_BASE_PATH, {
41
- ...options,
42
- projectId
44
+ ...params,
45
+ projectId,
46
+ ...rewrittenFilters
43
47
  });
44
48
  return this.apiClient(fetchUri);
45
49
  }
@@ -69,6 +73,7 @@ var UncachedAssetClient = class extends AssetClient {
69
73
  };
70
74
 
71
75
  // src/definitions.ts
76
+ var import_files = require("@uniformdev/files");
72
77
  var assetDefinitions = {
73
78
  image: {
74
79
  id: "image",
@@ -91,6 +96,18 @@ var assetDefinitions = {
91
96
  namePlural: "Other Assets"
92
97
  }
93
98
  };
99
+ var getAssetDefinitionType = (mimeType) => {
100
+ if (import_files.FILE_MIME_TYPES_IMAGE.includes(mimeType)) {
101
+ return assetDefinitions.image.id;
102
+ }
103
+ if (import_files.FILE_MIME_TYPES_VIDEO.includes(mimeType)) {
104
+ return assetDefinitions.video.id;
105
+ }
106
+ if (import_files.FILE_MIME_TYPES_AUDIO.includes(mimeType)) {
107
+ return assetDefinitions.audio.id;
108
+ }
109
+ return assetDefinitions.other.id;
110
+ };
94
111
 
95
112
  // src/imageDelivery.ts
96
113
  var isUniformImageUrl = (imageUrl) => {
@@ -98,7 +115,7 @@ var isUniformImageUrl = (imageUrl) => {
98
115
  if (typeof imageUrl !== "string") {
99
116
  return false;
100
117
  }
101
- return /(img)\.(eu\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
118
+ return /(img)\.(eu([1-9]\d*)?\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
102
119
  } catch (e) {
103
120
  return false;
104
121
  }
@@ -172,6 +189,7 @@ function convertAssetToPutAsset(asset) {
172
189
  _dataResources: asset.asset._dataResources,
173
190
  _name: asset.asset._name,
174
191
  type: asset.asset.type,
192
+ labels: asset.asset.labels,
175
193
  fields: {
176
194
  title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
177
195
  description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
@@ -188,5 +206,6 @@ function convertAssetToPutAsset(asset) {
188
206
  UncachedAssetClient,
189
207
  assetDefinitions,
190
208
  convertAssetToPutAsset,
209
+ getAssetDefinitionType,
191
210
  imageFrom
192
211
  });
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/AssetClient.ts
2
- import { ApiClient } from "@uniformdev/context/api";
2
+ import { ApiClient, rewriteFiltersForApi } from "@uniformdev/context/api";
3
3
  var ASSET_BASE_PATH = "/api/v1/assets";
4
4
  var AssetClient = class extends ApiClient {
5
5
  constructor(options) {
@@ -7,9 +7,12 @@ var AssetClient = class extends ApiClient {
7
7
  }
8
8
  async get(options) {
9
9
  const { projectId } = this.options;
10
+ const { filters, ...params } = options;
11
+ const rewrittenFilters = rewriteFiltersForApi(filters);
10
12
  const fetchUri = this.createUrl(ASSET_BASE_PATH, {
11
- ...options,
12
- projectId
13
+ ...params,
14
+ projectId,
15
+ ...rewrittenFilters
13
16
  });
14
17
  return this.apiClient(fetchUri);
15
18
  }
@@ -39,6 +42,7 @@ var UncachedAssetClient = class extends AssetClient {
39
42
  };
40
43
 
41
44
  // src/definitions.ts
45
+ import { FILE_MIME_TYPES_AUDIO, FILE_MIME_TYPES_IMAGE, FILE_MIME_TYPES_VIDEO } from "@uniformdev/files";
42
46
  var assetDefinitions = {
43
47
  image: {
44
48
  id: "image",
@@ -61,6 +65,18 @@ var assetDefinitions = {
61
65
  namePlural: "Other Assets"
62
66
  }
63
67
  };
68
+ var getAssetDefinitionType = (mimeType) => {
69
+ if (FILE_MIME_TYPES_IMAGE.includes(mimeType)) {
70
+ return assetDefinitions.image.id;
71
+ }
72
+ if (FILE_MIME_TYPES_VIDEO.includes(mimeType)) {
73
+ return assetDefinitions.video.id;
74
+ }
75
+ if (FILE_MIME_TYPES_AUDIO.includes(mimeType)) {
76
+ return assetDefinitions.audio.id;
77
+ }
78
+ return assetDefinitions.other.id;
79
+ };
64
80
 
65
81
  // src/imageDelivery.ts
66
82
  var isUniformImageUrl = (imageUrl) => {
@@ -68,7 +84,7 @@ var isUniformImageUrl = (imageUrl) => {
68
84
  if (typeof imageUrl !== "string") {
69
85
  return false;
70
86
  }
71
- return /(img)\.(eu\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
87
+ return /(img)\.(eu([1-9]\d*)?\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
72
88
  } catch (e) {
73
89
  return false;
74
90
  }
@@ -142,6 +158,7 @@ function convertAssetToPutAsset(asset) {
142
158
  _dataResources: asset.asset._dataResources,
143
159
  _name: asset.asset._name,
144
160
  type: asset.asset.type,
161
+ labels: asset.asset.labels,
145
162
  fields: {
146
163
  title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
147
164
  description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
@@ -157,5 +174,6 @@ export {
157
174
  UncachedAssetClient,
158
175
  assetDefinitions,
159
176
  convertAssetToPutAsset,
177
+ getAssetDefinitionType,
160
178
  imageFrom
161
179
  };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@uniformdev/assets",
3
- "version": "20.50.2-alpha.1+8798ffc32d",
3
+ "version": "20.50.2-alpha.109+846837c66a",
4
4
  "description": "Uniform Assets",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.esm.js",
8
8
  "exports": {
9
+ "source": "./src/index.ts",
9
10
  "import": {
10
11
  "types": "./dist/index.d.ts",
11
12
  "node": "./dist/index.mjs",
@@ -25,7 +26,6 @@
25
26
  "dev:ts": "tsup --watch",
26
27
  "clean": "rimraf dist",
27
28
  "test": "vitest run",
28
- "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
29
29
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
30
30
  "update-openapi": "tsx ./scripts/update-openapi.cts"
31
31
  },
@@ -36,10 +36,11 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@uniformdev/context": "20.50.2-alpha.1+8798ffc32d"
39
+ "@uniformdev/context": "20.50.2-alpha.109+846837c66a",
40
+ "@uniformdev/files": "20.50.2-alpha.109+846837c66a"
40
41
  },
41
42
  "devDependencies": {
42
43
  "ts-xor": "^1.3.0"
43
44
  },
44
- "gitHead": "8798ffc32d405a5d357628861a40cd964e3ea6f0"
45
+ "gitHead": "846837c66ad0f518683c100615b59b27f91498ba"
45
46
  }