New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@forge/resolver

Package Overview
Dependencies
Maintainers
14
Versions
351
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/resolver - npm Package Compare versions

Comparing version 0.1.0-next.0 to 0.1.0-next.1

7

CHANGELOG.md
# @forge/resolver
## 0.1.0-next.1
### Minor Changes
- 05d76b5: Update resolver and invoker API
## 0.1.0-next.0
### Minor Changes
- fff17c5: Add new Resolver class.

17

out/__test__/index.test.js

@@ -24,14 +24,17 @@ "use strict";

});
resolver.define('pushLogEntry', (logEntry) => {
resolver.define('pushLogEntry', ({ payload: { logEntry } }) => {
backendState.logs = [...backendState.logs, logEntry];
});
resolver.define('getProperty', (key) => {
resolver.define('getProperty', ({ payload: { key } }) => {
var _a;
return (_a = backendState[key]) !== null && _a !== void 0 ? _a : `Property ${key} does not exist.`;
});
resolver.define('addProperty', (key, value) => {
resolver.define('addProperty', ({ payload: { key, value } }) => {
backendState[key] = value;
});
resolver.define('invalidFunction', null);
const invoke = resolver.getDefinitions();
const invoke = async (functionKey, payload) => {
const handler = resolver.getDefinitions();
return handler({ call: { functionKey, payload }, context: {} });
};
it('should perform get operations', async () => {

@@ -42,6 +45,6 @@ expect(await invoke('getCloudId')).toEqual('cloudId-123');

it('should execute functions with params', async () => {
await invoke('pushLogEntry', 'new log');
await invoke('pushLogEntry', { logEntry: 'new log' });
expect(await invoke('getLogs')).toEqual(['some log entries', 'warning', 'not verified', 'new log']);
await invoke('addProperty', 'new-key', { foo: 'foo', bar: 3 });
expect(await invoke('getProperty', 'new-key')).toEqual({ foo: 'foo', bar: 3 });
await invoke('addProperty', { key: 'new-key', value: { foo: 'foo', bar: 3 } });
expect(await invoke('getProperty', { key: 'new-key' })).toEqual({ foo: 'foo', bar: 3 });
});

@@ -48,0 +51,0 @@ it('should throw an error if the function key does not exist', async () => {

@@ -0,7 +1,32 @@

interface InvokePayload {
call: {
functionKey: string;
payload?: {
[key in number | string]: any;
};
};
context: {
[key: string]: any;
};
}
interface Request {
payload: {
[key in number | string]: any;
};
context: InvokePayload['context'];
}
interface Response {
[key: string]: any;
}
declare type ResolverFunction = (request: Request) => Response | void;
export default class Resolver {
private functions;
constructor();
define(functionKey: string, cb: Function): this;
getDefinitions(): (functionKey: string, ...params: any) => Promise<any>;
define(functionKey: string, cb: ResolverFunction): this;
getDefinitions(): ({ call: { functionKey, payload: callPayload }, context }: InvokePayload, backendRuntimePayload?: {
[x: string]: any;
[x: number]: any;
} | undefined) => Promise<ReturnType<ResolverFunction>>;
}
export {};
//# sourceMappingURL=index.d.ts.map

@@ -12,3 +12,4 @@ "use strict";

getDefinitions() {
const resolve = async (functionKey, ...params) => {
const resolve = async ({ call: { functionKey, payload: callPayload }, context }, backendRuntimePayload) => {
var _a;
if (functionKey in this.functions) {

@@ -19,3 +20,6 @@ const cb = this.functions[functionKey];

}
return cb(...params);
return cb({
payload: callPayload || {},
context: Object.assign({ accountId: (_a = backendRuntimePayload === null || backendRuntimePayload === void 0 ? void 0 : backendRuntimePayload.principal) === null || _a === void 0 ? void 0 : _a.accountId }, context)
});
}

@@ -22,0 +26,0 @@ throw new Error(`Function '${functionKey}' is not defined.`);

{
"name": "@forge/resolver",
"version": "0.1.0-next.0",
"version": "0.1.0-next.1",
"description": "Forge function resolver",

@@ -5,0 +5,0 @@ "author": "Atlassian",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc