promptlineapp 1.10.2 → 1.10.3

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.
Files changed (2) hide show
  1. package/bin/cli.js +136 -13
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -2380,9 +2380,11 @@ export default function DevAdmin() {
2380
2380
  const [endpoints, setEndpoints] = useState({})
2381
2381
  const [endpointStatus, setEndpointStatus] = useState({}) // { bindingName: { alive: bool, info: obj, loading: string } }
2382
2382
  const [testBinding, setTestBinding] = useState('')
2383
- const [testInput, setTestInput] = useState('Hello, test!')
2383
+ const [testVariables, setTestVariables] = useState({})
2384
+ const [testSchema, setTestSchema] = useState(null) // input_schema from endpoint info
2384
2385
  const [testResult, setTestResult] = useState('')
2385
2386
  const [testing, setTesting] = useState(false)
2387
+ const [loadingSchema, setLoadingSchema] = useState(false)
2386
2388
  const [saved, setSaved] = useState(false)
2387
2389
 
2388
2390
  useEffect(() => {
@@ -2490,6 +2492,47 @@ export default function DevAdmin() {
2490
2492
  }
2491
2493
  }
2492
2494
 
2495
+ // Load schema when test binding changes
2496
+ const loadTestSchema = async (bindingName) => {
2497
+ const epData = typeof endpoints[bindingName] === 'string'
2498
+ ? parseEndpointUrl(endpoints[bindingName])
2499
+ : endpoints[bindingName]
2500
+ if (!epData?.id || !apiKey) {
2501
+ setTestSchema(null)
2502
+ return
2503
+ }
2504
+
2505
+ setLoadingSchema(true)
2506
+ try {
2507
+ const proxyPath = getProxyPath(epData.env)
2508
+ const res = await fetch(proxyPath + '/' + epData.id + '/info', {
2509
+ method: 'GET',
2510
+ headers: { 'X-API-Key': apiKey }
2511
+ })
2512
+ const data = await res.json()
2513
+ if (res.ok && data.inputSchema) {
2514
+ setTestSchema(data.inputSchema)
2515
+ const vars = {}
2516
+ Object.keys(data.inputSchema.properties || {}).forEach(key => {
2517
+ vars[key] = ''
2518
+ })
2519
+ setTestVariables(vars)
2520
+ } else {
2521
+ setTestSchema(null)
2522
+ }
2523
+ } catch (err) {
2524
+ setTestSchema(null)
2525
+ }
2526
+ setLoadingSchema(false)
2527
+ }
2528
+
2529
+ const handleBindingChange = (bindingName) => {
2530
+ setTestBinding(bindingName)
2531
+ setTestResult('')
2532
+ setTestVariables({})
2533
+ loadTestSchema(bindingName)
2534
+ }
2535
+
2493
2536
  const testEndpoint = async () => {
2494
2537
  const epData = typeof endpoints[testBinding] === 'string'
2495
2538
  ? parseEndpointUrl(endpoints[testBinding])
@@ -2514,7 +2557,10 @@ export default function DevAdmin() {
2514
2557
  'Content-Type': 'application/json',
2515
2558
  'X-API-Key': apiKey
2516
2559
  },
2517
- body: JSON.stringify({ input: { text: testInput } })
2560
+ body: JSON.stringify({
2561
+ input: testVariables,
2562
+ variables: testVariables
2563
+ })
2518
2564
  })
2519
2565
  const data = await res.json()
2520
2566
  if (!res.ok || data.error) {
@@ -2774,13 +2820,28 @@ export default function DevAdmin() {
2774
2820
  <div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
2775
2821
  <select
2776
2822
  value={testBinding}
2777
- onChange={e => setTestBinding(e.target.value)}
2823
+ onChange={e => handleBindingChange(e.target.value)}
2778
2824
  style={{ flex: 1, padding: 8, border: '1px solid #d1d5db', borderRadius: 4 }}
2779
2825
  >
2780
2826
  {availableBindings.map(b => (
2781
2827
  <option key={b.name} value={b.name}>{b.name}</option>
2782
2828
  ))}
2783
2829
  </select>
2830
+ <button
2831
+ onClick={() => loadTestSchema(testBinding)}
2832
+ disabled={loadingSchema}
2833
+ style={{
2834
+ padding: '8px 12px',
2835
+ background: '#fff',
2836
+ color: '#6366f1',
2837
+ border: '1px solid #6366f1',
2838
+ borderRadius: 4,
2839
+ cursor: loadingSchema ? 'wait' : 'pointer',
2840
+ fontSize: 12
2841
+ }}
2842
+ >
2843
+ {loadingSchema ? '...' : '↻ Load Schema'}
2844
+ </button>
2784
2845
  <button
2785
2846
  onClick={testEndpoint}
2786
2847
  disabled={testing}
@@ -2796,22 +2857,84 @@ export default function DevAdmin() {
2796
2857
  {testing ? '...' : 'Send'}
2797
2858
  </button>
2798
2859
  </div>
2799
- <textarea
2800
- value={testInput}
2801
- onChange={e => setTestInput(e.target.value)}
2802
- placeholder="Test input..."
2803
- rows={2}
2804
- style={{ width: '100%', padding: 8, border: '1px solid #d1d5db', borderRadius: 4, marginBottom: 12, resize: 'vertical' }}
2805
- />
2860
+
2861
+ {/* Variable Inputs */}
2862
+ {testSchema?.properties && Object.keys(testSchema.properties).length > 0 ? (
2863
+ <div style={{ marginBottom: 12 }}>
2864
+ <div style={{ fontSize: 12, color: '#6b7280', marginBottom: 8 }}>
2865
+ Variables ({Object.keys(testSchema.properties).length}):
2866
+ </div>
2867
+ <div style={{ display: 'grid', gap: 8 }}>
2868
+ {Object.entries(testSchema.properties).map(([key, prop]) => (
2869
+ <div key={key} style={{ display: 'flex', gap: 8, alignItems: 'flex-start' }}>
2870
+ <label style={{
2871
+ width: 140,
2872
+ fontSize: 12,
2873
+ fontWeight: 500,
2874
+ paddingTop: 8,
2875
+ color: testSchema.required?.includes(key) ? '#111' : '#6b7280'
2876
+ }}>
2877
+ {key}
2878
+ {testSchema.required?.includes(key) && <span style={{ color: '#ef4444' }}>*</span>}
2879
+ </label>
2880
+ {prop.type === 'object' || prop.type === 'array' ? (
2881
+ <textarea
2882
+ value={testVariables[key] || ''}
2883
+ onChange={e => setTestVariables(prev => ({ ...prev, [key]: e.target.value }))}
2884
+ placeholder={prop.description || \`Enter \${key} (JSON)\`}
2885
+ rows={2}
2886
+ style={{
2887
+ flex: 1,
2888
+ padding: 8,
2889
+ border: '1px solid #d1d5db',
2890
+ borderRadius: 4,
2891
+ fontSize: 12,
2892
+ resize: 'vertical'
2893
+ }}
2894
+ />
2895
+ ) : (
2896
+ <input
2897
+ type={prop.type === 'number' || prop.type === 'integer' ? 'number' : 'text'}
2898
+ value={testVariables[key] || ''}
2899
+ onChange={e => setTestVariables(prev => ({ ...prev, [key]: e.target.value }))}
2900
+ placeholder={prop.description || \`Enter \${key}\`}
2901
+ style={{
2902
+ flex: 1,
2903
+ padding: 8,
2904
+ border: '1px solid #d1d5db',
2905
+ borderRadius: 4,
2906
+ fontSize: 12
2907
+ }}
2908
+ />
2909
+ )}
2910
+ </div>
2911
+ ))}
2912
+ </div>
2913
+ </div>
2914
+ ) : (
2915
+ <div style={{
2916
+ padding: 12,
2917
+ background: '#f9fafb',
2918
+ borderRadius: 4,
2919
+ fontSize: 12,
2920
+ color: '#6b7280',
2921
+ marginBottom: 12,
2922
+ textAlign: 'center'
2923
+ }}>
2924
+ {loadingSchema ? 'Loading schema...' : 'Click "Load Schema" to see available variables'}
2925
+ </div>
2926
+ )}
2927
+
2806
2928
  {testResult && (
2807
2929
  <pre style={{
2808
- background: '#f9fafb',
2930
+ background: testResult.startsWith('Error') ? '#fef2f2' : '#f0fdf4',
2809
2931
  padding: 12,
2810
2932
  borderRadius: 4,
2811
2933
  fontSize: 13,
2812
2934
  overflow: 'auto',
2813
- maxHeight: 200,
2814
- whiteSpace: 'pre-wrap'
2935
+ maxHeight: 300,
2936
+ whiteSpace: 'pre-wrap',
2937
+ border: testResult.startsWith('Error') ? '1px solid #fecaca' : '1px solid #bbf7d0'
2815
2938
  }}>
2816
2939
  {testResult}
2817
2940
  </pre>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlineapp",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "Create PromptLine applications with ease",
5
5
  "author": "PromptLine <support@promptlineops.com>",
6
6
  "license": "MIT",