@uniformdev/assets 20.65.0 → 20.66.1-alpha.1

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
@@ -1722,6 +1722,7 @@ type AssetDefinition = {
1722
1722
  namePlural: string;
1723
1723
  };
1724
1724
  declare const assetDefinitions: Record<AssetDefinitionType, AssetDefinition>;
1725
+ declare const getAssetDefinitionType: (mimeType: string) => AssetDefinitionType;
1725
1726
 
1726
1727
  /**
1727
1728
  * A union type of possible query parameters for the image delivery API.
@@ -1779,6 +1780,9 @@ declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => {
1779
1780
  * Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
1780
1781
  * Removes things like author, stats, etc.
1781
1782
  */
1782
- 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;
1783
1787
 
1784
- 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
@@ -1722,6 +1722,7 @@ type AssetDefinition = {
1722
1722
  namePlural: string;
1723
1723
  };
1724
1724
  declare const assetDefinitions: Record<AssetDefinitionType, AssetDefinition>;
1725
+ declare const getAssetDefinitionType: (mimeType: string) => AssetDefinitionType;
1725
1726
 
1726
1727
  /**
1727
1728
  * A union type of possible query parameters for the image delivery API.
@@ -1779,6 +1780,9 @@ declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => {
1779
1780
  * Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
1780
1781
  * Removes things like author, stats, etc.
1781
1782
  */
1782
- 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;
1783
1787
 
1784
- 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
@@ -42,6 +42,7 @@ var UncachedAssetClient = class extends AssetClient {
42
42
  };
43
43
 
44
44
  // src/definitions.ts
45
+ import { FILE_MIME_TYPES_AUDIO, FILE_MIME_TYPES_IMAGE, FILE_MIME_TYPES_VIDEO } from "@uniformdev/files";
45
46
  var assetDefinitions = {
46
47
  image: {
47
48
  id: "image",
@@ -64,6 +65,18 @@ var assetDefinitions = {
64
65
  namePlural: "Other Assets"
65
66
  }
66
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
+ };
67
80
 
68
81
  // src/imageDelivery.ts
69
82
  var isUniformImageUrl = (imageUrl) => {
@@ -161,5 +174,6 @@ export {
161
174
  UncachedAssetClient,
162
175
  assetDefinitions,
163
176
  convertAssetToPutAsset,
177
+ getAssetDefinitionType,
164
178
  imageFrom
165
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);
@@ -72,6 +73,7 @@ var UncachedAssetClient = class extends AssetClient {
72
73
  };
73
74
 
74
75
  // src/definitions.ts
76
+ var import_files = require("@uniformdev/files");
75
77
  var assetDefinitions = {
76
78
  image: {
77
79
  id: "image",
@@ -94,6 +96,18 @@ var assetDefinitions = {
94
96
  namePlural: "Other Assets"
95
97
  }
96
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
+ };
97
111
 
98
112
  // src/imageDelivery.ts
99
113
  var isUniformImageUrl = (imageUrl) => {
@@ -192,5 +206,6 @@ function convertAssetToPutAsset(asset) {
192
206
  UncachedAssetClient,
193
207
  assetDefinitions,
194
208
  convertAssetToPutAsset,
209
+ getAssetDefinitionType,
195
210
  imageFrom
196
211
  });
package/dist/index.mjs CHANGED
@@ -42,6 +42,7 @@ var UncachedAssetClient = class extends AssetClient {
42
42
  };
43
43
 
44
44
  // src/definitions.ts
45
+ import { FILE_MIME_TYPES_AUDIO, FILE_MIME_TYPES_IMAGE, FILE_MIME_TYPES_VIDEO } from "@uniformdev/files";
45
46
  var assetDefinitions = {
46
47
  image: {
47
48
  id: "image",
@@ -64,6 +65,18 @@ var assetDefinitions = {
64
65
  namePlural: "Other Assets"
65
66
  }
66
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
+ };
67
80
 
68
81
  // src/imageDelivery.ts
69
82
  var isUniformImageUrl = (imageUrl) => {
@@ -161,5 +174,6 @@ export {
161
174
  UncachedAssetClient,
162
175
  assetDefinitions,
163
176
  convertAssetToPutAsset,
177
+ getAssetDefinitionType,
164
178
  imageFrom
165
179
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/assets",
3
- "version": "20.65.0",
3
+ "version": "20.66.1-alpha.1+5120c82a21",
4
4
  "description": "Uniform Assets",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -35,10 +35,11 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@uniformdev/context": "20.65.0"
38
+ "@uniformdev/context": "20.66.1-alpha.1+5120c82a21",
39
+ "@uniformdev/files": "20.66.1-alpha.1+5120c82a21"
39
40
  },
40
41
  "devDependencies": {
41
42
  "ts-xor": "^1.3.0"
42
43
  },
43
- "gitHead": "3c85a58c461592970dbff8f166067d61da7955e3"
44
+ "gitHead": "5120c82a21b28394d5da650ddb24afdbf93e947b"
44
45
  }