@flowrunner/cli 0.1.0
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/README.md +148 -0
- package/ai-docs/instructions/service-code-format/01-service-structure.md +180 -0
- package/ai-docs/instructions/service-code-format/02-zod-types.md +260 -0
- package/ai-docs/instructions/service-code-format/03-parameters.md +193 -0
- package/ai-docs/instructions/service-code-format/04-http-requests.md +257 -0
- package/ai-docs/instructions/service-code-format/05-dictionaries.md +103 -0
- package/ai-docs/instructions/service-code-format/06-oauth2.md +42 -0
- package/ai-docs/instructions/service-code-format/07-actions.md +171 -0
- package/ai-docs/instructions/service-code-format/08-polling-triggers.md +54 -0
- package/ai-docs/instructions/service-code-format/09-realtime-triggers.md +269 -0
- package/ai-docs/instructions/service-code-format/10-files-api.md +148 -0
- package/ai-docs/instructions/service-code-format/11-output-model.md +142 -0
- package/ai-docs/instructions/service-code-format/12-service-readme.md +69 -0
- package/ai-docs/instructions/service-code-format/13-runtime-contracts.md +193 -0
- package/ai-docs/instructions/service-code-format/14-reference-service.md +341 -0
- package/ai-docs/instructions/service-code-format/15-unit-tests.md +361 -0
- package/ai-docs/instructions/service-code-format/16-gotchas.md +201 -0
- package/ai-docs/instructions/service-code-format/17-client-certificates.md +162 -0
- package/ai-docs/instructions/service-code-format/18-test-recipes.md +160 -0
- package/ai-docs/instructions/service-code-format/README.md +120 -0
- package/ai-docs/providers/claude/agents/flowrunner-service-code-engineer.md +139 -0
- package/ai-docs/providers/claude/agents/flowrunner-service-test-engineer.md +497 -0
- package/ai-docs/providers/claude/main-orchestrator-segment.md +51 -0
- package/bin/flowrunner.js +66 -0
- package/bin/resolve-local.js +98 -0
- package/dist/cli.js +10972 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10131 -0
- package/dist/index.js.map +7 -0
- package/dist/types/flow-extension-runner/src/common/config.d.ts +12 -0
- package/dist/types/flow-extension-runner/src/common/constants.d.ts +9 -0
- package/dist/types/flow-extension-runner/src/common/context-files.d.ts +107 -0
- package/dist/types/flow-extension-runner/src/common/context.d.ts +6 -0
- package/dist/types/flow-extension-runner/src/common/types.d.ts +11 -0
- package/dist/types/flow-extension-runner/src/errors/base.d.ts +17 -0
- package/dist/types/flow-extension-runner/src/errors/codes.d.ts +17 -0
- package/dist/types/flow-extension-runner/src/errors/errors.d.ts +48 -0
- package/dist/types/flow-extension-runner/src/errors/index.d.ts +3 -0
- package/dist/types/flow-extension-runner/src/global.d.ts +34 -0
- package/dist/types/flow-extension-runner/src/index.d.ts +15 -0
- package/dist/types/flow-extension-runner/src/namespace.d.ts +3 -0
- package/dist/types/flow-extension-runner/src/v1/config.d.ts +3 -0
- package/dist/types/flow-extension-runner/src/v1/constants.d.ts +4 -0
- package/dist/types/flow-extension-runner/src/v1/index.d.ts +11 -0
- package/dist/types/flow-extension-runner/src/v1/namespace.d.ts +9 -0
- package/dist/types/flow-extension-runner/src/v1/service.d.ts +29 -0
- package/dist/types/flow-extension-runner/src/v1/types.d.ts +13 -0
- package/dist/types/flow-extension-runner/src/v2/actions/action-method.d.ts +34 -0
- package/dist/types/flow-extension-runner/src/v2/context/execution-context.d.ts +25 -0
- package/dist/types/flow-extension-runner/src/v2/context/logger.d.ts +2 -0
- package/dist/types/flow-extension-runner/src/v2/context/method-input.d.ts +27 -0
- package/dist/types/flow-extension-runner/src/v2/context/proxies.d.ts +1 -0
- package/dist/types/flow-extension-runner/src/v2/create-extension.d.ts +2 -0
- package/dist/types/flow-extension-runner/src/v2/crypto.d.ts +6 -0
- package/dist/types/flow-extension-runner/src/v2/dictionaries/dictionary-method.d.ts +24 -0
- package/dist/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +10 -0
- package/dist/types/flow-extension-runner/src/v2/extension.d.ts +51 -0
- package/dist/types/flow-extension-runner/src/v2/index.d.ts +39 -0
- package/dist/types/flow-extension-runner/src/v2/loaders/loader-method.d.ts +31 -0
- package/dist/types/flow-extension-runner/src/v2/loaders/loader-owner.d.ts +17 -0
- package/dist/types/flow-extension-runner/src/v2/loaders/payload-schema.d.ts +3 -0
- package/dist/types/flow-extension-runner/src/v2/method.d.ts +22 -0
- package/dist/types/flow-extension-runner/src/v2/model/field-mapper.d.ts +10 -0
- package/dist/types/flow-extension-runner/src/v2/model/method-model.d.ts +3 -0
- package/dist/types/flow-extension-runner/src/v2/model/model-types.d.ts +70 -0
- package/dist/types/flow-extension-runner/src/v2/model/params-model.d.ts +16 -0
- package/dist/types/flow-extension-runner/src/v2/oauth/method-names.d.ts +5 -0
- package/dist/types/flow-extension-runner/src/v2/oauth/oauth2.d.ts +9 -0
- package/dist/types/flow-extension-runner/src/v2/oauth/system-params.d.ts +6 -0
- package/dist/types/flow-extension-runner/src/v2/oauth/types.d.ts +54 -0
- package/dist/types/flow-extension-runner/src/v2/params/config-params.d.ts +14 -0
- package/dist/types/flow-extension-runner/src/v2/params/files-options.d.ts +58 -0
- package/dist/types/flow-extension-runner/src/v2/params/index.d.ts +19 -0
- package/dist/types/flow-extension-runner/src/v2/params/json/checks.d.ts +26 -0
- package/dist/types/flow-extension-runner/src/v2/params/json/decode.d.ts +24 -0
- package/dist/types/flow-extension-runner/src/v2/params/json/encode.d.ts +20 -0
- package/dist/types/flow-extension-runner/src/v2/params/json/types.d.ts +86 -0
- package/dist/types/flow-extension-runner/src/v2/params/json/values.d.ts +5 -0
- package/dist/types/flow-extension-runner/src/v2/params/method-params.d.ts +17 -0
- package/dist/types/flow-extension-runner/src/v2/params/params.d.ts +26 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/assert-object-schema.d.ts +6 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/assert-supported-schema.d.ts +8 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/coerce.d.ts +54 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/dates.d.ts +40 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +36 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +33 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +58 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/labels.d.ts +3 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/messages.d.ts +16 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/normalize.d.ts +8 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/parse.d.ts +7 -0
- package/dist/types/flow-extension-runner/src/v2/params/types.d.ts +29 -0
- package/dist/types/flow-extension-runner/src/v2/params/widget-types.d.ts +40 -0
- package/dist/types/flow-extension-runner/src/v2/params/zod.d.ts +86 -0
- package/dist/types/flow-extension-runner/src/v2/path.d.ts +1 -0
- package/dist/types/flow-extension-runner/src/v2/polling-triggers/mechanisms.d.ts +19 -0
- package/dist/types/flow-extension-runner/src/v2/polling-triggers/method-names.d.ts +1 -0
- package/dist/types/flow-extension-runner/src/v2/polling-triggers/polling-triggers.d.ts +11 -0
- package/dist/types/flow-extension-runner/src/v2/polling-triggers/system-params.d.ts +7 -0
- package/dist/types/flow-extension-runner/src/v2/polling-triggers/trigger-method.d.ts +25 -0
- package/dist/types/flow-extension-runner/src/v2/polling-triggers/types.d.ts +46 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/method-names.d.ts +7 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/realtime-setup.d.ts +10 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/system-params.d.ts +29 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/trigger-method.d.ts +33 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +147 -0
- package/dist/types/flow-extension-runner/src/v2/realtime-triggers/verify.d.ts +2 -0
- package/dist/types/flow-extension-runner/src/v2/registry.d.ts +20 -0
- package/dist/types/flow-extension-runner/src/v2/result.d.ts +13 -0
- package/dist/types/flow-extension-runner/src/v2/system-method.d.ts +41 -0
- package/dist/types/flow-extension-runner/src/v2/types.d.ts +126 -0
- package/dist/types/jsdoc-parser/src/custom-type-defs/files.d.ts +2 -0
- package/dist/types/jsdoc-parser/src/index.d.ts +2 -0
- package/dist/types/jsdoc-parser/src/lib.d.ts +42 -0
- package/dist/types/jsdoc-parser/src/types.d.ts +2 -0
- package/dist/types/packages/cli/src/api/console-client.d.ts +69 -0
- package/dist/types/packages/cli/src/constants/index.d.ts +5 -0
- package/dist/types/packages/cli/src/constants/packaging.d.ts +7 -0
- package/dist/types/packages/cli/src/constants/project.d.ts +9 -0
- package/dist/types/packages/cli/src/constants/providers.d.ts +30 -0
- package/dist/types/packages/cli/src/constants/server.d.ts +29 -0
- package/dist/types/packages/cli/src/constants/testing.d.ts +32 -0
- package/dist/types/packages/cli/src/errors.d.ts +131 -0
- package/dist/types/packages/cli/src/index.d.ts +29 -0
- package/dist/types/packages/cli/src/operations/deploy/discover-services.d.ts +26 -0
- package/dist/types/packages/cli/src/operations/deploy/hash.d.ts +1 -0
- package/dist/types/packages/cli/src/operations/deploy/index.d.ts +94 -0
- package/dist/types/packages/cli/src/operations/deploy/public-files.d.ts +20 -0
- package/dist/types/packages/cli/src/operations/deploy/select.d.ts +9 -0
- package/dist/types/packages/cli/src/operations/deploy/zip.d.ts +1 -0
- package/dist/types/packages/cli/src/operations/init/answers.d.ts +35 -0
- package/dist/types/packages/cli/src/operations/init/create-service.d.ts +39 -0
- package/dist/types/packages/cli/src/operations/init/index.d.ts +79 -0
- package/dist/types/packages/cli/src/operations/init/testing.d.ts +13 -0
- package/dist/types/packages/cli/src/operations/init-claude/index.d.ts +40 -0
- package/dist/types/packages/cli/src/operations/init-claude/segment.d.ts +25 -0
- package/dist/types/packages/cli/src/operations/login.d.ts +38 -0
- package/dist/types/packages/cli/src/operations/logout.d.ts +19 -0
- package/dist/types/packages/cli/src/operations/pull/extract.d.ts +23 -0
- package/dist/types/packages/cli/src/operations/pull/index.d.ts +87 -0
- package/dist/types/packages/cli/src/operations/server-target.d.ts +14 -0
- package/dist/types/packages/cli/src/operations/types.d.ts +20 -0
- package/dist/types/packages/cli/src/operations/use-server.d.ts +17 -0
- package/dist/types/packages/cli/src/project/auth.d.ts +41 -0
- package/dist/types/packages/cli/src/project/config.d.ts +31 -0
- package/dist/types/packages/cli/src/project/token.d.ts +5 -0
- package/dist/types/packages/cli/src/server/index.d.ts +14 -0
- package/dist/types/packages/cli/src/server/pages.d.ts +2 -0
- package/dist/types/packages/cli/src/server/routes/callback.d.ts +6 -0
- package/dist/types/packages/cli/src/server/types.d.ts +12 -0
- package/dist/types/packages/cli/src/templates/index.d.ts +8 -0
- package/dist/types/packages/cli/src/templates/manifest.d.ts +97 -0
- package/dist/types/packages/cli/src/templates/package-root.d.ts +3 -0
- package/dist/types/packages/cli/src/templates/paths.d.ts +3 -0
- package/dist/types/packages/cli/src/templates/registry.d.ts +13 -0
- package/dist/types/packages/cli/src/templates/render.d.ts +13 -0
- package/dist/types/packages/cli/src/templates/scaffold.d.ts +25 -0
- package/dist/types/packages/cli/src/utils/invocation.d.ts +28 -0
- package/dist/types/packages/cli/src/utils/open-browser.d.ts +2 -0
- package/dist/types/shared/src/constants/ai-agent-tools.d.ts +20 -0
- package/dist/types/shared/src/constants/ai.d.ts +11 -0
- package/dist/types/shared/src/constants/api-keys.d.ts +1 -0
- package/dist/types/shared/src/constants/app.d.ts +58 -0
- package/dist/types/shared/src/constants/billing.d.ts +16 -0
- package/dist/types/shared/src/constants/compliances.d.ts +3 -0
- package/dist/types/shared/src/constants/data-types.d.ts +26 -0
- package/dist/types/shared/src/constants/error-codes.d.ts +16 -0
- package/dist/types/shared/src/constants/flow.d.ts +12 -0
- package/dist/types/shared/src/constants/index.d.ts +16 -0
- package/dist/types/shared/src/constants/knowledge-base.d.ts +13 -0
- package/dist/types/shared/src/constants/notification-types.d.ts +985 -0
- package/dist/types/shared/src/constants/notifications.d.ts +10 -0
- package/dist/types/shared/src/constants/patterns.d.ts +28 -0
- package/dist/types/shared/src/constants/retry-policy.d.ts +30 -0
- package/dist/types/shared/src/constants/severity.d.ts +9 -0
- package/dist/types/shared/src/constants/shared-extensions-search.d.ts +6 -0
- package/dist/types/shared/src/constants/shared-extensions.d.ts +35 -0
- package/dist/types/shared/src/constants/zod.d.ts +2 -0
- package/dist/types/shared/src/errors/api.d.ts +4 -0
- package/dist/types/shared/src/errors/base.d.ts +38 -0
- package/dist/types/shared/src/errors/common.d.ts +39 -0
- package/dist/types/shared/src/errors/index.d.ts +13 -0
- package/dist/types/shared/src/errors/k8s.d.ts +4 -0
- package/dist/types/shared/src/errors/message.d.ts +48 -0
- package/dist/types/shared/src/errors/open-search.d.ts +4 -0
- package/dist/types/shared/src/errors/s3.d.ts +11 -0
- package/dist/types/shared/src/extensions/zod.d.ts +25 -0
- package/dist/types/shared/src/scheme/account/dto.d.ts +60 -0
- package/dist/types/shared/src/scheme/account/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/ai-agent-tools/dto.d.ts +69 -0
- package/dist/types/shared/src/scheme/ai-agent-tools/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/ai-agent-tools/parameters.d.ts +7 -0
- package/dist/types/shared/src/scheme/ai-router/dto.d.ts +23 -0
- package/dist/types/shared/src/scheme/ai-router/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/api-keys/dto.d.ts +28 -0
- package/dist/types/shared/src/scheme/api-keys/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/app/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/app/java.dto.d.ts +6 -0
- package/dist/types/shared/src/scheme/billing/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/billing/java.dto.d.ts +163 -0
- package/dist/types/shared/src/scheme/crm/billing.d.ts +149 -0
- package/dist/types/shared/src/scheme/crm/dto.d.ts +212 -0
- package/dist/types/shared/src/scheme/crm/index.d.ts +3 -0
- package/dist/types/shared/src/scheme/data-types/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/data-types/java.dto.d.ts +23 -0
- package/dist/types/shared/src/scheme/dynamic-forms/dto.d.ts +30 -0
- package/dist/types/shared/src/scheme/dynamic-forms/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/extensions/index.d.ts +1 -0
- package/dist/types/shared/src/scheme/extensions/params-to-zod.d.ts +14 -0
- package/dist/types/shared/src/scheme/flowrunner/custom-elements.d.ts +368 -0
- package/dist/types/shared/src/scheme/flowrunner/index.d.ts +3 -0
- package/dist/types/shared/src/scheme/flowrunner/java.dto.d.ts +628 -0
- package/dist/types/shared/src/scheme/index.d.ts +19 -0
- package/dist/types/shared/src/scheme/integration-connection/dto.d.ts +81 -0
- package/dist/types/shared/src/scheme/integration-connection/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/knowledge-base/dto.d.ts +540 -0
- package/dist/types/shared/src/scheme/knowledge-base/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/mcp-oauth/dto.d.ts +7 -0
- package/dist/types/shared/src/scheme/mcp-oauth/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/notifications/dto.d.ts +111 -0
- package/dist/types/shared/src/scheme/notifications/index.d.ts +3 -0
- package/dist/types/shared/src/scheme/notifications/rest.d.ts +148 -0
- package/dist/types/shared/src/scheme/properties/account.d.ts +3 -0
- package/dist/types/shared/src/scheme/properties/app.d.ts +5 -0
- package/dist/types/shared/src/scheme/properties/billing.d.ts +12 -0
- package/dist/types/shared/src/scheme/properties/common.d.ts +2 -0
- package/dist/types/shared/src/scheme/properties/db.d.ts +8 -0
- package/dist/types/shared/src/scheme/properties/flow-extensions.d.ts +7 -0
- package/dist/types/shared/src/scheme/properties/index.d.ts +7 -0
- package/dist/types/shared/src/scheme/remote-mcp-server/dto.d.ts +278 -0
- package/dist/types/shared/src/scheme/remote-mcp-server/index.d.ts +2 -0
- package/dist/types/shared/src/scheme/shared-extensions/base.d.ts +56 -0
- package/dist/types/shared/src/scheme/shared-extensions/config.d.ts +96 -0
- package/dist/types/shared/src/scheme/shared-extensions/custom-extensions.d.ts +485 -0
- package/dist/types/shared/src/scheme/shared-extensions/extension.d.ts +387 -0
- package/dist/types/shared/src/scheme/shared-extensions/flow-extensions.d.ts +64 -0
- package/dist/types/shared/src/scheme/shared-extensions/index.d.ts +15 -0
- package/dist/types/shared/src/scheme/shared-extensions/light.d.ts +38 -0
- package/dist/types/shared/src/scheme/shared-extensions/logs.d.ts +21 -0
- package/dist/types/shared/src/scheme/shared-extensions/methods.d.ts +80 -0
- package/dist/types/shared/src/scheme/shared-extensions/params-schema.d.ts +47 -0
- package/dist/types/shared/src/scheme/shared-extensions/popular-pool.d.ts +11 -0
- package/dist/types/shared/src/scheme/shared-extensions/resolve.d.ts +364 -0
- package/dist/types/shared/src/scheme/shared-extensions/rest.d.ts +9 -0
- package/dist/types/shared/src/scheme/shared-extensions/search.d.ts +177 -0
- package/dist/types/shared/src/scheme/shared-extensions/service-identity.d.ts +10 -0
- package/dist/types/shared/src/scheme/shared-extensions/service-info.d.ts +15 -0
- package/dist/types/shared/src/scheme/workspace/dto.d.ts +40 -0
- package/dist/types/shared/src/scheme/workspace/index.d.ts +1 -0
- package/dist/types/shared/src/utils/object.d.ts +8 -0
- package/dist/types/shared/src/utils/uuid.d.ts +5 -0
- package/dist/types/shared/src/utils/versions.d.ts +4 -0
- package/dist/types/types/backendless-request.d.ts +40 -0
- package/package.json +66 -0
- package/project-files/jest.config.js +38 -0
- package/project-files/jest.setup.js +24 -0
- package/project-files/sandbox/files-mock.js +654 -0
- package/project-files/sandbox/index.js +32 -0
- package/project-files/sandbox/nock-mock.js +600 -0
- package/project-files/sandbox/service.js +145 -0
- package/runtime/index.d.ts +2 -0
- package/runtime/index.js +5665 -0
- package/runtime/index.js.map +7 -0
- package/runtime/types/flow-extension-runner/src/common/config.d.ts +12 -0
- package/runtime/types/flow-extension-runner/src/common/constants.d.ts +9 -0
- package/runtime/types/flow-extension-runner/src/common/context-files.d.ts +107 -0
- package/runtime/types/flow-extension-runner/src/common/context.d.ts +6 -0
- package/runtime/types/flow-extension-runner/src/common/types.d.ts +11 -0
- package/runtime/types/flow-extension-runner/src/errors/base.d.ts +17 -0
- package/runtime/types/flow-extension-runner/src/errors/codes.d.ts +17 -0
- package/runtime/types/flow-extension-runner/src/errors/errors.d.ts +48 -0
- package/runtime/types/flow-extension-runner/src/errors/index.d.ts +3 -0
- package/runtime/types/flow-extension-runner/src/global.d.ts +34 -0
- package/runtime/types/flow-extension-runner/src/index.d.ts +15 -0
- package/runtime/types/flow-extension-runner/src/namespace.d.ts +3 -0
- package/runtime/types/flow-extension-runner/src/v1/config.d.ts +3 -0
- package/runtime/types/flow-extension-runner/src/v1/constants.d.ts +4 -0
- package/runtime/types/flow-extension-runner/src/v1/index.d.ts +11 -0
- package/runtime/types/flow-extension-runner/src/v1/namespace.d.ts +9 -0
- package/runtime/types/flow-extension-runner/src/v1/service.d.ts +29 -0
- package/runtime/types/flow-extension-runner/src/v1/types.d.ts +13 -0
- package/runtime/types/flow-extension-runner/src/v2/actions/action-method.d.ts +34 -0
- package/runtime/types/flow-extension-runner/src/v2/context/execution-context.d.ts +25 -0
- package/runtime/types/flow-extension-runner/src/v2/context/logger.d.ts +2 -0
- package/runtime/types/flow-extension-runner/src/v2/context/method-input.d.ts +27 -0
- package/runtime/types/flow-extension-runner/src/v2/context/proxies.d.ts +1 -0
- package/runtime/types/flow-extension-runner/src/v2/create-extension.d.ts +2 -0
- package/runtime/types/flow-extension-runner/src/v2/crypto.d.ts +6 -0
- package/runtime/types/flow-extension-runner/src/v2/dictionaries/dictionary-method.d.ts +24 -0
- package/runtime/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +10 -0
- package/runtime/types/flow-extension-runner/src/v2/extension.d.ts +51 -0
- package/runtime/types/flow-extension-runner/src/v2/index.d.ts +39 -0
- package/runtime/types/flow-extension-runner/src/v2/loaders/loader-method.d.ts +31 -0
- package/runtime/types/flow-extension-runner/src/v2/loaders/loader-owner.d.ts +17 -0
- package/runtime/types/flow-extension-runner/src/v2/loaders/payload-schema.d.ts +3 -0
- package/runtime/types/flow-extension-runner/src/v2/method.d.ts +22 -0
- package/runtime/types/flow-extension-runner/src/v2/model/field-mapper.d.ts +10 -0
- package/runtime/types/flow-extension-runner/src/v2/model/method-model.d.ts +3 -0
- package/runtime/types/flow-extension-runner/src/v2/model/model-types.d.ts +70 -0
- package/runtime/types/flow-extension-runner/src/v2/model/params-model.d.ts +16 -0
- package/runtime/types/flow-extension-runner/src/v2/oauth/method-names.d.ts +5 -0
- package/runtime/types/flow-extension-runner/src/v2/oauth/oauth2.d.ts +9 -0
- package/runtime/types/flow-extension-runner/src/v2/oauth/system-params.d.ts +6 -0
- package/runtime/types/flow-extension-runner/src/v2/oauth/types.d.ts +54 -0
- package/runtime/types/flow-extension-runner/src/v2/params/config-params.d.ts +14 -0
- package/runtime/types/flow-extension-runner/src/v2/params/files-options.d.ts +58 -0
- package/runtime/types/flow-extension-runner/src/v2/params/index.d.ts +19 -0
- package/runtime/types/flow-extension-runner/src/v2/params/json/checks.d.ts +26 -0
- package/runtime/types/flow-extension-runner/src/v2/params/json/decode.d.ts +24 -0
- package/runtime/types/flow-extension-runner/src/v2/params/json/encode.d.ts +20 -0
- package/runtime/types/flow-extension-runner/src/v2/params/json/types.d.ts +86 -0
- package/runtime/types/flow-extension-runner/src/v2/params/json/values.d.ts +5 -0
- package/runtime/types/flow-extension-runner/src/v2/params/method-params.d.ts +17 -0
- package/runtime/types/flow-extension-runner/src/v2/params/params.d.ts +26 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/assert-object-schema.d.ts +6 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/assert-supported-schema.d.ts +8 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/coerce.d.ts +54 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/dates.d.ts +40 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +36 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +33 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +58 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/labels.d.ts +3 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/messages.d.ts +16 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/normalize.d.ts +8 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/parse.d.ts +7 -0
- package/runtime/types/flow-extension-runner/src/v2/params/types.d.ts +29 -0
- package/runtime/types/flow-extension-runner/src/v2/params/widget-types.d.ts +40 -0
- package/runtime/types/flow-extension-runner/src/v2/params/zod.d.ts +86 -0
- package/runtime/types/flow-extension-runner/src/v2/path.d.ts +1 -0
- package/runtime/types/flow-extension-runner/src/v2/polling-triggers/mechanisms.d.ts +19 -0
- package/runtime/types/flow-extension-runner/src/v2/polling-triggers/method-names.d.ts +1 -0
- package/runtime/types/flow-extension-runner/src/v2/polling-triggers/polling-triggers.d.ts +11 -0
- package/runtime/types/flow-extension-runner/src/v2/polling-triggers/system-params.d.ts +7 -0
- package/runtime/types/flow-extension-runner/src/v2/polling-triggers/trigger-method.d.ts +25 -0
- package/runtime/types/flow-extension-runner/src/v2/polling-triggers/types.d.ts +46 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/method-names.d.ts +7 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/realtime-setup.d.ts +10 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/system-params.d.ts +29 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/trigger-method.d.ts +33 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/types.d.ts +147 -0
- package/runtime/types/flow-extension-runner/src/v2/realtime-triggers/verify.d.ts +2 -0
- package/runtime/types/flow-extension-runner/src/v2/registry.d.ts +20 -0
- package/runtime/types/flow-extension-runner/src/v2/result.d.ts +13 -0
- package/runtime/types/flow-extension-runner/src/v2/system-method.d.ts +41 -0
- package/runtime/types/flow-extension-runner/src/v2/types.d.ts +126 -0
- package/runtime/types/jsdoc-parser/src/custom-type-defs/files.d.ts +2 -0
- package/runtime/types/jsdoc-parser/src/index.d.ts +2 -0
- package/runtime/types/jsdoc-parser/src/lib.d.ts +42 -0
- package/runtime/types/jsdoc-parser/src/types.d.ts +2 -0
- package/runtime/types/packages/cli/src/runtime/index.d.ts +5 -0
- package/runtime/types/shared/src/constants/ai-agent-tools.d.ts +20 -0
- package/runtime/types/shared/src/constants/ai.d.ts +11 -0
- package/runtime/types/shared/src/constants/api-keys.d.ts +1 -0
- package/runtime/types/shared/src/constants/app.d.ts +58 -0
- package/runtime/types/shared/src/constants/billing.d.ts +16 -0
- package/runtime/types/shared/src/constants/compliances.d.ts +3 -0
- package/runtime/types/shared/src/constants/data-types.d.ts +26 -0
- package/runtime/types/shared/src/constants/error-codes.d.ts +16 -0
- package/runtime/types/shared/src/constants/flow.d.ts +12 -0
- package/runtime/types/shared/src/constants/index.d.ts +16 -0
- package/runtime/types/shared/src/constants/knowledge-base.d.ts +13 -0
- package/runtime/types/shared/src/constants/notification-types.d.ts +985 -0
- package/runtime/types/shared/src/constants/notifications.d.ts +10 -0
- package/runtime/types/shared/src/constants/patterns.d.ts +28 -0
- package/runtime/types/shared/src/constants/retry-policy.d.ts +30 -0
- package/runtime/types/shared/src/constants/severity.d.ts +9 -0
- package/runtime/types/shared/src/constants/shared-extensions-search.d.ts +6 -0
- package/runtime/types/shared/src/constants/shared-extensions.d.ts +35 -0
- package/runtime/types/shared/src/constants/zod.d.ts +2 -0
- package/runtime/types/shared/src/errors/api.d.ts +4 -0
- package/runtime/types/shared/src/errors/base.d.ts +38 -0
- package/runtime/types/shared/src/errors/common.d.ts +39 -0
- package/runtime/types/shared/src/errors/index.d.ts +13 -0
- package/runtime/types/shared/src/errors/k8s.d.ts +4 -0
- package/runtime/types/shared/src/errors/message.d.ts +48 -0
- package/runtime/types/shared/src/errors/open-search.d.ts +4 -0
- package/runtime/types/shared/src/errors/s3.d.ts +11 -0
- package/runtime/types/shared/src/extensions/zod.d.ts +25 -0
- package/runtime/types/shared/src/scheme/account/dto.d.ts +60 -0
- package/runtime/types/shared/src/scheme/account/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/ai-agent-tools/dto.d.ts +69 -0
- package/runtime/types/shared/src/scheme/ai-agent-tools/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/ai-agent-tools/parameters.d.ts +7 -0
- package/runtime/types/shared/src/scheme/ai-router/dto.d.ts +23 -0
- package/runtime/types/shared/src/scheme/ai-router/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/api-keys/dto.d.ts +28 -0
- package/runtime/types/shared/src/scheme/api-keys/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/app/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/app/java.dto.d.ts +6 -0
- package/runtime/types/shared/src/scheme/billing/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/billing/java.dto.d.ts +163 -0
- package/runtime/types/shared/src/scheme/crm/billing.d.ts +149 -0
- package/runtime/types/shared/src/scheme/crm/dto.d.ts +212 -0
- package/runtime/types/shared/src/scheme/crm/index.d.ts +3 -0
- package/runtime/types/shared/src/scheme/data-types/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/data-types/java.dto.d.ts +23 -0
- package/runtime/types/shared/src/scheme/dynamic-forms/dto.d.ts +30 -0
- package/runtime/types/shared/src/scheme/dynamic-forms/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/extensions/index.d.ts +1 -0
- package/runtime/types/shared/src/scheme/extensions/params-to-zod.d.ts +14 -0
- package/runtime/types/shared/src/scheme/flowrunner/custom-elements.d.ts +368 -0
- package/runtime/types/shared/src/scheme/flowrunner/index.d.ts +3 -0
- package/runtime/types/shared/src/scheme/flowrunner/java.dto.d.ts +628 -0
- package/runtime/types/shared/src/scheme/index.d.ts +19 -0
- package/runtime/types/shared/src/scheme/integration-connection/dto.d.ts +81 -0
- package/runtime/types/shared/src/scheme/integration-connection/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/knowledge-base/dto.d.ts +540 -0
- package/runtime/types/shared/src/scheme/knowledge-base/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/mcp-oauth/dto.d.ts +7 -0
- package/runtime/types/shared/src/scheme/mcp-oauth/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/notifications/dto.d.ts +111 -0
- package/runtime/types/shared/src/scheme/notifications/index.d.ts +3 -0
- package/runtime/types/shared/src/scheme/notifications/rest.d.ts +148 -0
- package/runtime/types/shared/src/scheme/properties/account.d.ts +3 -0
- package/runtime/types/shared/src/scheme/properties/app.d.ts +5 -0
- package/runtime/types/shared/src/scheme/properties/billing.d.ts +12 -0
- package/runtime/types/shared/src/scheme/properties/common.d.ts +2 -0
- package/runtime/types/shared/src/scheme/properties/db.d.ts +8 -0
- package/runtime/types/shared/src/scheme/properties/flow-extensions.d.ts +7 -0
- package/runtime/types/shared/src/scheme/properties/index.d.ts +7 -0
- package/runtime/types/shared/src/scheme/remote-mcp-server/dto.d.ts +278 -0
- package/runtime/types/shared/src/scheme/remote-mcp-server/index.d.ts +2 -0
- package/runtime/types/shared/src/scheme/shared-extensions/base.d.ts +56 -0
- package/runtime/types/shared/src/scheme/shared-extensions/config.d.ts +96 -0
- package/runtime/types/shared/src/scheme/shared-extensions/custom-extensions.d.ts +485 -0
- package/runtime/types/shared/src/scheme/shared-extensions/extension.d.ts +387 -0
- package/runtime/types/shared/src/scheme/shared-extensions/flow-extensions.d.ts +64 -0
- package/runtime/types/shared/src/scheme/shared-extensions/index.d.ts +15 -0
- package/runtime/types/shared/src/scheme/shared-extensions/light.d.ts +38 -0
- package/runtime/types/shared/src/scheme/shared-extensions/logs.d.ts +21 -0
- package/runtime/types/shared/src/scheme/shared-extensions/methods.d.ts +80 -0
- package/runtime/types/shared/src/scheme/shared-extensions/params-schema.d.ts +47 -0
- package/runtime/types/shared/src/scheme/shared-extensions/popular-pool.d.ts +11 -0
- package/runtime/types/shared/src/scheme/shared-extensions/resolve.d.ts +364 -0
- package/runtime/types/shared/src/scheme/shared-extensions/rest.d.ts +9 -0
- package/runtime/types/shared/src/scheme/shared-extensions/search.d.ts +177 -0
- package/runtime/types/shared/src/scheme/shared-extensions/service-identity.d.ts +10 -0
- package/runtime/types/shared/src/scheme/shared-extensions/service-info.d.ts +15 -0
- package/runtime/types/shared/src/scheme/workspace/dto.d.ts +40 -0
- package/runtime/types/shared/src/scheme/workspace/index.d.ts +1 -0
- package/runtime/types/shared/src/utils/object.d.ts +8 -0
- package/runtime/types/shared/src/utils/uuid.d.ts +5 -0
- package/runtime/types/shared/src/utils/versions.d.ts +4 -0
- package/runtime/types/types/backendless-request.d.ts +40 -0
- package/templates/blank/files/README.md +28 -0
- package/templates/blank/files/package.json +8 -0
- package/templates/blank/files/public/icon.svg +5 -0
- package/templates/blank/files/src/index.js +130 -0
- package/templates/blank/template.json +61 -0
- package/templates/demo-todo-list/files/README.md +54 -0
- package/templates/demo-todo-list/files/package.json +8 -0
- package/templates/demo-todo-list/files/public/icon.svg +8 -0
- package/templates/demo-todo-list/files/src/index.js +590 -0
- package/templates/demo-todo-list/template.json +44 -0
- package/templates/qa-test/files/README.md +88 -0
- package/templates/qa-test/files/package.json +8 -0
- package/templates/qa-test/files/public/icon.svg +8 -0
- package/templates/qa-test/files/src/index.js +755 -0
- package/templates/qa-test/template.json +62 -0
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A real Files API for tests, injected through `createFiles` — the host seam, not a patched client.
|
|
5
|
+
*
|
|
6
|
+
* `runServiceMethod({ createFiles })` replaces the file client for one invocation, on both formats —
|
|
7
|
+
* `ctx.files` in v2, `this.flowrunner.Files` in v1 (needs `flowrunner-cli` 0.0.1-dev.27 or newer; v1
|
|
8
|
+
* ignored the option before that). The factory is handed the file-service context (`{ serverURL,
|
|
9
|
+
* appId, apiKey, runtimeKey, flowId, executionId, retrieveNewS3Token }`) and returns anything
|
|
10
|
+
* satisfying **`FilesApi`** — the five methods `uploadFile` / `list` / `get` / `delete` / `usage`. The
|
|
11
|
+
* service is unaffected and unaware: it still calls `uploadFile(...)` and reads a `url` off the
|
|
12
|
+
* result, and no HTTP leaves the process.
|
|
13
|
+
*
|
|
14
|
+
* const filesAPI = createFilesSandbox()
|
|
15
|
+
*
|
|
16
|
+
* function runMethod({ methodName, methodData, data }) {
|
|
17
|
+
* return runServiceMethod({
|
|
18
|
+
* serviceId, serviceEntryPointPath, configs,
|
|
19
|
+
* createFiles: filesAPI.inMemory,
|
|
20
|
+
* ...data, methodName, methodData,
|
|
21
|
+
* })
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* afterEach(() => filesAPI.reset())
|
|
25
|
+
*
|
|
26
|
+
* ── `inMemory` is the backend you want ──
|
|
27
|
+
* Almost every service moves bytes one way — fetch from the vendor, save, return the URL to the
|
|
28
|
+
* FLOW — so the URL is an output nobody else fetches, and local storage behind a `file://` URL is the
|
|
29
|
+
* whole requirement.
|
|
30
|
+
*
|
|
31
|
+
* | factory | bytes land in | the URL it hands back | needed when |
|
|
32
|
+
* |---|---|---|---|
|
|
33
|
+
* | `inMemory` | a per-sandbox temp dir | `file://…` — local, real, unreachable off-box | always, today |
|
|
34
|
+
* | `s3Server` | the injected `objectStore` | a pre-signed `https://…` | a service hands a file it just saved BACK to a vendor to fetch |
|
|
35
|
+
*
|
|
36
|
+
* They are the same implementation over different blob storage, so switching is one word. `s3Server`
|
|
37
|
+
* has no store wired in, so it throws if asked for one without an `objectStore`. It exists because
|
|
38
|
+
* the day a service does need a fetchable URL, the layers, keys and result shapes should not have to
|
|
39
|
+
* be written again.
|
|
40
|
+
*
|
|
41
|
+
* ── What this buys over stubbing the file service's HTTP ──
|
|
42
|
+
* Storage is real, so the assertions are about outcomes rather than requests: a service that saves
|
|
43
|
+
* under one name and returns another no longer passes, `overwrite` and layer isolation behave, the
|
|
44
|
+
* result carries the documented `{ key, size, urlExpiresAt, overwritten, … }`, and `calls()` records
|
|
45
|
+
* the options object the service actually built — which is where an inverted option spread shows up
|
|
46
|
+
* as a `filename` the caller never chose.
|
|
47
|
+
*
|
|
48
|
+
* ── The three storage layers ──
|
|
49
|
+
* A file belongs to exactly one layer, named by `scope` and keyed the way the console keys it:
|
|
50
|
+
*
|
|
51
|
+
* WORKSPACE workspace/<filename>
|
|
52
|
+
* FLOW (default) flow/<flowId>/<filename>
|
|
53
|
+
* EXECUTION flow/<flowId>/execution/<executionId>/<filename>
|
|
54
|
+
*
|
|
55
|
+
* The execution prefix nests INSIDE the flow prefix, so `list` matches one level only — the S3
|
|
56
|
+
* delimiter behaviour. Listing recursively would leak a run's files into its flow. `FLOW` and
|
|
57
|
+
* `EXECUTION` need their ids present in the invocation, and reject with the runtime's own messages
|
|
58
|
+
* when they are not.
|
|
59
|
+
*
|
|
60
|
+
* ── Limits, on purpose ──
|
|
61
|
+
* - **The clock is frozen** at `FIXED_NOW`, so `createdAt` / `urlExpiresAt` / `objectExpiresAt` are
|
|
62
|
+
* byte-stable and a whole-object `toEqual` on a result is possible at all.
|
|
63
|
+
* - **`ttl` and `objectTtl` are recorded and reported, never enforced.** Nothing expires mid-suite.
|
|
64
|
+
* - **Quota is a number to divide by**, not a limit: an upload past `quotaBytes` still succeeds. Use
|
|
65
|
+
* `failNext(...)` for the over-quota branch.
|
|
66
|
+
* - **The temp dir is per sandbox instance** (`<project>/temp/files-sandbox/<uuid>`), because jest runs
|
|
67
|
+
* test files in parallel workers. `reset()` empties it, `dispose()` removes it.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
const crypto = require('crypto')
|
|
71
|
+
const fs = require('fs')
|
|
72
|
+
const path = require('path')
|
|
73
|
+
|
|
74
|
+
const { EXECUTION_CONTEXT_DEFAULTS } = require('./service')
|
|
75
|
+
|
|
76
|
+
/** The layers a file can live in. `FLOW` is the client's default when a call names no scope. */
|
|
77
|
+
const SCOPES = ['WORKSPACE', 'FLOW', 'EXECUTION']
|
|
78
|
+
|
|
79
|
+
/** Frozen clock. Every timestamp any backend reports is derived from it. */
|
|
80
|
+
const FIXED_NOW = '2026-01-01T00:00:00.000Z'
|
|
81
|
+
|
|
82
|
+
/** Applied when a call asks for a URL without naming a `ttl`, so the expiry is never null. */
|
|
83
|
+
const DEFAULT_URL_TTL_SECONDS = 3600
|
|
84
|
+
|
|
85
|
+
/** `usage()` reports against this unless the sandbox names another. 1 GiB. */
|
|
86
|
+
const DEFAULT_QUOTA_BYTES = 1073741824
|
|
87
|
+
|
|
88
|
+
const DEFAULT_WORKSPACE_ID = 'test-workspace-id'
|
|
89
|
+
|
|
90
|
+
/** Where `inMemory` keeps its bytes. Gitignored; one subdirectory per sandbox instance. */
|
|
91
|
+
const TEMP_ROOT = path.join(__dirname, '..', 'temp', 'files-sandbox')
|
|
92
|
+
|
|
93
|
+
/** The inspection helpers every backend carries, forwarded by the sandbox that owns it. */
|
|
94
|
+
const INSPECTION = ['keyFor', 'urlFor', 'stored', 'keys', 'read', 'contents', 'calls', 'seed', 'failNext']
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The key prefix of one layer, and the ids it requires — the runtime's `collectionPathByScope`, with
|
|
98
|
+
* its error messages, so a suite that forgets to supply a flow sees what production would say.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} scope
|
|
101
|
+
* @param {{ flowId: ?string, executionId: ?string }} ids
|
|
102
|
+
* @returns {string} e.g. `flow/flow-1/execution/exec-1`
|
|
103
|
+
*/
|
|
104
|
+
function prefixForScope(scope, ids) {
|
|
105
|
+
if (scope === 'WORKSPACE') {
|
|
106
|
+
return 'workspace'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (scope === 'FLOW') {
|
|
110
|
+
if (!ids.flowId) {
|
|
111
|
+
throw new Error('Flow scope requires flowId')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return `flow/${ ids.flowId }`
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (scope === 'EXECUTION') {
|
|
118
|
+
if (!ids.flowId || !ids.executionId) {
|
|
119
|
+
throw new Error('Execution scope requires flowId and executionId')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return `flow/${ ids.flowId }/execution/${ ids.executionId }`
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
throw new Error(`Unknown file scope "${ scope }". The scopes are ${ SCOPES.join(', ') }.`)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** `1536` → `'1.5 KB'`. The sandbox's own formatting; the console's exact wording is not contractual. */
|
|
129
|
+
function formatBytes(bytes) {
|
|
130
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
|
131
|
+
let value = bytes
|
|
132
|
+
let unit = 0
|
|
133
|
+
|
|
134
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
135
|
+
value /= 1024
|
|
136
|
+
unit += 1
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return `${ Math.round(value * 100) / 100 } ${ units[unit] }`
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** `FIXED_NOW` plus `seconds`, or null when there is no TTL to add. */
|
|
143
|
+
function expiryFor(seconds) {
|
|
144
|
+
return seconds === undefined || seconds === null
|
|
145
|
+
? null
|
|
146
|
+
: new Date(Date.parse(FIXED_NOW) + Number(seconds) * 1000).toISOString()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The error a Files call rejects with, shaped like the `ResponseError` the real client produces:
|
|
151
|
+
* `message` is the body's own `message` when it has one and the whole BODY otherwise, which is
|
|
152
|
+
* exactly the assumption the `error-message-not-a-string` defect class gets wrong.
|
|
153
|
+
*
|
|
154
|
+
* @param {*} body @param {number} status
|
|
155
|
+
*/
|
|
156
|
+
function filesError(body, status) {
|
|
157
|
+
const message = body && typeof body === 'object' && body.message !== undefined ? body.message : body
|
|
158
|
+
|
|
159
|
+
return Object.assign(new Error(), { name: 'ResponseError', message, status, body })
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Blob storage on the local filesystem, under one directory.
|
|
164
|
+
*
|
|
165
|
+
* Every path segment is encoded, so a filename carrying a `/` or a `?` stays one file rather than
|
|
166
|
+
* becoming a directory — the logical key is what `list` pages over, never the path on disk.
|
|
167
|
+
*/
|
|
168
|
+
function createDiskBlobs(dir) {
|
|
169
|
+
const pathFor = key => path.join(dir, ...key.split('/').map(encodeURIComponent))
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
dir,
|
|
173
|
+
|
|
174
|
+
write(key, bytes) {
|
|
175
|
+
const file = pathFor(key)
|
|
176
|
+
|
|
177
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
178
|
+
fs.writeFileSync(file, bytes)
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
read(key) {
|
|
182
|
+
const file = pathFor(key)
|
|
183
|
+
|
|
184
|
+
return fs.existsSync(file) ? fs.readFileSync(file) : undefined
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
remove(key) {
|
|
188
|
+
fs.rmSync(pathFor(key), { force: true })
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
clear() {
|
|
192
|
+
fs.rmSync(dir, { recursive: true, force: true })
|
|
193
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
destroy() {
|
|
197
|
+
fs.rmSync(dir, { recursive: true, force: true })
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
pathFor,
|
|
201
|
+
|
|
202
|
+
/** A `file://` URL of the real file. Resolvable here, and deliberately not off this machine. */
|
|
203
|
+
urlFor(key) {
|
|
204
|
+
return `file://${ pathFor(key) }`
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Blob storage in an object store that can hand out public URLs.
|
|
211
|
+
*
|
|
212
|
+
* `objectStore` is the only thing a real test S3 (MinIO, a scratch bucket) has to supply:
|
|
213
|
+
*
|
|
214
|
+
* { put(key, bytes), read(key), remove(key), clear(), publicUrl(key, { ttl }) }
|
|
215
|
+
*
|
|
216
|
+
* Everything above it — layers, keys, paging, result shapes — is shared with `inMemory`.
|
|
217
|
+
*/
|
|
218
|
+
function createObjectStoreBlobs(objectStore) {
|
|
219
|
+
const required = ['put', 'read', 'remove', 'clear', 'publicUrl']
|
|
220
|
+
const missing = required.filter(method => typeof (objectStore || {})[method] !== 'function')
|
|
221
|
+
|
|
222
|
+
if (missing.length) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
`createFilesSandbox({ objectStore }) is missing ${ missing.join(', ') }. ` +
|
|
225
|
+
'The S3-backed Files API needs an object store to talk to, and none is wired in. ' +
|
|
226
|
+
'Pass one implementing ' +
|
|
227
|
+
'{ put(key, bytes), read(key), remove(key), clear(), publicUrl(key, { ttl }) }, or use the ' +
|
|
228
|
+
'`inMemory` backend, which stores locally and hands back a file:// URL.'
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
dir: null,
|
|
234
|
+
write: (key, bytes) => objectStore.put(key, bytes),
|
|
235
|
+
read: key => objectStore.read(key),
|
|
236
|
+
remove: key => objectStore.remove(key),
|
|
237
|
+
clear: () => objectStore.clear(),
|
|
238
|
+
destroy: () => objectStore.clear(),
|
|
239
|
+
pathFor: key => key,
|
|
240
|
+
urlFor: (key, ttl) => objectStore.publicUrl(key, { ttl }),
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The `FilesApi` itself: five methods over a blob store and an index, for ONE invocation.
|
|
246
|
+
*
|
|
247
|
+
* The index is the sandbox's own record — insertion-ordered, so `list` is stable — and holds the
|
|
248
|
+
* metadata each upload carried. Blobs hold the bytes. They are separate because the two backends
|
|
249
|
+
* differ only in the second.
|
|
250
|
+
*/
|
|
251
|
+
function createFilesApiFor({ blobs, index, calls, failures, quotaBytes, workspaceId }, filesOptions) {
|
|
252
|
+
const ids = { flowId: filesOptions.flowId, executionId: filesOptions.executionId }
|
|
253
|
+
|
|
254
|
+
const keyFor = (scope, filename) => `${ prefixForScope(scope, ids) }/${ filename }`
|
|
255
|
+
|
|
256
|
+
/** Every method starts here: an armed failure takes precedence over doing the work. */
|
|
257
|
+
function checkFailure() {
|
|
258
|
+
if (failures.length) {
|
|
259
|
+
throw failures.shift()
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function record(method, entry) {
|
|
264
|
+
calls.push({ method, ...entry })
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async function urlPartsFor(key, { ttl, generateUrl }) {
|
|
268
|
+
if (generateUrl === false) {
|
|
269
|
+
// No URL was asked for, so there is no expiry either.
|
|
270
|
+
return { url: null, urlExpiresAt: null }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const lifetime = ttl === undefined ? DEFAULT_URL_TTL_SECONDS : ttl
|
|
274
|
+
|
|
275
|
+
return { url: await blobs.urlFor(key, lifetime), urlExpiresAt: expiryFor(lifetime) }
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function fileInfoFor(entry, options) {
|
|
279
|
+
return {
|
|
280
|
+
key: entry.key,
|
|
281
|
+
filename: entry.filename,
|
|
282
|
+
...await urlPartsFor(entry.key, options),
|
|
283
|
+
size: entry.size,
|
|
284
|
+
createdAt: FIXED_NOW,
|
|
285
|
+
objectExpiresAt: expiryFor(entry.objectTtl),
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
async uploadFile(file, options = {}) {
|
|
291
|
+
checkFailure()
|
|
292
|
+
|
|
293
|
+
const scope = options.scope || 'FLOW'
|
|
294
|
+
const filename = options.filename || 'file'
|
|
295
|
+
const bytes = Buffer.isBuffer(file) ? file : Buffer.from(file || [])
|
|
296
|
+
const key = keyFor(scope, filename)
|
|
297
|
+
const existing = index.get(key)
|
|
298
|
+
|
|
299
|
+
// `options` is recorded as the service built it, not as it was resolved — that is what makes an
|
|
300
|
+
// inverted option spread visible: the `filename` here is the one that won.
|
|
301
|
+
record('uploadFile', { scope, filename, size: bytes.length, options })
|
|
302
|
+
|
|
303
|
+
if (existing && !options.overwrite) {
|
|
304
|
+
throw filesError({ error: { message: `File "${ filename }" already exists in ${ scope } storage` } }, 409)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
await blobs.write(key, bytes)
|
|
308
|
+
|
|
309
|
+
index.set(key, {
|
|
310
|
+
key,
|
|
311
|
+
scope,
|
|
312
|
+
filename,
|
|
313
|
+
size: bytes.length,
|
|
314
|
+
ttl: options.ttl,
|
|
315
|
+
objectTtl: options.objectTtl,
|
|
316
|
+
generateUrl: options.generateUrl === undefined ? true : options.generateUrl,
|
|
317
|
+
overwrite: !!options.overwrite,
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
return {
|
|
321
|
+
key,
|
|
322
|
+
filename,
|
|
323
|
+
...await urlPartsFor(key, options),
|
|
324
|
+
size: bytes.length,
|
|
325
|
+
objectExpiresAt: expiryFor(options.objectTtl),
|
|
326
|
+
overwritten: !!existing,
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
async list(options = {}) {
|
|
331
|
+
checkFailure()
|
|
332
|
+
|
|
333
|
+
const scope = options.scope || 'FLOW'
|
|
334
|
+
const prefix = `${ prefixForScope(scope, ids) }/`
|
|
335
|
+
|
|
336
|
+
record('list', { scope, options })
|
|
337
|
+
|
|
338
|
+
// One level only: the execution prefix nests inside the flow prefix, and a layer lists its OWN
|
|
339
|
+
// files — what S3 does with a delimiter.
|
|
340
|
+
const all = [...index.values()]
|
|
341
|
+
.filter(entry => entry.key.startsWith(prefix) && !entry.key.slice(prefix.length).includes('/'))
|
|
342
|
+
|
|
343
|
+
const from = options.cursor === undefined ? 0 : Number(options.cursor)
|
|
344
|
+
const page = options.limit === undefined ? all.slice(from) : all.slice(from, from + Number(options.limit))
|
|
345
|
+
const next = from + page.length
|
|
346
|
+
|
|
347
|
+
return {
|
|
348
|
+
files: await Promise.all(page.map(entry => fileInfoFor(entry, options))),
|
|
349
|
+
// An offset, and only its opacity is contractual: page with the cursor you were handed.
|
|
350
|
+
cursor: next < all.length ? String(next) : null,
|
|
351
|
+
hasMore: next < all.length,
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
async get(filename, options = {}) {
|
|
356
|
+
checkFailure()
|
|
357
|
+
|
|
358
|
+
const scope = options.scope || 'FLOW'
|
|
359
|
+
const entry = index.get(keyFor(scope, filename))
|
|
360
|
+
|
|
361
|
+
record('get', { scope, filename, options })
|
|
362
|
+
|
|
363
|
+
if (!entry) {
|
|
364
|
+
throw filesError({ error: { message: `File "${ filename }" not found in ${ scope } storage` } }, 404)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return fileInfoFor(entry, options)
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
async delete(filename, options = {}) {
|
|
371
|
+
checkFailure()
|
|
372
|
+
|
|
373
|
+
const scope = options.scope || 'FLOW'
|
|
374
|
+
const key = keyFor(scope, filename)
|
|
375
|
+
const entry = index.get(key)
|
|
376
|
+
|
|
377
|
+
record('delete', { scope, filename, options })
|
|
378
|
+
|
|
379
|
+
if (!entry) {
|
|
380
|
+
throw filesError({ error: { message: `File "${ filename }" not found in ${ scope } storage` } }, 404)
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
await blobs.remove(key)
|
|
384
|
+
index.delete(key)
|
|
385
|
+
|
|
386
|
+
return { key, freedBytes: entry.size, deleted: true }
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
async usage() {
|
|
390
|
+
checkFailure()
|
|
391
|
+
record('usage', {})
|
|
392
|
+
|
|
393
|
+
// Always workspace-wide: the quota covers every layer, not just the one a call named.
|
|
394
|
+
const entries = [...index.values()]
|
|
395
|
+
const usedBytes = entries.reduce((total, entry) => total + entry.size, 0)
|
|
396
|
+
|
|
397
|
+
return {
|
|
398
|
+
workspaceId,
|
|
399
|
+
usedBytes,
|
|
400
|
+
quotaBytes,
|
|
401
|
+
usedFormatted: formatBytes(usedBytes),
|
|
402
|
+
quotaFormatted: formatBytes(quotaBytes),
|
|
403
|
+
utilizationPercent: quotaBytes ? Math.round((usedBytes / quotaBytes) * 10000) / 100 : 0,
|
|
404
|
+
fileCount: entries.length,
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Builds one backend: a `createFiles` factory carrying its own inspection helpers.
|
|
412
|
+
*
|
|
413
|
+
* The factory is a FUNCTION, so it can be handed straight to
|
|
414
|
+
* `runServiceMethod({ createFiles: filesAPI.inMemory })`, with `stored()` / `keys()` / `seed()` and
|
|
415
|
+
* the rest hanging off it.
|
|
416
|
+
*/
|
|
417
|
+
function createBackend({ blobs, defaults, quotaBytes, workspaceId }) {
|
|
418
|
+
/** Logical key → what the upload carried. Insertion-ordered, which is what makes `list` stable. */
|
|
419
|
+
const index = new Map()
|
|
420
|
+
const calls = []
|
|
421
|
+
const failures = []
|
|
422
|
+
|
|
423
|
+
const keyFor = (scope, filename, ids = defaults) => `${ prefixForScope(scope, ids) }/${ filename }`
|
|
424
|
+
|
|
425
|
+
/** The `createFiles` factory the runner calls, once per invocation. */
|
|
426
|
+
const factory = filesOptions => createFilesApiFor(
|
|
427
|
+
{ blobs, index, calls, failures, quotaBytes, workspaceId },
|
|
428
|
+
filesOptions || defaults
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
return Object.assign(factory, {
|
|
432
|
+
/** Where this backend's bytes are, or null for a store that is not on this filesystem. */
|
|
433
|
+
dir: blobs.dir,
|
|
434
|
+
|
|
435
|
+
keyFor,
|
|
436
|
+
|
|
437
|
+
/** The URL this backend hands a service for a stored key. */
|
|
438
|
+
urlFor: (key, ttl = DEFAULT_URL_TTL_SECONDS) => blobs.urlFor(key, ttl),
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* What is in storage, insertion-ordered: one flat record per file, with the options the upload
|
|
442
|
+
* carried and the bytes as text.
|
|
443
|
+
*/
|
|
444
|
+
stored() {
|
|
445
|
+
return [...index.values()].map(entry => ({
|
|
446
|
+
key: entry.key,
|
|
447
|
+
scope: entry.scope,
|
|
448
|
+
filename: entry.filename,
|
|
449
|
+
contents: (blobs.read(entry.key) || Buffer.alloc(0)).toString(),
|
|
450
|
+
size: entry.size,
|
|
451
|
+
ttl: entry.ttl,
|
|
452
|
+
objectTtl: entry.objectTtl,
|
|
453
|
+
generateUrl: entry.generateUrl,
|
|
454
|
+
overwrite: entry.overwrite,
|
|
455
|
+
}))
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
/** Just the keys, for a one-line "what landed where" assertion. */
|
|
459
|
+
keys() {
|
|
460
|
+
return [...index.keys()]
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
/** The stored bytes of one file, or undefined. Synchronous — the disk backend reads directly. */
|
|
464
|
+
read(scope, filename, ids) {
|
|
465
|
+
return blobs.read(keyFor(scope, filename, ids))
|
|
466
|
+
},
|
|
467
|
+
|
|
468
|
+
/** The stored bytes as text, which is what a fixture usually is. */
|
|
469
|
+
contents(scope, filename, ids) {
|
|
470
|
+
const bytes = blobs.read(keyFor(scope, filename, ids))
|
|
471
|
+
|
|
472
|
+
return bytes && bytes.toString()
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
/** Every Files call this backend served, in order — method, scope, filename and raw options. */
|
|
476
|
+
calls() {
|
|
477
|
+
return [...calls]
|
|
478
|
+
},
|
|
479
|
+
|
|
480
|
+
/** Puts a file in storage without a service call — for methods that read or delete one. */
|
|
481
|
+
seed(scope, filename, contents, meta = {}) {
|
|
482
|
+
const bytes = Buffer.isBuffer(contents) ? contents : Buffer.from(String(contents))
|
|
483
|
+
const key = keyFor(scope, filename, meta.ids)
|
|
484
|
+
|
|
485
|
+
blobs.write(key, bytes)
|
|
486
|
+
|
|
487
|
+
index.set(key, {
|
|
488
|
+
key,
|
|
489
|
+
scope,
|
|
490
|
+
filename,
|
|
491
|
+
size: bytes.length,
|
|
492
|
+
ttl: undefined,
|
|
493
|
+
objectTtl: undefined,
|
|
494
|
+
generateUrl: true,
|
|
495
|
+
overwrite: false,
|
|
496
|
+
...meta,
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
return factory
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Makes the next Files call reject instead of doing the work, leaving storage untouched.
|
|
504
|
+
*
|
|
505
|
+
* filesAPI.failNext({ error: { message: 'workspace storage quota exceeded' } }, 507)
|
|
506
|
+
*
|
|
507
|
+
* The rejection is shaped like the client's own `ResponseError` — `status`, `body`, and a
|
|
508
|
+
* `message` that is the body itself when the body has no `message` of its own.
|
|
509
|
+
*
|
|
510
|
+
* @param {*} body @param {number} [status]
|
|
511
|
+
*/
|
|
512
|
+
failNext(body, status = 500) {
|
|
513
|
+
failures.push(filesError(body, status))
|
|
514
|
+
|
|
515
|
+
return factory
|
|
516
|
+
},
|
|
517
|
+
|
|
518
|
+
/** Drops every stored file and every recorded call, and keeps the backend usable. */
|
|
519
|
+
reset() {
|
|
520
|
+
index.clear()
|
|
521
|
+
calls.length = 0
|
|
522
|
+
failures.length = 0
|
|
523
|
+
blobs.clear()
|
|
524
|
+
},
|
|
525
|
+
|
|
526
|
+
/** Reset, and remove the storage itself. */
|
|
527
|
+
dispose() {
|
|
528
|
+
index.clear()
|
|
529
|
+
calls.length = 0
|
|
530
|
+
failures.length = 0
|
|
531
|
+
blobs.destroy()
|
|
532
|
+
},
|
|
533
|
+
})
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* A `createFiles` factory storing bytes in a temp directory and handing back `file://` URLs.
|
|
538
|
+
*
|
|
539
|
+
* Reached as `createFilesSandbox().inMemory`; not exported on its own, because a suite always wants
|
|
540
|
+
* the sandbox's lifecycle with it.
|
|
541
|
+
*
|
|
542
|
+
* @param {object} [options] - `executionContext`, `quotaBytes`, `workspaceId`, `dir`.
|
|
543
|
+
*/
|
|
544
|
+
function createFilesAPI_inMemory(options = {}) {
|
|
545
|
+
const dir = options.dir || path.join(TEMP_ROOT, crypto.randomUUID())
|
|
546
|
+
|
|
547
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
548
|
+
|
|
549
|
+
return createBackend({
|
|
550
|
+
blobs: createDiskBlobs(dir),
|
|
551
|
+
defaults: { ...EXECUTION_CONTEXT_DEFAULTS, ...(options.executionContext || {}) },
|
|
552
|
+
quotaBytes: options.quotaBytes === undefined ? DEFAULT_QUOTA_BYTES : options.quotaBytes,
|
|
553
|
+
workspaceId: options.workspaceId || DEFAULT_WORKSPACE_ID,
|
|
554
|
+
})
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* A `createFiles` factory storing bytes in an object store that can hand out public URLs — the
|
|
559
|
+
* backend for a service whose file URL a third party has to fetch.
|
|
560
|
+
*
|
|
561
|
+
* Reached as `createFilesSandbox({ objectStore }).s3Server`. **No object store is wired in**, so it
|
|
562
|
+
* needs one and throws a message naming the five methods it wants if it does not get it. Everything
|
|
563
|
+
* else is shared with `inMemory`, so wiring MinIO or a scratch bucket is that adapter and nothing
|
|
564
|
+
* more.
|
|
565
|
+
*
|
|
566
|
+
* @param {object} options - `objectStore` (required), plus `executionContext`, `quotaBytes`,
|
|
567
|
+
* `workspaceId`.
|
|
568
|
+
*/
|
|
569
|
+
function createFilesAPI_S3Server(options = {}) {
|
|
570
|
+
return createBackend({
|
|
571
|
+
blobs: createObjectStoreBlobs(options.objectStore),
|
|
572
|
+
defaults: { ...EXECUTION_CONTEXT_DEFAULTS, ...(options.executionContext || {}) },
|
|
573
|
+
quotaBytes: options.quotaBytes === undefined ? DEFAULT_QUOTA_BYTES : options.quotaBytes,
|
|
574
|
+
workspaceId: options.workspaceId || DEFAULT_WORKSPACE_ID,
|
|
575
|
+
})
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Both backends plus one lifecycle, which is what a suite wants.
|
|
580
|
+
*
|
|
581
|
+
* const filesAPI = createFilesSandbox()
|
|
582
|
+
*
|
|
583
|
+
* runServiceMethod({ …, createFiles: filesAPI.inMemory })
|
|
584
|
+
* afterEach(() => filesAPI.reset())
|
|
585
|
+
* afterAll(() => filesAPI.dispose())
|
|
586
|
+
*
|
|
587
|
+
* `reset()` and `dispose()` cover every backend, so a suite needs one call either way. The inspection
|
|
588
|
+
* helpers on the sandbox itself (`stored`, `keys`, `contents`, `read`, `seed`, `calls`, `failNext`,
|
|
589
|
+
* `urlFor`, `keyFor`) forward to `inMemory`, the backend nearly every suite uses; reach for
|
|
590
|
+
* `filesAPI.s3Server.stored()` when a suite uses that one.
|
|
591
|
+
*
|
|
592
|
+
* `s3Server` is built on first use, so a sandbox with no `objectStore` is perfectly usable — the
|
|
593
|
+
* error arrives when something actually asks for the S3 backend.
|
|
594
|
+
*
|
|
595
|
+
* @param {object} [options] - `executionContext` (defaults matching `runServiceMethod`'s),
|
|
596
|
+
* `objectStore` (for `s3Server`), `quotaBytes`, `workspaceId`.
|
|
597
|
+
*/
|
|
598
|
+
function createFilesSandbox(options = {}) {
|
|
599
|
+
const inMemory = createFilesAPI_inMemory(options)
|
|
600
|
+
|
|
601
|
+
let s3 = null
|
|
602
|
+
|
|
603
|
+
const resolveS3 = () => {
|
|
604
|
+
if (!s3) {
|
|
605
|
+
s3 = createFilesAPI_S3Server(options)
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return s3
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
const s3Server = filesOptions => resolveS3()(filesOptions)
|
|
612
|
+
|
|
613
|
+
// The inspection surface of a backend that may not exist yet. Building it on access is what raises
|
|
614
|
+
// the "no object store" error where a suite asks for S3, rather than at construction.
|
|
615
|
+
for (const name of INSPECTION) {
|
|
616
|
+
s3Server[name] = (...args) => resolveS3()[name](...args)
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const sandbox = {
|
|
620
|
+
inMemory,
|
|
621
|
+
s3Server,
|
|
622
|
+
|
|
623
|
+
/** Empties every backend and forgets every recorded call. The `afterEach` one-liner. */
|
|
624
|
+
reset() {
|
|
625
|
+
inMemory.reset()
|
|
626
|
+
|
|
627
|
+
if (s3) {
|
|
628
|
+
s3.reset()
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
|
|
632
|
+
/** Reset, and remove the storage itself — the temp directory included. */
|
|
633
|
+
dispose() {
|
|
634
|
+
inMemory.dispose()
|
|
635
|
+
|
|
636
|
+
if (s3) {
|
|
637
|
+
s3.dispose()
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
for (const name of INSPECTION) {
|
|
644
|
+
sandbox[name] = (...args) => inMemory[name](...args)
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
return sandbox
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
module.exports = {
|
|
651
|
+
createFilesSandbox: createFilesSandbox,
|
|
652
|
+
FILES_FIXED_NOW: FIXED_NOW,
|
|
653
|
+
FILES_TEMP_ROOT: TEMP_ROOT,
|
|
654
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The test sandbox — everything a unit suite needs to drive a service the way the server does.
|
|
5
|
+
*
|
|
6
|
+
* These five exports are the entire surface a test file touches. There is no sandbox object to build,
|
|
7
|
+
* no `Flowrunner` global to install or clean up, and no service instance: `runServiceMethod` owns all
|
|
8
|
+
* of that, per call.
|
|
9
|
+
*
|
|
10
|
+
* | Export | For |
|
|
11
|
+
* |---|---|
|
|
12
|
+
* | `runServiceMethod(data)` | run one method exactly as the platform invokes it |
|
|
13
|
+
* | `createNockMock()` | intercept and record HTTP at the socket |
|
|
14
|
+
* | `createFilesSandbox()` | a real Files API, injected through `createFiles` |
|
|
15
|
+
* | `getServiceConfigItems(id, entryPoint)` | the published config descriptions |
|
|
16
|
+
* | `getServiceDefinition(id, entryPoint)` | the built service model — actions, triggers, dictionaries |
|
|
17
|
+
*
|
|
18
|
+
* These files are yours: `flowrunner init` copied them into the project and never touches them again.
|
|
19
|
+
* Adapt them when a service needs something they do not do.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const { createFilesSandbox } = require('./files-mock')
|
|
23
|
+
const { createNockMock } = require('./nock-mock')
|
|
24
|
+
const { getServiceConfigItems, getServiceDefinition, runServiceMethod } = require('./service')
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
runServiceMethod: runServiceMethod,
|
|
28
|
+
createNockMock: createNockMock,
|
|
29
|
+
createFilesSandbox: createFilesSandbox,
|
|
30
|
+
getServiceConfigItems: getServiceConfigItems,
|
|
31
|
+
getServiceDefinition: getServiceDefinition,
|
|
32
|
+
}
|