@elevasis/ui 2.30.0 → 2.32.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.
Files changed (130) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/app/index.css +38 -0
  3. package/dist/app/index.d.ts +190 -9
  4. package/dist/app/index.js +7 -6
  5. package/dist/charts/index.js +4 -5
  6. package/dist/{chunk-HXZQWMKE.js → chunk-2RJMVWFJ.js} +1 -6
  7. package/dist/{chunk-4VQ2PXMI.js → chunk-3FV6HBXS.js} +4 -4
  8. package/dist/{chunk-CW3UNAF2.js → chunk-4DYOXEH6.js} +410 -5
  9. package/dist/{chunk-JKTPRYGV.js → chunk-4MFNGNHF.js} +123 -192
  10. package/dist/{chunk-HYLERWRO.js → chunk-4QK76KIF.js} +7 -7
  11. package/dist/chunk-5FJJ72HU.js +13 -0
  12. package/dist/chunk-5J4PDX26.js +112 -0
  13. package/dist/{chunk-4SY6BTVZ.js → chunk-6DWD423K.js} +12 -9
  14. package/dist/{chunk-3GV5NHSS.js → chunk-7KZINJLP.js} +78 -232
  15. package/dist/{chunk-6WXDE5LZ.js → chunk-EPTHX4VZ.js} +1 -1
  16. package/dist/{chunk-6EFVZV6X.js → chunk-GCOQ3TBG.js} +243 -254
  17. package/dist/{chunk-LRZFLK2F.js → chunk-IQHU7O5Y.js} +4 -4
  18. package/dist/{chunk-X2SUMO3P.js → chunk-IZWTVFJ2.js} +16 -3
  19. package/dist/{chunk-IKQ42WHU.js → chunk-JFL3GRD4.js} +1 -1
  20. package/dist/{chunk-4FZYEEPK.js → chunk-LLRXA7D7.js} +5 -6
  21. package/dist/chunk-MOY4VOHF.js +347 -0
  22. package/dist/{chunk-XQQEKWTL.js → chunk-N55DVMAG.js} +6 -2
  23. package/dist/{chunk-7E3FUTND.js → chunk-ND5TDV2J.js} +1 -1
  24. package/dist/{chunk-WF227UBV.js → chunk-QQHOKTJA.js} +4 -4
  25. package/dist/{chunk-A7B7HLDF.js → chunk-QTI3KC7D.js} +5884 -515
  26. package/dist/chunk-QXCDKE2O.js +486 -0
  27. package/dist/chunk-R2XR4FCV.js +48 -0
  28. package/dist/chunk-R66W5UDG.js +26 -0
  29. package/dist/{chunk-T5Z7G2J2.js → chunk-RQA2EVN3.js} +6 -16
  30. package/dist/{chunk-SKXXT3E2.js → chunk-RQTWIXJ5.js} +4 -4
  31. package/dist/chunk-T35FWDAB.js +4342 -0
  32. package/dist/{chunk-DWK2QIAK.js → chunk-TYRUKGGD.js} +1 -1
  33. package/dist/{chunk-CN2HC4D4.js → chunk-UFTM5SZZ.js} +2 -2
  34. package/dist/{chunk-JCGD4GM6.js → chunk-UROTM5OR.js} +14 -1
  35. package/dist/{chunk-6YT4IKJ7.js → chunk-VNAZTCHA.js} +15 -0
  36. package/dist/{chunk-KVJ3LFH2.js → chunk-VNFR57DF.js} +4 -24
  37. package/dist/{chunk-SBCIB5TZ.js → chunk-VRNMNB3O.js} +6 -7
  38. package/dist/chunk-WQPX44YM.js +1626 -0
  39. package/dist/{chunk-T2PAD63Y.js → chunk-XZGSCABI.js} +1 -1
  40. package/dist/chunk-YLQEVSOR.js +299 -0
  41. package/dist/{chunk-P5WYW2GI.js → chunk-ZQOKIGZP.js} +152 -306
  42. package/dist/components/index.css +38 -0
  43. package/dist/components/index.d.ts +334 -38
  44. package/dist/components/index.js +42 -42
  45. package/dist/components/navigation/index.css +38 -0
  46. package/dist/components/navigation/index.js +3 -2
  47. package/dist/execution/index.d.ts +9 -3
  48. package/dist/features/auth/index.css +38 -0
  49. package/dist/features/auth/index.d.ts +212 -14
  50. package/dist/features/auth/index.js +41 -9
  51. package/dist/features/clients/index.css +649 -0
  52. package/dist/features/clients/index.d.ts +86 -0
  53. package/dist/features/clients/index.js +720 -0
  54. package/dist/features/crm/index.css +38 -0
  55. package/dist/features/crm/index.d.ts +228 -20
  56. package/dist/features/crm/index.js +20 -17
  57. package/dist/features/dashboard/index.css +38 -0
  58. package/dist/features/dashboard/index.d.ts +78 -3
  59. package/dist/features/dashboard/index.js +16 -16
  60. package/dist/features/delivery/index.css +38 -0
  61. package/dist/features/delivery/index.d.ts +201 -18
  62. package/dist/features/delivery/index.js +20 -18
  63. package/dist/features/knowledge/index.css +38 -0
  64. package/dist/features/knowledge/index.d.ts +20 -18
  65. package/dist/features/knowledge/index.js +116 -578
  66. package/dist/features/lead-gen/index.css +38 -0
  67. package/dist/features/lead-gen/index.d.ts +59 -51
  68. package/dist/features/lead-gen/index.js +20 -18
  69. package/dist/features/monitoring/index.css +38 -0
  70. package/dist/features/monitoring/index.d.ts +20 -18
  71. package/dist/features/monitoring/index.js +19 -18
  72. package/dist/features/monitoring/requests/index.css +38 -0
  73. package/dist/features/monitoring/requests/index.d.ts +21 -19
  74. package/dist/features/monitoring/requests/index.js +17 -15
  75. package/dist/features/operations/index.css +38 -0
  76. package/dist/features/operations/index.d.ts +945 -45
  77. package/dist/features/operations/index.js +24 -26
  78. package/dist/features/seo/index.d.ts +20 -18
  79. package/dist/features/seo/index.js +1 -1
  80. package/dist/features/settings/index.css +38 -0
  81. package/dist/features/settings/index.d.ts +201 -18
  82. package/dist/features/settings/index.js +18 -16
  83. package/dist/hooks/delivery/index.css +38 -0
  84. package/dist/hooks/delivery/index.d.ts +200 -0
  85. package/dist/hooks/delivery/index.js +2 -2
  86. package/dist/hooks/index.css +38 -0
  87. package/dist/hooks/index.d.ts +825 -47
  88. package/dist/hooks/index.js +14 -13
  89. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +194 -3
  90. package/dist/hooks/published.css +38 -0
  91. package/dist/hooks/published.d.ts +825 -47
  92. package/dist/hooks/published.js +14 -13
  93. package/dist/index.css +38 -0
  94. package/dist/index.d.ts +1506 -1212
  95. package/dist/index.js +15 -14
  96. package/dist/initialization/index.d.ts +181 -0
  97. package/dist/knowledge/index.d.ts +813 -1068
  98. package/dist/knowledge/index.js +7370 -2869
  99. package/dist/{chunk-CLUP5H3C.js → knowledge-search-index-5KYPO746.js} +441 -963
  100. package/dist/layout/index.d.ts +6 -0
  101. package/dist/layout/index.js +4 -5
  102. package/dist/organization/index.css +38 -0
  103. package/dist/profile/index.d.ts +181 -0
  104. package/dist/provider/index.css +38 -0
  105. package/dist/provider/index.d.ts +909 -1156
  106. package/dist/provider/index.js +11 -10
  107. package/dist/provider/published.css +38 -0
  108. package/dist/provider/published.d.ts +906 -1153
  109. package/dist/provider/published.js +7 -6
  110. package/dist/supabase/index.d.ts +349 -0
  111. package/dist/test-utils/index.d.ts +16 -9
  112. package/dist/test-utils/index.js +39 -32
  113. package/dist/test-utils/setup.js +1 -1
  114. package/dist/theme/index.js +3 -3
  115. package/dist/theme/presets/index.js +1 -1
  116. package/dist/types/index.d.ts +378 -5
  117. package/dist/utils/index.d.ts +78 -3
  118. package/dist/utils/index.js +1 -1
  119. package/dist/vite/index.js +2 -2
  120. package/dist/vite-plugin-knowledge/index.js +1 -1
  121. package/package.json +47 -37
  122. package/src/provider/README.md +5 -5
  123. package/dist/chunk-2DIYILF7.js +0 -413
  124. package/dist/chunk-3MDNBHVB.js +0 -3868
  125. package/dist/chunk-6IXOKUBC.js +0 -347
  126. package/dist/chunk-AKOD52HS.js +0 -739
  127. package/dist/chunk-ECNNI3NT.js +0 -6
  128. package/dist/chunk-JDNEWB5F.js +0 -10
  129. package/dist/chunk-NITGGYH2.js +0 -476
  130. package/dist/chunk-OAVTMITG.js +0 -13
@@ -1,347 +0,0 @@
1
- import { useInitialization } from './chunk-533DUEQY.js';
2
- import { useOrganization } from './chunk-DD3CCMCZ.js';
3
- import { createContext, useMemo, useCallback, useContext } from 'react';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- function createFeatureAccessHook({
7
- useInitialization: useInitialization2,
8
- useOrganization: useOrganization2
9
- }) {
10
- return function useFeatureAccess2() {
11
- const { profile, organizationReady } = useInitialization2();
12
- const { currentMembership } = useOrganization2();
13
- const { orgConfig, membershipConfig } = useMemo(() => {
14
- const organizationConfig = currentMembership?.organization?.config;
15
- const memberConfig = currentMembership?.config;
16
- return { orgConfig: organizationConfig, membershipConfig: memberConfig };
17
- }, [currentMembership]);
18
- const userConfig = profile?.config;
19
- const checkFeature = useCallback(
20
- (featureKey) => {
21
- if (profile?.is_platform_admin) {
22
- return { allowed: true, restrictedBy: null };
23
- }
24
- const membershipValue = membershipConfig?.features?.[featureKey];
25
- if (membershipValue === false) return { allowed: false, restrictedBy: "membership" };
26
- return { allowed: true, restrictedBy: null };
27
- },
28
- [profile?.is_platform_admin, membershipConfig]
29
- );
30
- const hasFeature = useCallback((featureKey) => checkFeature(featureKey).allowed, [checkFeature]);
31
- return {
32
- orgConfig,
33
- membershipConfig,
34
- userConfig,
35
- hasFeature,
36
- checkFeature,
37
- isReady: organizationReady
38
- };
39
- };
40
- }
41
-
42
- // ../core/src/organization-model/helpers.ts
43
- function defaultPathFor(id) {
44
- return `/${id.replaceAll(".", "/")}`;
45
- }
46
- function parentIdOf(id) {
47
- const index = id.lastIndexOf(".");
48
- return index === -1 ? void 0 : id.slice(0, index);
49
- }
50
- function findById(features, id) {
51
- return features.find((feature) => feature.id === id);
52
- }
53
- function findByPath(features, path) {
54
- return features.find((feature) => (feature.path ?? defaultPathFor(feature.id)) === path);
55
- }
56
- function childrenOf(features, id) {
57
- const prefix = `${id}.`;
58
- return features.filter((feature) => feature.id.startsWith(prefix) && !feature.id.slice(prefix.length).includes("."));
59
- }
60
- function topLevel(features) {
61
- return features.filter((feature) => !feature.id.includes("."));
62
- }
63
- function ancestorsOf(features, id) {
64
- const segments = id.split(".");
65
- const ids = segments.map((_, index) => segments.slice(0, index + 1).join("."));
66
- return ids.map((ancestorId) => findById(features, ancestorId)).filter((feature) => Boolean(feature));
67
- }
68
- function parentOf(features, id) {
69
- const parentId = parentIdOf(id);
70
- return parentId ? findById(features, parentId) : void 0;
71
- }
72
- function inheritedValue(features, id, getValue) {
73
- return ancestorsOf(features, id).slice().reverse().map(getValue).find((value) => value !== void 0);
74
- }
75
- function uiPositionFor(features, id) {
76
- return inheritedValue(features, id, (feature) => feature.uiPosition);
77
- }
78
- function requiresAdminFor(features, id) {
79
- return inheritedValue(features, id, (feature) => feature.requiresAdmin) ?? false;
80
- }
81
- function devOnlyFor(features, id) {
82
- return inheritedValue(features, id, (feature) => feature.devOnly) ?? false;
83
- }
84
-
85
- // src/provider/resolvers/RouteResolver.ts
86
- function normalizeRoutePath(path) {
87
- const trimmedPath = path.trim();
88
- if (!trimmedPath || trimmedPath === "/") {
89
- return "/";
90
- }
91
- return trimmedPath.replace(/\/+$/, "") || "/";
92
- }
93
- function isRouteMatch(currentPath, route) {
94
- const normalizedCurrentPath = normalizeRoutePath(currentPath);
95
- const normalizedRoute = normalizeRoutePath(route);
96
- return normalizedCurrentPath === normalizedRoute || normalizedCurrentPath.startsWith(`${normalizedRoute}/`);
97
- }
98
-
99
- // src/provider/resolvers/NavResolver.ts
100
- function uniqueIds(ids) {
101
- return ids ? [...new Set(ids)] : [];
102
- }
103
-
104
- // src/provider/validateManifests.ts
105
- function validateManifests(manifests, organizationModel) {
106
- if (!organizationModel) {
107
- return;
108
- }
109
- const validFeatureIds = new Set((organizationModel.features ?? []).map((f) => f.id));
110
- const errors = [];
111
- for (const manifest of manifests) {
112
- const key = manifest.key;
113
- if (!validFeatureIds.has(manifest.featureId)) {
114
- errors.push(
115
- `Manifest "${key}": featureId "${manifest.featureId}" is not a known feature id. Valid values: ${[...validFeatureIds].sort().join(", ")}`
116
- );
117
- }
118
- }
119
- if (errors.length > 0) {
120
- throw new Error(
121
- `Feature manifest validation failed with ${errors.length} error(s):
122
- ` + errors.map((e, i) => ` ${i + 1}. ${e}`).join("\n")
123
- );
124
- }
125
- }
126
- var ElevasisFeaturesContext = createContext(null);
127
- var useFeatureAccess = createFeatureAccessHook({
128
- useInitialization,
129
- useOrganization
130
- });
131
- function useElevasisFeatures() {
132
- const context = useContext(ElevasisFeaturesContext);
133
- if (!context) {
134
- throw new Error(
135
- "useElevasisFeatures must be used within an ElevasisFeaturesProvider. Wrap your app (or the relevant subtree) with <ElevasisFeaturesProvider>."
136
- );
137
- }
138
- return context;
139
- }
140
- function useOptionalElevasisFeatures() {
141
- return useContext(ElevasisFeaturesContext);
142
- }
143
- function defaultFeatures(organizationModel) {
144
- return organizationModel?.features ?? [];
145
- }
146
- function featurePath(feature) {
147
- return feature.path ?? defaultPathFor(feature.id);
148
- }
149
- function isOrganizationModelFeatureEnabled(organizationModel, featureId) {
150
- const feature = organizationModel?.features.find((f) => f.id === featureId);
151
- return feature?.enabled;
152
- }
153
- function resolveFeatureModules(features, isFeatureEnabled) {
154
- return features.map((feature) => {
155
- const featureId = feature.featureId;
156
- return {
157
- ...feature,
158
- access: {
159
- featureId,
160
- enabled: isFeatureEnabled(featureId)
161
- },
162
- semantics: {
163
- capabilityIds: uniqueIds(feature.capabilityIds ?? [])
164
- }
165
- };
166
- });
167
- }
168
- function buildShellFeatures(organizationModel, modules) {
169
- const iconByFeatureId = new Map(modules.map((module) => [module.featureId, module.icon]));
170
- return defaultFeatures(organizationModel).map((feature) => ({
171
- ...feature,
172
- iconComponent: iconByFeatureId.get(feature.id)
173
- }));
174
- }
175
- function createShellModel(features) {
176
- return {
177
- features,
178
- findByPath: (path) => findByPath(features, normalizeRoutePath(path)),
179
- findById: (id) => findById(features, id),
180
- childrenOf: (id) => childrenOf(features, id),
181
- ancestorsOf: (id) => ancestorsOf(features, id),
182
- parentOf: (id) => parentOf(features, id),
183
- topLevel: () => topLevel(features),
184
- uiPositionFor: (id) => uiPositionFor(features, id),
185
- requiresAdminFor: (id) => requiresAdminFor(features, id),
186
- devOnlyFor: (id) => devOnlyFor(features, id)
187
- };
188
- }
189
- function resolveOrganizationGraphFeature(features, shellModel) {
190
- for (const feature of features) {
191
- const graphBridge = feature.organizationGraph;
192
- if (!graphBridge) continue;
193
- const node = shellModel.findById(graphBridge.featureId);
194
- return {
195
- available: Boolean(node),
196
- featureId: graphBridge.featureId,
197
- featurePath: node ? featurePath(node) : void 0
198
- };
199
- }
200
- return {
201
- available: false
202
- };
203
- }
204
- function findMatchingNode(shellModel, currentPath) {
205
- const normalizedPath = normalizeRoutePath(currentPath);
206
- const exact = shellModel.findByPath(normalizedPath);
207
- if (exact) return exact;
208
- return [...shellModel.features].filter((feature) => {
209
- const path = normalizeRoutePath(featurePath(feature));
210
- return path !== "/" && isRouteMatch(normalizedPath, path);
211
- }).sort((a, b) => featurePath(b).length - featurePath(a).length)[0];
212
- }
213
- function ownsNode(module, node) {
214
- if (!node) return false;
215
- return node.id === module.featureId || node.id.startsWith(`${module.featureId}.`);
216
- }
217
- function resolveRoute(features, shellModel, currentPath, disabledSubsectionPaths) {
218
- const node = findMatchingNode(shellModel, currentPath);
219
- const normalizedPath = normalizeRoutePath(currentPath);
220
- if (disabledSubsectionPaths.some((disabledPath) => isRouteMatch(normalizedPath, disabledPath))) {
221
- return {
222
- status: "hidden",
223
- path: currentPath,
224
- node
225
- };
226
- }
227
- const feature = features.find((candidate) => ownsNode(candidate, node));
228
- if (!feature) {
229
- return {
230
- status: "unmatched",
231
- path: currentPath,
232
- node
233
- };
234
- }
235
- return {
236
- status: "matched",
237
- path: currentPath,
238
- feature,
239
- node
240
- };
241
- }
242
- function ElevasisFeaturesProvider({
243
- features,
244
- organizationModel,
245
- timeRange,
246
- operationsApiUrl,
247
- operationsSSEManager,
248
- deliveryApiUrl,
249
- deliverySSEManager,
250
- disabledSubsectionPaths = [],
251
- children
252
- }) {
253
- const resolvedOrganizationModel = useMemo(() => {
254
- if (!organizationModel) {
255
- return void 0;
256
- }
257
- return {
258
- ...organizationModel,
259
- knowledge: organizationModel.knowledge ?? { nodes: [] }
260
- };
261
- }, [organizationModel]);
262
- useMemo(() => validateManifests(features, resolvedOrganizationModel), [features, resolvedOrganizationModel]);
263
- const { hasFeature } = useFeatureAccess();
264
- const hasResolvedFeature = useCallback(
265
- (key) => {
266
- if (!hasFeature(key)) {
267
- return false;
268
- }
269
- const organizationModelFeatureEnabled = isOrganizationModelFeatureEnabled(resolvedOrganizationModel, key);
270
- return organizationModelFeatureEnabled ?? true;
271
- },
272
- [hasFeature, resolvedOrganizationModel]
273
- );
274
- const shellFeatures = useMemo(
275
- () => buildShellFeatures(resolvedOrganizationModel, features),
276
- [resolvedOrganizationModel, features]
277
- );
278
- const shellModel = useMemo(() => createShellModel(shellFeatures), [shellFeatures]);
279
- const normalizedDisabledSubsectionPaths = useMemo(
280
- () => [...new Set(disabledSubsectionPaths.map((path) => normalizeRoutePath(path)))],
281
- [disabledSubsectionPaths]
282
- );
283
- const resolvedFeatures = useMemo(
284
- () => resolveFeatureModules(features, hasResolvedFeature),
285
- [features, hasResolvedFeature]
286
- );
287
- const enabledResolvedFeatures = useMemo(
288
- () => resolvedFeatures.filter((feature) => feature.access.enabled),
289
- [resolvedFeatures]
290
- );
291
- const organizationGraph = useMemo(
292
- () => resolveOrganizationGraphFeature(enabledResolvedFeatures, shellModel),
293
- [enabledResolvedFeatures, shellModel]
294
- );
295
- const getResolvedFeature = useCallback(
296
- (key) => resolvedFeatures.find((feature) => feature.key === key),
297
- [resolvedFeatures]
298
- );
299
- const isFeatureEnabled = useCallback((key) => hasResolvedFeature(key), [hasResolvedFeature]);
300
- const resolveRouteByPath = useCallback(
301
- (path) => resolveRoute(enabledResolvedFeatures, shellModel, path, normalizedDisabledSubsectionPaths),
302
- [enabledResolvedFeatures, shellModel, normalizedDisabledSubsectionPaths]
303
- );
304
- const shellRuntime = useMemo(
305
- () => ({
306
- resolveRoute: resolveRouteByPath
307
- }),
308
- [resolveRouteByPath]
309
- );
310
- const value = useMemo(
311
- () => ({
312
- shellModel,
313
- shellRuntime,
314
- enabledResolvedFeatures,
315
- resolvedFeatures,
316
- organizationGraph,
317
- organizationModel: resolvedOrganizationModel,
318
- timeRange,
319
- operationsApiUrl,
320
- operationsSSEManager,
321
- deliveryApiUrl,
322
- deliverySSEManager,
323
- disabledSubsectionPaths: normalizedDisabledSubsectionPaths,
324
- isFeatureEnabled,
325
- getResolvedFeature
326
- }),
327
- [
328
- shellModel,
329
- shellRuntime,
330
- enabledResolvedFeatures,
331
- resolvedFeatures,
332
- organizationGraph,
333
- resolvedOrganizationModel,
334
- timeRange,
335
- operationsApiUrl,
336
- operationsSSEManager,
337
- deliveryApiUrl,
338
- deliverySSEManager,
339
- normalizedDisabledSubsectionPaths,
340
- isFeatureEnabled,
341
- getResolvedFeature
342
- ]
343
- );
344
- return /* @__PURE__ */ jsx(ElevasisFeaturesContext.Provider, { value, children });
345
- }
346
-
347
- export { ElevasisFeaturesProvider, createFeatureAccessHook, useElevasisFeatures, useOptionalElevasisFeatures };