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

appknit-platform-sdk

Package Overview
Dependencies
Maintainers
2
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appknit-platform-sdk - npm Package Compare versions

Comparing version 1.0.57-0 to 2.0.0-1

dist/src/types/extension.d.ts

76

dist/src/sdk.d.ts

@@ -1,19 +0,27 @@

import { SdkHttpHeaders, SdkStopExecutionStatus, SdkLogLevel, SdkLogEntry, SdkHttpRequestOptions, SdkHttpRequestTrace, SdkHttpResponse, SdkAuthenticationCredentialType, SdkFlowProvider, SdkStorageProvider, SdkContext, SdkDataProvider, SdkContextMap } from './types';
export interface SdkAuthentication {
type: SdkAuthenticationCredentialType;
credentials: any;
}
import { SdkHttpHeaders, SdkLogLevel, SdkLogEntry, SdkHttpRequestOptions, SdkHttpRequestTrace, SdkHttpResponse, SdkStorageProvider, SdkDataProvider, SdkRuntimePlatform, SdkExecutionProvider } from './types';
import { SdkExtensionCredentialType } from './types';
import type { ExecutionFramework } from '@appknit-io/common-frameworks';
export interface ISdkMetadata {
platform: SdkRuntimePlatform;
apiUrl: string;
internalApiUrl: string;
processId: string;
executionId: string;
organizationId: string;
applicationId: string;
sessionId: string;
jwt: string;
flowInvocationTags?: Record<string, string>;
invocationTags?: Record<string, string>;
debugDetails: any;
}
export declare enum SdkStopExecutionStatus {
SUCCEED = "SUCCEED",
FAILED = "FAILED"
}
declare type ObjectEntries = [key: string, value: any];
export declare class AppknitSDK {
protected sdkMetadata: ISdkMetadata;
protected authenticationBeforeRequestHook: (sdk: AppknitSDK, request: SdkHttpRequestOptions, type: SdkAuthenticationCredentialType, credentials: any) => Promise<void>;
protected authentication: {
type: SdkAuthenticationCredentialType;
protected credentialBeforeRequestHook: (sdk: AppknitSDK, request: SdkHttpRequestOptions, type: SdkExtensionCredentialType, credentials: any) => Promise<void>;
protected credential: {
type: SdkExtensionCredentialType;
credentials: any;

@@ -28,25 +36,7 @@ };

};
protected context: SdkContext;
protected executionFramework: ExecutionFramework;
protected executionProvider: SdkExecutionProvider;
protected dataProvider: SdkDataProvider;
protected flowProvider: SdkFlowProvider;
protected storageProvider: SdkStorageProvider;
protected stopExecution: {
status: SdkStopExecutionStatus;
comment: string;
};
readonly serialization: {
json: {
parse: (str: any) => any;
stringify: (obj: any) => string;
};
xml: {
parse: (str: any) => any;
stringify: (obj: any) => string;
};
yaml: {
parse: (str: any) => any;
stringify: (obj: any) => string;
};
};
constructor(context: SdkContext, sdkMetadata?: ISdkMetadata);
constructor(executionFramework: ExecutionFramework, sdkMetadata?: ISdkMetadata);
readonly logging: {

@@ -64,4 +54,7 @@ log: (level: SdkLogLevel, message: string, args?: any) => void;

setStopExecution(status: SdkStopExecutionStatus, comment: string): void;
setAuthenticationBeforeRequestHook(interceptor: (sdk: AppknitSDK, request: SdkHttpRequestOptions, type: SdkAuthenticationCredentialType, credentials: any) => Promise<void>): void;
setAuthentication(authentication: SdkAuthentication): void;
setCredentialBeforeRequestHook(interceptor: (sdk: AppknitSDK, request: SdkHttpRequestOptions, type: SdkExtensionCredentialType, credentials: any) => Promise<void>): void;
setCredential(credential: {
type: SdkExtensionCredentialType;
credentials: any;
}): void;
getLogs(): SdkLogEntry[];

@@ -74,8 +67,5 @@ getTraces(): SdkHttpRequestTrace[];

};
getStopExecution(): {
status: SdkStopExecutionStatus;
comment: string;
};
getAuthentication(): {
type: SdkAuthenticationCredentialType;
getStopExecution(): any;
getCredential(): {
type: SdkExtensionCredentialType;
credentials: any;

@@ -85,4 +75,4 @@ };

getDataProvider(): SdkDataProvider;
setFlowProvider(flowProvider: SdkFlowProvider): void;
getFlowProvider(): SdkFlowProvider;
setExecutionProvider(executionProvider: SdkExecutionProvider): void;
getExecutionProvider(): SdkExecutionProvider;
setStorageProvider(value: SdkStorageProvider): void;

@@ -98,9 +88,9 @@ getStorageProvider(): SdkStorageProvider;

getContextVariables(): string[];
getContext(): SdkContext;
getContext(): any;
getSdkMetadata(): ISdkMetadata;
setSdkMetadata(data: Record<string, any>): ISdkMetadata;
getFlowExecutionUrl(pathAndQuery: string): string;
getInvocationUrl(pathAndQuery: string): string;
private getSdkContextMapRecordKey;
createSdkContextMap(mapName: string, records: Array<Record<string, any>>, keyFields: Array<string>): SdkContextMap;
createSdkContextMap(mapName: string, records: Array<Record<string, any>>, keyFields: Array<string>): any;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppknitSDK = void 0;
exports.AppknitSDK = exports.SdkStopExecutionStatus = void 0;
const nodePath = require("path");
const _ = require("lodash");
const http = require("http");
const https = require("https");
const YAML = require("yaml");
const XML = require("fast-xml-parser");
const shortUuid = require("short-uuid");
const types_1 = require("./types");
const allowedSDKMetadataFields = ['flowInvocationTags'];
const prohibitedSDKContextFields = ['maps'];
const defaultHttpTimeout = 300000;
const completionKey = '__completion';
var SdkStopExecutionStatus;
(function (SdkStopExecutionStatus) {
SdkStopExecutionStatus["SUCCEED"] = "SUCCEED";
SdkStopExecutionStatus["FAILED"] = "FAILED";
})(SdkStopExecutionStatus = exports.SdkStopExecutionStatus || (exports.SdkStopExecutionStatus = {}));
class AppknitSDK {
constructor(context, sdkMetadata) {
this.authentication = null;
constructor(executionFramework, sdkMetadata) {
this.credential = null;
this.logs = [];
this.traces = [];
this.context = {};
this.serialization = {
json: {
parse: (str) => {
if (typeof str === 'string')
return JSON.parse(str);
else if (typeof str === 'object')
return str;
else
throw new Error('Parser Error: Value must be String or Object.');
},
stringify: (obj) => {
return JSON.stringify(obj);
},
},
xml: {
parse: (str) => {
return XML.parse(str, {
attributeNamePrefix: '',
attrNodeName: '@attributes',
allowBooleanAttributes: true,
parseTrueNumberOnly: true,
ignoreAttributes: false,
ignoreNameSpace: false,
parseNodeValue: true,
parseAttributeValue: true,
textNodeName: 'value',
}, true);
},
stringify: (obj) => {
const parser = new XML.j2xParser({
attributeNamePrefix: '',
attrNodeName: '@attributes',
ignoreAttributes: false,
textNodeName: 'value',
});
return parser.parse(obj);
},
},
yaml: {
parse: (str) => {
return YAML.parse(str);
},
stringify: (obj) => {
return YAML.stringify(obj);
},
},
};
this.logging = {

@@ -104,3 +57,3 @@ log: (level, message, args) => {

};
this.context = context || {};
this.executionFramework = executionFramework;
this.sdkMetadata = sdkMetadata || null;

@@ -129,4 +82,4 @@ }

requestBytesSent += Buffer.from(query).length;
if (this.authenticationBeforeRequestHook) {
await this.authenticationBeforeRequestHook(this, options, this.authentication ? this.authentication.type : null, this.authentication ? this.authentication.credentials : null);
if (this.credentialBeforeRequestHook) {
await this.credentialBeforeRequestHook(this, options, this.credential ? this.credential.type : null, this.credential ? this.credential.credentials : null);
}

@@ -344,12 +297,10 @@ const internalRequest = (httpRequestOptions, parentRequestId) => {

setStopExecution(status, comment) {
this.stopExecution = {
status,
comment,
};
this.executionFramework.setProcessVariable(this.sdkMetadata.processId, completionKey, { status, comment });
this.executionFramework.markProcessComplete(this.sdkMetadata.processId);
}
setAuthenticationBeforeRequestHook(interceptor) {
this.authenticationBeforeRequestHook = interceptor;
setCredentialBeforeRequestHook(interceptor) {
this.credentialBeforeRequestHook = interceptor;
}
setAuthentication(authentication) {
this.authentication = authentication;
setCredential(credential) {
this.credential = credential;
}

@@ -366,6 +317,6 @@ getLogs() {

getStopExecution() {
return this.stopExecution;
return this.executionFramework.getProcessVariable(this.sdkMetadata.processId, completionKey);
}
getAuthentication() {
return this.authentication;
getCredential() {
return this.credential;
}

@@ -378,7 +329,7 @@ setDataProvider(dataProvider) {

}
setFlowProvider(flowProvider) {
this.flowProvider = flowProvider;
setExecutionProvider(executionProvider) {
this.executionProvider = executionProvider;
}
getFlowProvider() {
return this.flowProvider;
getExecutionProvider() {
return this.executionProvider;
}

@@ -394,3 +345,3 @@ setStorageProvider(value) {

if (!this.storageProvider && this.sdkMetadata && this.sdkMetadata.internalApiUrl) {
this.storageProvider = new types_1.SdkStorageProvider(this, this.context, {
this.storageProvider = new types_1.SdkStorageProvider(this, {
baseURL: this.sdkMetadata.internalApiUrl,

@@ -404,62 +355,30 @@ headers: {

setContextVariable(variableId, value) {
if (!this.context)
this.context = {};
if (prohibitedSDKContextFields.indexOf(variableId) > -1) {
throw new types_1.InvalidInputError(`Prohibited context variable key - ${variableId}`);
}
this.context[variableId] = value;
this.executionFramework.setProcessVariable(this.sdkMetadata.processId, variableId, value);
}
setContextVariables(values) {
if (!this.context)
this.context = {};
values.forEach(entry => {
const [key, value] = entry;
if (prohibitedSDKContextFields.indexOf(key) > -1) {
throw new types_1.InvalidInputError(`Prohibited context variable key - ${key}`);
}
this.context[key] = value;
});
for (const entry of values) {
this.setContextVariable(entry[0], entry[1]);
}
}
setContextVariableIfNotSet(variableId, value) {
if (!this.context)
this.context = {};
if (this.context.hasOwnProperty(variableId)) {
throw new Error(`Variable with name ${variableId} already exists`);
if (!this.executionFramework.hasProcessVariable(this.sdkMetadata.processId, variableId)) {
this.executionFramework.setProcessVariable(this.sdkMetadata.processId, variableId, value);
}
if (prohibitedSDKContextFields.indexOf(variableId) > -1) {
throw new types_1.InvalidInputError(`Prohibited context variable key - ${variableId}`);
}
this.context[variableId] = value;
}
setContextVariablesIfNotSet(values) {
if (!this.context)
this.context = {};
values.forEach(entry => {
const [key, value] = entry;
if (this.context.hasOwnProperty(key)) {
throw new types_1.InvalidInputError(`Variable with name ${key} already exists`);
}
if (prohibitedSDKContextFields.indexOf(key) > -1) {
throw new types_1.InvalidInputError(`Prohibited context variable key - ${key}`);
}
this.context[key] = value;
});
for (const entry of values) {
this.setContextVariableIfNotSet(entry[0], entry[1]);
}
}
getContextVariable(variableId, defaultValue) {
if (!this.context)
this.context = {};
return this.context[variableId] || defaultValue;
return this.executionFramework.getProcessVariable(this.sdkMetadata.processId, variableId) || defaultValue;
}
unsetContext() {
this.context = {};
return this.executionFramework.clearProcessVariables(this.sdkMetadata.processId);
}
getContextVariables() {
if (!this.context)
this.context = {};
return Object.keys(this.context);
return Object.keys(this.executionFramework.getProcessVariables(this.sdkMetadata.processId) || {});
}
getContext() {
if (!this.context)
this.context = {};
return this.context;
return this.executionFramework.getProcessVariables(this.sdkMetadata.processId) || {};
}

@@ -470,11 +389,6 @@ getSdkMetadata() {

setSdkMetadata(data) {
if (!_.isObject(data)) {
const type = typeof data;
if (data == null || (type !== 'object' && type !== 'function')) {
throw new types_1.InvalidInputError();
}
for (const field in data) {
if (allowedSDKMetadataFields.indexOf(field) === -1) {
const errorMessage = `Valid metadata fields: ${allowedSDKMetadataFields.join(' | ')}`;
throw new types_1.InvalidInputError(errorMessage);
}
}
const sdkMetadata = this.sdkMetadata;

@@ -484,3 +398,3 @@ this.sdkMetadata = Object.assign(Object.assign({}, sdkMetadata), data);

}
getFlowExecutionUrl(pathAndQuery) {
getInvocationUrl(pathAndQuery) {
return pathAndQuery ? `${this.getSdkMetadata().apiUrl}${pathAndQuery}` : null;

@@ -494,3 +408,3 @@ }

}
const maps = this.context.maps || {};
const maps = this.executionFramework.getProcessVariable(this.sdkMetadata.processId, 'maps') || {};
const map = {

@@ -513,3 +427,3 @@ name: mapName,

maps[mapName] = map;
this.context.maps = maps;
this.executionFramework.setProcessVariable(this.sdkMetadata.processId, 'maps', maps);
return map;

@@ -516,0 +430,0 @@ }

export * from './error';
export * from './integration';
export * from './extension';
export * from './input-output-args';
export * from './log';
export * from './request';
export * from './data';
export * from './flow';
export * from './providers/data';
export * from './providers/execution';
export * from './context';
export * from './storage';
export * from './providers/storage';
export * from './utils';

@@ -14,10 +14,11 @@ "use strict";

__exportStar(require("./error"), exports);
__exportStar(require("./integration"), exports);
__exportStar(require("./extension"), exports);
__exportStar(require("./input-output-args"), exports);
__exportStar(require("./log"), exports);
__exportStar(require("./request"), exports);
__exportStar(require("./data"), exports);
__exportStar(require("./flow"), exports);
__exportStar(require("./providers/data"), exports);
__exportStar(require("./providers/execution"), exports);
__exportStar(require("./context"), exports);
__exportStar(require("./storage"), exports);
__exportStar(require("./providers/storage"), exports);
__exportStar(require("./utils"), exports);
//# sourceMappingURL=index.js.map
{
"name": "appknit-platform-sdk",
"version": "1.0.57-0",
"version": "2.0.0-1",
"description": "",

@@ -30,10 +30,9 @@ "homepage": "https://appknit.io",

"dependencies": {
"fast-xml-parser": "^3.17.4",
"form-data": "^3.0.0",
"lodash": "^4.17.20",
"mime-types": "^2.1.27",
"short-uuid": "^3.1.1",
"yaml": "^1.10.0"
"short-uuid": "^3.1.1"
},
"devDependencies": {
"@appknit-io/common-frameworks": "^1.4.6",
"@types/jest": "25.1.4",

@@ -61,2 +60,5 @@ "@types/lodash": "^4.14.168",

},
"peerDependencies": {
"@appknit-io/common-frameworks": "^1.4.6"
},
"jest": {

@@ -63,0 +65,0 @@ "moduleFileExtensions": [

Sorry, the diff of this file is not supported yet

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