agent-relay 4.0.19 → 4.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1407 -537
- package/dist/src/cli/commands/messaging.d.ts +44 -0
- package/dist/src/cli/commands/messaging.d.ts.map +1 -1
- package/dist/src/cli/commands/messaging.js +195 -8
- package/dist/src/cli/commands/messaging.js.map +1 -1
- package/dist/src/cli/commands/setup.d.ts +30 -1
- package/dist/src/cli/commands/setup.d.ts.map +1 -1
- package/dist/src/cli/commands/setup.js +102 -85
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/node_modules/@agent-relay/cloud/dist/auth.d.ts +2 -2
- package/node_modules/@agent-relay/cloud/dist/auth.d.ts.map +1 -1
- package/node_modules/@agent-relay/cloud/dist/auth.js +108 -62
- package/node_modules/@agent-relay/cloud/dist/auth.js.map +1 -1
- package/node_modules/@agent-relay/cloud/package.json +2 -2
- package/node_modules/@agent-relay/config/package.json +1 -1
- package/node_modules/@agent-relay/hooks/package.json +4 -4
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.d.ts +5 -35
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.d.ts.map +1 -1
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.js +158 -292
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.js.map +1 -1
- package/node_modules/@agent-relay/sdk/package.json +3 -2
- package/node_modules/@agent-relay/telemetry/package.json +1 -1
- package/node_modules/@agent-relay/trajectory/package.json +2 -2
- package/node_modules/@agent-relay/user-directory/package.json +2 -2
- package/node_modules/@agent-relay/utils/package.json +2 -2
- package/node_modules/@clack/core/CHANGELOG.md +200 -0
- package/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/@clack/core/README.md +22 -0
- package/node_modules/@clack/core/dist/index.cjs +15 -0
- package/node_modules/@clack/core/dist/index.cjs.map +1 -0
- package/node_modules/@clack/core/dist/index.d.cts +151 -0
- package/node_modules/@clack/core/dist/index.d.mts +151 -0
- package/node_modules/@clack/core/dist/index.d.ts +151 -0
- package/node_modules/@clack/core/dist/index.mjs +15 -0
- package/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/node_modules/@clack/core/package.json +62 -0
- package/node_modules/@clack/prompts/CHANGELOG.md +256 -0
- package/node_modules/@clack/prompts/LICENSE +23 -0
- package/node_modules/@clack/prompts/README.md +158 -0
- package/node_modules/@clack/prompts/dist/index.cjs +77 -0
- package/node_modules/@clack/prompts/dist/index.d.ts +106 -0
- package/node_modules/@clack/prompts/dist/index.mjs +77 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/index.d.ts +12 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/index.js +17 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/license +9 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/package.json +43 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/readme.md +35 -0
- package/node_modules/@clack/prompts/package.json +65 -0
- package/node_modules/@smithy/config-resolver/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +154 -61
- package/node_modules/@smithy/util-endpoints/dist-es/bdd/BinaryDecisionDiagram.js +15 -0
- package/node_modules/@smithy/util-endpoints/dist-es/decideEndpoint.js +41 -0
- package/node_modules/@smithy/util-endpoints/dist-es/index.js +2 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/coalesce.js +8 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/index.js +3 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/ite.js +3 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/split.js +13 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/substring.js +1 -1
- package/node_modules/@smithy/util-endpoints/dist-es/utils/endpointFunctions.js +4 -1
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +20 -5
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateTemplate.js +3 -6
- package/node_modules/@smithy/util-endpoints/dist-es/utils/getReferenceValue.js +1 -5
- package/node_modules/@smithy/util-endpoints/dist-types/bdd/BinaryDecisionDiagram.d.ts +22 -0
- package/node_modules/@smithy/util-endpoints/dist-types/decideEndpoint.d.ts +7 -0
- package/node_modules/@smithy/util-endpoints/dist-types/index.d.ts +2 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/coalesce.d.ts +7 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/index.d.ts +3 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/ite.d.ts +6 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/split.d.ts +11 -0
- package/node_modules/@smithy/util-endpoints/dist-types/utils/endpointFunctions.d.ts +4 -0
- package/node_modules/@smithy/util-endpoints/dist-types/utils/getReferenceValue.d.ts +3 -1
- package/node_modules/@smithy/util-endpoints/package.json +1 -1
- package/node_modules/agent-trajectories/README.md +562 -0
- package/node_modules/agent-trajectories/dist/chunk-W222QB6V.js +2036 -0
- package/node_modules/agent-trajectories/dist/chunk-W222QB6V.js.map +1 -0
- package/node_modules/agent-trajectories/dist/cli/index.d.ts +2 -0
- package/node_modules/agent-trajectories/dist/cli/index.js +4592 -0
- package/node_modules/agent-trajectories/dist/cli/index.js.map +1 -0
- package/node_modules/agent-trajectories/dist/index-7tzw_CMS.d.ts +1777 -0
- package/node_modules/agent-trajectories/dist/index.d.ts +90 -0
- package/node_modules/agent-trajectories/dist/index.js +73 -0
- package/node_modules/agent-trajectories/dist/index.js.map +1 -0
- package/node_modules/agent-trajectories/dist/sdk/index.d.ts +2 -0
- package/node_modules/agent-trajectories/dist/sdk/index.js +39 -0
- package/node_modules/agent-trajectories/dist/sdk/index.js.map +1 -0
- package/node_modules/agent-trajectories/package.json +72 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1157 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2509 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +520 -0
- package/node_modules/commander/lib/option.js +330 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +84 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +969 -0
- package/node_modules/picocolors/LICENSE +15 -0
- package/node_modules/picocolors/README.md +21 -0
- package/node_modules/picocolors/package.json +25 -0
- package/node_modules/picocolors/picocolors.browser.js +4 -0
- package/node_modules/picocolors/picocolors.d.ts +5 -0
- package/node_modules/picocolors/picocolors.js +75 -0
- package/node_modules/picocolors/types.d.ts +51 -0
- package/node_modules/sisteransi/license +21 -0
- package/node_modules/sisteransi/package.json +34 -0
- package/node_modules/sisteransi/readme.md +113 -0
- package/node_modules/sisteransi/src/index.js +58 -0
- package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/package.json +10 -10
- package/packages/cloud/dist/auth.d.ts +2 -2
- package/packages/cloud/dist/auth.d.ts.map +1 -1
- package/packages/cloud/dist/auth.js +108 -62
- package/packages/cloud/dist/auth.js.map +1 -1
- package/packages/cloud/package.json +2 -2
- package/packages/config/package.json +1 -1
- package/packages/hooks/package.json +4 -4
- package/packages/sdk/dist/workflows/trajectory.d.ts +5 -35
- package/packages/sdk/dist/workflows/trajectory.d.ts.map +1 -1
- package/packages/sdk/dist/workflows/trajectory.js +158 -292
- package/packages/sdk/dist/workflows/trajectory.js.map +1 -1
- package/packages/sdk/package.json +3 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +2 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import{TextPrompt as V,PasswordPrompt as j,ConfirmPrompt as N,SelectPrompt as k,SelectKeyPrompt as W,MultiSelectPrompt as D,GroupMultiSelectPrompt as L,isCancel as G,block as F}from"@clack/core";export{isCancel}from"@clack/core";import h from"node:process";import e from"picocolors";import{cursor as T,erase as A}from"sisteransi";function q(){return h.platform!=="win32"?h.env.TERM!=="linux":Boolean(h.env.CI)||Boolean(h.env.WT_SESSION)||Boolean(h.env.TERMINUS_SUBLIME)||h.env.ConEmuTask==="{cmd::Cmder}"||h.env.TERM_PROGRAM==="Terminus-Sublime"||h.env.TERM_PROGRAM==="vscode"||h.env.TERM==="xterm-256color"||h.env.TERM==="alacritty"||h.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const _=q(),o=(r,n)=>_?r:n,H=o("\u25C6","*"),I=o("\u25A0","x"),x=o("\u25B2","x"),S=o("\u25C7","o"),K=o("\u250C","T"),a=o("\u2502","|"),d=o("\u2514","\u2014"),b=o("\u25CF",">"),E=o("\u25CB"," "),C=o("\u25FB","[\u2022]"),w=o("\u25FC","[+]"),M=o("\u25FB","[ ]"),U=o("\u25AA","\u2022"),B=o("\u2500","-"),Z=o("\u256E","+"),z=o("\u251C","+"),X=o("\u256F","+"),J=o("\u25CF","\u2022"),Y=o("\u25C6","*"),Q=o("\u25B2","!"),ee=o("\u25A0","x"),y=r=>{switch(r){case"initial":case"active":return e.cyan(H);case"cancel":return e.red(I);case"error":return e.yellow(x);case"submit":return e.green(S)}},te=r=>new V({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){const n=`${e.gray(a)}
|
|
2
|
+
${y(this.state)} ${r.message}
|
|
3
|
+
`,i=r.placeholder?e.inverse(r.placeholder[0])+e.dim(r.placeholder.slice(1)):e.inverse(e.hidden("_")),t=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()}
|
|
4
|
+
${e.yellow(a)} ${t}
|
|
5
|
+
${e.yellow(d)} ${e.yellow(this.error)}
|
|
6
|
+
`;case"submit":return`${n}${e.gray(a)} ${e.dim(this.value||r.placeholder)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(this.value??""))}${this.value?.trim()?`
|
|
7
|
+
`+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${t}
|
|
8
|
+
${e.cyan(d)}
|
|
9
|
+
`}}}).prompt(),re=r=>new j({validate:r.validate,mask:r.mask??U,render(){const n=`${e.gray(a)}
|
|
10
|
+
${y(this.state)} ${r.message}
|
|
11
|
+
`,i=this.valueWithCursor,t=this.masked;switch(this.state){case"error":return`${n.trim()}
|
|
12
|
+
${e.yellow(a)} ${t}
|
|
13
|
+
${e.yellow(d)} ${e.yellow(this.error)}
|
|
14
|
+
`;case"submit":return`${n}${e.gray(a)} ${e.dim(t)}`;case"cancel":return`${n}${e.gray(a)} ${e.strikethrough(e.dim(t??""))}${t?`
|
|
15
|
+
`+e.gray(a):""}`;default:return`${n}${e.cyan(a)} ${i}
|
|
16
|
+
${e.cyan(d)}
|
|
17
|
+
`}}}).prompt(),se=r=>{const n=r.active??"Yes",i=r.inactive??"No";return new N({active:n,inactive:i,initialValue:r.initialValue??!0,render(){const t=`${e.gray(a)}
|
|
18
|
+
${y(this.state)} ${r.message}
|
|
19
|
+
`,s=this.value?n:i;switch(this.state){case"submit":return`${t}${e.gray(a)} ${e.dim(s)}`;case"cancel":return`${t}${e.gray(a)} ${e.strikethrough(e.dim(s))}
|
|
20
|
+
${e.gray(a)}`;default:return`${t}${e.cyan(a)} ${this.value?`${e.green(b)} ${n}`:`${e.dim(E)} ${e.dim(n)}`} ${e.dim("/")} ${this.value?`${e.dim(E)} ${e.dim(i)}`:`${e.green(b)} ${i}`}
|
|
21
|
+
${e.cyan(d)}
|
|
22
|
+
`}}}).prompt()},ie=r=>{const n=(t,s)=>{const c=t.label??String(t.value);return s==="active"?`${e.green(b)} ${c} ${t.hint?e.dim(`(${t.hint})`):""}`:s==="selected"?`${e.dim(c)}`:s==="cancelled"?`${e.strikethrough(e.dim(c))}`:`${e.dim(E)} ${e.dim(c)}`};let i=0;return new k({options:r.options,initialValue:r.initialValue,render(){const t=`${e.gray(a)}
|
|
23
|
+
${y(this.state)} ${r.message}
|
|
24
|
+
`;switch(this.state){case"submit":return`${t}${e.gray(a)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${e.gray(a)} ${n(this.options[this.cursor],"cancelled")}
|
|
25
|
+
${e.gray(a)}`;default:{const s=r.maxItems===void 0?1/0:Math.max(r.maxItems,5);this.cursor>=i+s-3?i=Math.max(Math.min(this.cursor-s+3,this.options.length-s),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));const c=s<this.options.length&&i>0,l=s<this.options.length&&i+s<this.options.length;return`${t}${e.cyan(a)} ${this.options.slice(i,i+s).map((u,m,$)=>m===0&&c?e.dim("..."):m===$.length-1&&l?e.dim("..."):n(u,m+i===this.cursor?"active":"inactive")).join(`
|
|
26
|
+
${e.cyan(a)} `)}
|
|
27
|
+
${e.cyan(d)}
|
|
28
|
+
`}}}}).prompt()},ne=r=>{const n=(i,t="inactive")=>{const s=i.label??String(i.value);return t==="selected"?`${e.dim(s)}`:t==="cancelled"?`${e.strikethrough(e.dim(s))}`:t==="active"?`${e.bgCyan(e.gray(` ${i.value} `))} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:`${e.gray(e.bgWhite(e.inverse(` ${i.value} `)))} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`};return new W({options:r.options,initialValue:r.initialValue,render(){const i=`${e.gray(a)}
|
|
29
|
+
${y(this.state)} ${r.message}
|
|
30
|
+
`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${n(this.options.find(t=>t.value===this.value),"selected")}`;case"cancel":return`${i}${e.gray(a)} ${n(this.options[0],"cancelled")}
|
|
31
|
+
${e.gray(a)}`;default:return`${i}${e.cyan(a)} ${this.options.map((t,s)=>n(t,s===this.cursor?"active":"inactive")).join(`
|
|
32
|
+
${e.cyan(a)} `)}
|
|
33
|
+
${e.cyan(d)}
|
|
34
|
+
`}}}).prompt()},ae=r=>{const n=(i,t)=>{const s=i.label??String(i.value);return t==="active"?`${e.cyan(C)} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="selected"?`${e.green(w)} ${e.dim(s)}`:t==="cancelled"?`${e.strikethrough(e.dim(s))}`:t==="active-selected"?`${e.green(w)} ${s} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="submitted"?`${e.dim(s)}`:`${e.dim(M)} ${e.dim(s)}`};return new D({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
35
|
+
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let i=`${e.gray(a)}
|
|
36
|
+
${y(this.state)} ${r.message}
|
|
37
|
+
`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${this.options.filter(({value:t})=>this.value.includes(t)).map(t=>n(t,"submitted")).join(e.dim(", "))||e.dim("none")}`;case"cancel":{const t=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${i}${e.gray(a)} ${t.trim()?`${t}
|
|
38
|
+
${e.gray(a)}`:""}`}case"error":{const t=this.error.split(`
|
|
39
|
+
`).map((s,c)=>c===0?`${e.yellow(d)} ${e.yellow(s)}`:` ${s}`).join(`
|
|
40
|
+
`);return i+e.yellow(a)+" "+this.options.map((s,c)=>{const l=this.value.includes(s.value),u=c===this.cursor;return u&&l?n(s,"active-selected"):l?n(s,"selected"):n(s,u?"active":"inactive")}).join(`
|
|
41
|
+
${e.yellow(a)} `)+`
|
|
42
|
+
`+t+`
|
|
43
|
+
`}default:return`${i}${e.cyan(a)} ${this.options.map((t,s)=>{const c=this.value.includes(t.value),l=s===this.cursor;return l&&c?n(t,"active-selected"):c?n(t,"selected"):n(t,l?"active":"inactive")}).join(`
|
|
44
|
+
${e.cyan(a)} `)}
|
|
45
|
+
${e.cyan(d)}
|
|
46
|
+
`}}}).prompt()},ce=r=>{const n=(i,t,s=[])=>{const c=i.label??String(i.value),l=typeof i.group=="string",u=l&&(s[s.indexOf(i)+1]??{group:!0}),m=l&&u.group===!0,$=l?`${m?d:a} `:"";return t==="active"?`${e.dim($)}${e.cyan(C)} ${c} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="group-active"?`${$}${e.cyan(C)} ${e.dim(c)}`:t==="group-active-selected"?`${$}${e.green(w)} ${e.dim(c)}`:t==="selected"?`${e.dim($)}${e.green(w)} ${e.dim(c)}`:t==="cancelled"?`${e.strikethrough(e.dim(c))}`:t==="active-selected"?`${e.dim($)}${e.green(w)} ${c} ${i.hint?e.dim(`(${i.hint})`):""}`:t==="submitted"?`${e.dim(c)}`:`${e.dim($)}${e.dim(M)} ${e.dim(c)}`};return new L({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
47
|
+
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`},render(){let i=`${e.gray(a)}
|
|
48
|
+
${y(this.state)} ${r.message}
|
|
49
|
+
`;switch(this.state){case"submit":return`${i}${e.gray(a)} ${this.options.filter(({value:t})=>this.value.includes(t)).map(t=>n(t,"submitted")).join(e.dim(", "))}`;case"cancel":{const t=this.options.filter(({value:s})=>this.value.includes(s)).map(s=>n(s,"cancelled")).join(e.dim(", "));return`${i}${e.gray(a)} ${t.trim()?`${t}
|
|
50
|
+
${e.gray(a)}`:""}`}case"error":{const t=this.error.split(`
|
|
51
|
+
`).map((s,c)=>c===0?`${e.yellow(d)} ${e.yellow(s)}`:` ${s}`).join(`
|
|
52
|
+
`);return`${i}${e.yellow(a)} ${this.options.map((s,c,l)=>{const u=this.value.includes(s.value)||s.group===!0&&this.isGroupSelected(`${s.value}`),m=c===this.cursor;return!m&&typeof s.group=="string"&&this.options[this.cursor].value===s.group?n(s,u?"group-active-selected":"group-active",l):m&&u?n(s,"active-selected",l):u?n(s,"selected",l):n(s,m?"active":"inactive",l)}).join(`
|
|
53
|
+
${e.yellow(a)} `)}
|
|
54
|
+
${t}
|
|
55
|
+
`}default:return`${i}${e.cyan(a)} ${this.options.map((t,s,c)=>{const l=this.value.includes(t.value)||t.group===!0&&this.isGroupSelected(`${t.value}`),u=s===this.cursor;return!u&&typeof t.group=="string"&&this.options[this.cursor].value===t.group?n(t,l?"group-active-selected":"group-active",c):u&&l?n(t,"active-selected",c):l?n(t,"selected",c):n(t,u?"active":"inactive",c)}).join(`
|
|
56
|
+
${e.cyan(a)} `)}
|
|
57
|
+
${e.cyan(d)}
|
|
58
|
+
`}}}).prompt()},R=r=>r.replace(me(),""),le=(r="",n="")=>{const i=`
|
|
59
|
+
${r}
|
|
60
|
+
`.split(`
|
|
61
|
+
`),t=R(n).length,s=Math.max(i.reduce((l,u)=>(u=R(u),u.length>l?u.length:l),0),t)+2,c=i.map(l=>`${e.gray(a)} ${e.dim(l)}${" ".repeat(s-R(l).length)}${e.gray(a)}`).join(`
|
|
62
|
+
`);process.stdout.write(`${e.gray(a)}
|
|
63
|
+
${e.green(S)} ${e.reset(n)} ${e.gray(B.repeat(Math.max(s-t-1,1))+Z)}
|
|
64
|
+
${c}
|
|
65
|
+
${e.gray(z+B.repeat(s+2)+X)}
|
|
66
|
+
`)},ue=(r="")=>{process.stdout.write(`${e.gray(d)} ${e.red(r)}
|
|
67
|
+
|
|
68
|
+
`)},oe=(r="")=>{process.stdout.write(`${e.gray(K)} ${r}
|
|
69
|
+
`)},$e=(r="")=>{process.stdout.write(`${e.gray(a)}
|
|
70
|
+
${e.gray(d)} ${r}
|
|
71
|
+
|
|
72
|
+
`)},f={message:(r="",{symbol:n=e.gray(a)}={})=>{const i=[`${e.gray(a)}`];if(r){const[t,...s]=r.split(`
|
|
73
|
+
`);i.push(`${n} ${t}`,...s.map(c=>`${e.gray(a)} ${c}`))}process.stdout.write(`${i.join(`
|
|
74
|
+
`)}
|
|
75
|
+
`)},info:r=>{f.message(r,{symbol:e.blue(J)})},success:r=>{f.message(r,{symbol:e.green(Y)})},step:r=>{f.message(r,{symbol:e.green(S)})},warn:r=>{f.message(r,{symbol:e.yellow(Q)})},warning:r=>{f.warn(r)},error:r=>{f.message(r,{symbol:e.red(ee)})}},de=()=>{const r=_?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=_?80:120;let i,t,s=!1,c="";const l=(v="")=>{s=!0,i=F(),c=v.replace(/\.+$/,""),process.stdout.write(`${e.gray(a)}
|
|
76
|
+
`);let g=0,p=0;t=setInterval(()=>{const O=e.magenta(r[g]),P=".".repeat(Math.floor(p)).slice(0,3);process.stdout.write(T.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${O} ${c}${P}`),g=g+1<r.length?g+1:0,p=p<r.length?p+.125:0},n)},u=(v="",g=0)=>{c=v??c,s=!1,clearInterval(t);const p=g===0?e.green(S):g===1?e.red(I):e.red(x);process.stdout.write(T.move(-999,0)),process.stdout.write(A.down(1)),process.stdout.write(`${p} ${c}
|
|
77
|
+
`),i()},m=(v="")=>{c=v??c},$=v=>{const g=v>1?"Something went wrong":"Canceled";s&&u(g,v)};return process.on("uncaughtExceptionMonitor",()=>$(2)),process.on("unhandledRejection",()=>$(2)),process.on("SIGINT",()=>$(1)),process.on("SIGTERM",()=>$(1)),process.on("exit",$),{start:l,stop:u,message:m}};function me(){const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,"g")}const he=async(r,n)=>{const i={},t=Object.keys(r);for(const s of t){const c=r[s],l=await c({results:i})?.catch(u=>{throw u});if(typeof n?.onCancel=="function"&&G(l)){i[s]="canceled",n.onCancel({results:i});continue}i[s]=l}return i};export{ue as cancel,se as confirm,he as group,ce as groupMultiselect,oe as intro,f as log,ae as multiselect,le as note,$e as outro,re as password,ie as select,ne as selectKey,de as spinner,te as text};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
|
|
3
|
+
export default function isUnicodeSupported() {
|
|
4
|
+
if (process.platform !== 'win32') {
|
|
5
|
+
return process.env.TERM !== 'linux'; // Linux console (kernel)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return Boolean(process.env.CI)
|
|
9
|
+
|| Boolean(process.env.WT_SESSION) // Windows Terminal
|
|
10
|
+
|| Boolean(process.env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
11
|
+
|| process.env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
12
|
+
|| process.env.TERM_PROGRAM === 'Terminus-Sublime'
|
|
13
|
+
|| process.env.TERM_PROGRAM === 'vscode'
|
|
14
|
+
|| process.env.TERM === 'xterm-256color'
|
|
15
|
+
|| process.env.TERM === 'alacritty'
|
|
16
|
+
|| process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "is-unicode-supported",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Detect whether the terminal supports Unicode",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/is-unicode-supported",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": "./index.js",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=12"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "xo && ava && tsd"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"index.js",
|
|
23
|
+
"index.d.ts"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"terminal",
|
|
27
|
+
"unicode",
|
|
28
|
+
"detect",
|
|
29
|
+
"utf8",
|
|
30
|
+
"console",
|
|
31
|
+
"shell",
|
|
32
|
+
"support",
|
|
33
|
+
"supports",
|
|
34
|
+
"supported",
|
|
35
|
+
"check",
|
|
36
|
+
"detection"
|
|
37
|
+
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"ava": "^4.0.1",
|
|
40
|
+
"tsd": "^0.19.1",
|
|
41
|
+
"xo": "^0.47.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# is-unicode-supported
|
|
2
|
+
|
|
3
|
+
> Detect whether the terminal supports Unicode
|
|
4
|
+
|
|
5
|
+
This can be useful to decide whether to use Unicode characters or fallback ASCII characters in command-line output.
|
|
6
|
+
|
|
7
|
+
Note that the check is quite naive. It just assumes all non-Windows terminals support Unicode and hard-codes which Windows terminals that do support Unicode. However, I have been using this logic in some popular packages for years without problems.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install is-unicode-supported
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import isUnicodeSupported from 'is-unicode-supported';
|
|
19
|
+
|
|
20
|
+
isUnicodeSupported();
|
|
21
|
+
//=> true
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
### isUnicodeSupported()
|
|
27
|
+
|
|
28
|
+
Returns a `boolean` for whether the terminal supports Unicode.
|
|
29
|
+
|
|
30
|
+
## Related
|
|
31
|
+
|
|
32
|
+
- [is-interactive](https://github.com/sindresorhus/is-interactive) - Check if stdout or stderr is interactive
|
|
33
|
+
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
|
34
|
+
- [figures](https://github.com/sindresorhus/figures) - Unicode symbols with Windows fallbacks
|
|
35
|
+
- [log-symbols](https://github.com/sindresorhus/log-symbols) - Colored symbols for various log levels
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clack/prompts",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/natemoo-re/clack",
|
|
19
|
+
"directory": "packages/prompts"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/natemoo-re/clack/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/natemoo-re/clack/tree/main/packages/prompts#readme",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"CHANGELOG.md"
|
|
28
|
+
],
|
|
29
|
+
"author": {
|
|
30
|
+
"name": "Nate Moore",
|
|
31
|
+
"email": "nate@natemoo.re",
|
|
32
|
+
"url": "https://twitter.com/n_moore"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"ask",
|
|
37
|
+
"clack",
|
|
38
|
+
"cli",
|
|
39
|
+
"command-line",
|
|
40
|
+
"command",
|
|
41
|
+
"input",
|
|
42
|
+
"interact",
|
|
43
|
+
"interface",
|
|
44
|
+
"menu",
|
|
45
|
+
"prompt",
|
|
46
|
+
"prompts",
|
|
47
|
+
"stdin",
|
|
48
|
+
"ui"
|
|
49
|
+
],
|
|
50
|
+
"packageManager": "pnpm@7.6.0",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@clack/core": "^0.3.3",
|
|
53
|
+
"picocolors": "^1.0.0",
|
|
54
|
+
"sisteransi": "^1.0.5"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"is-unicode-supported": "^1.3.0"
|
|
58
|
+
},
|
|
59
|
+
"bundledDependencies": [
|
|
60
|
+
"is-unicode-supported"
|
|
61
|
+
],
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "unbuild"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/config-resolver",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.15",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
|
|
6
6
|
"build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline config-resolver",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@smithy/node-config-provider": "^4.3.13",
|
|
28
28
|
"@smithy/types": "^4.14.0",
|
|
29
29
|
"@smithy/util-config-provider": "^4.2.2",
|
|
30
|
-
"@smithy/util-endpoints": "^3.
|
|
30
|
+
"@smithy/util-endpoints": "^3.4.0",
|
|
31
31
|
"@smithy/util-middleware": "^4.2.13",
|
|
32
32
|
"tslib": "^2.6.2"
|
|
33
33
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/util-defaults-mode-node",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.50",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
|
|
6
6
|
"build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline util-defaults-mode-node",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@smithy/config-resolver": "^4.4.
|
|
26
|
+
"@smithy/config-resolver": "^4.4.15",
|
|
27
27
|
"@smithy/credential-provider-imds": "^4.2.13",
|
|
28
28
|
"@smithy/node-config-provider": "^4.3.13",
|
|
29
29
|
"@smithy/property-provider": "^4.2.13",
|
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
var types = require('@smithy/types');
|
|
4
4
|
|
|
5
|
+
class BinaryDecisionDiagram {
|
|
6
|
+
nodes;
|
|
7
|
+
root;
|
|
8
|
+
conditions;
|
|
9
|
+
results;
|
|
10
|
+
constructor(bdd, root, conditions, results) {
|
|
11
|
+
this.nodes = bdd;
|
|
12
|
+
this.root = root;
|
|
13
|
+
this.conditions = conditions;
|
|
14
|
+
this.results = results;
|
|
15
|
+
}
|
|
16
|
+
static from(bdd, root, conditions, results) {
|
|
17
|
+
return new BinaryDecisionDiagram(bdd, root, conditions, results);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
class EndpointCache {
|
|
6
22
|
capacity;
|
|
7
23
|
data = new Map();
|
|
@@ -53,24 +69,12 @@ class EndpointCache {
|
|
|
53
69
|
}
|
|
54
70
|
}
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const isValidHostLabel = (value, allowSubDomains = false) => {
|
|
61
|
-
if (!allowSubDomains) {
|
|
62
|
-
return VALID_HOST_LABEL_REGEX.test(value);
|
|
63
|
-
}
|
|
64
|
-
const labels = value.split(".");
|
|
65
|
-
for (const label of labels) {
|
|
66
|
-
if (!isValidHostLabel(label)) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
72
|
+
class EndpointError extends Error {
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = "EndpointError";
|
|
69
76
|
}
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const customEndpointFunctions = {};
|
|
77
|
+
}
|
|
74
78
|
|
|
75
79
|
const debugId = "endpoints";
|
|
76
80
|
|
|
@@ -87,15 +91,19 @@ function toDebugString(input) {
|
|
|
87
91
|
return JSON.stringify(input, null, 2);
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
constructor(message) {
|
|
92
|
-
super(message);
|
|
93
|
-
this.name = "EndpointError";
|
|
94
|
-
}
|
|
95
|
-
}
|
|
94
|
+
const customEndpointFunctions = {};
|
|
96
95
|
|
|
97
96
|
const booleanEquals = (value1, value2) => value1 === value2;
|
|
98
97
|
|
|
98
|
+
function coalesce(...args) {
|
|
99
|
+
for (const arg of args) {
|
|
100
|
+
if (arg != null) {
|
|
101
|
+
return arg;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
const getAttrPathList = (path) => {
|
|
100
108
|
const parts = path.split(".");
|
|
101
109
|
const pathList = [];
|
|
@@ -133,8 +141,29 @@ const getAttr = (value, path) => getAttrPathList(path).reduce((acc, index) => {
|
|
|
133
141
|
|
|
134
142
|
const isSet = (value) => value != null;
|
|
135
143
|
|
|
144
|
+
const VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`);
|
|
145
|
+
const isValidHostLabel = (value, allowSubDomains = false) => {
|
|
146
|
+
if (!allowSubDomains) {
|
|
147
|
+
return VALID_HOST_LABEL_REGEX.test(value);
|
|
148
|
+
}
|
|
149
|
+
const labels = value.split(".");
|
|
150
|
+
for (const label of labels) {
|
|
151
|
+
if (!isValidHostLabel(label)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
function ite(condition, trueValue, falseValue) {
|
|
159
|
+
return condition ? trueValue : falseValue;
|
|
160
|
+
}
|
|
161
|
+
|
|
136
162
|
const not = (value) => !value;
|
|
137
163
|
|
|
164
|
+
const IP_V4_REGEX = new RegExp(`^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$`);
|
|
165
|
+
const isIpAddress = (value) => IP_V4_REGEX.test(value) || (value.startsWith("[") && value.endsWith("]"));
|
|
166
|
+
|
|
138
167
|
const DEFAULT_PORTS = {
|
|
139
168
|
[types.EndpointURLScheme.HTTP]: 80,
|
|
140
169
|
[types.EndpointURLScheme.HTTPS]: 443,
|
|
@@ -185,10 +214,24 @@ const parseURL = (value) => {
|
|
|
185
214
|
};
|
|
186
215
|
};
|
|
187
216
|
|
|
217
|
+
function split(value, delimiter, limit) {
|
|
218
|
+
if (limit === 1) {
|
|
219
|
+
return [value];
|
|
220
|
+
}
|
|
221
|
+
if (value === "") {
|
|
222
|
+
return [""];
|
|
223
|
+
}
|
|
224
|
+
const parts = value.split(delimiter);
|
|
225
|
+
if (limit === 0) {
|
|
226
|
+
return parts;
|
|
227
|
+
}
|
|
228
|
+
return parts.slice(0, limit - 1).concat(parts.slice(1).join(delimiter));
|
|
229
|
+
}
|
|
230
|
+
|
|
188
231
|
const stringEquals = (value1, value2) => value1 === value2;
|
|
189
232
|
|
|
190
233
|
const substring = (input, start, stop, reverse) => {
|
|
191
|
-
if (start >= stop || input.length < stop || /[^\u0000-\u007f]/.test(input)) {
|
|
234
|
+
if (input == null || start >= stop || input.length < stop || /[^\u0000-\u007f]/.test(input)) {
|
|
192
235
|
return null;
|
|
193
236
|
}
|
|
194
237
|
if (!reverse) {
|
|
@@ -201,11 +244,14 @@ const uriEncode = (value) => encodeURIComponent(value).replace(/[!*'()]/g, (c) =
|
|
|
201
244
|
|
|
202
245
|
const endpointFunctions = {
|
|
203
246
|
booleanEquals,
|
|
247
|
+
coalesce,
|
|
204
248
|
getAttr,
|
|
205
249
|
isSet,
|
|
206
250
|
isValidHostLabel,
|
|
251
|
+
ite,
|
|
207
252
|
not,
|
|
208
253
|
parseURL,
|
|
254
|
+
split,
|
|
209
255
|
stringEquals,
|
|
210
256
|
substring,
|
|
211
257
|
uriEncode,
|
|
@@ -213,10 +259,7 @@ const endpointFunctions = {
|
|
|
213
259
|
|
|
214
260
|
const evaluateTemplate = (template, options) => {
|
|
215
261
|
const evaluatedTemplateArr = [];
|
|
216
|
-
const
|
|
217
|
-
...options.endpointParams,
|
|
218
|
-
...options.referenceRecord,
|
|
219
|
-
};
|
|
262
|
+
const { referenceRecord, endpointParams } = options;
|
|
220
263
|
let currentIndex = 0;
|
|
221
264
|
while (currentIndex < template.length) {
|
|
222
265
|
const openingBraceIndex = template.indexOf("{", currentIndex);
|
|
@@ -237,10 +280,10 @@ const evaluateTemplate = (template, options) => {
|
|
|
237
280
|
const parameterName = template.substring(openingBraceIndex + 1, closingBraceIndex);
|
|
238
281
|
if (parameterName.includes("#")) {
|
|
239
282
|
const [refName, attrName] = parameterName.split("#");
|
|
240
|
-
evaluatedTemplateArr.push(getAttr(
|
|
283
|
+
evaluatedTemplateArr.push(getAttr((referenceRecord[refName] ?? endpointParams[refName]), attrName));
|
|
241
284
|
}
|
|
242
285
|
else {
|
|
243
|
-
evaluatedTemplateArr.push(
|
|
286
|
+
evaluatedTemplateArr.push((referenceRecord[parameterName] ?? endpointParams[parameterName]));
|
|
244
287
|
}
|
|
245
288
|
currentIndex = closingBraceIndex + 1;
|
|
246
289
|
}
|
|
@@ -248,11 +291,7 @@ const evaluateTemplate = (template, options) => {
|
|
|
248
291
|
};
|
|
249
292
|
|
|
250
293
|
const getReferenceValue = ({ ref }, options) => {
|
|
251
|
-
|
|
252
|
-
...options.endpointParams,
|
|
253
|
-
...options.referenceRecord,
|
|
254
|
-
};
|
|
255
|
-
return referenceRecord[ref];
|
|
294
|
+
return options.referenceRecord[ref] ?? options.endpointParams[ref];
|
|
256
295
|
};
|
|
257
296
|
|
|
258
297
|
const evaluateExpression = (obj, keyName, options) => {
|
|
@@ -268,12 +307,27 @@ const evaluateExpression = (obj, keyName, options) => {
|
|
|
268
307
|
throw new EndpointError(`'${keyName}': ${String(obj)} is not a string, function or reference.`);
|
|
269
308
|
};
|
|
270
309
|
const callFunction = ({ fn, argv }, options) => {
|
|
271
|
-
const evaluatedArgs = argv.
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
310
|
+
const evaluatedArgs = Array(argv.length);
|
|
311
|
+
for (let i = 0; i < evaluatedArgs.length; ++i) {
|
|
312
|
+
const arg = argv[i];
|
|
313
|
+
if (typeof arg === "boolean" || typeof arg === "number") {
|
|
314
|
+
evaluatedArgs[i] = arg;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
evaluatedArgs[i] = group$2.evaluateExpression(arg, "arg", options);
|
|
318
|
+
}
|
|
275
319
|
}
|
|
276
|
-
|
|
320
|
+
if (fn.includes(".")) {
|
|
321
|
+
const fnSegments = fn.split(".");
|
|
322
|
+
if (fnSegments[0] in customEndpointFunctions && fnSegments[1] != null) {
|
|
323
|
+
return customEndpointFunctions[fnSegments[0]][fnSegments[1]](...evaluatedArgs);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (typeof endpointFunctions[fn] !== "function") {
|
|
327
|
+
throw new Error(`function ${fn} not loaded in endpointFunctions.`);
|
|
328
|
+
}
|
|
329
|
+
const callable = endpointFunctions[fn];
|
|
330
|
+
return callable(...evaluatedArgs);
|
|
277
331
|
};
|
|
278
332
|
const group$2 = {
|
|
279
333
|
evaluateExpression,
|
|
@@ -292,27 +346,6 @@ const evaluateCondition = ({ assign, ...fnArgs }, options) => {
|
|
|
292
346
|
};
|
|
293
347
|
};
|
|
294
348
|
|
|
295
|
-
const evaluateConditions = (conditions = [], options) => {
|
|
296
|
-
const conditionsReferenceRecord = {};
|
|
297
|
-
for (const condition of conditions) {
|
|
298
|
-
const { result, toAssign } = evaluateCondition(condition, {
|
|
299
|
-
...options,
|
|
300
|
-
referenceRecord: {
|
|
301
|
-
...options.referenceRecord,
|
|
302
|
-
...conditionsReferenceRecord,
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
if (!result) {
|
|
306
|
-
return { result };
|
|
307
|
-
}
|
|
308
|
-
if (toAssign) {
|
|
309
|
-
conditionsReferenceRecord[toAssign.name] = toAssign.value;
|
|
310
|
-
options.logger?.debug?.(`${debugId} assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return { result: true, referenceRecord: conditionsReferenceRecord };
|
|
314
|
-
};
|
|
315
|
-
|
|
316
349
|
const getEndpointHeaders = (headers, options) => Object.entries(headers).reduce((acc, [headerKey, headerVal]) => ({
|
|
317
350
|
...acc,
|
|
318
351
|
[headerKey]: headerVal.map((headerValEntry) => {
|
|
@@ -365,6 +398,64 @@ const getEndpointUrl = (endpointUrl, options) => {
|
|
|
365
398
|
throw new EndpointError(`Endpoint URL must be a string, got ${typeof expression}`);
|
|
366
399
|
};
|
|
367
400
|
|
|
401
|
+
const RESULT = 100_000_000;
|
|
402
|
+
const decideEndpoint = (bdd, options) => {
|
|
403
|
+
const { nodes, root, results, conditions } = bdd;
|
|
404
|
+
let ref = root;
|
|
405
|
+
const referenceRecord = {};
|
|
406
|
+
const closure = {
|
|
407
|
+
referenceRecord,
|
|
408
|
+
endpointParams: options.endpointParams,
|
|
409
|
+
logger: options.logger,
|
|
410
|
+
};
|
|
411
|
+
while (ref !== 1 && ref !== -1 && ref < RESULT) {
|
|
412
|
+
const node_i = 3 * (Math.abs(ref) - 1);
|
|
413
|
+
const [condition_i, highRef, lowRef] = [nodes[node_i], nodes[node_i + 1], nodes[node_i + 2]];
|
|
414
|
+
const [fn, argv, assign] = conditions[condition_i];
|
|
415
|
+
const evaluation = evaluateCondition({ fn, assign, argv }, closure);
|
|
416
|
+
if (evaluation.toAssign) {
|
|
417
|
+
const { name, value } = evaluation.toAssign;
|
|
418
|
+
referenceRecord[name] = value;
|
|
419
|
+
}
|
|
420
|
+
ref = ref >= 0 === evaluation.result ? highRef : lowRef;
|
|
421
|
+
}
|
|
422
|
+
if (ref >= RESULT) {
|
|
423
|
+
const result = results[ref - RESULT];
|
|
424
|
+
if (result[0] === -1) {
|
|
425
|
+
const [, errorMessage] = result;
|
|
426
|
+
throw new EndpointError(errorMessage);
|
|
427
|
+
}
|
|
428
|
+
const [url, properties, headers] = result;
|
|
429
|
+
return {
|
|
430
|
+
url: getEndpointUrl(url, closure),
|
|
431
|
+
properties: getEndpointProperties(properties, closure),
|
|
432
|
+
headers: getEndpointHeaders(headers, closure),
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
throw new EndpointError(`No matching endpoint.`);
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
const evaluateConditions = (conditions = [], options) => {
|
|
439
|
+
const conditionsReferenceRecord = {};
|
|
440
|
+
for (const condition of conditions) {
|
|
441
|
+
const { result, toAssign } = evaluateCondition(condition, {
|
|
442
|
+
...options,
|
|
443
|
+
referenceRecord: {
|
|
444
|
+
...options.referenceRecord,
|
|
445
|
+
...conditionsReferenceRecord,
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
if (!result) {
|
|
449
|
+
return { result };
|
|
450
|
+
}
|
|
451
|
+
if (toAssign) {
|
|
452
|
+
conditionsReferenceRecord[toAssign.name] = toAssign.value;
|
|
453
|
+
options.logger?.debug?.(`${debugId} assign: ${toAssign.name} := ${toDebugString(toAssign.value)}`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return { result: true, referenceRecord: conditionsReferenceRecord };
|
|
457
|
+
};
|
|
458
|
+
|
|
368
459
|
const evaluateEndpointRule = (endpointRule, options) => {
|
|
369
460
|
const { conditions, endpoint } = endpointRule;
|
|
370
461
|
const { result, referenceRecord } = evaluateConditions(conditions, options);
|
|
@@ -464,9 +555,11 @@ const resolveEndpoint = (ruleSetObject, options) => {
|
|
|
464
555
|
return endpoint;
|
|
465
556
|
};
|
|
466
557
|
|
|
558
|
+
exports.BinaryDecisionDiagram = BinaryDecisionDiagram;
|
|
467
559
|
exports.EndpointCache = EndpointCache;
|
|
468
560
|
exports.EndpointError = EndpointError;
|
|
469
561
|
exports.customEndpointFunctions = customEndpointFunctions;
|
|
562
|
+
exports.decideEndpoint = decideEndpoint;
|
|
470
563
|
exports.isIpAddress = isIpAddress;
|
|
471
564
|
exports.isValidHostLabel = isValidHostLabel;
|
|
472
565
|
exports.resolveEndpoint = resolveEndpoint;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class BinaryDecisionDiagram {
|
|
2
|
+
nodes;
|
|
3
|
+
root;
|
|
4
|
+
conditions;
|
|
5
|
+
results;
|
|
6
|
+
constructor(bdd, root, conditions, results) {
|
|
7
|
+
this.nodes = bdd;
|
|
8
|
+
this.root = root;
|
|
9
|
+
this.conditions = conditions;
|
|
10
|
+
this.results = results;
|
|
11
|
+
}
|
|
12
|
+
static from(bdd, root, conditions, results) {
|
|
13
|
+
return new BinaryDecisionDiagram(bdd, root, conditions, results);
|
|
14
|
+
}
|
|
15
|
+
}
|