@vertesia/workflow 0.24.0-dev.202601221707
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/LICENSE +13 -0
- package/README.md +65 -0
- package/bin/bundle-workflows.mjs +39 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +33 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +73 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +19 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/chunkDocument.js +85 -0
- package/lib/cjs/activities/chunkDocument.js.map +1 -0
- package/lib/cjs/activities/copyParentArtifacts.js +127 -0
- package/lib/cjs/activities/copyParentArtifacts.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 +194 -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 +83 -0
- package/lib/cjs/activities/generateDocumentProperties.js.map +1 -0
- package/lib/cjs/activities/generateEmbeddings.js +257 -0
- package/lib/cjs/activities/generateEmbeddings.js.map +1 -0
- package/lib/cjs/activities/generateOrAssignContentType.js +125 -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 +51 -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/prepareAudio.js +239 -0
- package/lib/cjs/activities/media/prepareAudio.js.map +1 -0
- package/lib/cjs/activities/media/prepareVideo.js +429 -0
- package/lib/cjs/activities/media/prepareVideo.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/saveGladiaTranscription.js +81 -0
- package/lib/cjs/activities/media/saveGladiaTranscription.js.map +1 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +82 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/cjs/activities/notifyWebhook.js +158 -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 +343 -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 +122 -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 +79 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/index.js +56 -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 +72 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js +78 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js +86 -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 +64 -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 +31 -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 +54 -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 +30 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +70 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +16 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/chunkDocument.js +82 -0
- package/lib/esm/activities/chunkDocument.js.map +1 -0
- package/lib/esm/activities/copyParentArtifacts.js +124 -0
- package/lib/esm/activities/copyParentArtifacts.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 +190 -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 +80 -0
- package/lib/esm/activities/generateDocumentProperties.js.map +1 -0
- package/lib/esm/activities/generateEmbeddings.js +254 -0
- package/lib/esm/activities/generateEmbeddings.js.map +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js +122 -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 +25 -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/prepareAudio.js +200 -0
- package/lib/esm/activities/media/prepareAudio.js.map +1 -0
- package/lib/esm/activities/media/prepareVideo.js +390 -0
- package/lib/esm/activities/media/prepareVideo.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/saveGladiaTranscription.js +78 -0
- package/lib/esm/activities/media/saveGladiaTranscription.js.map +1 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +79 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/esm/activities/notifyWebhook.js +155 -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 +336 -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 +117 -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 +69 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.js +38 -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 +69 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generatePart.js +75 -0
- package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generateToc.js +83 -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 +54 -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 +27 -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 +45 -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/copyParentArtifacts.d.ts +19 -0
- package/lib/types/activities/copyParentArtifacts.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 +25 -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/prepareAudio.d.ts +25 -0
- package/lib/types/activities/media/prepareAudio.d.ts.map +1 -0
- package/lib/types/activities/media/prepareVideo.d.ts +30 -0
- package/lib/types/activities/media/prepareVideo.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/saveGladiaTranscription.d.ts +14 -0
- package/lib/types/activities/media/saveGladiaTranscription.d.ts.map +1 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +19 -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 +37 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/index.d.ts +37 -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 +26 -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 +8 -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 +17213 -0
- package/package.json +146 -0
- package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +55 -0
- package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +119 -0
- package/src/activities/advanced/updateDocumentFromInteractionRun.ts +35 -0
- package/src/activities/chunkDocument.ts +146 -0
- package/src/activities/copyParentArtifacts.ts +162 -0
- package/src/activities/createDocumentFromOther.ts +92 -0
- package/src/activities/executeInteraction.ts +300 -0
- package/src/activities/extractDocumentText.ts +205 -0
- package/src/activities/generateDocumentProperties.ts +120 -0
- package/src/activities/generateEmbeddings.ts +387 -0
- package/src/activities/generateOrAssignContentType.ts +218 -0
- package/src/activities/getObjectFromStore.ts +31 -0
- package/src/activities/handleError.ts +25 -0
- package/src/activities/index-dsl.ts +25 -0
- package/src/activities/index.ts +4 -0
- package/src/activities/media/prepareAudio.ts +334 -0
- package/src/activities/media/prepareVideo.ts +622 -0
- package/src/activities/media/processPdfWithTextract.ts +141 -0
- package/src/activities/media/saveGladiaTranscription.ts +128 -0
- package/src/activities/media/transcribeMediaWithGladia.ts +117 -0
- package/src/activities/notifyWebhook.test.ts +134 -0
- package/src/activities/notifyWebhook.ts +199 -0
- package/src/activities/rateLimiter.ts +41 -0
- package/src/activities/renditions/generateImageRendition.ts +111 -0
- package/src/activities/renditions/generateVideoRendition.ts +293 -0
- package/src/activities/setDocumentStatus.ts +25 -0
- package/src/conversion/TextractProcessor.ts +506 -0
- package/src/conversion/image.test.ts +118 -0
- package/src/conversion/image.ts +168 -0
- package/src/conversion/markitdown.ts +41 -0
- package/src/conversion/mutool.test.ts +74 -0
- package/src/conversion/mutool.ts +180 -0
- package/src/conversion/pandoc.test.ts +24 -0
- package/src/conversion/pandoc.ts +40 -0
- package/src/dsl/conditions.ts +76 -0
- package/src/dsl/dsl-workflow.test.ts +58 -0
- package/src/dsl/dsl-workflow.ts +397 -0
- package/src/dsl/dslProxyActivities.ts +38 -0
- package/src/dsl/ms.d.ts +11 -0
- package/src/dsl/projections.test.ts +159 -0
- package/src/dsl/projections.ts +72 -0
- package/src/dsl/setup/ActivityContext.ts +178 -0
- package/src/dsl/setup/fetch/DataProvider.ts +45 -0
- package/src/dsl/setup/fetch/index.ts +19 -0
- package/src/dsl/setup/fetch/providers.ts +67 -0
- package/src/dsl/test/test-child-workflow.ts +6 -0
- package/src/dsl/validation.test.ts +257 -0
- package/src/dsl/validation.ts +125 -0
- package/src/dsl/vars.test.ts +245 -0
- package/src/dsl/vars.ts +340 -0
- package/src/dsl/walk.test.ts +81 -0
- package/src/dsl/walk.ts +103 -0
- package/src/dsl/workflow-exec-child.test.ts +273 -0
- package/src/dsl/workflow-fetch.test.ts +138 -0
- package/src/dsl/workflow-import.test.ts +89 -0
- package/src/dsl/workflow.test.ts +122 -0
- package/src/dsl.ts +3 -0
- package/src/errors.ts +101 -0
- package/src/index.ts +41 -0
- package/src/iterative-generation/activities/extractToc.ts +63 -0
- package/src/iterative-generation/activities/finalizeOutput.ts +100 -0
- package/src/iterative-generation/activities/generatePart.ts +123 -0
- package/src/iterative-generation/activities/generateToc.ts +116 -0
- package/src/iterative-generation/activities/index.ts +4 -0
- package/src/iterative-generation/iterativeGenerationWorkflow.ts +68 -0
- package/src/iterative-generation/types.ts +99 -0
- package/src/iterative-generation/utils.ts +126 -0
- package/src/result-types.ts +25 -0
- package/src/system/notifyWebhookWorkflow.ts +70 -0
- package/src/system/recalculateEmbeddingsWorkflow.ts +41 -0
- package/src/utils/auth.ts +10 -0
- package/src/utils/blobs.ts +59 -0
- package/src/utils/chunks.ts +17 -0
- package/src/utils/client.ts +46 -0
- package/src/utils/expand-vars.ts +31 -0
- package/src/utils/memory.ts +61 -0
- package/src/utils/renditions.ts +127 -0
- package/src/utils/storage.ts +60 -0
- package/src/utils/tokens.ts +44 -0
- package/src/vars.ts +3 -0
- package/src/workflows.ts +7 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { log, activityInfo } from "@temporalio/activity";
|
|
2
|
+
import { VertesiaClient } from "@vertesia/client";
|
|
3
|
+
import {
|
|
4
|
+
DSLActivityExecutionPayload,
|
|
5
|
+
DSLWorkflowExecutionPayload,
|
|
6
|
+
Project,
|
|
7
|
+
WorkflowExecutionPayload,
|
|
8
|
+
} from "@vertesia/common";
|
|
9
|
+
import {
|
|
10
|
+
DocumentNotFoundError,
|
|
11
|
+
WorkflowParamNotFoundError,
|
|
12
|
+
} from "../../errors.js";
|
|
13
|
+
import { getProjectFromToken } from "../../utils/auth.js";
|
|
14
|
+
import { getVertesiaClient } from "../../utils/client.js";
|
|
15
|
+
import { Vars } from "../vars.js";
|
|
16
|
+
import {
|
|
17
|
+
getFetchProvider,
|
|
18
|
+
registerFetchProviderFactory,
|
|
19
|
+
} from "./fetch/index.js";
|
|
20
|
+
import {
|
|
21
|
+
DocumentProvider,
|
|
22
|
+
DocumentTypeProvider,
|
|
23
|
+
InteractionRunProvider,
|
|
24
|
+
} from "./fetch/providers.js";
|
|
25
|
+
|
|
26
|
+
registerFetchProviderFactory(DocumentProvider.ID, DocumentProvider.factory);
|
|
27
|
+
registerFetchProviderFactory(
|
|
28
|
+
DocumentTypeProvider.ID,
|
|
29
|
+
DocumentTypeProvider.factory,
|
|
30
|
+
);
|
|
31
|
+
registerFetchProviderFactory(
|
|
32
|
+
InteractionRunProvider.ID,
|
|
33
|
+
InteractionRunProvider.factory,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export class ActivityContext<ParamsT extends Record<string, any>> {
|
|
37
|
+
client: VertesiaClient;
|
|
38
|
+
_project?: Promise<Project | undefined>;
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
public payload: DSLActivityExecutionPayload<ParamsT>,
|
|
42
|
+
client: VertesiaClient,
|
|
43
|
+
public params: ParamsT,
|
|
44
|
+
) {
|
|
45
|
+
this.client = client;
|
|
46
|
+
this.fetchProject = this.fetchProject.bind(this);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get objectIds() {
|
|
50
|
+
return this.payload.objectIds;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get objectId() {
|
|
54
|
+
const objectId = this.payload.objectIds && this.payload.objectIds[0];
|
|
55
|
+
if (!objectId) {
|
|
56
|
+
log.error("No objectId found in payload");
|
|
57
|
+
throw new WorkflowParamNotFoundError(
|
|
58
|
+
"objectIds[0]",
|
|
59
|
+
(
|
|
60
|
+
this
|
|
61
|
+
.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload
|
|
62
|
+
).workflow,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return objectId;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get activityInfo() {
|
|
69
|
+
return activityInfo();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get runId() {
|
|
73
|
+
const runId = activityInfo().workflowExecution.runId;
|
|
74
|
+
if (!runId) {
|
|
75
|
+
log.error("No runId found in activityInfo");
|
|
76
|
+
throw new WorkflowParamNotFoundError(
|
|
77
|
+
"runId",
|
|
78
|
+
(
|
|
79
|
+
this
|
|
80
|
+
.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload
|
|
81
|
+
).workflow,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return runId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get workflowId() {
|
|
88
|
+
const workflowId = activityInfo().workflowExecution.workflowId;
|
|
89
|
+
if (!workflowId) {
|
|
90
|
+
log.error("No workflowId found in activityInfo");
|
|
91
|
+
throw new WorkflowParamNotFoundError(
|
|
92
|
+
"workflowId",
|
|
93
|
+
(
|
|
94
|
+
this
|
|
95
|
+
.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload
|
|
96
|
+
).workflow,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return workflowId;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fetchProject() {
|
|
103
|
+
if (!this._project) {
|
|
104
|
+
this._project = _fetchProject(this.client, this.payload);
|
|
105
|
+
}
|
|
106
|
+
return this._project;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function setupActivity<ParamsT extends Record<string, any>>(
|
|
111
|
+
payload: DSLActivityExecutionPayload<ParamsT>,
|
|
112
|
+
) {
|
|
113
|
+
const isDebugMode = !!payload.debug_mode;
|
|
114
|
+
|
|
115
|
+
const vars = new Vars({
|
|
116
|
+
...payload.params, // imported params (doesn't contain expressions)
|
|
117
|
+
...payload.activity.params, // activity params (may contain expressions)
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
//}
|
|
121
|
+
if (isDebugMode) {
|
|
122
|
+
log.info(`Setting up activity ${payload.activity.name}`, {
|
|
123
|
+
config: payload.config,
|
|
124
|
+
activity: payload.activity,
|
|
125
|
+
params: payload.params,
|
|
126
|
+
vars,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const client = await getVertesiaClient(payload);
|
|
131
|
+
const fetchSpecs = payload.activity.fetch;
|
|
132
|
+
if (fetchSpecs) {
|
|
133
|
+
const keys = Object.keys(fetchSpecs);
|
|
134
|
+
if (keys.length > 0) {
|
|
135
|
+
// create a new Vars instance to store the fetched data
|
|
136
|
+
for (const key of keys) {
|
|
137
|
+
let fetchSpec = fetchSpecs[key];
|
|
138
|
+
let query = fetchSpec.query;
|
|
139
|
+
if (query) {
|
|
140
|
+
query = vars.resolveParams(query);
|
|
141
|
+
fetchSpec = { ...fetchSpec, query };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const provider = getFetchProvider(client, fetchSpec);
|
|
145
|
+
|
|
146
|
+
log.info(
|
|
147
|
+
`Fetching data for ${key} with provider ${provider.name}`,
|
|
148
|
+
{ fetchSpec },
|
|
149
|
+
);
|
|
150
|
+
const result = await provider.fetch(fetchSpec);
|
|
151
|
+
if (result && result.length > 0) {
|
|
152
|
+
if (fetchSpec.limit === 1) {
|
|
153
|
+
vars.setValue(key, result[0]);
|
|
154
|
+
} else {
|
|
155
|
+
vars.setValue(key, result);
|
|
156
|
+
}
|
|
157
|
+
} else if (fetchSpec.on_not_found === "throw") {
|
|
158
|
+
throw new DocumentNotFoundError(
|
|
159
|
+
"No documents found for: " + JSON.stringify(fetchSpec),
|
|
160
|
+
);
|
|
161
|
+
} else {
|
|
162
|
+
vars.setValue(key, null);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const params = vars.resolve() as ParamsT;
|
|
169
|
+
return new ActivityContext<ParamsT>(payload, client, params);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function _fetchProject(
|
|
173
|
+
client: VertesiaClient,
|
|
174
|
+
payload: WorkflowExecutionPayload,
|
|
175
|
+
) {
|
|
176
|
+
const project = await getProjectFromToken(payload.auth_token);
|
|
177
|
+
return project ? await client.projects.retrieve(project.id) : undefined;
|
|
178
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FindPayload } from "@vertesia/common";
|
|
2
|
+
|
|
3
|
+
function parseSelector(selector: string) {
|
|
4
|
+
const parts = selector.split(/\s+/);
|
|
5
|
+
const result: Record<string, number> = {};
|
|
6
|
+
for (const part of parts) {
|
|
7
|
+
if (part.startsWith("-")) {
|
|
8
|
+
result[part.substring(1)] = 0;
|
|
9
|
+
} else {
|
|
10
|
+
result[part] = 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function applyProjection(result: Record<string, any>, select: string) {
|
|
17
|
+
if (!result) return result;
|
|
18
|
+
let selectorObj: Record<string, number | boolean>;
|
|
19
|
+
if (typeof select === 'string') {
|
|
20
|
+
selectorObj = parseSelector(select);
|
|
21
|
+
} else {
|
|
22
|
+
selectorObj = select;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const out: Record<string, any> = {};
|
|
26
|
+
for (const key of Object.keys(result)) {
|
|
27
|
+
if (selectorObj[key]) {
|
|
28
|
+
out[key] = result[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export abstract class DataProvider {
|
|
35
|
+
constructor(public name: string, public isProjectionSupported = false) {
|
|
36
|
+
}
|
|
37
|
+
async fetch(payload: FindPayload) {
|
|
38
|
+
let results = await this.doFetch(payload);
|
|
39
|
+
if (payload.select && !this.isProjectionSupported) {
|
|
40
|
+
results = results.map((result: Record<string, any>) => applyProjection(result, payload.select!));
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
abstract doFetch(payload: FindPayload): Promise<Record<string, any>[]>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActivityFetchSpec } from "@vertesia/common";
|
|
2
|
+
import { VertesiaClient } from "@vertesia/client";
|
|
3
|
+
import { DataProvider } from "./DataProvider.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const factories: Record<string, ((client: VertesiaClient, source?: string) => DataProvider)> = {};
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function registerFetchProviderFactory(name: string, factory: ((client: VertesiaClient) => DataProvider)) {
|
|
10
|
+
factories[name] = factory;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getFetchProvider(client: VertesiaClient, fetchSpec: ActivityFetchSpec) {
|
|
14
|
+
const factory = factories[fetchSpec.type];
|
|
15
|
+
if (!factory) {
|
|
16
|
+
throw new Error("Unknown data provider: " + fetchSpec.source);
|
|
17
|
+
}
|
|
18
|
+
return factory(client, fetchSpec.source);
|
|
19
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { FindPayload } from "@vertesia/common";
|
|
2
|
+
import { VertesiaClient } from "@vertesia/client";
|
|
3
|
+
import { DataProvider } from "./DataProvider.js";
|
|
4
|
+
|
|
5
|
+
function useMongoId(query: Record<string, any>) {
|
|
6
|
+
if (query.id) {
|
|
7
|
+
const result = { ...query, _id: query.id }
|
|
8
|
+
delete (result as any).id;
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
return query;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class DocumentProvider extends DataProvider {
|
|
15
|
+
static ID = "document";
|
|
16
|
+
constructor(public client: VertesiaClient) {
|
|
17
|
+
super(DocumentProvider.ID, true);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
doFetch(payload: FindPayload): Promise<Record<string, any>[]> {
|
|
21
|
+
const query = useMongoId(payload.query);
|
|
22
|
+
return this.client.objects.find({
|
|
23
|
+
query, select: payload.select, limit: payload.limit
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static factory(client: VertesiaClient) {
|
|
28
|
+
return new DocumentProvider(client);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class DocumentTypeProvider extends DataProvider {
|
|
33
|
+
static ID = "document_type";
|
|
34
|
+
constructor(public client: VertesiaClient) {
|
|
35
|
+
super(DocumentTypeProvider.ID, true);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
doFetch(payload: FindPayload): Promise<Record<string, any>[]> {
|
|
39
|
+
const query = useMongoId(payload.query);
|
|
40
|
+
return this.client.types.find({
|
|
41
|
+
query, select: payload.select, limit: payload.limit
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static factory(client: VertesiaClient) {
|
|
46
|
+
return new DocumentTypeProvider(client);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class InteractionRunProvider extends DataProvider {
|
|
51
|
+
static ID = "interaction_run";
|
|
52
|
+
constructor(public client: VertesiaClient) {
|
|
53
|
+
super(DocumentProvider.ID, true);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
doFetch(payload: FindPayload): Promise<Record<string, any>[]> {
|
|
57
|
+
const query = useMongoId(payload.query);
|
|
58
|
+
return this.client.runs.find({
|
|
59
|
+
query, select: payload.select, limit: payload.limit
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static factory(client: VertesiaClient) {
|
|
64
|
+
return new InteractionRunProvider(client);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { validateWorkflow } from "./validation.ts";
|
|
3
|
+
|
|
4
|
+
describe('workflow validation', () => {
|
|
5
|
+
|
|
6
|
+
test('empty object is not a valid workflow', () => {
|
|
7
|
+
const workflow: any = {
|
|
8
|
+
}
|
|
9
|
+
const errors = validateWorkflow(workflow);
|
|
10
|
+
expect(errors.length).toBe(2);
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('activities is required', () => {
|
|
14
|
+
const workflow: any = {
|
|
15
|
+
name: "test",
|
|
16
|
+
}
|
|
17
|
+
const errors = validateWorkflow(workflow);
|
|
18
|
+
expect(errors.length).toBe(1);
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('activities should be an array', () => {
|
|
22
|
+
const workflow: any = {
|
|
23
|
+
name: "test",
|
|
24
|
+
activities: {}
|
|
25
|
+
}
|
|
26
|
+
const errors = validateWorkflow(workflow);
|
|
27
|
+
expect(errors.length).toBe(1);
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('activities array should have at least one item', () => {
|
|
31
|
+
const workflow: any = {
|
|
32
|
+
name: "test",
|
|
33
|
+
activities: []
|
|
34
|
+
}
|
|
35
|
+
const errors = validateWorkflow(workflow);
|
|
36
|
+
expect(errors.length).toBe(1);
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('activity should have a name', () => {
|
|
40
|
+
const workflow: any = {
|
|
41
|
+
name: "test",
|
|
42
|
+
activities: [{}]
|
|
43
|
+
}
|
|
44
|
+
const errors = validateWorkflow(workflow);
|
|
45
|
+
expect(errors.length).toBe(1);
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('allow empty activity', () => {
|
|
49
|
+
const workflow: any = {
|
|
50
|
+
name: "test",
|
|
51
|
+
activities: [{ name: "test" }]
|
|
52
|
+
}
|
|
53
|
+
const errors = validateWorkflow(workflow);
|
|
54
|
+
expect(errors.length).toBe(0);
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('import undeclared var', () => {
|
|
58
|
+
const workflow: any = {
|
|
59
|
+
name: "test",
|
|
60
|
+
vars: { "foo": true },
|
|
61
|
+
activities: [{
|
|
62
|
+
name: "test",
|
|
63
|
+
import: ["foo", "bar"]
|
|
64
|
+
}]
|
|
65
|
+
}
|
|
66
|
+
const errors = validateWorkflow(workflow);
|
|
67
|
+
expect(errors.length).toBe(1);
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
test('import declared vars', () => {
|
|
72
|
+
const workflow: any = {
|
|
73
|
+
name: "test",
|
|
74
|
+
vars: { "foo": true, "bar": true },
|
|
75
|
+
activities: [{
|
|
76
|
+
name: "test",
|
|
77
|
+
import: ["foo", "bar"]
|
|
78
|
+
}]
|
|
79
|
+
}
|
|
80
|
+
const errors = validateWorkflow(workflow);
|
|
81
|
+
expect(errors.length).toBe(0);
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('import unknown imported var through expressions', () => {
|
|
85
|
+
const workflow: any = {
|
|
86
|
+
name: "test",
|
|
87
|
+
vars: { "foo": true },
|
|
88
|
+
activities: [{
|
|
89
|
+
name: "test",
|
|
90
|
+
import: [{ "foo": "foo", "barLen": "bar.length" }]
|
|
91
|
+
}]
|
|
92
|
+
}
|
|
93
|
+
const errors = validateWorkflow(workflow);
|
|
94
|
+
expect(errors.length).toBe(1);
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
test('import declared vars through expressions', () => {
|
|
98
|
+
const workflow: any = {
|
|
99
|
+
name: "test",
|
|
100
|
+
vars: { "foo": true, "bar": "true" },
|
|
101
|
+
activities: [{
|
|
102
|
+
name: "test",
|
|
103
|
+
import: [{ "foo": "foo", "barLen": "bar.length" }]
|
|
104
|
+
}]
|
|
105
|
+
}
|
|
106
|
+
const errors = validateWorkflow(workflow);
|
|
107
|
+
expect(errors.length).toBe(0);
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
test('detect self references', () => {
|
|
111
|
+
const workflow: any = {
|
|
112
|
+
name: "test",
|
|
113
|
+
vars: { "object_type": "thetype" },
|
|
114
|
+
activities: [{
|
|
115
|
+
name: "test",
|
|
116
|
+
import: ["object_type"],
|
|
117
|
+
params: {
|
|
118
|
+
"object_type": "${object_type}"
|
|
119
|
+
}
|
|
120
|
+
}]
|
|
121
|
+
}
|
|
122
|
+
const errors = validateWorkflow(workflow);
|
|
123
|
+
expect(errors.length).toBe(1);
|
|
124
|
+
expect(errors[0].includes("Self referencing parameter")).toBe(true);
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('reference known vars in fetch', () => {
|
|
128
|
+
const workflow: any = {
|
|
129
|
+
name: "test",
|
|
130
|
+
vars: { "foo": true, "bar": "true" },
|
|
131
|
+
activities: [{
|
|
132
|
+
name: "test",
|
|
133
|
+
import: [{ "foo": "foo", "barLen": "bar.length" }],
|
|
134
|
+
fetch: {
|
|
135
|
+
doc: {
|
|
136
|
+
query: {
|
|
137
|
+
foo: "${foo}",
|
|
138
|
+
barLen: "${barLen}"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}]
|
|
143
|
+
}
|
|
144
|
+
const errors = validateWorkflow(workflow);
|
|
145
|
+
console.log('##############errors', errors);
|
|
146
|
+
|
|
147
|
+
expect(errors.length).toBe(0);
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('reference unknown vars in fetch', () => {
|
|
151
|
+
const workflow: any = {
|
|
152
|
+
name: "test",
|
|
153
|
+
vars: { "foo": true, "bar": "true" },
|
|
154
|
+
activities: [{
|
|
155
|
+
name: "test",
|
|
156
|
+
import: [],
|
|
157
|
+
fetch: {
|
|
158
|
+
doc: {
|
|
159
|
+
query: {
|
|
160
|
+
foo: "${foo}",
|
|
161
|
+
barLen: "${barLen}"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}]
|
|
166
|
+
}
|
|
167
|
+
const errors = validateWorkflow(workflow);
|
|
168
|
+
expect(errors.length).toBe(2);
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
test('reference one unknown and one known var in fetch', () => {
|
|
172
|
+
const workflow: any = {
|
|
173
|
+
name: "test",
|
|
174
|
+
vars: { "foo": true, "bar": "true" },
|
|
175
|
+
activities: [{
|
|
176
|
+
name: "test",
|
|
177
|
+
import: ["foo"],
|
|
178
|
+
fetch: {
|
|
179
|
+
doc: {
|
|
180
|
+
query: {
|
|
181
|
+
foo: "${foo}",
|
|
182
|
+
barLen: "${barLen}"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}]
|
|
187
|
+
}
|
|
188
|
+
const errors = validateWorkflow(workflow);
|
|
189
|
+
expect(errors.length).toBe(1);
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
test('reference 2 unknown vars in params', () => {
|
|
193
|
+
const workflow: any = {
|
|
194
|
+
name: "test",
|
|
195
|
+
vars: { "foo": true, "bar": "true" },
|
|
196
|
+
activities: [{
|
|
197
|
+
name: "test",
|
|
198
|
+
import: ["foo"],
|
|
199
|
+
params: {
|
|
200
|
+
barLength: "${barLen}",
|
|
201
|
+
doc: "${doc.text}"
|
|
202
|
+
}
|
|
203
|
+
}]
|
|
204
|
+
}
|
|
205
|
+
const errors = validateWorkflow(workflow);
|
|
206
|
+
expect(errors.length).toBe(2);
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
test('reference 1 unknown vars in params', () => {
|
|
210
|
+
const workflow: any = {
|
|
211
|
+
name: "test",
|
|
212
|
+
vars: { "foo": true, "bar": "true" },
|
|
213
|
+
activities: [{
|
|
214
|
+
name: "test",
|
|
215
|
+
import: ["foo", { "barLen": "bar.length" }],
|
|
216
|
+
params: {
|
|
217
|
+
barLength: "${barLen}",
|
|
218
|
+
doc: "${doc.text}"
|
|
219
|
+
}
|
|
220
|
+
}]
|
|
221
|
+
}
|
|
222
|
+
const errors = validateWorkflow(workflow);
|
|
223
|
+
expect(errors.length).toBe(1);
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
test('reference known vars in params', () => {
|
|
227
|
+
const workflow: any = {
|
|
228
|
+
name: "test",
|
|
229
|
+
vars: { "foo": true, "bar": "true" },
|
|
230
|
+
activities: [
|
|
231
|
+
{
|
|
232
|
+
name: "test0",
|
|
233
|
+
output: "previousResult"
|
|
234
|
+
}, {
|
|
235
|
+
name: "test",
|
|
236
|
+
import: ["foo", { "barLen": "bar.length" }, "previousResult"],
|
|
237
|
+
fetch: {
|
|
238
|
+
doc: {
|
|
239
|
+
query: {
|
|
240
|
+
foo: "${foo}",
|
|
241
|
+
barLen: "${barLen}"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
params: {
|
|
246
|
+
fooParam: "${foo}",
|
|
247
|
+
barLenParam: "${barLen}",
|
|
248
|
+
doc: "${doc.text}",
|
|
249
|
+
prev: "${previousResult}"
|
|
250
|
+
}
|
|
251
|
+
}]
|
|
252
|
+
}
|
|
253
|
+
const errors = validateWorkflow(workflow);
|
|
254
|
+
expect(errors.length).toBe(0);
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
})
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { DSLActivitySpec, DSLWorkflowSpec, DSLWorkflowStep } from "@vertesia/common";
|
|
2
|
+
import { Vars, splitPath } from "./vars.js";
|
|
3
|
+
|
|
4
|
+
export function validateWorkflow(workflow: DSLWorkflowSpec, vars: string[] = []) {
|
|
5
|
+
const errors: string[] = [];
|
|
6
|
+
const workflowVars = new Set(vars);
|
|
7
|
+
workflowVars.add("objectId");
|
|
8
|
+
workflowVars.add("objectIds");
|
|
9
|
+
if (workflow.vars) {
|
|
10
|
+
for (const v of Object.keys(workflow.vars)) {
|
|
11
|
+
workflowVars.add(v);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (!workflow.name) {
|
|
15
|
+
errors.push("Workflow 'name' property is required");
|
|
16
|
+
}
|
|
17
|
+
if (workflow.steps && workflow.activities) {
|
|
18
|
+
errors.push("You must use either 'steps' or 'activities'. You cannot use both. Prefer using steps.");
|
|
19
|
+
return errors;
|
|
20
|
+
}
|
|
21
|
+
if (!workflow.steps && !workflow.activities) {
|
|
22
|
+
errors.push("The workflow requires one of 'steps' or 'activities' properties. Neither is present.");
|
|
23
|
+
return errors;
|
|
24
|
+
}
|
|
25
|
+
const stepsPropName = workflow.steps ? "steps" : "activities";
|
|
26
|
+
const steps = workflow.steps || workflow.activities;
|
|
27
|
+
if (!steps || !Array.isArray(steps)) {
|
|
28
|
+
errors.push(`Workflow '${stepsPropName}' property is required`);
|
|
29
|
+
return errors;
|
|
30
|
+
}
|
|
31
|
+
if (!steps || !Array.isArray(steps)) {
|
|
32
|
+
errors.push(`Workflow '${stepsPropName}' should be an array`);
|
|
33
|
+
return errors;
|
|
34
|
+
}
|
|
35
|
+
if (!steps.length) {
|
|
36
|
+
errors.push("Workflow should have at least one step or activity");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const activities: DSLActivitySpec[] = stepsPropName === "steps" ? (steps as DSLWorkflowStep[]).filter(s => s.type === "activity") : steps;
|
|
40
|
+
for (const activity of activities) {
|
|
41
|
+
const activityErrors = validateActivity(activity, workflowVars);
|
|
42
|
+
if (activityErrors.length > 0) {
|
|
43
|
+
for (const err of activityErrors) {
|
|
44
|
+
errors.push(`Activity "${activity.name}": ${err}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (activity.output) {
|
|
48
|
+
workflowVars.add(activity.output);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return errors;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function validateActivity(activity: DSLActivitySpec, workflowVars: Set<string>): string[] {
|
|
56
|
+
const errors: string[] = [];
|
|
57
|
+
if (!activity.name) {
|
|
58
|
+
errors.push("Activity name is required");
|
|
59
|
+
}
|
|
60
|
+
const importedVars = activity.import;
|
|
61
|
+
const localVars: Record<string, boolean> = {};
|
|
62
|
+
if (importedVars && importedVars.length > 0) {
|
|
63
|
+
for (const entry of importedVars) {
|
|
64
|
+
if (typeof entry === 'string') {
|
|
65
|
+
pushLocalVar(entry, localVars, errors);
|
|
66
|
+
if (!workflowVars.has(entry)) {
|
|
67
|
+
errors.push(`Unknown workflow variable "${entry}" in import declaration`);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
for (const key of Object.keys(entry)) {
|
|
71
|
+
pushLocalVar(key, localVars, errors);
|
|
72
|
+
const wfExpr = entry[key];
|
|
73
|
+
const wfVar = splitPath(wfExpr)[0];
|
|
74
|
+
if (!workflowVars.has(wfVar)) {
|
|
75
|
+
errors.push(`Unknown workflow variable "${wfExpr}" in import declaration`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// collect fetch vars and check expressions in fetch declarations
|
|
83
|
+
const fetch = activity.fetch;
|
|
84
|
+
if (fetch) {
|
|
85
|
+
const keys = Object.keys(fetch);
|
|
86
|
+
for (const key of keys) {
|
|
87
|
+
const query = fetch[key].query;
|
|
88
|
+
// check expressions in query
|
|
89
|
+
validateExpressions(query, localVars, errors);
|
|
90
|
+
}
|
|
91
|
+
for (const key of keys) {
|
|
92
|
+
pushLocalVar(key, localVars, errors);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// check expressions in activity params
|
|
96
|
+
if (activity.params) {
|
|
97
|
+
validateExpressions(activity.params, localVars, errors, true);
|
|
98
|
+
}
|
|
99
|
+
return errors;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
function validateExpressions(target: Record<string, any>, localVars: Record<string, boolean>, errors: string[], checkSelfReference = false) {
|
|
104
|
+
const vars = new Vars(localVars);
|
|
105
|
+
const refs = vars.getUnknownReferences(target);
|
|
106
|
+
for (const ref of refs) {
|
|
107
|
+
errors.push(`Unknown variable "${ref.name}" in expression "${ref.expression}"`)
|
|
108
|
+
}
|
|
109
|
+
if (checkSelfReference) {
|
|
110
|
+
// check for self references like `"object_type": "${object_type}"`.
|
|
111
|
+
for (const key of Object.keys(target)) {
|
|
112
|
+
const value = target[key];
|
|
113
|
+
if (typeof value === 'string' && value.includes("${" + key + "}")) {
|
|
114
|
+
errors.push(`Self referencing parameter "${key}" in expression "${value}"`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function pushLocalVar(v: string, localVars: Record<string, boolean>, errors: string[]) {
|
|
121
|
+
if (localVars[v] === true) {
|
|
122
|
+
errors.push(`Duplicate variable "${v}"`);
|
|
123
|
+
}
|
|
124
|
+
localVars[v] = true;
|
|
125
|
+
}
|