Skip to content

Commit 6740562

Browse files
authored
feat: url-loader@6.0.0 (#219)
# Description <!-- Include a summary of the change made and also list the dependencies that are required if any --> This PR migrates the repo off of Zod schemas toward pure TS with JSDoc annotations that can eventually be used to extract metadata for display in docs. Generally the external behavior should be identical, with obvious exceptions where schema entry points are no longer available etc., so this would constitute a breaking change for consumers relying on those entrypoints or whose inputs may no longer be valid with new type safety around video/image options. I've also updated all the tests to `.ts` so we can be sure the types for the API are working as we expect going forward. Although all the tests are passing, the doc generation issue remains unsolved, causing the repo-wide build to fail, so that will need to be updated to use a JSDoc parsing tool. However, it should be quite straightforward to wire that up in place of the previous Zod-embedded metadata. For now, I'm opening this against the `beta` branch so the required JSDoc parsing logic can be added and other changes can be experimented with before broader consumption. ## Issue Ticket Number N/A <!-- Specify above which issue this fixes by referencing the issue number (`#<ISSUE_NUMBER>`) or issue URL. --> <!-- Example: Fixes https://github.com/colbyfayock/cloudinary-util/issues/<ISSUE_NUMBER> --> ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [X] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Fix or improve the documentation - [X] This change requires a documentation update # Checklist (Still a draft, need to figure out how to work around missing schemas in build) <!-- These must all be followed and checked. --> - [ ] I have followed the contributing guidelines of this project as mentioned in [CONTRIBUTING.md](/CONTRIBUTING.md) - [ ] I have created an [issue](https://github.com/colbyfayock/cloudinary-util/issues) ticket for this PR - [ ] I have checked to ensure there aren't other open [Pull Requests](https://github.com/colbyfayock/cloudinary-util/pulls) for the same update/change? - [ ] I have performed a self-review of my own code - [ ] I have run tests locally to ensure they all pass - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes needed to the documentation # Description <!-- Include a summary of the change made and also list the dependencies that are required if any --> ## Issue Ticket Number Fixes #<ISSUE_NUMBER> <!-- Specify above which issue this fixes by referencing the issue number (`#<ISSUE_NUMBER>`) or issue URL. --> <!-- Example: Fixes https://github.com/colbyfayock/cloudinary-util/issues/<ISSUE_NUMBER> --> ## Type of change <!-- Please select all options that are applicable. --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Fix or improve the documentation - [ ] This change requires a documentation update # Checklist <!-- These must all be followed and checked. --> - [ ] I have followed the contributing guidelines of this project as mentioned in [CONTRIBUTING.md](/CONTRIBUTING.md) - [ ] I have created an [issue](https://github.com/colbyfayock/cloudinary-util/issues) ticket for this PR - [ ] I have checked to ensure there aren't other open [Pull Requests](https://github.com/colbyfayock/cloudinary-util/pulls) for the same update/change? - [ ] I have performed a self-review of my own code - [ ] I have run tests locally to ensure they all pass - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes needed to the documentation --------- Co-authored-by: David Blass <david@arktype.io> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: Mrinank Bhowmick <77621953+Mrinank-Bhowmick@users.noreply.github.com> Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> BREAKING CHANGE: removes zod schemas, refactors type system
1 parent e34fd5a commit 6740562

File tree

108 files changed

+5850
-8879
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+5850
-8879
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ module.exports = defineConfig({
3838
"@typescript-eslint/ban-types": "off",
3939
"@typescript-eslint/no-explicit-any": "off",
4040
"@typescript-eslint/no-non-null-assertion": "off",
41+
"@typescript-eslint/no-namespace": ["warn", { allowDeclarations: true }],
4142
},
4243
});

docs/src/components/SchemaTable/SchemaTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const SchemaTable = ({ schema, schemaKey }) => {
5959
};
6060

6161
return property;
62-
}
62+
},
6363
);
6464

6565
const sortedProperties = sortByKey(formattedProperties, "name");

docs/src/lib/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export function sortByKey(
77
array: Array<object> = [],
88
key: string,
9-
type: string = "asc"
9+
type: string = "asc",
1010
) {
1111
function compare(a: object, b: object) {
1212
let keyA = a[key];

packages/types/CHANGELOG.md

Lines changed: 43 additions & 46 deletions
Large diffs are not rendered by default.

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudinary-util/types",
3-
"version": "1.5.11",
3+
"version": "2.0.0-beta.3",
44
"type": "module",
55
"main": "./dist/index.cjs",
66
"types": "./dist/index.d.cts",

packages/types/src/index.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export type {
2-
CloudinaryResource, CloudinaryResourceAccessMode, CloudinaryResourceContext, CloudinaryResourceDeliveryType, CloudinaryResourceResourceType
2+
CloudinaryResource,
3+
CloudinaryResourceAccessMode,
4+
CloudinaryResourceContext,
5+
CloudinaryResourceDeliveryType,
6+
CloudinaryResourceResourceType,
37
} from "./types/resources.js";
48

59
export type {
@@ -14,24 +18,30 @@ export type {
1418
CloudinaryUploadWidgetInstanceMethods,
1519
CloudinaryUploadWidgetOptions,
1620
CloudinaryUploadWidgetResults,
17-
CloudinaryUploadWidgetSources
21+
CloudinaryUploadWidgetSources,
1822
} from "./types/cloudinary-upload-widget.js";
1923

2024
export type {
2125
CloudinaryVideoPlayer,
2226
CloudinaryVideoPlayerOptionPosterOptions,
2327
CloudinaryVideoPlayerOptions,
2428
CloudinaryVideoPlayerOptionsColors,
25-
CloudinaryVideoPlayerOptionsLogo, CloudinaryVideoPlayerPlaylistByTagOptions,
26-
CloudinaryVideoPlayerPlaylistOptions, CloudinaryVideoPlayerTextTracks, CloudinaryVideoPlayerTextTracksTrack, CloudinaryVideoPlayerTextTracksTrackOptions, CloudinaryVideoPlayerTextTracksTrackOptionsBox,
29+
CloudinaryVideoPlayerOptionsLogo,
30+
CloudinaryVideoPlayerPlaylistByTagOptions,
31+
CloudinaryVideoPlayerPlaylistOptions,
32+
CloudinaryVideoPlayerTextTracks,
33+
CloudinaryVideoPlayerTextTracksTrack,
34+
CloudinaryVideoPlayerTextTracksTrackOptions,
35+
CloudinaryVideoPlayerTextTracksTrackOptionsBox,
2736
CloudinaryVideoPlayerTextTracksTrackOptionsGravity,
28-
CloudinaryVideoPlayerTextTracksTrackOptionsTheme
37+
CloudinaryVideoPlayerTextTracksTrackOptionsTheme,
2938
} from "./types/cloudinary-video-player.js";
3039

40+
export type { CloudinaryProductGallery } from "./types/cloudinary-product-gallery.js";
41+
3142
export type {
3243
CloudinaryAssetConfiguration,
3344
CloudinaryAssetConfigurationAuthToken,
3445
CloudinaryAssetConfigurationCloud,
35-
CloudinaryAssetConfigurationUrl
46+
CloudinaryAssetConfigurationUrl,
3647
} from "./types/configuration.js";
37-
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
export interface CloudinaryProductGallery {
2+
// Required parameters
3+
cloudName?: string;
4+
mediaAssets?:
5+
| {
6+
publicId?: string;
7+
tag?: string;
8+
mediaType?: string;
9+
resourceType?: string;
10+
transformation?: object;
11+
thumbnailTransformation?: object;
12+
altText?: string;
13+
videoPlayerSource?: object;
14+
}[]
15+
| string[]; // string[] is a list of publicIDs
16+
container?: string | HTMLElement;
17+
18+
// Widget
19+
analytics?: boolean;
20+
displayProps?: {
21+
mode?: "classic" | "expanded";
22+
spacing?: number;
23+
columns?: number;
24+
topOffset?: number;
25+
bottomOffset?: number;
26+
};
27+
focus?: boolean;
28+
loaderProps?: {
29+
color?: string;
30+
opacity?: number;
31+
style?: "cloudinary" | "circle" | "custom";
32+
url?: string;
33+
};
34+
placeholderImage?: boolean;
35+
sort?: "none" | "asc" | "desc";
36+
sortProps?: {
37+
source?: string;
38+
id?: string;
39+
direction?: string;
40+
};
41+
themeProps?: {
42+
primary?: string; // Default: "#FFFFFF"
43+
onPrimary?: string; // Default: "#000000"
44+
active?: string; // Default: "#0078FF"
45+
};
46+
viewportBreakpoints?: {
47+
breakpoint: number; // Required
48+
[key: string]: any; // Other configuration parameters to override
49+
}[];
50+
51+
// Main viewer parameters
52+
accessibilityProps?: {
53+
mediaAltSource?: string;
54+
mediaAltId?: string;
55+
};
56+
ar3dProps?: {
57+
shadows?: boolean;
58+
showAR?: boolean;
59+
};
60+
aspectRatio?:
61+
| "square"
62+
| "1:1"
63+
| "3:4"
64+
| "4:3"
65+
| "4:6"
66+
| "6:4"
67+
| "5:7"
68+
| "7:5"
69+
| "5:8"
70+
| "8:5"
71+
| "9:16"
72+
| "16:9";
73+
borderColor?: string;
74+
borderWidth?: number;
75+
imageBreakpoint?: number;
76+
videoBreakpoint?: number;
77+
preload?: string[];
78+
radius?: number;
79+
spinProps?: {
80+
animate?: "none" | "start" | "end" | "both";
81+
spinDirection?: "clockwise" | "counter-clockwise";
82+
disableZoom?: boolean;
83+
showTip?: "always" | "never" | "touch";
84+
tipPosition?: "top" | "center" | "bottom";
85+
tipText?: string; // Default: "Drag to rotate"
86+
tipTouchText?: string; // Default: "Swipe to rotate"
87+
};
88+
startIndex?: number;
89+
tipProps?: {
90+
textColor?: string;
91+
color?: string;
92+
radius?: number;
93+
opacity?: number;
94+
};
95+
transition?: "slide" | "fade" | "none";
96+
videoProps?: {
97+
controls?: string;
98+
sound?: boolean;
99+
autoplay?: boolean;
100+
loop?: boolean;
101+
playerType?: string;
102+
};
103+
zoom?: boolean;
104+
zoomProps?: any;
105+
zoomPopupProps?: {
106+
backdropColor?: string;
107+
backdropOpacity?: number;
108+
zIndex?: number;
109+
};
110+
111+
// Carousel parameters
112+
carouselLocation?: "left" | "right" | "top" | "bottom";
113+
carouselOffset?: number;
114+
carouselStyle?: "none" | "thumbnails" | "indicators";
115+
indicatorProps?: {
116+
color?: string;
117+
selectedColor?: string;
118+
shape?: "round" | "square" | "radius";
119+
size?: number;
120+
spacing?: number;
121+
sticky?: boolean;
122+
};
123+
thumbnailProps?: any;
124+
125+
// Navigation parameters
126+
navigation?: "none" | "always" | "mouseover";
127+
navigationButtonProps?: {
128+
shape?: "none" | "round" | "square" | "radius" | "rectangle";
129+
iconColor?: string;
130+
color?: string;
131+
size?: number;
132+
};
133+
navigationOffset?: number;
134+
navigationPosition?: "inside" | "outside" | "offset";
135+
}

packages/types/src/types/cloudinary-upload-widget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CloudinaryResource } from './resources.js';
1+
import type { CloudinaryResource } from "./resources.js";
22

33
// Sourced from: https://cloudinary.com/documentation/upload_widget_reference
44

packages/types/src/types/cloudinary-video-player.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ export interface CloudinaryVideoPlayer {
306306
videojs: {
307307
cloudinary: {
308308
dispose: () => void;
309-
}
310-
}
311-
309+
};
310+
};
312311
}
313312

314313
export interface CloudinaryVideoPlayerOptionsLogo {
@@ -366,8 +365,10 @@ export interface CloudinaryVideoPlayerTextTracksTrack {
366365

367366
export interface CloudinaryVideoPlayerTextTracks {
368367
captions?: CloudinaryVideoPlayerTextTracksTrack;
369-
options?: CloudinaryVideoPlayerTextTracksTrackOptions
370-
subtitles?: CloudinaryVideoPlayerTextTracksTrack | Array<CloudinaryVideoPlayerTextTracksTrack>;
368+
options?: CloudinaryVideoPlayerTextTracksTrackOptions;
369+
subtitles?:
370+
| CloudinaryVideoPlayerTextTracksTrack
371+
| Array<CloudinaryVideoPlayerTextTracksTrack>;
371372
}
372373

373374
export interface CloudinaryVideoPlayerOptions
@@ -442,7 +443,9 @@ export interface CloudinaryVideoPlayerOptions
442443
};
443444
analytics?: boolean;
444445
allowUsageReport?: boolean;
445-
cloudinaryAnalytics?: boolean | CloudinaryVideoPlayerOptionsCloudinaryAnalytics;
446+
cloudinaryAnalytics?:
447+
| boolean
448+
| CloudinaryVideoPlayerOptionsCloudinaryAnalytics;
446449

447450
// ------------ Delivery ------------
448451
cloud_name?: string;
@@ -495,4 +498,4 @@ export interface CloudinaryVideoPlayerOptionsCloudinaryAnalyticsCustomData {
495498
customData3?: string;
496499
customData4?: string;
497500
customData5?: string;
498-
}
501+
}

packages/types/src/types/configuration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ export interface CloudinaryAssetConfigurationUrl {
2323
useRootPath?: boolean;
2424
forceVersion?: boolean;
2525
queryParams?: Record<string, string | number | boolean> | string;
26-
};
26+
}
2727

2828
export interface CloudinaryAssetConfigurationCloud {
2929
cloudName?: string;
3030
apiKey?: string;
3131
apiSecret?: string;
3232
authToken?: CloudinaryAssetConfigurationAuthToken;
33-
};
33+
}
3434

3535
export interface CloudinaryAssetConfiguration {
3636
cloud?: CloudinaryAssetConfigurationCloud;
3737
url?: CloudinaryAssetConfigurationUrl;
38-
}
38+
}

packages/types/src/types/resources.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
export type CloudinaryResourceAccessMode = "public" | "authenticated" | (string & {});
2-
export type CloudinaryResourceResourceType = "image" | "video" | "raw" | "auto" | (string & {});
1+
export type CloudinaryResourceAccessMode =
2+
| "public"
3+
| "authenticated"
4+
| (string & {});
5+
export type CloudinaryResourceResourceType =
6+
| "image"
7+
| "video"
8+
| "raw"
9+
| "auto"
10+
| (string & {});
311
export type CloudinaryResourceDeliveryType =
412
| "animoto"
513
| "asset"
@@ -68,4 +76,4 @@ export interface CloudinaryResource {
6876
version: number;
6977
width: number;
7078
[key: string]: unknown;
71-
}
79+
}

0 commit comments

Comments
 (0)