From 0916400583fcacb5fa48712124af19a04c01b8e7 Mon Sep 17 00:00:00 2001 From: Jure Bogunovic Date: Wed, 28 Sep 2022 01:09:16 +0200 Subject: [PATCH 1/4] fixes after merge with remote --- packages/cli/src/cli.ts | 3 +- packages/cli/src/commands/types.ts | 3 +- .../src/lib/option-parsers/client-config.ts | 6 +-- packages/cli/src/lib/workflow/JobRunner.ts | 8 ++-- .../js/core/src/__tests__/MaybeAsync.spec.ts | 43 +++++++++++-------- packages/js/core/src/types/MaybeAsync.ts | 17 -------- packages/js/core/src/types/Plugin.ts | 6 +-- .../cache/PackageToWrapperCacheResolver.ts | 14 ++---- 8 files changed, 37 insertions(+), 63 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index b95e8a1b81..9d90d7a8f9 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -2,13 +2,12 @@ import * as Commands from "./commands"; -import { executeMaybeAsyncFunction } from "@polywrap/core-js"; import { program } from "commander"; export const run = async (argv: string[]): Promise => { for (const command of Object.values(Commands)) { if ("setup" in command) { - await executeMaybeAsyncFunction(command.setup, program); + await command.setup(program); } } diff --git a/packages/cli/src/commands/types.ts b/packages/cli/src/commands/types.ts index b046c78d54..03c1f5d622 100644 --- a/packages/cli/src/commands/types.ts +++ b/packages/cli/src/commands/types.ts @@ -1,7 +1,8 @@ +import { MaybeAsync } from "@polywrap/core-js"; import { Command as Program, Argument } from "commander"; export { Program, Argument }; export interface Command { - setup: (program: Program) => void; + setup: (program: Program) => MaybeAsync; } diff --git a/packages/cli/src/lib/option-parsers/client-config.ts b/packages/cli/src/lib/option-parsers/client-config.ts index abc0e16701..0f3f464d03 100644 --- a/packages/cli/src/lib/option-parsers/client-config.ts +++ b/packages/cli/src/lib/option-parsers/client-config.ts @@ -3,7 +3,6 @@ import { intlMsg } from "../intl"; import { importTypescriptModule } from "../system"; import { getTestEnvClientConfig } from "../test-env"; -import { executeMaybeAsyncFunction } from "@polywrap/core-js"; import { PolywrapClientConfig } from "@polywrap/client-js"; import path from "path"; @@ -43,10 +42,7 @@ export async function parseClientConfigOption( process.exit(1); } - finalClientConfig = await executeMaybeAsyncFunction( - configModule.getClientConfig, - finalClientConfig - ); + finalClientConfig = await configModule.getClientConfig(finalClientConfig); try { validateClientConfig(finalClientConfig); diff --git a/packages/cli/src/lib/workflow/JobRunner.ts b/packages/cli/src/lib/workflow/JobRunner.ts index ea4c15cdd5..c86955b164 100644 --- a/packages/cli/src/lib/workflow/JobRunner.ts +++ b/packages/cli/src/lib/workflow/JobRunner.ts @@ -1,15 +1,15 @@ import { JobResult, JobStatus, Step } from "./types"; -import { PolywrapClient } from "@polywrap/client-js"; -import { executeMaybeAsyncFunction, MaybeAsync } from "@polywrap/core-js"; +import { Client, MaybeAsync } from "@polywrap/core-js"; import { WorkflowJobs } from "@polywrap/polywrap-manifest-types-js"; import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { PolywrapClient } from "@polywrap/client-js"; export class JobRunner { private jobOutput: Map; constructor( - private client: PolywrapClient, + private client: Client, private onExecution?: (id: string, JobResult: JobResult) => MaybeAsync ) { this.jobOutput = new Map(); @@ -208,7 +208,7 @@ export class JobRunner { this.jobOutput.set(absId, result); if (this.onExecution) { - await executeMaybeAsyncFunction(this.onExecution, absId, result); + await this.onExecution(absId, result); } } } diff --git a/packages/js/core/src/__tests__/MaybeAsync.spec.ts b/packages/js/core/src/__tests__/MaybeAsync.spec.ts index 24ec6374fc..d44a0b27fb 100644 --- a/packages/js/core/src/__tests__/MaybeAsync.spec.ts +++ b/packages/js/core/src/__tests__/MaybeAsync.spec.ts @@ -1,10 +1,11 @@ -import { - MaybeAsync, - executeMaybeAsyncFunction, - isPromise, -} from ".."; +import { MaybeAsync, isPromise } from ".."; -class ClassInstance { +interface IClassInterface { + normalMethod(arg: string): MaybeAsync; + asyncMethod(arg: string): MaybeAsync; +} + +class ClassInstance implements IClassInterface { constructor(private _prop: string) {} normalMethod(arg: string): string { @@ -12,29 +13,33 @@ class ClassInstance { } async asyncMethod(arg: string): Promise { - await new Promise((resolve) => - setTimeout(resolve, 200) - ); + await new Promise((resolve) => setTimeout(resolve, 200)); return this._prop + arg; } } describe("MaybeAsync", () => { - const promise: MaybeAsync = - new Promise((resolve, reject) => { return "" }); - const testFunction = (args: unknown[]) => { return "foo" }; - const testFunctionReturnPromise = (args: unknown[]) => new Promise((resolve) => { resolve("foo") }); + const promise: MaybeAsync = new Promise((resolve, reject) => { + return ""; + }); + const testFunction = (): MaybeAsync => { + return "foo"; + }; + const testFunctionReturnPromise = (): MaybeAsync => + new Promise((resolve) => { + resolve("foo"); + }); it("sanity", async () => { expect(isPromise(promise)).toBe(true); - expect(await executeMaybeAsyncFunction(testFunction)).toBe("foo"); - expect(await executeMaybeAsyncFunction(testFunctionReturnPromise)).toBe("foo"); + expect(await testFunction()).toBe("foo"); + expect(await testFunctionReturnPromise()).toBe("foo"); }); it("works with class instances", async () => { - const instance = new ClassInstance("bar"); - expect(await executeMaybeAsyncFunction(instance.normalMethod.bind(instance, "foo"))).toBe("barfoo") - expect(await executeMaybeAsyncFunction(instance.asyncMethod.bind(instance, "foo"))).toBe("barfoo") - }) + const instance: IClassInterface = new ClassInstance("bar"); + expect(await instance.normalMethod("foo")).toBe("barfoo"); + expect(await instance.asyncMethod("foo")).toBe("barfoo"); + }); }); diff --git a/packages/js/core/src/types/MaybeAsync.ts b/packages/js/core/src/types/MaybeAsync.ts index f713e5d4f0..1e3bb3d1ad 100644 --- a/packages/js/core/src/types/MaybeAsync.ts +++ b/packages/js/core/src/types/MaybeAsync.ts @@ -1,18 +1 @@ export type MaybeAsync = Promise | T; - -export const isPromise = ( - test?: MaybeAsync -): test is Promise => - !!test && typeof (test as Promise).then === "function"; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types -export const executeMaybeAsyncFunction = async ( - func: (...args: unknown[]) => Promise | T, - ...args: unknown[] -): Promise => { - let result = func(...args); - if (isPromise(result)) { - result = await result; - } - return result; -}; diff --git a/packages/js/core/src/types/Plugin.ts b/packages/js/core/src/types/Plugin.ts index 9e7a8b5237..ae63e75252 100644 --- a/packages/js/core/src/types/Plugin.ts +++ b/packages/js/core/src/types/Plugin.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { Client, MaybeAsync, executeMaybeAsyncFunction } from "."; +import { Client, MaybeAsync } from "."; import { WrapManifest } from "@polywrap/wrap-manifest-types-js"; import { Result, ResultErr, ResultOk } from "@polywrap/result"; @@ -60,9 +60,7 @@ export abstract class PluginModule< ); } - const data = await executeMaybeAsyncFunction( - fn.bind(this, args, client) - ); + const data = await fn(args, client); return ResultOk(data); } diff --git a/packages/js/uri-resolvers/src/cache/PackageToWrapperCacheResolver.ts b/packages/js/uri-resolvers/src/cache/PackageToWrapperCacheResolver.ts index 7dde779423..d670ff88b3 100644 --- a/packages/js/uri-resolvers/src/cache/PackageToWrapperCacheResolver.ts +++ b/packages/js/uri-resolvers/src/cache/PackageToWrapperCacheResolver.ts @@ -6,8 +6,6 @@ import { IUriResolver, Uri, Client, - executeMaybeAsyncFunction, - Wrapper, IUriResolutionContext, UriPackageOrWrapper, UriResolutionResult, @@ -39,9 +37,7 @@ export class PackageToWrapperCacheResolver implements IUriResolver { client: Client, resolutionContext: IUriResolutionContext ): Promise> { - const wrapper = await executeMaybeAsyncFunction( - this.cache.get.bind(this.cache, uri) - ); + const wrapper = await this.cache.get(uri); if (wrapper) { const result = UriResolutionResult.ok(uri, wrapper); @@ -78,9 +74,7 @@ export class PackageToWrapperCacheResolver implements IUriResolver { const wrapper = createResult.value; for (const uri of resolutionPath) { - await executeMaybeAsyncFunction( - this.cache.set.bind(this.cache, uri, wrapper) - ); + await this.cache.set(uri, wrapper); } result = UriResolutionResult.ok(result.value.uri, wrapper); @@ -89,9 +83,7 @@ export class PackageToWrapperCacheResolver implements IUriResolver { const resolutionPath: Uri[] = subContext.getResolutionPath(); for (const uri of resolutionPath) { - await executeMaybeAsyncFunction( - this.cache.set.bind(this.cache, uri, wrapper) - ); + await this.cache.set(uri, wrapper); } } } From 7d991ed710d69362cad6929cd6f8c455338baf34 Mon Sep 17 00:00:00 2001 From: Jure Bogunovic Date: Wed, 28 Sep 2022 03:06:53 +0200 Subject: [PATCH 2/4] removed unused func --- .../js/core/src/__tests__/MaybeAsync.spec.ts | 4 - yarn.lock | 144 +++++++++--------- 2 files changed, 72 insertions(+), 76 deletions(-) diff --git a/packages/js/core/src/__tests__/MaybeAsync.spec.ts b/packages/js/core/src/__tests__/MaybeAsync.spec.ts index d44a0b27fb..f23280de65 100644 --- a/packages/js/core/src/__tests__/MaybeAsync.spec.ts +++ b/packages/js/core/src/__tests__/MaybeAsync.spec.ts @@ -20,9 +20,6 @@ class ClassInstance implements IClassInterface { } describe("MaybeAsync", () => { - const promise: MaybeAsync = new Promise((resolve, reject) => { - return ""; - }); const testFunction = (): MaybeAsync => { return "foo"; }; @@ -32,7 +29,6 @@ describe("MaybeAsync", () => { }); it("sanity", async () => { - expect(isPromise(promise)).toBe(true); expect(await testFunction()).toBe("foo"); expect(await testFunctionReturnPromise()).toBe("foo"); }); diff --git a/yarn.lock b/yarn.lock index c53372ae26..a2e82ff4cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -124,10 +124,10 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.18.8", "@babel/compat-data@^7.19.1", "@babel/compat-data@^7.9.0": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.19.1.tgz#72d647b4ff6a4f82878d184613353af1dd0290f9" - integrity sha512-72a9ghR0gnESIa7jBN53U32FOVCEoztyIlKaNoU05zRhEecduGK9L9c3ww7Mp06JiR+0ls0GBPFJQwwtjn9ksg== +"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.18.8", "@babel/compat-data@^7.19.3", "@babel/compat-data@^7.9.0": + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.19.3.tgz#707b939793f867f5a73b2666e6d9a3396eb03151" + integrity sha512-prBHMK4JYYK+wDjJF1q99KK4JLL+egWS4nmNqdlMUgCExMZ+iZW0hGhyC3VEbsPjvaN0TBhW//VIFwBrk8sEiw== "@babel/core@7.9.0": version "7.9.0" @@ -152,32 +152,32 @@ source-map "^0.5.0" "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.4.5", "@babel/core@^7.7.5": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.19.1.tgz#c8fa615c5e88e272564ace3d42fbc8b17bfeb22b" - integrity sha512-1H8VgqXme4UXCRv7/Wa1bq7RVymKOzC7znjyFM8KiEzwFqcKUKYNoQef4GhdklgNvoBXyW4gYhuBNCM5o1zImw== + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.19.3.tgz#2519f62a51458f43b682d61583c3810e7dcee64c" + integrity sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.19.0" - "@babel/helper-compilation-targets" "^7.19.1" + "@babel/generator" "^7.19.3" + "@babel/helper-compilation-targets" "^7.19.3" "@babel/helper-module-transforms" "^7.19.0" "@babel/helpers" "^7.19.0" - "@babel/parser" "^7.19.1" + "@babel/parser" "^7.19.3" "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.1" - "@babel/types" "^7.19.0" + "@babel/traverse" "^7.19.3" + "@babel/types" "^7.19.3" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" json5 "^2.2.1" semver "^6.3.0" -"@babel/generator@^7.19.0", "@babel/generator@^7.4.0", "@babel/generator@^7.9.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.19.0.tgz#785596c06425e59334df2ccee63ab166b738419a" - integrity sha512-S1ahxf1gZ2dpoiFgA+ohK9DIpz50bJ0CWs7Zlzb54Z4sG8qmdIrGrVqmy1sAtTVRb+9CU6U8VqT9L0Zj7hxHVg== +"@babel/generator@^7.19.3", "@babel/generator@^7.4.0", "@babel/generator@^7.9.0": + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.19.3.tgz#d7f4d1300485b4547cb6f94b27d10d237b42bf59" + integrity sha512-fqVZnmp1ncvZU757UzDheKZpfPgatqY59XtW2/j/18H7u76akb8xqvjw82f+i2UKd/ksYsSick/BCLQUUtJ/qQ== dependencies: - "@babel/types" "^7.19.0" + "@babel/types" "^7.19.3" "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" @@ -196,12 +196,12 @@ "@babel/helper-explode-assignable-expression" "^7.18.6" "@babel/types" "^7.18.9" -"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.19.0", "@babel/helper-compilation-targets@^7.19.1", "@babel/helper-compilation-targets@^7.8.7": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.19.1.tgz#7f630911d83b408b76fe584831c98e5395d7a17c" - integrity sha512-LlLkkqhCMyz2lkQPvJNdIYU7O5YjWRgC2R4omjCTpZd8u8KMQzZvX4qce+/BluN1rcQiV7BoGUpmQ0LeHerbhg== +"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.19.0", "@babel/helper-compilation-targets@^7.19.3", "@babel/helper-compilation-targets@^7.8.7": + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.19.3.tgz#a10a04588125675d7c7ae299af86fa1b2ee038ca" + integrity sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg== dependencies: - "@babel/compat-data" "^7.19.1" + "@babel/compat-data" "^7.19.3" "@babel/helper-validator-option" "^7.18.6" browserslist "^4.21.3" semver "^6.3.0" @@ -353,7 +353,7 @@ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz#181f22d28ebe1b3857fa575f5c290b1aaf659b56" integrity sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw== -"@babel/helper-validator-identifier@^7.18.6": +"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== @@ -391,10 +391,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.19.1", "@babel/parser@^7.4.3", "@babel/parser@^7.7.0", "@babel/parser@^7.9.0": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.19.1.tgz#6f6d6c2e621aad19a92544cc217ed13f1aac5b4c" - integrity sha512-h7RCSorm1DdTVGJf3P2Mhj3kdnkmF/EiysUkzS2TdgAYqyjFdMQJbVuXOBej2SBJaXan/lIVtT6KkGbyyq753A== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.19.3", "@babel/parser@^7.4.3", "@babel/parser@^7.7.0", "@babel/parser@^7.9.0": + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.19.3.tgz#8dd36d17c53ff347f9e55c328710321b49479a9a" + integrity sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ== "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.18.6": version "7.18.6" @@ -1047,9 +1047,9 @@ "@babel/helper-plugin-utils" "^7.18.9" "@babel/plugin-transform-typescript@^7.9.0": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.19.1.tgz#adcf180a041dcbd29257ad31b0c65d4de531ce8d" - integrity sha512-+ILcOU+6mWLlvCwnL920m2Ow3wWx3Wo8n2t5aROQmV55GZt+hOiLvBaa3DNzRjSEHa1aauRs4/YLmkCfFkhhRQ== + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.19.3.tgz#4f1db1e0fe278b42ddbc19ec2f6cd2f8262e35d6" + integrity sha512-z6fnuK9ve9u/0X0rRvI9MY0xg+DOUaABDYOe+/SQTxtlptaBB/V9JIUxJn6xp3lMBeb9qe8xSFmHU35oZDXD+w== dependencies: "@babel/helper-create-class-features-plugin" "^7.19.0" "@babel/helper-plugin-utils" "^7.19.0" @@ -1137,12 +1137,12 @@ semver "^5.5.0" "@babel/preset-env@^7.4.5": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.19.1.tgz#9f04c916f9c0205a48ebe5cc1be7768eb1983f67" - integrity sha512-c8B2c6D16Lp+Nt6HcD+nHl0VbPKVnNPTpszahuxJJnurfMtKeZ80A+qUv48Y7wqvS+dTFuLuaM9oYxyNHbCLWA== + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.19.3.tgz#52cd19abaecb3f176a4ff9cc5e15b7bf06bec754" + integrity sha512-ziye1OTc9dGFOAXSWKUqQblYHNlBOaDl8wzqf2iKXJAltYiR3hKHUKmkt+S9PppW7RQpq4fFCrwwpIDj/f5P4w== dependencies: - "@babel/compat-data" "^7.19.1" - "@babel/helper-compilation-targets" "^7.19.1" + "@babel/compat-data" "^7.19.3" + "@babel/helper-compilation-targets" "^7.19.3" "@babel/helper-plugin-utils" "^7.19.0" "@babel/helper-validator-option" "^7.18.6" "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.18.6" @@ -1210,7 +1210,7 @@ "@babel/plugin-transform-unicode-escapes" "^7.18.10" "@babel/plugin-transform-unicode-regex" "^7.18.6" "@babel/preset-modules" "^0.1.5" - "@babel/types" "^7.19.0" + "@babel/types" "^7.19.3" babel-plugin-polyfill-corejs2 "^0.3.3" babel-plugin-polyfill-corejs3 "^0.6.0" babel-plugin-polyfill-regenerator "^0.4.1" @@ -1291,29 +1291,29 @@ "@babel/parser" "^7.18.10" "@babel/types" "^7.18.10" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.19.0", "@babel/traverse@^7.19.1", "@babel/traverse@^7.4.3", "@babel/traverse@^7.7.0", "@babel/traverse@^7.9.0": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.19.1.tgz#0fafe100a8c2a603b4718b1d9bf2568d1d193347" - integrity sha512-0j/ZfZMxKukDaag2PtOPDbwuELqIar6lLskVPPJDjXMXjfLb1Obo/1yjxIGqqAJrmfaTIY3z2wFLAQ7qSkLsuA== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.19.0", "@babel/traverse@^7.19.1", "@babel/traverse@^7.19.3", "@babel/traverse@^7.4.3", "@babel/traverse@^7.7.0", "@babel/traverse@^7.9.0": + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.19.3.tgz#3a3c5348d4988ba60884e8494b0592b2f15a04b4" + integrity sha512-qh5yf6149zhq2sgIXmwjnsvmnNQC2iw70UFjp4olxucKrWd/dvlUsBI88VSLUsnMNF7/vnOiA+nk1+yLoCqROQ== dependencies: "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.19.0" + "@babel/generator" "^7.19.3" "@babel/helper-environment-visitor" "^7.18.9" "@babel/helper-function-name" "^7.19.0" "@babel/helper-hoist-variables" "^7.18.6" "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.19.1" - "@babel/types" "^7.19.0" + "@babel/parser" "^7.19.3" + "@babel/types" "^7.19.3" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.7.0", "@babel/types@^7.9.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.19.0.tgz#75f21d73d73dc0351f3368d28db73465f4814600" - integrity sha512-YuGopBq3ke25BVSiS6fgF49Ul9gH1x70Bcr6bqRLjWCkcX8Hre1/5+z+IiWOIerRMSSEfGZVB9z9kyq7wVs9YA== +"@babel/types@^7.0.0", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.19.3", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.7.0", "@babel/types@^7.9.0": + version "7.19.3" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.19.3.tgz#fc420e6bbe54880bce6779ffaf315f5e43ec9624" + integrity sha512-hGCaQzIY22DJlDh9CH7NOxgKkFjBk0Cw9xDO1Xmh2151ti7wiGfQ3LauXzL4HP1fmFlTX6XjpRETTpUcv7wQLw== dependencies: "@babel/helper-string-parser" "^7.18.10" - "@babel/helper-validator-identifier" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" "@bcoe/v8-coverage@^0.2.3": @@ -3703,9 +3703,9 @@ integrity sha512-wH6Tu9mbiOt0n5EvdoWy0VGQaJMHfLIxY/6wS0xLC7CV1taM6gESEzcYy0ZlWvxxiiljYvfDIvz4hHbUUDRlhw== "@types/node@*": - version "18.7.20" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.20.tgz#d9442de7b5cb166476340b4271b15300fe058a39" - integrity sha512-adzY4vLLr5Uivmx8+zfSJ5fbdgKxX8UMtjtl+17n0B1q1Nz8JEmE151vefMdpD+1gyh+77weN4qEhej/O7budQ== + version "18.7.23" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.23.tgz#75c580983846181ebe5f4abc40fe9dfb2d65665f" + integrity sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg== "@types/node@12.12.26": version "12.12.26" @@ -5593,9 +5593,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001400: - version "1.0.30001411" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001411.tgz#303c8594ca5903b193a6d875ac613548cb73379a" - integrity sha512-HPnJKESKuhKpHvMY1/ux7J3nG7xG8jRuL4lbyCjDRm0doTNV91tcRk60xrP7Ym9DtJH/yuqntDWBJCqpXB4b7g== + version "1.0.30001412" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001412.tgz#30f67d55a865da43e0aeec003f073ea8764d5d7c" + integrity sha512-+TeEIee1gS5bYOiuf+PS/kp2mrXic37Hl66VY6EAfxasIk5fELTktK2oOezYed12H8w7jt3s512PpulQidPjwA== capture-exit@^2.0.0: version "2.0.0" @@ -6313,16 +6313,16 @@ copyfiles@2.4.1: yargs "^16.1.0" core-js-compat@^3.25.1, core-js-compat@^3.6.2: - version "3.25.2" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.25.2.tgz#7875573586809909c69e03ef310810c1969ee138" - integrity sha512-TxfyECD4smdn3/CjWxczVtJqVLEEC2up7/82t7vC0AzNogr+4nQ8vyF7abxAuTXWvjTClSbvGhU0RgqA4ToQaQ== + version "3.25.3" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.25.3.tgz#d6a442a03f4eade4555d4e640e6a06151dd95d38" + integrity sha512-xVtYpJQ5grszDHEUU9O7XbjjcZ0ccX3LgQsyqSvTnjX97ZqEgn9F5srmrwwwMtbKzDllyFPL+O+2OFMl1lU4TQ== dependencies: browserslist "^4.21.4" core-js-pure@^3.25.1: - version "3.25.2" - resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.25.2.tgz#44a4fd873bdd4fecf6ca11512bcefedbe87e744a" - integrity sha512-ItD7YpW1cUB4jaqFLZXe1AXkyqIxz6GqPnsDV4uF4hVcWh/WAGIqSqw5p0/WdsILM0Xht9s3Koyw05R3K6RtiA== + version "3.25.3" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.25.3.tgz#66ac5bfa5754b47fdfd14f3841c5ed21c46db608" + integrity sha512-T/7qvgv70MEvRkZ8p6BasLZmOVYKzOaWNBEHAU8FmveCJkl4nko2quqPQOmy6AJIp5MBanhz9no3A94NoRb0XA== core-js@^2.4.0: version "2.6.12" @@ -6330,9 +6330,9 @@ core-js@^2.4.0: integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== core-js@^3.5.0: - version "3.25.2" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.25.2.tgz#2d3670c1455432b53fa780300a6fc1bd8304932c" - integrity sha512-YB4IAT1bjEfxTJ1XYy11hJAKskO+qmhuDBM8/guIfMz4JvdsAQAqvyb97zXX7JgSrfPLG5mRGFWJwJD39ruq2A== + version "3.25.3" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.25.3.tgz#cbc2be50b5ddfa7981837bd8c41639f27b166593" + integrity sha512-y1hvKXmPHvm5B7w4ln1S4uc9eV/O5+iFExSRUimnvIph11uaizFR8LFMdONN8hG3P2pipUfX4Y/fR8rAEtcHcQ== core-util-is@1.0.2: version "1.0.2" @@ -7260,9 +7260,9 @@ electron-fetch@^1.7.2: encoding "^0.1.13" electron-to-chromium@^1.3.378, electron-to-chromium@^1.4.251: - version "1.4.261" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.261.tgz#31f14ad60c6f95bec404a77a2fd5e1962248e112" - integrity sha512-fVXliNUGJ7XUVJSAasPseBbVgJIeyw5M1xIkgXdTSRjlmCqBbiSTsEdLOCJS31Fc8B7CaloQ/BFAg8By3ODLdg== + version "1.4.265" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.265.tgz#45630ae190228f945ff79c060b99574b1347e5a7" + integrity sha512-38KaYBNs0oCzWCpr6j7fY/W9vF0vSp4tKFIshQTgdZMhUpkxgotkQgjJP6iGMdmlsgMs3i0/Hkko4UXLTrkYVQ== elliptic@6.5.4, elliptic@^6.5.3: version "6.5.4" @@ -17374,14 +17374,14 @@ typescript@4.0.7: integrity sha512-yi7M4y74SWvYbnazbn8/bmJmX4Zlej39ZOqwG/8dut/MYoSQ119GY9ZFbbGsD4PFZYWxqik/XsP3vk3+W5H3og== typescript@^4.0: - version "4.8.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88" - integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig== + version "4.8.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" + integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== uglify-js@^3.1.4: - version "3.17.1" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.1.tgz#1258a2a488147a8266b3034499ce6959978ba7f4" - integrity sha512-+juFBsLLw7AqMaqJ0GFvlsGZwdQfI2ooKQB39PSBgMnMakcFosi9O8jCwE+2/2nMNcc0z63r9mwjoDG8zr+q0Q== + version "3.17.2" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.2.tgz#f55f668b9a64b213977ae688703b6bbb7ca861c6" + integrity sha512-bbxglRjsGQMchfvXZNusUcYgiB9Hx2K4AHYXQy2DITZ9Rd+JzhX7+hoocE5Winr7z2oHvPsekkBwXtigvxevXg== uid-number@0.0.6: version "0.0.6" From 61d187575f5014781fd840781e8b176e4064f8b6 Mon Sep 17 00:00:00 2001 From: Jure Bogunovic Date: Wed, 28 Sep 2022 15:01:00 +0200 Subject: [PATCH 3/4] plugin method is now properly bound --- packages/js/core/src/types/Plugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/js/core/src/types/Plugin.ts b/packages/js/core/src/types/Plugin.ts index ae63e75252..26e57c2efe 100644 --- a/packages/js/core/src/types/Plugin.ts +++ b/packages/js/core/src/types/Plugin.ts @@ -61,6 +61,7 @@ export abstract class PluginModule< } const data = await fn(args, client); + return ResultOk(data); } @@ -75,7 +76,7 @@ export abstract class PluginModule< PluginMethod >)[method]; - return fn; + return fn.bind(this); } } From 8570c6045eda0faace22c3dd7e29b8e30b0c5f6a Mon Sep 17 00:00:00 2001 From: Jure Bogunovic Date: Wed, 28 Sep 2022 15:03:22 +0200 Subject: [PATCH 4/4] using polywrap client --- packages/cli/src/lib/workflow/JobRunner.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/lib/workflow/JobRunner.ts b/packages/cli/src/lib/workflow/JobRunner.ts index c86955b164..b5e6f05457 100644 --- a/packages/cli/src/lib/workflow/JobRunner.ts +++ b/packages/cli/src/lib/workflow/JobRunner.ts @@ -1,15 +1,15 @@ import { JobResult, JobStatus, Step } from "./types"; -import { Client, MaybeAsync } from "@polywrap/core-js"; +import { PolywrapClient } from "@polywrap/client-js"; +import { MaybeAsync } from "@polywrap/core-js"; import { WorkflowJobs } from "@polywrap/polywrap-manifest-types-js"; import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; -import { PolywrapClient } from "@polywrap/client-js"; export class JobRunner { private jobOutput: Map; constructor( - private client: Client, + private client: PolywrapClient, private onExecution?: (id: string, JobResult: JobResult) => MaybeAsync ) { this.jobOutput = new Map();