@vertesia/workflow 0.77.0 → 0.78.0-dev-9372725
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/package.json +128 -120
- package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +8 -5
- package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +6 -10
- package/src/activities/advanced/updateDocumentFromInteractionRun.ts +4 -1
- package/src/activities/chunkDocument.ts +4 -1
- package/src/activities/executeInteraction.ts +16 -9
- package/src/activities/generateDocumentProperties.ts +13 -7
- package/src/activities/generateOrAssignContentType.ts +17 -11
- package/src/activities/index-dsl.ts +1 -1
- package/src/activities/notifyWebhook.test.ts +117 -19
- package/src/activities/notifyWebhook.ts +17 -4
- package/src/activities/rateLimiter.ts +41 -0
- package/src/conversion/image.ts +6 -3
- package/src/dsl/dsl-workflow.ts +80 -0
- package/src/dsl/setup/ActivityContext.ts +45 -12
- package/src/dsl/workflow-exec-child.test.ts +4 -3
- package/src/dsl/workflow-fetch.test.ts +1 -1
- package/src/dsl/workflow-import.test.ts +1 -1
- package/src/dsl/workflow.test.ts +2 -1
- package/src/errors.ts +13 -0
- package/src/index.ts +1 -1
- package/src/iterative-generation/activities/extractToc.ts +26 -12
- package/src/iterative-generation/activities/finalizeOutput.ts +52 -29
- package/src/iterative-generation/activities/generatePart.ts +66 -24
- package/src/iterative-generation/activities/generateToc.ts +85 -66
- package/src/iterative-generation/utils.ts +2 -2
- package/src/utils/blobs.ts +3 -1
- package/src/utils/client.ts +22 -8
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +0 -32
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +0 -1
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +0 -72
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +0 -1
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +0 -18
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +0 -1
- package/lib/cjs/activities/chunkDocument.js +0 -84
- package/lib/cjs/activities/chunkDocument.js.map +0 -1
- package/lib/cjs/activities/createDocumentFromOther.js +0 -64
- package/lib/cjs/activities/createDocumentFromOther.js.map +0 -1
- package/lib/cjs/activities/executeInteraction.js +0 -186
- package/lib/cjs/activities/executeInteraction.js.map +0 -1
- package/lib/cjs/activities/extractDocumentText.js +0 -156
- package/lib/cjs/activities/extractDocumentText.js.map +0 -1
- package/lib/cjs/activities/generateDocumentProperties.js +0 -78
- package/lib/cjs/activities/generateDocumentProperties.js.map +0 -1
- package/lib/cjs/activities/generateEmbeddings.js +0 -358
- package/lib/cjs/activities/generateEmbeddings.js.map +0 -1
- package/lib/cjs/activities/generateOrAssignContentType.js +0 -123
- package/lib/cjs/activities/generateOrAssignContentType.js.map +0 -1
- package/lib/cjs/activities/getObjectFromStore.js +0 -20
- package/lib/cjs/activities/getObjectFromStore.js.map +0 -1
- package/lib/cjs/activities/handleError.js +0 -22
- package/lib/cjs/activities/handleError.js.map +0 -1
- package/lib/cjs/activities/identifyTextSections.js +0 -48
- package/lib/cjs/activities/identifyTextSections.js.map +0 -1
- package/lib/cjs/activities/index-dsl.js +0 -43
- package/lib/cjs/activities/index-dsl.js.map +0 -1
- package/lib/cjs/activities/index.js +0 -21
- package/lib/cjs/activities/index.js.map +0 -1
- package/lib/cjs/activities/media/processPdfWithTextract.js +0 -103
- package/lib/cjs/activities/media/processPdfWithTextract.js.map +0 -1
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +0 -51
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +0 -1
- package/lib/cjs/activities/notifyWebhook.js +0 -33
- package/lib/cjs/activities/notifyWebhook.js.map +0 -1
- package/lib/cjs/activities/renditions/generateImageRendition.js +0 -66
- package/lib/cjs/activities/renditions/generateImageRendition.js.map +0 -1
- package/lib/cjs/activities/renditions/generateVideoRendition.js +0 -200
- package/lib/cjs/activities/renditions/generateVideoRendition.js.map +0 -1
- package/lib/cjs/activities/setDocumentStatus.js +0 -15
- package/lib/cjs/activities/setDocumentStatus.js.map +0 -1
- package/lib/cjs/conversion/TextractProcessor.js +0 -417
- package/lib/cjs/conversion/TextractProcessor.js.map +0 -1
- package/lib/cjs/conversion/image.js +0 -147
- package/lib/cjs/conversion/image.js.map +0 -1
- package/lib/cjs/conversion/markitdown.js +0 -42
- package/lib/cjs/conversion/markitdown.js.map +0 -1
- package/lib/cjs/conversion/mutool.js +0 -147
- package/lib/cjs/conversion/mutool.js.map +0 -1
- package/lib/cjs/conversion/pandoc.js +0 -39
- package/lib/cjs/conversion/pandoc.js.map +0 -1
- package/lib/cjs/dsl/conditions.js +0 -81
- package/lib/cjs/dsl/conditions.js.map +0 -1
- package/lib/cjs/dsl/dsl-workflow.js +0 -277
- package/lib/cjs/dsl/dsl-workflow.js.map +0 -1
- package/lib/cjs/dsl/dslProxyActivities.js +0 -23
- package/lib/cjs/dsl/dslProxyActivities.js.map +0 -1
- package/lib/cjs/dsl/projections.js +0 -59
- package/lib/cjs/dsl/projections.js.map +0 -1
- package/lib/cjs/dsl/setup/ActivityContext.js +0 -120
- package/lib/cjs/dsl/setup/ActivityContext.js.map +0 -1
- package/lib/cjs/dsl/setup/fetch/DataProvider.js +0 -51
- package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +0 -1
- package/lib/cjs/dsl/setup/fetch/index.js +0 -16
- package/lib/cjs/dsl/setup/fetch/index.js.map +0 -1
- package/lib/cjs/dsl/setup/fetch/providers.js +0 -67
- package/lib/cjs/dsl/setup/fetch/providers.js.map +0 -1
- package/lib/cjs/dsl/test/test-child-workflow.js +0 -10
- package/lib/cjs/dsl/test/test-child-workflow.js.map +0 -1
- package/lib/cjs/dsl/validation.js +0 -122
- package/lib/cjs/dsl/validation.js.map +0 -1
- package/lib/cjs/dsl/vars.js +0 -341
- package/lib/cjs/dsl/vars.js.map +0 -1
- package/lib/cjs/dsl/walk.js +0 -100
- package/lib/cjs/dsl/walk.js.map +0 -1
- package/lib/cjs/dsl.js +0 -20
- package/lib/cjs/dsl.js.map +0 -1
- package/lib/cjs/errors.js +0 -49
- package/lib/cjs/errors.js.map +0 -1
- package/lib/cjs/index.js +0 -54
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/extractToc.js +0 -47
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js +0 -69
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/generatePart.js +0 -73
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/generateToc.js +0 -91
- package/lib/cjs/iterative-generation/activities/generateToc.js.map +0 -1
- package/lib/cjs/iterative-generation/activities/index.js +0 -12
- package/lib/cjs/iterative-generation/activities/index.js.map +0 -1
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +0 -56
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +0 -1
- package/lib/cjs/iterative-generation/types.js +0 -5
- package/lib/cjs/iterative-generation/types.js.map +0 -1
- package/lib/cjs/iterative-generation/utils.js +0 -121
- package/lib/cjs/iterative-generation/utils.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/result-types.js +0 -10
- package/lib/cjs/result-types.js.map +0 -1
- package/lib/cjs/system/notifyWebhookWorkflow.js +0 -46
- package/lib/cjs/system/notifyWebhookWorkflow.js.map +0 -1
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +0 -33
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +0 -1
- package/lib/cjs/utils/auth.js +0 -15
- package/lib/cjs/utils/auth.js.map +0 -1
- package/lib/cjs/utils/blobs.js +0 -61
- package/lib/cjs/utils/blobs.js.map +0 -1
- package/lib/cjs/utils/chunks.js +0 -14
- package/lib/cjs/utils/chunks.js.map +0 -1
- package/lib/cjs/utils/client.js +0 -29
- package/lib/cjs/utils/client.js.map +0 -1
- package/lib/cjs/utils/expand-vars.js +0 -33
- package/lib/cjs/utils/expand-vars.js.map +0 -1
- package/lib/cjs/utils/memory.js +0 -65
- package/lib/cjs/utils/memory.js.map +0 -1
- package/lib/cjs/utils/renditions.js +0 -88
- package/lib/cjs/utils/renditions.js.map +0 -1
- package/lib/cjs/utils/storage.js +0 -55
- package/lib/cjs/utils/storage.js.map +0 -1
- package/lib/cjs/utils/tokens.js +0 -38
- package/lib/cjs/utils/tokens.js.map +0 -1
- package/lib/cjs/vars.js +0 -20
- package/lib/cjs/vars.js.map +0 -1
- package/lib/cjs/workflows.js +0 -15
- package/lib/cjs/workflows.js.map +0 -1
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +0 -29
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +0 -1
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +0 -69
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +0 -1
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +0 -15
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +0 -1
- package/lib/esm/activities/chunkDocument.js +0 -81
- package/lib/esm/activities/chunkDocument.js.map +0 -1
- package/lib/esm/activities/createDocumentFromOther.js +0 -58
- package/lib/esm/activities/createDocumentFromOther.js.map +0 -1
- package/lib/esm/activities/executeInteraction.js +0 -182
- package/lib/esm/activities/executeInteraction.js.map +0 -1
- package/lib/esm/activities/extractDocumentText.js +0 -153
- package/lib/esm/activities/extractDocumentText.js.map +0 -1
- package/lib/esm/activities/generateDocumentProperties.js +0 -75
- package/lib/esm/activities/generateDocumentProperties.js.map +0 -1
- package/lib/esm/activities/generateEmbeddings.js +0 -355
- package/lib/esm/activities/generateEmbeddings.js.map +0 -1
- package/lib/esm/activities/generateOrAssignContentType.js +0 -120
- package/lib/esm/activities/generateOrAssignContentType.js.map +0 -1
- package/lib/esm/activities/getObjectFromStore.js +0 -17
- package/lib/esm/activities/getObjectFromStore.js.map +0 -1
- package/lib/esm/activities/handleError.js +0 -19
- package/lib/esm/activities/handleError.js.map +0 -1
- package/lib/esm/activities/identifyTextSections.js +0 -45
- package/lib/esm/activities/identifyTextSections.js.map +0 -1
- package/lib/esm/activities/index-dsl.js +0 -21
- package/lib/esm/activities/index-dsl.js.map +0 -1
- package/lib/esm/activities/index.js +0 -5
- package/lib/esm/activities/index.js.map +0 -1
- package/lib/esm/activities/media/processPdfWithTextract.js +0 -99
- package/lib/esm/activities/media/processPdfWithTextract.js.map +0 -1
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +0 -48
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +0 -1
- package/lib/esm/activities/notifyWebhook.js +0 -30
- package/lib/esm/activities/notifyWebhook.js.map +0 -1
- package/lib/esm/activities/renditions/generateImageRendition.js +0 -63
- package/lib/esm/activities/renditions/generateImageRendition.js.map +0 -1
- package/lib/esm/activities/renditions/generateVideoRendition.js +0 -194
- package/lib/esm/activities/renditions/generateVideoRendition.js.map +0 -1
- package/lib/esm/activities/setDocumentStatus.js +0 -12
- package/lib/esm/activities/setDocumentStatus.js.map +0 -1
- package/lib/esm/conversion/TextractProcessor.js +0 -410
- package/lib/esm/conversion/TextractProcessor.js.map +0 -1
- package/lib/esm/conversion/image.js +0 -141
- package/lib/esm/conversion/image.js.map +0 -1
- package/lib/esm/conversion/markitdown.js +0 -36
- package/lib/esm/conversion/markitdown.js.map +0 -1
- package/lib/esm/conversion/mutool.js +0 -139
- package/lib/esm/conversion/mutool.js.map +0 -1
- package/lib/esm/conversion/pandoc.js +0 -36
- package/lib/esm/conversion/pandoc.js.map +0 -1
- package/lib/esm/dsl/conditions.js +0 -75
- package/lib/esm/dsl/conditions.js.map +0 -1
- package/lib/esm/dsl/dsl-workflow.js +0 -270
- package/lib/esm/dsl/dsl-workflow.js.map +0 -1
- package/lib/esm/dsl/dslProxyActivities.js +0 -20
- package/lib/esm/dsl/dslProxyActivities.js.map +0 -1
- package/lib/esm/dsl/projections.js +0 -55
- package/lib/esm/dsl/projections.js.map +0 -1
- package/lib/esm/dsl/setup/ActivityContext.js +0 -115
- package/lib/esm/dsl/setup/ActivityContext.js.map +0 -1
- package/lib/esm/dsl/setup/fetch/DataProvider.js +0 -47
- package/lib/esm/dsl/setup/fetch/DataProvider.js.map +0 -1
- package/lib/esm/dsl/setup/fetch/index.js +0 -12
- package/lib/esm/dsl/setup/fetch/index.js.map +0 -1
- package/lib/esm/dsl/setup/fetch/providers.js +0 -61
- package/lib/esm/dsl/setup/fetch/providers.js.map +0 -1
- package/lib/esm/dsl/test/test-child-workflow.js +0 -5
- package/lib/esm/dsl/test/test-child-workflow.js.map +0 -1
- package/lib/esm/dsl/validation.js +0 -118
- package/lib/esm/dsl/validation.js.map +0 -1
- package/lib/esm/dsl/vars.js +0 -335
- package/lib/esm/dsl/vars.js.map +0 -1
- package/lib/esm/dsl/walk.js +0 -96
- package/lib/esm/dsl/walk.js.map +0 -1
- package/lib/esm/dsl.js +0 -4
- package/lib/esm/dsl.js.map +0 -1
- package/lib/esm/errors.js +0 -42
- package/lib/esm/errors.js.map +0 -1
- package/lib/esm/index.js +0 -36
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/iterative-generation/activities/extractToc.js +0 -44
- package/lib/esm/iterative-generation/activities/extractToc.js.map +0 -1
- package/lib/esm/iterative-generation/activities/finalizeOutput.js +0 -66
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +0 -1
- package/lib/esm/iterative-generation/activities/generatePart.js +0 -70
- package/lib/esm/iterative-generation/activities/generatePart.js.map +0 -1
- package/lib/esm/iterative-generation/activities/generateToc.js +0 -88
- package/lib/esm/iterative-generation/activities/generateToc.js.map +0 -1
- package/lib/esm/iterative-generation/activities/index.js +0 -5
- package/lib/esm/iterative-generation/activities/index.js.map +0 -1
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +0 -53
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +0 -1
- package/lib/esm/iterative-generation/types.js +0 -2
- package/lib/esm/iterative-generation/types.js.map +0 -1
- package/lib/esm/iterative-generation/utils.js +0 -112
- package/lib/esm/iterative-generation/utils.js.map +0 -1
- package/lib/esm/result-types.js +0 -7
- package/lib/esm/result-types.js.map +0 -1
- package/lib/esm/system/notifyWebhookWorkflow.js +0 -43
- package/lib/esm/system/notifyWebhookWorkflow.js.map +0 -1
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js +0 -30
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +0 -1
- package/lib/esm/utils/auth.js +0 -8
- package/lib/esm/utils/auth.js.map +0 -1
- package/lib/esm/utils/blobs.js +0 -51
- package/lib/esm/utils/blobs.js.map +0 -1
- package/lib/esm/utils/chunks.js +0 -9
- package/lib/esm/utils/chunks.js.map +0 -1
- package/lib/esm/utils/client.js +0 -25
- package/lib/esm/utils/client.js.map +0 -1
- package/lib/esm/utils/expand-vars.js +0 -30
- package/lib/esm/utils/expand-vars.js.map +0 -1
- package/lib/esm/utils/memory.js +0 -55
- package/lib/esm/utils/memory.js.map +0 -1
- package/lib/esm/utils/renditions.js +0 -80
- package/lib/esm/utils/renditions.js.map +0 -1
- package/lib/esm/utils/storage.js +0 -46
- package/lib/esm/utils/storage.js.map +0 -1
- package/lib/esm/utils/tokens.js +0 -34
- package/lib/esm/utils/tokens.js.map +0 -1
- package/lib/esm/vars.js +0 -4
- package/lib/esm/vars.js.map +0 -1
- package/lib/esm/workflows.js +0 -8
- package/lib/esm/workflows.js.map +0 -1
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +0 -17
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +0 -1
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +0 -39
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +0 -1
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +0 -19
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +0 -1
- package/lib/types/activities/chunkDocument.d.ts +0 -33
- package/lib/types/activities/chunkDocument.d.ts.map +0 -1
- package/lib/types/activities/createDocumentFromOther.d.ts +0 -21
- package/lib/types/activities/createDocumentFromOther.d.ts.map +0 -1
- package/lib/types/activities/executeInteraction.d.ts +0 -57
- package/lib/types/activities/executeInteraction.d.ts.map +0 -1
- package/lib/types/activities/extractDocumentText.d.ts +0 -10
- package/lib/types/activities/extractDocumentText.d.ts.map +0 -1
- package/lib/types/activities/generateDocumentProperties.d.ts +0 -32
- package/lib/types/activities/generateDocumentProperties.d.ts.map +0 -1
- package/lib/types/activities/generateEmbeddings.d.ts +0 -53
- package/lib/types/activities/generateEmbeddings.d.ts.map +0 -1
- package/lib/types/activities/generateOrAssignContentType.d.ts +0 -44
- package/lib/types/activities/generateOrAssignContentType.d.ts.map +0 -1
- package/lib/types/activities/getObjectFromStore.d.ts +0 -14
- package/lib/types/activities/getObjectFromStore.d.ts.map +0 -1
- package/lib/types/activities/handleError.d.ts +0 -6
- package/lib/types/activities/handleError.d.ts.map +0 -1
- package/lib/types/activities/identifyTextSections.d.ts +0 -12
- package/lib/types/activities/identifyTextSections.d.ts.map +0 -1
- package/lib/types/activities/index-dsl.d.ts +0 -20
- package/lib/types/activities/index-dsl.d.ts.map +0 -1
- package/lib/types/activities/index.d.ts +0 -5
- package/lib/types/activities/index.d.ts.map +0 -1
- package/lib/types/activities/media/processPdfWithTextract.d.ts +0 -26
- package/lib/types/activities/media/processPdfWithTextract.d.ts.map +0 -1
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +0 -14
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +0 -1
- package/lib/types/activities/notifyWebhook.d.ts +0 -16
- package/lib/types/activities/notifyWebhook.d.ts.map +0 -1
- package/lib/types/activities/renditions/generateImageRendition.d.ts +0 -14
- package/lib/types/activities/renditions/generateImageRendition.d.ts.map +0 -1
- package/lib/types/activities/renditions/generateVideoRendition.d.ts +0 -15
- package/lib/types/activities/renditions/generateVideoRendition.d.ts.map +0 -1
- package/lib/types/activities/setDocumentStatus.d.ts +0 -15
- package/lib/types/activities/setDocumentStatus.d.ts.map +0 -1
- package/lib/types/conversion/TextractProcessor.d.ts +0 -45
- package/lib/types/conversion/TextractProcessor.d.ts.map +0 -1
- package/lib/types/conversion/image.d.ts +0 -13
- package/lib/types/conversion/image.d.ts.map +0 -1
- package/lib/types/conversion/markitdown.d.ts +0 -2
- package/lib/types/conversion/markitdown.d.ts.map +0 -1
- package/lib/types/conversion/mutool.d.ts +0 -19
- package/lib/types/conversion/mutool.d.ts.map +0 -1
- package/lib/types/conversion/pandoc.d.ts +0 -2
- package/lib/types/conversion/pandoc.d.ts.map +0 -1
- package/lib/types/dsl/conditions.d.ts +0 -2
- package/lib/types/dsl/conditions.d.ts.map +0 -1
- package/lib/types/dsl/dsl-workflow.d.ts +0 -5
- package/lib/types/dsl/dsl-workflow.d.ts.map +0 -1
- package/lib/types/dsl/dslProxyActivities.d.ts +0 -10
- package/lib/types/dsl/dslProxyActivities.d.ts.map +0 -1
- package/lib/types/dsl/projections.d.ts +0 -4
- package/lib/types/dsl/projections.d.ts.map +0 -1
- package/lib/types/dsl/setup/ActivityContext.d.ts +0 -17
- package/lib/types/dsl/setup/ActivityContext.d.ts.map +0 -1
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts +0 -9
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +0 -1
- package/lib/types/dsl/setup/fetch/index.d.ts +0 -6
- package/lib/types/dsl/setup/fetch/index.d.ts.map +0 -1
- package/lib/types/dsl/setup/fetch/providers.d.ts +0 -25
- package/lib/types/dsl/setup/fetch/providers.d.ts.map +0 -1
- package/lib/types/dsl/test/test-child-workflow.d.ts +0 -4
- package/lib/types/dsl/test/test-child-workflow.d.ts.map +0 -1
- package/lib/types/dsl/validation.d.ts +0 -4
- package/lib/types/dsl/validation.d.ts.map +0 -1
- package/lib/types/dsl/vars.d.ts +0 -48
- package/lib/types/dsl/vars.d.ts.map +0 -1
- package/lib/types/dsl/walk.d.ts +0 -18
- package/lib/types/dsl/walk.d.ts.map +0 -1
- package/lib/types/dsl.d.ts +0 -4
- package/lib/types/dsl.d.ts.map +0 -1
- package/lib/types/errors.d.ts +0 -23
- package/lib/types/errors.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -35
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/extractToc.d.ts +0 -10
- package/lib/types/iterative-generation/activities/extractToc.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +0 -3
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/generatePart.d.ts +0 -3
- package/lib/types/iterative-generation/activities/generatePart.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/generateToc.d.ts +0 -4
- package/lib/types/iterative-generation/activities/generateToc.d.ts.map +0 -1
- package/lib/types/iterative-generation/activities/index.d.ts +0 -5
- package/lib/types/iterative-generation/activities/index.d.ts.map +0 -1
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +0 -3
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +0 -1
- package/lib/types/iterative-generation/types.d.ts +0 -79
- package/lib/types/iterative-generation/types.d.ts.map +0 -1
- package/lib/types/iterative-generation/utils.d.ts +0 -27
- package/lib/types/iterative-generation/utils.d.ts.map +0 -1
- package/lib/types/result-types.d.ts +0 -22
- package/lib/types/result-types.d.ts.map +0 -1
- package/lib/types/system/notifyWebhookWorkflow.d.ts +0 -7
- package/lib/types/system/notifyWebhookWorkflow.d.ts.map +0 -1
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +0 -25
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +0 -1
- package/lib/types/utils/auth.d.ts +0 -4
- package/lib/types/utils/auth.d.ts.map +0 -1
- package/lib/types/utils/blobs.d.ts +0 -7
- package/lib/types/utils/blobs.d.ts.map +0 -1
- package/lib/types/utils/chunks.d.ts +0 -9
- package/lib/types/utils/chunks.d.ts.map +0 -1
- package/lib/types/utils/client.d.ts +0 -12
- package/lib/types/utils/client.d.ts.map +0 -1
- package/lib/types/utils/expand-vars.d.ts +0 -8
- package/lib/types/utils/expand-vars.d.ts.map +0 -1
- package/lib/types/utils/memory.d.ts +0 -8
- package/lib/types/utils/memory.d.ts.map +0 -1
- package/lib/types/utils/renditions.d.ts +0 -23
- package/lib/types/utils/renditions.d.ts.map +0 -1
- package/lib/types/utils/storage.d.ts +0 -16
- package/lib/types/utils/storage.d.ts.map +0 -1
- package/lib/types/utils/tokens.d.ts +0 -11
- package/lib/types/utils/tokens.d.ts.map +0 -1
- package/lib/types/vars.d.ts +0 -3
- package/lib/types/vars.d.ts.map +0 -1
- package/lib/types/workflows.d.ts +0 -8
- package/lib/types/workflows.d.ts.map +0 -1
- package/lib/workflows-bundle.js +0 -12908
- package/src/activities/identifyTextSections.ts +0 -71
|
@@ -1,32 +1,130 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MockActivityEnvironment,
|
|
3
|
-
TestWorkflowEnvironment,
|
|
4
3
|
} from "@temporalio/testing";
|
|
5
|
-
import { beforeAll, describe, expect, test } from "vitest";
|
|
6
|
-
import { notifyWebhook, NotifyWebhook } from "./notifyWebhook.js";
|
|
4
|
+
import { beforeAll, beforeEach, describe, expect, it, test, vi } from "vitest";
|
|
5
|
+
import { notifyWebhook, NotifyWebhook, NotifyWebhookParams } from "./notifyWebhook.js";
|
|
6
|
+
import { ContentEventName, DSLActivityExecutionPayload } from "@vertesia/common";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// Mock fetch globally
|
|
9
|
+
vi.stubGlobal('fetch', vi.fn());
|
|
10
|
+
|
|
11
|
+
let testEnv: MockActivityEnvironment;
|
|
12
|
+
const mockFetch = vi.mocked(fetch);
|
|
10
13
|
|
|
11
14
|
beforeAll(async () => {
|
|
12
|
-
testEnv =
|
|
13
|
-
|
|
15
|
+
testEnv = new MockActivityEnvironment();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
vi.clearAllMocks();
|
|
14
20
|
});
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
const defaultParams = {
|
|
23
|
+
target_url: "https://vertesia.test",
|
|
24
|
+
method: "POST" as const,
|
|
25
|
+
payload: { message: "Hello World" }
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Helper function to create test payload
|
|
29
|
+
const createTestPayload = (params: Partial<NotifyWebhookParams> = {}): DSLActivityExecutionPayload<NotifyWebhookParams> => {
|
|
30
|
+
const mergedParams = { ...defaultParams, ...params };
|
|
31
|
+
return {
|
|
32
|
+
auth_token: process.env.VERTESIA_KEY || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature",
|
|
33
|
+
account_id: "unset",
|
|
34
|
+
project_id: "unset",
|
|
35
|
+
params: mergedParams,
|
|
36
|
+
config: {
|
|
37
|
+
studio_url: "http://mock-studio",
|
|
38
|
+
store_url: "http://mock-store",
|
|
39
|
+
},
|
|
40
|
+
workflow_name: "",
|
|
41
|
+
event: ContentEventName.create,
|
|
42
|
+
objectIds: [],
|
|
43
|
+
vars: {},
|
|
44
|
+
activity: { name: "notifyWebhook", params: mergedParams }
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
18
48
|
describe("Webhook should be notified", () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
it("test POST success", async () => {
|
|
50
|
+
// Mock successful response
|
|
51
|
+
const mockResponse = {
|
|
52
|
+
ok: true,
|
|
53
|
+
status: 200,
|
|
54
|
+
statusText: 'OK',
|
|
55
|
+
url: defaultParams.target_url
|
|
56
|
+
};
|
|
57
|
+
mockFetch.mockResolvedValueOnce(mockResponse as Response);
|
|
58
|
+
|
|
59
|
+
const payload = createTestPayload();
|
|
60
|
+
const res = await testEnv.run(notifyWebhook, payload);
|
|
61
|
+
|
|
62
|
+
// Verify fetch was called with correct parameters
|
|
63
|
+
expect(mockFetch).toHaveBeenCalledWith(defaultParams.target_url, {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
body: JSON.stringify({ message: 'Hello World' }),
|
|
66
|
+
headers: {
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Verify response
|
|
72
|
+
expect(res).toEqual({
|
|
73
|
+
status: 200,
|
|
74
|
+
message: 'OK',
|
|
75
|
+
url: defaultParams.target_url
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("test POST server error", async () => {
|
|
80
|
+
// Mock error response with response body
|
|
81
|
+
const mockResponse = {
|
|
82
|
+
ok: false,
|
|
83
|
+
status: 500,
|
|
84
|
+
statusText: 'Internal Server Error',
|
|
85
|
+
url: defaultParams.target_url,
|
|
86
|
+
text: vi.fn().mockResolvedValue('{"error": "Database connection failed", "code": "DB_ERROR"}')
|
|
87
|
+
} as unknown as Response;
|
|
88
|
+
mockFetch.mockResolvedValueOnce(mockResponse);
|
|
89
|
+
|
|
90
|
+
const payload = createTestPayload();
|
|
91
|
+
|
|
92
|
+
// Expect the function to throw an error with response payload
|
|
93
|
+
await expect(testEnv.run(notifyWebhook, payload)).rejects.toThrow(
|
|
94
|
+
`Webhook Notification to ${defaultParams.target_url} failed with status: 500 Internal Server Error - Response: {"error": "Database connection failed", "code": "DB_ERROR"}`
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// Verify fetch was called with correct parameters
|
|
98
|
+
expect(mockFetch).toHaveBeenCalledWith(defaultParams.target_url, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
body: JSON.stringify({ message: 'Hello World' }),
|
|
101
|
+
headers: {
|
|
102
|
+
'Content-Type': 'application/json',
|
|
26
103
|
},
|
|
27
|
-
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Verify that text() was called to read the response
|
|
107
|
+
expect(mockResponse.text).toHaveBeenCalled();
|
|
108
|
+
});
|
|
28
109
|
|
|
29
|
-
|
|
30
|
-
|
|
110
|
+
it("test POST network error", async () => {
|
|
111
|
+
// Mock fetch to throw a network error
|
|
112
|
+
const networkError = new Error('Network request failed');
|
|
113
|
+
mockFetch.mockRejectedValueOnce(networkError);
|
|
114
|
+
|
|
115
|
+
const payload = createTestPayload();
|
|
116
|
+
|
|
117
|
+
// Expect the function to throw the network error
|
|
118
|
+
await expect(testEnv.run(notifyWebhook, payload)).rejects.toThrow('Network request failed');
|
|
119
|
+
|
|
120
|
+
// Verify fetch was called with correct parameters
|
|
121
|
+
expect(mockFetch).toHaveBeenCalledWith(defaultParams.target_url, {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
body: JSON.stringify({ message: 'Hello World' }),
|
|
124
|
+
headers: {
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
31
128
|
});
|
|
129
|
+
|
|
32
130
|
});
|
|
@@ -36,13 +36,26 @@ export async function notifyWebhook(payload: DSLActivityExecutionPayload<NotifyW
|
|
|
36
36
|
...headers
|
|
37
37
|
},
|
|
38
38
|
}).catch(err => {
|
|
39
|
-
log.
|
|
40
|
-
throw
|
|
39
|
+
log.error(`An error occurred while notifying webhook at ${target_url}`, { err });
|
|
40
|
+
throw err;
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
if (!res.ok) {
|
|
44
|
-
log.warn(`
|
|
45
|
-
|
|
44
|
+
log.warn(`Webhook endpoint ${target_url} returned an error - ${res.status} ${res.statusText}`, { fetchResponse: res });
|
|
45
|
+
|
|
46
|
+
// Try to get response payload for error message
|
|
47
|
+
let errorMessage = `Webhook Notification to ${target_url} failed with status: ${res.status} ${res.statusText}`;
|
|
48
|
+
try {
|
|
49
|
+
const responseText = await res.text();
|
|
50
|
+
if (responseText) {
|
|
51
|
+
errorMessage += ` - Response: ${responseText}`;
|
|
52
|
+
}
|
|
53
|
+
} catch (readError) {
|
|
54
|
+
// If we can't read the response, just use the basic error message
|
|
55
|
+
log.debug('Could not read response body for error', { readError });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
throw new Error(errorMessage);
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
return { status: res.status, message: res.statusText, url: res.url }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DSLActivityExecutionPayload, RateLimitRequestPayload } from "@vertesia/common";
|
|
2
|
+
import { activityInfo, log } from "@temporalio/activity";
|
|
3
|
+
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
4
|
+
|
|
5
|
+
export interface RateLimitParams {
|
|
6
|
+
interactionIdOrEndpoint: string;
|
|
7
|
+
environmentId?: string;
|
|
8
|
+
modelId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RateLimitResult {
|
|
12
|
+
delayMs: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function checkRateLimit(payload: DSLActivityExecutionPayload<RateLimitParams>): Promise<RateLimitResult> {
|
|
16
|
+
const { client, params } = await setupActivity<RateLimitParams>(payload);
|
|
17
|
+
const { environmentId, modelId } = params;
|
|
18
|
+
|
|
19
|
+
const result: RateLimitResult = {
|
|
20
|
+
delayMs: 0,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
// Call the studio-server endpoint to get rate limit delay using the Vertesia client
|
|
25
|
+
const info = activityInfo();
|
|
26
|
+
const requestPayload: RateLimitRequestPayload = {
|
|
27
|
+
interaction: params.interactionIdOrEndpoint,
|
|
28
|
+
workflow_run_id: info.workflowExecution.runId,
|
|
29
|
+
environment_id: environmentId,
|
|
30
|
+
model_id: modelId,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const response = await client.interactions.requestSlot(requestPayload);
|
|
34
|
+
result.delayMs = response.delay_ms;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
log.warn('Failed to call rate limit API:', {error});
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
41
|
+
}
|
package/src/conversion/image.ts
CHANGED
|
@@ -78,6 +78,12 @@ export async function imageResizer(
|
|
|
78
78
|
const command = `convert`
|
|
79
79
|
let args = [inputPath];
|
|
80
80
|
|
|
81
|
+
// Add JPEG shrink-on-load optimization
|
|
82
|
+
args.push("-define", `jpeg:size=${max_hw * 3}x${max_hw * 3}`);
|
|
83
|
+
|
|
84
|
+
// Remove metadata
|
|
85
|
+
args.push("-strip");
|
|
86
|
+
|
|
81
87
|
// https://usage.imagemagick.org/filter/nicolas/#downsample
|
|
82
88
|
// Add colorspace correction if enabled
|
|
83
89
|
if (colorspaceCorrection) {
|
|
@@ -110,9 +116,6 @@ export async function imageResizer(
|
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
// Add JPEG shrink-on-load optimization
|
|
114
|
-
args.push("-define", `jpeg:size=${max_hw * 3}x${max_hw * 3}`);
|
|
115
|
-
|
|
116
119
|
// Resize operation
|
|
117
120
|
args.push("-resize", `${max_hw}x${max_hw}>`);
|
|
118
121
|
|
package/src/dsl/dsl-workflow.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
log,
|
|
8
8
|
patched,
|
|
9
9
|
proxyActivities,
|
|
10
|
+
sleep,
|
|
10
11
|
startChild,
|
|
11
12
|
UntypedActivities,
|
|
12
13
|
} from "@temporalio/workflow";
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
DSLWorkflowExecutionPayload,
|
|
19
20
|
DSLWorkflowSpec,
|
|
20
21
|
getDocumentIds,
|
|
22
|
+
getTenantId,
|
|
21
23
|
WorkflowExecutionPayload
|
|
22
24
|
} from "@vertesia/common";
|
|
23
25
|
import ms, { StringValue } from 'ms';
|
|
@@ -25,6 +27,8 @@ import { HandleDslErrorParams } from "../activities/handleError.js";
|
|
|
25
27
|
import * as activities from "../activities/index.js";
|
|
26
28
|
import { WF_NON_RETRYABLE_ERRORS, WorkflowParamNotFoundError } from "../errors.js";
|
|
27
29
|
import { Vars } from "./vars.js";
|
|
30
|
+
import { RateLimitParams } from "../activities/rateLimiter.js";
|
|
31
|
+
|
|
28
32
|
|
|
29
33
|
interface BaseActivityPayload extends WorkflowExecutionPayload {
|
|
30
34
|
workflow_name: string;
|
|
@@ -172,6 +176,7 @@ async function startChildWorkflow(step: DSLChildWorkflowStep, payload: DSLWorkfl
|
|
|
172
176
|
AccountId: [payload.account_id],
|
|
173
177
|
DocumentId: getDocumentIds(payload),
|
|
174
178
|
ProjectId: [payload.project_id],
|
|
179
|
+
TenantId: [getTenantId(payload.account_id, payload.project_id)],
|
|
175
180
|
InitiatedBy: payload.initiated_by ? [payload.initiated_by] : [],
|
|
176
181
|
},
|
|
177
182
|
});
|
|
@@ -204,6 +209,7 @@ async function executeChildWorkflow(step: DSLChildWorkflowStep, payload: DSLWork
|
|
|
204
209
|
AccountId: [payload.account_id],
|
|
205
210
|
DocumentId: getDocumentIds(payload),
|
|
206
211
|
ProjectId: [payload.project_id],
|
|
212
|
+
TenantId: [getTenantId(payload.account_id, payload.project_id)],
|
|
207
213
|
InitiatedBy: payload.initiated_by ? [payload.initiated_by] : [],
|
|
208
214
|
},
|
|
209
215
|
});
|
|
@@ -218,6 +224,48 @@ async function executeChildWorkflow(step: DSLChildWorkflowStep, payload: DSLWork
|
|
|
218
224
|
}
|
|
219
225
|
}
|
|
220
226
|
|
|
227
|
+
function buildRateLimitParams(activity: DSLActivitySpec, executionPayload: DSLActivityExecutionPayload<any>): RateLimitParams {
|
|
228
|
+
const params = executionPayload.params;
|
|
229
|
+
let interactionId: string;
|
|
230
|
+
|
|
231
|
+
switch (activity.name) {
|
|
232
|
+
case "executeInteraction":
|
|
233
|
+
interactionId = params.interactionName;
|
|
234
|
+
break;
|
|
235
|
+
|
|
236
|
+
case "generateDocumentProperties":
|
|
237
|
+
interactionId = params.interactionName || "sys:ExtractInformation";
|
|
238
|
+
break;
|
|
239
|
+
|
|
240
|
+
case "identifyTextSections":
|
|
241
|
+
interactionId = params.interactionName || "sys:IdentifyTextSections";
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
case "generateOrAssignContentType":
|
|
245
|
+
interactionId = params.interactionNames?.selectDocumentType || "sys:SelectDocumentType";
|
|
246
|
+
break;
|
|
247
|
+
|
|
248
|
+
case "chunkDocument":
|
|
249
|
+
interactionId = params.interactionName || "sys:ChunkDocument";
|
|
250
|
+
break;
|
|
251
|
+
|
|
252
|
+
default:
|
|
253
|
+
// For any other rate-limited activities, try to extract what we can
|
|
254
|
+
interactionId = params.interactionName;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (!interactionId) {
|
|
259
|
+
throw new Error(`No interaction ID could be determined for activity ${activity.name}`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
interactionIdOrEndpoint: interactionId,
|
|
264
|
+
environmentId: params.environment,
|
|
265
|
+
modelId: params.model,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
221
269
|
async function runActivity(activity: DSLActivitySpec, basePayload: BaseActivityPayload, vars: Vars, defaultProxy: ActivityInterfaceFor<UntypedActivities>, defaultOptions: ActivityOptions) {
|
|
222
270
|
if (basePayload.debug_mode) {
|
|
223
271
|
log.debug(`Workflow vars before executing activity ${activity.name}`, { vars: vars.resolve() });
|
|
@@ -245,6 +293,38 @@ async function runActivity(activity: DSLActivitySpec, basePayload: BaseActivityP
|
|
|
245
293
|
});
|
|
246
294
|
}
|
|
247
295
|
|
|
296
|
+
if (patched('system-activity-taskqueue')) {
|
|
297
|
+
// hack: do nothing, remove later
|
|
298
|
+
// https://github.com/vertesia/composableai/pull/544/files
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// call rate limiter depending on the activity type
|
|
302
|
+
const rateLimitedActivities = [
|
|
303
|
+
"chunkDocument",
|
|
304
|
+
"executeInteraction",
|
|
305
|
+
"generateDocumentProperties",
|
|
306
|
+
"generateOrAssignContentType",
|
|
307
|
+
"identifyTextSections",
|
|
308
|
+
];
|
|
309
|
+
|
|
310
|
+
if (activity.name && rateLimitedActivities.includes(activity.name)) {
|
|
311
|
+
log.info(`Applying rate limit for activity ${activity.name}`);
|
|
312
|
+
// Apply rate limiting logic here
|
|
313
|
+
// Check rate limit first - loop until no delay
|
|
314
|
+
const rateLimitParams = buildRateLimitParams(activity, executionPayload);
|
|
315
|
+
|
|
316
|
+
const rateLimitPayload = dslActivityPayload(basePayload, activity, rateLimitParams);
|
|
317
|
+
let rateLimitResult = await proxy.checkRateLimit(rateLimitPayload);
|
|
318
|
+
|
|
319
|
+
while (rateLimitResult.delayMs > 0) {
|
|
320
|
+
log.info(`Rate limit delay applied: ${rateLimitResult.delayMs}ms`);
|
|
321
|
+
await sleep(rateLimitResult.delayMs);
|
|
322
|
+
|
|
323
|
+
// Check again after sleeping
|
|
324
|
+
rateLimitResult = await proxy.checkRateLimit(rateLimitPayload);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
248
328
|
const fn = proxy[activity.name];
|
|
249
329
|
if (activity.parallel) {
|
|
250
330
|
//TODO execute in parallel
|
|
@@ -6,16 +6,32 @@ import {
|
|
|
6
6
|
Project,
|
|
7
7
|
WorkflowExecutionPayload,
|
|
8
8
|
} from "@vertesia/common";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
DocumentNotFoundError,
|
|
11
|
+
WorkflowParamNotFoundError,
|
|
12
|
+
} from "../../errors.js";
|
|
10
13
|
import { getProjectFromToken } from "../../utils/auth.js";
|
|
11
14
|
import { getVertesiaClient } from "../../utils/client.js";
|
|
12
15
|
import { Vars } from "../vars.js";
|
|
13
|
-
import {
|
|
14
|
-
|
|
16
|
+
import {
|
|
17
|
+
getFetchProvider,
|
|
18
|
+
registerFetchProviderFactory,
|
|
19
|
+
} from "./fetch/index.js";
|
|
20
|
+
import {
|
|
21
|
+
DocumentProvider,
|
|
22
|
+
DocumentTypeProvider,
|
|
23
|
+
InteractionRunProvider,
|
|
24
|
+
} from "./fetch/providers.js";
|
|
15
25
|
|
|
16
26
|
registerFetchProviderFactory(DocumentProvider.ID, DocumentProvider.factory);
|
|
17
|
-
registerFetchProviderFactory(
|
|
18
|
-
|
|
27
|
+
registerFetchProviderFactory(
|
|
28
|
+
DocumentTypeProvider.ID,
|
|
29
|
+
DocumentTypeProvider.factory,
|
|
30
|
+
);
|
|
31
|
+
registerFetchProviderFactory(
|
|
32
|
+
InteractionRunProvider.ID,
|
|
33
|
+
InteractionRunProvider.factory,
|
|
34
|
+
);
|
|
19
35
|
|
|
20
36
|
export class ActivityContext<ParamsT extends Record<string, any>> {
|
|
21
37
|
client: VertesiaClient;
|
|
@@ -40,7 +56,10 @@ export class ActivityContext<ParamsT extends Record<string, any>> {
|
|
|
40
56
|
log.error("No objectId found in payload");
|
|
41
57
|
throw new WorkflowParamNotFoundError(
|
|
42
58
|
"objectIds[0]",
|
|
43
|
-
(
|
|
59
|
+
(
|
|
60
|
+
this
|
|
61
|
+
.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload
|
|
62
|
+
).workflow,
|
|
44
63
|
);
|
|
45
64
|
}
|
|
46
65
|
return objectId;
|
|
@@ -56,7 +75,10 @@ export class ActivityContext<ParamsT extends Record<string, any>> {
|
|
|
56
75
|
log.error("No runId found in activityInfo");
|
|
57
76
|
throw new WorkflowParamNotFoundError(
|
|
58
77
|
"runId",
|
|
59
|
-
(
|
|
78
|
+
(
|
|
79
|
+
this
|
|
80
|
+
.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload
|
|
81
|
+
).workflow,
|
|
60
82
|
);
|
|
61
83
|
}
|
|
62
84
|
return runId;
|
|
@@ -68,7 +90,10 @@ export class ActivityContext<ParamsT extends Record<string, any>> {
|
|
|
68
90
|
log.error("No workflowId found in activityInfo");
|
|
69
91
|
throw new WorkflowParamNotFoundError(
|
|
70
92
|
"workflowId",
|
|
71
|
-
(
|
|
93
|
+
(
|
|
94
|
+
this
|
|
95
|
+
.payload as WorkflowExecutionPayload as DSLWorkflowExecutionPayload
|
|
96
|
+
).workflow,
|
|
72
97
|
);
|
|
73
98
|
}
|
|
74
99
|
return workflowId;
|
|
@@ -102,7 +127,7 @@ export async function setupActivity<ParamsT extends Record<string, any>>(
|
|
|
102
127
|
});
|
|
103
128
|
}
|
|
104
129
|
|
|
105
|
-
const client = getVertesiaClient(payload);
|
|
130
|
+
const client = await getVertesiaClient(payload);
|
|
106
131
|
const fetchSpecs = payload.activity.fetch;
|
|
107
132
|
if (fetchSpecs) {
|
|
108
133
|
const keys = Object.keys(fetchSpecs);
|
|
@@ -118,7 +143,10 @@ export async function setupActivity<ParamsT extends Record<string, any>>(
|
|
|
118
143
|
|
|
119
144
|
const provider = getFetchProvider(client, fetchSpec);
|
|
120
145
|
|
|
121
|
-
log.info(
|
|
146
|
+
log.info(
|
|
147
|
+
`Fetching data for ${key} with provider ${provider.name}`,
|
|
148
|
+
{ fetchSpec },
|
|
149
|
+
);
|
|
122
150
|
const result = await provider.fetch(fetchSpec);
|
|
123
151
|
if (result && result.length > 0) {
|
|
124
152
|
if (fetchSpec.limit === 1) {
|
|
@@ -127,7 +155,9 @@ export async function setupActivity<ParamsT extends Record<string, any>>(
|
|
|
127
155
|
vars.setValue(key, result);
|
|
128
156
|
}
|
|
129
157
|
} else if (fetchSpec.on_not_found === "throw") {
|
|
130
|
-
throw new DocumentNotFoundError(
|
|
158
|
+
throw new DocumentNotFoundError(
|
|
159
|
+
"No documents found for: " + JSON.stringify(fetchSpec),
|
|
160
|
+
);
|
|
131
161
|
} else {
|
|
132
162
|
vars.setValue(key, null);
|
|
133
163
|
}
|
|
@@ -141,7 +171,10 @@ export async function setupActivity<ParamsT extends Record<string, any>>(
|
|
|
141
171
|
return new ActivityContext<ParamsT>(payload, client, params);
|
|
142
172
|
}
|
|
143
173
|
|
|
144
|
-
async function _fetchProject(
|
|
174
|
+
async function _fetchProject(
|
|
175
|
+
client: VertesiaClient,
|
|
176
|
+
payload: WorkflowExecutionPayload,
|
|
177
|
+
) {
|
|
145
178
|
const project = await getProjectFromToken(payload.auth_token);
|
|
146
179
|
return project ? await client.projects.retrieve(project.id) : undefined;
|
|
147
180
|
}
|
|
@@ -129,6 +129,7 @@ describe('DSL Workflow with child workflows', () => {
|
|
|
129
129
|
AccountId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
130
130
|
DocumentId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
131
131
|
ProjectId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
132
|
+
TenantId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
132
133
|
InitiatedBy: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
133
134
|
},
|
|
134
135
|
});
|
|
@@ -158,7 +159,7 @@ describe('DSL Workflow with child workflows', () => {
|
|
|
158
159
|
account_id: '123',
|
|
159
160
|
project_id: '123',
|
|
160
161
|
wf_rule_name: 'test',
|
|
161
|
-
auth_token: '
|
|
162
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
162
163
|
config: {
|
|
163
164
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
164
165
|
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
@@ -202,7 +203,7 @@ describe('DSL Workflow with child workflows', () => {
|
|
|
202
203
|
account_id: '123',
|
|
203
204
|
project_id: '123',
|
|
204
205
|
wf_rule_name: 'test',
|
|
205
|
-
auth_token: '
|
|
206
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
206
207
|
config: {
|
|
207
208
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
208
209
|
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
@@ -246,7 +247,7 @@ describe('DSL Workflow with child workflows', () => {
|
|
|
246
247
|
account_id: '123',
|
|
247
248
|
project_id: '123',
|
|
248
249
|
wf_rule_name: 'test',
|
|
249
|
-
auth_token: '
|
|
250
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
250
251
|
config: {
|
|
251
252
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
252
253
|
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
@@ -107,7 +107,7 @@ describe('DSL Workflow', () => {
|
|
|
107
107
|
project_id: '123',
|
|
108
108
|
timestamp: Date.now(),
|
|
109
109
|
wf_rule_name: 'test',
|
|
110
|
-
auth_token: '
|
|
110
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
111
111
|
config: {
|
|
112
112
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
113
113
|
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
@@ -61,7 +61,7 @@ describe('DSL Workflow import vars', () => {
|
|
|
61
61
|
project_id: '123',
|
|
62
62
|
timestamp: Date.now(),
|
|
63
63
|
wf_rule_name: 'test',
|
|
64
|
-
auth_token: '
|
|
64
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
65
65
|
config: {
|
|
66
66
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
67
67
|
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
package/src/dsl/workflow.test.ts
CHANGED
|
@@ -60,6 +60,7 @@ describe('DSL Workflow', () => {
|
|
|
60
60
|
AccountId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
61
61
|
DocumentId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
62
62
|
ProjectId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
63
|
+
TenantId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
63
64
|
InitiatedBy: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
64
65
|
},
|
|
65
66
|
});
|
|
@@ -90,7 +91,7 @@ describe('DSL Workflow', () => {
|
|
|
90
91
|
project_id: '123',
|
|
91
92
|
timestamp: Date.now(),
|
|
92
93
|
wf_rule_name: 'test',
|
|
93
|
-
auth_token: '
|
|
94
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
94
95
|
config: {
|
|
95
96
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
96
97
|
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
package/src/errors.ts
CHANGED
|
@@ -51,6 +51,19 @@ export class WorkflowParamNotFoundError extends ApplicationFailure {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export class ResourceExhaustedError extends ApplicationFailure {
|
|
55
|
+
constructor(
|
|
56
|
+
public statusCode: number = 429,
|
|
57
|
+
message?: string,
|
|
58
|
+
) {
|
|
59
|
+
super(
|
|
60
|
+
message || "Resource exhausted - rate limit exceeded",
|
|
61
|
+
"ResourceExhaustedError",
|
|
62
|
+
true, // non-retryable
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
54
67
|
export const WF_NON_RETRYABLE_ERRORS = [
|
|
55
68
|
"DocumentNotFoundError",
|
|
56
69
|
"ActivityParamInvalidError",
|
package/src/index.ts
CHANGED
|
@@ -18,11 +18,11 @@ export * from "./activities/executeInteraction.js";
|
|
|
18
18
|
export * from "./activities/extractDocumentText.js";
|
|
19
19
|
export * from "./activities/generateDocumentProperties.js";
|
|
20
20
|
export * from "./activities/generateEmbeddings.js";
|
|
21
|
-
export * from "./activities/identifyTextSections.js";
|
|
22
21
|
export * from "./activities/renditions/generateImageRendition.js";
|
|
23
22
|
export * from "./activities/renditions/generateVideoRendition.js";
|
|
24
23
|
export * from "./activities/generateOrAssignContentType.js";
|
|
25
24
|
export * from "./activities/notifyWebhook.js";
|
|
25
|
+
export * from "./activities/rateLimiter.js";
|
|
26
26
|
export * from "./activities/setDocumentStatus.js";
|
|
27
27
|
export * from "./iterative-generation/activities/index.js";
|
|
28
28
|
|
|
@@ -2,8 +2,16 @@ import { log } from "@temporalio/activity";
|
|
|
2
2
|
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
3
3
|
import { parse as parseYaml } from "yaml";
|
|
4
4
|
import { getVertesiaClient } from "../../utils/client.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
buildAndPublishMemoryPack,
|
|
7
|
+
loadMemoryPack,
|
|
8
|
+
} from "../../utils/memory.js";
|
|
9
|
+
import {
|
|
10
|
+
IterativeGenerationPayload,
|
|
11
|
+
OutputMemoryMeta,
|
|
12
|
+
Toc,
|
|
13
|
+
TocIndex,
|
|
14
|
+
} from "../types.js";
|
|
7
15
|
import { tocIndex } from "../utils.js";
|
|
8
16
|
|
|
9
17
|
/**
|
|
@@ -12,10 +20,12 @@ import { tocIndex } from "../utils.js";
|
|
|
12
20
|
*
|
|
13
21
|
* @param payload
|
|
14
22
|
*/
|
|
15
|
-
export async function it_gen_extractToc(
|
|
23
|
+
export async function it_gen_extractToc(
|
|
24
|
+
payload: WorkflowExecutionPayload,
|
|
25
|
+
): Promise<TocIndex | null> {
|
|
16
26
|
const vars = payload.vars as IterativeGenerationPayload;
|
|
17
27
|
const memory = vars.memory;
|
|
18
|
-
const client = getVertesiaClient(payload);
|
|
28
|
+
const client = await getVertesiaClient(payload);
|
|
19
29
|
|
|
20
30
|
const inMemory = await loadMemoryPack(client, `${memory}/input`);
|
|
21
31
|
let tocJson: string | null = null;
|
|
@@ -37,13 +47,17 @@ export async function it_gen_extractToc(payload: WorkflowExecutionPayload): Prom
|
|
|
37
47
|
|
|
38
48
|
log.info(`Found a TOC in the input memory pack`);
|
|
39
49
|
|
|
40
|
-
await buildAndPublishMemoryPack(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
await buildAndPublishMemoryPack(
|
|
51
|
+
client,
|
|
52
|
+
`${vars.memory}/output`,
|
|
53
|
+
async () => {
|
|
54
|
+
return {
|
|
55
|
+
toc,
|
|
56
|
+
lastProcessedPart: undefined, // the part index (a number array)
|
|
57
|
+
previouslyGenerated: "",
|
|
58
|
+
} as OutputMemoryMeta;
|
|
59
|
+
},
|
|
60
|
+
);
|
|
47
61
|
|
|
48
62
|
return tocIndex(toc);
|
|
49
|
-
}
|
|
63
|
+
}
|