@vertesia/workflow 0.78.0-dev-28b447d → 0.79.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/advanced/createDocumentTypeFromInteractionRun.js +34 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +67 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +20 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/chunkDocument.js +86 -0
- package/lib/cjs/activities/chunkDocument.js.map +1 -0
- package/lib/cjs/activities/createDocumentFromOther.js +64 -0
- package/lib/cjs/activities/createDocumentFromOther.js.map +1 -0
- package/lib/cjs/activities/executeInteraction.js +189 -0
- package/lib/cjs/activities/executeInteraction.js.map +1 -0
- package/lib/cjs/activities/extractDocumentText.js +156 -0
- package/lib/cjs/activities/extractDocumentText.js.map +1 -0
- package/lib/cjs/activities/generateDocumentProperties.js +84 -0
- package/lib/cjs/activities/generateDocumentProperties.js.map +1 -0
- package/lib/cjs/activities/generateEmbeddings.js +358 -0
- package/lib/cjs/activities/generateEmbeddings.js.map +1 -0
- package/lib/cjs/activities/generateOrAssignContentType.js +126 -0
- package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -0
- package/lib/cjs/activities/getObjectFromStore.js +20 -0
- package/lib/cjs/activities/getObjectFromStore.js.map +1 -0
- package/lib/cjs/activities/handleError.js +22 -0
- package/lib/cjs/activities/handleError.js.map +1 -0
- package/lib/cjs/activities/index-dsl.js +43 -0
- package/lib/cjs/activities/index-dsl.js.map +1 -0
- package/lib/cjs/activities/index.js +21 -0
- package/lib/cjs/activities/index.js.map +1 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js +103 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +51 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/cjs/activities/notifyWebhook.js +157 -0
- package/lib/cjs/activities/notifyWebhook.js.map +1 -0
- package/lib/cjs/activities/rateLimiter.js +30 -0
- package/lib/cjs/activities/rateLimiter.js.map +1 -0
- package/lib/cjs/activities/renditions/generateImageRendition.js +66 -0
- package/lib/cjs/activities/renditions/generateImageRendition.js.map +1 -0
- package/lib/cjs/activities/renditions/generateVideoRendition.js +200 -0
- package/lib/cjs/activities/renditions/generateVideoRendition.js.map +1 -0
- package/lib/cjs/activities/setDocumentStatus.js +15 -0
- package/lib/cjs/activities/setDocumentStatus.js.map +1 -0
- package/lib/cjs/conversion/TextractProcessor.js +417 -0
- package/lib/cjs/conversion/TextractProcessor.js.map +1 -0
- package/lib/cjs/conversion/image.js +149 -0
- package/lib/cjs/conversion/image.js.map +1 -0
- package/lib/cjs/conversion/markitdown.js +42 -0
- package/lib/cjs/conversion/markitdown.js.map +1 -0
- package/lib/cjs/conversion/mutool.js +147 -0
- package/lib/cjs/conversion/mutool.js.map +1 -0
- package/lib/cjs/conversion/pandoc.js +39 -0
- package/lib/cjs/conversion/pandoc.js.map +1 -0
- package/lib/cjs/dsl/conditions.js +81 -0
- package/lib/cjs/dsl/conditions.js.map +1 -0
- package/lib/cjs/dsl/dsl-workflow.js +338 -0
- package/lib/cjs/dsl/dsl-workflow.js.map +1 -0
- package/lib/cjs/dsl/dslProxyActivities.js +23 -0
- package/lib/cjs/dsl/dslProxyActivities.js.map +1 -0
- package/lib/cjs/dsl/projections.js +59 -0
- package/lib/cjs/dsl/projections.js.map +1 -0
- package/lib/cjs/dsl/setup/ActivityContext.js +120 -0
- package/lib/cjs/dsl/setup/ActivityContext.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/DataProvider.js +51 -0
- package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/index.js +16 -0
- package/lib/cjs/dsl/setup/fetch/index.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/providers.js +67 -0
- package/lib/cjs/dsl/setup/fetch/providers.js.map +1 -0
- package/lib/cjs/dsl/test/test-child-workflow.js +10 -0
- package/lib/cjs/dsl/test/test-child-workflow.js.map +1 -0
- package/lib/cjs/dsl/validation.js +122 -0
- package/lib/cjs/dsl/validation.js.map +1 -0
- package/lib/cjs/dsl/vars.js +341 -0
- package/lib/cjs/dsl/vars.js.map +1 -0
- package/lib/cjs/dsl/walk.js +100 -0
- package/lib/cjs/dsl/walk.js.map +1 -0
- package/lib/cjs/dsl.js +20 -0
- package/lib/cjs/dsl.js.map +1 -0
- package/lib/cjs/errors.js +57 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/index.js +54 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js +47 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js +69 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js +74 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js +96 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/index.js +12 -0
- package/lib/cjs/iterative-generation/activities/index.js.map +1 -0
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +56 -0
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
- package/lib/cjs/iterative-generation/types.js +5 -0
- package/lib/cjs/iterative-generation/types.js.map +1 -0
- package/lib/cjs/iterative-generation/utils.js +121 -0
- package/lib/cjs/iterative-generation/utils.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/result-types.js +10 -0
- package/lib/cjs/result-types.js.map +1 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js +53 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +33 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +1 -0
- package/lib/cjs/utils/auth.js +15 -0
- package/lib/cjs/utils/auth.js.map +1 -0
- package/lib/cjs/utils/blobs.js +61 -0
- package/lib/cjs/utils/blobs.js.map +1 -0
- package/lib/cjs/utils/chunks.js +14 -0
- package/lib/cjs/utils/chunks.js.map +1 -0
- package/lib/cjs/utils/client.js +29 -0
- package/lib/cjs/utils/client.js.map +1 -0
- package/lib/cjs/utils/expand-vars.js +33 -0
- package/lib/cjs/utils/expand-vars.js.map +1 -0
- package/lib/cjs/utils/memory.js +65 -0
- package/lib/cjs/utils/memory.js.map +1 -0
- package/lib/cjs/utils/renditions.js +88 -0
- package/lib/cjs/utils/renditions.js.map +1 -0
- package/lib/cjs/utils/storage.js +55 -0
- package/lib/cjs/utils/storage.js.map +1 -0
- package/lib/cjs/utils/tokens.js +38 -0
- package/lib/cjs/utils/tokens.js.map +1 -0
- package/lib/cjs/vars.js +20 -0
- package/lib/cjs/vars.js.map +1 -0
- package/lib/cjs/workflows.js +15 -0
- package/lib/cjs/workflows.js.map +1 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +31 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +64 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +17 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/chunkDocument.js +83 -0
- package/lib/esm/activities/chunkDocument.js.map +1 -0
- package/lib/esm/activities/createDocumentFromOther.js +58 -0
- package/lib/esm/activities/createDocumentFromOther.js.map +1 -0
- package/lib/esm/activities/executeInteraction.js +185 -0
- package/lib/esm/activities/executeInteraction.js.map +1 -0
- package/lib/esm/activities/extractDocumentText.js +153 -0
- package/lib/esm/activities/extractDocumentText.js.map +1 -0
- package/lib/esm/activities/generateDocumentProperties.js +81 -0
- package/lib/esm/activities/generateDocumentProperties.js.map +1 -0
- package/lib/esm/activities/generateEmbeddings.js +355 -0
- package/lib/esm/activities/generateEmbeddings.js.map +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js +123 -0
- package/lib/esm/activities/generateOrAssignContentType.js.map +1 -0
- package/lib/esm/activities/getObjectFromStore.js +17 -0
- package/lib/esm/activities/getObjectFromStore.js.map +1 -0
- package/lib/esm/activities/handleError.js +19 -0
- package/lib/esm/activities/handleError.js.map +1 -0
- package/lib/esm/activities/index-dsl.js +21 -0
- package/lib/esm/activities/index-dsl.js.map +1 -0
- package/lib/esm/activities/index.js +5 -0
- package/lib/esm/activities/index.js.map +1 -0
- package/lib/esm/activities/media/processPdfWithTextract.js +99 -0
- package/lib/esm/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +48 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/esm/activities/notifyWebhook.js +154 -0
- package/lib/esm/activities/notifyWebhook.js.map +1 -0
- package/lib/esm/activities/rateLimiter.js +27 -0
- package/lib/esm/activities/rateLimiter.js.map +1 -0
- package/lib/esm/activities/renditions/generateImageRendition.js +63 -0
- package/lib/esm/activities/renditions/generateImageRendition.js.map +1 -0
- package/lib/esm/activities/renditions/generateVideoRendition.js +194 -0
- package/lib/esm/activities/renditions/generateVideoRendition.js.map +1 -0
- package/lib/esm/activities/setDocumentStatus.js +12 -0
- package/lib/esm/activities/setDocumentStatus.js.map +1 -0
- package/lib/esm/conversion/TextractProcessor.js +410 -0
- package/lib/esm/conversion/TextractProcessor.js.map +1 -0
- package/lib/esm/conversion/image.js +143 -0
- package/lib/esm/conversion/image.js.map +1 -0
- package/lib/esm/conversion/markitdown.js +36 -0
- package/lib/esm/conversion/markitdown.js.map +1 -0
- package/lib/esm/conversion/mutool.js +139 -0
- package/lib/esm/conversion/mutool.js.map +1 -0
- package/lib/esm/conversion/pandoc.js +36 -0
- package/lib/esm/conversion/pandoc.js.map +1 -0
- package/lib/esm/dsl/conditions.js +75 -0
- package/lib/esm/dsl/conditions.js.map +1 -0
- package/lib/esm/dsl/dsl-workflow.js +331 -0
- package/lib/esm/dsl/dsl-workflow.js.map +1 -0
- package/lib/esm/dsl/dslProxyActivities.js +20 -0
- package/lib/esm/dsl/dslProxyActivities.js.map +1 -0
- package/lib/esm/dsl/projections.js +55 -0
- package/lib/esm/dsl/projections.js.map +1 -0
- package/lib/esm/dsl/setup/ActivityContext.js +115 -0
- package/lib/esm/dsl/setup/ActivityContext.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/DataProvider.js +47 -0
- package/lib/esm/dsl/setup/fetch/DataProvider.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/index.js +12 -0
- package/lib/esm/dsl/setup/fetch/index.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/providers.js +61 -0
- package/lib/esm/dsl/setup/fetch/providers.js.map +1 -0
- package/lib/esm/dsl/test/test-child-workflow.js +5 -0
- package/lib/esm/dsl/test/test-child-workflow.js.map +1 -0
- package/lib/esm/dsl/validation.js +118 -0
- package/lib/esm/dsl/validation.js.map +1 -0
- package/lib/esm/dsl/vars.js +335 -0
- package/lib/esm/dsl/vars.js.map +1 -0
- package/lib/esm/dsl/walk.js +96 -0
- package/lib/esm/dsl/walk.js.map +1 -0
- package/lib/esm/dsl.js +4 -0
- package/lib/esm/dsl.js.map +1 -0
- package/lib/esm/errors.js +49 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.js +36 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/iterative-generation/activities/extractToc.js +44 -0
- package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js +66 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generatePart.js +71 -0
- package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generateToc.js +93 -0
- package/lib/esm/iterative-generation/activities/generateToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/index.js +5 -0
- package/lib/esm/iterative-generation/activities/index.js.map +1 -0
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +53 -0
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
- package/lib/esm/iterative-generation/types.js +2 -0
- package/lib/esm/iterative-generation/types.js.map +1 -0
- package/lib/esm/iterative-generation/utils.js +112 -0
- package/lib/esm/iterative-generation/utils.js.map +1 -0
- package/lib/esm/result-types.js +7 -0
- package/lib/esm/result-types.js.map +1 -0
- package/lib/esm/system/notifyWebhookWorkflow.js +50 -0
- package/lib/esm/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js +30 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +1 -0
- package/lib/esm/utils/auth.js +8 -0
- package/lib/esm/utils/auth.js.map +1 -0
- package/lib/esm/utils/blobs.js +51 -0
- package/lib/esm/utils/blobs.js.map +1 -0
- package/lib/esm/utils/chunks.js +9 -0
- package/lib/esm/utils/chunks.js.map +1 -0
- package/lib/esm/utils/client.js +25 -0
- package/lib/esm/utils/client.js.map +1 -0
- package/lib/esm/utils/expand-vars.js +30 -0
- package/lib/esm/utils/expand-vars.js.map +1 -0
- package/lib/esm/utils/memory.js +55 -0
- package/lib/esm/utils/memory.js.map +1 -0
- package/lib/esm/utils/renditions.js +80 -0
- package/lib/esm/utils/renditions.js.map +1 -0
- package/lib/esm/utils/storage.js +46 -0
- package/lib/esm/utils/storage.js.map +1 -0
- package/lib/esm/utils/tokens.js +34 -0
- package/lib/esm/utils/tokens.js.map +1 -0
- package/lib/esm/vars.js +4 -0
- package/lib/esm/vars.js.map +1 -0
- package/lib/esm/workflows.js +8 -0
- package/lib/esm/workflows.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +17 -0
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +39 -0
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +19 -0
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/chunkDocument.d.ts +33 -0
- package/lib/types/activities/chunkDocument.d.ts.map +1 -0
- package/lib/types/activities/createDocumentFromOther.d.ts +21 -0
- package/lib/types/activities/createDocumentFromOther.d.ts.map +1 -0
- package/lib/types/activities/executeInteraction.d.ts +61 -0
- package/lib/types/activities/executeInteraction.d.ts.map +1 -0
- package/lib/types/activities/extractDocumentText.d.ts +10 -0
- package/lib/types/activities/extractDocumentText.d.ts.map +1 -0
- package/lib/types/activities/generateDocumentProperties.d.ts +32 -0
- package/lib/types/activities/generateDocumentProperties.d.ts.map +1 -0
- package/lib/types/activities/generateEmbeddings.d.ts +53 -0
- package/lib/types/activities/generateEmbeddings.d.ts.map +1 -0
- package/lib/types/activities/generateOrAssignContentType.d.ts +44 -0
- package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -0
- package/lib/types/activities/getObjectFromStore.d.ts +14 -0
- package/lib/types/activities/getObjectFromStore.d.ts.map +1 -0
- package/lib/types/activities/handleError.d.ts +6 -0
- package/lib/types/activities/handleError.d.ts.map +1 -0
- package/lib/types/activities/index-dsl.d.ts +20 -0
- package/lib/types/activities/index-dsl.d.ts.map +1 -0
- package/lib/types/activities/index.d.ts +5 -0
- package/lib/types/activities/index.d.ts.map +1 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts +26 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts.map +1 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +14 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +1 -0
- package/lib/types/activities/notifyWebhook.d.ts +27 -0
- package/lib/types/activities/notifyWebhook.d.ts.map +1 -0
- package/lib/types/activities/rateLimiter.d.ts +11 -0
- package/lib/types/activities/rateLimiter.d.ts.map +1 -0
- package/lib/types/activities/renditions/generateImageRendition.d.ts +14 -0
- package/lib/types/activities/renditions/generateImageRendition.d.ts.map +1 -0
- package/lib/types/activities/renditions/generateVideoRendition.d.ts +15 -0
- package/lib/types/activities/renditions/generateVideoRendition.d.ts.map +1 -0
- package/lib/types/activities/setDocumentStatus.d.ts +15 -0
- package/lib/types/activities/setDocumentStatus.d.ts.map +1 -0
- package/lib/types/conversion/TextractProcessor.d.ts +45 -0
- package/lib/types/conversion/TextractProcessor.d.ts.map +1 -0
- package/lib/types/conversion/image.d.ts +13 -0
- package/lib/types/conversion/image.d.ts.map +1 -0
- package/lib/types/conversion/markitdown.d.ts +2 -0
- package/lib/types/conversion/markitdown.d.ts.map +1 -0
- package/lib/types/conversion/mutool.d.ts +19 -0
- package/lib/types/conversion/mutool.d.ts.map +1 -0
- package/lib/types/conversion/pandoc.d.ts +2 -0
- package/lib/types/conversion/pandoc.d.ts.map +1 -0
- package/lib/types/dsl/conditions.d.ts +2 -0
- package/lib/types/dsl/conditions.d.ts.map +1 -0
- package/lib/types/dsl/dsl-workflow.d.ts +5 -0
- package/lib/types/dsl/dsl-workflow.d.ts.map +1 -0
- package/lib/types/dsl/dslProxyActivities.d.ts +10 -0
- package/lib/types/dsl/dslProxyActivities.d.ts.map +1 -0
- package/lib/types/dsl/projections.d.ts +4 -0
- package/lib/types/dsl/projections.d.ts.map +1 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts +17 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts +9 -0
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/index.d.ts +6 -0
- package/lib/types/dsl/setup/fetch/index.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/providers.d.ts +25 -0
- package/lib/types/dsl/setup/fetch/providers.d.ts.map +1 -0
- package/lib/types/dsl/test/test-child-workflow.d.ts +4 -0
- package/lib/types/dsl/test/test-child-workflow.d.ts.map +1 -0
- package/lib/types/dsl/validation.d.ts +4 -0
- package/lib/types/dsl/validation.d.ts.map +1 -0
- package/lib/types/dsl/vars.d.ts +48 -0
- package/lib/types/dsl/vars.d.ts.map +1 -0
- package/lib/types/dsl/walk.d.ts +18 -0
- package/lib/types/dsl/walk.d.ts.map +1 -0
- package/lib/types/dsl.d.ts +4 -0
- package/lib/types/dsl.d.ts.map +1 -0
- package/lib/types/errors.d.ts +27 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/index.d.ts +35 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts +10 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +3 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts +3 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts +4 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/index.d.ts +5 -0
- package/lib/types/iterative-generation/activities/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +3 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +1 -0
- package/lib/types/iterative-generation/types.d.ts +79 -0
- package/lib/types/iterative-generation/types.d.ts.map +1 -0
- package/lib/types/iterative-generation/utils.d.ts +27 -0
- package/lib/types/iterative-generation/utils.d.ts.map +1 -0
- package/lib/types/result-types.d.ts +22 -0
- package/lib/types/result-types.d.ts.map +1 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts +8 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts.map +1 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +25 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +1 -0
- package/lib/types/utils/auth.d.ts +4 -0
- package/lib/types/utils/auth.d.ts.map +1 -0
- package/lib/types/utils/blobs.d.ts +7 -0
- package/lib/types/utils/blobs.d.ts.map +1 -0
- package/lib/types/utils/chunks.d.ts +9 -0
- package/lib/types/utils/chunks.d.ts.map +1 -0
- package/lib/types/utils/client.d.ts +12 -0
- package/lib/types/utils/client.d.ts.map +1 -0
- package/lib/types/utils/expand-vars.d.ts +8 -0
- package/lib/types/utils/expand-vars.d.ts.map +1 -0
- package/lib/types/utils/memory.d.ts +8 -0
- package/lib/types/utils/memory.d.ts.map +1 -0
- package/lib/types/utils/renditions.d.ts +23 -0
- package/lib/types/utils/renditions.d.ts.map +1 -0
- package/lib/types/utils/storage.d.ts +16 -0
- package/lib/types/utils/storage.d.ts.map +1 -0
- package/lib/types/utils/tokens.d.ts +11 -0
- package/lib/types/utils/tokens.d.ts.map +1 -0
- package/lib/types/vars.d.ts +3 -0
- package/lib/types/vars.d.ts.map +1 -0
- package/lib/types/workflows.d.ts +8 -0
- package/lib/types/workflows.d.ts.map +1 -0
- package/lib/workflows-bundle.js +13145 -0
- package/package.json +127 -127
- package/src/activities/notifyWebhook.test.ts +18 -14
- package/src/activities/notifyWebhook.ts +149 -14
- package/src/dsl/setup/ActivityContext.ts +12 -45
- package/src/dsl/workflow-exec-child.test.ts +3 -3
- package/src/dsl/workflow-fetch.test.ts +1 -1
- package/src/dsl/workflow-import.test.ts +1 -1
- package/src/dsl/workflow.test.ts +1 -1
- package/src/iterative-generation/activities/extractToc.ts +12 -26
- package/src/iterative-generation/activities/finalizeOutput.ts +29 -52
- package/src/iterative-generation/activities/generatePart.ts +23 -64
- package/src/iterative-generation/activities/generateToc.ts +65 -78
- package/src/system/notifyWebhookWorkflow.ts +15 -6
- package/src/utils/blobs.ts +1 -3
- package/src/utils/client.ts +8 -22
package/package.json
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"name": "@vertesia/workflow",
|
|
3
|
+
"version": "0.79.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Vertesia workflow DSL",
|
|
6
|
+
"main": "./lib/esm/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"bundle-workflows": "./bin/bundle-workflows.mjs"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
17
|
+
"directory": "zeno/workflow"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@smithy/types": "^3.7.2",
|
|
22
|
+
"@temporalio/proto": "^1.11.5",
|
|
23
|
+
"@temporalio/testing": "^1.11.5",
|
|
24
|
+
"@temporalio/worker": "^1.11.5",
|
|
25
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
26
|
+
"@types/node": "^22.5.1",
|
|
27
|
+
"@types/papaparse": "^5.3.15",
|
|
28
|
+
"@types/tmp": "^0.2.6",
|
|
29
|
+
"ts-dual-module": "^0.6.3",
|
|
30
|
+
"vitest": "^3.0.9"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@aws-sdk/client-s3": "^3.693.0",
|
|
34
|
+
"@aws-sdk/client-textract": "^3.693.0",
|
|
35
|
+
"@aws-sdk/credential-providers": "^3.693.0",
|
|
36
|
+
"@temporalio/activity": "^1.11.5",
|
|
37
|
+
"@temporalio/workflow": "^1.11.5",
|
|
38
|
+
"@types/json-schema": "^7.0.15",
|
|
39
|
+
"fast-deep-equal": "^3.1.3",
|
|
40
|
+
"jsonwebtoken": "^9.0.2",
|
|
41
|
+
"mime": "^4.0.0",
|
|
42
|
+
"ms": "3.0.0-canary.1",
|
|
43
|
+
"node-web-stream-adapters": "^0.2.1",
|
|
44
|
+
"p-limit": "^6.2.0",
|
|
45
|
+
"papaparse": "^5.4.1",
|
|
46
|
+
"seedrandom": "^3.0.5",
|
|
47
|
+
"sharp": "^0.33.4",
|
|
48
|
+
"tiktoken": "^1.0.15",
|
|
49
|
+
"tmp": "^0.2.3",
|
|
50
|
+
"tmp-promise": "^3.0.3",
|
|
51
|
+
"yaml": "^2.6.0",
|
|
52
|
+
"@llumiverse/common": "0.22.0",
|
|
53
|
+
"@vertesia/client": "0.79.0",
|
|
54
|
+
"@vertesia/api-fetch-client": "0.79.0",
|
|
55
|
+
"@vertesia/common": "0.79.0",
|
|
56
|
+
"@vertesia/memory": "0.50.0"
|
|
57
|
+
},
|
|
58
|
+
"ts_dual_module": {
|
|
59
|
+
"outDir": "lib",
|
|
60
|
+
"exports": {
|
|
61
|
+
"activities": "./activities/index.js",
|
|
62
|
+
"dsl-activities": "./activities/index-dsl.js",
|
|
63
|
+
"workflows": "./workflows",
|
|
64
|
+
"workflows-bundle": "./workflows-bundle.js",
|
|
65
|
+
"vars": "./vars"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"exports": {
|
|
69
|
+
".": {
|
|
70
|
+
"types": "./lib/types/index.d.ts",
|
|
71
|
+
"import": "./lib/esm/index.js",
|
|
72
|
+
"require": "./lib/cjs/index.js"
|
|
13
73
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
74
|
+
"./vars": {
|
|
75
|
+
"types": "./lib/types/vars.d.ts",
|
|
76
|
+
"import": "./lib/esm/vars.js",
|
|
77
|
+
"require": "./lib/cjs/vars.js"
|
|
18
78
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"@temporalio/testing": "^1.11.5",
|
|
24
|
-
"@temporalio/worker": "^1.11.5",
|
|
25
|
-
"@types/jsonwebtoken": "^9.0.7",
|
|
26
|
-
"@types/node": "^22.5.1",
|
|
27
|
-
"@types/papaparse": "^5.3.15",
|
|
28
|
-
"@types/tmp": "^0.2.6",
|
|
29
|
-
"ts-dual-module": "^0.6.3",
|
|
30
|
-
"vitest": "^3.0.9"
|
|
79
|
+
"./activities": {
|
|
80
|
+
"types": "./lib/types/activities/index.d.ts",
|
|
81
|
+
"import": "./lib/esm/activities/index.js",
|
|
82
|
+
"require": "./lib/cjs/activities/index.js"
|
|
31
83
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"@llumiverse/common": "workspace:*",
|
|
37
|
-
"@temporalio/activity": "^1.11.5",
|
|
38
|
-
"@temporalio/workflow": "^1.11.5",
|
|
39
|
-
"@types/json-schema": "^7.0.15",
|
|
40
|
-
"@vertesia/api-fetch-client": "workspace:*",
|
|
41
|
-
"@vertesia/client": "workspace:*",
|
|
42
|
-
"@vertesia/common": "workspace:*",
|
|
43
|
-
"@vertesia/memory": "workspace:*",
|
|
44
|
-
"fast-deep-equal": "^3.1.3",
|
|
45
|
-
"jsonwebtoken": "^9.0.2",
|
|
46
|
-
"mime": "^4.0.0",
|
|
47
|
-
"ms": "3.0.0-canary.1",
|
|
48
|
-
"node-web-stream-adapters": "^0.2.1",
|
|
49
|
-
"p-limit": "^6.2.0",
|
|
50
|
-
"papaparse": "^5.4.1",
|
|
51
|
-
"seedrandom": "^3.0.5",
|
|
52
|
-
"sharp": "^0.33.4",
|
|
53
|
-
"tiktoken": "^1.0.15",
|
|
54
|
-
"tmp": "^0.2.4",
|
|
55
|
-
"tmp-promise": "^3.0.3",
|
|
56
|
-
"yaml": "^2.6.0"
|
|
84
|
+
"./dsl-activities": {
|
|
85
|
+
"types": "./lib/types/activities/index-dsl.d.ts",
|
|
86
|
+
"import": "./lib/esm/activities/index-dsl.js",
|
|
87
|
+
"require": "./lib/cjs/activities/index-dsl.js"
|
|
57
88
|
},
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"dsl-activities": "./activities/index-dsl.js",
|
|
63
|
-
"workflows": "./workflows",
|
|
64
|
-
"workflows-bundle": "./workflows-bundle.js",
|
|
65
|
-
"vars": "./vars"
|
|
66
|
-
}
|
|
89
|
+
"./workflows": {
|
|
90
|
+
"types": "./lib/types/workflows.d.ts",
|
|
91
|
+
"import": "./lib/esm/workflows.js",
|
|
92
|
+
"require": "./lib/cjs/workflows.js"
|
|
67
93
|
},
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"require": "./lib/cjs/index.js"
|
|
73
|
-
},
|
|
74
|
-
"./vars": {
|
|
75
|
-
"types": "./lib/types/vars.d.ts",
|
|
76
|
-
"import": "./lib/esm/vars.js",
|
|
77
|
-
"require": "./lib/cjs/vars.js"
|
|
78
|
-
},
|
|
79
|
-
"./activities": {
|
|
80
|
-
"types": "./lib/types/activities/index.d.ts",
|
|
81
|
-
"import": "./lib/esm/activities/index.js",
|
|
82
|
-
"require": "./lib/cjs/activities/index.js"
|
|
83
|
-
},
|
|
84
|
-
"./dsl-activities": {
|
|
85
|
-
"types": "./lib/types/activities/index-dsl.d.ts",
|
|
86
|
-
"import": "./lib/esm/activities/index-dsl.js",
|
|
87
|
-
"require": "./lib/cjs/activities/index-dsl.js"
|
|
88
|
-
},
|
|
89
|
-
"./workflows": {
|
|
90
|
-
"types": "./lib/types/workflows.d.ts",
|
|
91
|
-
"import": "./lib/esm/workflows.js",
|
|
92
|
-
"require": "./lib/cjs/workflows.js"
|
|
93
|
-
},
|
|
94
|
-
"./dsl": {
|
|
95
|
-
"types": "./lib/types/dsl.d.ts",
|
|
96
|
-
"import": "./lib/esm/dsl.js",
|
|
97
|
-
"require": "./lib/cjs/dsl.js"
|
|
98
|
-
},
|
|
99
|
-
"./workflows-bundle": {
|
|
100
|
-
"import": "./lib/workflows-bundle.js"
|
|
101
|
-
},
|
|
102
|
-
"./errors": {
|
|
103
|
-
"types": "./lib/types/errors.d.ts",
|
|
104
|
-
"import": "./lib/esm/errors.js",
|
|
105
|
-
"require": "./lib/cjs/errors.js"
|
|
106
|
-
}
|
|
94
|
+
"./dsl": {
|
|
95
|
+
"types": "./lib/types/dsl.d.ts",
|
|
96
|
+
"import": "./lib/esm/dsl.js",
|
|
97
|
+
"require": "./lib/cjs/dsl.js"
|
|
107
98
|
},
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
"url": "https://github.com/vertesia/composableai.git",
|
|
111
|
-
"directory": "packages/workflow"
|
|
99
|
+
"./workflows-bundle": {
|
|
100
|
+
"import": "./lib/workflows-bundle.js"
|
|
112
101
|
},
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
102
|
+
"./errors": {
|
|
103
|
+
"types": "./lib/types/errors.d.ts",
|
|
104
|
+
"import": "./lib/esm/errors.js",
|
|
105
|
+
"require": "./lib/cjs/errors.js"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"types": "./lib/types/index.d.ts",
|
|
109
|
+
"typesVersions": {
|
|
110
|
+
"*": {
|
|
111
|
+
"activities": [
|
|
112
|
+
"./lib/types/activities/index.d.ts"
|
|
113
|
+
],
|
|
114
|
+
"dsl-activities": [
|
|
115
|
+
"./lib/types/activities/index-dsl.d.ts"
|
|
116
|
+
],
|
|
117
|
+
"workflows": [
|
|
118
|
+
"./lib/types/workflows.d.ts"
|
|
119
|
+
],
|
|
120
|
+
"dsl": [
|
|
121
|
+
"./lib/types/dsl.d.ts"
|
|
122
|
+
],
|
|
123
|
+
"vars": [
|
|
124
|
+
"./lib/types/dsl/vars.d.ts"
|
|
125
|
+
],
|
|
126
|
+
"errors": [
|
|
127
|
+
"./lib/types/errors.d.ts"
|
|
128
|
+
]
|
|
135
129
|
}
|
|
136
|
-
}
|
|
130
|
+
},
|
|
131
|
+
"scripts": {
|
|
132
|
+
"test": "vitest run",
|
|
133
|
+
"build": "pnpm exec tsmod build && node ./bin/bundle-workflows.mjs lib/esm/workflows.js lib/workflows-bundle.js",
|
|
134
|
+
"clean": "rm -rf ./lib tsconfig.tsbuildinfo"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MockActivityEnvironment,
|
|
3
3
|
} from "@temporalio/testing";
|
|
4
|
-
import { beforeAll, beforeEach, describe, expect, it, test, vi } from "vitest";
|
|
5
|
-
import { notifyWebhook, NotifyWebhook, NotifyWebhookParams } from "./notifyWebhook.js";
|
|
6
4
|
import { ContentEventName, DSLActivityExecutionPayload } from "@vertesia/common";
|
|
5
|
+
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { notifyWebhook, NotifyWebhookParams } from "./notifyWebhook.js";
|
|
7
7
|
|
|
8
8
|
// Mock fetch globally
|
|
9
9
|
vi.stubGlobal('fetch', vi.fn());
|
|
@@ -20,16 +20,20 @@ beforeEach(() => {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const defaultParams = {
|
|
23
|
-
|
|
23
|
+
webhook: "https://vertesia.test",
|
|
24
24
|
method: "POST" as const,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
detail: { message: "Hello World" },
|
|
26
|
+
workflow_id: "wf_id",
|
|
27
|
+
workflow_type: "wfFuncName",
|
|
28
|
+
workflow_run_id: "wf_run_id",
|
|
29
|
+
event_name: "completed",
|
|
30
|
+
} satisfies NotifyWebhookParams;
|
|
27
31
|
|
|
28
32
|
// Helper function to create test payload
|
|
29
33
|
const createTestPayload = (params: Partial<NotifyWebhookParams> = {}): DSLActivityExecutionPayload<NotifyWebhookParams> => {
|
|
30
34
|
const mergedParams = { ...defaultParams, ...params };
|
|
31
35
|
return {
|
|
32
|
-
auth_token:
|
|
36
|
+
auth_token: "unset",
|
|
33
37
|
account_id: "unset",
|
|
34
38
|
project_id: "unset",
|
|
35
39
|
params: mergedParams,
|
|
@@ -52,15 +56,15 @@ describe("Webhook should be notified", () => {
|
|
|
52
56
|
ok: true,
|
|
53
57
|
status: 200,
|
|
54
58
|
statusText: 'OK',
|
|
55
|
-
url: defaultParams.
|
|
59
|
+
url: defaultParams.webhook
|
|
56
60
|
};
|
|
57
61
|
mockFetch.mockResolvedValueOnce(mockResponse as Response);
|
|
58
62
|
|
|
59
63
|
const payload = createTestPayload();
|
|
60
64
|
const res = await testEnv.run(notifyWebhook, payload);
|
|
61
|
-
|
|
65
|
+
|
|
62
66
|
// Verify fetch was called with correct parameters
|
|
63
|
-
expect(mockFetch).toHaveBeenCalledWith(defaultParams.
|
|
67
|
+
expect(mockFetch).toHaveBeenCalledWith(defaultParams.webhook, {
|
|
64
68
|
method: 'POST',
|
|
65
69
|
body: JSON.stringify({ message: 'Hello World' }),
|
|
66
70
|
headers: {
|
|
@@ -72,7 +76,7 @@ describe("Webhook should be notified", () => {
|
|
|
72
76
|
expect(res).toEqual({
|
|
73
77
|
status: 200,
|
|
74
78
|
message: 'OK',
|
|
75
|
-
url: defaultParams.
|
|
79
|
+
url: defaultParams.webhook
|
|
76
80
|
});
|
|
77
81
|
});
|
|
78
82
|
|
|
@@ -82,7 +86,7 @@ describe("Webhook should be notified", () => {
|
|
|
82
86
|
ok: false,
|
|
83
87
|
status: 500,
|
|
84
88
|
statusText: 'Internal Server Error',
|
|
85
|
-
url: defaultParams.
|
|
89
|
+
url: defaultParams.webhook,
|
|
86
90
|
text: vi.fn().mockResolvedValue('{"error": "Database connection failed", "code": "DB_ERROR"}')
|
|
87
91
|
} as unknown as Response;
|
|
88
92
|
mockFetch.mockResolvedValueOnce(mockResponse);
|
|
@@ -91,11 +95,11 @@ describe("Webhook should be notified", () => {
|
|
|
91
95
|
|
|
92
96
|
// Expect the function to throw an error with response payload
|
|
93
97
|
await expect(testEnv.run(notifyWebhook, payload)).rejects.toThrow(
|
|
94
|
-
`Webhook Notification to ${defaultParams.
|
|
98
|
+
`Webhook Notification to ${defaultParams.webhook} failed with status: 500 Internal Server Error - Response: {"error": "Database connection failed", "code": "DB_ERROR"}`
|
|
95
99
|
);
|
|
96
100
|
|
|
97
101
|
// Verify fetch was called with correct parameters
|
|
98
|
-
expect(mockFetch).toHaveBeenCalledWith(defaultParams.
|
|
102
|
+
expect(mockFetch).toHaveBeenCalledWith(defaultParams.webhook, {
|
|
99
103
|
method: 'POST',
|
|
100
104
|
body: JSON.stringify({ message: 'Hello World' }),
|
|
101
105
|
headers: {
|
|
@@ -118,7 +122,7 @@ describe("Webhook should be notified", () => {
|
|
|
118
122
|
await expect(testEnv.run(notifyWebhook, payload)).rejects.toThrow('Network request failed');
|
|
119
123
|
|
|
120
124
|
// Verify fetch was called with correct parameters
|
|
121
|
-
expect(mockFetch).toHaveBeenCalledWith(defaultParams.
|
|
125
|
+
expect(mockFetch).toHaveBeenCalledWith(defaultParams.webhook, {
|
|
122
126
|
method: 'POST',
|
|
123
127
|
body: JSON.stringify({ message: 'Hello World' }),
|
|
124
128
|
headers: {
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { log } from "@temporalio/activity";
|
|
2
|
-
import {
|
|
2
|
+
import { VertesiaClient } from "@vertesia/client";
|
|
3
|
+
import { ApiVersions, DSLActivityExecutionPayload, DSLActivitySpec, WebHookSpec, WorkflowExecutionBaseParams } from "@vertesia/common";
|
|
3
4
|
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
4
5
|
import { WorkflowParamNotFoundError } from "../errors.js";
|
|
6
|
+
import { getVertesiaClientOptions } from "../utils/client.js";
|
|
5
7
|
|
|
6
8
|
export interface NotifyWebhookParams {
|
|
7
|
-
|
|
9
|
+
webhook: string | WebHookSpec; //URL to send the notification to
|
|
10
|
+
workflow_id: string; //The ID of the workflow sending the notification
|
|
11
|
+
workflow_type: string; //The type of workflow sending the notification (the wf function name)
|
|
12
|
+
workflow_run_id: string; //The ID of the specific workflow run sending the notification
|
|
13
|
+
event_name: string; //The event that triggered the notification (e.g. "completed", "failed", etc.)
|
|
14
|
+
detail?: Record<string, any>; // additional data about the event if any. It will be send to the webhook when using POST
|
|
15
|
+
//target_url: string; //URL to send the notification to
|
|
8
16
|
method: 'GET' | 'POST'; //HTTP method to use
|
|
9
|
-
|
|
10
|
-
headers?: Record<string, string>; //additional headers to send
|
|
17
|
+
headers?: Record<string, string>; // additional headers to send
|
|
11
18
|
}
|
|
12
19
|
|
|
20
|
+
export interface WebhookNotificationPayload {
|
|
21
|
+
workflow_id: string,
|
|
22
|
+
workflow_name: string,
|
|
23
|
+
workflow_run_id: string,
|
|
24
|
+
event_name: string,
|
|
25
|
+
detail?: Record<string, any>,
|
|
26
|
+
}
|
|
13
27
|
|
|
14
28
|
export interface NotifyWebhook extends DSLActivitySpec<NotifyWebhookParams> {
|
|
15
29
|
name: 'notifyWebhook';
|
|
@@ -19,22 +33,33 @@ export interface NotifyWebhook extends DSLActivitySpec<NotifyWebhookParams> {
|
|
|
19
33
|
export async function notifyWebhook(payload: DSLActivityExecutionPayload<NotifyWebhookParams>) {
|
|
20
34
|
|
|
21
35
|
const { params } = await setupActivity<NotifyWebhookParams>(payload);
|
|
22
|
-
const {
|
|
36
|
+
const { webhook, method, headers: defaultHeaders } = params
|
|
37
|
+
// resolve the url and the api version of the webhook
|
|
38
|
+
let target_url: string, version: number | undefined;
|
|
39
|
+
if (typeof webhook === 'string') {
|
|
40
|
+
target_url = webhook;
|
|
41
|
+
} else {
|
|
42
|
+
target_url = webhook.url;
|
|
43
|
+
version = webhook.version;
|
|
44
|
+
}
|
|
23
45
|
|
|
24
46
|
if (!target_url) throw new WorkflowParamNotFoundError('target_url');
|
|
25
47
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
const hasBody = params.detail && method === 'POST'; //body is sent only for POST
|
|
49
|
+
|
|
50
|
+
const headers = {
|
|
51
|
+
...defaultHeaders,
|
|
52
|
+
};
|
|
53
|
+
if (hasBody) {
|
|
54
|
+
headers['Content-Type'] = 'application/json';
|
|
55
|
+
}
|
|
56
|
+
const body = hasBody ? await createRequestBody(payload, params, version) : undefined
|
|
29
57
|
|
|
30
58
|
log.info(`Notifying webhook at ${target_url}`);
|
|
31
59
|
const res = await fetch(target_url, {
|
|
32
60
|
method,
|
|
33
61
|
body,
|
|
34
|
-
headers
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
|
-
...headers
|
|
37
|
-
},
|
|
62
|
+
headers,
|
|
38
63
|
}).catch(err => {
|
|
39
64
|
log.error(`An error occurred while notifying webhook at ${target_url}`, { err });
|
|
40
65
|
throw err;
|
|
@@ -42,7 +67,7 @@ export async function notifyWebhook(payload: DSLActivityExecutionPayload<NotifyW
|
|
|
42
67
|
|
|
43
68
|
if (!res.ok) {
|
|
44
69
|
log.warn(`Webhook endpoint ${target_url} returned an error - ${res.status} ${res.statusText}`, { fetchResponse: res });
|
|
45
|
-
|
|
70
|
+
|
|
46
71
|
// Try to get response payload for error message
|
|
47
72
|
let errorMessage = `Webhook Notification to ${target_url} failed with status: ${res.status} ${res.statusText}`;
|
|
48
73
|
try {
|
|
@@ -54,10 +79,120 @@ export async function notifyWebhook(payload: DSLActivityExecutionPayload<NotifyW
|
|
|
54
79
|
// If we can't read the response, just use the basic error message
|
|
55
80
|
log.debug('Could not read response body for error', { readError });
|
|
56
81
|
}
|
|
57
|
-
|
|
82
|
+
|
|
58
83
|
throw new Error(errorMessage);
|
|
59
84
|
}
|
|
60
85
|
|
|
61
86
|
return { status: res.status, message: res.statusText, url: res.url }
|
|
62
87
|
|
|
63
88
|
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// --------------------------------------
|
|
93
|
+
// Data provider for webhooks
|
|
94
|
+
// this allows to customize the payload sent to the webhook depending on the
|
|
95
|
+
// type of workflow and the api version of the webhook
|
|
96
|
+
// --------------------------------------
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
function getWorkflowName(workflowType: string): string {
|
|
100
|
+
// remove trailing Workflow or _Workflow case insensitive from the workflow type
|
|
101
|
+
return workflowType.replace(/_?workflow$/i, '');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function createRequestBody(payload: WorkflowExecutionBaseParams, params: NotifyWebhookParams, api_version: number | undefined): Promise<string> {
|
|
105
|
+
if (api_version === undefined || Number(api_version) < ApiVersions.COMPLETION_RESULT_V1) {
|
|
106
|
+
return createOldRequestBody(payload, params);
|
|
107
|
+
} else {
|
|
108
|
+
return createLatestRequestBody(payload, params, api_version);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function createLatestRequestBody(payload: WorkflowExecutionBaseParams, params: NotifyWebhookParams, api_version: number | undefined): Promise<string> {
|
|
113
|
+
const data = await createEventData(payload, params, api_version);
|
|
114
|
+
return JSON.stringify({
|
|
115
|
+
workflow_id: params.workflow_id,
|
|
116
|
+
workflow_name: getWorkflowName(params.workflow_type),
|
|
117
|
+
workflow_run_id: params.workflow_run_id,
|
|
118
|
+
event_name: params.event_name,
|
|
119
|
+
detail: data,
|
|
120
|
+
} satisfies WebhookNotificationPayload);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function createEventData(payload: WorkflowExecutionBaseParams, params: NotifyWebhookParams, api_version: number | undefined): Promise<any> {
|
|
124
|
+
const data = params.detail;
|
|
125
|
+
if (data && data.run_id && params.event_name === "workflow_completed" && params.workflow_type === 'ExecuteInteractionWorkflow') {
|
|
126
|
+
const client = getVersionedVertesiaClient(payload, api_version); //ensure client is initialized
|
|
127
|
+
// we replace the result property with the full execution run object
|
|
128
|
+
return await client.runs.retrieve(data.run_id);
|
|
129
|
+
}
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
function getVersionedVertesiaClient(payload: WorkflowExecutionBaseParams, version: string | number | undefined | null) {
|
|
135
|
+
// set the api version header
|
|
136
|
+
return new VertesiaClient(getVertesiaClientOptions(payload)).withApiVersion(version ? String(version) : null);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
// ----------------- Compatibility code -----------------
|
|
141
|
+
/* Before 2025-10-08 the notifyWebhook POST body was in the format:
|
|
142
|
+
|
|
143
|
+
{
|
|
144
|
+
"workflowId": "generation:ExecuteInteractionWorkflow:WhatColor:ox8wu6t4",
|
|
145
|
+
"runId": "0199c2c6-818f-77eb-b931-c1ba8b9e5184",
|
|
146
|
+
"status": "completed",
|
|
147
|
+
"result": {
|
|
148
|
+
"run_id": "68e616274b0e9bb510462378",
|
|
149
|
+
"status": "completed",
|
|
150
|
+
"result": {"Color": "white"}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
After Versions.COMPLETION_RESULT_V1 (20250925) when the completion result interface changed we improved the
|
|
155
|
+
payload to the current format:
|
|
156
|
+
|
|
157
|
+
{
|
|
158
|
+
"workflow_id": "generation:ExecuteInteractionWorkflow:WhatColor:bdedqjqj6",
|
|
159
|
+
"workflow_name": "ExecuteInteraction",
|
|
160
|
+
"workflow_run_id": "0199c2d4-6b1d-7cf2-a1e5-4cac6778091e",
|
|
161
|
+
"event_name": "workflow_completed",
|
|
162
|
+
"detail": ExecutionRun
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
where ExecutionRun contains a result property with the new completion result format.
|
|
166
|
+
|
|
167
|
+
"result": [
|
|
168
|
+
{
|
|
169
|
+
"type": "json",
|
|
170
|
+
"value": {
|
|
171
|
+
"Color": "white"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
//@ts-ignore
|
|
179
|
+
async function createOldRequestBody(payload: WorkflowExecutionBaseParams, params: NotifyWebhookParams): Promise<string> {
|
|
180
|
+
let data = params.detail;
|
|
181
|
+
if (data && data.run_id && params.event_name === "workflow_completed" && params.workflow_type === 'ExecuteInteractionWorkflow') {
|
|
182
|
+
const client = getVersionedVertesiaClient(payload, null); //ensure client is using no specific version
|
|
183
|
+
const run = await client.runs.retrieve(data.run_id);
|
|
184
|
+
// since we use an unversioned client the run will be in old format so we don't need to tranform the result
|
|
185
|
+
const result = run.result;
|
|
186
|
+
data = {
|
|
187
|
+
workflowId: params.workflow_id,
|
|
188
|
+
runId: params.workflow_run_id,
|
|
189
|
+
status: params.event_name === 'workflow_completed' ? 'completed' : params.event_name,
|
|
190
|
+
result: {
|
|
191
|
+
run_id: run.id,
|
|
192
|
+
status: run.status,
|
|
193
|
+
result: result || null
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return JSON.stringify(data || {});
|
|
198
|
+
}
|