@fluid-app/portal-core 0.1.16
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/chunk-CKQMccvm.cjs +28 -0
- package/dist/data-sources/DataAwareWidget.cjs +50 -0
- package/dist/data-sources/DataAwareWidget.cjs.map +1 -0
- package/dist/data-sources/DataAwareWidget.d.cts +24 -0
- package/dist/data-sources/DataAwareWidget.d.cts.map +1 -0
- package/dist/data-sources/DataAwareWidget.d.mts +24 -0
- package/dist/data-sources/DataAwareWidget.d.mts.map +1 -0
- package/dist/data-sources/DataAwareWidget.mjs +48 -0
- package/dist/data-sources/DataAwareWidget.mjs.map +1 -0
- package/dist/data-sources/ErrorState.cjs +20 -0
- package/dist/data-sources/ErrorState.cjs.map +1 -0
- package/dist/data-sources/ErrorState.d.cts +7 -0
- package/dist/data-sources/ErrorState.d.cts.map +1 -0
- package/dist/data-sources/ErrorState.d.mts +7 -0
- package/dist/data-sources/ErrorState.d.mts.map +1 -0
- package/dist/data-sources/ErrorState.mjs +18 -0
- package/dist/data-sources/ErrorState.mjs.map +1 -0
- package/dist/data-sources/context.cjs +24 -0
- package/dist/data-sources/context.cjs.map +1 -0
- package/dist/data-sources/context.d.cts +21 -0
- package/dist/data-sources/context.d.cts.map +1 -0
- package/dist/data-sources/context.d.mts +21 -0
- package/dist/data-sources/context.d.mts.map +1 -0
- package/dist/data-sources/context.mjs +21 -0
- package/dist/data-sources/context.mjs.map +1 -0
- package/dist/data-sources/fetchers/api.cjs +65 -0
- package/dist/data-sources/fetchers/api.cjs.map +1 -0
- package/dist/data-sources/fetchers/api.d.cts +10 -0
- package/dist/data-sources/fetchers/api.d.cts.map +1 -0
- package/dist/data-sources/fetchers/api.d.mts +10 -0
- package/dist/data-sources/fetchers/api.d.mts.map +1 -0
- package/dist/data-sources/fetchers/api.mjs +64 -0
- package/dist/data-sources/fetchers/api.mjs.map +1 -0
- package/dist/data-sources/fetchers/custom.cjs +108 -0
- package/dist/data-sources/fetchers/custom.cjs.map +1 -0
- package/dist/data-sources/fetchers/custom.d.cts +17 -0
- package/dist/data-sources/fetchers/custom.d.cts.map +1 -0
- package/dist/data-sources/fetchers/custom.d.mts +17 -0
- package/dist/data-sources/fetchers/custom.d.mts.map +1 -0
- package/dist/data-sources/fetchers/custom.mjs +107 -0
- package/dist/data-sources/fetchers/custom.mjs.map +1 -0
- package/dist/data-sources/fetchers/static.cjs +161 -0
- package/dist/data-sources/fetchers/static.cjs.map +1 -0
- package/dist/data-sources/fetchers/static.d.cts +40 -0
- package/dist/data-sources/fetchers/static.d.cts.map +1 -0
- package/dist/data-sources/fetchers/static.d.mts +40 -0
- package/dist/data-sources/fetchers/static.d.mts.map +1 -0
- package/dist/data-sources/fetchers/static.mjs +158 -0
- package/dist/data-sources/fetchers/static.mjs.map +1 -0
- package/dist/data-sources/preview-context.cjs +21 -0
- package/dist/data-sources/preview-context.cjs.map +1 -0
- package/dist/data-sources/preview-context.d.cts +13 -0
- package/dist/data-sources/preview-context.d.cts.map +1 -0
- package/dist/data-sources/preview-context.d.mts +13 -0
- package/dist/data-sources/preview-context.d.mts.map +1 -0
- package/dist/data-sources/preview-context.mjs +18 -0
- package/dist/data-sources/preview-context.mjs.map +1 -0
- package/dist/data-sources/registry-context.cjs +53 -0
- package/dist/data-sources/registry-context.cjs.map +1 -0
- package/dist/data-sources/registry-context.d.cts +48 -0
- package/dist/data-sources/registry-context.d.cts.map +1 -0
- package/dist/data-sources/registry-context.d.mts +48 -0
- package/dist/data-sources/registry-context.d.mts.map +1 -0
- package/dist/data-sources/registry-context.mjs +49 -0
- package/dist/data-sources/registry-context.mjs.map +1 -0
- package/dist/data-sources/registry.cjs +31 -0
- package/dist/data-sources/registry.cjs.map +1 -0
- package/dist/data-sources/registry.d.cts +19 -0
- package/dist/data-sources/registry.d.cts.map +1 -0
- package/dist/data-sources/registry.d.mts +19 -0
- package/dist/data-sources/registry.d.mts.map +1 -0
- package/dist/data-sources/registry.mjs +29 -0
- package/dist/data-sources/registry.mjs.map +1 -0
- package/dist/data-sources/transformers.cjs +154 -0
- package/dist/data-sources/transformers.cjs.map +1 -0
- package/dist/data-sources/transformers.d.cts +10 -0
- package/dist/data-sources/transformers.d.cts.map +1 -0
- package/dist/data-sources/transformers.d.mts +10 -0
- package/dist/data-sources/transformers.d.mts.map +1 -0
- package/dist/data-sources/transformers.mjs +153 -0
- package/dist/data-sources/transformers.mjs.map +1 -0
- package/dist/data-sources/types.cjs +0 -0
- package/dist/data-sources/types.d.cts +2 -0
- package/dist/data-sources/types.d.mts +2 -0
- package/dist/data-sources/types.mjs +1 -0
- package/dist/data-sources/use-widget-data.cjs +111 -0
- package/dist/data-sources/use-widget-data.cjs.map +1 -0
- package/dist/data-sources/use-widget-data.d.cts +17 -0
- package/dist/data-sources/use-widget-data.d.cts.map +1 -0
- package/dist/data-sources/use-widget-data.d.mts +17 -0
- package/dist/data-sources/use-widget-data.d.mts.map +1 -0
- package/dist/data-sources/use-widget-data.mjs +109 -0
- package/dist/data-sources/use-widget-data.mjs.map +1 -0
- package/dist/index-B5cTNde-.d.cts +246 -0
- package/dist/index-B5cTNde-.d.cts.map +1 -0
- package/dist/index-Cqt2JzkQ.d.mts +246 -0
- package/dist/index-Cqt2JzkQ.d.mts.map +1 -0
- package/dist/registries/index.cjs +243 -0
- package/dist/registries/index.cjs.map +1 -0
- package/dist/registries/index.d.cts +338 -0
- package/dist/registries/index.d.cts.map +1 -0
- package/dist/registries/index.d.mts +338 -0
- package/dist/registries/index.d.mts.map +1 -0
- package/dist/registries/index.mjs +229 -0
- package/dist/registries/index.mjs.map +1 -0
- package/dist/shell/AppShellLayout.cjs +49 -0
- package/dist/shell/AppShellLayout.cjs.map +1 -0
- package/dist/shell/AppShellLayout.d.cts +39 -0
- package/dist/shell/AppShellLayout.d.cts.map +1 -0
- package/dist/shell/AppShellLayout.d.mts +39 -0
- package/dist/shell/AppShellLayout.d.mts.map +1 -0
- package/dist/shell/AppShellLayout.mjs +46 -0
- package/dist/shell/AppShellLayout.mjs.map +1 -0
- package/dist/shell/ScreenHeader.cjs +44 -0
- package/dist/shell/ScreenHeader.cjs.map +1 -0
- package/dist/shell/ScreenHeader.d.cts +12 -0
- package/dist/shell/ScreenHeader.d.cts.map +1 -0
- package/dist/shell/ScreenHeader.d.mts +12 -0
- package/dist/shell/ScreenHeader.d.mts.map +1 -0
- package/dist/shell/ScreenHeader.mjs +42 -0
- package/dist/shell/ScreenHeader.mjs.map +1 -0
- package/dist/shell/ScreenHeaderContext.cjs +91 -0
- package/dist/shell/ScreenHeaderContext.cjs.map +1 -0
- package/dist/shell/ScreenHeaderContext.d.cts +35 -0
- package/dist/shell/ScreenHeaderContext.d.cts.map +1 -0
- package/dist/shell/ScreenHeaderContext.d.mts +35 -0
- package/dist/shell/ScreenHeaderContext.d.mts.map +1 -0
- package/dist/shell/ScreenHeaderContext.mjs +86 -0
- package/dist/shell/ScreenHeaderContext.mjs.map +1 -0
- package/dist/shell/ThemeModeContext.cjs +70 -0
- package/dist/shell/ThemeModeContext.cjs.map +1 -0
- package/dist/shell/ThemeModeContext.d.cts +33 -0
- package/dist/shell/ThemeModeContext.d.cts.map +1 -0
- package/dist/shell/ThemeModeContext.d.mts +33 -0
- package/dist/shell/ThemeModeContext.d.mts.map +1 -0
- package/dist/shell/ThemeModeContext.mjs +66 -0
- package/dist/shell/ThemeModeContext.mjs.map +1 -0
- package/dist/shell/index.cjs +43 -0
- package/dist/shell/index.d.cts +7 -0
- package/dist/shell/index.d.mts +7 -0
- package/dist/shell/index.mjs +7 -0
- package/dist/shell/sidebar.cjs +390 -0
- package/dist/shell/sidebar.cjs.map +1 -0
- package/dist/shell/sidebar.d.cts +85 -0
- package/dist/shell/sidebar.d.cts.map +1 -0
- package/dist/shell/sidebar.d.mts +85 -0
- package/dist/shell/sidebar.d.mts.map +1 -0
- package/dist/shell/sidebar.mjs +364 -0
- package/dist/shell/sidebar.mjs.map +1 -0
- package/dist/shell/use-mobile.cjs +51 -0
- package/dist/shell/use-mobile.cjs.map +1 -0
- package/dist/shell/use-mobile.d.cts +7 -0
- package/dist/shell/use-mobile.d.cts.map +1 -0
- package/dist/shell/use-mobile.d.mts +7 -0
- package/dist/shell/use-mobile.d.mts.map +1 -0
- package/dist/shell/use-mobile.mjs +47 -0
- package/dist/shell/use-mobile.mjs.map +1 -0
- package/dist/theme/index.cjs +758 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.d.cts +131 -0
- package/dist/theme/index.d.cts.map +1 -0
- package/dist/theme/index.d.mts +131 -0
- package/dist/theme/index.d.mts.map +1 -0
- package/dist/theme/index.mjs +728 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/types/index.cjs +18 -0
- package/dist/types/index.d.cts +4 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/index.mjs +2 -0
- package/dist/types-27AHMek-.d.cts +85 -0
- package/dist/types-27AHMek-.d.cts.map +1 -0
- package/dist/types-BXFX9bXp.cjs +303 -0
- package/dist/types-BXFX9bXp.cjs.map +1 -0
- package/dist/types-Bjmd7Fdx.mjs +208 -0
- package/dist/types-Bjmd7Fdx.mjs.map +1 -0
- package/dist/types-C5Zs5V3E.d.mts +155 -0
- package/dist/types-C5Zs5V3E.d.mts.map +1 -0
- package/dist/types-CeCPKvOv.d.mts +85 -0
- package/dist/types-CeCPKvOv.d.mts.map +1 -0
- package/dist/types-DrzvahW8.d.cts +155 -0
- package/dist/types-DrzvahW8.d.cts.map +1 -0
- package/dist/widget-schema-BKZgsNG7.d.mts +119 -0
- package/dist/widget-schema-BKZgsNG7.d.mts.map +1 -0
- package/dist/widget-schema-BSX2fVhW.d.cts +119 -0
- package/dist/widget-schema-BSX2fVhW.d.cts.map +1 -0
- package/dist/widget-utils/index.cjs +130 -0
- package/dist/widget-utils/index.cjs.map +1 -0
- package/dist/widget-utils/index.d.cts +47 -0
- package/dist/widget-utils/index.d.cts.map +1 -0
- package/dist/widget-utils/index.d.mts +47 -0
- package/dist/widget-utils/index.d.mts.map +1 -0
- package/dist/widget-utils/index.mjs +119 -0
- package/dist/widget-utils/index.mjs.map +1 -0
- package/package.json +200 -0
- package/src/styles/globals.css +1 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/data-sources/fetchers/static.ts
|
|
3
|
+
/**
|
|
4
|
+
* Endpoint patterns for fetching products by static source type.
|
|
5
|
+
* Tags require backend API support (not yet available).
|
|
6
|
+
*/
|
|
7
|
+
const STATIC_ENDPOINTS = {
|
|
8
|
+
collections: "/company/v1/products",
|
|
9
|
+
categories: "/company/v1/products"
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Query parameter names for each static source type.
|
|
13
|
+
*/
|
|
14
|
+
const STATIC_QUERY_PARAMS = {
|
|
15
|
+
collections: "collection_id",
|
|
16
|
+
categories: "category_id"
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Extract products array from API response.
|
|
20
|
+
* The /company/v1/products endpoint returns { products: [...], meta: {...} }
|
|
21
|
+
*/
|
|
22
|
+
function extractProducts(json) {
|
|
23
|
+
if (Array.isArray(json.products)) return json.products;
|
|
24
|
+
if (Array.isArray(json.data)) return json.data;
|
|
25
|
+
if (Array.isArray(json)) return json;
|
|
26
|
+
console.warn("[extractProducts] Could not find products array. Available keys:", Object.keys(json));
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Static data source fetcher.
|
|
31
|
+
*
|
|
32
|
+
* Fetches products filtered by collection or category ID.
|
|
33
|
+
* Tags are not yet supported (requires backend API changes).
|
|
34
|
+
*
|
|
35
|
+
* @param source - The static data source configuration
|
|
36
|
+
* @param context - The data source context with baseUrl and headers
|
|
37
|
+
* @returns Array of products matching the filter criteria
|
|
38
|
+
*/
|
|
39
|
+
async function staticFetcher(source, context) {
|
|
40
|
+
const { staticType, selectedId } = source;
|
|
41
|
+
if (staticType === "tags") throw new Error("Tags data source is not yet supported. Please select Collections or Categories instead.");
|
|
42
|
+
const endpoint = STATIC_ENDPOINTS[staticType];
|
|
43
|
+
const queryParam = STATIC_QUERY_PARAMS[staticType];
|
|
44
|
+
if (!endpoint || !queryParam) throw new Error(`Invalid data source configuration: "${staticType}" is not a supported static source type.`);
|
|
45
|
+
const url = new URL(`${context.baseUrl ?? ""}${endpoint}`, context.baseUrl ? void 0 : window.location.origin);
|
|
46
|
+
url.searchParams.set(queryParam, String(selectedId));
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(url.toString(), {
|
|
49
|
+
method: "GET",
|
|
50
|
+
headers: {
|
|
51
|
+
...context.getApiHeaders?.(),
|
|
52
|
+
"Content-Type": "application/json"
|
|
53
|
+
},
|
|
54
|
+
signal: context.signal
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) throw new Error(`Failed to fetch products for ${staticType} ${selectedId}: ${response.status} ${response.statusText}`);
|
|
57
|
+
return extractProducts(await response.json());
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error instanceof Error && error.name === "AbortError") return [];
|
|
60
|
+
console.error(`[staticFetcher] Error fetching ${staticType} ${selectedId}:`, error);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Endpoints for listing static source items (collections, categories, tags).
|
|
66
|
+
*/
|
|
67
|
+
const LIST_ENDPOINTS = {
|
|
68
|
+
collections: {
|
|
69
|
+
endpoint: "/company/v1/collections",
|
|
70
|
+
resultKey: "collections"
|
|
71
|
+
},
|
|
72
|
+
categories: {
|
|
73
|
+
endpoint: "/company/v1/categories",
|
|
74
|
+
resultKey: "categories"
|
|
75
|
+
},
|
|
76
|
+
tags: {
|
|
77
|
+
endpoint: "/company/v1/tags",
|
|
78
|
+
resultKey: "tags"
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* React hook for fetching static source items (collections, categories).
|
|
83
|
+
* Handles loading state, error state, abort on cleanup, and search filtering.
|
|
84
|
+
*
|
|
85
|
+
* @param staticType - The type of static source to fetch, or null to reset
|
|
86
|
+
* @param context - Context with baseUrl and getApiHeaders
|
|
87
|
+
* @param params - Optional search parameters
|
|
88
|
+
* @returns Object with items, isLoading, and error state
|
|
89
|
+
*/
|
|
90
|
+
function useStaticSourceItems(staticType, context, params) {
|
|
91
|
+
const [items, setItems] = useState([]);
|
|
92
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
93
|
+
const [error, setError] = useState(null);
|
|
94
|
+
const { baseUrl, getApiHeaders } = context;
|
|
95
|
+
const search = params?.search;
|
|
96
|
+
const getApiHeadersRef = useRef(getApiHeaders);
|
|
97
|
+
getApiHeadersRef.current = getApiHeaders;
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!staticType) {
|
|
100
|
+
setItems([]);
|
|
101
|
+
setError(null);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
let isCancelled = false;
|
|
105
|
+
const abortController = new AbortController();
|
|
106
|
+
setIsLoading(true);
|
|
107
|
+
setError(null);
|
|
108
|
+
const config = LIST_ENDPOINTS[staticType];
|
|
109
|
+
const url = new URL(`${baseUrl ?? ""}${config.endpoint}`, baseUrl ? void 0 : window.location.origin);
|
|
110
|
+
if (search) url.searchParams.set("search", search);
|
|
111
|
+
fetch(url.toString(), {
|
|
112
|
+
method: "GET",
|
|
113
|
+
headers: {
|
|
114
|
+
...getApiHeadersRef.current?.(),
|
|
115
|
+
"Content-Type": "application/json"
|
|
116
|
+
},
|
|
117
|
+
signal: abortController.signal
|
|
118
|
+
}).then(async (response) => {
|
|
119
|
+
if (!response.ok) throw new Error(`Failed to fetch ${staticType}: ${response.status}`);
|
|
120
|
+
const responseItems = (await response.json())[config.resultKey];
|
|
121
|
+
if (!Array.isArray(responseItems)) {
|
|
122
|
+
console.warn(`[useStaticSourceItems] Expected array at "${config.resultKey}" but got:`, typeof responseItems);
|
|
123
|
+
if (!isCancelled) setItems([]);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!isCancelled) setItems(responseItems.map((item) => ({
|
|
127
|
+
id: item.id,
|
|
128
|
+
title: item.title,
|
|
129
|
+
imageUrl: item.image_url
|
|
130
|
+
})));
|
|
131
|
+
}).catch((err) => {
|
|
132
|
+
if (err instanceof Error && err.name === "AbortError") return;
|
|
133
|
+
console.error(`[useStaticSourceItems] Failed to fetch ${staticType}:`, err);
|
|
134
|
+
if (isCancelled) return;
|
|
135
|
+
setError("An unexpected error occurred. Please try again.");
|
|
136
|
+
setItems([]);
|
|
137
|
+
}).finally(() => {
|
|
138
|
+
if (!isCancelled) setIsLoading(false);
|
|
139
|
+
});
|
|
140
|
+
return () => {
|
|
141
|
+
isCancelled = true;
|
|
142
|
+
abortController.abort();
|
|
143
|
+
};
|
|
144
|
+
}, [
|
|
145
|
+
staticType,
|
|
146
|
+
search,
|
|
147
|
+
baseUrl
|
|
148
|
+
]);
|
|
149
|
+
return {
|
|
150
|
+
items,
|
|
151
|
+
isLoading,
|
|
152
|
+
error
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { staticFetcher, useStaticSourceItems };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=static.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.mjs","names":[],"sources":["../../../src/data-sources/fetchers/static.ts"],"sourcesContent":["import { useState, useEffect, useRef } from \"react\";\nimport type {\n StaticDataSource,\n DataSourceContext,\n StaticSourceType,\n StaticItem,\n} from \"../types\";\n\n/**\n * Endpoint patterns for fetching products by static source type.\n * Tags require backend API support (not yet available).\n */\nconst STATIC_ENDPOINTS: Record<\"collections\" | \"categories\", string> = {\n collections: \"/company/v1/products\",\n categories: \"/company/v1/products\",\n};\n\n/**\n * Query parameter names for each static source type.\n */\nconst STATIC_QUERY_PARAMS: Record<\"collections\" | \"categories\", string> = {\n collections: \"collection_id\",\n categories: \"category_id\",\n};\n\n/**\n * Extract products array from API response.\n * The /company/v1/products endpoint returns { products: [...], meta: {...} }\n */\nfunction extractProducts(json: Record<string, unknown>): unknown[] {\n if (Array.isArray(json.products)) {\n return json.products;\n }\n if (Array.isArray(json.data)) {\n return json.data;\n }\n if (Array.isArray(json)) {\n return json;\n }\n console.warn(\n \"[extractProducts] Could not find products array. Available keys:\",\n Object.keys(json),\n );\n return [];\n}\n\n/**\n * Static data source fetcher.\n *\n * Fetches products filtered by collection or category ID.\n * Tags are not yet supported (requires backend API changes).\n *\n * @param source - The static data source configuration\n * @param context - The data source context with baseUrl and headers\n * @returns Array of products matching the filter criteria\n */\nexport async function staticFetcher(\n source: StaticDataSource,\n context: DataSourceContext,\n): Promise<unknown[]> {\n const { staticType, selectedId } = source;\n\n // Tags require backend API support - not yet implemented\n if (staticType === \"tags\") {\n throw new Error(\n \"Tags data source is not yet supported. Please select Collections or Categories instead.\",\n );\n }\n\n const endpoint = STATIC_ENDPOINTS[staticType];\n const queryParam = STATIC_QUERY_PARAMS[staticType];\n\n if (!endpoint || !queryParam) {\n throw new Error(\n `Invalid data source configuration: \"${staticType}\" is not a supported static source type.`,\n );\n }\n\n const url = new URL(\n `${context.baseUrl ?? \"\"}${endpoint}`,\n context.baseUrl ? undefined : window.location.origin,\n );\n url.searchParams.set(queryParam, String(selectedId));\n\n try {\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n ...context.getApiHeaders?.(),\n \"Content-Type\": \"application/json\",\n },\n signal: context.signal,\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch products for ${staticType} ${selectedId}: ${response.status} ${response.statusText}`,\n );\n }\n\n const json = await response.json();\n return extractProducts(json);\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n // Request was cancelled, don't log as error\n return [];\n }\n console.error(\n `[staticFetcher] Error fetching ${staticType} ${selectedId}:`,\n error,\n );\n throw error;\n }\n}\n\n/**\n * Endpoints for listing static source items (collections, categories, tags).\n */\nconst LIST_ENDPOINTS: Record<\n StaticSourceType,\n { endpoint: string; resultKey: string }\n> = {\n collections: {\n endpoint: \"/company/v1/collections\",\n resultKey: \"collections\",\n },\n categories: { endpoint: \"/company/v1/categories\", resultKey: \"categories\" },\n tags: { endpoint: \"/company/v1/tags\", resultKey: \"tags\" },\n};\n\n/**\n * Result type for useStaticSourceItems hook.\n */\nexport interface UseStaticSourceItemsResult {\n /** The fetched items */\n items: StaticItem[];\n /** True while items are being fetched */\n isLoading: boolean;\n /** Error message if fetch failed */\n error: string | null;\n}\n\n/**\n * React hook for fetching static source items (collections, categories).\n * Handles loading state, error state, abort on cleanup, and search filtering.\n *\n * @param staticType - The type of static source to fetch, or null to reset\n * @param context - Context with baseUrl and getApiHeaders\n * @param params - Optional search parameters\n * @returns Object with items, isLoading, and error state\n */\nexport function useStaticSourceItems(\n staticType: StaticSourceType | null,\n context: Pick<DataSourceContext, \"baseUrl\" | \"getApiHeaders\">,\n params?: { search?: string },\n): UseStaticSourceItemsResult {\n const [items, setItems] = useState<StaticItem[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Extract stable references from context to avoid dependency issues\n const { baseUrl, getApiHeaders } = context;\n const search = params?.search;\n\n // Use ref to avoid infinite re-renders when getApiHeaders changes reference\n const getApiHeadersRef = useRef(getApiHeaders);\n getApiHeadersRef.current = getApiHeaders;\n\n useEffect(() => {\n if (!staticType) {\n setItems([]);\n setError(null);\n return;\n }\n\n let isCancelled = false;\n const abortController = new AbortController();\n setIsLoading(true);\n setError(null);\n\n const config = LIST_ENDPOINTS[staticType];\n const url = new URL(\n `${baseUrl ?? \"\"}${config.endpoint}`,\n baseUrl ? undefined : window.location.origin,\n );\n\n if (search) {\n url.searchParams.set(\"search\", search);\n }\n\n fetch(url.toString(), {\n method: \"GET\",\n headers: {\n ...getApiHeadersRef.current?.(),\n \"Content-Type\": \"application/json\",\n },\n signal: abortController.signal,\n })\n .then(async (response) => {\n if (!response.ok) {\n throw new Error(`Failed to fetch ${staticType}: ${response.status}`);\n }\n const json = await response.json();\n const responseItems = json[config.resultKey] as Array<{\n id: string | number;\n title: string;\n image_url?: string;\n }>;\n\n if (!Array.isArray(responseItems)) {\n console.warn(\n `[useStaticSourceItems] Expected array at \"${config.resultKey}\" but got:`,\n typeof responseItems,\n );\n if (!isCancelled) {\n setItems([]);\n }\n return;\n }\n\n if (!isCancelled) {\n setItems(\n responseItems.map((item) => ({\n id: item.id,\n title: item.title,\n imageUrl: item.image_url,\n })),\n );\n }\n })\n .catch((err) => {\n if (err instanceof Error && err.name === \"AbortError\") {\n return;\n }\n\n // Log for debugging\n console.error(\n `[useStaticSourceItems] Failed to fetch ${staticType}:`,\n err,\n );\n\n if (isCancelled) return;\n\n setError(\"An unexpected error occurred. Please try again.\");\n setItems([]);\n })\n .finally(() => {\n if (!isCancelled) {\n setIsLoading(false);\n }\n });\n\n return () => {\n isCancelled = true;\n abortController.abort();\n };\n }, [staticType, search, baseUrl]);\n\n return { items, isLoading, error };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../chunk-CKQMccvm.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
//#region src/data-sources/preview-context.tsx
|
|
7
|
+
const WidgetPreviewContext = (0, react.createContext)({ isPreview: false });
|
|
8
|
+
function WidgetPreviewProvider({ children }) {
|
|
9
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WidgetPreviewContext, {
|
|
10
|
+
value: { isPreview: true },
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function useWidgetPreviewContext() {
|
|
15
|
+
return (0, react.useContext)(WidgetPreviewContext);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.WidgetPreviewProvider = WidgetPreviewProvider;
|
|
19
|
+
exports.useWidgetPreviewContext = useWidgetPreviewContext;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=preview-context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-context.cjs","names":[],"sources":["../../src/data-sources/preview-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\ntype WidgetPreviewContextValue = {\n isPreview: boolean;\n};\n\nconst WidgetPreviewContext = createContext<WidgetPreviewContextValue>({\n isPreview: false,\n});\n\nexport function WidgetPreviewProvider({\n children,\n}: {\n children: React.ReactNode;\n}): React.JSX.Element {\n return (\n <WidgetPreviewContext value={{ isPreview: true }}>\n {children}\n </WidgetPreviewContext>\n );\n}\n\nexport function useWidgetPreviewContext(): WidgetPreviewContextValue {\n return useContext(WidgetPreviewContext);\n}\n"],"mappings":";;;;;;AAQA,MAAM,wBAAA,GAAA,MAAA,eAAgE,EACpE,WAAW,OACZ,CAAC;AAEF,SAAgB,sBAAsB,EACpC,YAGoB;AACpB,QACE,iBAAA,GAAA,kBAAA,KAAC,sBAAD;EAAsB,OAAO,EAAE,WAAW,MAAM;EAC7C;EACoB,CAAA;;AAI3B,SAAgB,0BAAqD;AACnE,SAAA,GAAA,MAAA,YAAkB,qBAAqB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/data-sources/preview-context.d.ts
|
|
2
|
+
type WidgetPreviewContextValue = {
|
|
3
|
+
isPreview: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare function WidgetPreviewProvider({
|
|
6
|
+
children
|
|
7
|
+
}: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
declare function useWidgetPreviewContext(): WidgetPreviewContextValue;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { WidgetPreviewProvider, useWidgetPreviewContext };
|
|
13
|
+
//# sourceMappingURL=preview-context.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-context.d.cts","names":[],"sources":["../../src/data-sources/preview-context.tsx"],"mappings":";KAIK,yBAAA;EACH,SAAA;AAAA;AAAA,iBAOc,qBAAA,CAAA;EACd;AAAA;EAEA,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA,IACd,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,iBAQE,uBAAA,CAAA,GAA2B,yBAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/data-sources/preview-context.d.ts
|
|
2
|
+
type WidgetPreviewContextValue = {
|
|
3
|
+
isPreview: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare function WidgetPreviewProvider({
|
|
6
|
+
children
|
|
7
|
+
}: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
declare function useWidgetPreviewContext(): WidgetPreviewContextValue;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { WidgetPreviewProvider, useWidgetPreviewContext };
|
|
13
|
+
//# sourceMappingURL=preview-context.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-context.d.mts","names":[],"sources":["../../src/data-sources/preview-context.tsx"],"mappings":";KAIK,yBAAA;EACH,SAAA;AAAA;AAAA,iBAOc,qBAAA,CAAA;EACd;AAAA;EAEA,QAAA,EAAU,KAAA,CAAM,SAAA;AAAA,IACd,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,iBAQE,uBAAA,CAAA,GAA2B,yBAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/data-sources/preview-context.tsx
|
|
5
|
+
const WidgetPreviewContext = createContext({ isPreview: false });
|
|
6
|
+
function WidgetPreviewProvider({ children }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(WidgetPreviewContext, {
|
|
8
|
+
value: { isPreview: true },
|
|
9
|
+
children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function useWidgetPreviewContext() {
|
|
13
|
+
return useContext(WidgetPreviewContext);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { WidgetPreviewProvider, useWidgetPreviewContext };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=preview-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-context.mjs","names":[],"sources":["../../src/data-sources/preview-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\ntype WidgetPreviewContextValue = {\n isPreview: boolean;\n};\n\nconst WidgetPreviewContext = createContext<WidgetPreviewContextValue>({\n isPreview: false,\n});\n\nexport function WidgetPreviewProvider({\n children,\n}: {\n children: React.ReactNode;\n}): React.JSX.Element {\n return (\n <WidgetPreviewContext value={{ isPreview: true }}>\n {children}\n </WidgetPreviewContext>\n );\n}\n\nexport function useWidgetPreviewContext(): WidgetPreviewContextValue {\n return useContext(WidgetPreviewContext);\n}\n"],"mappings":";;;;AAQA,MAAM,uBAAuB,cAAyC,EACpE,WAAW,OACZ,CAAC;AAEF,SAAgB,sBAAsB,EACpC,YAGoB;AACpB,QACE,oBAAC,sBAAD;EAAsB,OAAO,EAAE,WAAW,MAAM;EAC7C;EACoB,CAAA;;AAI3B,SAAgB,0BAAqD;AACnE,QAAO,WAAW,qBAAqB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../chunk-CKQMccvm.cjs");
|
|
3
|
+
const require_data_sources_context = require("./context.cjs");
|
|
4
|
+
const require_data_sources_registry = require("./registry.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/data-sources/registry-context.tsx
|
|
8
|
+
const DataSourceRegistryContext = (0, react.createContext)({ registry: require_data_sources_registry.DEFAULT_DATA_SOURCE_REGISTRY });
|
|
9
|
+
/**
|
|
10
|
+
* Provides data source registry and configuration to all descendants.
|
|
11
|
+
* If no registry is provided, uses the default.
|
|
12
|
+
* Also provides the shared DataSourceProvider from portal-core so that
|
|
13
|
+
* portal-widgets hooks can access baseUrl and getApiHeaders.
|
|
14
|
+
*/
|
|
15
|
+
function DataSourceRegistryProvider({ registry, baseUrl, getApiHeaders, variables, children }) {
|
|
16
|
+
const value = (0, react.useMemo)(() => ({
|
|
17
|
+
registry: registry ?? require_data_sources_registry.DEFAULT_DATA_SOURCE_REGISTRY,
|
|
18
|
+
baseUrl,
|
|
19
|
+
getApiHeaders,
|
|
20
|
+
variables
|
|
21
|
+
}), [
|
|
22
|
+
registry,
|
|
23
|
+
baseUrl,
|
|
24
|
+
getApiHeaders,
|
|
25
|
+
variables
|
|
26
|
+
]);
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataSourceRegistryContext.Provider, {
|
|
28
|
+
value,
|
|
29
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_data_sources_context.DataSourceProvider, {
|
|
30
|
+
baseUrl,
|
|
31
|
+
getApiHeaders,
|
|
32
|
+
children
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Hook to access the data source registry.
|
|
38
|
+
*/
|
|
39
|
+
function useDataSourceRegistry() {
|
|
40
|
+
return (0, react.useContext)(DataSourceRegistryContext).registry;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Hook to access the full data source registry context (registry + config).
|
|
44
|
+
*/
|
|
45
|
+
function useDataSourceRegistryConfig() {
|
|
46
|
+
return (0, react.useContext)(DataSourceRegistryContext);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.DataSourceRegistryProvider = DataSourceRegistryProvider;
|
|
50
|
+
exports.useDataSourceRegistry = useDataSourceRegistry;
|
|
51
|
+
exports.useDataSourceRegistryConfig = useDataSourceRegistryConfig;
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=registry-context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-context.cjs","names":["DEFAULT_DATA_SOURCE_REGISTRY","DataSourceProvider"],"sources":["../../src/data-sources/registry-context.tsx"],"sourcesContent":["import type React from \"react\";\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport type { DataSourceRegistry } from \"./types\";\nimport { DEFAULT_DATA_SOURCE_REGISTRY } from \"./registry\";\nimport { DataSourceProvider } from \"./context\";\n\ninterface DataSourceRegistryContextValue {\n registry: DataSourceRegistry;\n baseUrl?: string | undefined;\n /** Get API headers function */\n getApiHeaders?: (() => Record<string, string>) | undefined;\n /** Dynamic variables for endpoint path substitution (e.g., { rep_id: \"123\" }) */\n variables?: Record<string, string> | undefined;\n}\n\nconst DataSourceRegistryContext = createContext<DataSourceRegistryContextValue>(\n {\n registry: DEFAULT_DATA_SOURCE_REGISTRY,\n },\n);\n\nexport interface DataSourceRegistryProviderProps {\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n /**\n * Get API headers function\n */\n getApiHeaders?: (() => Record<string, string>) | undefined;\n /** Dynamic variables for endpoint path substitution (e.g., { rep_id: \"123\" }) */\n variables?: Record<string, string> | undefined;\n children: ReactNode;\n}\n\n/**\n * Provides data source registry and configuration to all descendants.\n * If no registry is provided, uses the default.\n * Also provides the shared DataSourceProvider from portal-core so that\n * portal-widgets hooks can access baseUrl and getApiHeaders.\n */\nexport function DataSourceRegistryProvider({\n registry,\n baseUrl,\n getApiHeaders,\n variables,\n children,\n}: DataSourceRegistryProviderProps): React.JSX.Element {\n const value = useMemo(\n () => ({\n registry: registry ?? DEFAULT_DATA_SOURCE_REGISTRY,\n baseUrl,\n getApiHeaders,\n variables,\n }),\n [registry, baseUrl, getApiHeaders, variables],\n );\n\n return (\n <DataSourceRegistryContext.Provider value={value}>\n <DataSourceProvider baseUrl={baseUrl} getApiHeaders={getApiHeaders}>\n {children}\n </DataSourceProvider>\n </DataSourceRegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the data source registry.\n */\nexport function useDataSourceRegistry(): DataSourceRegistry {\n return useContext(DataSourceRegistryContext).registry;\n}\n\n/**\n * Hook to access the full data source registry context (registry + config).\n */\nexport function useDataSourceRegistryConfig(): DataSourceRegistryContextValue {\n return useContext(DataSourceRegistryContext);\n}\n"],"mappings":";;;;;;;AAeA,MAAM,6BAAA,GAAA,MAAA,eACJ,EACE,UAAUA,8BAAAA,8BACX,CACF;;;;;;;AAqBD,SAAgB,2BAA2B,EACzC,UACA,SACA,eACA,WACA,YACqD;CACrD,MAAM,SAAA,GAAA,MAAA,gBACG;EACL,UAAU,YAAYA,8BAAAA;EACtB;EACA;EACA;EACD,GACD;EAAC;EAAU;EAAS;EAAe;EAAU,CAC9C;AAED,QACE,iBAAA,GAAA,kBAAA,KAAC,0BAA0B,UAA3B;EAA2C;YACzC,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,oBAAD;GAA6B;GAAwB;GAClD;GACkB,CAAA;EACc,CAAA;;;;;AAOzC,SAAgB,wBAA4C;AAC1D,SAAA,GAAA,MAAA,YAAkB,0BAA0B,CAAC;;;;;AAM/C,SAAgB,8BAA8D;AAC5E,SAAA,GAAA,MAAA,YAAkB,0BAA0B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { s as DataSourceRegistry } from "../types-DrzvahW8.cjs";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/data-sources/registry-context.d.ts
|
|
5
|
+
interface DataSourceRegistryContextValue {
|
|
6
|
+
registry: DataSourceRegistry;
|
|
7
|
+
baseUrl?: string | undefined;
|
|
8
|
+
/** Get API headers function */
|
|
9
|
+
getApiHeaders?: (() => Record<string, string>) | undefined;
|
|
10
|
+
/** Dynamic variables for endpoint path substitution (e.g., { rep_id: "123" }) */
|
|
11
|
+
variables?: Record<string, string> | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface DataSourceRegistryProviderProps {
|
|
14
|
+
registry?: DataSourceRegistry | undefined;
|
|
15
|
+
/** Base URL for API calls (e.g., "https://api.fluid.app/api") */
|
|
16
|
+
baseUrl?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get API headers function
|
|
19
|
+
*/
|
|
20
|
+
getApiHeaders?: (() => Record<string, string>) | undefined;
|
|
21
|
+
/** Dynamic variables for endpoint path substitution (e.g., { rep_id: "123" }) */
|
|
22
|
+
variables?: Record<string, string> | undefined;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Provides data source registry and configuration to all descendants.
|
|
27
|
+
* If no registry is provided, uses the default.
|
|
28
|
+
* Also provides the shared DataSourceProvider from portal-core so that
|
|
29
|
+
* portal-widgets hooks can access baseUrl and getApiHeaders.
|
|
30
|
+
*/
|
|
31
|
+
declare function DataSourceRegistryProvider({
|
|
32
|
+
registry,
|
|
33
|
+
baseUrl,
|
|
34
|
+
getApiHeaders,
|
|
35
|
+
variables,
|
|
36
|
+
children
|
|
37
|
+
}: DataSourceRegistryProviderProps): React.JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to access the data source registry.
|
|
40
|
+
*/
|
|
41
|
+
declare function useDataSourceRegistry(): DataSourceRegistry;
|
|
42
|
+
/**
|
|
43
|
+
* Hook to access the full data source registry context (registry + config).
|
|
44
|
+
*/
|
|
45
|
+
declare function useDataSourceRegistryConfig(): DataSourceRegistryContextValue;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { DataSourceRegistryProvider, DataSourceRegistryProviderProps, useDataSourceRegistry, useDataSourceRegistryConfig };
|
|
48
|
+
//# sourceMappingURL=registry-context.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-context.d.cts","names":[],"sources":["../../src/data-sources/registry-context.tsx"],"mappings":";;;;UAMU,8BAAA;EACR,QAAA,EAAU,kBAAA;EACV,OAAA;;EAEA,aAAA,UAAuB,MAAA;;EAEvB,SAAA,GAAY,MAAA;AAAA;AAAA,UASG,+BAAA;EACf,QAAA,GAAW,kBAAA;;EAEX,OAAA;;;;EAIA,aAAA,UAAuB,MAAA;;EAEvB,SAAA,GAAY,MAAA;EACZ,QAAA,EAAU,SAAA;AAAA;;;;;;;iBASI,0BAAA,CAAA;EACd,QAAA;EACA,OAAA;EACA,aAAA;EACA,SAAA;EACA;AAAA,GACC,+BAAA,GAAkC,KAAA,CAAM,GAAA,CAAI,OAAA;;;;iBAuB/B,qBAAA,CAAA,GAAyB,kBAAA;;;;iBAOzB,2BAAA,CAAA,GAA+B,8BAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { s as DataSourceRegistry } from "../types-C5Zs5V3E.mjs";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/data-sources/registry-context.d.ts
|
|
5
|
+
interface DataSourceRegistryContextValue {
|
|
6
|
+
registry: DataSourceRegistry;
|
|
7
|
+
baseUrl?: string | undefined;
|
|
8
|
+
/** Get API headers function */
|
|
9
|
+
getApiHeaders?: (() => Record<string, string>) | undefined;
|
|
10
|
+
/** Dynamic variables for endpoint path substitution (e.g., { rep_id: "123" }) */
|
|
11
|
+
variables?: Record<string, string> | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface DataSourceRegistryProviderProps {
|
|
14
|
+
registry?: DataSourceRegistry | undefined;
|
|
15
|
+
/** Base URL for API calls (e.g., "https://api.fluid.app/api") */
|
|
16
|
+
baseUrl?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get API headers function
|
|
19
|
+
*/
|
|
20
|
+
getApiHeaders?: (() => Record<string, string>) | undefined;
|
|
21
|
+
/** Dynamic variables for endpoint path substitution (e.g., { rep_id: "123" }) */
|
|
22
|
+
variables?: Record<string, string> | undefined;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Provides data source registry and configuration to all descendants.
|
|
27
|
+
* If no registry is provided, uses the default.
|
|
28
|
+
* Also provides the shared DataSourceProvider from portal-core so that
|
|
29
|
+
* portal-widgets hooks can access baseUrl and getApiHeaders.
|
|
30
|
+
*/
|
|
31
|
+
declare function DataSourceRegistryProvider({
|
|
32
|
+
registry,
|
|
33
|
+
baseUrl,
|
|
34
|
+
getApiHeaders,
|
|
35
|
+
variables,
|
|
36
|
+
children
|
|
37
|
+
}: DataSourceRegistryProviderProps): React.JSX.Element;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to access the data source registry.
|
|
40
|
+
*/
|
|
41
|
+
declare function useDataSourceRegistry(): DataSourceRegistry;
|
|
42
|
+
/**
|
|
43
|
+
* Hook to access the full data source registry context (registry + config).
|
|
44
|
+
*/
|
|
45
|
+
declare function useDataSourceRegistryConfig(): DataSourceRegistryContextValue;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { DataSourceRegistryProvider, DataSourceRegistryProviderProps, useDataSourceRegistry, useDataSourceRegistryConfig };
|
|
48
|
+
//# sourceMappingURL=registry-context.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-context.d.mts","names":[],"sources":["../../src/data-sources/registry-context.tsx"],"mappings":";;;;UAMU,8BAAA;EACR,QAAA,EAAU,kBAAA;EACV,OAAA;;EAEA,aAAA,UAAuB,MAAA;;EAEvB,SAAA,GAAY,MAAA;AAAA;AAAA,UASG,+BAAA;EACf,QAAA,GAAW,kBAAA;;EAEX,OAAA;;;;EAIA,aAAA,UAAuB,MAAA;;EAEvB,SAAA,GAAY,MAAA;EACZ,QAAA,EAAU,SAAA;AAAA;;;;;;;iBASI,0BAAA,CAAA;EACd,QAAA;EACA,OAAA;EACA,aAAA;EACA,SAAA;EACA;AAAA,GACC,+BAAA,GAAkC,KAAA,CAAM,GAAA,CAAI,OAAA;;;;iBAuB/B,qBAAA,CAAA,GAAyB,kBAAA;;;;iBAOzB,2BAAA,CAAA,GAA+B,8BAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DataSourceProvider } from "./context.mjs";
|
|
2
|
+
import { DEFAULT_DATA_SOURCE_REGISTRY } from "./registry.mjs";
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/data-sources/registry-context.tsx
|
|
6
|
+
const DataSourceRegistryContext = createContext({ registry: DEFAULT_DATA_SOURCE_REGISTRY });
|
|
7
|
+
/**
|
|
8
|
+
* Provides data source registry and configuration to all descendants.
|
|
9
|
+
* If no registry is provided, uses the default.
|
|
10
|
+
* Also provides the shared DataSourceProvider from portal-core so that
|
|
11
|
+
* portal-widgets hooks can access baseUrl and getApiHeaders.
|
|
12
|
+
*/
|
|
13
|
+
function DataSourceRegistryProvider({ registry, baseUrl, getApiHeaders, variables, children }) {
|
|
14
|
+
const value = useMemo(() => ({
|
|
15
|
+
registry: registry ?? DEFAULT_DATA_SOURCE_REGISTRY,
|
|
16
|
+
baseUrl,
|
|
17
|
+
getApiHeaders,
|
|
18
|
+
variables
|
|
19
|
+
}), [
|
|
20
|
+
registry,
|
|
21
|
+
baseUrl,
|
|
22
|
+
getApiHeaders,
|
|
23
|
+
variables
|
|
24
|
+
]);
|
|
25
|
+
return /* @__PURE__ */ jsx(DataSourceRegistryContext.Provider, {
|
|
26
|
+
value,
|
|
27
|
+
children: /* @__PURE__ */ jsx(DataSourceProvider, {
|
|
28
|
+
baseUrl,
|
|
29
|
+
getApiHeaders,
|
|
30
|
+
children
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hook to access the data source registry.
|
|
36
|
+
*/
|
|
37
|
+
function useDataSourceRegistry() {
|
|
38
|
+
return useContext(DataSourceRegistryContext).registry;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hook to access the full data source registry context (registry + config).
|
|
42
|
+
*/
|
|
43
|
+
function useDataSourceRegistryConfig() {
|
|
44
|
+
return useContext(DataSourceRegistryContext);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { DataSourceRegistryProvider, useDataSourceRegistry, useDataSourceRegistryConfig };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=registry-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-context.mjs","names":[],"sources":["../../src/data-sources/registry-context.tsx"],"sourcesContent":["import type React from \"react\";\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport type { DataSourceRegistry } from \"./types\";\nimport { DEFAULT_DATA_SOURCE_REGISTRY } from \"./registry\";\nimport { DataSourceProvider } from \"./context\";\n\ninterface DataSourceRegistryContextValue {\n registry: DataSourceRegistry;\n baseUrl?: string | undefined;\n /** Get API headers function */\n getApiHeaders?: (() => Record<string, string>) | undefined;\n /** Dynamic variables for endpoint path substitution (e.g., { rep_id: \"123\" }) */\n variables?: Record<string, string> | undefined;\n}\n\nconst DataSourceRegistryContext = createContext<DataSourceRegistryContextValue>(\n {\n registry: DEFAULT_DATA_SOURCE_REGISTRY,\n },\n);\n\nexport interface DataSourceRegistryProviderProps {\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n /**\n * Get API headers function\n */\n getApiHeaders?: (() => Record<string, string>) | undefined;\n /** Dynamic variables for endpoint path substitution (e.g., { rep_id: \"123\" }) */\n variables?: Record<string, string> | undefined;\n children: ReactNode;\n}\n\n/**\n * Provides data source registry and configuration to all descendants.\n * If no registry is provided, uses the default.\n * Also provides the shared DataSourceProvider from portal-core so that\n * portal-widgets hooks can access baseUrl and getApiHeaders.\n */\nexport function DataSourceRegistryProvider({\n registry,\n baseUrl,\n getApiHeaders,\n variables,\n children,\n}: DataSourceRegistryProviderProps): React.JSX.Element {\n const value = useMemo(\n () => ({\n registry: registry ?? DEFAULT_DATA_SOURCE_REGISTRY,\n baseUrl,\n getApiHeaders,\n variables,\n }),\n [registry, baseUrl, getApiHeaders, variables],\n );\n\n return (\n <DataSourceRegistryContext.Provider value={value}>\n <DataSourceProvider baseUrl={baseUrl} getApiHeaders={getApiHeaders}>\n {children}\n </DataSourceProvider>\n </DataSourceRegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the data source registry.\n */\nexport function useDataSourceRegistry(): DataSourceRegistry {\n return useContext(DataSourceRegistryContext).registry;\n}\n\n/**\n * Hook to access the full data source registry context (registry + config).\n */\nexport function useDataSourceRegistryConfig(): DataSourceRegistryContextValue {\n return useContext(DataSourceRegistryContext);\n}\n"],"mappings":";;;;;AAeA,MAAM,4BAA4B,cAChC,EACE,UAAU,8BACX,CACF;;;;;;;AAqBD,SAAgB,2BAA2B,EACzC,UACA,SACA,eACA,WACA,YACqD;CACrD,MAAM,QAAQ,eACL;EACL,UAAU,YAAY;EACtB;EACA;EACA;EACD,GACD;EAAC;EAAU;EAAS;EAAe;EAAU,CAC9C;AAED,QACE,oBAAC,0BAA0B,UAA3B;EAA2C;YACzC,oBAAC,oBAAD;GAA6B;GAAwB;GAClD;GACkB,CAAA;EACc,CAAA;;;;;AAOzC,SAAgB,wBAA4C;AAC1D,QAAO,WAAW,0BAA0B,CAAC;;;;;AAM/C,SAAgB,8BAA8D;AAC5E,QAAO,WAAW,0BAA0B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_data_sources_fetchers_api = require("./fetchers/api.cjs");
|
|
3
|
+
const require_data_sources_fetchers_custom = require("./fetchers/custom.cjs");
|
|
4
|
+
const require_data_sources_fetchers_static = require("./fetchers/static.cjs");
|
|
5
|
+
const require_data_sources_transformers = require("./transformers.cjs");
|
|
6
|
+
//#region src/data-sources/registry.ts
|
|
7
|
+
/**
|
|
8
|
+
* Creates a data source registry with default fetchers.
|
|
9
|
+
* Users can extend this with custom fetchers and transformers.
|
|
10
|
+
*/
|
|
11
|
+
function createDataSourceRegistry(options) {
|
|
12
|
+
return {
|
|
13
|
+
fetchers: {
|
|
14
|
+
api: require_data_sources_fetchers_api.apiFetcher,
|
|
15
|
+
custom: require_data_sources_fetchers_custom.customFetcher,
|
|
16
|
+
static: require_data_sources_fetchers_static.staticFetcher,
|
|
17
|
+
...options?.fetchers
|
|
18
|
+
},
|
|
19
|
+
transformers: {
|
|
20
|
+
...require_data_sources_transformers.WIDGET_TRANSFORMERS,
|
|
21
|
+
...options?.transformers
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Default registry instance */
|
|
26
|
+
const DEFAULT_DATA_SOURCE_REGISTRY = createDataSourceRegistry();
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.DEFAULT_DATA_SOURCE_REGISTRY = DEFAULT_DATA_SOURCE_REGISTRY;
|
|
29
|
+
exports.createDataSourceRegistry = createDataSourceRegistry;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=registry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.cjs","names":["apiFetcher","customFetcher","staticFetcher","WIDGET_TRANSFORMERS"],"sources":["../../src/data-sources/registry.ts"],"sourcesContent":["import type {\n DataSourceRegistry,\n DataFetcher,\n DataTransformer,\n DataSourceType,\n} from \"./types\";\nimport { apiFetcher } from \"./fetchers/api\";\nimport { customFetcher } from \"./fetchers/custom\";\nimport { staticFetcher } from \"./fetchers/static\";\nimport { WIDGET_TRANSFORMERS } from \"./transformers\";\n\nexport interface CreateDataSourceRegistryOptions {\n /** Custom fetchers to add or override */\n fetchers?: Partial<Record<DataSourceType, DataFetcher>>;\n /** Custom transform functions */\n transformers?: Record<string, DataTransformer>;\n}\n\n/**\n * Creates a data source registry with default fetchers.\n * Users can extend this with custom fetchers and transformers.\n */\nexport function createDataSourceRegistry(\n options?: CreateDataSourceRegistryOptions,\n): DataSourceRegistry {\n return {\n fetchers: {\n api: apiFetcher,\n custom: customFetcher,\n static: staticFetcher,\n ...options?.fetchers,\n } as Record<DataSourceType, DataFetcher>,\n transformers: {\n ...WIDGET_TRANSFORMERS,\n ...options?.transformers,\n },\n };\n}\n\n/** Default registry instance */\nexport const DEFAULT_DATA_SOURCE_REGISTRY: DataSourceRegistry =\n createDataSourceRegistry();\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,yBACd,SACoB;AACpB,QAAO;EACL,UAAU;GACR,KAAKA,kCAAAA;GACL,QAAQC,qCAAAA;GACR,QAAQC,qCAAAA;GACR,GAAG,SAAS;GACb;EACD,cAAc;GACZ,GAAGC,kCAAAA;GACH,GAAG,SAAS;GACb;EACF;;;AAIH,MAAa,+BACX,0BAA0B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { c as DataSourceType, l as DataTransformer, r as DataFetcher, s as DataSourceRegistry } from "../types-DrzvahW8.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/data-sources/registry.d.ts
|
|
4
|
+
interface CreateDataSourceRegistryOptions {
|
|
5
|
+
/** Custom fetchers to add or override */
|
|
6
|
+
fetchers?: Partial<Record<DataSourceType, DataFetcher>>;
|
|
7
|
+
/** Custom transform functions */
|
|
8
|
+
transformers?: Record<string, DataTransformer>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a data source registry with default fetchers.
|
|
12
|
+
* Users can extend this with custom fetchers and transformers.
|
|
13
|
+
*/
|
|
14
|
+
declare function createDataSourceRegistry(options?: CreateDataSourceRegistryOptions): DataSourceRegistry;
|
|
15
|
+
/** Default registry instance */
|
|
16
|
+
declare const DEFAULT_DATA_SOURCE_REGISTRY: DataSourceRegistry;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CreateDataSourceRegistryOptions, DEFAULT_DATA_SOURCE_REGISTRY, createDataSourceRegistry };
|
|
19
|
+
//# sourceMappingURL=registry.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.cts","names":[],"sources":["../../src/data-sources/registry.ts"],"mappings":";;;UAWiB,+BAAA;;EAEf,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,cAAA,EAAgB,WAAA;EAF3B;EAIf,YAAA,GAAe,MAAA,SAAe,eAAA;AAAA;;;;;iBAOhB,wBAAA,CACd,OAAA,GAAU,+BAAA,GACT,kBAAA;;cAgBU,4BAAA,EAA8B,kBAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { c as DataSourceType, l as DataTransformer, r as DataFetcher, s as DataSourceRegistry } from "../types-C5Zs5V3E.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/data-sources/registry.d.ts
|
|
4
|
+
interface CreateDataSourceRegistryOptions {
|
|
5
|
+
/** Custom fetchers to add or override */
|
|
6
|
+
fetchers?: Partial<Record<DataSourceType, DataFetcher>>;
|
|
7
|
+
/** Custom transform functions */
|
|
8
|
+
transformers?: Record<string, DataTransformer>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a data source registry with default fetchers.
|
|
12
|
+
* Users can extend this with custom fetchers and transformers.
|
|
13
|
+
*/
|
|
14
|
+
declare function createDataSourceRegistry(options?: CreateDataSourceRegistryOptions): DataSourceRegistry;
|
|
15
|
+
/** Default registry instance */
|
|
16
|
+
declare const DEFAULT_DATA_SOURCE_REGISTRY: DataSourceRegistry;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CreateDataSourceRegistryOptions, DEFAULT_DATA_SOURCE_REGISTRY, createDataSourceRegistry };
|
|
19
|
+
//# sourceMappingURL=registry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.mts","names":[],"sources":["../../src/data-sources/registry.ts"],"mappings":";;;UAWiB,+BAAA;;EAEf,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,cAAA,EAAgB,WAAA;EAF3B;EAIf,YAAA,GAAe,MAAA,SAAe,eAAA;AAAA;;;;;iBAOhB,wBAAA,CACd,OAAA,GAAU,+BAAA,GACT,kBAAA;;cAgBU,4BAAA,EAA8B,kBAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { apiFetcher } from "./fetchers/api.mjs";
|
|
2
|
+
import { customFetcher } from "./fetchers/custom.mjs";
|
|
3
|
+
import { staticFetcher } from "./fetchers/static.mjs";
|
|
4
|
+
import { WIDGET_TRANSFORMERS } from "./transformers.mjs";
|
|
5
|
+
//#region src/data-sources/registry.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a data source registry with default fetchers.
|
|
8
|
+
* Users can extend this with custom fetchers and transformers.
|
|
9
|
+
*/
|
|
10
|
+
function createDataSourceRegistry(options) {
|
|
11
|
+
return {
|
|
12
|
+
fetchers: {
|
|
13
|
+
api: apiFetcher,
|
|
14
|
+
custom: customFetcher,
|
|
15
|
+
static: staticFetcher,
|
|
16
|
+
...options?.fetchers
|
|
17
|
+
},
|
|
18
|
+
transformers: {
|
|
19
|
+
...WIDGET_TRANSFORMERS,
|
|
20
|
+
...options?.transformers
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Default registry instance */
|
|
25
|
+
const DEFAULT_DATA_SOURCE_REGISTRY = createDataSourceRegistry();
|
|
26
|
+
//#endregion
|
|
27
|
+
export { DEFAULT_DATA_SOURCE_REGISTRY, createDataSourceRegistry };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=registry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.mjs","names":[],"sources":["../../src/data-sources/registry.ts"],"sourcesContent":["import type {\n DataSourceRegistry,\n DataFetcher,\n DataTransformer,\n DataSourceType,\n} from \"./types\";\nimport { apiFetcher } from \"./fetchers/api\";\nimport { customFetcher } from \"./fetchers/custom\";\nimport { staticFetcher } from \"./fetchers/static\";\nimport { WIDGET_TRANSFORMERS } from \"./transformers\";\n\nexport interface CreateDataSourceRegistryOptions {\n /** Custom fetchers to add or override */\n fetchers?: Partial<Record<DataSourceType, DataFetcher>>;\n /** Custom transform functions */\n transformers?: Record<string, DataTransformer>;\n}\n\n/**\n * Creates a data source registry with default fetchers.\n * Users can extend this with custom fetchers and transformers.\n */\nexport function createDataSourceRegistry(\n options?: CreateDataSourceRegistryOptions,\n): DataSourceRegistry {\n return {\n fetchers: {\n api: apiFetcher,\n custom: customFetcher,\n static: staticFetcher,\n ...options?.fetchers,\n } as Record<DataSourceType, DataFetcher>,\n transformers: {\n ...WIDGET_TRANSFORMERS,\n ...options?.transformers,\n },\n };\n}\n\n/** Default registry instance */\nexport const DEFAULT_DATA_SOURCE_REGISTRY: DataSourceRegistry =\n createDataSourceRegistry();\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,yBACd,SACoB;AACpB,QAAO;EACL,UAAU;GACR,KAAK;GACL,QAAQ;GACR,QAAQ;GACR,GAAG,SAAS;GACb;EACD,cAAc;GACZ,GAAG;GACH,GAAG,SAAS;GACb;EACF;;;AAIH,MAAa,+BACX,0BAA0B"}
|