@bytescale/sdk 1.2.0 → 1.4.0
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/browser/cjs/main.js +904 -198
- package/dist/node/cjs/main.js +418 -205
- package/dist/node/esm/main.mjs +424 -207
- package/dist/types/index.d.ts +2 -0
- package/dist/types/private/AuthSessionState.d.ts +13 -0
- package/dist/types/private/ConsoleUtils.d.ts +5 -0
- package/dist/types/private/EnvChecker.d.ts +4 -0
- package/dist/types/private/Mutex.d.ts +16 -0
- package/dist/types/private/TypeUtils.d.ts +2 -0
- package/dist/types/{uploads/private → private}/UploadManagerBase.d.ts +2 -2
- package/dist/types/private/dtos/SetAccessTokenRequestDto.d.ts +6 -0
- package/dist/types/private/dtos/SetAccessTokenResponseDto.d.ts +7 -0
- package/dist/types/private/model/AuthManagerInterface.d.ts +44 -0
- package/dist/types/private/model/AuthSession.d.ts +7 -0
- package/dist/types/private/model/UploadManagerInterface.d.ts +5 -0
- package/dist/types/{uploads/private → private}/model/UploadSourceProcessed.d.ts +1 -1
- package/dist/types/public/browser/AuthManagerBrowser.d.ts +20 -0
- package/dist/types/{uploads/public → public}/browser/UploadManagerBrowser.d.ts +2 -2
- package/dist/types/{uploads/public → public}/browser/index.d.ts +1 -0
- package/dist/types/public/node/AuthManagerNode.d.ts +6 -0
- package/dist/types/{uploads/public → public}/node/UploadManagerNode.d.ts +2 -2
- package/dist/types/{uploads/public → public}/node/index.d.ts +1 -0
- package/dist/types/{uploads/public/shared/Model.d.ts → public/shared/CommonTypes.d.ts} +3 -9
- package/dist/types/public/shared/UrlBuilder.d.ts +32 -0
- package/dist/types/public/shared/UrlBuilderTypes.d.ts +173 -0
- package/dist/types/{generated → public/shared/generated}/apis/FileApi.d.ts +7 -1
- package/dist/types/{generated → public/shared/generated}/models/index.d.ts +6 -10
- package/dist/types/{generated → public/shared/generated}/runtime.d.ts +46 -16
- package/dist/types/public/shared/index.d.ts +4 -0
- package/package.json +2 -2
- package/tests/ChunkedStream.test.ts +1 -1
- package/tests/UrlBuilder.test.ts +168 -0
- package/dist/types/index.browser.d.ts +0 -3
- package/dist/types/index.node.d.ts +0 -3
- package/dist/types/uploads/private/TypeUtils.d.ts +0 -1
- package/dist/types/uploads/private/model/UploadManagerInterface.d.ts +0 -5
- package/dist/types/uploads/public/shared/index.d.ts +0 -1
- /package/dist/types/{uploads/private → private}/NodeChunkedStream.d.ts +0 -0
- /package/dist/types/{uploads/private → private}/StreamUtils.d.ts +0 -0
- /package/dist/types/{uploads/private → private}/model/AddCancellationHandler.d.ts +0 -0
- /package/dist/types/{uploads/private → private}/model/OnPartProgress.d.ts +0 -0
- /package/dist/types/{uploads/private → private}/model/PreUploadInfo.d.ts +0 -0
- /package/dist/types/{uploads/private → private}/model/PutUploadPartResult.d.ts +0 -0
- /package/dist/types/{generated → public/shared/generated}/apis/FolderApi.d.ts +0 -0
- /package/dist/types/{generated → public/shared/generated}/apis/JobApi.d.ts +0 -0
- /package/dist/types/{generated → public/shared/generated}/apis/UploadApi.d.ts +0 -0
- /package/dist/types/{generated → public/shared/generated}/apis/index.d.ts +0 -0
- /package/dist/types/{generated → public/shared/generated}/index.d.ts +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { UrlBuilder } from "../src/public/shared";
|
|
2
|
+
|
|
3
|
+
describe("UrlBuilder", () => {
|
|
4
|
+
test("raw file without params", () => {
|
|
5
|
+
const actual = new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg" });
|
|
6
|
+
const expected = "https://upcdn.io/1234abc/raw/example.jpg";
|
|
7
|
+
expect(actual).toEqual(expected);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test("raw file with one param", () => {
|
|
11
|
+
const actual = new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { auth: true } });
|
|
12
|
+
const expected = "https://upcdn.io/1234abc/raw/example.jpg?auth=true";
|
|
13
|
+
expect(actual).toEqual(expected);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("raw file with multiple params", () => {
|
|
17
|
+
const actual = new UrlBuilder().url({
|
|
18
|
+
accountId: "1234abc",
|
|
19
|
+
filePath: "/example.jpg",
|
|
20
|
+
options: { auth: true, cache: true, version: "42" }
|
|
21
|
+
});
|
|
22
|
+
const expected = "https://upcdn.io/1234abc/raw/example.jpg?auth=true&cache=true&version=42";
|
|
23
|
+
expect(actual).toEqual(expected);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("raw file with rewritten params", () => {
|
|
27
|
+
const actual = new UrlBuilder().url({
|
|
28
|
+
accountId: "1234abc",
|
|
29
|
+
filePath: "/example.jpg",
|
|
30
|
+
options: { auth: true, cache: true, cacheTtl: 100 } // cacheTtl is rewritten to cache_ttl
|
|
31
|
+
});
|
|
32
|
+
const expected = "https://upcdn.io/1234abc/raw/example.jpg?auth=true&cache=true&cache_ttl=100";
|
|
33
|
+
expect(actual).toEqual(expected);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("transformation preset without params", () => {
|
|
37
|
+
const actual = new UrlBuilder().url({
|
|
38
|
+
accountId: "1234abc",
|
|
39
|
+
filePath: "/example.jpg",
|
|
40
|
+
options: { transformation: { type: "preset", preset: "thumbnail" } }
|
|
41
|
+
});
|
|
42
|
+
const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg";
|
|
43
|
+
expect(actual).toEqual(expected);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("transformation preset with one param", () => {
|
|
47
|
+
const actual = new UrlBuilder().url({
|
|
48
|
+
accountId: "1234abc",
|
|
49
|
+
filePath: "/example.jpg",
|
|
50
|
+
options: { transformation: { type: "preset", preset: "thumbnail", params: { artifact: "/foo" } } }
|
|
51
|
+
});
|
|
52
|
+
const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg?artifact=%2Ffoo";
|
|
53
|
+
expect(actual).toEqual(expected);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("transformation preset with multiple params", () => {
|
|
57
|
+
const actual = new UrlBuilder().url({
|
|
58
|
+
accountId: "1234abc",
|
|
59
|
+
filePath: "/example.jpg",
|
|
60
|
+
options: {
|
|
61
|
+
transformation: { type: "preset", preset: "thumbnail", params: { large: false, artifact: "/foo" } }
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg?large=false&artifact=%2Ffoo";
|
|
65
|
+
expect(actual).toEqual(expected);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("transformation preset with rewritten params", () => {
|
|
69
|
+
const actual = new UrlBuilder().url({
|
|
70
|
+
accountId: "1234abc",
|
|
71
|
+
filePath: "/example.jpg",
|
|
72
|
+
options: {
|
|
73
|
+
// cachePermanently is rewritten to cache_perm
|
|
74
|
+
transformation: { type: "preset", preset: "thumbnail", params: { cachePermanently: false, artifact: "/foo" } }
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg?cache_perm=false&artifact=%2Ffoo";
|
|
78
|
+
expect(actual).toEqual(expected);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("transformation API without params", () => {
|
|
82
|
+
const actual = new UrlBuilder().url({
|
|
83
|
+
accountId: "1234abc",
|
|
84
|
+
filePath: "/example.jpg",
|
|
85
|
+
options: {
|
|
86
|
+
transformation: {
|
|
87
|
+
type: "image"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const expected = "https://upcdn.io/1234abc/image/example.jpg";
|
|
92
|
+
expect(actual).toEqual(expected);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("transformation API with one param", () => {
|
|
96
|
+
const actual = new UrlBuilder().url({
|
|
97
|
+
accountId: "1234abc",
|
|
98
|
+
filePath: "/example.jpg",
|
|
99
|
+
options: {
|
|
100
|
+
transformation: {
|
|
101
|
+
type: "image",
|
|
102
|
+
params: {
|
|
103
|
+
w: 42
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const expected = "https://upcdn.io/1234abc/image/example.jpg?w=42";
|
|
109
|
+
expect(actual).toEqual(expected);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("transformation API with a mix of params", () => {
|
|
113
|
+
const actual = new UrlBuilder().url({
|
|
114
|
+
accountId: "1234abc",
|
|
115
|
+
filePath: "/example.jpg",
|
|
116
|
+
options: {
|
|
117
|
+
transformation: {
|
|
118
|
+
type: "image",
|
|
119
|
+
params: {
|
|
120
|
+
w: 42,
|
|
121
|
+
h: 50
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
auth: true
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
const expected = "https://upcdn.io/1234abc/image/example.jpg?auth=true&w=42&h=50";
|
|
128
|
+
expect(actual).toEqual(expected);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("elide null and undefined", () => {
|
|
132
|
+
const actual = new UrlBuilder().url({
|
|
133
|
+
accountId: "1234abc",
|
|
134
|
+
filePath: "/example.jpg",
|
|
135
|
+
options: {
|
|
136
|
+
transformation: {
|
|
137
|
+
type: "image",
|
|
138
|
+
params: {
|
|
139
|
+
w: null,
|
|
140
|
+
h: undefined,
|
|
141
|
+
r: 52
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
auth: true
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const expected = "https://upcdn.io/1234abc/image/example.jpg?auth=true&r=52";
|
|
148
|
+
expect(actual).toEqual(expected);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("custom CNAME", () => {
|
|
152
|
+
const actual = new UrlBuilder({ cdnUrl: "https://example.com" }).url({
|
|
153
|
+
accountId: "1234abc",
|
|
154
|
+
filePath: "/example.jpg",
|
|
155
|
+
options: {
|
|
156
|
+
transformation: {
|
|
157
|
+
type: "image",
|
|
158
|
+
params: {
|
|
159
|
+
w: 42,
|
|
160
|
+
h: 50
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const expected = "https://example.com/1234abc/image/example.jpg?w=42&h=50";
|
|
166
|
+
expect(actual).toEqual(expected);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function assertUnreachable(x: never): never;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Model";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|