@burdenoff/microfe-bigconsole 2026.729.4 → 2026.730.2

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.
@@ -18,9 +18,8 @@ import "../builder/DashboardEditorShell.js";
18
18
  import "../builder/index.js";
19
19
  import "./DashboardCanvas.js";
20
20
  import "./LiveCanvasToggle.js";
21
- import "./TemplatePicker/TemplatePicker.js";
22
- import "./TemplatePicker/index.js";
23
21
  import "./CreateDashboardDialog.js";
24
22
  import "./ExportDashboardDialog.js";
25
23
  import "./ImportDashboardDialog.js";
24
+ import "./TemplatePicker/index.js";
26
25
  import "./DrilldownBreadcrumb.js";
@@ -0,0 +1,27 @@
1
+ import "../../generated/global-operations.js";
2
+ import { gql as e } from "@apollo/client";
3
+ //#region src/bigconsole/graphql/storeTemplates.ts
4
+ var t = e`
5
+ mutation ImportDashboardTemplate($input: ImportDashboardTemplateInput!) {
6
+ importDashboardTemplate(input: $input) {
7
+ success
8
+ errorMessage
9
+ unresolvedSlots
10
+ resolvedSlots
11
+ widgetsNeedingData
12
+ warnings
13
+ stats {
14
+ pagesCreated
15
+ widgetsCreated
16
+ }
17
+ dashboard {
18
+ id
19
+ name
20
+ }
21
+ }
22
+ }
23
+ `;
24
+ //#endregion
25
+ export { t as IMPORT_DASHBOARD_TEMPLATE };
26
+
27
+ //# sourceMappingURL=storeTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storeTemplates.js","names":[],"sources":["../../../src/bigconsole/graphql/storeTemplates.ts"],"sourcesContent":["/**\n * GraphQL documents for store-distributed dashboard templates.\n *\n * The two catalog reads are generated from\n * `src/operations/global/store/queries/*.graphql` in the usual way.\n *\n * `IMPORT_DASHBOARD_TEMPLATE` is defined inline as an interim measure.\n * `importDashboardTemplate` is new in wspace-bigconsole-svc, so it is not yet\n * present in `graphql/wspace.graphql` — that file is only ever refreshed by\n * `bun run schema:pull` against a live gateway (hand-editing it is a repo\n * guardrail), and the gateway supergraph only carries the field once the\n * service has deployed and Hive has reconciled.\n *\n * It cannot simply be dropped into `src/operations/wspace/**` yet either:\n * `src/generated` is gitignored and CI regenerates it, so an operation file\n * referencing a field the checked-in schema lacks fails codegen and breaks the\n * build. Once `schema:pull` has run, move this document into\n * `src/operations/wspace/dashboard/mutations/importDashboardTemplate.graphql`\n * and import the generated `ImportDashboardTemplateDocument` instead — the\n * shape is unchanged.\n *\n * @module bigconsole/graphql/storeTemplates\n */\nimport { gql } from '@apollo/client';\n\nexport {\n BrowseDashboardTemplatesDocument as BROWSE_DASHBOARD_TEMPLATES,\n GetDashboardTemplateDetailDocument as GET_DASHBOARD_TEMPLATE_DETAIL,\n} from '../../generated/global-operations';\n\nexport const IMPORT_DASHBOARD_TEMPLATE = gql`\n mutation ImportDashboardTemplate($input: ImportDashboardTemplateInput!) {\n importDashboardTemplate(input: $input) {\n success\n errorMessage\n unresolvedSlots\n resolvedSlots\n widgetsNeedingData\n warnings\n stats {\n pagesCreated\n widgetsCreated\n }\n dashboard {\n id\n name\n }\n }\n }\n`;\n"],"mappings":";;;AA8BA,IAAa,IAA4B,CAAG"}
@@ -1,301 +1,4 @@
1
- import { ArchiveTemplateDocument as e, CreateTemplateDocument as t, DeleteTemplateDocument as n, DeprecateTemplateDocument as r, GetTemplateDocument as i, InstantiateTemplateDocument as a, ListFeaturedTemplatesDocument as o, ListTemplatesDocument as s, PublishTemplateDocument as c, RateTemplateDocument as l, SearchTemplatesDocument as u, UpdateTemplateDocument as d } from "../../generated/wspace-operations.js";
2
- import { createBigConsoleQuotaError as f, isBigConsoleQuotaError as p } from "../utils/quota.js";
3
- import { useCallback as m, useState as h } from "react";
4
- import { useApolloClient as g } from "@apollo/client/react";
5
- //#region src/bigconsole/hooks/useDashboardTemplates.ts
6
- function _(e) {
7
- return {
8
- id: e.id,
9
- workspaceId: e.workspaceId,
10
- tenantId: e.tenantId,
11
- name: e.name,
12
- description: e.description,
13
- category: e.category,
14
- tags: e.tags || [],
15
- definition: e.definition || {},
16
- definitionVersion: e.definitionVersion || "1.0",
17
- placeholders: e.placeholders || {},
18
- thumbnailFileId: e.thumbnailFileId,
19
- previewUrl: e.previewUrl,
20
- authorType: e.authorType || "WORKSPACE",
21
- isPublic: e.isPublic ?? !1,
22
- isActive: e.isActive ?? !0,
23
- isFeatured: e.isFeatured ?? !1,
24
- complexity: e.complexity || "BEGINNER",
25
- usageCount: e.usageCount || 0,
26
- rating: e.rating,
27
- ratingCount: e.ratingCount || 0,
28
- status: e.status || "DRAFT",
29
- version: e.version || 1,
30
- metadata: e.metadata,
31
- createdAt: e.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
32
- createdBy: e.createdBy,
33
- updatedAt: e.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
34
- };
35
- }
36
- function v(e) {
37
- return {
38
- id: e.id,
39
- workspaceId: e.workspaceId,
40
- name: e.name,
41
- description: e.description,
42
- category: e.category,
43
- tags: e.tags || [],
44
- thumbnailFileId: e.thumbnailFileId,
45
- previewUrl: e.previewUrl,
46
- authorType: e.authorType || "WORKSPACE",
47
- isPublic: e.isPublic ?? !1,
48
- isFeatured: e.isFeatured ?? !1,
49
- complexity: e.complexity || "BEGINNER",
50
- usageCount: e.usageCount || 0,
51
- rating: e.rating,
52
- ratingCount: e.ratingCount || 0,
53
- status: e.status || "DRAFT",
54
- createdAt: e.createdAt || (/* @__PURE__ */ new Date()).toISOString()
55
- };
56
- }
57
- function y() {
58
- let [y, b] = h([]), [x, S] = h([]), [C, w] = h(!1), [T, E] = h(null), D = g(), O = [
59
- "ANALYTICS",
60
- "OPERATIONS",
61
- "SALES",
62
- "MARKETING",
63
- "FINANCE",
64
- "HR",
65
- "CUSTOM"
66
- ], k = m(async (e) => {
67
- try {
68
- w(!0), E(null);
69
- let t = ((await D.query({
70
- query: s,
71
- variables: {
72
- ...e,
73
- first: 100
74
- },
75
- fetchPolicy: "network-only"
76
- })).data?.listTemplates?.edges || []).map((e) => v(e.node));
77
- return b(t), t;
78
- } catch (e) {
79
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to fetch templates")), [];
80
- } finally {
81
- w(!1);
82
- }
83
- }, [D]);
84
- return {
85
- templates: y,
86
- featuredTemplates: x,
87
- categories: O,
88
- loading: C,
89
- error: T,
90
- fetchTemplates: k,
91
- fetchFeaturedTemplates: m(async (e) => {
92
- try {
93
- w(!0), E(null);
94
- let t = ((await D.query({
95
- query: o,
96
- variables: {
97
- category: e,
98
- first: 50
99
- },
100
- fetchPolicy: "network-only"
101
- })).data?.listFeaturedTemplates?.edges || []).map((e) => v(e.node));
102
- return S(t), t;
103
- } catch (e) {
104
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to fetch featured templates")), [];
105
- } finally {
106
- w(!1);
107
- }
108
- }, [D]),
109
- searchTemplates: m(async (e, t, n) => {
110
- try {
111
- w(!0), E(null);
112
- let r = ((await D.query({
113
- query: u,
114
- variables: {
115
- query: e,
116
- category: t,
117
- complexity: n,
118
- first: 50
119
- },
120
- fetchPolicy: "network-only"
121
- })).data?.searchTemplates?.edges || []).map((e) => v(e.node));
122
- return b(r), r;
123
- } catch (e) {
124
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to search templates")), [];
125
- } finally {
126
- w(!1);
127
- }
128
- }, [D]),
129
- getTemplate: m(async (e) => {
130
- try {
131
- w(!0), E(null);
132
- let t = await D.query({
133
- query: i,
134
- variables: { id: e },
135
- fetchPolicy: "network-only"
136
- });
137
- return t.data?.getTemplate ? _(t.data.getTemplate) : null;
138
- } catch (e) {
139
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to get template")), null;
140
- } finally {
141
- w(!1);
142
- }
143
- }, [D]),
144
- createTemplate: m(async (e) => {
145
- try {
146
- w(!0), E(null);
147
- let n = await D.mutate({
148
- mutation: t,
149
- variables: { input: e }
150
- });
151
- if (n.data?.createTemplate) {
152
- let e = _(n.data.createTemplate);
153
- return await k(), e;
154
- }
155
- return null;
156
- } catch (e) {
157
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to create template")), null;
158
- } finally {
159
- w(!1);
160
- }
161
- }, [D, k]),
162
- updateTemplate: m(async (e) => {
163
- try {
164
- w(!0), E(null);
165
- let t = await D.mutate({
166
- mutation: d,
167
- variables: { input: e }
168
- });
169
- if (t.data?.updateTemplate) {
170
- let e = t.data.updateTemplate, n = _(e);
171
- return b((t) => t.map((t) => t.id === n.id ? v(e) : t)), n;
172
- }
173
- return null;
174
- } catch (e) {
175
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to update template")), null;
176
- } finally {
177
- w(!1);
178
- }
179
- }, [D]),
180
- deleteTemplate: m(async (e) => {
181
- try {
182
- return w(!0), E(null), (await D.mutate({
183
- mutation: n,
184
- variables: { id: e }
185
- })).data?.deleteTemplate ? (b((t) => t.filter((t) => t.id !== e)), S((t) => t.filter((t) => t.id !== e)), !0) : !1;
186
- } catch (e) {
187
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to delete template")), !1;
188
- } finally {
189
- w(!1);
190
- }
191
- }, [D]),
192
- instantiateTemplate: m(async (e) => {
193
- try {
194
- w(!0), E(null);
195
- let t = await D.mutate({
196
- mutation: a,
197
- variables: { input: e }
198
- });
199
- if (p(t)) throw f(t);
200
- return t.data?.instantiateTemplate ? (b((t) => t.map((t) => t.id === e.templateId ? {
201
- ...t,
202
- usageCount: t.usageCount + 1
203
- } : t)), t.data.instantiateTemplate) : null;
204
- } catch (e) {
205
- if (p(e)) throw e;
206
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to instantiate template")), null;
207
- } finally {
208
- w(!1);
209
- }
210
- }, [D]),
211
- rateTemplate: m(async (e) => {
212
- try {
213
- w(!0), E(null);
214
- let t = await D.mutate({
215
- mutation: l,
216
- variables: { input: e }
217
- });
218
- if (t.data?.rateTemplate) {
219
- let e = _(t.data.rateTemplate);
220
- return b((t) => t.map((t) => t.id === e.id ? {
221
- ...t,
222
- rating: e.rating,
223
- ratingCount: e.ratingCount
224
- } : t)), e;
225
- }
226
- return null;
227
- } catch (e) {
228
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to rate template")), null;
229
- } finally {
230
- w(!1);
231
- }
232
- }, [D]),
233
- publishTemplate: m(async (e) => {
234
- try {
235
- w(!0), E(null);
236
- let t = await D.mutate({
237
- mutation: c,
238
- variables: { id: e }
239
- });
240
- if (t.data?.publishTemplate) {
241
- let n = _(t.data.publishTemplate);
242
- return b((t) => t.map((t) => t.id === e ? {
243
- ...t,
244
- status: "ACTIVE"
245
- } : t)), n;
246
- }
247
- return null;
248
- } catch (e) {
249
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to publish template")), null;
250
- } finally {
251
- w(!1);
252
- }
253
- }, [D]),
254
- deprecateTemplate: m(async (e) => {
255
- try {
256
- w(!0), E(null);
257
- let t = await D.mutate({
258
- mutation: r,
259
- variables: { id: e }
260
- });
261
- if (t.data?.deprecateTemplate) {
262
- let n = _(t.data.deprecateTemplate);
263
- return b((t) => t.map((t) => t.id === e ? {
264
- ...t,
265
- status: "DEPRECATED"
266
- } : t)), n;
267
- }
268
- return null;
269
- } catch (e) {
270
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to deprecate template")), null;
271
- } finally {
272
- w(!1);
273
- }
274
- }, [D]),
275
- archiveTemplate: m(async (t) => {
276
- try {
277
- w(!0), E(null);
278
- let n = await D.mutate({
279
- mutation: e,
280
- variables: { id: t }
281
- });
282
- if (n.data?.archiveTemplate) {
283
- let e = _(n.data.archiveTemplate);
284
- return b((e) => e.map((e) => e.id === t ? {
285
- ...e,
286
- status: "ARCHIVED"
287
- } : e)), e;
288
- }
289
- return null;
290
- } catch (e) {
291
- return E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to archive template")), null;
292
- } finally {
293
- w(!1);
294
- }
295
- }, [D])
296
- };
297
- }
298
- //#endregion
299
- export { y as default };
300
-
301
- //# sourceMappingURL=useDashboardTemplates.js.map
1
+ import "../../generated/wspace-operations.js";
2
+ import "../utils/quota.js";
3
+ import "react";
4
+ import "@apollo/client/react";
@@ -0,0 +1,137 @@
1
+ import { BrowseDashboardTemplatesDocument as e, GetDashboardTemplateDetailDocument as t } from "../../generated/global-operations.js";
2
+ import { IMPORT_DASHBOARD_TEMPLATE as n } from "../graphql/storeTemplates.js";
3
+ import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
4
+ import { useApolloClient as s } from "@apollo/client/react";
5
+ import { useGatewayClient as c } from "@burdenoff/fe-libs/shared/graphql";
6
+ //#region src/bigconsole/hooks/useStoreDashboardTemplates.ts
7
+ function l(e) {
8
+ let t = e.pricingModel ?? "FREE";
9
+ return {
10
+ id: e.id,
11
+ name: e.name,
12
+ slug: e.slug,
13
+ description: e.description ?? null,
14
+ icon: e.icon ?? null,
15
+ category: e.category ?? null,
16
+ tags: e.tags ?? [],
17
+ featured: e.featured ?? !1,
18
+ downloads: e.downloads ?? 0,
19
+ rating: e.rating ?? null,
20
+ pricingModel: t,
21
+ price: e.price ?? 0,
22
+ requiresPurchase: t !== "FREE" && (e.price ?? 0) > 0
23
+ };
24
+ }
25
+ function u(u = {}) {
26
+ let { search: d, category: f, autoLoad: p = !0 } = u, m = c("global"), h = s(), [g, _] = o([]), [v, y] = o(0), [b, x] = o(!1), [S, C] = o(null), w = r(async (t) => {
27
+ if (m) {
28
+ x(!0), C(null);
29
+ try {
30
+ let n = await m.query({
31
+ query: e,
32
+ variables: { input: {
33
+ filter: {
34
+ type: "DASHBOARD",
35
+ status: "PUBLISHED",
36
+ compatibleWith: "bigconsole",
37
+ ...t ?? d ? { search: t ?? d } : {},
38
+ ...f && f !== "ALL" ? { category: f } : {}
39
+ },
40
+ sortBy: "RELEVANCE",
41
+ pagination: {
42
+ limit: 50,
43
+ offset: 0
44
+ }
45
+ } },
46
+ fetchPolicy: "network-only"
47
+ });
48
+ _((n.data?.browseStore?.products ?? []).map(l)), y(n.data?.browseStore?.totalCount ?? 0);
49
+ } catch (e) {
50
+ C(e instanceof Error ? e.message : "Failed to load templates from the store"), _([]), y(0);
51
+ } finally {
52
+ x(!1);
53
+ }
54
+ }
55
+ }, [
56
+ m,
57
+ d,
58
+ f
59
+ ]);
60
+ i(() => {
61
+ p && w();
62
+ }, [p, w]);
63
+ let T = r(async (e) => {
64
+ if (!m) return null;
65
+ try {
66
+ let n = (await m.query({
67
+ query: t,
68
+ variables: { id: e },
69
+ fetchPolicy: "network-only"
70
+ })).data?.product?.content;
71
+ if (!n || typeof n != "object") return null;
72
+ let r = n;
73
+ return r.definition ? {
74
+ definition: r.definition,
75
+ requiredDataSinks: r.requiredDataSinks ?? [],
76
+ requiredWidgetTypes: r.requiredWidgetTypes ?? [],
77
+ requiredInputs: r.requiredInputs ?? [],
78
+ defaultDashboardName: r.defaultDashboardName,
79
+ defaultCategory: r.defaultCategory ?? null,
80
+ defaultTags: r.defaultTags ?? [],
81
+ difficultyLevel: r.difficultyLevel ?? "medium"
82
+ } : null;
83
+ } catch {
84
+ return null;
85
+ }
86
+ }, [m]), E = r(async (e) => {
87
+ let t = (await h.mutate({
88
+ mutation: n,
89
+ variables: { input: {
90
+ content: e.content,
91
+ sourceTemplateId: e.templateId,
92
+ sourceTemplateName: e.templateName,
93
+ ...e.name ? { name: e.name } : {},
94
+ ...e.visibility ? { visibility: e.visibility } : {},
95
+ ...e.dataSinkBindings?.length ? { dataSinkBindings: e.dataSinkBindings } : {},
96
+ ...e.inputValues && Object.keys(e.inputValues).length ? { inputValues: e.inputValues } : {}
97
+ } }
98
+ })).data?.importDashboardTemplate;
99
+ return t ? {
100
+ success: t.success,
101
+ dashboardId: t.dashboard?.id,
102
+ errorMessage: t.errorMessage,
103
+ unresolvedSlots: t.unresolvedSlots ?? [],
104
+ resolvedSlots: t.resolvedSlots ?? [],
105
+ widgetsNeedingData: t.widgetsNeedingData ?? 0,
106
+ warnings: t.warnings ?? []
107
+ } : {
108
+ success: !1,
109
+ errorMessage: "No response from the server",
110
+ unresolvedSlots: [],
111
+ resolvedSlots: [],
112
+ widgetsNeedingData: 0,
113
+ warnings: []
114
+ };
115
+ }, [h]);
116
+ return a(() => ({
117
+ templates: g,
118
+ loading: b,
119
+ error: S,
120
+ totalCount: v,
121
+ refetch: w,
122
+ fetchTemplateContent: T,
123
+ installTemplate: E
124
+ }), [
125
+ g,
126
+ b,
127
+ S,
128
+ v,
129
+ w,
130
+ T,
131
+ E
132
+ ]);
133
+ }
134
+ //#endregion
135
+ export { u as default };
136
+
137
+ //# sourceMappingURL=useStoreDashboardTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStoreDashboardTemplates.js","names":[],"sources":["../../../src/bigconsole/hooks/useStoreDashboardTemplates.ts"],"sourcesContent":["/**\n * Store-distributed dashboard templates.\n *\n * Dashboard templates live in the global store as `StoreProduct` rows of type\n * `DASHBOARD` whose `content` column holds a `DashboardTemplateContent`\n * document. This mirrors how FluidGrids sources its workflow templates\n * (`browseStore(type: WORKFLOW)` → `content.definitionJson` →\n * `importWorkflowTemplate`).\n *\n * Two gateways are involved: the catalog is read from the **global** gateway,\n * and the install mutation runs against the **workspace** gateway, which is\n * where the dashboard is created.\n *\n * @module bigconsole/hooks/useStoreDashboardTemplates\n */\nimport { useApolloClient } from '@apollo/client/react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport {\n BROWSE_DASHBOARD_TEMPLATES,\n GET_DASHBOARD_TEMPLATE_DETAIL,\n IMPORT_DASHBOARD_TEMPLATE,\n} from '../graphql/storeTemplates';\n\n/** A column a widget expects from the sink bound to its slot. */\nexport interface TemplateExpectedField {\n name: string;\n role?: string;\n}\n\n/** A data-binding slot the template needs filled. */\nexport interface TemplateRequiredDataSink {\n slot: string;\n label: string;\n description?: string | null;\n expectedFields: TemplateExpectedField[];\n widgetTitles: string[];\n}\n\nexport interface TemplateRequiredWidgetType {\n widgetType: string;\n widgetTypeKey?: string | null;\n publishType: 'BUILTIN' | 'STORE' | 'CUSTOM';\n displayName?: string;\n requiresPurchase?: boolean;\n}\n\nexport interface TemplateRequiredInput {\n name: string;\n type: 'string' | 'number' | 'boolean' | 'select' | 'secret';\n label: string;\n placeholder?: string;\n required: boolean;\n defaultValue?: string | number | boolean | null;\n options?: { label: string; value: string }[];\n helpText?: string;\n}\n\nexport interface DashboardTemplateContent {\n definition: unknown;\n requiredDataSinks: TemplateRequiredDataSink[];\n requiredWidgetTypes: TemplateRequiredWidgetType[];\n requiredInputs: TemplateRequiredInput[];\n defaultDashboardName?: string;\n defaultCategory?: string | null;\n defaultTags?: string[];\n difficultyLevel?: 'easy' | 'medium' | 'hard';\n}\n\n/** A store product presented as a template card. */\nexport interface StoreDashboardTemplate {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n category?: string | null;\n tags: string[];\n featured: boolean;\n downloads: number;\n rating?: number | null;\n pricingModel: string;\n price: number;\n /** True for anything the workspace has to buy before it can be installed. */\n requiresPurchase: boolean;\n}\n\ninterface RawStoreProduct {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n icon?: string | null;\n category?: string | null;\n tags?: string[] | null;\n featured?: boolean | null;\n downloads?: number | null;\n rating?: number | null;\n pricingModel?: string | null;\n price?: number | null;\n}\n\nexport interface InstallTemplateArgs {\n templateId: string;\n templateName: string;\n content: DashboardTemplateContent;\n name?: string;\n visibility?: string;\n dataSinkBindings?: { slot: string; dataSinkId: string }[];\n inputValues?: Record<string, unknown>;\n}\n\nexport interface InstallTemplateResult {\n success: boolean;\n dashboardId?: string;\n errorMessage?: string;\n unresolvedSlots: string[];\n resolvedSlots: string[];\n widgetsNeedingData: number;\n warnings: string[];\n}\n\nfunction normalizeProduct(raw: RawStoreProduct): StoreDashboardTemplate {\n const pricingModel = raw.pricingModel ?? 'FREE';\n return {\n id: raw.id,\n name: raw.name,\n slug: raw.slug,\n description: raw.description ?? null,\n icon: raw.icon ?? null,\n category: raw.category ?? null,\n tags: raw.tags ?? [],\n featured: raw.featured ?? false,\n downloads: raw.downloads ?? 0,\n rating: raw.rating ?? null,\n pricingModel,\n price: raw.price ?? 0,\n requiresPurchase: pricingModel !== 'FREE' && (raw.price ?? 0) > 0,\n };\n}\n\nexport interface UseStoreDashboardTemplatesResult {\n templates: StoreDashboardTemplate[];\n loading: boolean;\n error: string | null;\n totalCount: number;\n refetch: (search?: string) => Promise<void>;\n /** Fetch the full template document. Kept lazy: content is large. */\n fetchTemplateContent: (templateId: string) => Promise<DashboardTemplateContent | null>;\n installTemplate: (args: InstallTemplateArgs) => Promise<InstallTemplateResult>;\n}\n\nexport function useStoreDashboardTemplates(\n options: { search?: string; category?: string; autoLoad?: boolean } = {}\n): UseStoreDashboardTemplatesResult {\n const { search, category, autoLoad = true } = options;\n\n const globalClient = useGatewayClient('global');\n const workspaceClient = useApolloClient();\n\n const [templates, setTemplates] = useState<StoreDashboardTemplate[]>([]);\n const [totalCount, setTotalCount] = useState(0);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const refetch = useCallback(\n async (overrideSearch?: string): Promise<void> => {\n if (!globalClient) return;\n setLoading(true);\n setError(null);\n try {\n const result = await globalClient.query<{\n browseStore?: { products?: RawStoreProduct[]; totalCount?: number };\n }>({\n query: BROWSE_DASHBOARD_TEMPLATES,\n variables: {\n input: {\n filter: {\n type: 'DASHBOARD',\n status: 'PUBLISHED',\n // Without this a template published from another product's\n // devportal listing would show up in BigConsole's gallery.\n compatibleWith: 'bigconsole',\n ...((overrideSearch ?? search) ? { search: overrideSearch ?? search } : {}),\n ...(category && category !== 'ALL' ? { category } : {}),\n },\n sortBy: 'RELEVANCE',\n pagination: { limit: 50, offset: 0 },\n },\n },\n fetchPolicy: 'network-only',\n });\n\n setTemplates((result.data?.browseStore?.products ?? []).map(normalizeProduct));\n setTotalCount(result.data?.browseStore?.totalCount ?? 0);\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to load templates from the store');\n setTemplates([]);\n setTotalCount(0);\n } finally {\n setLoading(false);\n }\n },\n [globalClient, search, category]\n );\n\n useEffect(() => {\n if (autoLoad) void refetch();\n }, [autoLoad, refetch]);\n\n const fetchTemplateContent = useCallback(\n async (templateId: string): Promise<DashboardTemplateContent | null> => {\n if (!globalClient) return null;\n try {\n const result = await globalClient.query<{ product?: { content?: unknown } }>({\n query: GET_DASHBOARD_TEMPLATE_DETAIL,\n variables: { id: templateId },\n fetchPolicy: 'network-only',\n });\n const content = result.data?.product?.content;\n if (!content || typeof content !== 'object') return null;\n const doc = content as Partial<DashboardTemplateContent>;\n if (!doc.definition) return null;\n return {\n definition: doc.definition,\n requiredDataSinks: doc.requiredDataSinks ?? [],\n requiredWidgetTypes: doc.requiredWidgetTypes ?? [],\n requiredInputs: doc.requiredInputs ?? [],\n defaultDashboardName: doc.defaultDashboardName,\n defaultCategory: doc.defaultCategory ?? null,\n defaultTags: doc.defaultTags ?? [],\n difficultyLevel: doc.difficultyLevel ?? 'medium',\n };\n } catch {\n return null;\n }\n },\n [globalClient]\n );\n\n const installTemplate = useCallback(\n async (args: InstallTemplateArgs): Promise<InstallTemplateResult> => {\n const result = await workspaceClient.mutate<{\n importDashboardTemplate?: InstallTemplateResult & { dashboard?: { id: string } | null };\n }>({\n mutation: IMPORT_DASHBOARD_TEMPLATE,\n variables: {\n input: {\n content: args.content,\n sourceTemplateId: args.templateId,\n sourceTemplateName: args.templateName,\n ...(args.name ? { name: args.name } : {}),\n ...(args.visibility ? { visibility: args.visibility } : {}),\n ...(args.dataSinkBindings?.length ? { dataSinkBindings: args.dataSinkBindings } : {}),\n ...(args.inputValues && Object.keys(args.inputValues).length ? { inputValues: args.inputValues } : {}),\n },\n },\n });\n\n const payload = result.data?.importDashboardTemplate;\n if (!payload) {\n return {\n success: false,\n errorMessage: 'No response from the server',\n unresolvedSlots: [],\n resolvedSlots: [],\n widgetsNeedingData: 0,\n warnings: [],\n };\n }\n\n return {\n success: payload.success,\n dashboardId: payload.dashboard?.id,\n errorMessage: payload.errorMessage,\n unresolvedSlots: payload.unresolvedSlots ?? [],\n resolvedSlots: payload.resolvedSlots ?? [],\n widgetsNeedingData: payload.widgetsNeedingData ?? 0,\n warnings: payload.warnings ?? [],\n };\n },\n [workspaceClient]\n );\n\n return useMemo(\n () => ({\n templates,\n loading,\n error,\n totalCount,\n refetch,\n fetchTemplateContent,\n installTemplate,\n }),\n [templates, loading, error, totalCount, refetch, fetchTemplateContent, installTemplate]\n );\n}\n\nexport default useStoreDashboardTemplates;\n"],"mappings":"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"}
@@ -0,0 +1,49 @@
1
+ import { gql as e } from "@apollo/client";
2
+ import "@apollo/client/react";
3
+ //#region src/generated/global-operations.ts
4
+ var t = e`
5
+ query BrowseDashboardTemplates($input: BrowseStoreInput!) {
6
+ browseStore(input: $input) {
7
+ totalCount
8
+ hasMore
9
+ products {
10
+ id
11
+ name
12
+ slug
13
+ description
14
+ icon
15
+ category
16
+ tags
17
+ featured
18
+ downloads
19
+ rating
20
+ pricingModel
21
+ price
22
+ }
23
+ }
24
+ }
25
+ `, n = e`
26
+ query GetDashboardTemplateDetail($id: ID!) {
27
+ product(id: $id) {
28
+ id
29
+ name
30
+ slug
31
+ description
32
+ longDescription
33
+ icon
34
+ screenshots
35
+ category
36
+ tags
37
+ pricingModel
38
+ price
39
+ downloads
40
+ rating
41
+ reviewCount
42
+ content
43
+ }
44
+ }
45
+ `;
46
+ //#endregion
47
+ export { t as BrowseDashboardTemplatesDocument, n as GetDashboardTemplateDetailDocument };
48
+
49
+ //# sourceMappingURL=global-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-operations.js","names":[],"sources":["../../src/generated/global-operations.ts"],"sourcesContent":["// @ts-nocheck\nimport * as Types from './global-types';\n\nimport { gql } from '@apollo/client';\nimport * as Apollo from '@apollo/client';\nimport * as ApolloReactHooks from '@apollo/client/react';\nconst defaultOptions = {} as const;\nexport type BrowseDashboardTemplatesQueryVariables = Types.Exact<{\n input: Types.BrowseStoreInput;\n}>;\n\n\nexport type BrowseDashboardTemplatesQuery = { __typename?: 'Query', browseStore: { __typename?: 'BrowseStoreResult', totalCount: number, hasMore: boolean, products: Array<{ __typename?: 'StoreProduct', id: string, name: string, slug: string, description?: string | null, icon?: string | null, category?: string | null, tags: Array<string>, featured: boolean, downloads: number, rating?: number | null, pricingModel: Types.PricingModel, price: number }> } };\n\nexport type GetDashboardTemplateDetailQueryVariables = Types.Exact<{\n id: Types.Scalars['ID']['input'];\n}>;\n\n\nexport type GetDashboardTemplateDetailQuery = { __typename?: 'Query', product?: { __typename?: 'StoreProduct', id: string, name: string, slug: string, description?: string | null, longDescription?: string | null, icon?: string | null, screenshots: Array<string>, category?: string | null, tags: Array<string>, pricingModel: Types.PricingModel, price: number, downloads: number, rating?: number | null, reviewCount: number, content?: Record<string, unknown> | null } | null };\n\n\nexport const BrowseDashboardTemplatesDocument = gql`\n query BrowseDashboardTemplates($input: BrowseStoreInput!) {\n browseStore(input: $input) {\n totalCount\n hasMore\n products {\n id\n name\n slug\n description\n icon\n category\n tags\n featured\n downloads\n rating\n pricingModel\n price\n }\n }\n}\n `;\n\n/**\n * __useBrowseDashboardTemplatesQuery__\n *\n * To run a query within a React component, call `useBrowseDashboardTemplatesQuery` and pass it any options that fit your needs.\n * When your component renders, `useBrowseDashboardTemplatesQuery` returns an object from Apollo Client that contains loading, error, and data properties\n * you can use to render your UI.\n *\n * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;\n *\n * @example\n * const { data, loading, error } = useBrowseDashboardTemplatesQuery({\n * variables: {\n * input: // value for 'input'\n * },\n * });\n */\nexport function useBrowseDashboardTemplatesQuery(baseOptions: ApolloReactHooks.QueryHookOptions<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables> & ({ variables: Types.BrowseDashboardTemplatesQueryVariables; skip?: boolean; } | { skip: boolean; }) ) {\n const options = {...defaultOptions, ...baseOptions}\n return ApolloReactHooks.useQuery<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>(BrowseDashboardTemplatesDocument, options);\n }\nexport function useBrowseDashboardTemplatesLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>) {\n const options = {...defaultOptions, ...baseOptions}\n return ApolloReactHooks.useLazyQuery<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>(BrowseDashboardTemplatesDocument, options);\n }\n// @ts-ignore\nexport function useBrowseDashboardTemplatesSuspenseQuery(baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>;\nexport function useBrowseDashboardTemplatesSuspenseQuery(baseOptions?: ApolloReactHooks.SkipToken | ApolloReactHooks.SuspenseQueryHookOptions<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.BrowseDashboardTemplatesQuery | undefined, Types.BrowseDashboardTemplatesQueryVariables>;\nexport function useBrowseDashboardTemplatesSuspenseQuery(baseOptions?: ApolloReactHooks.SkipToken | ApolloReactHooks.SuspenseQueryHookOptions<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>) {\n const options = baseOptions === ApolloReactHooks.skipToken ? baseOptions : {...defaultOptions, ...baseOptions}\n return ApolloReactHooks.useSuspenseQuery<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>(BrowseDashboardTemplatesDocument, options);\n }\nexport type BrowseDashboardTemplatesQueryHookResult = ReturnType<typeof useBrowseDashboardTemplatesQuery>;\nexport type BrowseDashboardTemplatesLazyQueryHookResult = ReturnType<typeof useBrowseDashboardTemplatesLazyQuery>;\nexport type BrowseDashboardTemplatesSuspenseQueryHookResult = ReturnType<typeof useBrowseDashboardTemplatesSuspenseQuery>;\nexport type BrowseDashboardTemplatesQueryResult = Apollo.QueryResult<Types.BrowseDashboardTemplatesQuery, Types.BrowseDashboardTemplatesQueryVariables>;\nexport const GetDashboardTemplateDetailDocument = gql`\n query GetDashboardTemplateDetail($id: ID!) {\n product(id: $id) {\n id\n name\n slug\n description\n longDescription\n icon\n screenshots\n category\n tags\n pricingModel\n price\n downloads\n rating\n reviewCount\n content\n }\n}\n `;\n\n/**\n * __useGetDashboardTemplateDetailQuery__\n *\n * To run a query within a React component, call `useGetDashboardTemplateDetailQuery` and pass it any options that fit your needs.\n * When your component renders, `useGetDashboardTemplateDetailQuery` returns an object from Apollo Client that contains loading, error, and data properties\n * you can use to render your UI.\n *\n * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;\n *\n * @example\n * const { data, loading, error } = useGetDashboardTemplateDetailQuery({\n * variables: {\n * id: // value for 'id'\n * },\n * });\n */\nexport function useGetDashboardTemplateDetailQuery(baseOptions: ApolloReactHooks.QueryHookOptions<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables> & ({ variables: Types.GetDashboardTemplateDetailQueryVariables; skip?: boolean; } | { skip: boolean; }) ) {\n const options = {...defaultOptions, ...baseOptions}\n return ApolloReactHooks.useQuery<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>(GetDashboardTemplateDetailDocument, options);\n }\nexport function useGetDashboardTemplateDetailLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>) {\n const options = {...defaultOptions, ...baseOptions}\n return ApolloReactHooks.useLazyQuery<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>(GetDashboardTemplateDetailDocument, options);\n }\n// @ts-ignore\nexport function useGetDashboardTemplateDetailSuspenseQuery(baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>;\nexport function useGetDashboardTemplateDetailSuspenseQuery(baseOptions?: ApolloReactHooks.SkipToken | ApolloReactHooks.SuspenseQueryHookOptions<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>): ApolloReactHooks.UseSuspenseQueryResult<Types.GetDashboardTemplateDetailQuery | undefined, Types.GetDashboardTemplateDetailQueryVariables>;\nexport function useGetDashboardTemplateDetailSuspenseQuery(baseOptions?: ApolloReactHooks.SkipToken | ApolloReactHooks.SuspenseQueryHookOptions<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>) {\n const options = baseOptions === ApolloReactHooks.skipToken ? baseOptions : {...defaultOptions, ...baseOptions}\n return ApolloReactHooks.useSuspenseQuery<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>(GetDashboardTemplateDetailDocument, options);\n }\nexport type GetDashboardTemplateDetailQueryHookResult = ReturnType<typeof useGetDashboardTemplateDetailQuery>;\nexport type GetDashboardTemplateDetailLazyQueryHookResult = ReturnType<typeof useGetDashboardTemplateDetailLazyQuery>;\nexport type GetDashboardTemplateDetailSuspenseQueryHookResult = ReturnType<typeof useGetDashboardTemplateDetailSuspenseQuery>;\nexport type GetDashboardTemplateDetailQueryResult = Apollo.QueryResult<Types.GetDashboardTemplateDetailQuery, Types.GetDashboardTemplateDetailQueryVariables>;"],"mappings":";;;AAsBA,IAAa,IAAmC,CAAG;;;;;;;;;;;;;;;;;;;;;OA0DtC,IAAqC,CAAG"}