@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,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 shpuld 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 imorted 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
|
+
}
|
@@ -0,0 +1,245 @@
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
2
|
+
import { Vars } from "./vars.ts";
|
3
|
+
|
4
|
+
describe('Workflow vars', () => {
|
5
|
+
|
6
|
+
test('access initial variables', () => {
|
7
|
+
const vars = new Vars({
|
8
|
+
objectId: "123",
|
9
|
+
timestamp: 123456,
|
10
|
+
});
|
11
|
+
expect(vars.getValue("objectId")).toBe("123");
|
12
|
+
expect(vars.getValue("timestamp")).toBe(123456);
|
13
|
+
expect(vars.getValue("foo")).toBeUndefined();
|
14
|
+
})
|
15
|
+
|
16
|
+
test('set and access variables', () => {
|
17
|
+
const vars = new Vars({
|
18
|
+
objectId: "123",
|
19
|
+
timestamp: 123456,
|
20
|
+
});
|
21
|
+
expect(vars.getValue("objectId")).toBe("123");
|
22
|
+
vars.setValue("objectId", "456");
|
23
|
+
expect(vars.getValue("objectId")).toBe("456");
|
24
|
+
})
|
25
|
+
|
26
|
+
test('access and modify ref variables', () => {
|
27
|
+
const vars = new Vars({
|
28
|
+
objectId: "123",
|
29
|
+
config: {
|
30
|
+
name: "foo",
|
31
|
+
},
|
32
|
+
objectIdAlias: "${objectId}",
|
33
|
+
configNameAlias: "${config.name}",
|
34
|
+
});
|
35
|
+
expect(vars.getValue("objectIdAlias")).toBe("123");
|
36
|
+
expect(vars.getValue("configNameAlias")).toBe("foo");
|
37
|
+
vars.setValue("objectId", "456");
|
38
|
+
vars.getValue("config").name = "bar";
|
39
|
+
expect(vars.getValue("objectIdAlias")).toBe("456");
|
40
|
+
expect(vars.getValue("configNameAlias")).toBe("bar");
|
41
|
+
})
|
42
|
+
|
43
|
+
test('replace literal with ref', () => {
|
44
|
+
const vars = new Vars({
|
45
|
+
objectId: "123",
|
46
|
+
otherId: "1234",
|
47
|
+
});
|
48
|
+
expect(vars.getValue("objectId")).toBe("123");
|
49
|
+
expect(vars.getValue("otherId")).toBe("1234");
|
50
|
+
vars.setValue("objectId", "456");
|
51
|
+
vars.load({ "otherId": "${objectId}" });
|
52
|
+
expect(vars.getValue("objectId")).toBe("456");
|
53
|
+
expect(vars.getValue("otherId")).toBe("456");
|
54
|
+
});
|
55
|
+
|
56
|
+
test("undefined ref variable", () => {
|
57
|
+
const vars = new Vars({
|
58
|
+
otherId: "${objectId}",
|
59
|
+
});
|
60
|
+
expect(vars.getValue("otherId")).toBeUndefined();
|
61
|
+
})
|
62
|
+
|
63
|
+
test("default values", () => {
|
64
|
+
const vars = new Vars({
|
65
|
+
squote: "${objectId ?? '123'}",
|
66
|
+
dquote: "${objectId ?? \"123\"}",
|
67
|
+
number: "${objectId ?? 123}",
|
68
|
+
boolean: "${objectId ?? true}",
|
69
|
+
array: "${objectId ?? [1,2]}",
|
70
|
+
});
|
71
|
+
// object valus and path expression are not supported
|
72
|
+
expect(vars.getValue("squote")).toBe("123");
|
73
|
+
expect(vars.getValue("dquote")).toBe("123");
|
74
|
+
expect(vars.getValue("number")).toBe(123);
|
75
|
+
expect(vars.getValue("boolean")).toBe(true);
|
76
|
+
expect(vars.getValue("array")).toEqual([1, 2]);
|
77
|
+
})
|
78
|
+
|
79
|
+
test("array map", () => {
|
80
|
+
const vars = new Vars({
|
81
|
+
docs: [{ text: "hello" }, { text: "world" }],
|
82
|
+
});
|
83
|
+
// object valus and path expression are not supported
|
84
|
+
expect(vars.getValue("docs.text").join(' ')).toBe("hello world");
|
85
|
+
})
|
86
|
+
|
87
|
+
test("resolveParams", () => {
|
88
|
+
const vars = new Vars({
|
89
|
+
objectIds: ["123", "456"],
|
90
|
+
objectId: "123",
|
91
|
+
data: { message: "hello" },
|
92
|
+
});
|
93
|
+
const params = {
|
94
|
+
query: {
|
95
|
+
_id: "${objectId}",
|
96
|
+
data: "${data}",
|
97
|
+
},
|
98
|
+
secondDocId: "${objectIds.1}",
|
99
|
+
secondDocIdByBracket: "${objectIds[1]}",
|
100
|
+
}
|
101
|
+
const resolved = vars.resolveParams(params);
|
102
|
+
expect(Object.keys(resolved).length).toBe(3);
|
103
|
+
expect(resolved.query).toBeTypeOf("object");
|
104
|
+
expect(resolved.query._id).toBe("123");
|
105
|
+
expect(resolved.query.data).toBeTypeOf("object");
|
106
|
+
expect(resolved.query.data.message).toBe("hello");
|
107
|
+
expect(resolved.secondDocId).toBe("456");
|
108
|
+
expect(resolved.secondDocIdByBracket).toBe("456");
|
109
|
+
|
110
|
+
});
|
111
|
+
|
112
|
+
test("resolve", () => {
|
113
|
+
const vars = new Vars({
|
114
|
+
objectId: "123",
|
115
|
+
message: "hello",
|
116
|
+
prompt_data: { message: "${message}" },
|
117
|
+
data2: "${prompt_data}",
|
118
|
+
unknown: "${notdefined}"
|
119
|
+
});
|
120
|
+
const resolved = vars.resolve();
|
121
|
+
console.log('@@@@@@@@@@@@@@@@@@@', resolved);
|
122
|
+
expect(Object.keys(resolved).length).toBe(4); // since unknown will be undefined it will not be included
|
123
|
+
expect(resolved.objectId).toBe("123");
|
124
|
+
expect(resolved.prompt_data).toBeTypeOf("object");
|
125
|
+
expect(resolved.prompt_data.message).toBe("hello");
|
126
|
+
expect(resolved.data2).toBeTypeOf("object");
|
127
|
+
expect(resolved.data2.message).toBe("hello");
|
128
|
+
expect(resolved.unnown).toBeUndefined();
|
129
|
+
});
|
130
|
+
|
131
|
+
|
132
|
+
test("createImportVars", () => {
|
133
|
+
const vars = new Vars({
|
134
|
+
person: { name: "John", age: 30 },
|
135
|
+
objectId: "123",
|
136
|
+
data: { message: "hello" },
|
137
|
+
data2: "${data}",
|
138
|
+
});
|
139
|
+
const params = vars.createImportVars(["data2", { "name": "person.name", "age": "person.age" }, { message: "data.message" }]);
|
140
|
+
expect(Object.keys(params).length).toBe(4);
|
141
|
+
expect(params.name).toBe("John");
|
142
|
+
expect(params.age).toBe(30);
|
143
|
+
expect(params.message).toBe("hello");
|
144
|
+
expect(params.data2).toStrictEqual({ message: "hello" });
|
145
|
+
});
|
146
|
+
|
147
|
+
test("evaluate null and exists conditions", () => {
|
148
|
+
const vars = new Vars({
|
149
|
+
objectId: "123",
|
150
|
+
docType: {
|
151
|
+
id: "bla",
|
152
|
+
idNull: null,
|
153
|
+
}
|
154
|
+
});
|
155
|
+
expect(vars.match({ objectId: { $exists: true } })).toBe(true);
|
156
|
+
expect(vars.match({ objectId: { $exists: false } })).toBe(false);
|
157
|
+
expect(vars.match({ objectIds: { $exists: true } })).toBe(false);
|
158
|
+
expect(vars.match({ objectIds: { $exists: false } })).toBe(true);
|
159
|
+
expect(vars.match({ "docType.id": { $exists: true } })).toBe(true);
|
160
|
+
expect(vars.match({ "docType.idNull": { $exists: true } })).toBe(true);
|
161
|
+
|
162
|
+
expect(vars.match({ objectId: { $null: true } })).toBe(false);
|
163
|
+
expect(vars.match({ objectId: { $null: false } })).toBe(true);
|
164
|
+
expect(vars.match({ objectIds: { $null: false } })).toBe(false);
|
165
|
+
expect(vars.match({ objectIds: { $null: true } })).toBe(true);
|
166
|
+
expect(vars.match({ "docType.id": { $null: true } })).toBe(false);
|
167
|
+
expect(vars.match({ "docType.idNull": { $null: true } })).toBe(true);
|
168
|
+
});
|
169
|
+
|
170
|
+
test("evaluate $eq conditions", () => {
|
171
|
+
const vars = new Vars({
|
172
|
+
objectId: "123",
|
173
|
+
otherId: "${objectId}",
|
174
|
+
config: {
|
175
|
+
name: { foo: "bar" },
|
176
|
+
tags: ["a", "b", "c"]
|
177
|
+
}
|
178
|
+
});
|
179
|
+
expect(vars.match({ objectId: { $eq: "123" } })).toBe(true);
|
180
|
+
expect(vars.match({ objectId: { $eq: "456" } })).toBe(false);
|
181
|
+
expect(vars.match({ objectId: { $ne: "123" } })).toBe(false);
|
182
|
+
expect(vars.match({ objectId: { $ne: "456" } })).toBe(true);
|
183
|
+
|
184
|
+
expect(vars.match({ otherId: { $eq: "123" } })).toBe(true);
|
185
|
+
expect(vars.match({ otherId: { $eq: "456" } })).toBe(false);
|
186
|
+
expect(vars.match({ otherId: { $ne: "123" } })).toBe(false);
|
187
|
+
expect(vars.match({ otherId: { $ne: "456" } })).toBe(true);
|
188
|
+
|
189
|
+
expect(vars.match({ "config": { $eq: { name: { foo: "bar" }, tags: ["a", "b", "c"] } } })).toBe(true);
|
190
|
+
});
|
191
|
+
|
192
|
+
test("evaluate $regexp conditions", () => {
|
193
|
+
const vars = new Vars({
|
194
|
+
expr: "a=2",
|
195
|
+
});
|
196
|
+
expect(vars.match({ expr: { $regexp: "^.*\\s*=\\s*.*$" } })).toBe(true);
|
197
|
+
});
|
198
|
+
|
199
|
+
test("evaluate string compare conditions", () => {
|
200
|
+
const vars = new Vars({
|
201
|
+
expr: "<tag />",
|
202
|
+
});
|
203
|
+
expect(vars.match({ expr: { $startsWith: "<" } })).toBe(true);
|
204
|
+
expect(vars.match({ expr: { $contains: "tag" } })).toBe(true);
|
205
|
+
expect(vars.match({ expr: { $endsWith: "/>" } })).toBe(true);
|
206
|
+
});
|
207
|
+
|
208
|
+
test("evaluate $in conditions", () => {
|
209
|
+
const vars = new Vars({
|
210
|
+
name: "foo",
|
211
|
+
});
|
212
|
+
expect(vars.match({ name: { $in: ["foo", "bar"] } })).toBe(true);
|
213
|
+
expect(vars.match({ name: { $nin: ["hello", "world"] } })).toBe(true);
|
214
|
+
});
|
215
|
+
|
216
|
+
test("evaluate $lt, $gt conditions", () => {
|
217
|
+
const vars = new Vars({
|
218
|
+
value: 5,
|
219
|
+
});
|
220
|
+
expect(vars.match({ value: { $lt: 6 } })).toBe(true);
|
221
|
+
expect(vars.match({ value: { $gt: 4 } })).toBe(true);
|
222
|
+
expect(vars.match({ value: { $lte: 5 } })).toBe(true);
|
223
|
+
expect(vars.match({ value: { $gte: 5 } })).toBe(true);
|
224
|
+
});
|
225
|
+
|
226
|
+
test("evaluate $or conditions", () => {
|
227
|
+
const vars = new Vars({
|
228
|
+
value: 5,
|
229
|
+
name: "foo"
|
230
|
+
});
|
231
|
+
expect(vars.match({ value: { $or: [{ $lt: 4 }, { $gt: 6 }] } })).toBe(false);
|
232
|
+
expect(vars.match({ name: { $or: [{ $eq: "bar" }, { $eq: "foo" }] } })).toBe(true);
|
233
|
+
expect(vars.match({ name: { $or: [{ $eq: "bar" }, { $eq: "fooo" }] } })).toBe(false);
|
234
|
+
});
|
235
|
+
|
236
|
+
test("evaluate nested conditions", () => {
|
237
|
+
const vars = new Vars({
|
238
|
+
config: {
|
239
|
+
name: "foo",
|
240
|
+
},
|
241
|
+
});
|
242
|
+
expect(vars.match({ "config.name": { $eq: "foo" } })).toBe(true);
|
243
|
+
});
|
244
|
+
|
245
|
+
});
|