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

api-core

Package Overview
Dependencies
Maintainers
1
Versions
225
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-core - npm Package Compare versions

Comparing version 0.25.0 to 0.26.3

3

dist/src/query/ApiQueryBuilder.d.ts

@@ -96,3 +96,4 @@ /// <reference types="node" />

private addQueryActions;
private static addMethodCallStep;
private addMethodActions;
private addMethodCallStep;
private addQueryStep;

@@ -99,0 +100,0 @@ private static buildProvideIdStep;

@@ -88,2 +88,6 @@ "use strict";

let arrayRequest = false;
if (!sourceId) {
resolve(scope);
return;
}
if (Array.isArray(sourceId)) {

@@ -360,3 +364,3 @@ arrayRequest = true;

else if (lastSegment instanceof ApiRequest_1.MethodPathSegment) {
ApiQueryBuilder.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge);
this.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge, true);
if (lastSegment.method.scope === ApiEdgeMethod_1.ApiEdgeMethodScope.Entry) {

@@ -430,3 +434,3 @@ query.unshift(new ProvideIdQueryStep(lastSegment.edge.idField));

else if (lastSegment instanceof ApiRequest_1.MethodPathSegment) {
ApiQueryBuilder.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge);
this.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge, true);
if (lastSegment.method.scope === ApiEdgeMethod_1.ApiEdgeMethodScope.Entry) {

@@ -507,3 +511,3 @@ query.unshift(new ProvideIdQueryStep(lastSegment.edge.idField));

if (lastSegment instanceof ApiRequest_1.MethodPathSegment) {
ApiQueryBuilder.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge);
this.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge, true);
if (lastSegment.method.scope === ApiEdgeMethod_1.ApiEdgeMethodScope.Entry) {

@@ -583,5 +587,44 @@ query.unshift(new ProvideIdQueryStep(lastSegment.edge.idField));

}
static addMethodCallStep(request, query, method, edge) {
addMethodActions(triggerKind, query, method, queryType, edge, output = false) {
const trigger = ApiEdgeAction_1.ApiEdgeActionTrigger.Method;
let actions = edge.actions.filter((action) => action.triggerKind == triggerKind &&
(action.targetTypes & queryType) &&
(action.triggers & trigger) &&
(!action.triggerNames.length || action.triggerNames.indexOf(method.name) == -1));
actions.forEach((action) => query.unshift(action));
if (output) {
const apiTrigger = triggerKind == ApiEdgeAction_1.ApiEdgeActionTriggerKind.BeforeEvent ?
ApiAction_1.ApiActionTriggerKind.BeforeOutput : ApiAction_1.ApiActionTriggerKind.AfterOutput;
this.api.actions
.filter((action) => action.triggerKind == apiTrigger)
.forEach((action) => query.unshift(action));
}
}
addMethodCallStep(request, query, method, edge, output) {
if (method.acceptedTypes & request.type) {
let queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Any;
if (request.type === ApiRequest_1.ApiRequestType.Create) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Create;
}
else if (request.type === ApiRequest_1.ApiRequestType.Read) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Read;
}
else if (request.type === ApiRequest_1.ApiRequestType.Update) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Update;
}
else if (request.type === ApiRequest_1.ApiRequestType.Patch) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Patch;
}
else if (request.type === ApiRequest_1.ApiRequestType.Delete) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Delete;
}
else if (request.type === ApiRequest_1.ApiRequestType.Exists) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Exists;
}
else if (request.type === ApiRequest_1.ApiRequestType.Change) {
queryType = ApiEdgeQueryType_1.ApiEdgeQueryType.Change;
}
this.addMethodActions(ApiEdgeAction_1.ApiEdgeActionTriggerKind.AfterEvent, query, method, queryType, edge, output);
query.unshift(new CallMethodQueryStep(method, edge));
this.addMethodActions(ApiEdgeAction_1.ApiEdgeActionTriggerKind.BeforeEvent, query, method, queryType, edge, output);
}

@@ -588,0 +631,0 @@ else {

{
"name": "api-core",
"version": "0.25.0",
"version": "0.26.3",
"description": "Model-based dynamic multi-level APIs for any provider, plus multiple consumption channels",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -122,2 +122,7 @@ import {ApiQuery, ApiQueryScope, QueryStep} from "./ApiQuery";

if(!sourceId) {
resolve(scope);
return
}
if(Array.isArray(sourceId)) {

@@ -513,7 +518,49 @@ arrayRequest = true;

private static addMethodCallStep(request: ApiRequest, query: ApiQuery, method: ApiEdgeMethod, edge: ApiEdgeDefinition) {
private addMethodActions(triggerKind: ApiEdgeActionTriggerKind,
query: ApiQuery,
method: ApiEdgeMethod,
queryType: ApiEdgeQueryType,
edge: ApiEdgeDefinition,
output: boolean = false) {
const trigger = ApiEdgeActionTrigger.Method;
let actions = edge.actions.filter((action: ApiEdgeAction) =>
action.triggerKind == triggerKind &&
(action.targetTypes & queryType) &&
(action.triggers & trigger) &&
(!action.triggerNames.length || action.triggerNames.indexOf(method.name) == -1));
actions.forEach((action: ApiEdgeAction) => query.unshift(action));
if(output) {
const apiTrigger = triggerKind == ApiEdgeActionTriggerKind.BeforeEvent ?
ApiActionTriggerKind.BeforeOutput : ApiActionTriggerKind.AfterOutput;
this.api.actions
.filter((action: ApiAction) => action.triggerKind == apiTrigger)
.forEach((action: ApiAction) => query.unshift(action))
}
}
private addMethodCallStep(request: ApiRequest, query: ApiQuery, method: ApiEdgeMethod, edge: ApiEdgeDefinition, output: boolean) {
if(method.acceptedTypes & request.type) {
//TODO: this.addPostMethodActions(request, query, method);
let queryType = ApiEdgeQueryType.Any;
if (request.type === ApiRequestType.Create) {
queryType = ApiEdgeQueryType.Create;
} else if (request.type === ApiRequestType.Read) {
queryType = ApiEdgeQueryType.Read;
} else if (request.type === ApiRequestType.Update) {
queryType = ApiEdgeQueryType.Update;
} else if (request.type === ApiRequestType.Patch) {
queryType = ApiEdgeQueryType.Patch;
} else if (request.type === ApiRequestType.Delete) {
queryType = ApiEdgeQueryType.Delete;
} else if (request.type === ApiRequestType.Exists) {
queryType = ApiEdgeQueryType.Exists;
} else if (request.type === ApiRequestType.Change) {
queryType = ApiEdgeQueryType.Change;
}
this.addMethodActions(ApiEdgeActionTriggerKind.AfterEvent, query, method, queryType, edge, output);
query.unshift(new CallMethodQueryStep(method, edge));
//TODO: this.addPreMethodActions(request, query, method);
this.addMethodActions(ApiEdgeActionTriggerKind.BeforeEvent, query, method, queryType, edge, output)
}

@@ -644,3 +691,3 @@ else {

else if(lastSegment instanceof MethodPathSegment) {
ApiQueryBuilder.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge);
this.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge, true);
if(lastSegment.method.scope === ApiEdgeMethodScope.Entry) {

@@ -738,3 +785,3 @@ //TODO: Add support for providing id for Edge methods.

else if(lastSegment instanceof MethodPathSegment) {
ApiQueryBuilder.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge);
this.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge, true);
if(lastSegment.method.scope === ApiEdgeMethodScope.Entry) {

@@ -842,3 +889,3 @@ //TODO: Add support for providing id for Edge methods.

if(lastSegment instanceof MethodPathSegment) {
ApiQueryBuilder.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge);
this.addMethodCallStep(request, query, lastSegment.method, lastSegment.edge, true);
if(lastSegment.method.scope === ApiEdgeMethodScope.Entry) {

@@ -845,0 +892,0 @@ //TODO: Add support for providing id for Edge methods.

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