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

theprogrammablemind

Package Overview
Dependencies
Maintainers
0
Versions
625
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

theprogrammablemind - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

src/configHelpers.js

5

index.js
const { Semantics, Semantic } = require('./src/semantics')
const { Generators, Generator } = require('./src/generators')
const { Config } = require('./src/config')
const { w, where } = require('./src/helpers')
const Digraph = require('./src/digraph')

@@ -17,5 +18,5 @@ const client = require('./client')

ensureTestFile: client.ensureTestFile,
where: client.where,
where,
stableId: client.stableId,
w: client.w,
w,
Config,

@@ -22,0 +23,0 @@ Semantics,

26

package.json
{
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"eslint": "^7.31.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4",
"jest": "^29.7.0",
"@typescript-eslint/parser": "^4.28.4",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"eslint-plugin-node": "^11.1.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-promise": "^5.1.0",
"eslint": "^7.31.0"
"jest": "^29.7.0"
},

@@ -46,2 +46,3 @@ "scripts": {

"src/config.js",
"src/configHelpers.js",
"src/copy.js",

@@ -56,17 +57,16 @@ "src/digraph.js",

"dependencies": {
"base-64": "^1.0.0",
"deep-equal": "^2.0.4",
"uuid": "^8.3.2",
"fs": "0.0.1-security",
"json-diff": "^1.0.3",
"json-stable-stringify": "^1.0.1",
"lodash": "^4.17.20",
"fs": "0.0.1-security",
"base-64": "^1.0.0",
"sort-json": "^2.0.0",
"node-fetch": "^2.6.1",
"readline": "^1.3.0",
"scriptjs": "^2.5.9",
"underscore": "^1.13.1",
"json-stable-stringify": "^1.0.1",
"node-fetch": "^2.6.1"
"sort-json": "^2.0.0",
"uuid": "^8.3.2"
},
"version": "8.0.0",
"version": "8.1.0",
"license": "UNLICENSED"
}

@@ -47,3 +47,3 @@ const { args: contextArgs, normalizeGenerator } = require('./helpers')

matches (baseArgs, objects, context, hierarchy, config, options = {}) {
async matches (baseArgs, objects, context, hierarchy, config, options = {}) {
if (objects && objects.namespaced) {

@@ -67,7 +67,7 @@ objects = objects.namespaced[this.uuid]

// return this.match(args)
const matches = this.match(args)
const matches = await this.match(args)
if ((matches && (options.debug || {}).match) ||
callId == this.callId) {
debugger // next line is the matcher
this.match(args)
await this.match(args)
}

@@ -78,3 +78,3 @@ return matches

// apply (baseArgs, objects, g, gs, context, hierarchy, config, response, log, options = {}) {
apply (baseArgs, objects, context, hierarchy, config, response, log, options = {}) {
async apply (baseArgs, objects, context, hierarchy, config, response, log, options = {}) {
if (!log) {

@@ -135,3 +135,3 @@ throw new Error('generators.apply argument log is required')

}
return this._apply(args)
return await this._apply(args)
}

@@ -172,3 +172,3 @@ }

// assumed - properties added to context before the generators are called. For setting paraphrase property
apply (args, context, assumed = {}, options = {}) {
async apply (args, context, assumed = {}, options = {}) {
if (Array.isArray(context)) {

@@ -194,3 +194,3 @@ throw new Error('Expected a context not an array')

const generator = this.generators[igenerator]
if (generator.matches(args, objects, context, hierarchy, config, options)) {
if (await generator.matches(args, objects, context, hierarchy, config, options)) {
const log = (message) => { this.logs.push(message) }

@@ -200,3 +200,3 @@ // this.logs.push(`Generators: applied ${generator.toString()}\n to\n ${JSON.stringify(context)}`)

try {
generated = generator.apply(args, objects, context, hierarchy, config, response, log)
generated = await generator.apply(args, objects, context, hierarchy, config, response, log)
} catch (e) {

@@ -203,0 +203,0 @@ // the next if handle this

const deepEqual = require('deep-equal')
const stringify = require('json-stable-stringify')
function where (goUp = 2) {
const e = new Error()
const regexForm1 = /\((.*):(\d+):(\d+)\)$/
const regexForm2 = /at (.*):(\d+):(\d+)$/
const lines = e.stack.split('\n')
let line
let match
for (line of lines.slice(1)) {
// if (!(line.includes('config.js:') || line.includes('client.js:') || line.includes('<anonymous>'))) {
if (!(line.includes('config.js:') || line.includes('client.js:') || line.includes('helpers.js:'))) {
match = regexForm1.exec(line) || regexForm2.exec(line)
if (!match) {
continue
}
break
}
}
// const line = e.stack.split("\n")[goUp];
// const match = regexForm1.exec(line) || regexForm2.exec(line)
if (match) {
return `${match[1]}:${match[2]}`
} else {
return 'running in browser or in an async call so the stack is broken.'
}
}
function w (func) {
func.where = where(3)
return func
}
// properties - the properties that correspond to types

@@ -406,3 +437,5 @@ // types - the expected types of the properties

sortJson,
subPriority
subPriority,
where,
w,
}

@@ -52,3 +52,3 @@

if (!Array.isArray(object[property])) {
return projection
continue
}

@@ -55,0 +55,0 @@ for (const propertyRef of object[property]) {

@@ -52,29 +52,28 @@ const { args: contextArgs, normalizeGenerator, normalizeSemantic } = require('./helpers')

matches (baseArgs, context, options = {}) {
const hierarchy = baseArgs.hierarchy
const config = baseArgs.config
const objects = baseArgs.getObjects(this.uuid)
// const ask = baseArgs.getAsk(this.uuid)
// return this.matcher(Object.assign({}, argsBase, {args: contextArgs(context, hierarchy), objects: objects, global: objects, context: context, hierarchy: hierarchy, api: this.getAPI(config)})
const callId = baseArgs.calls.current()
const moreArgs = {
uuid: this.uuid,
args: contextArgs(context, hierarchy),
objects,
global: objects,
context: context,
// hierarchy: hierarchy,
callId,
api: this.getAPI(config),
apis: this.getAPIs(config)
fixUpArgs (args, context) {
args.uuid = this.uuid
args.callId = args.calls.current()
const objects = args.getObjects(this.uuid)
args.objects = objects
args.global = objects
const config = args.config
args.api = this.getAPI(config)
args.apis = this.getAPIs(config)
args.args = contextArgs(context, args.hierarchy)
args.context = context
let n = (id) => id
if (config && 'nsToString' in config) {
n = (id) => config.nsToString(id)
}
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
args.n = n
args.uuid = this.uuid
Object.assign(args, (args.getUUIDScoped || (() => { return {} }))(this.uuid))
}
const matches = this.matcher(args)
if (matches && (options.debug || {}).match ||
callId == this.callId) {
async matches (args, context, options = {}) {
this.fixUpArgs(args, context)
const matches = await this.matcher(args)
if (matches && (options.debug || {}).match || args.callId == this.callId) {
debugger // next line is the matcher
this.matcher(args)
await this.matcher(args)
}

@@ -84,41 +83,15 @@ return matches

apply (baseArgs, context, s, log, options = {}) {
const { hierarchy, config, response } = baseArgs
const objects = baseArgs.getObjects(this.uuid)
async apply (args, context, s, options = {}) {
const { config } = args
if (config && config.debugLoops) {
console.log('apply', this.toLabel())
}
if (baseArgs.calls && config && baseArgs.calls.stack.length > config.maxDepth) {
if (args.calls && config && args.calls.stack.length > config.maxDepth) {
throw new Error(`Max depth of ${config.maxDepth} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
}
// const ask = baseArgs.getAsk(this.uuid)
if (!log) {
console.trace()
throw new Error('log is a required argument')
}
const contextPrime = Object.assign({}, context)
let n = (id) => id
if (config && 'nsToString' in config) {
n = (id) => config.nsToString(id)
}
const callId = baseArgs.calls.current()
const moreArgs = {
uuid: this.uuid,
callId,
args: contextArgs(context, hierarchy),
objects,
log,
global: objects,
n,
context: contextPrime,
uuid: this.uuid,
// config,
response,
api: this.getAPI(config),
apis: this.getAPIs(config)
}
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
if ((options.debug || {}).apply ||
callId == this.callId) {
this.fixUpArgs(args, contextPrime)
if ((options.debug || {}).apply || args.callId == this.callId) {
debugger

@@ -129,3 +102,3 @@ }

}
this._apply(args)
await this._apply(args)
return contextPrime

@@ -182,3 +155,3 @@ }

applyToContext (args, context, options) {
async applyToContext (args, context, options) {
// let context_prime = {}

@@ -188,2 +161,3 @@ if (!(context instanceof Array || context instanceof Object)) {

}
args = { ...args }
const config = args.config

@@ -196,2 +170,4 @@ let contextPrime = Object.assign({}, context)

let seenQuestion = false
const deferred = []
args.log = (message) => { this.logs.push(message) }
for (const isemantic in this.semantics) {

@@ -206,3 +182,3 @@ const semantic = this.semantics[isemantic]

}
if (semantic.matches(args, context, options)) {
if (await semantic.matches(args, context, options)) {
if (!this.calls[counter]) {

@@ -212,5 +188,13 @@ this.calls[counter] = 0

this.calls[counter] += 1
const log = (message) => { this.logs.push(message) }
try {
contextPrime = semantic.apply(args, context, s, log, options)
let deferWasCalled = false
const defer = (listener) => {
deferred.push({ semantic, listener })
deferWasCalled = true
}
args.defer = defer
contextPrime = await semantic.apply(args, context, s, options)
if (deferWasCalled) {
continue
}
if (!contextPrime.controlKeepMotivation && semantic.oneShot) {

@@ -220,6 +204,9 @@ // semantic.tied_ids.forEach((tied_id) => args.config.removeSemantic(tied_id))

}
for (const { listener } of deferred) {
listener(args)
}
} catch (e) {
contextPrime = null
let errorMessage
e.retryCall = () => semantic.apply(args, context, s, log, options)
e.retryCall = () => semantic.apply(args, context, s, options)
const help = 'The error has a retryCall property that will recall the function that failed.'

@@ -292,2 +279,9 @@ if (e.stack && e.message) {

lines.setElement(1, 2, JSON.stringify(contextPrime, null, 2))
for (const { semantic } of deferred) {
lines.setElement(0, 1, 'DEFERRED')
lines.setElement(0, 2, semantic.toLabel())
lines.newRow()
lines.setElement(0, 2, semantic.toString())
lines.newRow()
}
this.logs.push(lines.toString())

@@ -323,15 +317,15 @@ }

applyToContexts (args, contexts, options) {
async applyToContexts (args, contexts, options) {
const contextsPrime = []
contexts.forEach((context) => {
contextsPrime.push(this.applyToContext(args, context, options))
})
for (const context of contexts) {
contextsPrime.push(await this.applyToContext(args, context, options))
}
return contextsPrime
}
apply (args, context, options) {
async apply (args, context, options) {
if (Array.isArray(context)) {
return this.applyToContexts(args, context, options)
return await this.applyToContexts(args, context, options)
} else if (context instanceof Object) {
return this.applyToContext(args, context, options)
return await this.applyToContext(args, context, options)
} else {

@@ -338,0 +332,0 @@ return context

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

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