Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@perspect3vism/ad4m

Package Overview
Dependencies
Maintainers
4
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@perspect3vism/ad4m - npm Package Compare versions

Comparing version 0.1.30 to 0.1.31

7

lib/perspectives/PerspectiveProxy.d.ts

@@ -28,3 +28,10 @@ import PerspectiveClient, { LinkCallback } from "./PerspectiveClient";

setSingleTarget(link: Link): Promise<void>;
sdnaFlows(): Promise<string[]>;
availableFlows(exprAddr: string): Promise<string[]>;
startFlow(flowName: string, exprAddr: string): Promise<void>;
expressionsInFlowState(flowName: string, flowState: number): Promise<string[]>;
flowState(flowName: string, exprAddr: string): Promise<number>;
flowActions(flowName: string, exprAddr: string): Promise<string[]>;
runFlowAction(flowName: string, exprAddr: string, actionName: string): Promise<void>;
}
export {};

75

lib/perspectives/PerspectiveProxy.js

@@ -13,5 +13,6 @@ "use strict";

};
var _PerspectiveProxy_handle, _PerspectiveProxy_client, _PerspectiveProxy_perspectiveLinkAddedCallbacks, _PerspectiveProxy_perspectiveLinkRemovedCallbacks;
var _PerspectiveProxy_handle, _PerspectiveProxy_client, _PerspectiveProxy_perspectiveLinkAddedCallbacks, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, _PerspectiveProxy_executeAction;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PerspectiveProxy = void 0;
const Links_1 = require("../links/Links");
const LinkQuery_1 = require("./LinkQuery");

@@ -24,2 +25,3 @@ class PerspectiveProxy {

_PerspectiveProxy_perspectiveLinkRemovedCallbacks.set(this, void 0);
_PerspectiveProxy_executeAction.set(this, void 0);
__classPrivateFieldSet(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, [], "f");

@@ -31,2 +33,32 @@ __classPrivateFieldSet(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, [], "f");

__classPrivateFieldGet(this, _PerspectiveProxy_client, "f").addPerspectiveLinkRemovedListener(__classPrivateFieldGet(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f"));
__classPrivateFieldSet(this, _PerspectiveProxy_executeAction, async (actions, expression) => {
console.log("execute:", actions);
const replaceThis = (input) => {
if (input)
return input.replace('this', expression);
else
return undefined;
};
for (let command of actions) {
switch (command.action) {
case 'addLink':
await this.add(new Links_1.Link({
source: replaceThis(command.source),
predicate: replaceThis(command.predicate),
target: replaceThis(command.target)
}));
break;
case 'removeLink':
const linkExpressions = await this.get(new LinkQuery_1.LinkQuery({
source: replaceThis(command.source),
predicate: replaceThis(command.predicate),
target: replaceThis(command.target)
}));
for (const linkExpression of linkExpressions) {
await this.remove(linkExpression);
}
break;
}
}
}, "f");
}

@@ -101,4 +133,43 @@ get uuid() {

}
// Returns all the SDNA flows defined in this perspective
async sdnaFlows() {
const allFlows = await this.infer("register_sdna_flow(X, _)");
return allFlows.map(x => x.X);
}
// Returns all SDNA flows that can be started from the given expression
async availableFlows(exprAddr) {
const availableFlows = await this.infer(`flowable("${exprAddr}", F), register_sdna_flow(X, F)`);
return availableFlows.map(x => x.X);
}
// Starts a new flow
async startFlow(flowName, exprAddr) {
let startAction = await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`);
// should always return one solution...
startAction = eval(startAction[0].Action);
await __classPrivateFieldGet(this, _PerspectiveProxy_executeAction, "f").call(this, startAction, exprAddr);
}
// Returns all expressions in the given state of given flow
async expressionsInFlowState(flowName, flowState) {
let expressions = await this.infer(`register_sdna_flow("${flowName}", F), flow_state(X, ${flowState}, F)`);
return expressions.map(r => r.X);
}
// Returns the given expression's flow state with regard to given flow
async flowState(flowName, exprAddr) {
let state = await this.infer(`register_sdna_flow("${flowName}", F), flow_state("${exprAddr}", X, F)`);
return state[0].X;
}
// Returns available action names, with regard to flow and expression's flow state
async flowActions(flowName, exprAddr) {
let actionNames = await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, Name, _, _)`);
return actionNames.map(r => r.Name);
}
// Runs given action
async runFlowAction(flowName, exprAddr, actionName) {
let action = await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`);
// should find only one
action = eval(action[0].Action);
await __classPrivateFieldGet(this, _PerspectiveProxy_executeAction, "f").call(this, action, exprAddr);
}
}
exports.PerspectiveProxy = PerspectiveProxy;
_PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_perspectiveLinkAddedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkRemovedCallbacks = new WeakMap();
_PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_perspectiveLinkAddedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkRemovedCallbacks = new WeakMap(), _PerspectiveProxy_executeAction = new WeakMap();

@@ -28,3 +28,10 @@ import PerspectiveClient, { LinkCallback } from "./PerspectiveClient";

setSingleTarget(link: Link): Promise<void>;
sdnaFlows(): Promise<string[]>;
availableFlows(exprAddr: string): Promise<string[]>;
startFlow(flowName: string, exprAddr: string): Promise<void>;
expressionsInFlowState(flowName: string, flowState: number): Promise<string[]>;
flowState(flowName: string, exprAddr: string): Promise<number>;
flowActions(flowName: string, exprAddr: string): Promise<string[]>;
runFlowAction(flowName: string, exprAddr: string, actionName: string): Promise<void>;
}
export {};

@@ -13,5 +13,6 @@ "use strict";

};
var _PerspectiveProxy_handle, _PerspectiveProxy_client, _PerspectiveProxy_perspectiveLinkAddedCallbacks, _PerspectiveProxy_perspectiveLinkRemovedCallbacks;
var _PerspectiveProxy_handle, _PerspectiveProxy_client, _PerspectiveProxy_perspectiveLinkAddedCallbacks, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, _PerspectiveProxy_executeAction;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PerspectiveProxy = void 0;
const Links_1 = require("../links/Links");
const LinkQuery_1 = require("./LinkQuery");

@@ -24,2 +25,3 @@ class PerspectiveProxy {

_PerspectiveProxy_perspectiveLinkRemovedCallbacks.set(this, void 0);
_PerspectiveProxy_executeAction.set(this, void 0);
__classPrivateFieldSet(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, [], "f");

@@ -31,2 +33,32 @@ __classPrivateFieldSet(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, [], "f");

__classPrivateFieldGet(this, _PerspectiveProxy_client, "f").addPerspectiveLinkRemovedListener(__classPrivateFieldGet(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f"));
__classPrivateFieldSet(this, _PerspectiveProxy_executeAction, async (actions, expression) => {
console.log("execute:", actions);
const replaceThis = (input) => {
if (input)
return input.replace('this', expression);
else
return undefined;
};
for (let command of actions) {
switch (command.action) {
case 'addLink':
await this.add(new Links_1.Link({
source: replaceThis(command.source),
predicate: replaceThis(command.predicate),
target: replaceThis(command.target)
}));
break;
case 'removeLink':
const linkExpressions = await this.get(new LinkQuery_1.LinkQuery({
source: replaceThis(command.source),
predicate: replaceThis(command.predicate),
target: replaceThis(command.target)
}));
for (const linkExpression of linkExpressions) {
await this.remove(linkExpression);
}
break;
}
}
}, "f");
}

@@ -101,4 +133,43 @@ get uuid() {

}
// Returns all the SDNA flows defined in this perspective
async sdnaFlows() {
const allFlows = await this.infer("register_sdna_flow(X, _)");
return allFlows.map(x => x.X);
}
// Returns all SDNA flows that can be started from the given expression
async availableFlows(exprAddr) {
const availableFlows = await this.infer(`flowable("${exprAddr}", F), register_sdna_flow(X, F)`);
return availableFlows.map(x => x.X);
}
// Starts a new flow
async startFlow(flowName, exprAddr) {
let startAction = await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`);
// should always return one solution...
startAction = eval(startAction[0].Action);
await __classPrivateFieldGet(this, _PerspectiveProxy_executeAction, "f").call(this, startAction, exprAddr);
}
// Returns all expressions in the given state of given flow
async expressionsInFlowState(flowName, flowState) {
let expressions = await this.infer(`register_sdna_flow("${flowName}", F), flow_state(X, ${flowState}, F)`);
return expressions.map(r => r.X);
}
// Returns the given expression's flow state with regard to given flow
async flowState(flowName, exprAddr) {
let state = await this.infer(`register_sdna_flow("${flowName}", F), flow_state("${exprAddr}", X, F)`);
return state[0].X;
}
// Returns available action names, with regard to flow and expression's flow state
async flowActions(flowName, exprAddr) {
let actionNames = await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, Name, _, _)`);
return actionNames.map(r => r.Name);
}
// Runs given action
async runFlowAction(flowName, exprAddr, actionName) {
let action = await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`);
// should find only one
action = eval(action[0].Action);
await __classPrivateFieldGet(this, _PerspectiveProxy_executeAction, "f").call(this, action, exprAddr);
}
}
exports.PerspectiveProxy = PerspectiveProxy;
_PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_perspectiveLinkAddedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkRemovedCallbacks = new WeakMap();
_PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_perspectiveLinkAddedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkRemovedCallbacks = new WeakMap(), _PerspectiveProxy_executeAction = new WeakMap();

2

package.json
{
"name": "@perspect3vism/ad4m",
"version": "0.1.30",
"version": "0.1.31",
"description": "*The Agent-Centric Distributed Application Meta-ontology* or just: *Agent-Centric DApp Meta-ontology* * A new meta-ontology for interoperable, decentralized application design * A spanning-layer to enable seamless integration between Holochain DNAs, blockchains, linked-data structures/ontologies and centralized back-ends * The basis for turning distinct, monolithic and siloed apps into a global, open and interoperable sense-making network",

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

@@ -15,2 +15,3 @@ import PerspectiveClient, { LinkCallback, PerspectiveHandleCallback } from "./PerspectiveClient";

#perspectiveLinkRemovedCallbacks: PerspectiveHandleCallback[]
#executeAction

@@ -24,2 +25,34 @@ constructor(handle: PerspectiveHandle, ad4m: PerspectiveClient) {

this.#client.addPerspectiveLinkRemovedListener(this.#handle.uuid, this.#perspectiveLinkRemovedCallbacks)
this.#executeAction = async (actions, expression) => {
console.log("execute:", actions)
const replaceThis = (input: string|undefined) => {
if(input)
return input.replace('this', expression)
else
return undefined
}
for(let command of actions) {
switch(command.action) {
case 'addLink':
await this.add(new Link({
source: replaceThis(command.source),
predicate: replaceThis(command.predicate),
target: replaceThis(command.target)
}))
break;
case 'removeLink':
const linkExpressions = await this.get(new LinkQuery({
source: replaceThis(command.source),
predicate: replaceThis(command.predicate),
target: replaceThis(command.target)}))
for (const linkExpression of linkExpressions) {
await this.remove(linkExpression)
}
break;
}
}
}
}

@@ -109,2 +142,49 @@

}
// Returns all the SDNA flows defined in this perspective
async sdnaFlows(): Promise<string[]> {
const allFlows = await this.infer("register_sdna_flow(X, _)")
return allFlows.map(x => x.X)
}
// Returns all SDNA flows that can be started from the given expression
async availableFlows(exprAddr: string): Promise<string[]> {
const availableFlows = await this.infer(`flowable("${exprAddr}", F), register_sdna_flow(X, F)`)
return availableFlows.map(x => x.X)
}
// Starts a new flow
async startFlow(flowName: string, exprAddr: string) {
let startAction = await this.infer(`start_action(Action, F), register_sdna_flow("${flowName}", F)`)
// should always return one solution...
startAction = eval(startAction[0].Action)
await this.#executeAction(startAction, exprAddr)
}
// Returns all expressions in the given state of given flow
async expressionsInFlowState(flowName: string, flowState: number): Promise<string[]> {
let expressions = await this.infer(`register_sdna_flow("${flowName}", F), flow_state(X, ${flowState}, F)`)
return expressions.map(r => r.X)
}
// Returns the given expression's flow state with regard to given flow
async flowState(flowName: string, exprAddr: string): Promise<number> {
let state = await this.infer(`register_sdna_flow("${flowName}", F), flow_state("${exprAddr}", X, F)`)
return state[0].X
}
// Returns available action names, with regard to flow and expression's flow state
async flowActions(flowName: string, exprAddr: string): Promise<string[]> {
let actionNames = await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, Name, _, _)`)
return actionNames.map(r => r.Name)
}
// Runs given action
async runFlowAction(flowName: string, exprAddr: string, actionName: string) {
let action = await this.infer(`register_sdna_flow("${flowName}", Flow), flow_state("${exprAddr}", State, Flow), action(State, "${actionName}", _, Action)`)
// should find only one
action = eval(action[0].Action)
await this.#executeAction(action, exprAddr)
}
}

Sorry, the diff of this file is too big to display

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