@bavard/agent-config
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -11,3 +11,2 @@ import { BaseAgentAction } from './actions/base-action'; | ||
export declare class AgentConfig { | ||
#private; | ||
readonly uname: string; | ||
@@ -21,2 +20,3 @@ readonly projectId: string; | ||
private graphPolicies; | ||
private activePolicyName?; | ||
presetResponseOptions: IResponseOption[]; | ||
@@ -43,3 +43,3 @@ constructor(projectId: string, uname: string); | ||
getActiveGraphPolicy(): GraphPolicy | undefined; | ||
set activePolicyName(name: string); | ||
setActivePolicyName(name: string): void; | ||
toJsonObj(): IAgentConfig; | ||
@@ -46,0 +46,0 @@ copy(): AgentConfig; |
"use strict"; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) { | ||
if (!privateMap.has(receiver)) { | ||
throw new TypeError("attempted to get private field on non-instance"); | ||
} | ||
return privateMap.get(receiver); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { | ||
if (!privateMap.has(receiver)) { | ||
throw new TypeError("attempted to set private field on non-instance"); | ||
} | ||
privateMap.set(receiver, value); | ||
return value; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _activePolicyName; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -39,3 +25,2 @@ exports.AgentConfig = exports.EPolicyType = void 0; | ||
this.graphPolicies = new Map(); | ||
_activePolicyName.set(this, void 0); | ||
this.presetResponseOptions = []; | ||
@@ -46,4 +31,4 @@ this.projectId = projectId; | ||
getDefaultPolicyType() { | ||
if (__classPrivateFieldGet(this, _activePolicyName) && | ||
this.graphPolicies.has(__classPrivateFieldGet(this, _activePolicyName))) { | ||
if (this.activePolicyName && | ||
this.graphPolicies.has(this.activePolicyName)) { | ||
return EPolicyType.GRAPH; | ||
@@ -127,10 +112,10 @@ } | ||
getActiveGraphPolicy() { | ||
if (__classPrivateFieldGet(this, _activePolicyName) && | ||
this.graphPolicies.has(__classPrivateFieldGet(this, _activePolicyName))) { | ||
return this.graphPolicies.get(__classPrivateFieldGet(this, _activePolicyName)); | ||
if (this.activePolicyName && | ||
this.graphPolicies.has(this.activePolicyName)) { | ||
return this.graphPolicies.get(this.activePolicyName); | ||
} | ||
} | ||
set activePolicyName(name) { | ||
setActivePolicyName(name) { | ||
if (this.graphPolicies.has(name)) { | ||
__classPrivateFieldSet(this, _activePolicyName, name); | ||
this.activePolicyName = name; | ||
} | ||
@@ -144,3 +129,3 @@ else { | ||
const jsonObj = { | ||
activePolicyName: __classPrivateFieldGet(this, _activePolicyName), | ||
activePolicyName: this.activePolicyName, | ||
version: packageJson.version, | ||
@@ -167,3 +152,2 @@ uname: this.uname, | ||
config.language = jsonObj.language; | ||
__classPrivateFieldSet(config, _activePolicyName, jsonObj.activePolicyName); | ||
for (const slot of jsonObj.slots || []) { | ||
@@ -185,2 +169,3 @@ config.addSlot(slot.name, slot.type); | ||
config.presetResponseOptions = jsonObj.presetResponseOptions || []; | ||
jsonObj.activePolicyName && config.setActivePolicyName(jsonObj.activePolicyName); | ||
return config; | ||
@@ -190,2 +175,1 @@ } | ||
exports.AgentConfig = AgentConfig; | ||
_activePolicyName = new WeakMap(); |
{ | ||
"name": "@bavard/agent-config", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -24,3 +24,3 @@ import { BaseAgentAction } from './actions/base-action'; | ||
private graphPolicies: Map<string, GraphPolicy> = new Map(); | ||
#activePolicyName?: string; | ||
private activePolicyName?: string; | ||
presetResponseOptions: IResponseOption[] = []; | ||
@@ -35,4 +35,4 @@ | ||
if ( | ||
this.#activePolicyName && | ||
this.graphPolicies.has(this.#activePolicyName) | ||
this.activePolicyName && | ||
this.graphPolicies.has(this.activePolicyName) | ||
) { | ||
@@ -136,12 +136,12 @@ return EPolicyType.GRAPH; | ||
if ( | ||
this.#activePolicyName && | ||
this.graphPolicies.has(this.#activePolicyName) | ||
this.activePolicyName && | ||
this.graphPolicies.has(this.activePolicyName) | ||
) { | ||
return this.graphPolicies.get(this.#activePolicyName); | ||
return this.graphPolicies.get(this.activePolicyName); | ||
} | ||
} | ||
set activePolicyName(name: string) { | ||
setActivePolicyName(name: string) { | ||
if (this.graphPolicies.has(name)) { | ||
this.#activePolicyName = name; | ||
this.activePolicyName = name; | ||
} else { | ||
@@ -155,3 +155,3 @@ throw new Error(`No graph policy with name "${name}" was found.`); | ||
const jsonObj: IAgentConfig = { | ||
activePolicyName: this.#activePolicyName, | ||
activePolicyName: this.activePolicyName, | ||
version: packageJson.version, | ||
@@ -182,3 +182,2 @@ uname: this.uname, | ||
config.language = jsonObj.language; | ||
config.#activePolicyName = jsonObj.activePolicyName; | ||
@@ -206,2 +205,3 @@ for (const slot of jsonObj.slots || []) { | ||
config.presetResponseOptions = jsonObj.presetResponseOptions || []; | ||
jsonObj.activePolicyName && config.setActivePolicyName(jsonObj.activePolicyName); | ||
@@ -208,0 +208,0 @@ return config; |
135887
4122