@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
package/src/dsl/walk.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
export type ObjectKey = string | number | undefined;
|
|
3
|
+
export interface ObjectVisitor {
|
|
4
|
+
onStartObject?: (key: ObjectKey, value: any) => void;
|
|
5
|
+
onEndObject?: (key: ObjectKey, value: any) => void;
|
|
6
|
+
onStartIteration?: (key: ObjectKey, value: Iterable<any>) => void;
|
|
7
|
+
onEndIteration?: (key: ObjectKey, value: Iterable<any>) => void;
|
|
8
|
+
onValue?: (key: ObjectKey, value: any) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ObjectWalker {
|
|
12
|
+
supportIterators = false; // only array are supported by default
|
|
13
|
+
constructor(supportIterators = false) {
|
|
14
|
+
this.supportIterators = supportIterators;
|
|
15
|
+
}
|
|
16
|
+
walk(obj: any, visitor: ObjectVisitor) {
|
|
17
|
+
this._walk(undefined, obj, visitor);
|
|
18
|
+
}
|
|
19
|
+
_walk(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
|
|
20
|
+
const type = typeof obj;
|
|
21
|
+
if (!obj || type !== 'object' || obj instanceof Date) {
|
|
22
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
23
|
+
} else if (Array.isArray(obj)) {
|
|
24
|
+
this._walkIterable(key, obj, visitor);
|
|
25
|
+
} else if (this.supportIterators && obj[Symbol.iterator] === 'function') {
|
|
26
|
+
this._walkIterable(key, obj, visitor);
|
|
27
|
+
} else if (obj.constructor === Object) { // a plain object
|
|
28
|
+
this._walkObject(key, obj, visitor);
|
|
29
|
+
} else { // a random object - we treat it as a value
|
|
30
|
+
visitor.onValue && visitor.onValue(key, obj);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_walkIterable(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
|
|
35
|
+
visitor.onStartIteration && visitor.onStartIteration(key, obj);
|
|
36
|
+
let i = 0;
|
|
37
|
+
for (const value of obj) {
|
|
38
|
+
this._walk(i++, value, visitor);
|
|
39
|
+
}
|
|
40
|
+
visitor.onEndIteration && visitor.onEndIteration(key, obj);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_walkObject(key: ObjectKey, obj: any, visitor: ObjectVisitor) {
|
|
44
|
+
visitor.onStartObject && visitor.onStartObject(key, obj);
|
|
45
|
+
for (const k of Object.keys(obj)) {
|
|
46
|
+
this._walk(k, obj[k], visitor);
|
|
47
|
+
}
|
|
48
|
+
visitor.onEndObject && visitor.onEndObject(key, obj);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
map(obj: any, mapFn: (key: ObjectKey, value: any) => any) {
|
|
52
|
+
const visitor = new MapVisitor(mapFn);
|
|
53
|
+
this.walk(obj, visitor);
|
|
54
|
+
return visitor.result;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class MapVisitor implements ObjectVisitor {
|
|
59
|
+
result: any;
|
|
60
|
+
current: any;
|
|
61
|
+
stack: any[] = [];
|
|
62
|
+
constructor(private mapFn: (key: ObjectKey, value: any) => any) { }
|
|
63
|
+
|
|
64
|
+
onStartObject(key: ObjectKey) {
|
|
65
|
+
if (key === undefined) {
|
|
66
|
+
this.result = {};
|
|
67
|
+
this.current = this.result;
|
|
68
|
+
} else {
|
|
69
|
+
this.stack.push(this.current);
|
|
70
|
+
const obj = {};
|
|
71
|
+
this.current[key] = obj;
|
|
72
|
+
this.current = obj;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
onEndObject() {
|
|
76
|
+
this.current = this.stack.pop();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onStartIteration(key: ObjectKey) {
|
|
80
|
+
if (key === undefined) {
|
|
81
|
+
this.result = [];
|
|
82
|
+
this.current = this.result;
|
|
83
|
+
} else {
|
|
84
|
+
this.stack.push(this.current);
|
|
85
|
+
const ar: any[] = [];
|
|
86
|
+
this.current[key] = ar;
|
|
87
|
+
this.current = ar;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onEndIteration() {
|
|
92
|
+
this.current = this.stack.pop();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onValue(key: ObjectKey, value: any) {
|
|
96
|
+
const r = this.mapFn(key, value);
|
|
97
|
+
if (key === undefined) {
|
|
98
|
+
this.result = r;
|
|
99
|
+
} else if (r !== undefined) {
|
|
100
|
+
this.current[key] = r;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import * as protos from '@temporalio/proto';
|
|
2
|
+
import { TestWorkflowEnvironment } from '@temporalio/testing';
|
|
3
|
+
import { Worker } from '@temporalio/worker';
|
|
4
|
+
import { ContentEventName, DSLActivityExecutionPayload, DSLWorkflowExecutionPayload, DSLWorkflowStep } from '@vertesia/common';
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
|
6
|
+
import { dslWorkflow } from './dsl-workflow.js';
|
|
7
|
+
import { setupActivity } from './setup/ActivityContext.js';
|
|
8
|
+
|
|
9
|
+
interface SayHelloParams {
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
interface PrepareResultParams {
|
|
13
|
+
parent: string;
|
|
14
|
+
child: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function sayHelloFromParent(payload: DSLActivityExecutionPayload<SayHelloParams>) {
|
|
18
|
+
const { params } = await setupActivity(payload);
|
|
19
|
+
return `Parent: Hello, ${params.name}!`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function sayHelloFromDSLChild(payload: DSLActivityExecutionPayload<SayHelloParams>) {
|
|
23
|
+
const { params } = await setupActivity(payload);
|
|
24
|
+
return `DSL Child: Hello, ${params.name}!`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function prepareResult(payload: DSLActivityExecutionPayload<PrepareResultParams>) {
|
|
28
|
+
const { params } = await setupActivity(payload);
|
|
29
|
+
return [params.parent, params.child]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const steps1: DSLWorkflowStep[] = [
|
|
33
|
+
{
|
|
34
|
+
type: 'activity',
|
|
35
|
+
name: 'sayHelloFromParent',
|
|
36
|
+
output: 'parent',
|
|
37
|
+
import: ["name"],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'workflow',
|
|
41
|
+
name: 'testChildWorkflow',
|
|
42
|
+
output: 'child',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'activity',
|
|
46
|
+
name: 'prepareResult',
|
|
47
|
+
import: ["parent", "child"],
|
|
48
|
+
output: 'result',
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
const childSteps: DSLWorkflowStep[] = [
|
|
53
|
+
{
|
|
54
|
+
type: 'activity',
|
|
55
|
+
name: 'sayHelloFromDSLChild',
|
|
56
|
+
output: 'result',
|
|
57
|
+
import: ["name"],
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
const steps2: DSLWorkflowStep[] = [
|
|
62
|
+
{
|
|
63
|
+
type: 'activity',
|
|
64
|
+
name: 'sayHelloFromParent',
|
|
65
|
+
output: 'parent',
|
|
66
|
+
import: ["name"],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'workflow',
|
|
70
|
+
name: 'dslWorkflow',
|
|
71
|
+
output: 'child',
|
|
72
|
+
spec: {
|
|
73
|
+
name: 'testChildWorkflow',
|
|
74
|
+
steps: childSteps,
|
|
75
|
+
vars: {}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'activity',
|
|
80
|
+
name: 'prepareResult',
|
|
81
|
+
import: ["parent", "child"],
|
|
82
|
+
output: 'result',
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
const steps3: DSLWorkflowStep[] = [
|
|
87
|
+
{
|
|
88
|
+
type: 'activity',
|
|
89
|
+
name: 'sayHelloFromParent',
|
|
90
|
+
output: 'parent',
|
|
91
|
+
import: ["name"],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'workflow',
|
|
95
|
+
name: 'dslWorkflow',
|
|
96
|
+
output: 'child',
|
|
97
|
+
spec: {
|
|
98
|
+
name: 'testChildWorkflow',
|
|
99
|
+
steps: childSteps,
|
|
100
|
+
vars: {}
|
|
101
|
+
},
|
|
102
|
+
vars: {
|
|
103
|
+
storeUrl: 'store:${objectIds[0]}',
|
|
104
|
+
name: '${name}'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'activity',
|
|
109
|
+
name: 'prepareResult',
|
|
110
|
+
import: ["parent", "child"],
|
|
111
|
+
output: 'result',
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
// ========== test env setup ==========
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
describe('DSL Workflow with child workflows', () => {
|
|
120
|
+
|
|
121
|
+
let testEnv: TestWorkflowEnvironment;
|
|
122
|
+
|
|
123
|
+
beforeAll(async () => {
|
|
124
|
+
testEnv = await TestWorkflowEnvironment.createLocal();
|
|
125
|
+
const { connection } = testEnv;
|
|
126
|
+
await connection.operatorService.addSearchAttributes({
|
|
127
|
+
namespace: 'default',
|
|
128
|
+
searchAttributes: {
|
|
129
|
+
AccountId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
130
|
+
DocumentId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
131
|
+
ProjectId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
132
|
+
TenantId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
133
|
+
InitiatedBy: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
afterAll(async () => {
|
|
139
|
+
await testEnv?.teardown();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('execute child workflow', async () => {
|
|
143
|
+
const { client, nativeConnection } = testEnv;
|
|
144
|
+
const taskQueue = 'test';
|
|
145
|
+
|
|
146
|
+
const name = 'Foo';
|
|
147
|
+
|
|
148
|
+
const worker = await Worker.create({
|
|
149
|
+
connection: nativeConnection,
|
|
150
|
+
taskQueue,
|
|
151
|
+
workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
|
|
152
|
+
activities: { sayHelloFromParent, prepareResult },
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const payload: DSLWorkflowExecutionPayload = {
|
|
156
|
+
event: ContentEventName.create,
|
|
157
|
+
objectIds: ['123'],
|
|
158
|
+
vars: {},
|
|
159
|
+
account_id: '123',
|
|
160
|
+
project_id: '123',
|
|
161
|
+
wf_rule_name: 'test',
|
|
162
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
163
|
+
config: {
|
|
164
|
+
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
165
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
166
|
+
},
|
|
167
|
+
workflow: {
|
|
168
|
+
steps: steps1,
|
|
169
|
+
vars: {
|
|
170
|
+
name,
|
|
171
|
+
},
|
|
172
|
+
name: 'test',
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
|
|
177
|
+
args: [payload],
|
|
178
|
+
workflowId: 'test',
|
|
179
|
+
taskQueue,
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
expect(result).toEqual([`Parent: Hello, ${name}!`, `Child: Hello, ${name}!`]);
|
|
183
|
+
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('execute DSL child workflow', async () => {
|
|
187
|
+
const { client, nativeConnection } = testEnv;
|
|
188
|
+
const taskQueue = 'test';
|
|
189
|
+
|
|
190
|
+
const name = 'Bar';
|
|
191
|
+
|
|
192
|
+
const worker = await Worker.create({
|
|
193
|
+
connection: nativeConnection,
|
|
194
|
+
taskQueue,
|
|
195
|
+
workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
|
|
196
|
+
activities: { sayHelloFromParent, prepareResult, sayHelloFromDSLChild },
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const payload: DSLWorkflowExecutionPayload = {
|
|
200
|
+
event: ContentEventName.create,
|
|
201
|
+
objectIds: ['123'],
|
|
202
|
+
vars: {},
|
|
203
|
+
account_id: '123',
|
|
204
|
+
project_id: '123',
|
|
205
|
+
wf_rule_name: 'test',
|
|
206
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
207
|
+
config: {
|
|
208
|
+
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
209
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
210
|
+
},
|
|
211
|
+
workflow: {
|
|
212
|
+
steps: steps2,
|
|
213
|
+
vars: {
|
|
214
|
+
name,
|
|
215
|
+
},
|
|
216
|
+
name: 'test',
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
|
|
221
|
+
args: [payload],
|
|
222
|
+
workflowId: 'test',
|
|
223
|
+
taskQueue,
|
|
224
|
+
}));
|
|
225
|
+
|
|
226
|
+
expect(result).toEqual([`Parent: Hello, ${name}!`, `DSL Child: Hello, ${name}!`]);
|
|
227
|
+
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test('execute DSL child workflow with variable resolution', async () => {
|
|
231
|
+
const { client, nativeConnection } = testEnv;
|
|
232
|
+
const taskQueue = 'test';
|
|
233
|
+
|
|
234
|
+
const name = 'Baz';
|
|
235
|
+
|
|
236
|
+
const worker = await Worker.create({
|
|
237
|
+
connection: nativeConnection,
|
|
238
|
+
taskQueue,
|
|
239
|
+
workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
|
|
240
|
+
activities: { sayHelloFromParent, prepareResult, sayHelloFromDSLChild },
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const payload: DSLWorkflowExecutionPayload = {
|
|
244
|
+
event: ContentEventName.create,
|
|
245
|
+
objectIds: ['doc123'],
|
|
246
|
+
vars: {},
|
|
247
|
+
account_id: '123',
|
|
248
|
+
project_id: '123',
|
|
249
|
+
wf_rule_name: 'test',
|
|
250
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
251
|
+
config: {
|
|
252
|
+
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
253
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
254
|
+
},
|
|
255
|
+
workflow: {
|
|
256
|
+
steps: steps3,
|
|
257
|
+
vars: {
|
|
258
|
+
name,
|
|
259
|
+
},
|
|
260
|
+
name: 'test',
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
|
|
265
|
+
args: [payload],
|
|
266
|
+
workflowId: 'test-vars',
|
|
267
|
+
taskQueue,
|
|
268
|
+
}));
|
|
269
|
+
|
|
270
|
+
expect(result).toEqual([`Parent: Hello, ${name}!`, `DSL Child: Hello, ${name}!`]);
|
|
271
|
+
|
|
272
|
+
});
|
|
273
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { VertesiaClient } from '@vertesia/client';
|
|
2
|
+
import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload, FindPayload } from '@vertesia/common';
|
|
3
|
+
import { TestWorkflowEnvironment } from '@temporalio/testing';
|
|
4
|
+
import { Worker } from '@temporalio/worker';
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
6
|
+
import { dslWorkflow } from './dsl-workflow.js';
|
|
7
|
+
import { setupActivity } from "./setup/ActivityContext.js";
|
|
8
|
+
import { DataProvider } from './setup/fetch/DataProvider.js';
|
|
9
|
+
import { registerFetchProviderFactory } from './setup/fetch/index.js';
|
|
10
|
+
|
|
11
|
+
interface SayMessageParams {
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class DocumentTestProvider extends DataProvider {
|
|
16
|
+
|
|
17
|
+
static ID = "document";
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
super(DocumentTestProvider.ID, true);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
doFetch(payload: FindPayload): Promise<Record<string, any>[]> {
|
|
24
|
+
const query = payload.query;
|
|
25
|
+
console.log('query', query);
|
|
26
|
+
if (query.lang === 'en') {
|
|
27
|
+
return Promise.resolve([query.greeting ? { text: 'Hello' } : { text: "World" }])
|
|
28
|
+
} else {
|
|
29
|
+
return Promise.resolve([query.greeting ? { text: 'Bonjour' } : { text: "Monde" }])
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static factory(_context: VertesiaClient) {
|
|
34
|
+
return new DocumentTestProvider();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
registerFetchProviderFactory(DocumentTestProvider.ID, DocumentTestProvider.factory);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async function sayMessage(payload: DSLActivityExecutionPayload<SayMessageParams>): Promise<string> {
|
|
42
|
+
const { params } = await setupActivity(payload);
|
|
43
|
+
return params.message;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const activities: DSLActivitySpec[] = [
|
|
48
|
+
{
|
|
49
|
+
name: 'sayMessage',
|
|
50
|
+
output: 'result',
|
|
51
|
+
import: ["lang"],
|
|
52
|
+
params: {
|
|
53
|
+
message: "${greeting.text}, ${name.text}!"
|
|
54
|
+
},
|
|
55
|
+
fetch: {
|
|
56
|
+
name: {
|
|
57
|
+
type: "document",
|
|
58
|
+
query: {
|
|
59
|
+
lang: "${lang}", greeting: false
|
|
60
|
+
},
|
|
61
|
+
limit: 1,
|
|
62
|
+
},
|
|
63
|
+
greeting: {
|
|
64
|
+
type: "document",
|
|
65
|
+
query: {
|
|
66
|
+
lang: "${lang}", greeting: true
|
|
67
|
+
},
|
|
68
|
+
limit: 1,
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
// ========== test env setup ==========
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
describe('DSL Workflow', () => {
|
|
78
|
+
|
|
79
|
+
let testEnv: TestWorkflowEnvironment;
|
|
80
|
+
|
|
81
|
+
beforeAll(async () => {
|
|
82
|
+
testEnv = await TestWorkflowEnvironment.createLocal();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
afterAll(async () => {
|
|
86
|
+
await testEnv?.teardown();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('successfully completes a mock workflow', async () => {
|
|
90
|
+
const { client, nativeConnection } = testEnv;
|
|
91
|
+
const taskQueue = 'test';
|
|
92
|
+
|
|
93
|
+
const lang = 'en';
|
|
94
|
+
|
|
95
|
+
const worker = await Worker.create({
|
|
96
|
+
connection: nativeConnection,
|
|
97
|
+
taskQueue,
|
|
98
|
+
workflowsPath: new URL("./dsl-workflow.ts", import.meta.url).pathname,
|
|
99
|
+
activities: { sayMessage },
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const payload: DSLWorkflowExecutionPayload = {
|
|
103
|
+
event: ContentEventName.create,
|
|
104
|
+
objectIds: ['123'],
|
|
105
|
+
vars: {},
|
|
106
|
+
account_id: '123',
|
|
107
|
+
project_id: '123',
|
|
108
|
+
timestamp: Date.now(),
|
|
109
|
+
wf_rule_name: 'test',
|
|
110
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
111
|
+
config: {
|
|
112
|
+
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
113
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
114
|
+
},
|
|
115
|
+
workflow: {
|
|
116
|
+
activities,
|
|
117
|
+
vars: {
|
|
118
|
+
lang,
|
|
119
|
+
},
|
|
120
|
+
name: 'test',
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
|
|
125
|
+
args: [payload],
|
|
126
|
+
workflowId: 'test',
|
|
127
|
+
taskQueue,
|
|
128
|
+
}));
|
|
129
|
+
|
|
130
|
+
expect(result).toBe('Hello, World!');
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload } from '@vertesia/common';
|
|
2
|
+
import { TestWorkflowEnvironment } from '@temporalio/testing';
|
|
3
|
+
import { Worker } from '@temporalio/worker';
|
|
4
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
5
|
+
import { dslWorkflow } from './dsl-workflow.js';
|
|
6
|
+
import { setupActivity } from "./setup/ActivityContext.js";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async function testImportedVars(payload: DSLActivityExecutionPayload) {
|
|
10
|
+
const { params } = await setupActivity(payload);
|
|
11
|
+
if (!params.object_name) throw new Error('object_name is required');
|
|
12
|
+
console.log('!!!!!!!!!!@@@@@@@@@@@@@@!!!!!!!!!!!!!!', params.object_name);
|
|
13
|
+
return params.object_name;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const activities: DSLActivitySpec[] = [
|
|
18
|
+
{
|
|
19
|
+
name: 'testImportedVars',
|
|
20
|
+
import: ["object_name"],
|
|
21
|
+
output: 'result',
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
// ========== test env setup ==========
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
describe('DSL Workflow import vars', () => {
|
|
29
|
+
|
|
30
|
+
let testEnv: TestWorkflowEnvironment;
|
|
31
|
+
|
|
32
|
+
beforeAll(async () => {
|
|
33
|
+
testEnv = await TestWorkflowEnvironment.createLocal();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterAll(async () => {
|
|
37
|
+
await testEnv?.teardown();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
it('import vars are part of activity params', async () => {
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const { client, nativeConnection } = testEnv;
|
|
45
|
+
const taskQueue = 'test';
|
|
46
|
+
|
|
47
|
+
const object_name = 'object_name';
|
|
48
|
+
|
|
49
|
+
const worker = await Worker.create({
|
|
50
|
+
connection: nativeConnection,
|
|
51
|
+
taskQueue,
|
|
52
|
+
workflowsPath: new URL("./dsl-workflow.ts", import.meta.url).pathname,
|
|
53
|
+
activities: { testImportedVars },
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const payload: DSLWorkflowExecutionPayload = {
|
|
57
|
+
event: ContentEventName.create,
|
|
58
|
+
objectIds: ['123'],
|
|
59
|
+
vars: {},
|
|
60
|
+
account_id: '123',
|
|
61
|
+
project_id: '123',
|
|
62
|
+
timestamp: Date.now(),
|
|
63
|
+
wf_rule_name: 'test',
|
|
64
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
65
|
+
config: {
|
|
66
|
+
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
67
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
68
|
+
},
|
|
69
|
+
workflow: {
|
|
70
|
+
activities,
|
|
71
|
+
vars: {
|
|
72
|
+
object_name,
|
|
73
|
+
},
|
|
74
|
+
name: 'test',
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
|
|
79
|
+
args: [payload],
|
|
80
|
+
workflowId: 'test',
|
|
81
|
+
taskQueue,
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
expect(result).toBe(object_name);
|
|
85
|
+
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
});
|