@uniformdev/assets 20.77.1-alpha.3.sha-c33b228bc0 → 20.77.2-alpha.3.sha-e9420d8e77

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
@@ -1933,6 +1933,21 @@ interface ImageFromApi {
1933
1933
  */
1934
1934
  declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => ImageFromApi;
1935
1935
 
1936
+ type AssetInputFields = NonNullable<NonNullable<AssetUpsertRequest['asset']>['fields']>;
1937
+ /**
1938
+ * The asset `fields` a write carries. The API assembles `url`, `mediaType`, `size`, `width` and
1939
+ * `height` from the attached file on every read, and the write schema rejects those along with
1940
+ * `custom`, so a write can neither send nor settle them.
1941
+ *
1942
+ * The CLI's asset comparator projects onto this same list, so a push only reports a difference a
1943
+ * push can act on.
1944
+ */
1945
+ declare const WRITABLE_ASSET_FIELDS: readonly ["title", "description", "file", "focalPoint"];
1946
+ /**
1947
+ * Selects the asset fields a write carries, dropping the ones the API computes from the attached
1948
+ * file. Returns a new object rather than editing the asset it reads.
1949
+ */
1950
+ declare const selectWritableAssetFields: (fields?: Asset["fields"]) => AssetInputFields;
1936
1951
  /**
1937
1952
  * Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
1938
1953
  * Removes things like author, stats, etc.
@@ -1942,4 +1957,4 @@ declare function convertAssetToPutAsset(asset: {
1942
1957
  projectId: string;
1943
1958
  }): AssetUpsertRequest;
1944
1959
 
1945
- 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 ImageFromApi, type ImageFromTransformProps, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset, getAssetDefinitionType, imageFrom };
1960
+ 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 ImageFromApi, type ImageFromTransformProps, UncachedAssetClient, WRITABLE_ASSET_FIELDS, assetDefinitions, convertAssetToPutAsset, getAssetDefinitionType, imageFrom, selectWritableAssetFields };
package/dist/index.d.ts CHANGED
@@ -1933,6 +1933,21 @@ interface ImageFromApi {
1933
1933
  */
1934
1934
  declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => ImageFromApi;
1935
1935
 
1936
+ type AssetInputFields = NonNullable<NonNullable<AssetUpsertRequest['asset']>['fields']>;
1937
+ /**
1938
+ * The asset `fields` a write carries. The API assembles `url`, `mediaType`, `size`, `width` and
1939
+ * `height` from the attached file on every read, and the write schema rejects those along with
1940
+ * `custom`, so a write can neither send nor settle them.
1941
+ *
1942
+ * The CLI's asset comparator projects onto this same list, so a push only reports a difference a
1943
+ * push can act on.
1944
+ */
1945
+ declare const WRITABLE_ASSET_FIELDS: readonly ["title", "description", "file", "focalPoint"];
1946
+ /**
1947
+ * Selects the asset fields a write carries, dropping the ones the API computes from the attached
1948
+ * file. Returns a new object rather than editing the asset it reads.
1949
+ */
1950
+ declare const selectWritableAssetFields: (fields?: Asset["fields"]) => AssetInputFields;
1936
1951
  /**
1937
1952
  * Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
1938
1953
  * Removes things like author, stats, etc.
@@ -1942,4 +1957,4 @@ declare function convertAssetToPutAsset(asset: {
1942
1957
  projectId: string;
1943
1958
  }): AssetUpsertRequest;
1944
1959
 
1945
- 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 ImageFromApi, type ImageFromTransformProps, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset, getAssetDefinitionType, imageFrom };
1960
+ 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 ImageFromApi, type ImageFromTransformProps, UncachedAssetClient, WRITABLE_ASSET_FIELDS, assetDefinitions, convertAssetToPutAsset, getAssetDefinitionType, imageFrom, selectWritableAssetFields };
package/dist/index.esm.js CHANGED
@@ -172,8 +172,21 @@ var imageFrom = (asset) => {
172
172
  };
173
173
 
174
174
  // src/utils/assetConverter.ts
175
+ var WRITABLE_ASSET_FIELDS = [
176
+ "title",
177
+ "description",
178
+ "file",
179
+ "focalPoint"
180
+ ];
181
+ var selectProperties = (source, names) => {
182
+ const selected = {};
183
+ for (const name of names) {
184
+ selected[name] = source[name];
185
+ }
186
+ return selected;
187
+ };
188
+ var selectWritableAssetFields = (fields = {}) => selectProperties(fields, WRITABLE_ASSET_FIELDS);
175
189
  function convertAssetToPutAsset(asset) {
176
- var _a, _b, _c, _d;
177
190
  return {
178
191
  asset: {
179
192
  _id: asset.asset._id,
@@ -181,12 +194,7 @@ function convertAssetToPutAsset(asset) {
181
194
  _name: asset.asset._name,
182
195
  type: asset.asset.type,
183
196
  labels: asset.asset.labels,
184
- fields: {
185
- title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
186
- description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
187
- file: (_c = asset.asset.fields) == null ? void 0 : _c.file,
188
- focalPoint: (_d = asset.asset.fields) == null ? void 0 : _d.focalPoint
189
- }
197
+ fields: selectWritableAssetFields(asset.asset.fields)
190
198
  },
191
199
  projectId: asset.projectId
192
200
  };
@@ -194,8 +202,10 @@ function convertAssetToPutAsset(asset) {
194
202
  export {
195
203
  AssetClient,
196
204
  UncachedAssetClient,
205
+ WRITABLE_ASSET_FIELDS,
197
206
  assetDefinitions,
198
207
  convertAssetToPutAsset,
199
208
  getAssetDefinitionType,
200
- imageFrom
209
+ imageFrom,
210
+ selectWritableAssetFields
201
211
  };
package/dist/index.js CHANGED
@@ -22,10 +22,12 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AssetClient: () => AssetClient,
24
24
  UncachedAssetClient: () => UncachedAssetClient,
25
+ WRITABLE_ASSET_FIELDS: () => WRITABLE_ASSET_FIELDS,
25
26
  assetDefinitions: () => assetDefinitions,
26
27
  convertAssetToPutAsset: () => convertAssetToPutAsset,
27
28
  getAssetDefinitionType: () => getAssetDefinitionType,
28
- imageFrom: () => imageFrom
29
+ imageFrom: () => imageFrom,
30
+ selectWritableAssetFields: () => selectWritableAssetFields
29
31
  });
30
32
  module.exports = __toCommonJS(index_exports);
31
33
 
@@ -203,8 +205,21 @@ var imageFrom = (asset) => {
203
205
  };
204
206
 
205
207
  // src/utils/assetConverter.ts
208
+ var WRITABLE_ASSET_FIELDS = [
209
+ "title",
210
+ "description",
211
+ "file",
212
+ "focalPoint"
213
+ ];
214
+ var selectProperties = (source, names) => {
215
+ const selected = {};
216
+ for (const name of names) {
217
+ selected[name] = source[name];
218
+ }
219
+ return selected;
220
+ };
221
+ var selectWritableAssetFields = (fields = {}) => selectProperties(fields, WRITABLE_ASSET_FIELDS);
206
222
  function convertAssetToPutAsset(asset) {
207
- var _a, _b, _c, _d;
208
223
  return {
209
224
  asset: {
210
225
  _id: asset.asset._id,
@@ -212,12 +227,7 @@ function convertAssetToPutAsset(asset) {
212
227
  _name: asset.asset._name,
213
228
  type: asset.asset.type,
214
229
  labels: asset.asset.labels,
215
- fields: {
216
- title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
217
- description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
218
- file: (_c = asset.asset.fields) == null ? void 0 : _c.file,
219
- focalPoint: (_d = asset.asset.fields) == null ? void 0 : _d.focalPoint
220
- }
230
+ fields: selectWritableAssetFields(asset.asset.fields)
221
231
  },
222
232
  projectId: asset.projectId
223
233
  };
@@ -226,8 +236,10 @@ function convertAssetToPutAsset(asset) {
226
236
  0 && (module.exports = {
227
237
  AssetClient,
228
238
  UncachedAssetClient,
239
+ WRITABLE_ASSET_FIELDS,
229
240
  assetDefinitions,
230
241
  convertAssetToPutAsset,
231
242
  getAssetDefinitionType,
232
- imageFrom
243
+ imageFrom,
244
+ selectWritableAssetFields
233
245
  });
package/dist/index.mjs CHANGED
@@ -172,8 +172,21 @@ var imageFrom = (asset) => {
172
172
  };
173
173
 
174
174
  // src/utils/assetConverter.ts
175
+ var WRITABLE_ASSET_FIELDS = [
176
+ "title",
177
+ "description",
178
+ "file",
179
+ "focalPoint"
180
+ ];
181
+ var selectProperties = (source, names) => {
182
+ const selected = {};
183
+ for (const name of names) {
184
+ selected[name] = source[name];
185
+ }
186
+ return selected;
187
+ };
188
+ var selectWritableAssetFields = (fields = {}) => selectProperties(fields, WRITABLE_ASSET_FIELDS);
175
189
  function convertAssetToPutAsset(asset) {
176
- var _a, _b, _c, _d;
177
190
  return {
178
191
  asset: {
179
192
  _id: asset.asset._id,
@@ -181,12 +194,7 @@ function convertAssetToPutAsset(asset) {
181
194
  _name: asset.asset._name,
182
195
  type: asset.asset.type,
183
196
  labels: asset.asset.labels,
184
- fields: {
185
- title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
186
- description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
187
- file: (_c = asset.asset.fields) == null ? void 0 : _c.file,
188
- focalPoint: (_d = asset.asset.fields) == null ? void 0 : _d.focalPoint
189
- }
197
+ fields: selectWritableAssetFields(asset.asset.fields)
190
198
  },
191
199
  projectId: asset.projectId
192
200
  };
@@ -194,8 +202,10 @@ function convertAssetToPutAsset(asset) {
194
202
  export {
195
203
  AssetClient,
196
204
  UncachedAssetClient,
205
+ WRITABLE_ASSET_FIELDS,
197
206
  assetDefinitions,
198
207
  convertAssetToPutAsset,
199
208
  getAssetDefinitionType,
200
- imageFrom
209
+ imageFrom,
210
+ selectWritableAssetFields
201
211
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/assets",
3
- "version": "20.77.1-alpha.3.sha-c33b228bc0",
3
+ "version": "20.77.2-alpha.3.sha-e9420d8e77",
4
4
  "description": "Uniform Assets",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -37,11 +37,11 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@uniformdev/context": "20.77.1-alpha.3.sha-c33b228bc0",
41
- "@uniformdev/files": "20.77.1-alpha.3.sha-c33b228bc0"
40
+ "@uniformdev/context": "20.77.2-alpha.3.sha-e9420d8e77",
41
+ "@uniformdev/files": "20.77.2-alpha.3.sha-e9420d8e77"
42
42
  },
43
43
  "devDependencies": {
44
44
  "ts-xor": "^1.3.0"
45
45
  },
46
- "gitHead": "c33b228bc0ee1d8ba5b77d8d2e095a633436d3fd"
46
+ "gitHead": "e9420d8e77e7b9b0c5ea14bfe38f1f16a9a236ee"
47
47
  }