@vertesia/workflow 0.42.2
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 +24 -0
- package/bin/bundle-workflows.mjs +26 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +32 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +66 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +18 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/chunkDocument.js +79 -0
- package/lib/cjs/activities/chunkDocument.js.map +1 -0
- package/lib/cjs/activities/createDocumentFromOther.js +64 -0
- package/lib/cjs/activities/createDocumentFromOther.js.map +1 -0
- package/lib/cjs/activities/executeInteraction.js +135 -0
- package/lib/cjs/activities/executeInteraction.js.map +1 -0
- package/lib/cjs/activities/extractDocumentText.js +140 -0
- package/lib/cjs/activities/extractDocumentText.js.map +1 -0
- package/lib/cjs/activities/generateDocumentProperties.js +59 -0
- package/lib/cjs/activities/generateDocumentProperties.js.map +1 -0
- package/lib/cjs/activities/generateEmbeddings.js +292 -0
- package/lib/cjs/activities/generateEmbeddings.js.map +1 -0
- package/lib/cjs/activities/generateImageRendition.js +104 -0
- package/lib/cjs/activities/generateImageRendition.js.map +1 -0
- package/lib/cjs/activities/generateOrAssignContentType.js +103 -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/index.js +54 -0
- package/lib/cjs/activities/index.js.map +1 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js +102 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +51 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/cjs/activities/notifyWebhook.js +34 -0
- package/lib/cjs/activities/notifyWebhook.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 +416 -0
- package/lib/cjs/conversion/TextractProcessor.js.map +1 -0
- package/lib/cjs/conversion/image.js +22 -0
- package/lib/cjs/conversion/image.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/conversion/pdf.js +13 -0
- package/lib/cjs/conversion/pdf.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 +223 -0
- package/lib/cjs/dsl/dsl-workflow.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 +96 -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/errors.js +36 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/index.js +43 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js +47 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js +69 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js +73 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js +91 -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 +55 -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 +118 -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/generateObjectText.js +89 -0
- package/lib/cjs/system/generateObjectText.js.map +1 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js +52 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +37 -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 +63 -0
- package/lib/cjs/utils/blobs.js.map +1 -0
- package/lib/cjs/utils/client.js +25 -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 +72 -0
- package/lib/cjs/utils/memory.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 +17 -0
- package/lib/cjs/workflows.js.map +1 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +29 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +63 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +15 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/chunkDocument.js +76 -0
- package/lib/esm/activities/chunkDocument.js.map +1 -0
- package/lib/esm/activities/createDocumentFromOther.js +58 -0
- package/lib/esm/activities/createDocumentFromOther.js.map +1 -0
- package/lib/esm/activities/executeInteraction.js +131 -0
- package/lib/esm/activities/executeInteraction.js.map +1 -0
- package/lib/esm/activities/extractDocumentText.js +137 -0
- package/lib/esm/activities/extractDocumentText.js.map +1 -0
- package/lib/esm/activities/generateDocumentProperties.js +56 -0
- package/lib/esm/activities/generateDocumentProperties.js.map +1 -0
- package/lib/esm/activities/generateEmbeddings.js +256 -0
- package/lib/esm/activities/generateEmbeddings.js.map +1 -0
- package/lib/esm/activities/generateImageRendition.js +98 -0
- package/lib/esm/activities/generateImageRendition.js.map +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js +100 -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/index.js +21 -0
- package/lib/esm/activities/index.js.map +1 -0
- package/lib/esm/activities/media/processPdfWithTextract.js +98 -0
- package/lib/esm/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +48 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/esm/activities/notifyWebhook.js +31 -0
- package/lib/esm/activities/notifyWebhook.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 +409 -0
- package/lib/esm/conversion/TextractProcessor.js.map +1 -0
- package/lib/esm/conversion/image.js +16 -0
- package/lib/esm/conversion/image.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/conversion/pdf.js +7 -0
- package/lib/esm/conversion/pdf.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 +216 -0
- package/lib/esm/dsl/dsl-workflow.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 +91 -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/errors.js +30 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.js +25 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/iterative-generation/activities/extractToc.js +44 -0
- package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js +66 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generatePart.js +70 -0
- package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generateToc.js +88 -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 +52 -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 +109 -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/generateObjectText.js +86 -0
- package/lib/esm/system/generateObjectText.js.map +1 -0
- package/lib/esm/system/notifyWebhookWorkflow.js +49 -0
- package/lib/esm/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js +34 -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 +52 -0
- package/lib/esm/utils/blobs.js.map +1 -0
- package/lib/esm/utils/client.js +22 -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 +60 -0
- package/lib/esm/utils/memory.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 +9 -0
- package/lib/esm/workflows.js.map +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 +29 -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 +18 -0
- package/lib/types/activities/chunkDocument.d.ts.map +1 -0
- package/lib/types/activities/createDocumentFromOther.d.ts +21 -0
- package/lib/types/activities/createDocumentFromOther.d.ts.map +1 -0
- package/lib/types/activities/executeInteraction.d.ts +40 -0
- package/lib/types/activities/executeInteraction.d.ts.map +1 -0
- package/lib/types/activities/extractDocumentText.d.ts +9 -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 +49 -0
- package/lib/types/activities/generateEmbeddings.d.ts.map +1 -0
- package/lib/types/activities/generateImageRendition.d.ts +17 -0
- package/lib/types/activities/generateImageRendition.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/index.d.ts +21 -0
- package/lib/types/activities/index.d.ts.map +1 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts +26 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts.map +1 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +14 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +1 -0
- package/lib/types/activities/notifyWebhook.d.ts +17 -0
- package/lib/types/activities/notifyWebhook.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 +9 -0
- package/lib/types/conversion/image.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/conversion/pdf.d.ts +2 -0
- package/lib/types/conversion/pdf.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/projections.d.ts +4 -0
- package/lib/types/dsl/projections.d.ts.map +1 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts +14 -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/errors.d.ts +16 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/index.d.ts +24 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts +10 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +3 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts +3 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts +4 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/index.d.ts +5 -0
- package/lib/types/iterative-generation/activities/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +3 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +1 -0
- package/lib/types/iterative-generation/types.d.ts +79 -0
- package/lib/types/iterative-generation/types.d.ts.map +1 -0
- package/lib/types/iterative-generation/utils.d.ts +27 -0
- package/lib/types/iterative-generation/utils.d.ts.map +1 -0
- package/lib/types/result-types.d.ts +22 -0
- package/lib/types/result-types.d.ts.map +1 -0
- package/lib/types/system/generateObjectText.d.ts +4 -0
- package/lib/types/system/generateObjectText.d.ts.map +1 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts +6 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts.map +1 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +40 -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 +8 -0
- package/lib/types/utils/blobs.d.ts.map +1 -0
- package/lib/types/utils/client.d.ts +7 -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 +12 -0
- package/lib/types/utils/memory.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 +9 -0
- package/lib/types/workflows.d.ts.map +1 -0
- package/lib/workflows-bundle.js +18394 -0
- package/package.json +109 -0
- package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +54 -0
- package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +97 -0
- package/src/activities/advanced/updateDocumentFromInteractionRun.ts +34 -0
- package/src/activities/chunkDocument.ts +124 -0
- package/src/activities/createDocumentFromOther.ts +92 -0
- package/src/activities/executeInteraction.ts +191 -0
- package/src/activities/extractDocumentText.ts +174 -0
- package/src/activities/generateDocumentProperties.ts +93 -0
- package/src/activities/generateEmbeddings.ts +345 -0
- package/src/activities/generateImageRendition.ts +134 -0
- package/src/activities/generateOrAssignContentType.ts +152 -0
- package/src/activities/getObjectFromStore.ts +31 -0
- package/src/activities/index.ts +21 -0
- package/src/activities/media/processPdfWithTextract.ts +141 -0
- package/src/activities/media/transcribeMediaWithGladia.ts +83 -0
- package/src/activities/notifyWebhook.test.ts +32 -0
- package/src/activities/notifyWebhook.ts +51 -0
- package/src/activities/setDocumentStatus.ts +25 -0
- package/src/conversion/TextractProcessor.ts +505 -0
- package/src/conversion/image.test.ts +26 -0
- package/src/conversion/image.ts +22 -0
- package/src/conversion/mutool.test.ts +74 -0
- package/src/conversion/mutool.ts +180 -0
- package/src/conversion/pandoc.test.ts +22 -0
- package/src/conversion/pandoc.ts +44 -0
- package/src/conversion/pdf.test.ts +35 -0
- package/src/conversion/pdf.ts +8 -0
- package/src/dsl/conditions.ts +76 -0
- package/src/dsl/dsl-workflow.test.ts +58 -0
- package/src/dsl/dsl-workflow.ts +235 -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 +106 -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 +182 -0
- package/src/dsl/workflow-fetch.test.ts +135 -0
- package/src/dsl/workflow-import.test.ts +89 -0
- package/src/dsl/workflow.test.ts +110 -0
- package/src/errors.ts +24 -0
- package/src/index.ts +27 -0
- package/src/iterative-generation/activities/extractToc.ts +49 -0
- package/src/iterative-generation/activities/finalizeOutput.ts +77 -0
- package/src/iterative-generation/activities/generatePart.ts +82 -0
- package/src/iterative-generation/activities/generateToc.ts +98 -0
- package/src/iterative-generation/activities/index.ts +4 -0
- package/src/iterative-generation/iterativeGenerationWorkflow.ts +67 -0
- package/src/iterative-generation/types.ts +99 -0
- package/src/iterative-generation/utils.ts +123 -0
- package/src/result-types.ts +25 -0
- package/src/system/generateObjectText.ts +109 -0
- package/src/system/notifyWebhookWorkflow.ts +64 -0
- package/src/system/recalculateEmbeddingsWorkflow.ts +46 -0
- package/src/utils/auth.ts +10 -0
- package/src/utils/blobs.ts +58 -0
- package/src/utils/client.ts +31 -0
- package/src/utils/expand-vars.ts +31 -0
- package/src/utils/memory.ts +66 -0
- package/src/utils/tokens.ts +44 -0
- package/src/vars.ts +3 -0
- package/src/workflows.ts +9 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
2
|
+
import { Vars } from "./vars.ts";
|
3
|
+
import { makeProjection } from "./projections.ts";
|
4
|
+
|
5
|
+
describe('Result Projections', () => {
|
6
|
+
|
7
|
+
test('simple projection', () => {
|
8
|
+
const params: Record<string, any> = {
|
9
|
+
docTypes: [{ id: 1, name: "type1" }, { id: 2, name: "type2" }],
|
10
|
+
objectId: "123"
|
11
|
+
}
|
12
|
+
const result = {
|
13
|
+
result: {
|
14
|
+
document_type: "C",
|
15
|
+
}
|
16
|
+
}
|
17
|
+
const spec = {
|
18
|
+
docType: "${docTypes[0].name}",
|
19
|
+
objectId: "${objectId}",
|
20
|
+
resultType: "${#.result.document_type}",
|
21
|
+
timestamp: 123456
|
22
|
+
}
|
23
|
+
const out = makeProjection(spec, params, result);
|
24
|
+
|
25
|
+
expect(Object.keys(out).length).toBe(4);
|
26
|
+
expect(out.docType).toBe("type1");
|
27
|
+
expect(out.objectId).toBe("123");
|
28
|
+
expect(out.resultType).toBe("C");
|
29
|
+
expect(out.timestamp).toBe(123456);
|
30
|
+
expect(out.foo).toBeUndefined();
|
31
|
+
})
|
32
|
+
|
33
|
+
test('$element match', () => {
|
34
|
+
const params: Record<string, any> = {
|
35
|
+
docTypes: [{ id: 1, name: "type1" }, { id: 2, name: "type2" }],
|
36
|
+
objectId: "123"
|
37
|
+
}
|
38
|
+
const result = {
|
39
|
+
result: {
|
40
|
+
document_type: "type2",
|
41
|
+
}
|
42
|
+
}
|
43
|
+
const spec = {
|
44
|
+
docType: {
|
45
|
+
$element: {
|
46
|
+
from: "${docTypes}",
|
47
|
+
where: { name: { $eq: "${#.result.document_type}" } },
|
48
|
+
else: { id: 0, name: "unknown" }
|
49
|
+
}
|
50
|
+
},
|
51
|
+
isNewType: {
|
52
|
+
$eval: {
|
53
|
+
"#.result.document_type": { $nin: "${docTypes.name}" }
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
const out = makeProjection(spec, params, result);
|
59
|
+
|
60
|
+
|
61
|
+
expect(Object.keys(out).length).toBe(2);
|
62
|
+
expect(out.docType).toStrictEqual({ id: 2, name: "type2" });
|
63
|
+
expect(out.isNewType).toBe(false);
|
64
|
+
})
|
65
|
+
|
66
|
+
test('$element does not match', () => {
|
67
|
+
const params: Record<string, any> = {
|
68
|
+
docTypes: [{ id: 1, name: "type1" }, { id: 2, name: "type2" }],
|
69
|
+
objectId: "123"
|
70
|
+
}
|
71
|
+
const result = {
|
72
|
+
result: {
|
73
|
+
document_type: "a_new_type",
|
74
|
+
}
|
75
|
+
}
|
76
|
+
const projection = {
|
77
|
+
docType: {
|
78
|
+
$element: {
|
79
|
+
from: "${docTypes}",
|
80
|
+
where: { name: { $eq: "${#.result.document_type}" } },
|
81
|
+
else: { id: 0, name: "${#.result.document_type}" }
|
82
|
+
}
|
83
|
+
},
|
84
|
+
isNewType: {
|
85
|
+
$eval: {
|
86
|
+
"#.result.document_type": { $nin: "${docTypes.name}" }
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
const out = makeProjection(projection, params, result);
|
92
|
+
|
93
|
+
|
94
|
+
expect(Object.keys(out).length).toBe(2);
|
95
|
+
expect(out.docType).toStrictEqual({ id: 0, name: "a_new_type" });
|
96
|
+
expect(out.isNewType).toBe(true);
|
97
|
+
})
|
98
|
+
|
99
|
+
test('$element with field', () => {
|
100
|
+
const params: Record<string, any> = {
|
101
|
+
docTypes: [{ id: 1, name: "type1" }, { id: 2, name: "type2" }],
|
102
|
+
objectId: "123"
|
103
|
+
}
|
104
|
+
const result = {
|
105
|
+
result: {
|
106
|
+
document_type: "type2",
|
107
|
+
}
|
108
|
+
}
|
109
|
+
const projection = {
|
110
|
+
other: null,
|
111
|
+
name: "${#.result.document_type}",
|
112
|
+
id: {
|
113
|
+
$element: {
|
114
|
+
field: "id",
|
115
|
+
from: "${docTypes}",
|
116
|
+
where: { name: { $eq: "${#.result.document_type}" } },
|
117
|
+
else: null
|
118
|
+
}
|
119
|
+
},
|
120
|
+
}
|
121
|
+
|
122
|
+
const out = makeProjection(projection, params, result);
|
123
|
+
|
124
|
+
|
125
|
+
expect(Object.keys(out).length).toBe(3);
|
126
|
+
expect(out).toStrictEqual({ id: 2, name: "type2", other: null });
|
127
|
+
})
|
128
|
+
|
129
|
+
test('$element with field - no match', () => {
|
130
|
+
const params: Record<string, any> = {
|
131
|
+
docTypes: [{ id: 1, name: "type1" }, { id: 2, name: "type2" }],
|
132
|
+
objectId: "123"
|
133
|
+
}
|
134
|
+
const result = {
|
135
|
+
result: {
|
136
|
+
document_type: "a_new_type",
|
137
|
+
}
|
138
|
+
}
|
139
|
+
const projection = {
|
140
|
+
other: null,
|
141
|
+
name: "${#.result.document_type}",
|
142
|
+
id: {
|
143
|
+
$element: {
|
144
|
+
field: "id",
|
145
|
+
from: "${docTypes}",
|
146
|
+
where: { name: { $eq: "${#.result.document_type}" } },
|
147
|
+
else: null
|
148
|
+
}
|
149
|
+
},
|
150
|
+
}
|
151
|
+
|
152
|
+
const out = makeProjection(projection, params, result);
|
153
|
+
|
154
|
+
|
155
|
+
expect(Object.keys(out).length).toBe(3);
|
156
|
+
expect(out).toStrictEqual({ id: null, name: "a_new_type", other: null });
|
157
|
+
})
|
158
|
+
|
159
|
+
});
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { DSLActivityExecutionPayload } from "@vertesia/common";
|
2
|
+
import { matchCondition } from "./conditions.js";
|
3
|
+
import { Vars } from "./vars.js";
|
4
|
+
|
5
|
+
|
6
|
+
interface ProjectOperation {
|
7
|
+
(arg: any, vars: Vars): any
|
8
|
+
}
|
9
|
+
|
10
|
+
interface ElementOperation {
|
11
|
+
field?: string,
|
12
|
+
from: any[],
|
13
|
+
where: Record<string, any>,
|
14
|
+
else: any
|
15
|
+
}
|
16
|
+
const operations: Record<string, ProjectOperation> = {
|
17
|
+
$element(arg: ElementOperation, _vars: Vars) {
|
18
|
+
const where = arg.where;
|
19
|
+
const whereKeys = Object.keys(where);
|
20
|
+
const r = arg.from.find((elem: any) => {
|
21
|
+
for (const key of whereKeys) {
|
22
|
+
const value = key === '_' ? elem : elem[key];
|
23
|
+
if (matchCondition(value, where[key])) {
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
return false;
|
28
|
+
})
|
29
|
+
if (arg.field) {
|
30
|
+
return r ? r[arg.field] : arg.else;
|
31
|
+
} else {
|
32
|
+
return r || arg.else;
|
33
|
+
}
|
34
|
+
},
|
35
|
+
$eval(arg: any, vars: Vars) {
|
36
|
+
return vars.match(arg);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
function runProjection(obj: any, vars: Vars) {
|
41
|
+
if (obj && !Array.isArray(obj) && typeof obj === "object") {
|
42
|
+
const keys = Object.keys(obj)
|
43
|
+
if (keys.length === 1) {
|
44
|
+
const key = keys[0];
|
45
|
+
const fn = operations[key];
|
46
|
+
if (fn) {
|
47
|
+
return fn(obj[key], vars);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return obj; // return the value as is
|
52
|
+
}
|
53
|
+
|
54
|
+
export function projectResult(payload: DSLActivityExecutionPayload, params: Record<string, any>, result: any, fallback: any) {
|
55
|
+
return payload.activity.projection ? makeProjection(payload.activity.projection, params, result) : fallback;
|
56
|
+
}
|
57
|
+
|
58
|
+
export function makeProjection(spec: Record<string, any>, params: Record<string, any>, result: any) {
|
59
|
+
const vars = new Vars({
|
60
|
+
...params,
|
61
|
+
'#': result,
|
62
|
+
});
|
63
|
+
|
64
|
+
const projection = vars.resolveParams(spec);
|
65
|
+
|
66
|
+
const out: any = {}
|
67
|
+
for (const [key, value] of Object.entries(projection)) {
|
68
|
+
out[key] = runProjection(value, vars);
|
69
|
+
}
|
70
|
+
|
71
|
+
return out;
|
72
|
+
}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import { ComposableClient } from "@vertesia/client";
|
2
|
+
import { DSLActivityExecutionPayload, DSLWorkflowExecutionPayload, Project, WorkflowExecutionPayload } from "@vertesia/common";
|
3
|
+
import { log } from "@temporalio/activity";
|
4
|
+
import { NoDocumentFound, WorkflowParamNotFound } from "../../errors.js";
|
5
|
+
import { getClient } from "../../utils/client.js";
|
6
|
+
import { Vars } from "../vars.js";
|
7
|
+
import { getFetchProvider, registerFetchProviderFactory } from "./fetch/index.js";
|
8
|
+
import { DocumentProvider, DocumentTypeProvider, InteractionRunProvider } from "./fetch/providers.js";
|
9
|
+
import { getProjectFromToken } from "../../utils/auth.js";
|
10
|
+
|
11
|
+
|
12
|
+
registerFetchProviderFactory(DocumentProvider.ID, DocumentProvider.factory);
|
13
|
+
registerFetchProviderFactory(DocumentTypeProvider.ID, DocumentTypeProvider.factory);
|
14
|
+
registerFetchProviderFactory(InteractionRunProvider.ID, InteractionRunProvider.factory);
|
15
|
+
|
16
|
+
export class ActivityContext<T extends Record<string, any> = Record<string, any>> {
|
17
|
+
client: ComposableClient;
|
18
|
+
_project?: Promise<Project | undefined>;
|
19
|
+
|
20
|
+
constructor(public payload: DSLActivityExecutionPayload, client: ComposableClient, public params: T) {
|
21
|
+
this.client = client;
|
22
|
+
this.fetchProject = this.fetchProject.bind(this);
|
23
|
+
}
|
24
|
+
|
25
|
+
get objectIds() {
|
26
|
+
return this.payload.objectIds;
|
27
|
+
}
|
28
|
+
|
29
|
+
get objectId() {
|
30
|
+
const objectId = this.payload.objectIds && this.payload.objectIds[0];
|
31
|
+
if (!objectId) {
|
32
|
+
log.error('No objectId found in payload');
|
33
|
+
throw new WorkflowParamNotFound('objectIds[0]', (this.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload).workflow);
|
34
|
+
}
|
35
|
+
return objectId;
|
36
|
+
}
|
37
|
+
|
38
|
+
fetchProject() {
|
39
|
+
if (!this._project) {
|
40
|
+
this._project = _fetchProject(this.client, this.payload);
|
41
|
+
}
|
42
|
+
return this._project;
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
export async function setupActivity<T extends Record<string, any> = Record<string, any>>(payload: DSLActivityExecutionPayload) {
|
49
|
+
|
50
|
+
const isDebugMode = !!payload.debug_mode;
|
51
|
+
|
52
|
+
const vars = new Vars({
|
53
|
+
...payload.params, // imported params (doesn't contain expressions)
|
54
|
+
...payload.activity.params, // activity params (may contain expressions)
|
55
|
+
});
|
56
|
+
|
57
|
+
//}
|
58
|
+
if (isDebugMode) {
|
59
|
+
log.info(`Setting up activity ${payload.activity.name}`, { config: payload.config, activity: payload.activity, params: payload.params, vars });
|
60
|
+
}
|
61
|
+
|
62
|
+
const client = getClient(payload);
|
63
|
+
const fetchSpecs = payload.activity.fetch;
|
64
|
+
if (fetchSpecs) {
|
65
|
+
|
66
|
+
const keys = Object.keys(fetchSpecs);
|
67
|
+
if (keys.length > 0) {
|
68
|
+
// create a new Vars instance to store the fetched data
|
69
|
+
for (const key of keys) {
|
70
|
+
let fetchSpec = fetchSpecs[key];
|
71
|
+
let query = fetchSpec.query;
|
72
|
+
if (query) {
|
73
|
+
query = vars.resolveParams(query);
|
74
|
+
fetchSpec = { ...fetchSpec, query };
|
75
|
+
}
|
76
|
+
|
77
|
+
const provider = await getFetchProvider(client, fetchSpec);
|
78
|
+
|
79
|
+
log.info(`Fetching data for ${key} with provider ${provider.name}`, { fetchSpec });
|
80
|
+
const result = await provider.fetch(fetchSpec);
|
81
|
+
if (result && result.length > 0) {
|
82
|
+
if (fetchSpec.limit === 1) {
|
83
|
+
vars.setValue(key, result[0]);
|
84
|
+
} else {
|
85
|
+
vars.setValue(key, result);
|
86
|
+
}
|
87
|
+
} else if (fetchSpec.on_not_found === 'throw') {
|
88
|
+
throw new NoDocumentFound("No documents found for: " + JSON.stringify(fetchSpec));
|
89
|
+
} else {
|
90
|
+
vars.setValue(key, null);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
const params = vars.resolve() as T;
|
97
|
+
log.info(`Activity ${payload.activity.name} setup complete`, { params });
|
98
|
+
|
99
|
+
return new ActivityContext<T>(payload, client, params);
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
async function _fetchProject(client: ComposableClient, payload: WorkflowExecutionPayload) {
|
104
|
+
const project = await getProjectFromToken(payload.auth_token);
|
105
|
+
return project ? await client.projects.retrieve(project.id) : undefined;
|
106
|
+
}
|
@@ -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 { ComposableClient } from "@vertesia/client";
|
3
|
+
import { DataProvider } from "./DataProvider.js";
|
4
|
+
|
5
|
+
|
6
|
+
const factories: Record<string, ((client: ComposableClient, source?: string) => DataProvider)> = {};
|
7
|
+
|
8
|
+
|
9
|
+
export function registerFetchProviderFactory(name: string, factory: ((client: ComposableClient) => DataProvider)) {
|
10
|
+
factories[name] = factory;
|
11
|
+
}
|
12
|
+
|
13
|
+
export function getFetchProvider(client: ComposableClient, 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 { ComposableClient } 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: ComposableClient) {
|
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: ComposableClient) {
|
28
|
+
return new DocumentProvider(client);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
export class DocumentTypeProvider extends DataProvider {
|
33
|
+
static ID = "document_type";
|
34
|
+
constructor(public client: ComposableClient) {
|
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: ComposableClient) {
|
46
|
+
return new DocumentTypeProvider(client);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
export class InteractionRunProvider extends DataProvider {
|
51
|
+
static ID = "interaction_run";
|
52
|
+
constructor(public client: ComposableClient) {
|
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: ComposableClient) {
|
64
|
+
return new InteractionRunProvider(client);
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|