@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,600 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wire-level mock for `Flowrunner.Request`, backed by nock.
|
|
5
|
+
*
|
|
6
|
+
* Services get the REAL `Flowrunner.Request` from `flowrunner-cli/runtime`, so the only place left
|
|
7
|
+
* to intercept is the HTTP layer — which is what nock does. Every recorded field below is therefore
|
|
8
|
+
* read off the wire; nothing here knows about the Request chain.
|
|
9
|
+
*
|
|
10
|
+
* Setup responses:
|
|
11
|
+
* mock.onGet('https://api.example.com/items').reply({ items: [] })
|
|
12
|
+
* mock.onPost('https://api.example.com/items').reply({ id: '123' })
|
|
13
|
+
* mock.onPost('https://api.example.com/items').reply({ error: 'nope' }, 422)
|
|
14
|
+
* mock.onPut('https://api.example.com/items/1').replyWith(call => ({ echoed: call.body }))
|
|
15
|
+
* mock.onDelete('https://api.example.com/items/1').replyWithError({ code: 1 }, 409)
|
|
16
|
+
* mock.onGet('https://api.example.com/items').replyWithNetworkError('ECONNRESET')
|
|
17
|
+
* mock.on('propfind', 'https://dav.example.com/dir').reply('<xml/>')
|
|
18
|
+
*
|
|
19
|
+
* `onAny(url)` / `onAny()` also exist and are BANNED in new suites: every method under test calls a
|
|
20
|
+
* known URL, so a catch-all only hides a wrong one.
|
|
21
|
+
*
|
|
22
|
+
* Inspect calls:
|
|
23
|
+
* mock.history // [{ method, url, canonicalUrl, fullUrl, headers, query, body, formData,
|
|
24
|
+
* // contentType, contentLength, timeout }]
|
|
25
|
+
*
|
|
26
|
+
* ── Lifecycle ──
|
|
27
|
+
* `createNockMock()` in `beforeAll`, `dispose()` in `afterAll` — the second half is not optional.
|
|
28
|
+
* nock patches the shared `http` module when it activates, and jest gives every test file its own
|
|
29
|
+
* module registry (so its own copy of nock) but ONE `http`. A suite that never disposes leaves its
|
|
30
|
+
* activation stacked on `http` for the rest of the worker, and the layers corrupt each other:
|
|
31
|
+
* request bodies that silently vanish, wrappers left pointing into a torn-down realm throwing
|
|
32
|
+
* `Cannot convert undefined or null to object` with an empty stack. That is why suites pass alone
|
|
33
|
+
* and fail in a full run. `dispose()` calls `nock.restore()` once the last mock is gone, which
|
|
34
|
+
* leaves `http` exactly as it was found.
|
|
35
|
+
*
|
|
36
|
+
* ── What the wire flattens ──
|
|
37
|
+
* - `query` values are re-typed by shape (see `parseQuery`), because a query string carries no
|
|
38
|
+
* types. `{ limit: 100 }` survives the round trip; a string that looks like a number does not.
|
|
39
|
+
* - `headers` keys are re-cased by `normalizeHeaders`, because Node's http client lowercases
|
|
40
|
+
* them. `X-Token` survives the round trip; `X-API-KEY` comes back as `X-Api-Key`.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const http = require('http')
|
|
44
|
+
const nock = require('nock')
|
|
45
|
+
const queryString = require('query-string')
|
|
46
|
+
|
|
47
|
+
/** Live mocks for THIS test file, oldest first. The newest one with a matching handler wins. */
|
|
48
|
+
const liveMocks = []
|
|
49
|
+
|
|
50
|
+
/** Methods that currently have a catch-all interceptor registered. */
|
|
51
|
+
const interceptedMethods = new Set()
|
|
52
|
+
|
|
53
|
+
/** Catch-alls installed up front; anything else is installed on demand by `on(method, url)`. */
|
|
54
|
+
const STANDARD_METHODS = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options']
|
|
55
|
+
|
|
56
|
+
const DEFAULT_PORTS = { 'http:': '80', 'https:': '443' }
|
|
57
|
+
|
|
58
|
+
/** Status `replyWithError` uses when a test does not name one. */
|
|
59
|
+
const DEFAULT_ERROR_STATUS = 400
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Carries `req.setTimeout(ms)` through to the recorded call. The value never reaches the socket and
|
|
63
|
+
* nock does not hand the reply callback the ClientRequest the caller saw, so a header is the only
|
|
64
|
+
* way it survives. Stripped from the recorded headers again by `normalizeHeaders`.
|
|
65
|
+
*/
|
|
66
|
+
const TIMEOUT_HEADER = 'x-flowrunner-sandbox-timeout'
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Headers Node's http client and `backendless-request` add on the way out. The service never set
|
|
70
|
+
* them, so recording them would make every whole-object `toEqual` on `headers` fail.
|
|
71
|
+
*/
|
|
72
|
+
const TRANSPORT_HEADERS = new Set([
|
|
73
|
+
'connection',
|
|
74
|
+
'content-length',
|
|
75
|
+
'host',
|
|
76
|
+
'transfer-encoding',
|
|
77
|
+
])
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Records `req.setTimeout(ms)` on the request as a header, so `buildRecord` can read it back.
|
|
81
|
+
*
|
|
82
|
+
* The value never reaches the socket, so the wire cannot show it. Patched on the PROTOTYPE, once,
|
|
83
|
+
* and never removed: the replacement closes over nothing but the original core function and a
|
|
84
|
+
* string constant, so — unlike a wrapper closing over module state — it stays valid after the realm
|
|
85
|
+
* that installed it is torn down.
|
|
86
|
+
*
|
|
87
|
+
* It has to be Node's REAL `ClientRequest` prototype. Requiring nock replaces `http.ClientRequest`
|
|
88
|
+
* with a subclass of it, while the requests nock hands out are still instances of the real class,
|
|
89
|
+
* so a patch applied to `http.ClientRequest.prototype` after nock loads never runs.
|
|
90
|
+
*/
|
|
91
|
+
const clientRequestProto = Object.getPrototypeOf(http.ClientRequest.prototype) === http.OutgoingMessage.prototype
|
|
92
|
+
? http.ClientRequest.prototype
|
|
93
|
+
: Object.getPrototypeOf(http.ClientRequest.prototype)
|
|
94
|
+
|
|
95
|
+
const originalSetTimeout = clientRequestProto.setTimeout
|
|
96
|
+
|
|
97
|
+
function recordTimeout(ms, handler) {
|
|
98
|
+
// Recorded only while a mock is live, so a request made outside one never carries the marker. The
|
|
99
|
+
// flag lives on the shared `http` module, NOT in a module variable: jest gives each
|
|
100
|
+
// test file its own realm but one `http`, so whichever realm installs this patch first owns the
|
|
101
|
+
// closure for the whole worker and must not read that realm's own state.
|
|
102
|
+
if (http.__flowrunnerSandboxMocking && !this.headersSent) {
|
|
103
|
+
try {
|
|
104
|
+
this.setHeader(TIMEOUT_HEADER, String(ms))
|
|
105
|
+
} catch (ignored) {
|
|
106
|
+
// Headers already flushed — the timeout simply goes unrecorded.
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return originalSetTimeout.call(this, ms, handler)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
recordTimeout.__flowrunnerSandbox = true
|
|
114
|
+
|
|
115
|
+
if (!clientRequestProto.setTimeout.__flowrunnerSandbox) {
|
|
116
|
+
clientRequestProto.setTimeout = recordTimeout
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Reduces a URL to the two forms a handler can be matched against: without its query string and
|
|
121
|
+
* with it. Default ports are dropped so `https://x.test:443/a` and `https://x.test/a` are one URL.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} urlString
|
|
124
|
+
* @returns {{ base: string, full: string, search: string }|null} null when the input is not a URL.
|
|
125
|
+
*/
|
|
126
|
+
function canonicalize(urlString) {
|
|
127
|
+
let url
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
url = new URL(urlString)
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return null
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const port = url.port && url.port !== DEFAULT_PORTS[url.protocol] ? `:${ url.port }` : ''
|
|
136
|
+
const base = `${ url.protocol }//${ url.hostname }${ port }${ url.pathname }`
|
|
137
|
+
|
|
138
|
+
return { base, full: base + url.search, search: url.search }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {string|RegExp|undefined} handlerUrl - undefined matches every URL.
|
|
143
|
+
* @param {{ url: string, canonicalUrl: string, fullUrl: string }} record
|
|
144
|
+
*/
|
|
145
|
+
function urlMatches(handlerUrl, record) {
|
|
146
|
+
if (handlerUrl === undefined || handlerUrl === null) {
|
|
147
|
+
return true
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (handlerUrl instanceof RegExp) {
|
|
151
|
+
return handlerUrl.test(record.fullUrl) || handlerUrl.test(record.canonicalUrl)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const handler = canonicalize(handlerUrl)
|
|
155
|
+
|
|
156
|
+
if (!handler) {
|
|
157
|
+
return handlerUrl === record.url || handlerUrl === record.fullUrl
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// A handler registered WITH a query string only matches that exact query; one registered without
|
|
161
|
+
// matches whatever query the service ended up adding via `.query()`.
|
|
162
|
+
return handler.search ? handler.full === record.fullUrl : handler.base === record.canonicalUrl
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Turns a query string into the `{ name: value }` shape tests assert against.
|
|
167
|
+
*
|
|
168
|
+
* A query string is untyped, so `parseNumbers`/`parseBooleans` put back the JS types the service
|
|
169
|
+
* passed to `.query()` — `?limit=100&flag=true` reads as `{ limit: 100, flag: true }`. The inference
|
|
170
|
+
* is by shape, not by intent, so a value that only LOOKS numeric or boolean comes back coerced: an
|
|
171
|
+
* id sent as the string `'123'` reads as `123`, and a zero-padded `'007'` reads as `7`. Assert those
|
|
172
|
+
* with the coerced value.
|
|
173
|
+
*
|
|
174
|
+
* A parameter repeated in the query becomes an array (`arrayFormat: 'none'`, the default).
|
|
175
|
+
*/
|
|
176
|
+
function parseQuery(search) {
|
|
177
|
+
// Spread into a plain object: query-string returns a null-prototype one, which reads the same
|
|
178
|
+
// under `toEqual` but not under `toStrictEqual`.
|
|
179
|
+
return { ...queryString.parse(search, { parseNumbers: true, parseBooleans: true }) }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Rebuilds the header object a service actually set, out of what came off the wire.
|
|
184
|
+
*
|
|
185
|
+
* Two things happen to headers between `.set()` and the socket: `backendless-request` lowercases
|
|
186
|
+
* every name, and Node adds its own transport headers. Both are undone here — transport headers are
|
|
187
|
+
* dropped, and each remaining name is upper-cased at the start of every hyphen-separated segment,
|
|
188
|
+
* which is the conventional HTTP spelling (`x-token` → `X-Token`, `content-type` → `Content-Type`).
|
|
189
|
+
*
|
|
190
|
+
* The original casing is gone by the time nock sees the request, so this RE-DERIVES it rather than
|
|
191
|
+
* restoring it. Conventional names round-trip exactly; a service that shouted its header
|
|
192
|
+
* (`X-API-KEY`) or wrote it in camelCase (`apiKey`) gets the conventional spelling back instead
|
|
193
|
+
* (`X-Api-Key`, `Apikey`).
|
|
194
|
+
*
|
|
195
|
+
* @param {object} rawHeaders - Lowercased headers as nock recorded them.
|
|
196
|
+
* @returns {object} A new object; the input is left alone.
|
|
197
|
+
*/
|
|
198
|
+
function normalizeHeaders(rawHeaders) {
|
|
199
|
+
const headers = {}
|
|
200
|
+
|
|
201
|
+
for (const [name, value] of Object.entries(rawHeaders || {})) {
|
|
202
|
+
const lower = name.toLowerCase()
|
|
203
|
+
|
|
204
|
+
// The harness's own marker must never look like something the service set.
|
|
205
|
+
if (TRANSPORT_HEADERS.has(lower) || lower === TIMEOUT_HEADER) {
|
|
206
|
+
continue
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const normalized = name
|
|
210
|
+
.split('-')
|
|
211
|
+
.map(segment => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
212
|
+
.join('-')
|
|
213
|
+
|
|
214
|
+
headers[normalized] = value
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return headers
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The multipart body as text, whatever encoding nock handed it over in.
|
|
222
|
+
*
|
|
223
|
+
* nock stringifies the request body for the reply callback, and a body that is not valid UTF-8 — which
|
|
224
|
+
* is exactly what a multipart upload carrying binary bytes is — arrives HEX-ENCODED. Left as-is the
|
|
225
|
+
* boundary is invisible in it, `parseFormData` finds no parts, and a binary upload reads as
|
|
226
|
+
* `{ _fields: [] }`: "the service sent nothing", which is indistinguishable from a genuinely empty
|
|
227
|
+
* body and is the one thing a multipart test exists to tell apart.
|
|
228
|
+
*
|
|
229
|
+
* Decoded only when the decoded form actually contains the boundary, so a text upload — or a body that
|
|
230
|
+
* merely happens to look like hex — is handed back untouched.
|
|
231
|
+
*/
|
|
232
|
+
function multipartText(rawBody, boundary) {
|
|
233
|
+
const text = Buffer.isBuffer(rawBody) ? rawBody.toString('binary') : String(rawBody)
|
|
234
|
+
|
|
235
|
+
if (text.includes(boundary) || !/^(?:[0-9a-f]{2})+$/i.test(text)) {
|
|
236
|
+
return text
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const decoded = Buffer.from(text, 'hex').toString('binary')
|
|
240
|
+
|
|
241
|
+
return decoded.includes(boundary) ? decoded : text
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Rebuilds the `{ _fields: [{ name, value, filename, contentType }] }` shape a FormData body had
|
|
246
|
+
* before it was serialized, by parsing the multipart body off the wire.
|
|
247
|
+
*/
|
|
248
|
+
function parseFormData(rawBody, contentType) {
|
|
249
|
+
const boundaryMatch = /boundary=(?:"([^"]+)"|([^;\s]+))/i.exec(contentType || '')
|
|
250
|
+
|
|
251
|
+
if (!boundaryMatch) {
|
|
252
|
+
return undefined
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const boundary = `--${ boundaryMatch[1] || boundaryMatch[2] }`
|
|
256
|
+
const fields = []
|
|
257
|
+
|
|
258
|
+
for (const part of multipartText(rawBody, boundary).split(boundary)) {
|
|
259
|
+
const section = part.replace(/^\r\n/, '')
|
|
260
|
+
const headerEnd = section.indexOf('\r\n\r\n')
|
|
261
|
+
|
|
262
|
+
if (!section || section.startsWith('--') || headerEnd === -1) {
|
|
263
|
+
continue
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const headers = section.slice(0, headerEnd)
|
|
267
|
+
const name = /\bname="([^"]*)"/i.exec(headers)
|
|
268
|
+
const filename = /\bfilename="([^"]*)"/i.exec(headers)
|
|
269
|
+
// The per-part Content-Type. Recorded because it is the only thing that tells an upload's MIME
|
|
270
|
+
// type apart from the default, and a service picks it deliberately (usually from the extension).
|
|
271
|
+
const partType = /^content-type:\s*(.+)$/im.exec(headers)
|
|
272
|
+
const value = section.slice(headerEnd + 4).replace(/\r\n$/, '')
|
|
273
|
+
|
|
274
|
+
fields.push({
|
|
275
|
+
name: name ? name[1] : undefined,
|
|
276
|
+
// A part carrying a filename is a file upload, and the service appended it as a Buffer. Hand
|
|
277
|
+
// one back so `Buffer.isBuffer(field.value)` still holds. (Text parts stay strings.)
|
|
278
|
+
value : filename ? Buffer.from(value, 'binary') : value,
|
|
279
|
+
filename : filename ? filename[1] : undefined,
|
|
280
|
+
contentType: partType ? partType[1].trim() : undefined,
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return { _fields: fields }
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* nock hands the body over already JSON-parsed when the content type says JSON, and as a string
|
|
289
|
+
* otherwise. Normalize the leftovers: an empty body reads as "no body at all".
|
|
290
|
+
*/
|
|
291
|
+
function parseBody(rawBody, contentType) {
|
|
292
|
+
if (rawBody === undefined || rawBody === null || rawBody === '') {
|
|
293
|
+
return undefined
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (typeof rawBody !== 'string') {
|
|
297
|
+
return rawBody
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// `a=1&b=two` is the wire form of `{ a: '1', b: 'two' }` — decode it back, the same way a JSON
|
|
301
|
+
// body comes back as an object rather than its serialized text. Values stay STRINGS here, unlike
|
|
302
|
+
// query params: form bodies overwhelmingly carry ids and flags the service already stringified,
|
|
303
|
+
// and re-typing them turned `company_id: '142'` into `142`.
|
|
304
|
+
if (String(contentType || '').startsWith('application/x-www-form-urlencoded')) {
|
|
305
|
+
return { ...queryString.parse(rawBody) }
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
return JSON.parse(rawBody)
|
|
310
|
+
} catch (error) {
|
|
311
|
+
return rawBody
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Builds one history entry from nock's interceptor context. */
|
|
316
|
+
function buildRecord(req, uri, rawBody) {
|
|
317
|
+
const options = req.options || {}
|
|
318
|
+
const headers = req.headers || {}
|
|
319
|
+
const parsed = canonicalize(`${ options.proto }://${ options.host }${ uri }`) || { base: uri, full: uri }
|
|
320
|
+
const contentType = headers['content-type']
|
|
321
|
+
const formData = contentType && contentType.includes('multipart/form-data')
|
|
322
|
+
? parseFormData(rawBody, contentType)
|
|
323
|
+
: undefined
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
method: String(req.method || '').toLowerCase(),
|
|
327
|
+
// `url` and `canonicalUrl` hold the same string. Both are recorded because suites assert either
|
|
328
|
+
// one, and only `canonicalUrl` is contractually the normalized form.
|
|
329
|
+
url : parsed.base,
|
|
330
|
+
canonicalUrl: parsed.base,
|
|
331
|
+
fullUrl : parsed.full,
|
|
332
|
+
headers : normalizeHeaders(headers),
|
|
333
|
+
query : parseQuery(parsed.full.slice(parsed.base.length)),
|
|
334
|
+
body : formData ? undefined : parseBody(rawBody, contentType),
|
|
335
|
+
formData,
|
|
336
|
+
contentType,
|
|
337
|
+
// Transport details kept OFF `headers` on purpose: many suites assert the whole header object
|
|
338
|
+
// with `toEqual`, and a service never sets these itself.
|
|
339
|
+
contentLength: headers['content-length'] !== undefined ? Number(headers['content-length']) : undefined,
|
|
340
|
+
timeout : headers[TIMEOUT_HEADER] !== undefined ? Number(headers[TIMEOUT_HEADER]) : undefined,
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* nock only emits Error instances — handing it a plain object makes the request hang silently — so
|
|
346
|
+
* `replyWithError({ message, body })` has to be reconstituted into a real Error carrying those props.
|
|
347
|
+
*/
|
|
348
|
+
function toError(error) {
|
|
349
|
+
if (error instanceof Error) {
|
|
350
|
+
return error
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (typeof error === 'string') {
|
|
354
|
+
return new Error(error)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return Object.assign(new Error((error && error.message) || 'Request failed'), error)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Handler precedence, applied across every live mock, newest mock first:
|
|
362
|
+
* exact method+url → method+any url → any method+url → any method+any url, first registered wins
|
|
363
|
+
* within a tier.
|
|
364
|
+
*
|
|
365
|
+
* nock's own routing is not used for this: its precedence follows scope registration order, so a
|
|
366
|
+
* broad `onAny()` fallback would shadow a specific handler registered after it.
|
|
367
|
+
*/
|
|
368
|
+
function resolveHandler(record) {
|
|
369
|
+
for (let i = liveMocks.length - 1; i >= 0; i--) {
|
|
370
|
+
const handler = liveMocks[i].findHandler(record)
|
|
371
|
+
|
|
372
|
+
if (handler) {
|
|
373
|
+
return { mock: liveMocks[i], handler }
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return { mock: liveMocks[liveMocks.length - 1], handler: null }
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* The single reply callback behind every catch-all interceptor. `this` is nock's interceptor
|
|
382
|
+
* context, so it must stay a function declaration.
|
|
383
|
+
*/
|
|
384
|
+
function dispatch(uri, rawBody, callback) {
|
|
385
|
+
const record = buildRecord(this.req, uri, rawBody)
|
|
386
|
+
const { mock, handler } = resolveHandler(record)
|
|
387
|
+
|
|
388
|
+
if (!mock) {
|
|
389
|
+
return callback(new Error(`No request mock is active for ${ record.method.toUpperCase() } ${ record.url }`))
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
mock.history.push(record)
|
|
393
|
+
|
|
394
|
+
// No handler registered: resolve with null rather than failing the request.
|
|
395
|
+
if (!handler) {
|
|
396
|
+
return callback(null, [200, null])
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (handler.error) {
|
|
400
|
+
return callback(toError(handler.error))
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
let response
|
|
404
|
+
|
|
405
|
+
try {
|
|
406
|
+
response = typeof handler.response === 'function' ? handler.response(record) : handler.response
|
|
407
|
+
} catch (error) {
|
|
408
|
+
// A `replyWith` callback that throws synchronously — the idiom retry tests use to fail the
|
|
409
|
+
// first attempt.
|
|
410
|
+
return callback(toError(error))
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
Promise.resolve(response).then(
|
|
414
|
+
value => callback(null, [handler.status, value === undefined ? null : value, handler.headers]),
|
|
415
|
+
error => callback(toError(error)),
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Registers the persisted catch-all for one HTTP method, once. */
|
|
420
|
+
function installCatchAll(method) {
|
|
421
|
+
if (interceptedMethods.has(method)) {
|
|
422
|
+
return
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// `dispose()` deactivates nock so it stops patching `http`; a later mock in the same file has to
|
|
426
|
+
// put it back.
|
|
427
|
+
if (!nock.isActive()) {
|
|
428
|
+
nock.activate()
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
nock(/.*/)
|
|
432
|
+
.persist()
|
|
433
|
+
.intercept(/.*/, method.toUpperCase())
|
|
434
|
+
.query(() => true)
|
|
435
|
+
.reply(dispatch)
|
|
436
|
+
|
|
437
|
+
interceptedMethods.add(method)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function createNockMock() {
|
|
441
|
+
const history = []
|
|
442
|
+
const handlers = []
|
|
443
|
+
|
|
444
|
+
const state = {
|
|
445
|
+
history,
|
|
446
|
+
|
|
447
|
+
findHandler(record) {
|
|
448
|
+
return (
|
|
449
|
+
handlers.find(h => h.url !== undefined && h.method === record.method && urlMatches(h.url, record)) ||
|
|
450
|
+
handlers.find(h => h.url === undefined && h.method === record.method) ||
|
|
451
|
+
handlers.find(h => h.url !== undefined && h.method === 'any' && urlMatches(h.url, record)) ||
|
|
452
|
+
handlers.find(h => h.url === undefined && h.method === 'any')
|
|
453
|
+
)
|
|
454
|
+
},
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function createReplyBuilder(method, url) {
|
|
458
|
+
if (method !== 'any') {
|
|
459
|
+
installCatchAll(method)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return {
|
|
463
|
+
/**
|
|
464
|
+
* @param {*} response - The resolved value, or a function/promise producing it.
|
|
465
|
+
* @param {number} [status] - HTTP status; anything outside 2xx makes the request reject.
|
|
466
|
+
* @param {object} [headers] - Response headers, for APIs that signal through them.
|
|
467
|
+
*/
|
|
468
|
+
reply(response, status = 200, headers = undefined) {
|
|
469
|
+
handlers.push({ method, url, response, status, headers })
|
|
470
|
+
|
|
471
|
+
return api
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Answers with an error RESPONSE — a real status code and body, the way the API would.
|
|
476
|
+
*
|
|
477
|
+
* .replyWithError('Invalid Account or Auth', 401) // body: { message: '…' }
|
|
478
|
+
* .replyWithError({ errors: [ 'Invalid Account' ] }, 401)
|
|
479
|
+
* .replyWithError('server error') // status defaults to 400
|
|
480
|
+
*
|
|
481
|
+
* For a failure with no response at all — a dropped connection, a reset socket — use
|
|
482
|
+
* `replyWithNetworkError` instead; those are a different branch in service code than a 500.
|
|
483
|
+
*
|
|
484
|
+
* A single OBJECT argument with no status keeps the older reading: it becomes a client-side
|
|
485
|
+
* Error the request rejects with. Most existing call sites mean it that way, and the two
|
|
486
|
+
* readings are indistinguishable from the argument alone — so an object body MUST carry its
|
|
487
|
+
* status explicitly. A string never needs one.
|
|
488
|
+
*
|
|
489
|
+
* @param {string|object|Error} body - Response body; a string becomes `{ message: body }`.
|
|
490
|
+
* @param {number} [status] - HTTP status. Required for an object body.
|
|
491
|
+
*/
|
|
492
|
+
replyWithError(body, status) {
|
|
493
|
+
if (status === undefined && (body instanceof Error || (body !== null && typeof body === 'object'))) {
|
|
494
|
+
handlers.push({ method, url, error: body })
|
|
495
|
+
|
|
496
|
+
return api
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
handlers.push({
|
|
500
|
+
method,
|
|
501
|
+
url,
|
|
502
|
+
response: typeof body === 'string' || body === null || body === undefined
|
|
503
|
+
? { message: body === null || body === undefined ? 'Request failed' : body }
|
|
504
|
+
: body,
|
|
505
|
+
status : status === undefined ? DEFAULT_ERROR_STATUS : status,
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
return api
|
|
509
|
+
},
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Fails the request at the transport layer: no status, no body, nothing came back.
|
|
513
|
+
*
|
|
514
|
+
* This is what a service sees when the connection is refused, reset or times out, and it is a
|
|
515
|
+
* genuinely different path from an error response — `error.status` is undefined and
|
|
516
|
+
* `error.code` carries the syscall name.
|
|
517
|
+
*
|
|
518
|
+
* .replyWithNetworkError('ECONNRESET')
|
|
519
|
+
* .replyWithNetworkError('socket hang up')
|
|
520
|
+
*
|
|
521
|
+
* @param {string} [code] - A syscall code (`ECONNRESET`, `ETIMEDOUT`, …) or a free-text
|
|
522
|
+
* reason. A syscall-shaped value is set on `error.code` as well as the message.
|
|
523
|
+
*/
|
|
524
|
+
replyWithNetworkError(code = 'ECONNRESET') {
|
|
525
|
+
const error = new Error(code)
|
|
526
|
+
|
|
527
|
+
if (/^E[A-Z_]+$/.test(code)) {
|
|
528
|
+
error.code = code
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
handlers.push({ method, url, error })
|
|
532
|
+
|
|
533
|
+
return api
|
|
534
|
+
},
|
|
535
|
+
|
|
536
|
+
/** @param {(call: object) => *} fn - Receives the history entry, returns the response. */
|
|
537
|
+
replyWith(fn) {
|
|
538
|
+
handlers.push({ method, url, response: fn, status: 200 })
|
|
539
|
+
|
|
540
|
+
return api
|
|
541
|
+
},
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const api = {
|
|
546
|
+
history,
|
|
547
|
+
|
|
548
|
+
/** `onGet`, `onPost`, … `onAny` are generated below; `on()` covers anything non-standard. */
|
|
549
|
+
on(method, url) {
|
|
550
|
+
return createReplyBuilder(String(method).toLowerCase(), url)
|
|
551
|
+
},
|
|
552
|
+
|
|
553
|
+
/** Drops recorded calls and registered handlers, keeping the mock itself active. */
|
|
554
|
+
reset() {
|
|
555
|
+
history.length = 0
|
|
556
|
+
handlers.length = 0
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Drops registered handlers but keeps the recorded calls. For suites whose own `replyWith()`
|
|
561
|
+
* helper re-arms the transport mid-test: the first matching handler wins, so a stale one
|
|
562
|
+
* registered earlier in the same test would shadow the new reply.
|
|
563
|
+
*/
|
|
564
|
+
resetHandlers() {
|
|
565
|
+
handlers.length = 0
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
/** Removes this mock and, once none are left, un-patches `http`. See "Lifecycle" above. */
|
|
569
|
+
dispose() {
|
|
570
|
+
api.reset()
|
|
571
|
+
|
|
572
|
+
const index = liveMocks.indexOf(state)
|
|
573
|
+
|
|
574
|
+
if (index !== -1) {
|
|
575
|
+
liveMocks.splice(index, 1)
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if (!liveMocks.length) {
|
|
579
|
+
nock.cleanAll()
|
|
580
|
+
nock.restore()
|
|
581
|
+
interceptedMethods.clear()
|
|
582
|
+
http.__flowrunnerSandboxMocking = false
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
for (const method of [...STANDARD_METHODS, 'any']) {
|
|
588
|
+
api[`on${ method.charAt(0).toUpperCase() }${ method.slice(1) }`] = url => createReplyBuilder(method, url)
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
liveMocks.push(state)
|
|
592
|
+
http.__flowrunnerSandboxMocking = true
|
|
593
|
+
STANDARD_METHODS.forEach(installCatchAll)
|
|
594
|
+
|
|
595
|
+
return api
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
module.exports = {
|
|
599
|
+
createNockMock: createNockMock,
|
|
600
|
+
}
|