@stackable-labs/cli-app-extension 1.88.3 → 1.90.0
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.js +18 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1526,12 +1526,13 @@ export const appStore = createStore<AppState>({
|
|
|
1526
1526
|
{
|
|
1527
1527
|
path: "surfaces/Content.tsx",
|
|
1528
1528
|
title: "Content Surface with Loading State",
|
|
1529
|
-
code: `import { ui, useStore, useContextData, Surface } from '@stackable-labs/sdk-extension-react'
|
|
1529
|
+
code: `import { ui, useStore, useContextData, useSettings, Surface } from '@stackable-labs/sdk-extension-react'
|
|
1530
1530
|
import { appStore } from '../store'
|
|
1531
1531
|
|
|
1532
1532
|
export function Content() {
|
|
1533
1533
|
const viewState = useStore(appStore, (s) => s.viewState)
|
|
1534
1534
|
const { loading } = useContextData()
|
|
1535
|
+
const settings = useSettings() // Non-secret settings from settingsSchema
|
|
1535
1536
|
|
|
1536
1537
|
if (loading) {
|
|
1537
1538
|
return (
|
|
@@ -1626,19 +1627,33 @@ export function createApi(query: QueryFn) {
|
|
|
1626
1627
|
}
|
|
1627
1628
|
|
|
1628
1629
|
// \u2500\u2500 data.fetch wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1630
|
+
//
|
|
1631
|
+
// For API keys and secrets, use {{settings.xxx}} placeholders in headers.
|
|
1632
|
+
// The proxy resolves them server-side \u2014 the real secret never enters extension code.
|
|
1633
|
+
// Declare secret fields in manifest.json settingsSchema with "secret": true.
|
|
1629
1634
|
|
|
1630
1635
|
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL as string
|
|
1631
1636
|
|
|
1632
1637
|
export function createFetchApi(fetch: FetchFn) {
|
|
1633
1638
|
return {
|
|
1634
1639
|
async getItems(): Promise<unknown[]> {
|
|
1635
|
-
const result = await fetch(\`\${API_BASE_URL}/items\`, {
|
|
1640
|
+
const result = await fetch(\`\${API_BASE_URL}/items\`, {
|
|
1641
|
+
method: 'GET',
|
|
1642
|
+
headers: {
|
|
1643
|
+
'X-API-Key': '{{settings.apiKey}}',
|
|
1644
|
+
},
|
|
1645
|
+
})
|
|
1636
1646
|
if (!result.ok) throw new Error(\`getItems failed: \${result.status}\`)
|
|
1637
1647
|
return result.data as unknown[]
|
|
1638
1648
|
},
|
|
1639
1649
|
|
|
1640
1650
|
async getItem(itemId: string): Promise<unknown> {
|
|
1641
|
-
const result = await fetch(\`\${API_BASE_URL}/items/\${itemId}\`, {
|
|
1651
|
+
const result = await fetch(\`\${API_BASE_URL}/items/\${itemId}\`, {
|
|
1652
|
+
method: 'GET',
|
|
1653
|
+
headers: {
|
|
1654
|
+
'X-API-Key': '{{settings.apiKey}}',
|
|
1655
|
+
},
|
|
1656
|
+
})
|
|
1642
1657
|
if (!result.ok) throw new Error(\`getItem failed: \${result.status}\`)
|
|
1643
1658
|
return result.data as unknown
|
|
1644
1659
|
},
|