@remotion/serverless-client 4.0.261
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/.turbo/turbo-make.log +6 -0
- package/LICENSE.md +49 -0
- package/README.md +5 -0
- package/bundle.ts +15 -0
- package/dist/await.d.ts +1 -0
- package/dist/await.js +2 -0
- package/dist/calculate-chunk-times.d.ts +5 -0
- package/dist/calculate-chunk-times.js +29 -0
- package/dist/compress-props.d.ts +30 -0
- package/dist/compress-props.js +97 -0
- package/dist/constants.d.ts +314 -0
- package/dist/constants.js +64 -0
- package/dist/docs-url.d.ts +1 -0
- package/dist/docs-url.js +4 -0
- package/dist/error-category.d.ts +3 -0
- package/dist/error-category.js +16 -0
- package/dist/esm/index.mjs +3467 -0
- package/dist/estimate-price-from-bucket.d.ts +15 -0
- package/dist/estimate-price-from-bucket.js +31 -0
- package/dist/expected-out-name.d.ts +10 -0
- package/dist/expected-out-name.js +53 -0
- package/dist/format-costs-info.d.ts +2 -0
- package/dist/format-costs-info.js +23 -0
- package/dist/get-custom-out-name.d.ts +7 -0
- package/dist/get-custom-out-name.js +33 -0
- package/dist/get-files-in-folder.d.ts +5 -0
- package/dist/get-files-in-folder.js +2 -0
- package/dist/get-or-create-bucket.d.ts +23 -0
- package/dist/get-or-create-bucket.js +44 -0
- package/dist/get-overall-progress-from-storage.d.ts +11 -0
- package/dist/get-overall-progress-from-storage.js +25 -0
- package/dist/get-overall-progress.d.ts +9 -0
- package/dist/get-overall-progress.js +23 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +105 -0
- package/dist/input-props-keys.d.ts +2 -0
- package/dist/input-props-keys.js +11 -0
- package/dist/inspect-error.d.ts +4 -0
- package/dist/inspect-error.js +39 -0
- package/dist/make-bucket-name.d.ts +3 -0
- package/dist/make-bucket-name.js +7 -0
- package/dist/make-timeout-error.d.ts +13 -0
- package/dist/make-timeout-error.js +32 -0
- package/dist/make-timeout-message.d.ts +12 -0
- package/dist/make-timeout-message.js +76 -0
- package/dist/min-max.d.ts +2 -0
- package/dist/min-max.js +33 -0
- package/dist/most-expensive-chunks.d.ts +13 -0
- package/dist/most-expensive-chunks.js +28 -0
- package/dist/overall-render-progress.d.ts +24 -0
- package/dist/overall-render-progress.js +2 -0
- package/dist/progress.d.ts +16 -0
- package/dist/progress.js +258 -0
- package/dist/provider-implementation.d.ts +193 -0
- package/dist/provider-implementation.js +2 -0
- package/dist/render-has-audio-video.d.ts +6 -0
- package/dist/render-has-audio-video.js +21 -0
- package/dist/render-metadata.d.ts +45 -0
- package/dist/render-metadata.js +2 -0
- package/dist/render-progress.d.ts +51 -0
- package/dist/render-progress.js +2 -0
- package/dist/return-values.d.ts +38 -0
- package/dist/return-values.js +2 -0
- package/dist/serialize-artifact.d.ts +9 -0
- package/dist/serialize-artifact.js +37 -0
- package/dist/stream-to-string.d.ts +2 -0
- package/dist/stream-to-string.js +14 -0
- package/dist/streaming/streaming.d.ts +101 -0
- package/dist/streaming/streaming.js +61 -0
- package/dist/test/dont-contain-forbidden.test.d.ts +1 -0
- package/dist/test/dont-contain-forbidden.test.js +18 -0
- package/dist/test/expected-out-name.test.d.ts +1 -0
- package/dist/test/expected-out-name.test.js +167 -0
- package/dist/test/min-max.test.d.ts +1 -0
- package/dist/test/min-max.test.js +24 -0
- package/dist/test/most-expensive-chunks.test.d.ts +1 -0
- package/dist/test/most-expensive-chunks.test.js +163 -0
- package/dist/truthy.d.ts +3 -0
- package/dist/truthy.js +6 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +2 -0
- package/dist/validate-bucket-name.d.ts +7 -0
- package/dist/validate-bucket-name.js +16 -0
- package/dist/validate-download-behavior.d.ts +1 -0
- package/dist/validate-download-behavior.js +21 -0
- package/dist/validate-frames-per-function.d.ts +4 -0
- package/dist/validate-frames-per-function.js +29 -0
- package/dist/validate-outname.d.ts +9 -0
- package/dist/validate-outname.js +43 -0
- package/dist/validate-privacy.d.ts +2 -0
- package/dist/validate-privacy.js +14 -0
- package/dist/validate-webhook.d.ts +3 -0
- package/dist/validate-webhook.js +16 -0
- package/dist/webhook-types.d.ts +29 -0
- package/dist/webhook-types.js +2 -0
- package/dist/write-error-to-storage.d.ts +24 -0
- package/dist/write-error-to-storage.js +2 -0
- package/eslint.config.mjs +5 -0
- package/package.json +41 -0
- package/src/await.ts +1 -0
- package/src/calculate-chunk-times.ts +42 -0
- package/src/compress-props.ts +171 -0
- package/src/constants.ts +403 -0
- package/src/docs-url.ts +1 -0
- package/src/error-category.ts +14 -0
- package/src/estimate-price-from-bucket.ts +59 -0
- package/src/expected-out-name.ts +83 -0
- package/src/format-costs-info.ts +24 -0
- package/src/get-custom-out-name.ts +44 -0
- package/src/get-files-in-folder.ts +6 -0
- package/src/get-or-create-bucket.ts +79 -0
- package/src/get-overall-progress-from-storage.ts +44 -0
- package/src/get-overall-progress.ts +42 -0
- package/src/index.ts +125 -0
- package/src/input-props-keys.ts +7 -0
- package/src/inspect-error.ts +60 -0
- package/src/make-bucket-name.ts +9 -0
- package/src/make-timeout-error.ts +51 -0
- package/src/make-timeout-message.ts +118 -0
- package/src/min-max.ts +34 -0
- package/src/most-expensive-chunks.ts +46 -0
- package/src/overall-render-progress.ts +30 -0
- package/src/progress.ts +327 -0
- package/src/provider-implementation.ts +261 -0
- package/src/render-has-audio-video.ts +28 -0
- package/src/render-metadata.ts +60 -0
- package/src/render-progress.ts +58 -0
- package/src/return-values.ts +45 -0
- package/src/serialize-artifact.ts +51 -0
- package/src/stream-to-string.ts +14 -0
- package/src/streaming/streaming.ts +148 -0
- package/src/test/dont-contain-forbidden.test.ts +14 -0
- package/src/test/expected-out-name.test.ts +197 -0
- package/src/test/min-max.test.ts +25 -0
- package/src/test/most-expensive-chunks.test.ts +167 -0
- package/src/truthy.ts +5 -0
- package/src/types.ts +77 -0
- package/src/validate-bucket-name.ts +34 -0
- package/src/validate-download-behavior.ts +26 -0
- package/src/validate-frames-per-function.ts +54 -0
- package/src/validate-outname.ts +63 -0
- package/src/validate-privacy.ts +20 -0
- package/src/validate-webhook.ts +18 -0
- package/src/webhook-types.ts +36 -0
- package/src/write-error-to-storage.ts +23 -0
- package/tsconfig.json +18 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
|
+
const most_expensive_chunks_1 = require("../most-expensive-chunks");
|
|
5
|
+
(0, bun_test_1.test)('Should calculate most expensive chunks', () => {
|
|
6
|
+
const most = (0, most_expensive_chunks_1.getMostExpensiveChunks)({
|
|
7
|
+
parsedTimings: [
|
|
8
|
+
{
|
|
9
|
+
chunk: 0,
|
|
10
|
+
rendered: 1000,
|
|
11
|
+
start: 0,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
chunk: 1,
|
|
15
|
+
rendered: 4000,
|
|
16
|
+
start: 2000,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
chunk: 2,
|
|
20
|
+
rendered: 5000,
|
|
21
|
+
start: 2000,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
chunk: 3,
|
|
25
|
+
rendered: 3000,
|
|
26
|
+
start: 2000,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
chunk: 4,
|
|
30
|
+
rendered: 100000,
|
|
31
|
+
start: 2000,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
chunk: 5,
|
|
35
|
+
rendered: 2001,
|
|
36
|
+
start: 2000,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
chunk: 6,
|
|
40
|
+
rendered: 2500,
|
|
41
|
+
start: 2000,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
framesPerFunction: 10,
|
|
45
|
+
firstFrame: 0,
|
|
46
|
+
lastFrame: 99,
|
|
47
|
+
});
|
|
48
|
+
(0, bun_test_1.expect)(most).toEqual([
|
|
49
|
+
{ timeInMilliseconds: 98000, chunk: 4, frameRange: [40, 49] },
|
|
50
|
+
{ timeInMilliseconds: 3000, chunk: 2, frameRange: [20, 29] },
|
|
51
|
+
{ timeInMilliseconds: 2000, chunk: 1, frameRange: [10, 19] },
|
|
52
|
+
{ timeInMilliseconds: 1000, chunk: 0, frameRange: [0, 9] },
|
|
53
|
+
{ timeInMilliseconds: 1000, chunk: 3, frameRange: [30, 39] },
|
|
54
|
+
]);
|
|
55
|
+
});
|
|
56
|
+
(0, bun_test_1.test)('Render starting from frame 10 should have correct offset', () => {
|
|
57
|
+
const framesPerFunction = 10;
|
|
58
|
+
const firstFrame = 10;
|
|
59
|
+
const lastFrame = 99;
|
|
60
|
+
const most = (0, most_expensive_chunks_1.getMostExpensiveChunks)({
|
|
61
|
+
parsedTimings: [
|
|
62
|
+
{
|
|
63
|
+
chunk: 0,
|
|
64
|
+
rendered: 1000,
|
|
65
|
+
start: 0,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
chunk: 1,
|
|
69
|
+
rendered: 4000,
|
|
70
|
+
start: 2000,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
chunk: 2,
|
|
74
|
+
rendered: 5000,
|
|
75
|
+
start: 2000,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
chunk: 3,
|
|
79
|
+
rendered: 3000,
|
|
80
|
+
start: 2000,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
chunk: 4,
|
|
84
|
+
rendered: 100000,
|
|
85
|
+
start: 2000,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
chunk: 5,
|
|
89
|
+
rendered: 2001,
|
|
90
|
+
start: 2000,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
chunk: 6,
|
|
94
|
+
rendered: 2500,
|
|
95
|
+
start: 2000,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
framesPerFunction,
|
|
99
|
+
firstFrame,
|
|
100
|
+
lastFrame,
|
|
101
|
+
});
|
|
102
|
+
(0, bun_test_1.expect)(most).toEqual([
|
|
103
|
+
{ timeInMilliseconds: 98000, chunk: 4, frameRange: [50, 59] },
|
|
104
|
+
{ timeInMilliseconds: 3000, chunk: 2, frameRange: [30, 39] },
|
|
105
|
+
{ timeInMilliseconds: 2000, chunk: 1, frameRange: [20, 29] },
|
|
106
|
+
{ timeInMilliseconds: 1000, chunk: 0, frameRange: [10, 19] },
|
|
107
|
+
{ timeInMilliseconds: 1000, chunk: 3, frameRange: [40, 49] },
|
|
108
|
+
]);
|
|
109
|
+
});
|
|
110
|
+
(0, bun_test_1.test)('Render starting from frame 10 and last chunk in most expensive should be corret', () => {
|
|
111
|
+
const framesPerFunction = 10;
|
|
112
|
+
const firstFrame = 10;
|
|
113
|
+
const lastFrame = 79;
|
|
114
|
+
const most = (0, most_expensive_chunks_1.getMostExpensiveChunks)({
|
|
115
|
+
parsedTimings: [
|
|
116
|
+
{
|
|
117
|
+
chunk: 0,
|
|
118
|
+
rendered: 1000,
|
|
119
|
+
start: 0,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
chunk: 1,
|
|
123
|
+
rendered: 4000,
|
|
124
|
+
start: 2000,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
chunk: 2,
|
|
128
|
+
rendered: 5000,
|
|
129
|
+
start: 2000,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
chunk: 3,
|
|
133
|
+
rendered: 3000,
|
|
134
|
+
start: 2000,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
chunk: 4,
|
|
138
|
+
rendered: 100000,
|
|
139
|
+
start: 2000,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
chunk: 5,
|
|
143
|
+
rendered: 2001,
|
|
144
|
+
start: 2000,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
chunk: 6,
|
|
148
|
+
rendered: 125000,
|
|
149
|
+
start: 2000,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
framesPerFunction,
|
|
153
|
+
firstFrame,
|
|
154
|
+
lastFrame,
|
|
155
|
+
});
|
|
156
|
+
(0, bun_test_1.expect)(most).toEqual([
|
|
157
|
+
{ timeInMilliseconds: 123000, chunk: 6, frameRange: [70, 79] },
|
|
158
|
+
{ timeInMilliseconds: 98000, chunk: 4, frameRange: [50, 59] },
|
|
159
|
+
{ timeInMilliseconds: 3000, chunk: 2, frameRange: [30, 39] },
|
|
160
|
+
{ timeInMilliseconds: 2000, chunk: 1, frameRange: [20, 29] },
|
|
161
|
+
{ timeInMilliseconds: 1000, chunk: 0, frameRange: [10, 19] },
|
|
162
|
+
]);
|
|
163
|
+
});
|
package/dist/truthy.d.ts
ADDED
package/dist/truthy.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ServerlessPayloads, ServerlessRoutines } from './constants';
|
|
2
|
+
export interface CloudProvider<Region extends string = string, ReceivedArtifactType extends Record<string, unknown> = Record<string, unknown>, CreateFunctionSpecifics extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
|
+
type: string;
|
|
4
|
+
region: Region;
|
|
5
|
+
receivedArtifactType: ReceivedArtifactType;
|
|
6
|
+
creationFunctionOptions: CreateFunctionSpecifics;
|
|
7
|
+
}
|
|
8
|
+
export type ReceivedArtifact<Provider extends CloudProvider> = {
|
|
9
|
+
filename: string;
|
|
10
|
+
sizeInBytes: number;
|
|
11
|
+
s3Url: string;
|
|
12
|
+
s3Key: string;
|
|
13
|
+
} & Provider['receivedArtifactType'];
|
|
14
|
+
export type CostsInfo = {
|
|
15
|
+
accruedSoFar: number;
|
|
16
|
+
displayCost: string;
|
|
17
|
+
currency: string;
|
|
18
|
+
disclaimer: string;
|
|
19
|
+
};
|
|
20
|
+
export type RenderStillFunctionResponsePayload<Provider extends CloudProvider> = {
|
|
21
|
+
type: 'success';
|
|
22
|
+
output: string;
|
|
23
|
+
outKey: string;
|
|
24
|
+
size: number;
|
|
25
|
+
bucketName: string;
|
|
26
|
+
sizeInBytes: number;
|
|
27
|
+
estimatedPrice: CostsInfo;
|
|
28
|
+
renderId: string;
|
|
29
|
+
receivedArtifacts: ReceivedArtifact<Provider>[];
|
|
30
|
+
};
|
|
31
|
+
export type ChunkRetry = {
|
|
32
|
+
chunk: number;
|
|
33
|
+
attempt: number;
|
|
34
|
+
time: number;
|
|
35
|
+
};
|
|
36
|
+
export type ParsedTiming = {
|
|
37
|
+
chunk: number;
|
|
38
|
+
start: number;
|
|
39
|
+
rendered: number;
|
|
40
|
+
};
|
|
41
|
+
export type CallFunctionOptions<T extends ServerlessRoutines, Provider extends CloudProvider> = {
|
|
42
|
+
functionName: string;
|
|
43
|
+
type: T;
|
|
44
|
+
payload: ServerlessPayloads<Provider>[T];
|
|
45
|
+
region: Provider['region'];
|
|
46
|
+
timeoutInTest: number;
|
|
47
|
+
};
|
|
48
|
+
export type ObjectChunkTimingData = {
|
|
49
|
+
chunk: number;
|
|
50
|
+
frameRange: [number, number];
|
|
51
|
+
startDate: number;
|
|
52
|
+
timings: {
|
|
53
|
+
[key: number]: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateBucketName = void 0;
|
|
4
|
+
const validateBucketName = ({ bucketName, bucketNamePrefix, options, }) => {
|
|
5
|
+
if (typeof bucketName !== 'string') {
|
|
6
|
+
throw new TypeError(`'bucketName' must be a string, but is ${JSON.stringify(bucketName)}`);
|
|
7
|
+
}
|
|
8
|
+
if (options.mustStartWithRemotion &&
|
|
9
|
+
!bucketName.startsWith(bucketNamePrefix)) {
|
|
10
|
+
throw new Error(`The bucketName parameter must start with ${bucketNamePrefix}.`);
|
|
11
|
+
}
|
|
12
|
+
if (!bucketName.match(/^(?=^.{3,63}$)(?!^(\d+\.)+\d+$)(^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$)/)) {
|
|
13
|
+
throw new Error(`The bucket ${bucketName} `);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.validateBucketName = validateBucketName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateDownloadBehavior: (downloadBehavior: unknown) => null | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateDownloadBehavior = void 0;
|
|
4
|
+
const validateDownloadBehavior = (downloadBehavior) => {
|
|
5
|
+
if (downloadBehavior === null || downloadBehavior === undefined) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
if (typeof downloadBehavior !== 'object') {
|
|
9
|
+
throw new Error('downloadBehavior must be null or an object');
|
|
10
|
+
}
|
|
11
|
+
const behavior = downloadBehavior;
|
|
12
|
+
if (behavior.type !== 'download' && behavior.type !== 'play-in-browser') {
|
|
13
|
+
throw new Error('Download behavior must be either "download" or "play-in-browser"');
|
|
14
|
+
}
|
|
15
|
+
if (behavior.type === 'download') {
|
|
16
|
+
if (typeof behavior.fileName !== 'string' && behavior.fileName !== null) {
|
|
17
|
+
throw new Error('If "downloadBehavior.type" is "download", then fileName must be "null" or a string');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.validateDownloadBehavior = validateDownloadBehavior;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFramesPerFunction = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const validateFramesPerFunction = ({ framesPerFunction, durationInFrames, }) => {
|
|
6
|
+
if (framesPerFunction === null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (framesPerFunction === undefined) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (typeof framesPerFunction !== 'number') {
|
|
13
|
+
throw new TypeError(`'framesPerLambda' needs to be a number, passed ${JSON.stringify(framesPerFunction)}`);
|
|
14
|
+
}
|
|
15
|
+
if (!Number.isFinite(framesPerFunction)) {
|
|
16
|
+
throw new TypeError(`'framesPerLambda' needs to be finite, passed ${framesPerFunction}`);
|
|
17
|
+
}
|
|
18
|
+
if (Number.isNaN(framesPerFunction)) {
|
|
19
|
+
throw new TypeError(`'framesPerLambda' needs to be NaN, passed ${framesPerFunction}`);
|
|
20
|
+
}
|
|
21
|
+
if (framesPerFunction % 1 !== 0) {
|
|
22
|
+
throw new TypeError(`'framesPerLambda' needs to be an integer, passed ${framesPerFunction}`);
|
|
23
|
+
}
|
|
24
|
+
const effectiveMinimum = Math.min(constants_1.MINIMUM_FRAMES_PER_FUNCTIONS, durationInFrames);
|
|
25
|
+
if (framesPerFunction < effectiveMinimum) {
|
|
26
|
+
throw new TypeError(`The framesPerLambda needs to be at least ${effectiveMinimum}, but is ${framesPerFunction}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.validateFramesPerFunction = validateFramesPerFunction;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AudioCodec, Codec } from '@remotion/renderer';
|
|
2
|
+
import type { OutNameInputWithoutCredentials } from './constants';
|
|
3
|
+
export declare const validateOutname: ({ outName, codec, audioCodecSetting, separateAudioTo, bucketNamePrefix, }: {
|
|
4
|
+
outName: OutNameInputWithoutCredentials | undefined | null;
|
|
5
|
+
codec: Codec | null;
|
|
6
|
+
audioCodecSetting: AudioCodec | null;
|
|
7
|
+
separateAudioTo: string | null;
|
|
8
|
+
bucketNamePrefix: string;
|
|
9
|
+
}) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateOutname = void 0;
|
|
4
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
5
|
+
const validate_bucket_name_1 = require("./validate-bucket-name");
|
|
6
|
+
const validateS3Key = (s3Key) => {
|
|
7
|
+
if (typeof s3Key !== 'string') {
|
|
8
|
+
throw new TypeError('The S3 key must be a string. Passed an object of type ' + typeof s3Key);
|
|
9
|
+
}
|
|
10
|
+
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html
|
|
11
|
+
if (!s3Key.match(/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g)) {
|
|
12
|
+
throw new Error("The S3 Key must match the RegExp `/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g`. You passed: " +
|
|
13
|
+
s3Key +
|
|
14
|
+
'. Check for invalid characters.');
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const validateOutname = ({ outName, codec, audioCodecSetting, separateAudioTo, bucketNamePrefix, }) => {
|
|
18
|
+
if (typeof outName === 'undefined' || outName === null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (typeof outName !== 'string') {
|
|
22
|
+
validateS3Key(outName.key);
|
|
23
|
+
(0, validate_bucket_name_1.validateBucketName)({
|
|
24
|
+
bucketName: outName.bucketName,
|
|
25
|
+
bucketNamePrefix,
|
|
26
|
+
options: {
|
|
27
|
+
mustStartWithRemotion: false,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (codec) {
|
|
33
|
+
pure_1.NoReactAPIs.validateOutputFilename({
|
|
34
|
+
codec,
|
|
35
|
+
audioCodecSetting,
|
|
36
|
+
extension: pure_1.NoReactAPIs.getExtensionOfFilename(outName),
|
|
37
|
+
preferLossless: false,
|
|
38
|
+
separateAudioTo,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
validateS3Key(outName);
|
|
42
|
+
};
|
|
43
|
+
exports.validateOutname = validateOutname;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePrivacy = validatePrivacy;
|
|
4
|
+
function validatePrivacy(privacy, allowPrivate) {
|
|
5
|
+
if (typeof privacy !== 'string') {
|
|
6
|
+
throw new TypeError('Privacy must be a string');
|
|
7
|
+
}
|
|
8
|
+
if (!allowPrivate && privacy === 'private') {
|
|
9
|
+
throw new TypeError('Privacy must be either "public" or "no-acl"');
|
|
10
|
+
}
|
|
11
|
+
if (privacy !== 'private' && privacy !== 'public' && privacy !== 'no-acl') {
|
|
12
|
+
throw new TypeError('Privacy must be either "private", "public" or "no-acl"');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateWebhook = exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE = void 0;
|
|
4
|
+
exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE = 1024;
|
|
5
|
+
const validateWebhook = (webhook) => {
|
|
6
|
+
if (typeof webhook === 'undefined' || webhook === null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (webhook.customData) {
|
|
10
|
+
const size = JSON.stringify(webhook.customData).length;
|
|
11
|
+
if (size > exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE) {
|
|
12
|
+
throw new Error(`Webhook "customData" must be less than ${exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE} bytes. Current size: ${size} bytes.`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.validateWebhook = validateWebhook;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AfterRenderCost } from './constants';
|
|
2
|
+
import type { EnhancedErrorInfo } from './write-error-to-storage';
|
|
3
|
+
type StaticWebhookPayload = {
|
|
4
|
+
renderId: string;
|
|
5
|
+
expectedBucketOwner: string;
|
|
6
|
+
bucketName: string;
|
|
7
|
+
customData: Record<string, unknown> | null;
|
|
8
|
+
};
|
|
9
|
+
export type WebhookErrorPayload = StaticWebhookPayload & {
|
|
10
|
+
type: 'error';
|
|
11
|
+
errors: {
|
|
12
|
+
message: string;
|
|
13
|
+
name: string;
|
|
14
|
+
stack: string;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
export type WebhookSuccessPayload = StaticWebhookPayload & {
|
|
18
|
+
type: 'success';
|
|
19
|
+
lambdaErrors: EnhancedErrorInfo[];
|
|
20
|
+
outputUrl: string | undefined;
|
|
21
|
+
outputFile: string | undefined;
|
|
22
|
+
timeToFinish: number | undefined;
|
|
23
|
+
costs: AfterRenderCost;
|
|
24
|
+
};
|
|
25
|
+
export type WebhookTimeoutPayload = StaticWebhookPayload & {
|
|
26
|
+
type: 'timeout';
|
|
27
|
+
};
|
|
28
|
+
export type WebhookPayload = WebhookErrorPayload | WebhookSuccessPayload | WebhookTimeoutPayload;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FileNameAndSize } from './get-files-in-folder';
|
|
2
|
+
export type FunctionErrorInfo = {
|
|
3
|
+
type: 'renderer' | 'browser' | 'stitcher' | 'webhook' | 'artifact';
|
|
4
|
+
message: string;
|
|
5
|
+
name: string;
|
|
6
|
+
stack: string;
|
|
7
|
+
frame: number | null;
|
|
8
|
+
chunk: number | null;
|
|
9
|
+
isFatal: boolean;
|
|
10
|
+
attempt: number;
|
|
11
|
+
willRetry: boolean;
|
|
12
|
+
totalAttempts: number;
|
|
13
|
+
tmpDir: {
|
|
14
|
+
files: FileNameAndSize[];
|
|
15
|
+
total: number;
|
|
16
|
+
} | null;
|
|
17
|
+
};
|
|
18
|
+
export type EnhancedErrorInfo = FunctionErrorInfo & {
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Will always be an empty string.
|
|
21
|
+
*/
|
|
22
|
+
s3Location: string;
|
|
23
|
+
explanation: string | null;
|
|
24
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"repository": {
|
|
3
|
+
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/serverless-client"
|
|
4
|
+
},
|
|
5
|
+
"name": "@remotion/serverless-client",
|
|
6
|
+
"version": "4.0.261",
|
|
7
|
+
"main": "dist",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"author": "Jonny Burger <jonny@remotion.dev>",
|
|
10
|
+
"contributors": [],
|
|
11
|
+
"license": "UNLICENSED",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"eslint": "9.19.0",
|
|
21
|
+
"remotion": "4.0.261",
|
|
22
|
+
"@remotion/streaming": "4.0.261",
|
|
23
|
+
"@remotion/renderer": "4.0.261",
|
|
24
|
+
"@remotion/eslint-config-internal": "4.0.261"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
"./package.json": "./package.json",
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"require": "./dist/index.js",
|
|
31
|
+
"module": "./dist/esm/index.mjs",
|
|
32
|
+
"import": "./dist/esm/index.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"lint": "eslint src",
|
|
37
|
+
"formatting": "prettier src --check",
|
|
38
|
+
"test": "bun test src",
|
|
39
|
+
"make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/await.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Await<T> = T extends PromiseLike<infer U> ? U : T;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {max, min} from './min-max';
|
|
2
|
+
import type {ParsedTiming} from './types';
|
|
3
|
+
|
|
4
|
+
const getAbsoluteTime = (parsedTimings: ParsedTiming[]) => {
|
|
5
|
+
if (parsedTimings.length === 0) {
|
|
6
|
+
return 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const allEnds = parsedTimings.map((p) => p.rendered);
|
|
10
|
+
const allStarts = parsedTimings.map((p) => p.start);
|
|
11
|
+
|
|
12
|
+
const biggestEnd = max(allEnds);
|
|
13
|
+
const smallestStart = min(allStarts);
|
|
14
|
+
|
|
15
|
+
return Math.max(0, biggestEnd - smallestStart);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const calculateChunkTimes = ({
|
|
19
|
+
type,
|
|
20
|
+
timings,
|
|
21
|
+
}: {
|
|
22
|
+
type: 'combined-time-for-cost-calculation' | 'absolute-time';
|
|
23
|
+
timings: ParsedTiming[];
|
|
24
|
+
}) => {
|
|
25
|
+
const parsedTimings = timings;
|
|
26
|
+
|
|
27
|
+
const absoluteTime = getAbsoluteTime(parsedTimings);
|
|
28
|
+
|
|
29
|
+
if (type === 'combined-time-for-cost-calculation') {
|
|
30
|
+
const totalEncodingTimings = parsedTimings
|
|
31
|
+
.map((p) => Math.max(0, p.rendered - p.start))
|
|
32
|
+
.reduce((a, b) => a + b, 0);
|
|
33
|
+
|
|
34
|
+
return totalEncodingTimings + absoluteTime;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (type === 'absolute-time') {
|
|
38
|
+
return absoluteTime;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw new Error('invalid time for calculate chunk times');
|
|
42
|
+
};
|