@vertesia/workflow 0.65.0 → 0.67.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/lib/cjs/activities/generateOrAssignContentType.js +1 -0
- package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -1
- package/lib/cjs/activities/renditions/generateImageRendition.js +14 -1
- package/lib/cjs/activities/renditions/generateImageRendition.js.map +1 -1
- package/lib/cjs/activities/renditions/generateVideoRendition.js +5 -1
- package/lib/cjs/activities/renditions/generateVideoRendition.js.map +1 -1
- package/lib/cjs/errors.js +1 -60
- package/lib/cjs/errors.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/renditions.js +20 -20
- package/lib/cjs/utils/renditions.js.map +1 -1
- package/lib/cjs/utils/storage.js +55 -0
- package/lib/cjs/utils/storage.js.map +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js.map +1 -1
- package/lib/esm/activities/renditions/generateImageRendition.js +14 -1
- package/lib/esm/activities/renditions/generateImageRendition.js.map +1 -1
- package/lib/esm/activities/renditions/generateVideoRendition.js +5 -1
- package/lib/esm/activities/renditions/generateVideoRendition.js.map +1 -1
- package/lib/esm/errors.js +0 -55
- package/lib/esm/errors.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/renditions.js +20 -20
- package/lib/esm/utils/renditions.js.map +1 -1
- package/lib/esm/utils/storage.js +46 -0
- package/lib/esm/utils/storage.js.map +1 -0
- package/lib/types/activities/renditions/generateImageRendition.d.ts.map +1 -1
- package/lib/types/activities/renditions/generateVideoRendition.d.ts.map +1 -1
- package/lib/types/errors.d.ts +0 -31
- package/lib/types/errors.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/utils/renditions.d.ts +3 -3
- package/lib/types/utils/renditions.d.ts.map +1 -1
- package/lib/types/utils/storage.d.ts +16 -0
- package/lib/types/utils/storage.d.ts.map +1 -0
- package/lib/workflows-bundle.js +427 -358
- package/package.json +7 -6
- package/src/activities/generateOrAssignContentType.ts +1 -0
- package/src/activities/renditions/generateImageRendition.ts +97 -80
- package/src/activities/renditions/generateVideoRendition.ts +6 -1
- package/src/errors.ts +0 -58
- package/src/index.ts +1 -0
- package/src/utils/renditions.ts +24 -21
- package/src/utils/storage.ts +61 -0
package/lib/esm/errors.js
CHANGED
@@ -1,16 +1,4 @@
|
|
1
1
|
import { ApplicationFailure } from "@temporalio/workflow";
|
2
|
-
/**
|
3
|
-
* @deprecated Use {@link DocumentNotFoundError} instead.
|
4
|
-
*/
|
5
|
-
export class NoDocumentFound extends Error {
|
6
|
-
ids;
|
7
|
-
constructor(message, ids) {
|
8
|
-
super(message);
|
9
|
-
this.ids = ids;
|
10
|
-
this.name = "NoDocumentFound";
|
11
|
-
this.ids = ids;
|
12
|
-
}
|
13
|
-
}
|
14
2
|
export class DocumentNotFoundError extends ApplicationFailure {
|
15
3
|
ids;
|
16
4
|
constructor(message, ids) {
|
@@ -18,19 +6,6 @@ export class DocumentNotFoundError extends ApplicationFailure {
|
|
18
6
|
this.ids = ids;
|
19
7
|
}
|
20
8
|
}
|
21
|
-
/**
|
22
|
-
* @deprecated Use {@link ActivityParamNotFoundError} instead.
|
23
|
-
*/
|
24
|
-
export class ActivityParamNotFound extends Error {
|
25
|
-
paramName;
|
26
|
-
activity;
|
27
|
-
constructor(paramName, activity) {
|
28
|
-
super(`Required parameter ${paramName} not found in activity ${activity.name}`);
|
29
|
-
this.paramName = paramName;
|
30
|
-
this.activity = activity;
|
31
|
-
this.name = "ActivityParamNotFound";
|
32
|
-
}
|
33
|
-
}
|
34
9
|
export class ActivityParamNotFoundError extends ApplicationFailure {
|
35
10
|
paramName;
|
36
11
|
activity;
|
@@ -40,19 +15,6 @@ export class ActivityParamNotFoundError extends ApplicationFailure {
|
|
40
15
|
this.activity = activity;
|
41
16
|
}
|
42
17
|
}
|
43
|
-
/**
|
44
|
-
* @deprecated Use {@link ActivityParamInvalidError} instead.
|
45
|
-
*/
|
46
|
-
export class ActivityParamInvalid extends Error {
|
47
|
-
paramName;
|
48
|
-
activity;
|
49
|
-
constructor(paramName, activity, reason) {
|
50
|
-
super(`${paramName} in activity ${activity.name} is invalid${reason ? ` ${reason}` : ""}`);
|
51
|
-
this.paramName = paramName;
|
52
|
-
this.activity = activity;
|
53
|
-
this.name = "ActivityParamInvalid";
|
54
|
-
}
|
55
|
-
}
|
56
18
|
export class ActivityParamInvalidError extends ApplicationFailure {
|
57
19
|
paramName;
|
58
20
|
activity;
|
@@ -62,19 +24,6 @@ export class ActivityParamInvalidError extends ApplicationFailure {
|
|
62
24
|
this.activity = activity;
|
63
25
|
}
|
64
26
|
}
|
65
|
-
/**
|
66
|
-
* @deprecated Use {@link WorkflowParamNotFoundError} instead.
|
67
|
-
*/
|
68
|
-
export class WorkflowParamNotFound extends Error {
|
69
|
-
paramName;
|
70
|
-
workflow;
|
71
|
-
constructor(paramName, workflow) {
|
72
|
-
super(`Required parameter ${paramName} not found in workflow ${workflow?.name}`);
|
73
|
-
this.paramName = paramName;
|
74
|
-
this.workflow = workflow;
|
75
|
-
this.name = "WorkflowParamNotFound";
|
76
|
-
}
|
77
|
-
}
|
78
27
|
export class WorkflowParamNotFoundError extends ApplicationFailure {
|
79
28
|
paramName;
|
80
29
|
workflow;
|
@@ -85,13 +34,9 @@ export class WorkflowParamNotFoundError extends ApplicationFailure {
|
|
85
34
|
}
|
86
35
|
}
|
87
36
|
export const WF_NON_RETRYABLE_ERRORS = [
|
88
|
-
"NoDocumentFound",
|
89
37
|
"DocumentNotFoundError",
|
90
|
-
"ActivityParamInvalid",
|
91
38
|
"ActivityParamInvalidError",
|
92
|
-
"ActivityParamNotFound",
|
93
39
|
"ActivityParamNotFoundError",
|
94
|
-
"WorkflowParamNotFound",
|
95
40
|
"WorkflowParamNotFoundError",
|
96
41
|
];
|
97
42
|
//# sourceMappingURL=errors.js.map
|
package/lib/esm/errors.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,MAAM,OAAO,qBAAsB,SAAQ,kBAAkB;IACrB;IAApC,YAAY,OAAe,EAAS,GAAc;QAC9C,KAAK,CACD,OAAO,EACP,uBAAuB,EACvB,IAAI,CACP,CAAA;QAL+B,QAAG,GAAH,GAAG,CAAW;IAMlD,CAAC;CACJ;AAED,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAEnD;IACA;IAFX,YACW,SAAiB,EACjB,QAAyB;QAEhC,KAAK,CACD,sBAAsB,SAAS,0BAA0B,QAAQ,CAAC,IAAI,EAAE,EACxE,4BAA4B,EAC5B,IAAI,CACP,CAAC;QAPK,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAiB;IAOpC,CAAC;CACJ;AAED,MAAM,OAAO,yBAA0B,SAAQ,kBAAkB;IAElD;IACA;IAFX,YACW,SAAiB,EACjB,QAAyB,EAChC,MAAe;QAEf,KAAK,CACD,GAAG,SAAS,gBAAgB,QAAQ,CAAC,IAAI,cAAc,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EACnF,2BAA2B,EAC3B,IAAI,CACP,CAAC;QARK,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAiB;IAQpC,CAAC;CACJ;AAED,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAEnD;IACA;IAFX,YACW,SAAiB,EACjB,QAA0B;QAEjC,KAAK,CACD,sBAAsB,SAAS,0BAA0B,QAAQ,EAAE,IAAI,EAAE,EACzE,4BAA4B,EAC5B,IAAI,CACP,CAAC;QAPK,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAkB;IAOrC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC,uBAAuB;IACvB,2BAA2B;IAC3B,4BAA4B;IAC5B,4BAA4B;CAC/B,CAAC"}
|
package/lib/esm/index.js
CHANGED
@@ -30,5 +30,6 @@ export * from "./utils/client.js";
|
|
30
30
|
export * from "./utils/memory.js";
|
31
31
|
export * from "./utils/tokens.js";
|
32
32
|
export * from "./utils/renditions.js";
|
33
|
+
export * from "./utils/storage.js";
|
33
34
|
export * from "./conversion/image.js";
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oFAAoF;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,cAAc,uDAAuD,CAAC;AAEtE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,mEAAmE,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oFAAoF;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,cAAc,uDAAuD,CAAC;AAEtE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,mEAAmE,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,uBAAuB,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { log } from "@temporalio/activity";
|
2
|
-
import { imageResizer } from "../conversion/image.js";
|
3
|
-
import fs from "fs";
|
4
2
|
import { NodeStreamSource } from "@vertesia/client/node";
|
5
|
-
import
|
3
|
+
import fs from "fs";
|
4
|
+
import pLimit from 'p-limit';
|
5
|
+
import { imageResizer } from "../conversion/image.js";
|
6
6
|
/**
|
7
7
|
* Get the path for all files for a rendition
|
8
8
|
* @param objectId
|
@@ -10,33 +10,33 @@ import path from "path";
|
|
10
10
|
* @param pageNumber
|
11
11
|
* @returns
|
12
12
|
*/
|
13
|
-
export function getRenditionsPath(
|
14
|
-
const path = `renditions/${
|
13
|
+
export function getRenditionsPath(contentEtag, params) {
|
14
|
+
const path = `renditions/${contentEtag}/${params.max_hw}`;
|
15
15
|
return path;
|
16
16
|
}
|
17
17
|
/**
|
18
18
|
* Get a specific page path for a rendition
|
19
19
|
*/
|
20
|
-
export function getRenditionPagePath(
|
21
|
-
//if number, pad to
|
20
|
+
export function getRenditionPagePath(contentEtag, params, pageNumber = 0) {
|
21
|
+
//if number, pad to 4 char
|
22
22
|
if (typeof pageNumber === "number") {
|
23
|
-
pageNumber = String(pageNumber).padStart(
|
23
|
+
pageNumber = String(pageNumber).padStart(4, "0");
|
24
24
|
}
|
25
|
-
const path = getRenditionsPath(
|
25
|
+
const path = getRenditionsPath(contentEtag, params);
|
26
26
|
const pagePath = `${path}/${pageNumber}.${params.format}`;
|
27
27
|
return pagePath;
|
28
28
|
}
|
29
29
|
/**
|
30
30
|
* Upload Rendition page to the cloud
|
31
31
|
*/
|
32
|
-
export async function uploadRenditionPages(client,
|
33
|
-
log.info(`Uploading rendition for ${
|
34
|
-
const
|
35
|
-
|
36
|
-
const pageId = getRenditionPagePath(
|
32
|
+
export async function uploadRenditionPages(client, contentEtag, files, params, concurrency) {
|
33
|
+
log.info(`Uploading rendition for etag ${contentEtag} with ${files.length} pages (max_hw: ${params.max_hw}, format: ${params.format})`, { files });
|
34
|
+
const limit = pLimit(concurrency ?? 20);
|
35
|
+
const uploads = files.map((file, i) => limit(async () => {
|
36
|
+
const pageId = getRenditionPagePath(contentEtag, params, i);
|
37
37
|
let resizedImagePath = null;
|
38
38
|
try {
|
39
|
-
log.info(`Resizing image for ${
|
39
|
+
log.info(`Resizing image for ${contentEtag} page ${i}`, {
|
40
40
|
file,
|
41
41
|
params,
|
42
42
|
});
|
@@ -47,7 +47,7 @@ export async function uploadRenditionPages(client, objectId, files, params) {
|
|
47
47
|
const format = "image/" + params.format;
|
48
48
|
const fileId = pageId.split("/").pop() ?? pageId;
|
49
49
|
const source = new NodeStreamSource(fileStream, fileId, format, pageId);
|
50
|
-
log.info(`Uploading rendition for ${
|
50
|
+
log.info(`Uploading rendition for ${contentEtag} page ${i} with max_hw: ${params.max_hw} and format: ${params.format}`, {
|
51
51
|
resizedImagePath,
|
52
52
|
fileId,
|
53
53
|
format,
|
@@ -56,25 +56,25 @@ export async function uploadRenditionPages(client, objectId, files, params) {
|
|
56
56
|
const result = await client.files
|
57
57
|
.uploadFile(source)
|
58
58
|
.catch((err) => {
|
59
|
-
log.error(`Failed to upload rendition for ${
|
59
|
+
log.error(`Failed to upload rendition for ${contentEtag} page ${i}`, {
|
60
60
|
error: err,
|
61
61
|
errorMessage: err.message,
|
62
62
|
stack: err.stack,
|
63
63
|
});
|
64
64
|
return Promise.reject(`Upload failed: ${err.message}`);
|
65
65
|
});
|
66
|
-
log.info(`Rendition uploaded for ${
|
66
|
+
log.info(`Rendition uploaded for ${contentEtag} page ${i}`, {
|
67
67
|
result,
|
68
68
|
});
|
69
69
|
return result;
|
70
70
|
}
|
71
71
|
catch (err) {
|
72
|
-
log.error(`Failed to upload rendition for ${
|
72
|
+
log.error(`Failed to upload rendition for ${contentEtag} page ${i}`, {
|
73
73
|
error: err,
|
74
74
|
});
|
75
75
|
return Promise.reject(`Upload failed: ${err.message}`);
|
76
76
|
}
|
77
|
-
});
|
77
|
+
}));
|
78
78
|
return Promise.all(uploads);
|
79
79
|
}
|
80
80
|
//# sourceMappingURL=renditions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"renditions.js","sourceRoot":"","sources":["../../../src/utils/renditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;
|
1
|
+
{"version":3,"file":"renditions.js","sourceRoot":"","sources":["../../../src/utils/renditions.ts"],"names":[],"mappings":"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OAAO;oBACzB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACnB,CACJ,CAAC;gBACF,OAAO,OAAO,CAAC,MAAM,CAAC,kBAAkB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;YACP,GAAG,CAAC,IAAI,CAAC,0BAA0B,WAAW,SAAS,CAAC,EAAE,EAAE;gBACxD,MAAM;aACT,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAClB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,GAAG,CAAC,KAAK,CAAC,kCAAkC,WAAW,SAAS,CAAC,EAAE,EAAE;gBACjE,KAAK,EAAE,GAAG;aACb,CAAC,CAAC;YACH,OAAO,OAAO,CAAC,MAAM,CAAC,kBAAkB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;IACL,CAAC,CAAC,CAAC,CAAC;IAEJ,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { activityInfo, log } from "@temporalio/activity";
|
2
|
+
import { ApplicationFailure } from "@temporalio/workflow";
|
3
|
+
import { NodeStreamSource } from "@vertesia/client/node";
|
4
|
+
import { basename } from "path";
|
5
|
+
import mime from "mime";
|
6
|
+
import { fetchBlobAsBuffer } from "../utils/blobs.js";
|
7
|
+
export const agentStoragePath = (runId) => `agents/${runId}`;
|
8
|
+
/**
|
9
|
+
*
|
10
|
+
* Save an artifact generated by an agent to cloud storage
|
11
|
+
*
|
12
|
+
* @param client
|
13
|
+
* @param name
|
14
|
+
* @param fileContent
|
15
|
+
* @param mimeType
|
16
|
+
* @returns
|
17
|
+
*/
|
18
|
+
export async function saveAgentArtifact(client, name, fileContent, mimeType = "application/json") {
|
19
|
+
const { runId } = activityInfo().workflowExecution;
|
20
|
+
const ext = mime.getExtension(mimeType);
|
21
|
+
if (!name) {
|
22
|
+
throw ApplicationFailure.nonRetryable(`Name is required`);
|
23
|
+
}
|
24
|
+
//create the file path and append extension if needed
|
25
|
+
const filePath = agentStoragePath(runId) + "/" + name + (ext && !name.endsWith(ext) ? "." + ext : "");
|
26
|
+
log.info(`Storing agent artifact ${filePath} for run ${runId}`);
|
27
|
+
try {
|
28
|
+
const source = new NodeStreamSource(fileContent, `${runId}-${basename(filePath)}`, mimeType, filePath);
|
29
|
+
return await client.files.uploadFile(source);
|
30
|
+
}
|
31
|
+
catch (err) {
|
32
|
+
log.error(`Failed to save agent artifact for run ${runId}`, {
|
33
|
+
err,
|
34
|
+
file: filePath,
|
35
|
+
});
|
36
|
+
throw ApplicationFailure.nonRetryable(`Failed to save agent artifact for run ${runId}`, "SaveAgentArtifactError", {
|
37
|
+
error: err,
|
38
|
+
});
|
39
|
+
}
|
40
|
+
}
|
41
|
+
export async function fetchAgentArtifact(client, name) {
|
42
|
+
const { runId } = activityInfo().workflowExecution;
|
43
|
+
const filePath = agentStoragePath(runId) + "/" + name;
|
44
|
+
return fetchBlobAsBuffer(client, filePath);
|
45
|
+
}
|
46
|
+
//# sourceMappingURL=storage.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/utils/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,UAAU,KAAK,EAAE,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,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KAAK,EAAE,GAAG,YAAY,EAAE,CAAC,iBAAiB,CAAC;IACnD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC;IACtD,OAAO,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC/C,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generateImageRendition.d.ts","sourceRoot":"","sources":["../../../../src/activities/renditions/generateImageRendition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhF,OAAO,
|
1
|
+
{"version":3,"file":"generateImageRendition.d.ts","sourceRoot":"","sources":["../../../../src/activities/renditions/generateImageRendition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhF,OAAO,EACH,oBAAoB,EAEvB,MAAM,2BAA2B,CAAC;AAEnC,UAAU,4BAA6B,SAAQ,oBAAoB;CAAI;AAEvE,MAAM,WAAW,sBACb,SAAQ,eAAe,CAAC,4BAA4B,CAAC;IACrD,IAAI,EAAE,wBAAwB,CAAC;CAClC;AAED,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC;;;;GAiGrE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generateVideoRendition.d.ts","sourceRoot":"","sources":["../../../../src/activities/renditions/generateVideoRendition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAShF,OAAO,EACH,oBAAoB,EAEvB,MAAM,2BAA2B,CAAC;AAInC,UAAU,4BAA6B,SAAQ,oBAAoB;CAAI;AAEvE,MAAM,WAAW,sBACb,SAAQ,eAAe,CAAC,4BAA4B,CAAC;IACrD,IAAI,EAAE,wBAAwB,CAAC;CAClC;AA0FD,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC;;;;;
|
1
|
+
{"version":3,"file":"generateVideoRendition.d.ts","sourceRoot":"","sources":["../../../../src/activities/renditions/generateVideoRendition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAShF,OAAO,EACH,oBAAoB,EAEvB,MAAM,2BAA2B,CAAC;AAInC,UAAU,4BAA6B,SAAQ,oBAAoB;CAAI;AAEvE,MAAM,WAAW,sBACb,SAAQ,eAAe,CAAC,4BAA4B,CAAC;IACrD,IAAI,EAAE,wBAAwB,CAAC;CAClC;AA0FD,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC;;;;;GAmLrE"}
|
package/lib/types/errors.d.ts
CHANGED
@@ -1,50 +1,19 @@
|
|
1
1
|
import { ApplicationFailure } from "@temporalio/workflow";
|
2
2
|
import { DSLActivitySpec, DSLWorkflowSpec } from "@vertesia/common";
|
3
|
-
/**
|
4
|
-
* @deprecated Use {@link DocumentNotFoundError} instead.
|
5
|
-
*/
|
6
|
-
export declare class NoDocumentFound extends Error {
|
7
|
-
ids?: string[] | undefined;
|
8
|
-
constructor(message: string, ids?: string[] | undefined);
|
9
|
-
}
|
10
3
|
export declare class DocumentNotFoundError extends ApplicationFailure {
|
11
4
|
ids?: string[] | undefined;
|
12
5
|
constructor(message: string, ids?: string[] | undefined);
|
13
6
|
}
|
14
|
-
/**
|
15
|
-
* @deprecated Use {@link ActivityParamNotFoundError} instead.
|
16
|
-
*/
|
17
|
-
export declare class ActivityParamNotFound extends Error {
|
18
|
-
paramName: string;
|
19
|
-
activity: DSLActivitySpec;
|
20
|
-
constructor(paramName: string, activity: DSLActivitySpec);
|
21
|
-
}
|
22
7
|
export declare class ActivityParamNotFoundError extends ApplicationFailure {
|
23
8
|
paramName: string;
|
24
9
|
activity: DSLActivitySpec;
|
25
10
|
constructor(paramName: string, activity: DSLActivitySpec);
|
26
11
|
}
|
27
|
-
/**
|
28
|
-
* @deprecated Use {@link ActivityParamInvalidError} instead.
|
29
|
-
*/
|
30
|
-
export declare class ActivityParamInvalid extends Error {
|
31
|
-
paramName: string;
|
32
|
-
activity: DSLActivitySpec;
|
33
|
-
constructor(paramName: string, activity: DSLActivitySpec, reason?: string);
|
34
|
-
}
|
35
12
|
export declare class ActivityParamInvalidError extends ApplicationFailure {
|
36
13
|
paramName: string;
|
37
14
|
activity: DSLActivitySpec;
|
38
15
|
constructor(paramName: string, activity: DSLActivitySpec, reason?: string);
|
39
16
|
}
|
40
|
-
/**
|
41
|
-
* @deprecated Use {@link WorkflowParamNotFoundError} instead.
|
42
|
-
*/
|
43
|
-
export declare class WorkflowParamNotFound extends Error {
|
44
|
-
paramName: string;
|
45
|
-
workflow?: DSLWorkflowSpec | undefined;
|
46
|
-
constructor(paramName: string, workflow?: DSLWorkflowSpec | undefined);
|
47
|
-
}
|
48
17
|
export declare class WorkflowParamNotFoundError extends ApplicationFailure {
|
49
18
|
paramName: string;
|
50
19
|
workflow?: DSLWorkflowSpec | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE,qBAAa,qBAAsB,SAAQ,kBAAkB;IACrB,GAAG,CAAC,EAAE,MAAM,EAAE;gBAAtC,OAAO,EAAE,MAAM,EAAS,GAAG,CAAC,EAAE,MAAM,EAAE,YAAA;CAOrD;AAED,qBAAa,0BAA2B,SAAQ,kBAAkB;IAEnD,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,eAAe;gBADzB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,eAAe;CAQvC;AAED,qBAAa,yBAA0B,SAAQ,kBAAkB;IAElD,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,eAAe;gBADzB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,MAAM;CAQtB;AAED,qBAAa,0BAA2B,SAAQ,kBAAkB;IAEnD,SAAS,EAAE,MAAM;IACjB,QAAQ,CAAC,EAAE,eAAe;gBAD1B,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,eAAe,YAAA;CAQxC;AAED,eAAO,MAAM,uBAAuB,UAKnC,CAAC"}
|
package/lib/types/index.d.ts
CHANGED
@@ -29,5 +29,6 @@ export * from "./utils/client.js";
|
|
29
29
|
export * from "./utils/memory.js";
|
30
30
|
export * from "./utils/tokens.js";
|
31
31
|
export * from "./utils/renditions.js";
|
32
|
+
export * from "./utils/storage.js";
|
32
33
|
export * from "./conversion/image.js";
|
33
34
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,cAAc,uDAAuD,CAAC;AAEtE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,mEAAmE,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,cAAc,uDAAuD,CAAC;AAEtE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,mEAAmE,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oCAAoC,CAAC;AACnD,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,uBAAuB,CAAC"}
|
@@ -11,13 +11,13 @@ export interface ImageRenditionParams {
|
|
11
11
|
* @param pageNumber
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function getRenditionsPath(
|
14
|
+
export declare function getRenditionsPath(contentEtag: string, params: ImageRenditionParams): string;
|
15
15
|
/**
|
16
16
|
* Get a specific page path for a rendition
|
17
17
|
*/
|
18
|
-
export declare function getRenditionPagePath(
|
18
|
+
export declare function getRenditionPagePath(contentEtag: string, params: ImageRenditionParams, pageNumber?: number | string): string;
|
19
19
|
/**
|
20
20
|
* Upload Rendition page to the cloud
|
21
21
|
*/
|
22
|
-
export declare function uploadRenditionPages(client: VertesiaClient,
|
22
|
+
export declare function uploadRenditionPages(client: VertesiaClient, contentEtag: string, files: string[], params: ImageRenditionParams, concurrency?: number): Promise<string[]>;
|
23
23
|
//# sourceMappingURL=renditions.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"renditions.d.ts","sourceRoot":"","sources":["../../../src/utils/renditions.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"renditions.d.ts","sourceRoot":"","sources":["../../../src/utils/renditions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAKxD,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC7B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,oBAAoB,UAI/B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,oBAAoB,EAC5B,UAAU,GAAE,MAAM,GAAG,MAAU,UASlC;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,oBAAoB,EAC5B,WAAW,CAAC,EAAE,MAAM,qBAyEvB"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { VertesiaClient } from "@vertesia/client";
|
2
|
+
import { Readable } from "stream";
|
3
|
+
export declare const agentStoragePath: (runId: string) => string;
|
4
|
+
/**
|
5
|
+
*
|
6
|
+
* Save an artifact generated by an agent to cloud storage
|
7
|
+
*
|
8
|
+
* @param client
|
9
|
+
* @param name
|
10
|
+
* @param fileContent
|
11
|
+
* @param mimeType
|
12
|
+
* @returns
|
13
|
+
*/
|
14
|
+
export declare function saveAgentArtifact(client: VertesiaClient, name: string, fileContent: Readable, mimeType?: string): Promise<string>;
|
15
|
+
export declare function fetchAgentArtifact(client: VertesiaClient, name: string): Promise<Buffer<ArrayBufferLike>>;
|
16
|
+
//# sourceMappingURL=storage.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/utils/storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKlC,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,WAAsB,CAAC;AAErE;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,QAAQ,EACrB,QAAQ,GAAE,MAA2B,mBA4BxC;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAI5E"}
|