@uniformdev/assets 20.7.1-alpha.12 → 20.7.1-alpha.121
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/LICENSE.txt +1 -1
- package/dist/index.d.mts +120 -14
- package/dist/index.d.ts +120 -14
- package/dist/index.esm.js +76 -3
- package/dist/index.js +78 -4
- package/dist/index.mjs +76 -3
- package/package.json +6 -3
package/LICENSE.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
©
|
|
1
|
+
© 2025 Uniform Systems, Inc. All Rights Reserved.
|
|
2
2
|
See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApiClient, ClientOptions } from '@uniformdev/context/api';
|
|
2
|
+
import { XOR } from 'ts-xor';
|
|
2
3
|
|
|
3
4
|
interface components$1 {
|
|
4
5
|
schemas: {
|
|
@@ -11,6 +12,8 @@ interface components$1 {
|
|
|
11
12
|
name: string;
|
|
12
13
|
/** @description Appears next to the parameter in the Composition editor */
|
|
13
14
|
helpText?: string;
|
|
15
|
+
/** @description Context provided to AI when generating content for this parameter. May also be shown to humans. */
|
|
16
|
+
guidance?: string;
|
|
14
17
|
/** @description Type name of the parameter (provided by a Uniform integration) */
|
|
15
18
|
type: string;
|
|
16
19
|
/** @description If true, this property can have locale-specific values. If false or not defined,
|
|
@@ -145,7 +148,7 @@ interface components$1 {
|
|
|
145
148
|
categoryId?: string | null;
|
|
146
149
|
/** @description Description of the component definition */
|
|
147
150
|
description?: string;
|
|
148
|
-
/** @description
|
|
151
|
+
/** @description Preview image URL for the component definition (shown in the UI) */
|
|
149
152
|
previewImageUrl?: string;
|
|
150
153
|
/**
|
|
151
154
|
* @description if this component uses team permissions or custom permissions
|
|
@@ -218,6 +221,27 @@ interface components$1 {
|
|
|
218
221
|
* @description ID of the workflow that instances of this content type will use by default. When not set, no workflow is attached
|
|
219
222
|
*/
|
|
220
223
|
workflowId?: string;
|
|
224
|
+
/** @description Configurations for previewing an entry on a consuming pattern or composition. */
|
|
225
|
+
previewConfigurations?: components$1["schemas"]["ContentTypePreviewConfiguration"][];
|
|
226
|
+
};
|
|
227
|
+
/** @description Defines a configuration for previewing an entry on a consuming pattern or composition. */
|
|
228
|
+
ContentTypePreviewConfiguration: {
|
|
229
|
+
/**
|
|
230
|
+
* @description The type of preview configuration
|
|
231
|
+
* @enum {string}
|
|
232
|
+
*/
|
|
233
|
+
type: "pattern" | "project-map";
|
|
234
|
+
/** @description Display label for the preview configuration */
|
|
235
|
+
label: string;
|
|
236
|
+
/**
|
|
237
|
+
* Format: uuid
|
|
238
|
+
* @description Target preview entity ID (project map node ID or pattern ID)
|
|
239
|
+
*/
|
|
240
|
+
id: string;
|
|
241
|
+
/** @description Optional mapping of dynamic input names to their values */
|
|
242
|
+
dynamicInputs?: {
|
|
243
|
+
[key: string]: string;
|
|
244
|
+
};
|
|
221
245
|
};
|
|
222
246
|
/** @description Defines an editable parameter on a component */
|
|
223
247
|
ComponentParameter: {
|
|
@@ -878,6 +902,8 @@ interface components$1 {
|
|
|
878
902
|
/** @description Allows executing the transition for a role. Note that write permissions to the destination stage are NOT required to execute a transition to it */
|
|
879
903
|
execute?: boolean;
|
|
880
904
|
};
|
|
905
|
+
/** @enum {string} */
|
|
906
|
+
ReleaseState: "open" | "locked" | "queued" | "launching" | "launched" | "deleting";
|
|
881
907
|
ProjectMapNodeAllowedQueryString: {
|
|
882
908
|
/** @description The name of the query string parameter */
|
|
883
909
|
name: string;
|
|
@@ -885,6 +911,20 @@ interface components$1 {
|
|
|
885
911
|
value?: string;
|
|
886
912
|
/** @description Help text for authors who might be setting up a preview value for this query string */
|
|
887
913
|
helpText?: string;
|
|
914
|
+
/** @description Configuration for providing a list of allowed values for this query string */
|
|
915
|
+
optionsSource?: {
|
|
916
|
+
/**
|
|
917
|
+
* @description The source type for the options
|
|
918
|
+
* @enum {string}
|
|
919
|
+
*/
|
|
920
|
+
source: "static";
|
|
921
|
+
options: {
|
|
922
|
+
/** @description Display name for the option */
|
|
923
|
+
name: string;
|
|
924
|
+
/** @description The actual value to be used */
|
|
925
|
+
value: string;
|
|
926
|
+
}[];
|
|
927
|
+
};
|
|
888
928
|
};
|
|
889
929
|
ProjectMapNodeData: {
|
|
890
930
|
/** @description While performing a search if a node is a hit, this property will return true. If it's supporting structure, like a parent of a search hit, it will return false */
|
|
@@ -1157,6 +1197,14 @@ interface components {
|
|
|
1157
1197
|
/** @constant */
|
|
1158
1198
|
type: "number";
|
|
1159
1199
|
};
|
|
1200
|
+
focalPoint?: {
|
|
1201
|
+
value: {
|
|
1202
|
+
x: number;
|
|
1203
|
+
y: number;
|
|
1204
|
+
};
|
|
1205
|
+
/** @constant */
|
|
1206
|
+
type: "focalPoint";
|
|
1207
|
+
};
|
|
1160
1208
|
/** @description Asset field values */
|
|
1161
1209
|
custom?: {
|
|
1162
1210
|
[key: string]: components["schemas"]["ComponentParameter"];
|
|
@@ -1192,6 +1240,14 @@ interface components {
|
|
|
1192
1240
|
/** @constant */
|
|
1193
1241
|
type: "file";
|
|
1194
1242
|
};
|
|
1243
|
+
focalPoint?: {
|
|
1244
|
+
value: {
|
|
1245
|
+
x: number;
|
|
1246
|
+
y: number;
|
|
1247
|
+
};
|
|
1248
|
+
/** @constant */
|
|
1249
|
+
type: "focalPoint";
|
|
1250
|
+
};
|
|
1195
1251
|
};
|
|
1196
1252
|
_dataResources?: components["schemas"]["DataResourceDefinitions"];
|
|
1197
1253
|
};
|
|
@@ -1497,33 +1553,31 @@ type AssetParamValueItem = {
|
|
|
1497
1553
|
};
|
|
1498
1554
|
/**
|
|
1499
1555
|
* The width of the original asset
|
|
1500
|
-
*
|
|
1501
|
-
* Should resolve to a number but might
|
|
1502
|
-
* be a string with a pointer reference
|
|
1503
1556
|
*/
|
|
1504
1557
|
width?: {
|
|
1505
1558
|
type: 'number';
|
|
1506
|
-
value: number |
|
|
1559
|
+
value: number | undefined;
|
|
1507
1560
|
};
|
|
1508
1561
|
/**
|
|
1509
1562
|
* The height of the original asset
|
|
1510
|
-
*
|
|
1511
|
-
* Should resolve to a number but might
|
|
1512
|
-
* be a string with a pointer reference
|
|
1513
1563
|
*/
|
|
1514
1564
|
height?: {
|
|
1515
1565
|
type: 'number';
|
|
1516
|
-
value: number |
|
|
1566
|
+
value: number | undefined;
|
|
1517
1567
|
};
|
|
1518
1568
|
/**
|
|
1519
1569
|
* The size in bytes of the original asset
|
|
1520
|
-
*
|
|
1521
|
-
* Should resolve to a number but might
|
|
1522
|
-
* be a string with a pointer reference
|
|
1523
1570
|
*/
|
|
1524
1571
|
size?: {
|
|
1525
1572
|
type: 'number';
|
|
1526
|
-
value: number |
|
|
1573
|
+
value: number | undefined;
|
|
1574
|
+
};
|
|
1575
|
+
focalPoint?: {
|
|
1576
|
+
type: 'focalPoint';
|
|
1577
|
+
value: {
|
|
1578
|
+
x: number;
|
|
1579
|
+
y: number;
|
|
1580
|
+
} | undefined;
|
|
1527
1581
|
};
|
|
1528
1582
|
/**
|
|
1529
1583
|
* Any key/value properties which the source
|
|
@@ -1566,10 +1620,62 @@ type AssetDefinition = {
|
|
|
1566
1620
|
};
|
|
1567
1621
|
declare const assetDefinitions: Record<AssetDefinitionType, AssetDefinition>;
|
|
1568
1622
|
|
|
1623
|
+
/**
|
|
1624
|
+
* A union type of possible query parameters for the image delivery API.
|
|
1625
|
+
*/
|
|
1626
|
+
type ImageDeliveryParams = XOR<{
|
|
1627
|
+
format: 'original';
|
|
1628
|
+
}, {
|
|
1629
|
+
width?: number;
|
|
1630
|
+
height?: number;
|
|
1631
|
+
/**
|
|
1632
|
+
* scale-down - resize the image to fit within the given dimensions, but never larger than the original size, while maintaining the aspect ratio
|
|
1633
|
+
* contain - resize the image to fit within the given dimensions, including possibly enlarging the image, while maintaining the aspect ratio
|
|
1634
|
+
* cover - resize the image to fully cover the given dimensions, cropping as needed
|
|
1635
|
+
*
|
|
1636
|
+
* "cover" additionally supports specifying a focal point via the "focal" parameter
|
|
1637
|
+
*/
|
|
1638
|
+
fit?: 'scale-down' | 'contain' | 'cover';
|
|
1639
|
+
focal?: undefined;
|
|
1640
|
+
}, {
|
|
1641
|
+
width?: number;
|
|
1642
|
+
height?: number;
|
|
1643
|
+
/** cover - resize the image to fully cover the given dimensions, cropping as needed */
|
|
1644
|
+
fit: 'cover';
|
|
1645
|
+
/** "string" is in format NxM - N and M are numbers between 0.00 and 1.00, N representing the x-axis and M representing the y-axis */
|
|
1646
|
+
focal: 'auto' | 'center' | string;
|
|
1647
|
+
}>;
|
|
1648
|
+
/**
|
|
1649
|
+
* A union type of possible transformations accepted by the `imageFrom` function.
|
|
1650
|
+
* Differentiates slightly from the `ImageDeliveryParams` type, in that the focal
|
|
1651
|
+
* point is represented by an object { x: number, y: number }, and not a string.
|
|
1652
|
+
*/
|
|
1653
|
+
type ImageFromTransformProps = XOR<{
|
|
1654
|
+
width?: number;
|
|
1655
|
+
height?: number;
|
|
1656
|
+
fit?: 'scale-down' | 'contain' | 'cover';
|
|
1657
|
+
}, {
|
|
1658
|
+
width?: number;
|
|
1659
|
+
height?: number;
|
|
1660
|
+
fit?: 'cover';
|
|
1661
|
+
focal: 'auto' | 'center' | {
|
|
1662
|
+
x: number;
|
|
1663
|
+
y: number;
|
|
1664
|
+
};
|
|
1665
|
+
}>;
|
|
1666
|
+
/**
|
|
1667
|
+
* A helper function for extracting the image URL from an asset and optionally
|
|
1668
|
+
* applying transformation URL query parameters.
|
|
1669
|
+
*/
|
|
1670
|
+
declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => {
|
|
1671
|
+
url: () => string;
|
|
1672
|
+
transform: (transformProps: ImageFromTransformProps) => /*elided*/ any;
|
|
1673
|
+
};
|
|
1674
|
+
|
|
1569
1675
|
/**
|
|
1570
1676
|
* Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
|
|
1571
1677
|
* Removes things like author, stats, etc.
|
|
1572
1678
|
*/
|
|
1573
1679
|
declare function convertAssetToPutAsset(asset: AssetGetResponseSingle): AssetUpsertRequest;
|
|
1574
1680
|
|
|
1575
|
-
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, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApiClient, ClientOptions } from '@uniformdev/context/api';
|
|
2
|
+
import { XOR } from 'ts-xor';
|
|
2
3
|
|
|
3
4
|
interface components$1 {
|
|
4
5
|
schemas: {
|
|
@@ -11,6 +12,8 @@ interface components$1 {
|
|
|
11
12
|
name: string;
|
|
12
13
|
/** @description Appears next to the parameter in the Composition editor */
|
|
13
14
|
helpText?: string;
|
|
15
|
+
/** @description Context provided to AI when generating content for this parameter. May also be shown to humans. */
|
|
16
|
+
guidance?: string;
|
|
14
17
|
/** @description Type name of the parameter (provided by a Uniform integration) */
|
|
15
18
|
type: string;
|
|
16
19
|
/** @description If true, this property can have locale-specific values. If false or not defined,
|
|
@@ -145,7 +148,7 @@ interface components$1 {
|
|
|
145
148
|
categoryId?: string | null;
|
|
146
149
|
/** @description Description of the component definition */
|
|
147
150
|
description?: string;
|
|
148
|
-
/** @description
|
|
151
|
+
/** @description Preview image URL for the component definition (shown in the UI) */
|
|
149
152
|
previewImageUrl?: string;
|
|
150
153
|
/**
|
|
151
154
|
* @description if this component uses team permissions or custom permissions
|
|
@@ -218,6 +221,27 @@ interface components$1 {
|
|
|
218
221
|
* @description ID of the workflow that instances of this content type will use by default. When not set, no workflow is attached
|
|
219
222
|
*/
|
|
220
223
|
workflowId?: string;
|
|
224
|
+
/** @description Configurations for previewing an entry on a consuming pattern or composition. */
|
|
225
|
+
previewConfigurations?: components$1["schemas"]["ContentTypePreviewConfiguration"][];
|
|
226
|
+
};
|
|
227
|
+
/** @description Defines a configuration for previewing an entry on a consuming pattern or composition. */
|
|
228
|
+
ContentTypePreviewConfiguration: {
|
|
229
|
+
/**
|
|
230
|
+
* @description The type of preview configuration
|
|
231
|
+
* @enum {string}
|
|
232
|
+
*/
|
|
233
|
+
type: "pattern" | "project-map";
|
|
234
|
+
/** @description Display label for the preview configuration */
|
|
235
|
+
label: string;
|
|
236
|
+
/**
|
|
237
|
+
* Format: uuid
|
|
238
|
+
* @description Target preview entity ID (project map node ID or pattern ID)
|
|
239
|
+
*/
|
|
240
|
+
id: string;
|
|
241
|
+
/** @description Optional mapping of dynamic input names to their values */
|
|
242
|
+
dynamicInputs?: {
|
|
243
|
+
[key: string]: string;
|
|
244
|
+
};
|
|
221
245
|
};
|
|
222
246
|
/** @description Defines an editable parameter on a component */
|
|
223
247
|
ComponentParameter: {
|
|
@@ -878,6 +902,8 @@ interface components$1 {
|
|
|
878
902
|
/** @description Allows executing the transition for a role. Note that write permissions to the destination stage are NOT required to execute a transition to it */
|
|
879
903
|
execute?: boolean;
|
|
880
904
|
};
|
|
905
|
+
/** @enum {string} */
|
|
906
|
+
ReleaseState: "open" | "locked" | "queued" | "launching" | "launched" | "deleting";
|
|
881
907
|
ProjectMapNodeAllowedQueryString: {
|
|
882
908
|
/** @description The name of the query string parameter */
|
|
883
909
|
name: string;
|
|
@@ -885,6 +911,20 @@ interface components$1 {
|
|
|
885
911
|
value?: string;
|
|
886
912
|
/** @description Help text for authors who might be setting up a preview value for this query string */
|
|
887
913
|
helpText?: string;
|
|
914
|
+
/** @description Configuration for providing a list of allowed values for this query string */
|
|
915
|
+
optionsSource?: {
|
|
916
|
+
/**
|
|
917
|
+
* @description The source type for the options
|
|
918
|
+
* @enum {string}
|
|
919
|
+
*/
|
|
920
|
+
source: "static";
|
|
921
|
+
options: {
|
|
922
|
+
/** @description Display name for the option */
|
|
923
|
+
name: string;
|
|
924
|
+
/** @description The actual value to be used */
|
|
925
|
+
value: string;
|
|
926
|
+
}[];
|
|
927
|
+
};
|
|
888
928
|
};
|
|
889
929
|
ProjectMapNodeData: {
|
|
890
930
|
/** @description While performing a search if a node is a hit, this property will return true. If it's supporting structure, like a parent of a search hit, it will return false */
|
|
@@ -1157,6 +1197,14 @@ interface components {
|
|
|
1157
1197
|
/** @constant */
|
|
1158
1198
|
type: "number";
|
|
1159
1199
|
};
|
|
1200
|
+
focalPoint?: {
|
|
1201
|
+
value: {
|
|
1202
|
+
x: number;
|
|
1203
|
+
y: number;
|
|
1204
|
+
};
|
|
1205
|
+
/** @constant */
|
|
1206
|
+
type: "focalPoint";
|
|
1207
|
+
};
|
|
1160
1208
|
/** @description Asset field values */
|
|
1161
1209
|
custom?: {
|
|
1162
1210
|
[key: string]: components["schemas"]["ComponentParameter"];
|
|
@@ -1192,6 +1240,14 @@ interface components {
|
|
|
1192
1240
|
/** @constant */
|
|
1193
1241
|
type: "file";
|
|
1194
1242
|
};
|
|
1243
|
+
focalPoint?: {
|
|
1244
|
+
value: {
|
|
1245
|
+
x: number;
|
|
1246
|
+
y: number;
|
|
1247
|
+
};
|
|
1248
|
+
/** @constant */
|
|
1249
|
+
type: "focalPoint";
|
|
1250
|
+
};
|
|
1195
1251
|
};
|
|
1196
1252
|
_dataResources?: components["schemas"]["DataResourceDefinitions"];
|
|
1197
1253
|
};
|
|
@@ -1497,33 +1553,31 @@ type AssetParamValueItem = {
|
|
|
1497
1553
|
};
|
|
1498
1554
|
/**
|
|
1499
1555
|
* The width of the original asset
|
|
1500
|
-
*
|
|
1501
|
-
* Should resolve to a number but might
|
|
1502
|
-
* be a string with a pointer reference
|
|
1503
1556
|
*/
|
|
1504
1557
|
width?: {
|
|
1505
1558
|
type: 'number';
|
|
1506
|
-
value: number |
|
|
1559
|
+
value: number | undefined;
|
|
1507
1560
|
};
|
|
1508
1561
|
/**
|
|
1509
1562
|
* The height of the original asset
|
|
1510
|
-
*
|
|
1511
|
-
* Should resolve to a number but might
|
|
1512
|
-
* be a string with a pointer reference
|
|
1513
1563
|
*/
|
|
1514
1564
|
height?: {
|
|
1515
1565
|
type: 'number';
|
|
1516
|
-
value: number |
|
|
1566
|
+
value: number | undefined;
|
|
1517
1567
|
};
|
|
1518
1568
|
/**
|
|
1519
1569
|
* The size in bytes of the original asset
|
|
1520
|
-
*
|
|
1521
|
-
* Should resolve to a number but might
|
|
1522
|
-
* be a string with a pointer reference
|
|
1523
1570
|
*/
|
|
1524
1571
|
size?: {
|
|
1525
1572
|
type: 'number';
|
|
1526
|
-
value: number |
|
|
1573
|
+
value: number | undefined;
|
|
1574
|
+
};
|
|
1575
|
+
focalPoint?: {
|
|
1576
|
+
type: 'focalPoint';
|
|
1577
|
+
value: {
|
|
1578
|
+
x: number;
|
|
1579
|
+
y: number;
|
|
1580
|
+
} | undefined;
|
|
1527
1581
|
};
|
|
1528
1582
|
/**
|
|
1529
1583
|
* Any key/value properties which the source
|
|
@@ -1566,10 +1620,62 @@ type AssetDefinition = {
|
|
|
1566
1620
|
};
|
|
1567
1621
|
declare const assetDefinitions: Record<AssetDefinitionType, AssetDefinition>;
|
|
1568
1622
|
|
|
1623
|
+
/**
|
|
1624
|
+
* A union type of possible query parameters for the image delivery API.
|
|
1625
|
+
*/
|
|
1626
|
+
type ImageDeliveryParams = XOR<{
|
|
1627
|
+
format: 'original';
|
|
1628
|
+
}, {
|
|
1629
|
+
width?: number;
|
|
1630
|
+
height?: number;
|
|
1631
|
+
/**
|
|
1632
|
+
* scale-down - resize the image to fit within the given dimensions, but never larger than the original size, while maintaining the aspect ratio
|
|
1633
|
+
* contain - resize the image to fit within the given dimensions, including possibly enlarging the image, while maintaining the aspect ratio
|
|
1634
|
+
* cover - resize the image to fully cover the given dimensions, cropping as needed
|
|
1635
|
+
*
|
|
1636
|
+
* "cover" additionally supports specifying a focal point via the "focal" parameter
|
|
1637
|
+
*/
|
|
1638
|
+
fit?: 'scale-down' | 'contain' | 'cover';
|
|
1639
|
+
focal?: undefined;
|
|
1640
|
+
}, {
|
|
1641
|
+
width?: number;
|
|
1642
|
+
height?: number;
|
|
1643
|
+
/** cover - resize the image to fully cover the given dimensions, cropping as needed */
|
|
1644
|
+
fit: 'cover';
|
|
1645
|
+
/** "string" is in format NxM - N and M are numbers between 0.00 and 1.00, N representing the x-axis and M representing the y-axis */
|
|
1646
|
+
focal: 'auto' | 'center' | string;
|
|
1647
|
+
}>;
|
|
1648
|
+
/**
|
|
1649
|
+
* A union type of possible transformations accepted by the `imageFrom` function.
|
|
1650
|
+
* Differentiates slightly from the `ImageDeliveryParams` type, in that the focal
|
|
1651
|
+
* point is represented by an object { x: number, y: number }, and not a string.
|
|
1652
|
+
*/
|
|
1653
|
+
type ImageFromTransformProps = XOR<{
|
|
1654
|
+
width?: number;
|
|
1655
|
+
height?: number;
|
|
1656
|
+
fit?: 'scale-down' | 'contain' | 'cover';
|
|
1657
|
+
}, {
|
|
1658
|
+
width?: number;
|
|
1659
|
+
height?: number;
|
|
1660
|
+
fit?: 'cover';
|
|
1661
|
+
focal: 'auto' | 'center' | {
|
|
1662
|
+
x: number;
|
|
1663
|
+
y: number;
|
|
1664
|
+
};
|
|
1665
|
+
}>;
|
|
1666
|
+
/**
|
|
1667
|
+
* A helper function for extracting the image URL from an asset and optionally
|
|
1668
|
+
* applying transformation URL query parameters.
|
|
1669
|
+
*/
|
|
1670
|
+
declare const imageFrom: (asset: Asset | AssetParamValueItem | string) => {
|
|
1671
|
+
url: () => string;
|
|
1672
|
+
transform: (transformProps: ImageFromTransformProps) => /*elided*/ any;
|
|
1673
|
+
};
|
|
1674
|
+
|
|
1569
1675
|
/**
|
|
1570
1676
|
* Converts a content asset to a put content asset body that has only the properties expected to the PUT API.
|
|
1571
1677
|
* Removes things like author, stats, etc.
|
|
1572
1678
|
*/
|
|
1573
1679
|
declare function convertAssetToPutAsset(asset: AssetGetResponseSingle): AssetUpsertRequest;
|
|
1574
1680
|
|
|
1575
|
-
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, UncachedAssetClient, assetDefinitions, convertAssetToPutAsset };
|
|
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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -62,9 +62,80 @@ var assetDefinitions = {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
// src/imageDelivery.ts
|
|
66
|
+
var isUniformImageUrl = (imageUrl) => {
|
|
67
|
+
try {
|
|
68
|
+
if (typeof imageUrl !== "string") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return /(img)\.(eu\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var imageFrom = (asset) => {
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
|
+
const baseUrl = typeof asset === "string" ? asset : (_b = (_a = asset.fields) == null ? void 0 : _a.url) == null ? void 0 : _b.value;
|
|
79
|
+
const isUniformHosted = isUniformImageUrl(baseUrl);
|
|
80
|
+
const deliveryParams = {};
|
|
81
|
+
if (typeof asset !== "string") {
|
|
82
|
+
if ((_d = (_c = asset.fields) == null ? void 0 : _c.focalPoint) == null ? void 0 : _d.value) {
|
|
83
|
+
deliveryParams.focal = `${asset.fields.focalPoint.value.x}x${asset.fields.focalPoint.value.y}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const api = {
|
|
87
|
+
url: () => {
|
|
88
|
+
if (!baseUrl) {
|
|
89
|
+
return "";
|
|
90
|
+
}
|
|
91
|
+
if (!isUniformHosted) {
|
|
92
|
+
return baseUrl;
|
|
93
|
+
}
|
|
94
|
+
const url = new URL(baseUrl);
|
|
95
|
+
const params = deliveryParams;
|
|
96
|
+
if (params.width !== void 0) {
|
|
97
|
+
url.searchParams.set("width", params.width.toString());
|
|
98
|
+
}
|
|
99
|
+
if (params.height !== void 0) {
|
|
100
|
+
url.searchParams.set("height", params.height.toString());
|
|
101
|
+
}
|
|
102
|
+
if (params.fit !== void 0) {
|
|
103
|
+
url.searchParams.set("fit", params.fit);
|
|
104
|
+
} else if (params.width !== void 0 && params.height !== void 0) {
|
|
105
|
+
url.searchParams.set("fit", "cover");
|
|
106
|
+
params.fit = "cover";
|
|
107
|
+
}
|
|
108
|
+
if (params.width !== void 0 && params.height !== void 0 && params.focal !== void 0 && params.fit === "cover") {
|
|
109
|
+
url.searchParams.set("focal", params.focal);
|
|
110
|
+
}
|
|
111
|
+
return url.toString();
|
|
112
|
+
},
|
|
113
|
+
transform: (transformProps) => {
|
|
114
|
+
if (transformProps.width !== void 0) {
|
|
115
|
+
deliveryParams.width = transformProps.width;
|
|
116
|
+
}
|
|
117
|
+
if (transformProps.height !== void 0) {
|
|
118
|
+
deliveryParams.height = transformProps.height;
|
|
119
|
+
}
|
|
120
|
+
if (transformProps.fit !== void 0) {
|
|
121
|
+
deliveryParams.fit = transformProps.fit;
|
|
122
|
+
}
|
|
123
|
+
if (transformProps.focal !== void 0) {
|
|
124
|
+
if (typeof transformProps.focal === "string") {
|
|
125
|
+
deliveryParams.focal = transformProps.focal;
|
|
126
|
+
} else {
|
|
127
|
+
deliveryParams.focal = `${transformProps.focal.x}x${transformProps.focal.y}`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return api;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return api;
|
|
134
|
+
};
|
|
135
|
+
|
|
65
136
|
// src/utils/assetConverter.ts
|
|
66
137
|
function convertAssetToPutAsset(asset) {
|
|
67
|
-
var _a, _b, _c;
|
|
138
|
+
var _a, _b, _c, _d;
|
|
68
139
|
return {
|
|
69
140
|
asset: {
|
|
70
141
|
_id: asset.asset._id,
|
|
@@ -74,7 +145,8 @@ function convertAssetToPutAsset(asset) {
|
|
|
74
145
|
fields: {
|
|
75
146
|
title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
|
|
76
147
|
description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
|
|
77
|
-
file: (_c = asset.asset.fields) == null ? void 0 : _c.file
|
|
148
|
+
file: (_c = asset.asset.fields) == null ? void 0 : _c.file,
|
|
149
|
+
focalPoint: (_d = asset.asset.fields) == null ? void 0 : _d.focalPoint
|
|
78
150
|
}
|
|
79
151
|
},
|
|
80
152
|
projectId: asset.projectId
|
|
@@ -84,5 +156,6 @@ export {
|
|
|
84
156
|
AssetClient,
|
|
85
157
|
UncachedAssetClient,
|
|
86
158
|
assetDefinitions,
|
|
87
|
-
convertAssetToPutAsset
|
|
159
|
+
convertAssetToPutAsset,
|
|
160
|
+
imageFrom
|
|
88
161
|
};
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,8 @@ __export(src_exports, {
|
|
|
23
23
|
AssetClient: () => AssetClient,
|
|
24
24
|
UncachedAssetClient: () => UncachedAssetClient,
|
|
25
25
|
assetDefinitions: () => assetDefinitions,
|
|
26
|
-
convertAssetToPutAsset: () => convertAssetToPutAsset
|
|
26
|
+
convertAssetToPutAsset: () => convertAssetToPutAsset,
|
|
27
|
+
imageFrom: () => imageFrom
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(src_exports);
|
|
29
30
|
|
|
@@ -91,9 +92,80 @@ var assetDefinitions = {
|
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
94
|
|
|
95
|
+
// src/imageDelivery.ts
|
|
96
|
+
var isUniformImageUrl = (imageUrl) => {
|
|
97
|
+
try {
|
|
98
|
+
if (typeof imageUrl !== "string") {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return /(img)\.(eu\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var imageFrom = (asset) => {
|
|
107
|
+
var _a, _b, _c, _d;
|
|
108
|
+
const baseUrl = typeof asset === "string" ? asset : (_b = (_a = asset.fields) == null ? void 0 : _a.url) == null ? void 0 : _b.value;
|
|
109
|
+
const isUniformHosted = isUniformImageUrl(baseUrl);
|
|
110
|
+
const deliveryParams = {};
|
|
111
|
+
if (typeof asset !== "string") {
|
|
112
|
+
if ((_d = (_c = asset.fields) == null ? void 0 : _c.focalPoint) == null ? void 0 : _d.value) {
|
|
113
|
+
deliveryParams.focal = `${asset.fields.focalPoint.value.x}x${asset.fields.focalPoint.value.y}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const api = {
|
|
117
|
+
url: () => {
|
|
118
|
+
if (!baseUrl) {
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
121
|
+
if (!isUniformHosted) {
|
|
122
|
+
return baseUrl;
|
|
123
|
+
}
|
|
124
|
+
const url = new URL(baseUrl);
|
|
125
|
+
const params = deliveryParams;
|
|
126
|
+
if (params.width !== void 0) {
|
|
127
|
+
url.searchParams.set("width", params.width.toString());
|
|
128
|
+
}
|
|
129
|
+
if (params.height !== void 0) {
|
|
130
|
+
url.searchParams.set("height", params.height.toString());
|
|
131
|
+
}
|
|
132
|
+
if (params.fit !== void 0) {
|
|
133
|
+
url.searchParams.set("fit", params.fit);
|
|
134
|
+
} else if (params.width !== void 0 && params.height !== void 0) {
|
|
135
|
+
url.searchParams.set("fit", "cover");
|
|
136
|
+
params.fit = "cover";
|
|
137
|
+
}
|
|
138
|
+
if (params.width !== void 0 && params.height !== void 0 && params.focal !== void 0 && params.fit === "cover") {
|
|
139
|
+
url.searchParams.set("focal", params.focal);
|
|
140
|
+
}
|
|
141
|
+
return url.toString();
|
|
142
|
+
},
|
|
143
|
+
transform: (transformProps) => {
|
|
144
|
+
if (transformProps.width !== void 0) {
|
|
145
|
+
deliveryParams.width = transformProps.width;
|
|
146
|
+
}
|
|
147
|
+
if (transformProps.height !== void 0) {
|
|
148
|
+
deliveryParams.height = transformProps.height;
|
|
149
|
+
}
|
|
150
|
+
if (transformProps.fit !== void 0) {
|
|
151
|
+
deliveryParams.fit = transformProps.fit;
|
|
152
|
+
}
|
|
153
|
+
if (transformProps.focal !== void 0) {
|
|
154
|
+
if (typeof transformProps.focal === "string") {
|
|
155
|
+
deliveryParams.focal = transformProps.focal;
|
|
156
|
+
} else {
|
|
157
|
+
deliveryParams.focal = `${transformProps.focal.x}x${transformProps.focal.y}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return api;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return api;
|
|
164
|
+
};
|
|
165
|
+
|
|
94
166
|
// src/utils/assetConverter.ts
|
|
95
167
|
function convertAssetToPutAsset(asset) {
|
|
96
|
-
var _a, _b, _c;
|
|
168
|
+
var _a, _b, _c, _d;
|
|
97
169
|
return {
|
|
98
170
|
asset: {
|
|
99
171
|
_id: asset.asset._id,
|
|
@@ -103,7 +175,8 @@ function convertAssetToPutAsset(asset) {
|
|
|
103
175
|
fields: {
|
|
104
176
|
title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
|
|
105
177
|
description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
|
|
106
|
-
file: (_c = asset.asset.fields) == null ? void 0 : _c.file
|
|
178
|
+
file: (_c = asset.asset.fields) == null ? void 0 : _c.file,
|
|
179
|
+
focalPoint: (_d = asset.asset.fields) == null ? void 0 : _d.focalPoint
|
|
107
180
|
}
|
|
108
181
|
},
|
|
109
182
|
projectId: asset.projectId
|
|
@@ -114,5 +187,6 @@ function convertAssetToPutAsset(asset) {
|
|
|
114
187
|
AssetClient,
|
|
115
188
|
UncachedAssetClient,
|
|
116
189
|
assetDefinitions,
|
|
117
|
-
convertAssetToPutAsset
|
|
190
|
+
convertAssetToPutAsset,
|
|
191
|
+
imageFrom
|
|
118
192
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -62,9 +62,80 @@ var assetDefinitions = {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
// src/imageDelivery.ts
|
|
66
|
+
var isUniformImageUrl = (imageUrl) => {
|
|
67
|
+
try {
|
|
68
|
+
if (typeof imageUrl !== "string") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return /(img)\.(eu\.)?uniform\.(rocks|global)$/.test(new URL(imageUrl).hostname);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var imageFrom = (asset) => {
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
|
+
const baseUrl = typeof asset === "string" ? asset : (_b = (_a = asset.fields) == null ? void 0 : _a.url) == null ? void 0 : _b.value;
|
|
79
|
+
const isUniformHosted = isUniformImageUrl(baseUrl);
|
|
80
|
+
const deliveryParams = {};
|
|
81
|
+
if (typeof asset !== "string") {
|
|
82
|
+
if ((_d = (_c = asset.fields) == null ? void 0 : _c.focalPoint) == null ? void 0 : _d.value) {
|
|
83
|
+
deliveryParams.focal = `${asset.fields.focalPoint.value.x}x${asset.fields.focalPoint.value.y}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const api = {
|
|
87
|
+
url: () => {
|
|
88
|
+
if (!baseUrl) {
|
|
89
|
+
return "";
|
|
90
|
+
}
|
|
91
|
+
if (!isUniformHosted) {
|
|
92
|
+
return baseUrl;
|
|
93
|
+
}
|
|
94
|
+
const url = new URL(baseUrl);
|
|
95
|
+
const params = deliveryParams;
|
|
96
|
+
if (params.width !== void 0) {
|
|
97
|
+
url.searchParams.set("width", params.width.toString());
|
|
98
|
+
}
|
|
99
|
+
if (params.height !== void 0) {
|
|
100
|
+
url.searchParams.set("height", params.height.toString());
|
|
101
|
+
}
|
|
102
|
+
if (params.fit !== void 0) {
|
|
103
|
+
url.searchParams.set("fit", params.fit);
|
|
104
|
+
} else if (params.width !== void 0 && params.height !== void 0) {
|
|
105
|
+
url.searchParams.set("fit", "cover");
|
|
106
|
+
params.fit = "cover";
|
|
107
|
+
}
|
|
108
|
+
if (params.width !== void 0 && params.height !== void 0 && params.focal !== void 0 && params.fit === "cover") {
|
|
109
|
+
url.searchParams.set("focal", params.focal);
|
|
110
|
+
}
|
|
111
|
+
return url.toString();
|
|
112
|
+
},
|
|
113
|
+
transform: (transformProps) => {
|
|
114
|
+
if (transformProps.width !== void 0) {
|
|
115
|
+
deliveryParams.width = transformProps.width;
|
|
116
|
+
}
|
|
117
|
+
if (transformProps.height !== void 0) {
|
|
118
|
+
deliveryParams.height = transformProps.height;
|
|
119
|
+
}
|
|
120
|
+
if (transformProps.fit !== void 0) {
|
|
121
|
+
deliveryParams.fit = transformProps.fit;
|
|
122
|
+
}
|
|
123
|
+
if (transformProps.focal !== void 0) {
|
|
124
|
+
if (typeof transformProps.focal === "string") {
|
|
125
|
+
deliveryParams.focal = transformProps.focal;
|
|
126
|
+
} else {
|
|
127
|
+
deliveryParams.focal = `${transformProps.focal.x}x${transformProps.focal.y}`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return api;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return api;
|
|
134
|
+
};
|
|
135
|
+
|
|
65
136
|
// src/utils/assetConverter.ts
|
|
66
137
|
function convertAssetToPutAsset(asset) {
|
|
67
|
-
var _a, _b, _c;
|
|
138
|
+
var _a, _b, _c, _d;
|
|
68
139
|
return {
|
|
69
140
|
asset: {
|
|
70
141
|
_id: asset.asset._id,
|
|
@@ -74,7 +145,8 @@ function convertAssetToPutAsset(asset) {
|
|
|
74
145
|
fields: {
|
|
75
146
|
title: (_a = asset.asset.fields) == null ? void 0 : _a.title,
|
|
76
147
|
description: (_b = asset.asset.fields) == null ? void 0 : _b.description,
|
|
77
|
-
file: (_c = asset.asset.fields) == null ? void 0 : _c.file
|
|
148
|
+
file: (_c = asset.asset.fields) == null ? void 0 : _c.file,
|
|
149
|
+
focalPoint: (_d = asset.asset.fields) == null ? void 0 : _d.focalPoint
|
|
78
150
|
}
|
|
79
151
|
},
|
|
80
152
|
projectId: asset.projectId
|
|
@@ -84,5 +156,6 @@ export {
|
|
|
84
156
|
AssetClient,
|
|
85
157
|
UncachedAssetClient,
|
|
86
158
|
assetDefinitions,
|
|
87
|
-
convertAssetToPutAsset
|
|
159
|
+
convertAssetToPutAsset,
|
|
160
|
+
imageFrom
|
|
88
161
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/assets",
|
|
3
|
-
"version": "20.7.1-alpha.
|
|
3
|
+
"version": "20.7.1-alpha.121+a4f284458c",
|
|
4
4
|
"description": "Uniform Assets",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@uniformdev/context": "20.7.1-alpha.
|
|
39
|
+
"@uniformdev/context": "20.7.1-alpha.121+a4f284458c"
|
|
40
40
|
},
|
|
41
|
-
"
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"ts-xor": "^1.3.0"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "a4f284458cffb24442299a5210bdad47c05aada3"
|
|
42
45
|
}
|