@datatechsolutions/ui 2.11.93 → 3.2.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 (138) hide show
  1. package/dist/astrlabe/contracts.d.mts +3 -3
  2. package/dist/astrlabe/contracts.d.ts +3 -3
  3. package/dist/astrlabe/index.js +108 -108
  4. package/dist/astrlabe/index.mjs +4 -4
  5. package/dist/astrlabe/workflow-canvas.js +4 -4
  6. package/dist/astrlabe/workflow-canvas.mjs +3 -3
  7. package/dist/brand/index.d.mts +1 -15
  8. package/dist/brand/index.d.ts +1 -15
  9. package/dist/brand/index.js +0 -14
  10. package/dist/brand/index.js.map +1 -1
  11. package/dist/brand/index.mjs +0 -14
  12. package/dist/brand/index.mjs.map +1 -1
  13. package/dist/{chunk-24QKSC74.js → chunk-3JJWPOK6.js} +6 -6
  14. package/dist/{chunk-24QKSC74.js.map → chunk-3JJWPOK6.js.map} +1 -1
  15. package/dist/{chunk-HGN5W56D.mjs → chunk-3ZUMJTDT.mjs} +3 -3
  16. package/dist/{chunk-HGN5W56D.mjs.map → chunk-3ZUMJTDT.mjs.map} +1 -1
  17. package/dist/{chunk-LKJZGFM4.mjs → chunk-5GDKCFM5.mjs} +3 -3
  18. package/dist/{chunk-LKJZGFM4.mjs.map → chunk-5GDKCFM5.mjs.map} +1 -1
  19. package/dist/{chunk-ZHUPYX4Q.mjs → chunk-5RM6NGZ6.mjs} +3 -3
  20. package/dist/{chunk-ZHUPYX4Q.mjs.map → chunk-5RM6NGZ6.mjs.map} +1 -1
  21. package/dist/{chunk-DB64YDV2.js → chunk-AOUUZ52N.js} +55 -55
  22. package/dist/{chunk-DB64YDV2.js.map → chunk-AOUUZ52N.js.map} +1 -1
  23. package/dist/{chunk-VGSWSQQU.mjs → chunk-B67DP7MI.mjs} +4 -4
  24. package/dist/{chunk-VGSWSQQU.mjs.map → chunk-B67DP7MI.mjs.map} +1 -1
  25. package/dist/{chunk-NYQAEPC7.js → chunk-EFOXN3LC.js} +159 -168
  26. package/dist/chunk-EFOXN3LC.js.map +1 -0
  27. package/dist/{chunk-ARVLVWUC.js → chunk-F54Q2YJY.js} +97 -15
  28. package/dist/chunk-F54Q2YJY.js.map +1 -0
  29. package/dist/{chunk-GMZ3PTNK.mjs → chunk-H2D2CRTD.mjs} +7 -7
  30. package/dist/{chunk-GMZ3PTNK.mjs.map → chunk-H2D2CRTD.mjs.map} +1 -1
  31. package/dist/{chunk-PTGPQJZJ.js → chunk-HDCUWUNH.js} +15 -15
  32. package/dist/{chunk-PTGPQJZJ.js.map → chunk-HDCUWUNH.js.map} +1 -1
  33. package/dist/{chunk-ZKUYNCAG.js → chunk-I2NZGVBG.js} +1595 -2140
  34. package/dist/chunk-I2NZGVBG.js.map +1 -0
  35. package/dist/{chunk-MLAXYDEU.mjs → chunk-IRPS5UCS.mjs} +3 -3
  36. package/dist/{chunk-MLAXYDEU.mjs.map → chunk-IRPS5UCS.mjs.map} +1 -1
  37. package/dist/{chunk-TEQYIK2B.mjs → chunk-IRT4T3CU.mjs} +92 -101
  38. package/dist/chunk-IRT4T3CU.mjs.map +1 -0
  39. package/dist/{chunk-A3BFURJB.mjs → chunk-JN6IL6OH.mjs} +1595 -2138
  40. package/dist/chunk-JN6IL6OH.mjs.map +1 -0
  41. package/dist/{chunk-NA57KK4O.js → chunk-JSNRCYSO.js} +4 -4
  42. package/dist/{chunk-NA57KK4O.js.map → chunk-JSNRCYSO.js.map} +1 -1
  43. package/dist/{chunk-XSBZNPUO.js → chunk-KR2X2WHJ.js} +53 -53
  44. package/dist/{chunk-XSBZNPUO.js.map → chunk-KR2X2WHJ.js.map} +1 -1
  45. package/dist/{chunk-YEWXDCCI.mjs → chunk-LEKZUS6N.mjs} +4 -4
  46. package/dist/{chunk-YEWXDCCI.mjs.map → chunk-LEKZUS6N.mjs.map} +1 -1
  47. package/dist/{chunk-6NAZVG2O.mjs → chunk-MVBIAXVN.mjs} +4 -4
  48. package/dist/{chunk-6NAZVG2O.mjs.map → chunk-MVBIAXVN.mjs.map} +1 -1
  49. package/dist/{chunk-4TY55HGO.mjs → chunk-OL73LBX5.mjs} +3 -3
  50. package/dist/{chunk-4TY55HGO.mjs.map → chunk-OL73LBX5.mjs.map} +1 -1
  51. package/dist/{chunk-HUGHELRM.mjs → chunk-QYA53LUF.mjs} +6 -6
  52. package/dist/chunk-QYA53LUF.mjs.map +1 -0
  53. package/dist/{chunk-DWFLIXES.mjs → chunk-R4TQWXNG.mjs} +3 -3
  54. package/dist/{chunk-DWFLIXES.mjs.map → chunk-R4TQWXNG.mjs.map} +1 -1
  55. package/dist/{chunk-SMKN4ZVB.js → chunk-RGI74SQH.js} +4 -4
  56. package/dist/{chunk-SMKN4ZVB.js.map → chunk-RGI74SQH.js.map} +1 -1
  57. package/dist/{chunk-FZTOP6EE.js → chunk-RL35XATZ.js} +141 -141
  58. package/dist/chunk-RL35XATZ.js.map +1 -0
  59. package/dist/{chunk-BUI7BCUN.js → chunk-RXZNACMI.js} +33 -33
  60. package/dist/{chunk-BUI7BCUN.js.map → chunk-RXZNACMI.js.map} +1 -1
  61. package/dist/{chunk-ST3GH5OM.js → chunk-SU3YPWFW.js} +26 -26
  62. package/dist/{chunk-ST3GH5OM.js.map → chunk-SU3YPWFW.js.map} +1 -1
  63. package/dist/{chunk-DIMLLLZR.js → chunk-TIJJHW2Z.js} +36 -36
  64. package/dist/{chunk-DIMLLLZR.js.map → chunk-TIJJHW2Z.js.map} +1 -1
  65. package/dist/{chunk-2RDGJXYZ.js → chunk-TVMLV675.js} +67 -67
  66. package/dist/{chunk-2RDGJXYZ.js.map → chunk-TVMLV675.js.map} +1 -1
  67. package/dist/{chunk-Y3WJAYOY.mjs → chunk-UDDZTTLO.mjs} +6 -6
  68. package/dist/chunk-UDDZTTLO.mjs.map +1 -0
  69. package/dist/{chunk-43GCSCQA.js → chunk-W5OEBO6E.js} +12 -12
  70. package/dist/chunk-W5OEBO6E.js.map +1 -0
  71. package/dist/{chunk-3Z366CVM.js → chunk-Y6AEE56Q.js} +67 -67
  72. package/dist/{chunk-3Z366CVM.js.map → chunk-Y6AEE56Q.js.map} +1 -1
  73. package/dist/{chunk-RXFAQFE7.mjs → chunk-YIB2YAM5.mjs} +3 -3
  74. package/dist/{chunk-RXFAQFE7.mjs.map → chunk-YIB2YAM5.mjs.map} +1 -1
  75. package/dist/{chunk-OLXOBT42.mjs → chunk-YV72JM4B.mjs} +4 -4
  76. package/dist/{chunk-OLXOBT42.mjs.map → chunk-YV72JM4B.mjs.map} +1 -1
  77. package/dist/{chunk-MEEFOZC4.js → chunk-ZM5MVWIT.js} +4 -4
  78. package/dist/{chunk-MEEFOZC4.js.map → chunk-ZM5MVWIT.js.map} +1 -1
  79. package/dist/{chunk-PU2KTO4O.mjs → chunk-ZV5EZXXO.mjs} +97 -15
  80. package/dist/chunk-ZV5EZXXO.mjs.map +1 -0
  81. package/dist/index.d.mts +8 -41
  82. package/dist/index.d.ts +8 -41
  83. package/dist/index.js +745 -753
  84. package/dist/index.mjs +2 -2
  85. package/dist/platform/admin/index.js +11 -11
  86. package/dist/platform/admin/index.mjs +5 -5
  87. package/dist/platform/agents-workspace.js +7 -7
  88. package/dist/platform/agents-workspace.mjs +6 -6
  89. package/dist/platform/app-shell.js +4 -4
  90. package/dist/platform/app-shell.mjs +3 -3
  91. package/dist/platform/auth/index.js +28 -28
  92. package/dist/platform/auth/index.mjs +5 -5
  93. package/dist/platform/billing/index.js +4 -4
  94. package/dist/platform/billing/index.mjs +3 -3
  95. package/dist/platform/impersonation/index.js +4 -4
  96. package/dist/platform/impersonation/index.mjs +3 -3
  97. package/dist/platform/index.d.mts +1 -1
  98. package/dist/platform/index.d.ts +1 -1
  99. package/dist/platform/index.js +99 -99
  100. package/dist/platform/index.js.map +1 -1
  101. package/dist/platform/index.mjs +19 -19
  102. package/dist/platform/index.mjs.map +1 -1
  103. package/dist/platform/pages/index.d.mts +4 -5
  104. package/dist/platform/pages/index.d.ts +4 -5
  105. package/dist/platform/pages/index.js +197 -197
  106. package/dist/platform/pages/index.js.map +1 -1
  107. package/dist/platform/pages/index.mjs +9 -9
  108. package/dist/platform/pages/index.mjs.map +1 -1
  109. package/dist/platform/settings/index.js +8 -8
  110. package/dist/platform/settings/index.mjs +7 -7
  111. package/dist/platform/telemetry/index.d.mts +51 -0
  112. package/dist/platform/telemetry/index.d.ts +51 -0
  113. package/dist/platform/telemetry/index.js +96 -0
  114. package/dist/platform/telemetry/index.js.map +1 -0
  115. package/dist/platform/telemetry/index.mjs +89 -0
  116. package/dist/platform/telemetry/index.mjs.map +1 -0
  117. package/dist/platform/workflow-api-client.d.mts +1 -1
  118. package/dist/platform/workflow-api-client.d.ts +1 -1
  119. package/dist/platform/workflow-api-client.js +61 -61
  120. package/dist/platform/workflow-api-client.mjs +1 -1
  121. package/dist/platform/workflow-canvas-shell.js +5 -5
  122. package/dist/platform/workflow-canvas-shell.mjs +4 -4
  123. package/dist/{workflow-api-client-DVLhcpUj.d.ts → workflow-api-client-BKD8OfP_.d.ts} +61 -30
  124. package/dist/{workflow-api-client-DpBxHTHr.d.mts → workflow-api-client-DoYj7nHz.d.mts} +61 -30
  125. package/package.json +7 -1
  126. package/dist/chunk-43GCSCQA.js.map +0 -1
  127. package/dist/chunk-A3BFURJB.mjs.map +0 -1
  128. package/dist/chunk-ARVLVWUC.js.map +0 -1
  129. package/dist/chunk-FZTOP6EE.js.map +0 -1
  130. package/dist/chunk-HUGHELRM.mjs.map +0 -1
  131. package/dist/chunk-NYQAEPC7.js.map +0 -1
  132. package/dist/chunk-PU2KTO4O.mjs.map +0 -1
  133. package/dist/chunk-TEQYIK2B.mjs.map +0 -1
  134. package/dist/chunk-Y3WJAYOY.mjs.map +0 -1
  135. package/dist/chunk-ZKUYNCAG.js.map +0 -1
  136. package/src/brand/logos/fuel-icon.svg +0 -32
  137. package/src/brand/logos/fuel-logo-dark.svg +0 -43
  138. package/src/brand/logos/fuel-logo.svg +0 -43
@@ -1,23 +1,23 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunk43GCSCQA_js = require('../../chunk-43GCSCQA.js');
5
- require('../../chunk-BUI7BCUN.js');
6
- require('../../chunk-DB64YDV2.js');
7
- require('../../chunk-NA57KK4O.js');
8
- require('../../chunk-PTGPQJZJ.js');
9
- require('../../chunk-ZKUYNCAG.js');
4
+ var chunkW5OEBO6E_js = require('../../chunk-W5OEBO6E.js');
5
+ require('../../chunk-RXZNACMI.js');
6
+ require('../../chunk-AOUUZ52N.js');
7
+ require('../../chunk-JSNRCYSO.js');
8
+ require('../../chunk-HDCUWUNH.js');
9
+ require('../../chunk-I2NZGVBG.js');
10
10
  require('../../chunk-UZ3CMNUJ.js');
11
11
  require('../../chunk-YXN2K77G.js');
12
12
  require('../../chunk-S7KHTUHA.js');
13
- require('../../chunk-ARVLVWUC.js');
13
+ require('../../chunk-F54Q2YJY.js');
14
14
  require('../../chunk-FAGDZEKM.js');
15
15
 
16
16
 
17
17
 
18
18
  Object.defineProperty(exports, "PlatformSettings", {
19
19
  enumerable: true,
20
- get: function () { return chunk43GCSCQA_js.PlatformSettings; }
20
+ get: function () { return chunkW5OEBO6E_js.PlatformSettings; }
21
21
  });
22
22
  //# sourceMappingURL=index.js.map
23
23
  //# sourceMappingURL=index.js.map
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- export { PlatformSettings } from '../../chunk-Y3WJAYOY.mjs';
3
- import '../../chunk-MLAXYDEU.mjs';
4
- import '../../chunk-YEWXDCCI.mjs';
5
- import '../../chunk-LKJZGFM4.mjs';
6
- import '../../chunk-DWFLIXES.mjs';
7
- import '../../chunk-A3BFURJB.mjs';
2
+ export { PlatformSettings } from '../../chunk-UDDZTTLO.mjs';
3
+ import '../../chunk-IRPS5UCS.mjs';
4
+ import '../../chunk-LEKZUS6N.mjs';
5
+ import '../../chunk-5GDKCFM5.mjs';
6
+ import '../../chunk-R4TQWXNG.mjs';
7
+ import '../../chunk-JN6IL6OH.mjs';
8
8
  import '../../chunk-D2JF6C3E.mjs';
9
9
  import '../../chunk-7VJ7CMMT.mjs';
10
10
  import '../../chunk-QWG2FMUN.mjs';
11
- import '../../chunk-PU2KTO4O.mjs';
11
+ import '../../chunk-ZV5EZXXO.mjs';
12
12
  import '../../chunk-SYNVNTLJ.mjs';
13
13
  //# sourceMappingURL=index.mjs.map
14
14
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,51 @@
1
+ import * as posthog_js from 'posthog-js';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ type TelemetryUser = {
6
+ /** Stable user id — typically the windsock JWT `sub`. */
7
+ id: string;
8
+ email?: string;
9
+ name?: string;
10
+ role?: string;
11
+ /** Tenant id — from `https://datatechsolutions.com.br/organization_id` claim. */
12
+ organizationId?: string;
13
+ };
14
+ type TelemetryProviderProps = {
15
+ /** App slug — e.g. `astrlabe`, `sextant`, `data-br`. Tags every event. */
16
+ app: string;
17
+ /**
18
+ * PostHog project token (write-only key, safe in browser bundles).
19
+ * If unset, the provider falls back to `window.__APP_CONFIG__.posthog.key`
20
+ * (set by the CDK-managed `runtime-config.js`) and then to
21
+ * `import.meta.env.VITE_POSTHOG_KEY`. Pass explicitly only for tests
22
+ * or sub-app embeds.
23
+ */
24
+ projectKey?: string;
25
+ /**
26
+ * PostHog ingestion host. Falls back through the same chain as
27
+ * `projectKey`; defaults to US Cloud if nothing else resolves.
28
+ */
29
+ apiHost?: string;
30
+ /** Whether to record session replays. Defaults to true. */
31
+ recordSessions?: boolean;
32
+ /** Current authenticated user, if any. The provider re-identifies on change. */
33
+ user?: TelemetryUser | null;
34
+ children: ReactNode;
35
+ };
36
+ /**
37
+ * Wrap every SPA in this provider. Pass the windsock-resolved user so
38
+ * PostHog associates events with the right tenant; pass `null` after
39
+ * sign-out so the next session is anonymous.
40
+ */
41
+ declare function TelemetryProvider({ app, projectKey: propProjectKey, apiHost: propApiHost, recordSessions, user, children, }: TelemetryProviderProps): react_jsx_runtime.JSX.Element;
42
+ /**
43
+ * Re-export the posthog-js/react hook so consumer SPAs can capture
44
+ * custom events without importing posthog-js directly:
45
+ *
46
+ * const ph = useTelemetry()
47
+ * ph?.capture('workflow_run_started', { workflowId })
48
+ */
49
+ declare const useTelemetry: () => posthog_js.PostHog;
50
+
51
+ export { TelemetryProvider, type TelemetryProviderProps, type TelemetryUser, useTelemetry };
@@ -0,0 +1,51 @@
1
+ import * as posthog_js from 'posthog-js';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ type TelemetryUser = {
6
+ /** Stable user id — typically the windsock JWT `sub`. */
7
+ id: string;
8
+ email?: string;
9
+ name?: string;
10
+ role?: string;
11
+ /** Tenant id — from `https://datatechsolutions.com.br/organization_id` claim. */
12
+ organizationId?: string;
13
+ };
14
+ type TelemetryProviderProps = {
15
+ /** App slug — e.g. `astrlabe`, `sextant`, `data-br`. Tags every event. */
16
+ app: string;
17
+ /**
18
+ * PostHog project token (write-only key, safe in browser bundles).
19
+ * If unset, the provider falls back to `window.__APP_CONFIG__.posthog.key`
20
+ * (set by the CDK-managed `runtime-config.js`) and then to
21
+ * `import.meta.env.VITE_POSTHOG_KEY`. Pass explicitly only for tests
22
+ * or sub-app embeds.
23
+ */
24
+ projectKey?: string;
25
+ /**
26
+ * PostHog ingestion host. Falls back through the same chain as
27
+ * `projectKey`; defaults to US Cloud if nothing else resolves.
28
+ */
29
+ apiHost?: string;
30
+ /** Whether to record session replays. Defaults to true. */
31
+ recordSessions?: boolean;
32
+ /** Current authenticated user, if any. The provider re-identifies on change. */
33
+ user?: TelemetryUser | null;
34
+ children: ReactNode;
35
+ };
36
+ /**
37
+ * Wrap every SPA in this provider. Pass the windsock-resolved user so
38
+ * PostHog associates events with the right tenant; pass `null` after
39
+ * sign-out so the next session is anonymous.
40
+ */
41
+ declare function TelemetryProvider({ app, projectKey: propProjectKey, apiHost: propApiHost, recordSessions, user, children, }: TelemetryProviderProps): react_jsx_runtime.JSX.Element;
42
+ /**
43
+ * Re-export the posthog-js/react hook so consumer SPAs can capture
44
+ * custom events without importing posthog-js directly:
45
+ *
46
+ * const ph = useTelemetry()
47
+ * ph?.capture('workflow_run_started', { workflowId })
48
+ */
49
+ declare const useTelemetry: () => posthog_js.PostHog;
50
+
51
+ export { TelemetryProvider, type TelemetryProviderProps, type TelemetryUser, useTelemetry };
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var posthog = require('posthog-js');
5
+ var react = require('posthog-js/react');
6
+ var react$1 = require('react');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var posthog__default = /*#__PURE__*/_interopDefault(posthog);
12
+
13
+ // src/platform/telemetry/posthog-provider.tsx
14
+ var DEFAULT_API_HOST = "https://us.i.posthog.com";
15
+ function resolveConfig(propKey, propHost) {
16
+ let key = propKey ?? "";
17
+ let host = propHost ?? "";
18
+ if (typeof window !== "undefined") {
19
+ const runtime = window.__APP_CONFIG__?.posthog;
20
+ if (!key && runtime?.key) key = runtime.key;
21
+ if (!host && runtime?.host) host = runtime.host;
22
+ }
23
+ try {
24
+ const env = undefined ?? {};
25
+ if (!key) key = env.VITE_POSTHOG_KEY ?? "";
26
+ if (!host) host = env.VITE_POSTHOG_HOST ?? "";
27
+ } catch {
28
+ }
29
+ if (!host) host = DEFAULT_API_HOST;
30
+ return { key, host };
31
+ }
32
+ function TelemetryProvider({
33
+ app,
34
+ projectKey: propProjectKey,
35
+ apiHost: propApiHost,
36
+ recordSessions = true,
37
+ user,
38
+ children
39
+ }) {
40
+ const { key: projectKey, host: apiHost } = react$1.useMemo(
41
+ () => resolveConfig(propProjectKey, propApiHost),
42
+ [propProjectKey, propApiHost]
43
+ );
44
+ const enabled = react$1.useMemo(() => {
45
+ if (!projectKey) return false;
46
+ if (typeof window === "undefined") return false;
47
+ if (window.localStorage?.getItem("posthog_opt_out") === "true") return false;
48
+ return true;
49
+ }, [projectKey]);
50
+ react$1.useEffect(() => {
51
+ if (!enabled || !projectKey) return;
52
+ posthog__default.default.init(projectKey, {
53
+ api_host: apiHost,
54
+ defaults: "2026-01-30",
55
+ // Session replay: capture DOM + console + network (excluding
56
+ // request/response bodies — PII risk). The masking config blanks
57
+ // input fields by default; sensitive forms (login, MFA) should
58
+ // mark themselves with `data-ph-no-capture` to be extra-safe.
59
+ session_recording: recordSessions ? {
60
+ maskAllInputs: true,
61
+ recordCrossOriginIframes: false
62
+ } : void 0,
63
+ capture_pageview: "history_change",
64
+ capture_pageleave: true,
65
+ autocapture: true,
66
+ // Always tag every event with the SPA slug so we can filter.
67
+ loaded: (instance) => {
68
+ instance.register({ app });
69
+ }
70
+ });
71
+ }, [enabled, projectKey, apiHost, recordSessions, app]);
72
+ react$1.useEffect(() => {
73
+ if (!enabled) return;
74
+ if (user?.id) {
75
+ posthog__default.default.identify(user.id, {
76
+ email: user.email,
77
+ name: user.name,
78
+ role: user.role,
79
+ organization_id: user.organizationId
80
+ });
81
+ if (user.organizationId) {
82
+ posthog__default.default.group("organization", user.organizationId);
83
+ }
84
+ } else {
85
+ posthog__default.default.reset();
86
+ }
87
+ }, [enabled, user?.id, user?.email, user?.name, user?.role, user?.organizationId]);
88
+ if (!enabled) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
89
+ return /* @__PURE__ */ jsxRuntime.jsx(react.PostHogProvider, { client: posthog__default.default, children });
90
+ }
91
+ var useTelemetry = react.usePostHog;
92
+
93
+ exports.TelemetryProvider = TelemetryProvider;
94
+ exports.useTelemetry = useTelemetry;
95
+ //# sourceMappingURL=index.js.map
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/platform/telemetry/posthog-provider.tsx"],"names":["useMemo","useEffect","posthog","jsx","Fragment","PostHogProvider","usePostHog"],"mappings":";;;;;;;;;;;;AAiEA,IAAM,gBAAA,GAAmB,0BAAA;AAQ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,KAAA,CAAM,cAAA,EAAgB,IAAA,CAAK,cAAc,CAAA;AAAA,MACnD;AAAA,IACF,CAAA,MAAO;AAGL,MAAAA,wBAAA,CAAQ,KAAA,EAAM;AAAA,IAChB;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,EAAS,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,cAAc,CAAC,CAAA;AAEjF,EAAA,IAAI,CAAC,OAAA,EAAS,uBAAOC,cAAA,CAAAC,mBAAA,EAAA,EAAG,QAAA,EAAS,CAAA;AAEjC,EAAA,uBAAOD,cAAA,CAACE,qBAAA,EAAA,EAAgB,MAAA,EAAQH,wBAAA,EAAU,QAAA,EAAS,CAAA;AACrD;AASO,IAAM,YAAA,GAAeI","file":"index.js","sourcesContent":["/**\n * PostHog telemetry provider.\n *\n * Mounted once at the root of every Datatech SPA (astrlabe, sextant,\n * data-br, kori-erp, windsock-ui). Reads the PostHog project key + host\n * from `window.__APP_CONFIG__.posthog` — populated by `runtime-config.js`\n * which the deployed SPA's index.html loads BEFORE main.tsx. The CDK\n * FrontendStack uploads `runtime-config.js` to the bucket from SSM\n * (`/datatech/{env}/posthog/{project-key,api-host}`).\n *\n * For local dev, `import.meta.env.VITE_POSTHOG_KEY` is the fallback —\n * empty in most local sessions, so telemetry stays off without ceremony.\n *\n * Explicit prop overrides (`projectKey` / `apiHost`) win over both —\n * useful for tests and one-off sub-app embeds.\n *\n * Why a shared provider instead of per-app posthog.init():\n * - Single bundle dep (peer-installed in each SPA, but the wiring\n * code lives here so identification + opt-out logic stays consistent).\n * - Auto-tags every event with `app` (SPA name) and `organization_id`\n * (windsock JWT claim) so analytics across the platform can pivot\n * by tenant without per-team plumbing.\n *\n * Opt-out:\n * - Tracking disabled if no project key is resolvable from any source.\n * - Tracking disabled if `localStorage.posthog_opt_out === 'true'`.\n * - Replay can be disabled separately via `recordSessions={false}`.\n */\nimport posthog from 'posthog-js'\nimport { PostHogProvider, usePostHog } from 'posthog-js/react'\nimport { type ReactNode, useEffect, useMemo } from 'react'\n\nexport type TelemetryUser = {\n /** Stable user id — typically the windsock JWT `sub`. */\n id: string\n email?: string\n name?: string\n role?: string\n /** Tenant id — from `https://datatechsolutions.com.br/organization_id` claim. */\n organizationId?: string\n}\n\nexport type TelemetryProviderProps = {\n /** App slug — e.g. `astrlabe`, `sextant`, `data-br`. Tags every event. */\n app: string\n /**\n * PostHog project token (write-only key, safe in browser bundles).\n * If unset, the provider falls back to `window.__APP_CONFIG__.posthog.key`\n * (set by the CDK-managed `runtime-config.js`) and then to\n * `import.meta.env.VITE_POSTHOG_KEY`. Pass explicitly only for tests\n * or sub-app embeds.\n */\n projectKey?: string\n /**\n * PostHog ingestion host. Falls back through the same chain as\n * `projectKey`; defaults to US Cloud if nothing else resolves.\n */\n apiHost?: string\n /** Whether to record session replays. Defaults to true. */\n recordSessions?: boolean\n /** Current authenticated user, if any. The provider re-identifies on change. */\n user?: TelemetryUser | null\n children: ReactNode\n}\n\nconst DEFAULT_API_HOST = 'https://us.i.posthog.com'\n\n/**\n * Resolve the PostHog config from the first source that has a value:\n * 1. Explicit prop (test override)\n * 2. `window.__APP_CONFIG__.posthog.{key,host}` (deployed runtime-config.js)\n * 3. `import.meta.env.VITE_POSTHOG_*` (local dev)\n */\nfunction resolveConfig(propKey?: string, propHost?: string): { key: string; host: string } {\n let key = propKey ?? ''\n let host = propHost ?? ''\n\n if (typeof window !== 'undefined') {\n const runtime = (window as unknown as { __APP_CONFIG__?: { posthog?: { key?: string; host?: string } } })\n .__APP_CONFIG__?.posthog\n if (!key && runtime?.key) key = runtime.key\n if (!host && runtime?.host) host = runtime.host\n }\n\n // Vite injects `import.meta.env.*` at build time; reading is safe in\n // both dev and prod bundles. Empty string when not defined.\n try {\n const env = (import.meta as unknown as { env?: Record<string, string | undefined> }).env ?? {}\n if (!key) key = env.VITE_POSTHOG_KEY ?? ''\n if (!host) host = env.VITE_POSTHOG_HOST ?? ''\n } catch {\n /* import.meta unavailable (CJS test env) — treat as no env */\n }\n\n if (!host) host = DEFAULT_API_HOST\n return { key, host }\n}\n\n/**\n * Wrap every SPA in this provider. Pass the windsock-resolved user so\n * PostHog associates events with the right tenant; pass `null` after\n * sign-out so the next session is anonymous.\n */\nexport function TelemetryProvider({\n app,\n projectKey: propProjectKey,\n apiHost: propApiHost,\n recordSessions = true,\n user,\n children,\n}: TelemetryProviderProps) {\n const { key: projectKey, host: apiHost } = useMemo(\n () => resolveConfig(propProjectKey, propApiHost),\n [propProjectKey, propApiHost],\n )\n\n const enabled = useMemo(() => {\n if (!projectKey) return false\n if (typeof window === 'undefined') return false\n if (window.localStorage?.getItem('posthog_opt_out') === 'true') return false\n return true\n }, [projectKey])\n\n useEffect(() => {\n if (!enabled || !projectKey) return\n // Idempotent — posthog.init no-ops on second call with same key.\n posthog.init(projectKey, {\n api_host: apiHost,\n defaults: '2026-01-30',\n // Session replay: capture DOM + console + network (excluding\n // request/response bodies — PII risk). The masking config blanks\n // input fields by default; sensitive forms (login, MFA) should\n // mark themselves with `data-ph-no-capture` to be extra-safe.\n session_recording: recordSessions\n ? {\n maskAllInputs: true,\n recordCrossOriginIframes: false,\n }\n : undefined,\n capture_pageview: 'history_change',\n capture_pageleave: true,\n autocapture: true,\n // Always tag every event with the SPA slug so we can filter.\n loaded: (instance) => {\n instance.register({ app })\n },\n })\n }, [enabled, projectKey, apiHost, recordSessions, app])\n\n useEffect(() => {\n if (!enabled) return\n if (user?.id) {\n posthog.identify(user.id, {\n email: user.email,\n name: user.name,\n role: user.role,\n organization_id: user.organizationId,\n })\n if (user.organizationId) {\n posthog.group('organization', user.organizationId)\n }\n } else {\n // No user (sign-out, never authenticated) → reset PostHog identity\n // so the next sign-in starts a fresh session.\n posthog.reset()\n }\n }, [enabled, user?.id, user?.email, user?.name, user?.role, user?.organizationId])\n\n if (!enabled) return <>{children}</>\n\n return <PostHogProvider client={posthog}>{children}</PostHogProvider>\n}\n\n/**\n * Re-export the posthog-js/react hook so consumer SPAs can capture\n * custom events without importing posthog-js directly:\n *\n * const ph = useTelemetry()\n * ph?.capture('workflow_run_started', { workflowId })\n */\nexport const useTelemetry = usePostHog\n"]}
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ import posthog from 'posthog-js';
3
+ import { usePostHog, PostHogProvider } from 'posthog-js/react';
4
+ import { useMemo, useEffect } from 'react';
5
+ import { jsx, Fragment } from 'react/jsx-runtime';
6
+
7
+ // src/platform/telemetry/posthog-provider.tsx
8
+ var DEFAULT_API_HOST = "https://us.i.posthog.com";
9
+ function resolveConfig(propKey, propHost) {
10
+ let key = propKey ?? "";
11
+ let host = propHost ?? "";
12
+ if (typeof window !== "undefined") {
13
+ const runtime = window.__APP_CONFIG__?.posthog;
14
+ if (!key && runtime?.key) key = runtime.key;
15
+ if (!host && runtime?.host) host = runtime.host;
16
+ }
17
+ try {
18
+ const env = import.meta.env ?? {};
19
+ if (!key) key = env.VITE_POSTHOG_KEY ?? "";
20
+ if (!host) host = env.VITE_POSTHOG_HOST ?? "";
21
+ } catch {
22
+ }
23
+ if (!host) host = DEFAULT_API_HOST;
24
+ return { key, host };
25
+ }
26
+ function TelemetryProvider({
27
+ app,
28
+ projectKey: propProjectKey,
29
+ apiHost: propApiHost,
30
+ recordSessions = true,
31
+ user,
32
+ children
33
+ }) {
34
+ const { key: projectKey, host: apiHost } = useMemo(
35
+ () => resolveConfig(propProjectKey, propApiHost),
36
+ [propProjectKey, propApiHost]
37
+ );
38
+ const enabled = useMemo(() => {
39
+ if (!projectKey) return false;
40
+ if (typeof window === "undefined") return false;
41
+ if (window.localStorage?.getItem("posthog_opt_out") === "true") return false;
42
+ return true;
43
+ }, [projectKey]);
44
+ useEffect(() => {
45
+ if (!enabled || !projectKey) return;
46
+ posthog.init(projectKey, {
47
+ api_host: apiHost,
48
+ defaults: "2026-01-30",
49
+ // Session replay: capture DOM + console + network (excluding
50
+ // request/response bodies — PII risk). The masking config blanks
51
+ // input fields by default; sensitive forms (login, MFA) should
52
+ // mark themselves with `data-ph-no-capture` to be extra-safe.
53
+ session_recording: recordSessions ? {
54
+ maskAllInputs: true,
55
+ recordCrossOriginIframes: false
56
+ } : void 0,
57
+ capture_pageview: "history_change",
58
+ capture_pageleave: true,
59
+ autocapture: true,
60
+ // Always tag every event with the SPA slug so we can filter.
61
+ loaded: (instance) => {
62
+ instance.register({ app });
63
+ }
64
+ });
65
+ }, [enabled, projectKey, apiHost, recordSessions, app]);
66
+ useEffect(() => {
67
+ if (!enabled) return;
68
+ if (user?.id) {
69
+ posthog.identify(user.id, {
70
+ email: user.email,
71
+ name: user.name,
72
+ role: user.role,
73
+ organization_id: user.organizationId
74
+ });
75
+ if (user.organizationId) {
76
+ posthog.group("organization", user.organizationId);
77
+ }
78
+ } else {
79
+ posthog.reset();
80
+ }
81
+ }, [enabled, user?.id, user?.email, user?.name, user?.role, user?.organizationId]);
82
+ if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children });
83
+ return /* @__PURE__ */ jsx(PostHogProvider, { client: posthog, children });
84
+ }
85
+ var useTelemetry = usePostHog;
86
+
87
+ export { TelemetryProvider, useTelemetry };
88
+ //# sourceMappingURL=index.mjs.map
89
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/platform/telemetry/posthog-provider.tsx"],"names":[],"mappings":";;;;;;AAiEA,IAAM,gBAAA,GAAmB,0BAAA;AAQzB,SAAS,aAAA,CAAc,SAAkB,QAAA,EAAkD;AACzF,EAAA,IAAI,MAAM,OAAA,IAAW,EAAA;AACrB,EAAA,IAAI,OAAO,QAAA,IAAY,EAAA;AAEvB,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,MAAM,OAAA,GAAW,OACd,cAAA,EAAgB,OAAA;AACnB,IAAA,IAAI,CAAC,GAAA,IAAO,OAAA,EAAS,GAAA,QAAW,OAAA,CAAQ,GAAA;AACxC,I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;AAEjF,EAAA,IAAI,CAAC,OAAA,EAAS,uBAAO,GAAA,CAAA,QAAA,EAAA,EAAG,QAAA,EAAS,CAAA;AAEjC,EAAA,uBAAO,GAAA,CAAC,eAAA,EAAA,EAAgB,MAAA,EAAQ,OAAA,EAAU,QAAA,EAAS,CAAA;AACrD;AASO,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["/**\n * PostHog telemetry provider.\n *\n * Mounted once at the root of every Datatech SPA (astrlabe, sextant,\n * data-br, kori-erp, windsock-ui). Reads the PostHog project key + host\n * from `window.__APP_CONFIG__.posthog` — populated by `runtime-config.js`\n * which the deployed SPA's index.html loads BEFORE main.tsx. The CDK\n * FrontendStack uploads `runtime-config.js` to the bucket from SSM\n * (`/datatech/{env}/posthog/{project-key,api-host}`).\n *\n * For local dev, `import.meta.env.VITE_POSTHOG_KEY` is the fallback —\n * empty in most local sessions, so telemetry stays off without ceremony.\n *\n * Explicit prop overrides (`projectKey` / `apiHost`) win over both —\n * useful for tests and one-off sub-app embeds.\n *\n * Why a shared provider instead of per-app posthog.init():\n * - Single bundle dep (peer-installed in each SPA, but the wiring\n * code lives here so identification + opt-out logic stays consistent).\n * - Auto-tags every event with `app` (SPA name) and `organization_id`\n * (windsock JWT claim) so analytics across the platform can pivot\n * by tenant without per-team plumbing.\n *\n * Opt-out:\n * - Tracking disabled if no project key is resolvable from any source.\n * - Tracking disabled if `localStorage.posthog_opt_out === 'true'`.\n * - Replay can be disabled separately via `recordSessions={false}`.\n */\nimport posthog from 'posthog-js'\nimport { PostHogProvider, usePostHog } from 'posthog-js/react'\nimport { type ReactNode, useEffect, useMemo } from 'react'\n\nexport type TelemetryUser = {\n /** Stable user id — typically the windsock JWT `sub`. */\n id: string\n email?: string\n name?: string\n role?: string\n /** Tenant id — from `https://datatechsolutions.com.br/organization_id` claim. */\n organizationId?: string\n}\n\nexport type TelemetryProviderProps = {\n /** App slug — e.g. `astrlabe`, `sextant`, `data-br`. Tags every event. */\n app: string\n /**\n * PostHog project token (write-only key, safe in browser bundles).\n * If unset, the provider falls back to `window.__APP_CONFIG__.posthog.key`\n * (set by the CDK-managed `runtime-config.js`) and then to\n * `import.meta.env.VITE_POSTHOG_KEY`. Pass explicitly only for tests\n * or sub-app embeds.\n */\n projectKey?: string\n /**\n * PostHog ingestion host. Falls back through the same chain as\n * `projectKey`; defaults to US Cloud if nothing else resolves.\n */\n apiHost?: string\n /** Whether to record session replays. Defaults to true. */\n recordSessions?: boolean\n /** Current authenticated user, if any. The provider re-identifies on change. */\n user?: TelemetryUser | null\n children: ReactNode\n}\n\nconst DEFAULT_API_HOST = 'https://us.i.posthog.com'\n\n/**\n * Resolve the PostHog config from the first source that has a value:\n * 1. Explicit prop (test override)\n * 2. `window.__APP_CONFIG__.posthog.{key,host}` (deployed runtime-config.js)\n * 3. `import.meta.env.VITE_POSTHOG_*` (local dev)\n */\nfunction resolveConfig(propKey?: string, propHost?: string): { key: string; host: string } {\n let key = propKey ?? ''\n let host = propHost ?? ''\n\n if (typeof window !== 'undefined') {\n const runtime = (window as unknown as { __APP_CONFIG__?: { posthog?: { key?: string; host?: string } } })\n .__APP_CONFIG__?.posthog\n if (!key && runtime?.key) key = runtime.key\n if (!host && runtime?.host) host = runtime.host\n }\n\n // Vite injects `import.meta.env.*` at build time; reading is safe in\n // both dev and prod bundles. Empty string when not defined.\n try {\n const env = (import.meta as unknown as { env?: Record<string, string | undefined> }).env ?? {}\n if (!key) key = env.VITE_POSTHOG_KEY ?? ''\n if (!host) host = env.VITE_POSTHOG_HOST ?? ''\n } catch {\n /* import.meta unavailable (CJS test env) — treat as no env */\n }\n\n if (!host) host = DEFAULT_API_HOST\n return { key, host }\n}\n\n/**\n * Wrap every SPA in this provider. Pass the windsock-resolved user so\n * PostHog associates events with the right tenant; pass `null` after\n * sign-out so the next session is anonymous.\n */\nexport function TelemetryProvider({\n app,\n projectKey: propProjectKey,\n apiHost: propApiHost,\n recordSessions = true,\n user,\n children,\n}: TelemetryProviderProps) {\n const { key: projectKey, host: apiHost } = useMemo(\n () => resolveConfig(propProjectKey, propApiHost),\n [propProjectKey, propApiHost],\n )\n\n const enabled = useMemo(() => {\n if (!projectKey) return false\n if (typeof window === 'undefined') return false\n if (window.localStorage?.getItem('posthog_opt_out') === 'true') return false\n return true\n }, [projectKey])\n\n useEffect(() => {\n if (!enabled || !projectKey) return\n // Idempotent — posthog.init no-ops on second call with same key.\n posthog.init(projectKey, {\n api_host: apiHost,\n defaults: '2026-01-30',\n // Session replay: capture DOM + console + network (excluding\n // request/response bodies — PII risk). The masking config blanks\n // input fields by default; sensitive forms (login, MFA) should\n // mark themselves with `data-ph-no-capture` to be extra-safe.\n session_recording: recordSessions\n ? {\n maskAllInputs: true,\n recordCrossOriginIframes: false,\n }\n : undefined,\n capture_pageview: 'history_change',\n capture_pageleave: true,\n autocapture: true,\n // Always tag every event with the SPA slug so we can filter.\n loaded: (instance) => {\n instance.register({ app })\n },\n })\n }, [enabled, projectKey, apiHost, recordSessions, app])\n\n useEffect(() => {\n if (!enabled) return\n if (user?.id) {\n posthog.identify(user.id, {\n email: user.email,\n name: user.name,\n role: user.role,\n organization_id: user.organizationId,\n })\n if (user.organizationId) {\n posthog.group('organization', user.organizationId)\n }\n } else {\n // No user (sign-out, never authenticated) → reset PostHog identity\n // so the next sign-in starts a fresh session.\n posthog.reset()\n }\n }, [enabled, user?.id, user?.email, user?.name, user?.role, user?.organizationId])\n\n if (!enabled) return <>{children}</>\n\n return <PostHogProvider client={posthog}>{children}</PostHogProvider>\n}\n\n/**\n * Re-export the posthog-js/react hook so consumer SPAs can capture\n * custom events without importing posthog-js directly:\n *\n * const ph = useTelemetry()\n * ph?.capture('workflow_run_started', { workflowId })\n */\nexport const useTelemetry = usePostHog\n"]}
@@ -2,5 +2,5 @@ import '../astrlabe/contracts.mjs';
2
2
  import '../index-VI9gyJXl.mjs';
3
3
  import '@datatechsolutions/shared-domain/ports/workflow';
4
4
  import '@datatechsolutions/shared-domain/common';
5
- export { h as AiGenerateResponse, i as AiValidateResponse, A as AnalyticsSummary, j as ApprovalDecision, k as ApprovalResponse, l as ModelProviderCatalogEntry, M as ModelProviderConnection, N as NodeMetrics, m as NodeValidationIssue, P as PresignUploadInput, n as PresignedUpload, o as PublicSampleWorkflow, p as RunEvent, R as RunTimelineEntry, W as WorkflowRunListParams, q as WorkflowTemplateSummary, r as aiGenerateWorkflow, s as aiValidateWorkflow, t as buildAuthenticatedApiUrl, u as cancelWorkflowRun, v as createAgentConfig, w as createAgentPrompt, x as createAgentRule, y as createAgentTool, z as createAgentToolDefinition, B as createDatasource, C as createModelProviderConnection, E as createWorkflow, F as createWorkflowFromTemplate, G as deleteAgentConfig, H as deleteAgentPrompt, I as deleteAgentRule, J as deleteAgentTool, K as deleteAgentToolDefinition, L as deleteModelProviderConnection, O as deleteUpload, Q as deleteWorkflow, S as executeAgentRule, T as executeWorkflow, U as getAgentConfigsWithPrompts, V as getAgentModels, X as getAgentPrompts, Y as getAgentRules, Z as getAgentToolDefinitions, _ as getAgentTools, $ as getAnalyticsSummary, a0 as getCurrentAccessToken, a1 as getDatasourceSchema, a2 as getDatasourceTables, a3 as getDatasources, a4 as getPublicSampleWorkflow, a5 as getRunTimeline, a6 as getUploadDownloadUrl, a7 as getWorkflowById, a8 as getWorkflowRunById, a9 as getWorkflowRuns, aa as getWorkflows, ab as listModelProviderCatalog, ac as listModelProviderConnections, ad as listWorkflowRuns, ae as listWorkflowTemplates, af as presignUpload, ag as publishWorkflow, ah as replayWorkflowRun, ai as saveWorkflowDraft, aj as setAccessTokenProvider, ak as setAuthenticatedFetch, al as submitApproval, am as subscribeToRunEvents, an as updateAgentConfig, ao as updateAgentPrompt, ap as updateAgentRule, aq as updateAgentTool, ar as updateAgentToolDefinition, as as updateModelProviderConnection, at as updateWorkflowSettings } from '../workflow-api-client-DpBxHTHr.mjs';
5
+ export { h as AiGenerateResponse, i as AiValidateResponse, A as AnalyticsSummary, j as ApprovalDecision, k as ApprovalResponse, l as ModelFamilyCatalogEntry, m as ModelProviderCatalogEntry, M as ModelProviderConnection, N as NodeMetrics, n as NodeValidationIssue, P as PresignUploadInput, o as PresignedUpload, p as PublicSampleWorkflow, q as RunEvent, r as RunSubscriptionState, R as RunTimelineEntry, W as WorkflowRunListParams, s as WorkflowTemplateSummary, t as aiGenerateWorkflow, u as aiValidateWorkflow, v as buildAuthenticatedApiUrl, w as cancelWorkflowRun, x as createAgentConfig, y as createAgentPrompt, z as createAgentRule, B as createAgentTool, C as createAgentToolDefinition, E as createDatasource, F as createModelProviderConnection, G as createWorkflow, H as createWorkflowFromTemplate, I as deleteAgentConfig, J as deleteAgentPrompt, K as deleteAgentRule, L as deleteAgentTool, O as deleteAgentToolDefinition, Q as deleteModelProviderConnection, S as deleteUpload, T as deleteWorkflow, U as executeAgentRule, V as executeWorkflow, X as getAgentConfigsWithPrompts, Y as getAgentModels, Z as getAgentPrompts, _ as getAgentRules, $ as getAgentToolDefinitions, a0 as getAgentTools, a1 as getAnalyticsSummary, a2 as getCurrentAccessToken, a3 as getDatasourceSchema, a4 as getDatasourceTables, a5 as getDatasources, a6 as getPublicSampleWorkflow, a7 as getRunTimeline, a8 as getUploadDownloadUrl, a9 as getWorkflowById, aa as getWorkflowRunById, ab as getWorkflowRuns, ac as getWorkflows, ad as listModelProviderCatalog, ae as listModelProviderConnections, af as listWorkflowRuns, ag as listWorkflowTemplates, ah as presignUpload, ai as publishWorkflow, aj as replayWorkflowRun, ak as saveWorkflowDraft, al as setAccessTokenProvider, am as setAuthenticatedFetch, an as submitApproval, ao as subscribeToRunEvents, ap as updateAgentConfig, aq as updateAgentPrompt, ar as updateAgentRule, as as updateAgentTool, at as updateAgentToolDefinition, au as updateModelProviderConnection, av as updateWorkflowSettings } from '../workflow-api-client-DoYj7nHz.mjs';
6
6
  import 'react/jsx-runtime';
@@ -2,5 +2,5 @@ import '../astrlabe/contracts.js';
2
2
  import '../index-CoB18TbG.js';
3
3
  import '@datatechsolutions/shared-domain/ports/workflow';
4
4
  import '@datatechsolutions/shared-domain/common';
5
- export { h as AiGenerateResponse, i as AiValidateResponse, A as AnalyticsSummary, j as ApprovalDecision, k as ApprovalResponse, l as ModelProviderCatalogEntry, M as ModelProviderConnection, N as NodeMetrics, m as NodeValidationIssue, P as PresignUploadInput, n as PresignedUpload, o as PublicSampleWorkflow, p as RunEvent, R as RunTimelineEntry, W as WorkflowRunListParams, q as WorkflowTemplateSummary, r as aiGenerateWorkflow, s as aiValidateWorkflow, t as buildAuthenticatedApiUrl, u as cancelWorkflowRun, v as createAgentConfig, w as createAgentPrompt, x as createAgentRule, y as createAgentTool, z as createAgentToolDefinition, B as createDatasource, C as createModelProviderConnection, E as createWorkflow, F as createWorkflowFromTemplate, G as deleteAgentConfig, H as deleteAgentPrompt, I as deleteAgentRule, J as deleteAgentTool, K as deleteAgentToolDefinition, L as deleteModelProviderConnection, O as deleteUpload, Q as deleteWorkflow, S as executeAgentRule, T as executeWorkflow, U as getAgentConfigsWithPrompts, V as getAgentModels, X as getAgentPrompts, Y as getAgentRules, Z as getAgentToolDefinitions, _ as getAgentTools, $ as getAnalyticsSummary, a0 as getCurrentAccessToken, a1 as getDatasourceSchema, a2 as getDatasourceTables, a3 as getDatasources, a4 as getPublicSampleWorkflow, a5 as getRunTimeline, a6 as getUploadDownloadUrl, a7 as getWorkflowById, a8 as getWorkflowRunById, a9 as getWorkflowRuns, aa as getWorkflows, ab as listModelProviderCatalog, ac as listModelProviderConnections, ad as listWorkflowRuns, ae as listWorkflowTemplates, af as presignUpload, ag as publishWorkflow, ah as replayWorkflowRun, ai as saveWorkflowDraft, aj as setAccessTokenProvider, ak as setAuthenticatedFetch, al as submitApproval, am as subscribeToRunEvents, an as updateAgentConfig, ao as updateAgentPrompt, ap as updateAgentRule, aq as updateAgentTool, ar as updateAgentToolDefinition, as as updateModelProviderConnection, at as updateWorkflowSettings } from '../workflow-api-client-DVLhcpUj.js';
5
+ export { h as AiGenerateResponse, i as AiValidateResponse, A as AnalyticsSummary, j as ApprovalDecision, k as ApprovalResponse, l as ModelFamilyCatalogEntry, m as ModelProviderCatalogEntry, M as ModelProviderConnection, N as NodeMetrics, n as NodeValidationIssue, P as PresignUploadInput, o as PresignedUpload, p as PublicSampleWorkflow, q as RunEvent, r as RunSubscriptionState, R as RunTimelineEntry, W as WorkflowRunListParams, s as WorkflowTemplateSummary, t as aiGenerateWorkflow, u as aiValidateWorkflow, v as buildAuthenticatedApiUrl, w as cancelWorkflowRun, x as createAgentConfig, y as createAgentPrompt, z as createAgentRule, B as createAgentTool, C as createAgentToolDefinition, E as createDatasource, F as createModelProviderConnection, G as createWorkflow, H as createWorkflowFromTemplate, I as deleteAgentConfig, J as deleteAgentPrompt, K as deleteAgentRule, L as deleteAgentTool, O as deleteAgentToolDefinition, Q as deleteModelProviderConnection, S as deleteUpload, T as deleteWorkflow, U as executeAgentRule, V as executeWorkflow, X as getAgentConfigsWithPrompts, Y as getAgentModels, Z as getAgentPrompts, _ as getAgentRules, $ as getAgentToolDefinitions, a0 as getAgentTools, a1 as getAnalyticsSummary, a2 as getCurrentAccessToken, a3 as getDatasourceSchema, a4 as getDatasourceTables, a5 as getDatasources, a6 as getPublicSampleWorkflow, a7 as getRunTimeline, a8 as getUploadDownloadUrl, a9 as getWorkflowById, aa as getWorkflowRunById, ab as getWorkflowRuns, ac as getWorkflows, ad as listModelProviderCatalog, ae as listModelProviderConnections, af as listWorkflowRuns, ag as listWorkflowTemplates, ah as presignUpload, ai as publishWorkflow, aj as replayWorkflowRun, ak as saveWorkflowDraft, al as setAccessTokenProvider, am as setAuthenticatedFetch, an as submitApproval, ao as subscribeToRunEvents, ap as updateAgentConfig, aq as updateAgentPrompt, ar as updateAgentRule, as as updateAgentTool, at as updateAgentToolDefinition, au as updateModelProviderConnection, av as updateWorkflowSettings } from '../workflow-api-client-BKD8OfP_.js';
6
6
  import 'react/jsx-runtime';