-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK #64
SDK #64
Conversation
@gentlementlegen I moved SDK code here but testing with I've tried switching to node.js/jest but I'm getting an error:
As far as I understand ts-jest should transpile Typescript to CommonJS module according to their docs so this should work. |
After trying for so long, it seems the issue is only with octokit packages...when I removed them the test passed. Still trying to figure out how to fix it. |
So after switching to
I'm not sure why it can't find it but I fixed it by adding it to jest config: moduleNameMapper: {
"@octokit/webhooks-methods": "<rootDir>/node_modules/@octokit/webhooks-methods/dist-node/index.js",
} |
I had to switch to @gentlementlegen it seems that @octokit/webhooks are not getting mocked and it's calling the real implementation. do you have any idea how to fix this? |
@whilefoo my guess is that Jest hoists the module mock, so it doesn't use the mock but the real implementation instead. Could you try to do |
This PR adds support for Worker plugins, it uses Hono framework which can run on any runtime (cloudflare/netlify/node.js) and is basically an API server that handles requests from the kernel, checks for signature, sets up the context (octokit, settings, env, payload) and calls the function provided by the plugin developer and returns the result from the function back to the kernel |
@whilefoo How is it meant to be used exactly? I see no script in the |
Co-authored-by: Mentlegen <[email protected]>
@whilefoo Is the SDK supposed to be used by external products such as the plugins, that would replace the their code with the Otherwise if it is meant only for debug purposes it is fine, but since you added |
You're correct, it's supposed to be used by plugins. Thanks for noticing, it seems I forgot to transfer changes from PR in a separate repo |
@whilefoo I testing importing it in environments where I'd suggest the following configuration: import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/sdk/index.ts"],
format: ["cjs", "esm"],
outDir: "dist",
splitting: false,
sourcemap: false,
clean: true,
dts: true,
legacyOutput: true,
}); withing "exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/index.d.ts"
}
},
"files": [
"dist"
],
"module": "dist/esm/index.js",
"main": "dist/index.js",
"typings": "dist/index.d.ts", Also in the example you gave me you use |
Thanks for the help! I've never done this so I don't have much experience |
Tested with the following code: import { serve } from "@hono/node-server";
import { createPlugin, Context } from "@ubiquity-dao/ubiquibot-kernel";
type Config = { test: boolean };
type Env = { test: string };
type SupportedEvents = "issue_comment.created";
createPlugin(
async (context: Context<Config, Env, SupportedEvents>) => {
context.logger.info("Hello world");
return { success: true };
},
{ name: "", commands: {}, description: "desc", "ubiquity:listeners": [] },
).then((o) => serve(o)); Accessing {"name":"","commands":{},"description":"desc","ubiquity:listeners":[]} On a Is this the intended behavior? |
|
@whilefoo Got it. I am fine with the code. Do you intend on changing the plugins and the template with this new package? |
I will change worker plugins, sdk for action plugins will be coming soon |
We should phase out the use of "ubiquibot" perhaps you can use |
No description provided.