zcatalyst-cli 1.21.0 → 1.22.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/lib/api-timer.d.ts +17 -0
- package/lib/api-timer.js +2 -2
- package/lib/apig-utils.d.ts +41 -0
- package/lib/apig-utils.js +32 -32
- package/lib/appsail-utils.d.ts +3 -0
- package/lib/appsail-utils.js +116 -12
- package/lib/archiver.d.ts +47 -0
- package/lib/archiver.js +6 -6
- package/lib/authentication/constants/auth.d.ts +21 -0
- package/lib/authentication/constants/auth.js +37 -0
- package/lib/authentication/constants/scopes.d.ts +81 -0
- package/lib/{util_modules/constants/lib → authentication/constants}/scopes.js +1 -0
- package/lib/authentication/credential.d.ts +39 -0
- package/lib/{internal → authentication}/credential.js +63 -46
- package/lib/authentication/crypt.d.ts +13 -0
- package/lib/authentication/error.d.ts +4 -0
- package/lib/authentication/error.js +14 -0
- package/lib/authentication/index.d.ts +5 -0
- package/lib/authentication/index.js +65 -63
- package/lib/authentication/login.d.ts +46 -0
- package/lib/authentication/login.js +147 -105
- package/lib/authentication/revoke.d.ts +9 -0
- package/lib/bin/catalyst.d.ts +2 -0
- package/lib/bin/catalyst.js +80 -36
- package/lib/cli_table/index.js +3 -2
- package/lib/client-utils.d.ts +16 -0
- package/lib/client-utils.js +57 -50
- package/lib/client.d.ts +21 -0
- package/lib/client.js +93 -6
- package/lib/code-deck.d.ts +21 -0
- package/lib/command_needs/auth.d.ts +2 -0
- package/lib/command_needs/auth.js +25 -24
- package/lib/command_needs/config.d.ts +4 -0
- package/lib/command_needs/rc.d.ts +8 -0
- package/lib/command_needs/rc.js +24 -24
- package/lib/commands/apig/disable.d.ts +3 -0
- package/lib/commands/apig/disable.js +8 -8
- package/lib/commands/apig/enable.d.ts +3 -0
- package/lib/commands/apig/enable.js +8 -8
- package/lib/commands/apig/status.d.ts +18 -0
- package/lib/commands/apig/status.js +12 -12
- package/lib/commands/appsail/add.d.ts +3 -0
- package/lib/commands/appsail/add.js +7 -6
- package/lib/commands/appsail/unlink.d.ts +3 -0
- package/lib/commands/appsail/unlink.js +43 -0
- package/lib/commands/client/delete.d.ts +3 -0
- package/lib/commands/client/delete.js +19 -19
- package/lib/commands/client/setup.d.ts +3 -0
- package/lib/commands/client/setup.js +6 -5
- package/lib/commands/codelib/install.d.ts +3 -0
- package/lib/commands/codelib/install.js +15 -15
- package/lib/commands/config/delete.d.ts +3 -0
- package/lib/commands/config/delete.js +2 -2
- package/lib/commands/config/get.d.ts +3 -0
- package/lib/commands/config/get.js +2 -2
- package/lib/commands/config/list.d.ts +3 -0
- package/lib/commands/config/list.js +2 -2
- package/lib/commands/config/set.d.ts +3 -0
- package/lib/commands/config/set.js +2 -2
- package/lib/commands/deploy/appsail.d.ts +3 -0
- package/lib/commands/deploy/appsail.js +11 -9
- package/lib/commands/deploy/index.d.ts +3 -0
- package/lib/commands/deploy/index.js +43 -25
- package/lib/commands/deploy/slate.d.ts +3 -0
- package/lib/commands/deploy/slate.js +1 -1
- package/lib/commands/ds/export.d.ts +3 -0
- package/lib/commands/ds/export.js +9 -9
- package/lib/commands/ds/import.d.ts +3 -0
- package/lib/commands/ds/import.js +13 -13
- package/lib/commands/ds/status.d.ts +23 -0
- package/lib/commands/ds/status.js +12 -11
- package/lib/commands/event/generate/index.d.ts +3 -0
- package/lib/commands/event/generate/index.js +5 -186
- package/lib/commands/event/generate/integ.d.ts +3 -0
- package/lib/commands/event/generate/integ.js +4 -4
- package/lib/commands/event/generate/job.d.ts +3 -0
- package/lib/commands/functions/add.d.ts +3 -0
- package/lib/commands/functions/add.js +6 -5
- package/lib/commands/functions/config.d.ts +3 -0
- package/lib/commands/functions/config.js +5 -5
- package/lib/commands/functions/delete.d.ts +3 -0
- package/lib/commands/functions/delete.js +19 -18
- package/lib/commands/functions/execute.d.ts +3 -0
- package/lib/commands/functions/execute.js +202 -0
- package/lib/commands/functions/setup.d.ts +3 -0
- package/lib/commands/functions/setup.js +6 -5
- package/lib/commands/functions/shell.d.ts +3 -0
- package/lib/commands/functions/shell.js +32 -28
- package/lib/commands/help.d.ts +3 -0
- package/lib/commands/help.js +4 -4
- package/lib/commands/iac/export.d.ts +3 -0
- package/lib/commands/iac/export.js +9 -8
- package/lib/commands/iac/import.d.ts +6 -0
- package/lib/commands/iac/import.js +23 -22
- package/lib/commands/iac/pack.d.ts +3 -0
- package/lib/commands/iac/pack.js +13 -13
- package/lib/commands/iac/status.d.ts +3 -0
- package/lib/commands/iac/status.js +4 -4
- package/lib/commands/index.d.ts +3 -0
- package/lib/commands/index.js +74 -64
- package/lib/commands/init.d.ts +3 -0
- package/lib/commands/init.js +13 -11
- package/lib/commands/login.d.ts +3 -0
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.d.ts +3 -0
- package/lib/commands/logout.js +1 -1
- package/lib/commands/project/list.d.ts +3 -0
- package/lib/commands/project/list.js +7 -6
- package/lib/commands/project/reset.d.ts +3 -0
- package/lib/commands/project/reset.js +5 -5
- package/lib/commands/project/use.d.ts +3 -0
- package/lib/commands/project/use.js +13 -11
- package/lib/commands/pull.d.ts +3 -0
- package/lib/commands/pull.js +16 -15
- package/lib/commands/run.d.ts +3 -0
- package/lib/commands/run.js +9 -9
- package/lib/commands/serve.d.ts +3 -0
- package/lib/commands/signals/generate/index.d.ts +3 -0
- package/lib/commands/slate/create.d.ts +3 -0
- package/lib/commands/slate/link.d.ts +3 -0
- package/lib/commands/slate/unlink.d.ts +3 -0
- package/lib/commands/slate/unlink.js +1 -1
- package/lib/commands/token/generate.d.ts +3 -0
- package/lib/commands/token/generate.js +4 -3
- package/lib/commands/token/list.d.ts +3 -0
- package/lib/commands/token/list.js +4 -3
- package/lib/commands/token/revoke.d.ts +3 -0
- package/lib/commands/token/revoke.js +3 -3
- package/lib/commands/whoami.d.ts +3 -0
- package/lib/commands/whoami.js +8 -8
- package/lib/commands/zest/generate/index.d.ts +14 -0
- package/lib/commands/zest/generate/index.js +1 -2
- package/lib/deploy/features/apig.d.ts +2 -0
- package/lib/deploy/features/apig.js +11 -11
- package/lib/deploy/features/appsail/index.d.ts +3 -0
- package/lib/deploy/features/appsail/index.js +82 -194
- package/lib/deploy/features/appsail/pack.d.ts +14 -0
- package/lib/deploy/features/appsail/pack.js +130 -0
- package/lib/deploy/features/appsail/utils.d.ts +15 -0
- package/lib/deploy/features/appsail/utils.js +163 -17
- package/lib/deploy/features/client.d.ts +2 -0
- package/lib/deploy/features/client.js +5 -4
- package/lib/deploy/features/functions/index.d.ts +2 -0
- package/lib/deploy/features/functions/index.js +41 -32
- package/lib/deploy/features/functions/languages/index.d.ts +4 -0
- package/lib/deploy/features/functions/languages/index.js +14 -1
- package/lib/deploy/features/functions/utils.d.ts +1 -0
- package/lib/deploy/features/functions/utils.js +136 -0
- package/lib/deploy/features/index.d.ts +8 -0
- package/lib/deploy/features/slate.d.ts +5 -0
- package/lib/deploy/features/slate.js +5 -5
- package/lib/deploy/index.d.ts +6 -0
- package/lib/deploy/index.js +12 -11
- package/lib/deploy/util.d.ts +7 -0
- package/lib/deploy/util.js +22 -0
- package/lib/docs/commands/functions/execute.toml +29 -0
- package/lib/docs/endpoints/lib/git-hub.toml +3 -0
- package/lib/docs/fn-utils/lib/java/classpath.toml +9 -0
- package/lib/docs/fn-utils/lib/java/ensure-java-userconfig.toml +24 -0
- package/lib/docs/fn-utils/lib/java/index.toml +15 -0
- package/{docs → lib/docs}/option-filter.toml +12 -3
- package/lib/docs/util_modules/container.toml +6 -0
- package/{docs → lib/docs}/util_modules/project.toml +1 -1
- package/lib/endpoints/index.d.ts +119 -0
- package/lib/endpoints/index.js +32 -25
- package/lib/endpoints/lib/apig.d.ts +17 -0
- package/lib/endpoints/lib/apig.js +12 -12
- package/lib/endpoints/lib/applogic.d.ts +21 -0
- package/lib/endpoints/lib/applogic.js +10 -10
- package/lib/endpoints/lib/appsail.d.ts +64 -0
- package/lib/endpoints/lib/appsail.js +94 -5
- package/lib/endpoints/lib/cache.d.ts +12 -0
- package/lib/endpoints/lib/cache.js +8 -8
- package/lib/endpoints/lib/catalyst-details.d.ts +8 -0
- package/lib/endpoints/lib/catalyst-details.js +2 -2
- package/lib/endpoints/lib/client.d.ts +16 -0
- package/lib/endpoints/lib/client.js +12 -12
- package/lib/endpoints/lib/code-deck.d.ts +10 -0
- package/lib/endpoints/lib/code-deck.js +3 -3
- package/lib/endpoints/lib/common.d.ts +5 -0
- package/lib/endpoints/lib/common.js +2 -2
- package/lib/endpoints/lib/datastore.d.ts +11 -0
- package/lib/endpoints/lib/datastore.js +6 -6
- package/lib/endpoints/lib/ds-bulk.d.ts +46 -0
- package/lib/endpoints/lib/ds-bulk.js +12 -12
- package/lib/endpoints/lib/env.d.ts +8 -0
- package/lib/endpoints/lib/env.js +5 -5
- package/lib/endpoints/lib/event-bus.d.ts +10 -0
- package/lib/endpoints/lib/event-bus.js +4 -4
- package/lib/endpoints/lib/filestore.d.ts +13 -0
- package/lib/endpoints/lib/filestore.js +6 -6
- package/lib/endpoints/lib/functions.d.ts +24 -0
- package/lib/endpoints/lib/functions.js +14 -14
- package/lib/endpoints/lib/git-hub.d.ts +16 -0
- package/lib/endpoints/lib/git-hub.js +15 -2
- package/lib/endpoints/lib/iac.d.ts +43 -0
- package/lib/endpoints/lib/iac.js +20 -20
- package/lib/endpoints/lib/job-scheduling.d.ts +43 -0
- package/lib/endpoints/lib/job-scheduling.js +2 -2
- package/lib/endpoints/lib/log.d.ts +10 -0
- package/lib/endpoints/lib/org.d.ts +13 -0
- package/lib/endpoints/lib/org.js +2 -2
- package/lib/endpoints/lib/project.d.ts +18 -0
- package/lib/endpoints/lib/project.js +11 -11
- package/lib/endpoints/lib/queue.d.ts +14 -0
- package/lib/endpoints/lib/queue.js +8 -8
- package/lib/endpoints/lib/sdk.d.ts +10 -0
- package/lib/endpoints/lib/sdk.js +5 -5
- package/lib/endpoints/lib/slate.d.ts +16 -0
- package/lib/endpoints/lib/stratus.d.ts +15 -0
- package/lib/endpoints/lib/tunnel.d.ts +38 -0
- package/lib/endpoints/lib/tunnel.js +5 -5
- package/lib/endpoints/lib/user.d.ts +8 -0
- package/lib/endpoints/lib/user.js +46 -0
- package/lib/endpoints/lib/zcql.d.ts +12 -0
- package/lib/endpoints/lib/zcql.js +4 -4
- package/lib/endpoints/lib/zest.d.ts +73 -0
- package/lib/error/context-help.d.ts +1 -0
- package/lib/{util_modules → error}/context-help.js +15 -18
- package/lib/error/index.d.ts +27 -0
- package/lib/{error.js → error/index.js} +18 -14
- package/lib/error/utils.d.ts +2 -0
- package/lib/error/utils.js +8 -0
- package/lib/errorOut.d.ts +3 -0
- package/lib/errorOut.js +10 -9
- package/lib/errorResponse.d.ts +4 -0
- package/lib/event_generate/cache.d.ts +2 -0
- package/lib/event_generate/cache.js +3 -3
- package/lib/event_generate/custom.d.ts +1 -0
- package/lib/event_generate/custom.js +2 -2
- package/lib/event_generate/datastore.d.ts +7 -0
- package/lib/event_generate/datastore.js +6 -6
- package/lib/event_generate/filestore.d.ts +2 -0
- package/lib/event_generate/filestore.js +2 -2
- package/lib/event_generate/github.d.ts +2 -0
- package/lib/event_generate/index.d.ts +2 -0
- package/lib/event_generate/index.js +196 -0
- package/lib/event_generate/integration/cliq.d.ts +2 -0
- package/lib/event_generate/integration/cliq.js +4 -4
- package/lib/event_generate/stratus.d.ts +2 -0
- package/lib/event_generate/user.d.ts +2 -0
- package/lib/event_generate/webapp.d.ts +2 -0
- package/lib/execute/caller.d.ts +14 -0
- package/lib/execute/caller.js +155 -0
- package/lib/execute/index.d.ts +3 -0
- package/lib/execute/index.js +87 -0
- package/lib/execute-script.d.ts +6 -0
- package/lib/execute-script.js +62 -32
- package/lib/express_middlewares/apig-matcher.d.ts +3 -0
- package/lib/express_middlewares/auth-checker.d.ts +3 -0
- package/lib/express_middlewares/authenticator.d.ts +3 -0
- package/lib/express_middlewares/authenticator.js +3 -2
- package/lib/express_middlewares/cookie-parser.d.ts +3 -0
- package/lib/express_middlewares/error-handler.d.ts +3 -0
- package/lib/express_middlewares/logger.d.ts +5 -0
- package/lib/express_middlewares/logger.js +3 -2
- package/lib/express_middlewares/project.d.ts +6 -0
- package/lib/express_middlewares/url-rewriter.d.ts +3 -0
- package/lib/fn-utils/index.d.ts +10 -0
- package/lib/fn-utils/lib/browserLogic.d.ts +2 -0
- package/lib/fn-utils/lib/browserLogic.js +7 -6
- package/lib/fn-utils/lib/common.d.ts +85 -0
- package/lib/fn-utils/lib/common.js +79 -90
- package/lib/fn-utils/lib/integ.d.ts +2 -0
- package/lib/fn-utils/lib/integ.js +10 -4
- package/lib/fn-utils/lib/java/classpath.d.ts +2 -0
- package/lib/fn-utils/lib/java/classpath.js +107 -0
- package/lib/fn-utils/lib/java/compile.d.ts +4 -0
- package/lib/fn-utils/lib/java/compile.js +222 -0
- package/lib/fn-utils/lib/java/ensure-java-userconfig.d.ts +22 -0
- package/lib/fn-utils/lib/java/ensure-java-userconfig.js +264 -0
- package/lib/fn-utils/lib/java/index.d.ts +16 -0
- package/lib/fn-utils/lib/java/index.js +254 -0
- package/lib/fn-utils/lib/java/keywords.d.ts +2 -0
- package/lib/fn-utils/lib/java/keywords.js +71 -0
- package/lib/fn-utils/lib/node.d.ts +5 -0
- package/lib/fn-utils/lib/node.js +30 -10
- package/lib/fn-utils/lib/python.d.ts +3 -0
- package/lib/fn-utils/lib/python.js +9 -4
- package/lib/fn-watcher.d.ts +8 -0
- package/lib/fn-watcher.js +18 -23
- package/lib/iac/status/bundle.d.ts +2 -0
- package/lib/iac/status/bundle.js +10 -7
- package/lib/iac/status/deploy.d.ts +2 -0
- package/lib/iac/status/deploy.js +10 -10
- package/lib/iac/status/util/index.d.ts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +15 -4
- package/lib/init/dependencies/npm-install.d.ts +3 -0
- package/lib/init/dependencies/npm-install.js +4 -3
- package/lib/init/dependencies/package-json.d.ts +2 -0
- package/lib/init/dependencies/package-json.js +3 -3
- package/lib/init/dependencies/python/ensure-python.d.ts +2 -0
- package/lib/init/dependencies/python/pip-install.d.ts +7 -0
- package/lib/init/dependencies/python/pip-install.js +3 -3
- package/lib/init/features/appsail/index.d.ts +2 -0
- package/lib/init/features/appsail/index.js +48 -124
- package/lib/init/features/appsail/utils.d.ts +16 -0
- package/lib/init/features/appsail/utils.js +264 -0
- package/lib/init/features/client/index.d.ts +2 -0
- package/lib/init/features/client/index.js +1 -0
- package/lib/init/features/client/initializers/angular.d.ts +2 -0
- package/lib/init/features/client/initializers/angular.js +42 -12
- package/lib/init/features/client/initializers/basic.d.ts +2 -0
- package/lib/init/features/client/initializers/basic.js +2 -2
- package/lib/init/features/client/initializers/lyte.d.ts +2 -0
- package/lib/init/features/client/initializers/lyte.js +1 -1
- package/lib/init/features/client/initializers/react.d.ts +2 -0
- package/lib/init/features/client/initializers/react.js +5 -4
- package/lib/init/features/client/types.d.ts +10 -0
- package/lib/init/features/client/types.js +2 -0
- package/lib/init/features/functions/index.d.ts +17 -0
- package/lib/init/features/functions/index.js +60 -8
- package/lib/init/features/functions/languages/index.d.ts +6 -0
- package/lib/init/features/functions/languages/java.d.ts +2 -0
- package/lib/init/features/functions/languages/java.js +9 -7
- package/lib/init/features/functions/languages/node.d.ts +2 -0
- package/lib/init/features/functions/languages/node.js +6 -4
- package/lib/init/features/functions/languages/python.d.ts +2 -0
- package/lib/init/features/functions/languages/python.js +9 -7
- package/lib/init/features/index.d.ts +14 -0
- package/lib/init/features/index.js +13 -13
- package/lib/init/features/project.d.ts +2 -0
- package/lib/init/features/project.js +19 -22
- package/lib/init/features/slate/index.d.ts +2 -0
- package/lib/init/features/slate/index.js +2 -2
- package/lib/init/index.d.ts +2 -0
- package/lib/init/index.js +5 -5
- package/lib/init/util/client.d.ts +8 -0
- package/lib/init/util/client.js +10 -10
- package/lib/init/util/common.d.ts +12 -0
- package/lib/init/util/common.js +17 -16
- package/lib/init/util/functions.d.ts +7 -0
- package/lib/init/util/functions.js +3 -3
- package/lib/init/util/project.d.ts +3 -0
- package/lib/init/util/project.js +4 -4
- package/lib/internal/api.d.ts +78 -0
- package/lib/internal/api.js +32 -22
- package/lib/internal/command.d.ts +40 -0
- package/lib/internal/command.js +27 -11
- package/lib/internal/config.d.ts +19 -0
- package/lib/internal/config.js +4 -5
- package/lib/internal/rc.d.ts +44 -0
- package/lib/internal/rc.js +9 -9
- package/lib/migration/global/1.4.0.d.ts +2 -0
- package/lib/migration/global/1.4.0.js +4 -4
- package/lib/migration/global/1.6.2.d.ts +2 -0
- package/lib/migration/global/1.6.2.js +13 -13
- package/lib/migration/index.d.ts +6 -0
- package/lib/migration/index.js +19 -18
- package/lib/option-filter.d.ts +5 -0
- package/lib/option-filter.js +57 -30
- package/lib/optional-import.d.ts +2 -0
- package/lib/optional-import.js +3 -3
- package/lib/plugin-loader.d.ts +6 -0
- package/lib/plugin-loader.js +2 -2
- package/lib/port-resolver.d.ts +24 -0
- package/lib/port-resolver.js +14 -13
- package/lib/progress.d.ts +34 -0
- package/lib/prompt/index.d.ts +34 -0
- package/lib/prompt/index.js +49 -9
- package/lib/prompt/types/file-path.d.ts +25 -0
- package/lib/prompt/types/search-box.d.ts +56 -0
- package/lib/prompt/types/search-box.js +84 -46
- package/lib/prompt/types/tree.d.ts +65 -0
- package/lib/prompt/types/with-description.d.ts +15 -0
- package/lib/prompt/types/with-description.js +74 -0
- package/lib/pull/features/apig.d.ts +2 -0
- package/lib/pull/features/apig.js +10 -10
- package/lib/pull/features/client.d.ts +2 -0
- package/lib/pull/features/client.js +11 -10
- package/lib/pull/features/functions/index.d.ts +2 -0
- package/lib/pull/features/functions/index.js +38 -41
- package/lib/pull/features/functions/languages.d.ts +4 -0
- package/lib/pull/features/functions/languages.js +3 -3
- package/lib/pull/features/index.d.ts +6 -0
- package/lib/pull/index.d.ts +2 -0
- package/lib/pull/index.js +8 -8
- package/lib/repl-server.d.ts +32 -0
- package/lib/repl-server.js +8 -8
- package/lib/runtime-store.d.ts +3 -0
- package/lib/runtime-store.js +6 -12
- package/lib/serve/features/apig.d.ts +3 -0
- package/lib/serve/features/apig.js +3 -3
- package/lib/serve/features/appsail.d.ts +16 -0
- package/lib/serve/features/appsail.js +52 -10
- package/lib/serve/features/client.d.ts +2 -0
- package/lib/serve/features/client.js +1 -1
- package/lib/serve/features/index.d.ts +7 -0
- package/lib/serve/features/index.js +4 -4
- package/lib/serve/features/slate.d.ts +12 -0
- package/lib/serve/index.d.ts +2 -0
- package/lib/serve/index.js +65 -67
- package/lib/serve/server/index.d.ts +37 -0
- package/lib/serve/server/index.js +215 -121
- package/lib/serve/server/lib/appsail/index.d.ts +6 -0
- package/lib/serve/server/lib/appsail/index.js +214 -117
- package/lib/serve/server/lib/appsail/start.js +14 -5
- package/lib/serve/server/lib/java/index.d.ts +6 -0
- package/lib/serve/server/lib/java/index.js +52 -22
- package/lib/serve/server/lib/master/appsail.d.ts +5 -0
- package/lib/serve/server/lib/master/appsail.js +16 -5
- package/lib/serve/server/lib/master/functions.d.ts +5 -0
- package/lib/serve/server/lib/master/functions.js +27 -0
- package/lib/serve/server/lib/master/index.d.ts +10 -0
- package/lib/serve/server/lib/master/index.js +11 -3
- package/lib/serve/server/lib/master/slate.d.ts +5 -0
- package/lib/serve/server/lib/master/slate.js +3 -0
- package/lib/serve/server/lib/master/unknown-req-proxy.d.ts +4 -0
- package/lib/serve/server/lib/master/unknown-req-proxy.js +3 -5
- package/lib/serve/server/lib/master/utils.d.ts +24 -0
- package/lib/serve/server/lib/master/utils.js +8 -4
- package/lib/serve/server/lib/master/web-client.d.ts +5 -0
- package/lib/serve/server/lib/node/index.d.ts +6 -0
- package/lib/serve/server/lib/node/index.js +54 -43
- package/lib/serve/server/lib/node/server/bio.js +133 -0
- package/lib/serve/server/lib/node/server/browserlogic/browserlogic-puppeteer.js +1 -1
- package/lib/serve/server/lib/node/server/index.js +22 -1
- package/lib/serve/server/lib/python/index.d.ts +6 -0
- package/lib/serve/server/lib/python/index.js +63 -8
- package/lib/serve/server/lib/slate/index.d.ts +6 -0
- package/lib/serve/server/lib/slate/static-server.d.ts +7 -0
- package/lib/serve/server/lib/slate/static-server.js +24 -24
- package/lib/serve/server/lib/web_client/index.d.ts +5 -0
- package/lib/serve/server/lib/web_client/index.js +11 -8
- package/lib/serve/server/lib/web_client/server.d.ts +7 -0
- package/lib/serve/server/lib/web_client/server.js +22 -22
- package/lib/serve/server/lib/web_client/types.d.ts +15 -0
- package/lib/serve/server/lib/web_client/types.js +2 -0
- package/lib/shell/dependencies/http-functions.d.ts +35 -0
- package/lib/shell/dependencies/http-functions.js +59 -26
- package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
- package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +51 -10
- package/lib/shell/dependencies/invoker/job/node.mjs +2 -2
- package/lib/shell/dependencies/non-http-function/fn-execution-handler.d.ts +13 -0
- package/lib/shell/dependencies/non-http-function/fn-execution-handler.js +260 -0
- package/lib/shell/dependencies/non-http-function/fn-handler.d.ts +30 -0
- package/lib/shell/dependencies/non-http-function/fn-handler.js +258 -0
- package/lib/shell/dependencies/non-http-function/index.d.ts +20 -0
- package/lib/shell/dependencies/non-http-function/index.js +62 -0
- package/lib/shell/dependencies/non-http-function/java.d.ts +9 -0
- package/lib/shell/dependencies/non-http-function/java.js +42 -0
- package/lib/shell/dependencies/non-http-function/node.d.ts +8 -0
- package/lib/shell/dependencies/non-http-function/node.js +36 -0
- package/lib/shell/dependencies/non-http-function/python.d.ts +5 -0
- package/lib/shell/dependencies/non-http-function/python.js +47 -0
- package/lib/shell/dependencies/non-http-function/slave-manager.d.ts +23 -0
- package/lib/shell/dependencies/non-http-function/slave-manager.js +173 -0
- package/lib/shell/dependencies/tunnel-server.d.ts +23 -0
- package/lib/shell/dependencies/tunnel-server.js +4 -4
- package/lib/shell/index.d.ts +2 -0
- package/lib/shell/index.js +31 -25
- package/lib/shell/prepare/index.d.ts +4 -0
- package/lib/shell/prepare/index.js +9 -27
- package/lib/shell/prepare/languages/index.d.ts +6 -0
- package/lib/shell/prepare/languages/index.js +20 -5
- package/lib/shell/prepare/languages/java.d.ts +3 -0
- package/lib/shell/prepare/languages/java.js +6 -14
- package/lib/shell/prepare/languages/node.d.ts +3 -0
- package/lib/shell/prepare/languages/node.js +14 -1
- package/lib/shell/prepare/languages/python.d.ts +3 -0
- package/lib/shell/prepare/languages/python.js +13 -2
- package/lib/slate-utils.d.ts +12 -0
- package/lib/throbber/index.d.ts +36 -0
- package/lib/throbber/index.js +11 -7
- package/lib/throbber/utils.d.ts +23 -0
- package/lib/track.d.ts +2 -0
- package/lib/track.js +13 -13
- package/lib/userConfig.d.ts +22 -0
- package/lib/userConfig.js +18 -8
- package/lib/util_modules/config/index.d.ts +6 -0
- package/lib/util_modules/config/lib/apig.d.ts +15 -0
- package/lib/util_modules/config/lib/apig.js +4 -4
- package/lib/util_modules/config/lib/appsail.d.ts +50 -0
- package/lib/util_modules/config/lib/appsail.js +96 -26
- package/lib/util_modules/config/lib/client.d.ts +20 -0
- package/lib/util_modules/config/lib/client.js +19 -6
- package/lib/util_modules/config/lib/functions.d.ts +48 -0
- package/lib/util_modules/config/lib/functions.js +27 -16
- package/lib/util_modules/config/lib/slate.d.ts +106 -0
- package/lib/util_modules/config/lib/slate.js +1 -1
- package/lib/util_modules/config-store.d.ts +12 -0
- package/lib/util_modules/config-store.js +55 -0
- package/lib/util_modules/constants/index.d.ts +24 -0
- package/lib/util_modules/constants/index.js +1 -5
- package/lib/util_modules/constants/lib/apig-rules.d.ts +3 -0
- package/lib/util_modules/constants/lib/apig-rules.js +1 -1
- package/lib/util_modules/constants/lib/browserLogic.d.ts +20 -0
- package/lib/util_modules/constants/lib/cliq-handlers.d.ts +32 -0
- package/lib/util_modules/constants/lib/dc-type.d.ts +59 -0
- package/lib/util_modules/constants/lib/default.d.ts +48 -0
- package/lib/util_modules/constants/lib/default.js +4 -0
- package/lib/util_modules/constants/lib/env-path.d.ts +6 -0
- package/lib/util_modules/constants/lib/event-action.d.ts +11 -0
- package/lib/util_modules/constants/lib/event-source.d.ts +11 -0
- package/lib/util_modules/constants/lib/file-names.d.ts +37 -0
- package/lib/util_modules/constants/lib/file-names.js +1 -0
- package/lib/util_modules/constants/lib/fn-type.d.ts +11 -0
- package/lib/util_modules/constants/lib/folder-names.d.ts +9 -0
- package/lib/util_modules/constants/lib/iac.d.ts +7 -0
- package/lib/util_modules/constants/lib/integ.d.ts +13 -0
- package/lib/util_modules/constants/lib/needed-scopes.d.ts +4 -0
- package/lib/util_modules/constants/lib/needed-scopes.js +3 -4
- package/lib/util_modules/constants/lib/placeholders.d.ts +65 -0
- package/lib/util_modules/constants/lib/placeholders.js +2 -1
- package/lib/util_modules/constants/lib/plugin.d.ts +27 -0
- package/lib/util_modules/constants/lib/ref-mapping.d.ts +15 -0
- package/lib/util_modules/constants/lib/regex.d.ts +20 -0
- package/lib/util_modules/constants/lib/regex.js +3 -0
- package/lib/util_modules/constants/lib/remote-mapping.d.ts +15 -0
- package/lib/util_modules/constants/lib/runtime.d.ts +18 -0
- package/lib/util_modules/constants/lib/signals-api-names.d.ts +9 -0
- package/lib/util_modules/constants/lib/signals-publishers-type.d.ts +7 -0
- package/lib/util_modules/constants/lib/signals-publishers.d.ts +9 -0
- package/lib/util_modules/constants/lib/template.d.ts +65 -0
- package/lib/util_modules/constants/lib/urls.d.ts +26 -0
- package/lib/util_modules/constants/lib/urls.js +12 -1
- package/lib/util_modules/constants/project.d.ts +4 -0
- package/lib/util_modules/container.d.ts +3 -0
- package/lib/util_modules/container.js +176 -0
- package/lib/util_modules/dc.d.ts +10 -0
- package/lib/{dc.js → util_modules/dc.js} +14 -18
- package/lib/util_modules/env.d.ts +7 -0
- package/lib/util_modules/env.js +3 -2
- package/lib/util_modules/fs/index.d.ts +3 -0
- package/lib/util_modules/fs/lib/async.d.ts +53 -0
- package/lib/util_modules/fs/lib/async.js +30 -1
- package/lib/util_modules/fs/lib/sync.d.ts +39 -0
- package/lib/util_modules/fs/lib/sync.js +24 -16
- package/lib/util_modules/fs/utils.d.ts +1 -0
- package/lib/util_modules/global-space.d.ts +1 -0
- package/lib/util_modules/js.d.ts +10 -0
- package/lib/util_modules/logger/index.d.ts +19 -0
- package/lib/util_modules/logger/index.js +80 -0
- package/lib/util_modules/logger/utils.d.ts +29 -0
- package/lib/util_modules/logger/utils.js +66 -0
- package/lib/util_modules/logger/winston.d.ts +9 -0
- package/lib/util_modules/logger/winston.js +90 -0
- package/lib/util_modules/option.d.ts +5 -0
- package/lib/util_modules/option.js +5 -5
- package/lib/util_modules/project.d.ts +70 -0
- package/lib/util_modules/project.js +26 -20
- package/lib/util_modules/runtime-store.d.ts +11 -0
- package/lib/util_modules/runtime-store.js +16 -0
- package/lib/util_modules/server.d.ts +13 -0
- package/lib/util_modules/server.js +78 -1
- package/lib/util_modules/shell.d.ts +21 -0
- package/lib/util_modules/shell.js +19 -4
- package/lib/util_modules/toml.d.ts +2 -0
- package/lib/util_modules/{parser/toml.js → toml.js} +3 -3
- package/package.json +6 -5
- package/templates/init/functions/java/event/sample.java +5 -8
- package/templates/init/functions/node/cron/types/cron.d.ts +1 -1
- package/templates/init/functions/node/event/sample.js +1 -12
- package/templates/init/functions/python/event/sample.py +0 -9
- package/templates/init/functions/python/integ/cliq/sample.py +1 -12
- package/docs/commands/signals/generate/index.toml +0 -19
- package/docs/commands/slate/unlink.toml +0 -9
- package/docs/commands/zest/generate/index.toml +0 -4
- package/docs/fn-utils/lib/ensure-java-userconfig.toml +0 -15
- package/docs/fn-utils/lib/java.toml +0 -34
- package/docs/serve/server/lib/slate/index.toml +0 -15
- package/docs/slate-utils.toml +0 -9
- package/lib/config-store.js +0 -10
- package/lib/fn-utils/lib/ensure-java-userconfig.js +0 -145
- package/lib/fn-utils/lib/java.js +0 -512
- package/lib/shell/dependencies/local-function.js +0 -483
- package/lib/util_modules/char.js +0 -12
- package/lib/util_modules/constants/lib/auth.js +0 -37
- package/lib/util_modules/logger.js +0 -51
- package/lib/winston.js +0 -75
- /package/lib/{internal → authentication}/crypt.js +0 -0
- /package/{docs/internal → lib/authentication/docs}/credential.toml +0 -0
- /package/{docs/authentication → lib/authentication/docs}/index.toml +0 -0
- /package/{docs/authentication → lib/authentication/docs}/login.toml +0 -0
- /package/{docs → lib/docs}/apig-utils.toml +0 -0
- /package/{docs → lib/docs}/client-utils.toml +0 -0
- /package/{docs → lib/docs}/command_needs/auth.toml +0 -0
- /package/{docs → lib/docs}/command_needs/rc.toml +0 -0
- /package/{docs → lib/docs}/commands/apig/disable.toml +0 -0
- /package/{docs → lib/docs}/commands/apig/enable.toml +0 -0
- /package/{docs → lib/docs}/commands/apig/status.toml +0 -0
- /package/{docs → lib/docs}/commands/client/delete.toml +0 -0
- /package/{docs → lib/docs}/commands/ds/export.toml +0 -0
- /package/{docs → lib/docs}/commands/ds/import.toml +0 -0
- /package/{docs → lib/docs}/commands/ds/status.toml +0 -0
- /package/{docs → lib/docs}/commands/event/generate/index.toml +0 -0
- /package/{docs → lib/docs}/commands/event/generate/integ.toml +0 -0
- /package/{docs → lib/docs}/commands/event/generate/job.toml +0 -0
- /package/{docs → lib/docs}/commands/functions/config.toml +0 -0
- /package/{docs → lib/docs}/commands/functions/delete.toml +0 -0
- /package/{docs → lib/docs}/commands/functions/shell.toml +0 -0
- /package/{docs → lib/docs}/commands/iac/export.toml +0 -0
- /package/{docs → lib/docs}/commands/iac/import.toml +0 -0
- /package/{docs → lib/docs}/commands/iac/status.toml +0 -0
- /package/{docs → lib/docs}/commands/project/use.toml +0 -0
- /package/{docs → lib/docs}/dc.toml +0 -0
- /package/{docs → lib/docs}/deploy/features/apig.toml +0 -0
- /package/{docs → lib/docs}/deploy/features/functions/index.toml +0 -0
- /package/{docs → lib/docs}/endpoints/lib/env.toml +0 -0
- /package/{docs → lib/docs}/endpoints/lib/job-scheduling.toml +0 -0
- /package/{docs → lib/docs}/event_generate/cache.toml +0 -0
- /package/{docs → lib/docs}/event_generate/custom.toml +0 -0
- /package/{docs → lib/docs}/event_generate/datastore.toml +0 -0
- /package/{docs → lib/docs}/event_generate/filestore.toml +0 -0
- /package/{docs → lib/docs}/event_generate/integration/cliq.toml +0 -0
- /package/{docs → lib/docs}/execute-script.toml +0 -0
- /package/{docs → lib/docs}/fn-utils/lib/common.toml +0 -0
- /package/{docs → lib/docs}/fn-utils/lib/node.toml +0 -0
- /package/{docs → lib/docs}/fn-utils/lib/python.toml +0 -0
- /package/{docs → lib/docs}/iac/status/bundle.toml +0 -0
- /package/{docs → lib/docs}/init/dependencies/python/ensure-python.toml +0 -0
- /package/{docs → lib/docs}/init/dependencies/python/pip-install.toml +0 -0
- /package/{docs → lib/docs}/init/index.toml +0 -0
- /package/{docs → lib/docs}/internal/command.toml +0 -0
- /package/{docs → lib/docs}/internal/config.toml +0 -0
- /package/{docs → lib/docs}/optional-import.toml +0 -0
- /package/{docs → lib/docs}/plugin-loader.toml +0 -0
- /package/{docs → lib/docs}/port-resolver.toml +0 -0
- /package/{docs → lib/docs}/pull/index.toml +0 -0
- /package/{docs → lib/docs}/serve/index.toml +0 -0
- /package/{docs → lib/docs}/serve/server/index.toml +0 -0
- /package/{docs → lib/docs}/serve/server/lib/appsail/index.toml +0 -0
- /package/{docs → lib/docs}/serve/server/lib/web_client/server.toml +0 -0
- /package/{docs → lib/docs}/shell/dependencies/tunnel-server.toml +0 -0
- /package/{docs → lib/docs}/shell/index.toml +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/.classpath +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/.project +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/catalyst-config.json +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/playwright/sample.java +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/.classpath +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/.project +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/catalyst-config.json +0 -0
- /package/templates/init/functions/java/{browserLogic → browserlogic}/selenium/sample.java +0 -0
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.checkIfRuntimeServerRunning = void 0;
|
|
16
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
16
17
|
const better_queue_1 = __importDefault(require("better-queue"));
|
|
17
18
|
const express_1 = __importDefault(require("express"));
|
|
18
19
|
const path_1 = require("path");
|
|
@@ -24,20 +25,21 @@ const logger_1 = __importDefault(require("../../express_middlewares/logger"));
|
|
|
24
25
|
const project_1 = __importDefault(require("../../express_middlewares/project"));
|
|
25
26
|
const fn_utils_1 = require("../../fn-utils");
|
|
26
27
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
28
|
+
const utils_1 = require("../../serve/server/lib/master/utils");
|
|
27
29
|
const constants_1 = require("../../util_modules/constants");
|
|
28
30
|
const runtime_1 = __importDefault(require("../../util_modules/constants/lib/runtime"));
|
|
29
31
|
const fs_1 = require("../../util_modules/fs");
|
|
30
32
|
const js_1 = require("../../util_modules/js");
|
|
31
|
-
const
|
|
32
|
-
const logger_2 = require("../../util_modules/logger");
|
|
33
|
+
const index_1 = require("../../util_modules/logger/index");
|
|
33
34
|
const project_2 = require("../../util_modules/project");
|
|
34
35
|
const shell_1 = require("../../util_modules/shell");
|
|
35
36
|
const request_1 = __importDefault(require("request"));
|
|
36
|
-
const ensure_java_userconfig_1 = require("../../fn-utils/lib/ensure-java-userconfig");
|
|
37
|
+
const ensure_java_userconfig_1 = require("../../fn-utils/lib/java/ensure-java-userconfig");
|
|
37
38
|
const option_1 = require("../../util_modules/option");
|
|
38
39
|
const server_1 = require("../../util_modules/server");
|
|
40
|
+
const port_resolver_1 = __importDefault(require("../../port-resolver"));
|
|
39
41
|
const logUrl = (name, pthName, httpPort, masterPort) => {
|
|
40
|
-
(0,
|
|
42
|
+
(0, index_1.labeled)(`functions(${name})`, 'URL => http://localhost:' + (masterPort === -1 ? httpPort : masterPort) + pthName).MESSAGE();
|
|
41
43
|
};
|
|
42
44
|
const checkIfRuntimeServerRunning = (port, itr = 0) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
45
|
if (itr > 50) {
|
|
@@ -45,7 +47,7 @@ const checkIfRuntimeServerRunning = (port, itr = 0) => __awaiter(void 0, void 0,
|
|
|
45
47
|
exit: 2
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
return new Promise((res) => {
|
|
50
|
+
return new Promise((res, reject) => {
|
|
49
51
|
request_1.default
|
|
50
52
|
.get(`http://127.0.0.1:${port}/ruok`, {
|
|
51
53
|
headers: {
|
|
@@ -53,13 +55,15 @@ const checkIfRuntimeServerRunning = (port, itr = 0) => __awaiter(void 0, void 0,
|
|
|
53
55
|
}
|
|
54
56
|
})
|
|
55
57
|
.on('response', (_response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
(0,
|
|
58
|
+
(0, index_1.debug)(`ruok response: ${_response.statusCode}: ${_response.statusMessage}`);
|
|
57
59
|
if (_response.statusCode === 200) {
|
|
58
60
|
res(true);
|
|
59
61
|
}
|
|
60
62
|
else if (_response.statusCode === 503) {
|
|
61
63
|
yield js_1.JS.sleep(100);
|
|
62
|
-
yield (0, exports.checkIfRuntimeServerRunning)(port, ++itr)
|
|
64
|
+
yield (0, exports.checkIfRuntimeServerRunning)(port, ++itr)
|
|
65
|
+
.then((x) => res(x))
|
|
66
|
+
.catch((er) => reject(er));
|
|
63
67
|
}
|
|
64
68
|
else {
|
|
65
69
|
yield js_1.JS.sleep(500);
|
|
@@ -73,7 +77,9 @@ const checkIfRuntimeServerRunning = (port, itr = 0) => __awaiter(void 0, void 0,
|
|
|
73
77
|
const incomingError = error_1.default.getErrorInstance(error).original;
|
|
74
78
|
if (incomingError.code === 'ECONNREFUSED' || incomingError.code === 'ECONNRESET') {
|
|
75
79
|
yield js_1.JS.sleep(100);
|
|
76
|
-
yield (0, exports.checkIfRuntimeServerRunning)(port, ++itr)
|
|
80
|
+
yield (0, exports.checkIfRuntimeServerRunning)(port, ++itr)
|
|
81
|
+
.then((x) => res(x))
|
|
82
|
+
.catch((er) => reject(er));
|
|
77
83
|
}
|
|
78
84
|
else {
|
|
79
85
|
throw new error_1.default('Unable to spin up python runtime server. ErrorCode: ' + incomingError.code, {
|
|
@@ -102,7 +108,7 @@ class HttpFunctions {
|
|
|
102
108
|
this.runningSlaves = [];
|
|
103
109
|
this.targets = [];
|
|
104
110
|
this.q = new better_queue_1.default((opts, cb) => {
|
|
105
|
-
var _a, _b;
|
|
111
|
+
var _a, _b, _c, _d;
|
|
106
112
|
fs_1.SYNC.ensureFile(this.responseFile, true);
|
|
107
113
|
fs_1.SYNC.ensureFile(this.requestFile, true);
|
|
108
114
|
fs_1.SYNC.ensureFile(this.metaFile, true);
|
|
@@ -119,21 +125,22 @@ class HttpFunctions {
|
|
|
119
125
|
stdio: 'pipe',
|
|
120
126
|
env: Object.assign({ X_ZOHO_CATALYST_IS_LOCAL: 'true', X_ZOHO_CATALYST_FUNCTION_LOADED: 'true', X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, CATALYST_PORTAL_DOMAIN: constants_1.ORIGIN.iamPortal, CATALYST_PROJECT_TIMEZONE: (0, project_2.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone) }, opts.envVars)
|
|
121
127
|
}).RAW();
|
|
122
|
-
(_a = slave.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (
|
|
123
|
-
|
|
128
|
+
(_a = slave.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (chunk) => {
|
|
129
|
+
const logs = Buffer.isBuffer(chunk) ? chunk.toString().split('\n') : [chunk];
|
|
130
|
+
logs.forEach((logStr) => (0, index_1.log)('info', `[${(0, ansi_colors_1.bold)(opts.id || 'function')}] ${logStr}`, true));
|
|
124
131
|
});
|
|
125
|
-
(_b = slave.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (
|
|
126
|
-
const
|
|
127
|
-
(0,
|
|
132
|
+
(_b = slave.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (chunk) => {
|
|
133
|
+
const logs = Buffer.isBuffer(chunk) ? chunk.toString().split('\n') : [chunk];
|
|
134
|
+
logs.forEach((logStr) => (0, index_1.log)('error', `[${(0, ansi_colors_1.bold)(opts.id || 'function')}] ${logStr}`, true));
|
|
128
135
|
});
|
|
129
136
|
slave.on('uncaughtException', (err, origin) => {
|
|
130
137
|
const errorString = `Caught exception: ${err}\n` + `Exception origin: ${origin}`;
|
|
131
|
-
(0,
|
|
138
|
+
(0, index_1.error)(errorString);
|
|
132
139
|
cb(errorString, null);
|
|
133
140
|
});
|
|
134
141
|
slave.on('exit', (code) => {
|
|
135
142
|
if (!fs_1.SYNC.fileExists(this.responseFile)) {
|
|
136
|
-
(0,
|
|
143
|
+
(0, index_1.debug)(`${this.responseFile} not present`);
|
|
137
144
|
cb(new Error('File does not exists: ' + this.responseFile));
|
|
138
145
|
return;
|
|
139
146
|
}
|
|
@@ -157,10 +164,29 @@ class HttpFunctions {
|
|
|
157
164
|
break;
|
|
158
165
|
}
|
|
159
166
|
});
|
|
167
|
+
if (opts.debug) {
|
|
168
|
+
const debugListener = (data) => {
|
|
169
|
+
const str = Buffer.isBuffer(data) ? data.toString() : data;
|
|
170
|
+
if (opts.command.endsWith('node')) {
|
|
171
|
+
str.includes('Debugger listening') && startDebug();
|
|
172
|
+
}
|
|
173
|
+
else if (opts.command.endsWith('java')) {
|
|
174
|
+
str.includes('Listening for transport dt_socket') && startDebug();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const startDebug = () => {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
utils_1.serverEvent.emit('connection');
|
|
180
|
+
(_a = slave.stdout) === null || _a === void 0 ? void 0 : _a.removeListener('data', debugListener);
|
|
181
|
+
(_b = slave.stderr) === null || _b === void 0 ? void 0 : _b.removeListener('data', debugListener);
|
|
182
|
+
};
|
|
183
|
+
(_c = slave.stdout) === null || _c === void 0 ? void 0 : _c.once('data', debugListener);
|
|
184
|
+
(_d = slave.stderr) === null || _d === void 0 ? void 0 : _d.once('data', debugListener);
|
|
185
|
+
}
|
|
160
186
|
this.runningSlaves.push(slave);
|
|
161
187
|
}, { batchSize: 1, concurrent: 1, maxTimeout: Infinity }).on('task_failed', (targetName, err) => {
|
|
162
|
-
(0,
|
|
163
|
-
(0,
|
|
188
|
+
(0, index_1.debug)('Unable to serve the function: ' + targetName);
|
|
189
|
+
(0, index_1.debug)(err);
|
|
164
190
|
});
|
|
165
191
|
}
|
|
166
192
|
_spinUpServer() {
|
|
@@ -186,7 +212,7 @@ class HttpFunctions {
|
|
|
186
212
|
this.app.use(authenticator_1.default);
|
|
187
213
|
}
|
|
188
214
|
const reqHandler = (fnTarget) => (request, response, next) => {
|
|
189
|
-
var _a, _b;
|
|
215
|
+
var _a, _b, _c, _d;
|
|
190
216
|
const urlParts = new url_1.URL(request.originalUrl, request.protocol + '://' + request.get('host')).searchParams;
|
|
191
217
|
const query = JSON.stringify(Object.fromEntries(urlParts.entries()));
|
|
192
218
|
const slaveOptions = [];
|
|
@@ -197,8 +223,11 @@ class HttpFunctions {
|
|
|
197
223
|
exit: 2
|
|
198
224
|
});
|
|
199
225
|
}
|
|
200
|
-
const slaveFnTarget = {
|
|
201
|
-
|
|
226
|
+
const slaveFnTarget = {
|
|
227
|
+
index: (_a = fnTarget.index) === null || _a === void 0 ? void 0 : _a.replace((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.functions, fnTarget.name) + path_1.sep, ''),
|
|
228
|
+
name: fnTarget.name
|
|
229
|
+
};
|
|
230
|
+
if ((_b = fnTarget.stack) === null || _b === void 0 ? void 0 : _b.startsWith(runtime_1.default.language.node.value)) {
|
|
202
231
|
if (debugPort !== -1) {
|
|
203
232
|
slaveOptions.push('--inspect-brk=' + debugPort);
|
|
204
233
|
}
|
|
@@ -226,10 +255,11 @@ class HttpFunctions {
|
|
|
226
255
|
pth: (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, fnTarget.name),
|
|
227
256
|
req: request,
|
|
228
257
|
id: fnTarget.name,
|
|
258
|
+
debug: debugPort !== -1,
|
|
229
259
|
envVars: fnTarget.env_var
|
|
230
260
|
});
|
|
231
261
|
}
|
|
232
|
-
else if ((
|
|
262
|
+
else if ((_c = fnTarget.stack) === null || _c === void 0 ? void 0 : _c.startsWith(runtime_1.default.language.java.value)) {
|
|
233
263
|
const invoker = fnTarget.type === constants_1.FN_TYPE.basic
|
|
234
264
|
? this.javaInvoker[fnTarget.type] + `/${fnTarget.stack}/JavabioInvoker`
|
|
235
265
|
: this.javaInvoker[fnTarget.type];
|
|
@@ -262,9 +292,7 @@ class HttpFunctions {
|
|
|
262
292
|
'x-zc-cookie': request.headers['x-zc-cookie'],
|
|
263
293
|
'x-zc-user-type': request.headers['x-zc-user-type']
|
|
264
294
|
}));
|
|
265
|
-
const
|
|
266
|
-
const userConfigCmd = userConfig_1.default.get(configKey);
|
|
267
|
-
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)(userConfigCmd, 'java', fnTarget.stack);
|
|
295
|
+
const spawnCommand = (0, ensure_java_userconfig_1.getJavaSpawnCommand)('java', (_d = fnTarget.additionalInfo) === null || _d === void 0 ? void 0 : _d.binPath);
|
|
268
296
|
slave = this.q.push({
|
|
269
297
|
command: spawnCommand,
|
|
270
298
|
options: slaveOptions,
|
|
@@ -272,6 +300,7 @@ class HttpFunctions {
|
|
|
272
300
|
pth: (0, path_1.join)(runtime_store_1.default.get('project.root'), constants_1.FOLDERNAME.build, constants_1.FOLDERNAME.functions, fnTarget.name),
|
|
273
301
|
req: request,
|
|
274
302
|
id: fnTarget.name,
|
|
303
|
+
debug: debugPort !== -1,
|
|
275
304
|
envVars: fnTarget.env_var
|
|
276
305
|
});
|
|
277
306
|
}
|
|
@@ -349,7 +378,7 @@ class HttpFunctions {
|
|
|
349
378
|
}
|
|
350
379
|
});
|
|
351
380
|
(_b = target.watcher) === null || _b === void 0 ? void 0 : _b.on('compiled', () => {
|
|
352
|
-
(0,
|
|
381
|
+
(0, index_1.labeled)(`functions[${target.name}]`, 'ready!').MESSAGE();
|
|
353
382
|
logUrl(target.name, new url_1.URL(target.url).pathname, httpPort, masterPort);
|
|
354
383
|
if (this.repl && this.repl.paused) {
|
|
355
384
|
this.repl.resume();
|
|
@@ -367,6 +396,10 @@ class HttpFunctions {
|
|
|
367
396
|
if (this.repl !== undefined) {
|
|
368
397
|
this.repl.showPrompt();
|
|
369
398
|
}
|
|
399
|
+
server.once('close', () => {
|
|
400
|
+
port_resolver_1.default.freePort(httpPort);
|
|
401
|
+
port_resolver_1.default.freePort(debugPort);
|
|
402
|
+
});
|
|
370
403
|
res(server);
|
|
371
404
|
});
|
|
372
405
|
});
|
|
@@ -266,7 +266,7 @@ public class JavacronInvoker {
|
|
|
266
266
|
|
|
267
267
|
defaultCron.setCronDetails(userData.get("cron_details") != null ? (JSONObject) userData.get("cron_details") : null);
|
|
268
268
|
defaultCron.setRemainingExecutionCount(userData.get("remaining_count") != null ? (Integer) userData.get("remaining_count") : -1);
|
|
269
|
-
defaultCron.setCronParam(jsonToMap(userData.get("data")));
|
|
269
|
+
defaultCron.setCronParam(jsonToMap(userData.get("data") != null ? userData.get("data") : new JSONObject()));
|
|
270
270
|
defaultCron.setProjectDetails(userData.get("project_details") != null ? (JSONObject) userData.get("project_details") : new JSONObject(projectData));
|
|
271
271
|
CronRequest cronRequest = defaultCron;
|
|
272
272
|
|
|
@@ -19,6 +19,7 @@ import java.util.logging.LogRecord;
|
|
|
19
19
|
import java.util.logging.Logger;
|
|
20
20
|
import java.util.logging.SimpleFormatter;
|
|
21
21
|
|
|
22
|
+
import org.json.JSONException;
|
|
22
23
|
import org.json.JSONObject;
|
|
23
24
|
|
|
24
25
|
import com.catalyst.Context;
|
|
@@ -29,6 +30,38 @@ import com.catalyst.impl.DefaultContext;
|
|
|
29
30
|
import com.catalyst.job.JobRequest;
|
|
30
31
|
import com.catalyst.job.impl.DefaultJobRequest;
|
|
31
32
|
|
|
33
|
+
class ZcJSONObject extends JSONObject {
|
|
34
|
+
|
|
35
|
+
ZcJSONObject(String jsonString) throws JSONException {
|
|
36
|
+
super(jsonString);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public long getLong(String key, boolean throwErr) throws JSONException {
|
|
40
|
+
try {
|
|
41
|
+
return super.getLong(key);
|
|
42
|
+
} catch (JSONException ex) {
|
|
43
|
+
if(throwErr) {
|
|
44
|
+
throw ex;
|
|
45
|
+
}
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public ZcJSONObject getJSONObject(String key) throws JSONException {
|
|
51
|
+
return this.getJSONObject(key, false);
|
|
52
|
+
}
|
|
53
|
+
public ZcJSONObject getJSONObject(String key, boolean throwErr) throws JSONException {
|
|
54
|
+
try {
|
|
55
|
+
return new ZcJSONObject(super.getJSONObject(key).toString());
|
|
56
|
+
} catch(JSONException ex) {
|
|
57
|
+
if(throwErr) {
|
|
58
|
+
throw ex;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
32
65
|
public class JavajobInvoker {
|
|
33
66
|
|
|
34
67
|
private static final Integer MESSAGE_LENGTH = 1500;
|
|
@@ -186,7 +219,12 @@ public class JavajobInvoker {
|
|
|
186
219
|
String fnName = (String) target.get("name");
|
|
187
220
|
String fnExePath = Paths.get(invokerDir, "../../", "functions", fnName).normalize().toString();
|
|
188
221
|
|
|
189
|
-
|
|
222
|
+
ZcJSONObject userData = null;
|
|
223
|
+
try {
|
|
224
|
+
userData = new ZcJSONObject(args[2]);
|
|
225
|
+
} catch (JSONException jsonEx) {
|
|
226
|
+
// do not handle the exception
|
|
227
|
+
}
|
|
190
228
|
HashMap<String, Object> projectData = jsonToMap(args[3]);
|
|
191
229
|
HashMap<String, Object> authData = jsonToMap(args[4]);
|
|
192
230
|
|
|
@@ -211,21 +249,24 @@ public class JavajobInvoker {
|
|
|
211
249
|
setZCThreadLocalProject(projectData);
|
|
212
250
|
setZCThreadLocalAuth(authData);
|
|
213
251
|
|
|
252
|
+
|
|
253
|
+
// construct job details from input data
|
|
254
|
+
ZcJSONObject jobDetails = userData.getJSONObject("job_details");
|
|
255
|
+
ZcJSONObject jobMetaDetails = jobDetails != null ? jobDetails.getJSONObject("job_meta_details") : null;
|
|
256
|
+
ZcJSONObject jobpoolDetails = jobMetaDetails != null ? jobMetaDetails.getJSONObject("jobpool_details") : null;
|
|
257
|
+
ZcJSONObject projectDetails = jobpoolDetails != null ? jobpoolDetails.getJSONObject("project_details") : null;
|
|
258
|
+
ZcJSONObject capacity = userData.getJSONObject("capacity");
|
|
259
|
+
ZcJSONObject params = jobMetaDetails != null ? jobMetaDetails.getJSONObject("params") : null;
|
|
260
|
+
|
|
261
|
+
// construct default job request from input job details
|
|
214
262
|
DefaultJobRequest defaultJob = new DefaultJobRequest();
|
|
215
263
|
|
|
216
|
-
JSONObject jobDetails = userData.getJSONObject("job_details");
|
|
217
|
-
JSONObject jobMetaDetails = jobDetails.getJSONObject("job_meta_details");
|
|
218
|
-
JSONObject jobpoolDetails = jobMetaDetails.getJSONObject("jobpool_details");
|
|
219
|
-
JSONObject projectDetails = jobpoolDetails.getJSONObject("project_details");
|
|
220
|
-
JSONObject capacity = userData.getJSONObject("capacity");
|
|
221
|
-
JSONObject params = jobMetaDetails.getJSONObject("params");
|
|
222
|
-
|
|
223
264
|
defaultJob.setJobDetails(jobDetails != null ? (JSONObject) jobDetails : new JSONObject());
|
|
224
265
|
defaultJob.setJobMetaDetails(jobMetaDetails != null ? (JSONObject) jobDetails : new JSONObject());
|
|
225
266
|
defaultJob.setJobpoolDetails(jobpoolDetails != null ? (JSONObject) jobpoolDetails : new JSONObject());
|
|
226
|
-
defaultJob.setProjectDetails(projectDetails);
|
|
267
|
+
defaultJob.setProjectDetails(projectDetails != null ? (JSONObject) projectDetails : new JSONObject());
|
|
227
268
|
CapacityAttributes capacityAttributes = CapacityAttributes.getInstance();
|
|
228
|
-
capacityAttributes.setMemory(capacity.getLong("memory"));
|
|
269
|
+
capacityAttributes.setMemory(capacity != null ? capacity.getLong("memory") : 0l);
|
|
229
270
|
defaultJob.setJobCapacity(capacityAttributes);
|
|
230
271
|
defaultJob.setJobParams(jsonToMap(params != null ? params.toString() : new JSONObject().toString()));
|
|
231
272
|
|
|
@@ -61,8 +61,8 @@ const context = {
|
|
|
61
61
|
const jobReq = {
|
|
62
62
|
getJobDetails: () => ('job_details' in userData ? userData.job_details : {}),
|
|
63
63
|
getJobMetaDetails: () => jobReq.getJobDetails()?.job_meta_details || {},
|
|
64
|
-
|
|
65
|
-
getProjectDetails: () => jobReq.
|
|
64
|
+
getJobPoolDetails: () => jobReq.getJobMetaDetails()?.jobpool_details || {},
|
|
65
|
+
getProjectDetails: () => jobReq.getJobPoolDetails()?.project_details || {},
|
|
66
66
|
getJobCapacityAttributes: () => jobReq.getJobDetails()?.capacity || {},
|
|
67
67
|
getAllJobParams: () => jobReq.getJobMetaDetails()?.params || {},
|
|
68
68
|
getJobParam: (key) => (jobReq.getAllJobParams() || {})[key]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { ChildProcess } from 'child_process';
|
|
4
|
+
import { IFnTarget } from '../../../fn-utils/lib/common';
|
|
5
|
+
import { IServerDetails } from '../../../serve/server';
|
|
6
|
+
import { FnHandler } from './fn-handler';
|
|
7
|
+
import { EventEmitter } from 'stream';
|
|
8
|
+
import { ContainerEvents } from '@zcatalyst/container-plugin';
|
|
9
|
+
export declare class FnExecutionHandler extends FnHandler {
|
|
10
|
+
constructor(serverDetails: IServerDetails<IFnTarget>, localFnEvents: EventEmitter);
|
|
11
|
+
execute(data: Record<string, unknown>, accessToken: string): Promise<ChildProcess>;
|
|
12
|
+
executeWithContainer(data: Record<string, unknown>, accessToken: string): Promise<ContainerEvents>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.FnExecutionHandler = void 0;
|
|
39
|
+
const child_process_1 = require("child_process");
|
|
40
|
+
const fn_handler_1 = require("./fn-handler");
|
|
41
|
+
const fn_utils_1 = require("../../../fn-utils");
|
|
42
|
+
const path_1 = require("path");
|
|
43
|
+
const node_1 = __importDefault(require("./node"));
|
|
44
|
+
const java_1 = __importDefault(require("./java"));
|
|
45
|
+
const python_1 = __importDefault(require("./python"));
|
|
46
|
+
const project_1 = require("../../../util_modules/project");
|
|
47
|
+
const constants_1 = require("../../../util_modules/constants");
|
|
48
|
+
const error_1 = __importDefault(require("../../../error"));
|
|
49
|
+
const port_resolver_1 = __importDefault(require("../../../port-resolver"));
|
|
50
|
+
const http_functions_1 = require("../http-functions");
|
|
51
|
+
const logger_1 = require("../../../util_modules/logger");
|
|
52
|
+
const container_plugin_1 = require("@zcatalyst/container-plugin");
|
|
53
|
+
const ansi_colors_1 = require("ansi-colors");
|
|
54
|
+
const env_1 = require("../../../util_modules/env");
|
|
55
|
+
const server_1 = require("../../../util_modules/server");
|
|
56
|
+
const utils_1 = require("../../../serve/server/lib/master/utils");
|
|
57
|
+
const readline_1 = __importDefault(require("readline"));
|
|
58
|
+
class FnExecutionHandler extends fn_handler_1.FnHandler {
|
|
59
|
+
constructor(serverDetails, localFnEvents) {
|
|
60
|
+
super(serverDetails, localFnEvents);
|
|
61
|
+
}
|
|
62
|
+
execute(data, accessToken) {
|
|
63
|
+
var _a, _b, _c, _d, _e;
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const projectRoot = (0, project_1.getProjectRoot)();
|
|
66
|
+
const slaveFnTarget = {
|
|
67
|
+
index: (_b = (_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.index) === null || _b === void 0 ? void 0 : _b.replace((0, path_1.join)(projectRoot, constants_1.FOLDERNAME.functions, this.fn.target.name) + path_1.sep, ''),
|
|
68
|
+
name: (_c = this.fn.target) === null || _c === void 0 ? void 0 : _c.name
|
|
69
|
+
};
|
|
70
|
+
switch (this.stack) {
|
|
71
|
+
case 'node': {
|
|
72
|
+
this.slave = (0, node_1.default)(this.fn, JSON.stringify(data), { slaveFnTarget, accessToken });
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 'java': {
|
|
76
|
+
const javaInvoker = (0, path_1.join)(projectRoot, constants_1.FOLDERNAME.build, '.catalyst', this.fn.target.stack, 'Java' + this.fn.target.type + 'Invoker');
|
|
77
|
+
fn_utils_1.fnUtils.java.ensureJavaInvoker(javaInvoker, (0, path_1.normalize)((0, path_1.join)(__dirname, '../invoker', this.fn.target.type, 'java', 'Java' + this.fn.target.type + 'Invoker.java')), this.fn.target);
|
|
78
|
+
this.slave = (0, java_1.default)(this.fn, JSON.stringify(data), {
|
|
79
|
+
javaInvoker,
|
|
80
|
+
slaveFnTarget,
|
|
81
|
+
accessToken
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'python': {
|
|
86
|
+
const pyFn = this.fn;
|
|
87
|
+
this.slave = yield (0, python_1.default)(pyFn);
|
|
88
|
+
const attachVsCodeDebugger = (port) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
try {
|
|
90
|
+
yield (0, server_1.isPortListening)(port, 25, env_1.isWindows ? 1000 : 500).catch((er) => (0, logger_1.debug)('error listening for port: ' + port, er));
|
|
91
|
+
utils_1.serverEvent.emit('connection');
|
|
92
|
+
yield new Promise((res, rej) => {
|
|
93
|
+
const connTimeout = setTimeout(() => rej('debugger connection timeout'), 10000);
|
|
94
|
+
utils_1.serverEvent.once('attach', () => {
|
|
95
|
+
clearTimeout(connTimeout);
|
|
96
|
+
res();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (er) {
|
|
101
|
+
utils_1.serverEvent.emit('error', er);
|
|
102
|
+
this.kill();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
if (!(this.slave instanceof child_process_1.ChildProcess)) {
|
|
107
|
+
throw new error_1.default('Slave not an instance of Child process', {
|
|
108
|
+
context: this.slave,
|
|
109
|
+
exit: 2
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const debugConfig = (_d = pyFn.target.additionalInfo) === null || _d === void 0 ? void 0 : _d.debug;
|
|
113
|
+
if (this.fn.target.type === 'job') {
|
|
114
|
+
if (debugConfig && env_1.isVsCode) {
|
|
115
|
+
yield attachVsCodeDebugger(debugConfig.port);
|
|
116
|
+
}
|
|
117
|
+
const httpPort = yield port_resolver_1.default.getFreePort(constants_1.DEFAULT.serve_port.http[(_e = this.fn.target) === null || _e === void 0 ? void 0 : _e.type], 200);
|
|
118
|
+
this.processFlowHandler(data, httpPort);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
new Promise((resolve, reject) => {
|
|
122
|
+
var _a;
|
|
123
|
+
(_a = this.slave) === null || _a === void 0 ? void 0 : _a.once('spawn', () => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
try {
|
|
125
|
+
if (debugConfig) {
|
|
126
|
+
if (env_1.isVsCode) {
|
|
127
|
+
yield attachVsCodeDebugger(debugConfig.port);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
yield new Promise((res, rej) => {
|
|
131
|
+
try {
|
|
132
|
+
const rl = readline_1.default.createInterface({
|
|
133
|
+
input: process.stdin,
|
|
134
|
+
output: process.stdout,
|
|
135
|
+
terminal: true
|
|
136
|
+
});
|
|
137
|
+
rl.on('line', () => {
|
|
138
|
+
rl.close();
|
|
139
|
+
res();
|
|
140
|
+
});
|
|
141
|
+
(0, logger_1.info)();
|
|
142
|
+
(0, logger_1.info)(`${(0, ansi_colors_1.dim)('>> ')} Please attach a ${(0, ansi_colors_1.bold)('DEBUGGER')} and press ${(0, ansi_colors_1.bold)('ANY KEY')} to continue executing the ${(0, ansi_colors_1.bold)(pyFn.target.name)} function`);
|
|
143
|
+
(0, logger_1.info)();
|
|
144
|
+
}
|
|
145
|
+
catch (er) {
|
|
146
|
+
rej(er);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
yield (0, http_functions_1.checkIfRuntimeServerRunning)(this.fn.httpPort.toString());
|
|
152
|
+
yield this.fnRequestHandler({
|
|
153
|
+
httpPort: this.fn.httpPort,
|
|
154
|
+
data,
|
|
155
|
+
accessToken
|
|
156
|
+
}).finally(() => this.kill());
|
|
157
|
+
resolve();
|
|
158
|
+
}
|
|
159
|
+
catch (er) {
|
|
160
|
+
const _er = error_1.default.getErrorInstance(er);
|
|
161
|
+
reject(_er);
|
|
162
|
+
}
|
|
163
|
+
}));
|
|
164
|
+
}).catch((err) => {
|
|
165
|
+
(0, logger_1.debug)('Error with fnRequestHandling flow: ', err);
|
|
166
|
+
this.localFnEvents.emit('error', err);
|
|
167
|
+
});
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
default: {
|
|
171
|
+
throw new error_1.default('Invalid stack for fn execution handling: ' + this.stack, {
|
|
172
|
+
exit: 2
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return this.slave;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
executeWithContainer(data, accessToken) {
|
|
180
|
+
var _a, _b, _c, _d, _e;
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
(0, logger_1.debug)('using container to serve the function: ' + ((_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.name));
|
|
183
|
+
const container = yield Promise.resolve().then(() => __importStar(require('@zcatalyst/container-plugin')));
|
|
184
|
+
const httpPort = yield port_resolver_1.default.getFreePort(constants_1.DEFAULT.serve_port.http[(_b = this.fn.target) === null || _b === void 0 ? void 0 : _b.type], 200);
|
|
185
|
+
this.fn.target.env_var = Object.assign({ X_ZOHO_CATALYST_ACCOUNTS_URL: constants_1.ORIGIN.auth, X_ZOHO_CATALYST_CONSOLE_URL: constants_1.ORIGIN.admin, X_ZOHO_CATALYST_RESOURCE_ID: (_c = this.fn.target) === null || _c === void 0 ? void 0 : _c.id, X_ZOHO_STRATUS_RESOURCE_SUFFIX: constants_1.ORIGIN.stratusSuffix, X_ZOHO_CATALYST_CODE_LOCATION: '/catalyst/', CATALYST_PROJECT_TIMEZONE: (0, project_1.getProjectTimezone)(Intl.DateTimeFormat().resolvedOptions().timeZone), X_ZOHO_CATALYST_ORG: (0, project_1.getEnvId)(), X_ZOHO_ADMIN_CRED_TOKEN: accessToken, CATALYST_FUNCTION_TYPE: constants_1.REMOTE_REF.functions.type[(_d = this.fn.target) === null || _d === void 0 ? void 0 : _d.type] }, (_e = this.fn.target) === null || _e === void 0 ? void 0 : _e.env_var);
|
|
186
|
+
if (this.fn.target.type === 'job') {
|
|
187
|
+
const hostIp = 'host.docker.internal';
|
|
188
|
+
const sysEnvs = {
|
|
189
|
+
X_ZOHO_DATA_URL: `http://${hostIp}:${httpPort}/data`,
|
|
190
|
+
X_ZOHO_CALLBACK_URL: `http://${hostIp}:${httpPort}/callback`,
|
|
191
|
+
X_ZOHO_ADMIN_CRED_TYPE: 'token',
|
|
192
|
+
X_ZOHO_ADMIN_CRED_TOKEN: accessToken,
|
|
193
|
+
X_ZOHO_USER_CRED_TYPE: 'token',
|
|
194
|
+
X_ZOHO_USER_CRED_TOKEN: accessToken,
|
|
195
|
+
X_ZOHO_USER_TYPE: 'admin',
|
|
196
|
+
X_ZOHO_PROJECT_KEY: (0, project_1.getDomainKey)(),
|
|
197
|
+
X_ZOHO_PROJECTID: (0, project_1.getProjectId)(),
|
|
198
|
+
X_ZOHO_PROJECT_DOMAIN: (0, project_1.getDomainPrefix)() + '.' + constants_1.ORIGIN.app.replace('https://', ''),
|
|
199
|
+
X_ZOHO_CATALYST_ENVIRONMENT: 'Development',
|
|
200
|
+
CATALYST_API_DOMAIN: constants_1.ORIGIN.admin
|
|
201
|
+
};
|
|
202
|
+
this.fn.target.env_var = Object.assign(Object.assign({}, this.fn.target.env_var), sysEnvs);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
this.fn.httpPort = httpPort;
|
|
206
|
+
}
|
|
207
|
+
const pluginEvent = yield container.start({
|
|
208
|
+
details: this.fn,
|
|
209
|
+
projectId: (0, project_1.getProjectId)(),
|
|
210
|
+
ruok: this.fn.target.type === 'job'
|
|
211
|
+
? container_plugin_1.RUOK.SKIP
|
|
212
|
+
: this.fn.debugPort !== undefined && this.fn.debugPort !== -1
|
|
213
|
+
? container_plugin_1.RUOK.INFINITE
|
|
214
|
+
: container_plugin_1.RUOK.FINITE
|
|
215
|
+
});
|
|
216
|
+
pluginEvent.on('error', (er) => {
|
|
217
|
+
var _a;
|
|
218
|
+
(0, logger_1.debug)('Container Error: ', er);
|
|
219
|
+
(0, logger_1.info)();
|
|
220
|
+
(0, logger_1.error)(`Error running the function ${(0, ansi_colors_1.bold)(((_a = this.fn.target) === null || _a === void 0 ? void 0 : _a.name) + '')} in container`);
|
|
221
|
+
(0, logger_1.info)();
|
|
222
|
+
});
|
|
223
|
+
pluginEvent.emit('start', this.fn);
|
|
224
|
+
pluginEvent.once('ready', () => __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
var _f, _g;
|
|
226
|
+
try {
|
|
227
|
+
if (((_f = this.fn.target) === null || _f === void 0 ? void 0 : _f.type) === 'job') {
|
|
228
|
+
yield this.processFlowHandler(data, httpPort).finally(() => this.kill());
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (((_g = this.fn.target) === null || _g === void 0 ? void 0 : _g.type) === 'cron') {
|
|
232
|
+
const cronData = {
|
|
233
|
+
project_details: {},
|
|
234
|
+
cron_details: {},
|
|
235
|
+
data,
|
|
236
|
+
remaining_count: 0
|
|
237
|
+
};
|
|
238
|
+
data = cronData;
|
|
239
|
+
}
|
|
240
|
+
yield this.fnRequestHandler({
|
|
241
|
+
httpPort: this.fn.httpPort,
|
|
242
|
+
data,
|
|
243
|
+
accessToken
|
|
244
|
+
}).finally(() => this.kill());
|
|
245
|
+
}
|
|
246
|
+
catch (er) {
|
|
247
|
+
pluginEvent.emit('error', er instanceof error_1.default
|
|
248
|
+
? er
|
|
249
|
+
: error_1.default.getErrorInstance(er, {
|
|
250
|
+
message: 'Error when communicating with the container function ',
|
|
251
|
+
skipHelp: true
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
}));
|
|
255
|
+
this.slave = pluginEvent;
|
|
256
|
+
return this.slave;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.FnExecutionHandler = FnExecutionHandler;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import EventEmitter from 'events';
|
|
4
|
+
import { IFnTarget } from '../../../fn-utils/lib/common';
|
|
5
|
+
import { IServerDetails } from '../../../serve/server';
|
|
6
|
+
import { FSWatcher } from 'chokidar';
|
|
7
|
+
import { ChildProcess } from 'child_process';
|
|
8
|
+
import { ContainerEvents } from '@zcatalyst/container-plugin/out/utils';
|
|
9
|
+
export declare class FnHandler {
|
|
10
|
+
fn: IServerDetails<IFnTarget>;
|
|
11
|
+
stack: string;
|
|
12
|
+
responseFile: string;
|
|
13
|
+
metaFile: string;
|
|
14
|
+
closed: boolean;
|
|
15
|
+
localFnEvents: EventEmitter;
|
|
16
|
+
watcher?: FSWatcher;
|
|
17
|
+
slave?: ChildProcess | ContainerEvents;
|
|
18
|
+
constructor(fn: IServerDetails<IFnTarget>, localFnEvents: EventEmitter);
|
|
19
|
+
writeResponse(response: string, status: number): void;
|
|
20
|
+
responseProcessor(statusCode: number, message?: string): void;
|
|
21
|
+
processFlowHandler(data: Record<string, unknown>, listenPort: number): Promise<void>;
|
|
22
|
+
fnRequestHandler({ httpPort, data, accessToken }: {
|
|
23
|
+
httpPort: number;
|
|
24
|
+
data?: Record<string, unknown>;
|
|
25
|
+
accessToken: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
fnResponseHandler(code?: number, sig?: string): Promise<void>;
|
|
28
|
+
shutdown(): Promise<void>;
|
|
29
|
+
kill(): void;
|
|
30
|
+
}
|