teraprox-core-sdk 0.3.2 → 0.3.5

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.
@@ -52,6 +52,23 @@ function createReducersBundle(config) {
52
52
  };
53
53
  }
54
54
 
55
+ // src/adapters/null/NullObservabilityAdapter.ts
56
+ var NullObservabilityAdapter = class {
57
+ trackInteraction(payload) {
58
+ var _a;
59
+ console.info(`[Observability] INTERACTION: ${payload.name}`, (_a = payload.properties) != null ? _a : {});
60
+ }
61
+ captureVitals(payload) {
62
+ var _a, _b;
63
+ const unit = (_a = payload.unit) != null ? _a : "";
64
+ console.info(`[Observability] VITAL: ${payload.name} = ${payload.value}${unit}`, (_b = payload.meta) != null ? _b : {});
65
+ }
66
+ logBreadcrumb(payload) {
67
+ var _a;
68
+ console.info(`[Observability] BREADCRUMB [${payload.category}]: ${payload.message}`, (_a = payload.data) != null ? _a : {});
69
+ }
70
+ };
71
+
55
72
  // src/federation/StandaloneProvider.tsx
56
73
  import { useMemo, useCallback, useState, useEffect as useEffect2, useRef } from "react";
57
74
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -65,13 +82,21 @@ async function probeEmulator(host, port) {
65
82
  return false;
66
83
  }
67
84
  }
68
- async function resolveRtdbStrategy(firebaseConfig) {
69
- var _a;
85
+ async function resolveRtdbStrategy(firebaseConfig, emulator) {
86
+ var _a, _b;
87
+ if (emulator) {
88
+ return {
89
+ type: "emulator",
90
+ host: emulator.host,
91
+ port: emulator.port,
92
+ namespace: (_a = emulator.namespace) != null ? _a : "teraprox-default-rtdb"
93
+ };
94
+ }
70
95
  const emulatorHostEnv = typeof process !== "undefined" && process.env.REACT_APP_RTDB_EMULATOR_HOST || void 0;
71
96
  if (emulatorHostEnv) {
72
97
  const [host, portStr] = emulatorHostEnv.split(":");
73
98
  const port = parseInt(portStr != null ? portStr : "9000", 10);
74
- const namespace = (_a = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _a : "demo-local";
99
+ const namespace = (_b = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _b : "demo-local";
75
100
  return { type: "emulator", host, port, namespace };
76
101
  }
77
102
  if (firebaseConfig && Object.keys(firebaseConfig).length > 0) {
@@ -147,7 +172,7 @@ function RtdbConfigWarning({ onDismiss }) {
147
172
  }
148
173
  );
149
174
  }
150
- function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }) {
175
+ function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }) {
151
176
  const [subscriptions] = useState([]);
152
177
  const subscriptionsRef = useRef(subscriptions);
153
178
  subscriptionsRef.current = subscriptions;
@@ -182,7 +207,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
182
207
  let cancelled = false;
183
208
  (async () => {
184
209
  var _a;
185
- const strategy = await resolveRtdbStrategy(firebaseConfig);
210
+ const strategy = await resolveRtdbStrategy(firebaseConfig, emulator);
186
211
  if (cancelled) return;
187
212
  if (strategy.type === "none") {
188
213
  if (process.env.NODE_ENV !== "production") setRtdbWarning(true);
@@ -250,7 +275,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
250
275
  cancelled = true;
251
276
  cleanup == null ? void 0 : cleanup();
252
277
  };
253
- }, [firebaseConfig, tenant]);
278
+ }, [firebaseConfig, emulator, tenant]);
254
279
  const value = useMemo(
255
280
  () => ({
256
281
  createController,
@@ -263,7 +288,8 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
263
288
  },
264
289
  handleLogout: () => {
265
290
  },
266
- hostedByCore: false
291
+ hostedByCore: false,
292
+ observability: new NullObservabilityAdapter()
267
293
  }),
268
294
  [createController, toast, subscribe, unsubscribe]
269
295
  );
@@ -282,14 +308,14 @@ var DEFAULT_DEV_USER = {
282
308
  lastName: "User",
283
309
  token: "dev-standalone-token",
284
310
  email: "dev@teraprox.local",
285
- id: "dev-user-id",
311
+ id: "1",
286
312
  role: "admin",
287
313
  user: "devuser",
288
314
  userName: "devuser",
289
315
  setor: "Desenvolvimento",
290
- userSetor: { setorId: "dev-setor-id" },
316
+ userSetor: { setorId: "1" },
291
317
  companyName: "Dev Company",
292
- companyId: "dev-company-id",
318
+ companyId: "1",
293
319
  filters: []
294
320
  };
295
321
  function DevAutoLogin({ actions, devUser, children }) {
@@ -313,6 +339,7 @@ export {
313
339
  CoreServiceContext,
314
340
  FederatedBridge,
315
341
  createReducersBundle,
342
+ NullObservabilityAdapter,
316
343
  StandaloneProvider,
317
344
  DevAutoLogin
318
345
  };
@@ -34,6 +34,50 @@ interface MatchingObjectSubscription {
34
34
  userId?: string;
35
35
  }
36
36
 
37
+ /**
38
+ * Port de Observabilidade — contrato entre os Use Cases/Adapters e
39
+ * qualquer implementação de RUM (Datadog, Sentry, Grafana, console…).
40
+ */
41
+ interface VitalsPayload {
42
+ /** Nome da métrica Web Vital: 'LCP', 'CLS', 'FID', 'TTFB', etc. */
43
+ name: string;
44
+ /** Valor numérico da métrica */
45
+ value: number;
46
+ /** Unidade da métrica: 'ms', 'score', 'count', etc. */
47
+ unit?: string;
48
+ /** Metadados adicionais opcionais */
49
+ meta?: Record<string, unknown>;
50
+ }
51
+ interface BreadcrumbPayload {
52
+ /** Categoria do breadcrumb: 'action', 'navigation', 'http', 'error', etc. */
53
+ category: string;
54
+ /** Mensagem legível descrevendo o evento */
55
+ message: string;
56
+ /** Dados estruturados adicionais */
57
+ data?: Record<string, unknown>;
58
+ }
59
+ interface InteractionPayload {
60
+ /** Nome da interação (ex.: 'save-solicitacao', 'approve-ss', 'reject-ss') */
61
+ name: string;
62
+ /** Propriedades associadas à interação */
63
+ properties?: Record<string, unknown>;
64
+ }
65
+ interface IObservabilityPort {
66
+ /**
67
+ * Registra uma interação do usuário (clique, submit, navegação intencional).
68
+ * Usado para rastrear fluxos de negócio e funis.
69
+ */
70
+ trackInteraction(payload: InteractionPayload): void;
71
+ /**
72
+ * Captura métricas de performance (Web Vitals: LCP, CLS, FID, TTFB).
73
+ */
74
+ captureVitals(payload: VitalsPayload): void;
75
+ /**
76
+ * Adiciona um breadcrumb ao trail de eventos para diagnóstico de erros.
77
+ */
78
+ logBreadcrumb(payload: BreadcrumbPayload): void;
79
+ }
80
+
37
81
  interface CoreService {
38
82
  /** Cria um HttpController configurado para um contexto/endpoint */
39
83
  createController(context: string, baseEndPoint?: string): HttpController;
@@ -51,6 +95,8 @@ interface CoreService {
51
95
  handleLogout(): void;
52
96
  /** Indica se o componente está hospedado pelo Core */
53
97
  hostedByCore: boolean;
98
+ /** Porta de observabilidade — tracking, vitals e breadcrumbs */
99
+ observability: IObservabilityPort;
54
100
  }
55
101
 
56
102
  interface FederatedBridgeProps {
@@ -119,6 +165,11 @@ interface ReducersBundle {
119
165
  }
120
166
  declare function createReducersBundle(config: ReducersBundleConfig): ReducersBundle;
121
167
 
168
+ interface EmulatorConfig {
169
+ host: string;
170
+ port: number;
171
+ namespace?: string;
172
+ }
122
173
  interface StandaloneConfig {
123
174
  /**
124
175
  * Factory for creating an HttpController. The remote provides its
@@ -133,11 +184,20 @@ interface StandaloneConfig {
133
184
  * object listening via Firebase RTDB — same path the Core uses.
134
185
  *
135
186
  * If omitted, the provider auto-detects the RTDB emulator:
136
- * 1. Reads `REACT_APP_RTDB_EMULATOR_HOST` (e.g. `localhost:9000`)
137
- * 2. Falls back to probing `localhost:9000`
138
- * 3. If neither works, shows a configuration popup (dev only)
187
+ * 1. Uses `emulator` prop if provided
188
+ * 2. Reads `REACT_APP_RTDB_EMULATOR_HOST` env var
189
+ * 3. Falls back to probing `localhost:9000`
190
+ * 4. If neither works, shows a configuration popup (dev only)
139
191
  */
140
192
  firebaseConfig?: Record<string, unknown>;
193
+ /**
194
+ * Explicit emulator configuration. Preferred over env vars because
195
+ * DefinePlugin may not replace process.env.REACT_APP_* inside node_modules.
196
+ * The app should read its own env vars and pass them here.
197
+ *
198
+ * Example: `{ host: 'localhost', port: 9000, namespace: 'teraprox-default-rtdb' }`
199
+ */
200
+ emulator?: EmulatorConfig;
141
201
  /**
142
202
  * Tenant / company ID used to build the RTDB path:
143
203
  * `{tenant}/matchingObjects`
@@ -178,7 +238,7 @@ interface StandaloneConfig {
178
238
  * }
179
239
  * ```
180
240
  */
181
- declare function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
241
+ declare function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
182
242
 
183
243
  interface DevUser {
184
244
  firstName: string;
@@ -256,4 +316,4 @@ interface RemoteManifest {
256
316
  menuSections: RemoteMenuSection[];
257
317
  }
258
318
 
259
- export { type CoreService as C, DevAutoLogin as D, FederatedBridge as F, type HttpController as H, type MatchingObjectSubscription as M, type ReducersBundle as R, StandaloneProvider as S, type ToastService as T, type ReducersBundleConfig as a, type RemoteManifest as b, type RemoteMenuItem as c, type RemoteMenuSection as d, type ToastOptions as e, createReducersBundle as f };
319
+ export { type BreadcrumbPayload as B, type CoreService as C, DevAutoLogin as D, FederatedBridge as F, type HttpController as H, type IObservabilityPort as I, type MatchingObjectSubscription as M, type ReducersBundle as R, StandaloneProvider as S, type ToastService as T, type VitalsPayload as V, type InteractionPayload as a, type ReducersBundleConfig as b, type RemoteManifest as c, type RemoteMenuItem as d, type RemoteMenuSection as e, type ToastOptions as f, createReducersBundle as g };
@@ -34,6 +34,50 @@ interface MatchingObjectSubscription {
34
34
  userId?: string;
35
35
  }
36
36
 
37
+ /**
38
+ * Port de Observabilidade — contrato entre os Use Cases/Adapters e
39
+ * qualquer implementação de RUM (Datadog, Sentry, Grafana, console…).
40
+ */
41
+ interface VitalsPayload {
42
+ /** Nome da métrica Web Vital: 'LCP', 'CLS', 'FID', 'TTFB', etc. */
43
+ name: string;
44
+ /** Valor numérico da métrica */
45
+ value: number;
46
+ /** Unidade da métrica: 'ms', 'score', 'count', etc. */
47
+ unit?: string;
48
+ /** Metadados adicionais opcionais */
49
+ meta?: Record<string, unknown>;
50
+ }
51
+ interface BreadcrumbPayload {
52
+ /** Categoria do breadcrumb: 'action', 'navigation', 'http', 'error', etc. */
53
+ category: string;
54
+ /** Mensagem legível descrevendo o evento */
55
+ message: string;
56
+ /** Dados estruturados adicionais */
57
+ data?: Record<string, unknown>;
58
+ }
59
+ interface InteractionPayload {
60
+ /** Nome da interação (ex.: 'save-solicitacao', 'approve-ss', 'reject-ss') */
61
+ name: string;
62
+ /** Propriedades associadas à interação */
63
+ properties?: Record<string, unknown>;
64
+ }
65
+ interface IObservabilityPort {
66
+ /**
67
+ * Registra uma interação do usuário (clique, submit, navegação intencional).
68
+ * Usado para rastrear fluxos de negócio e funis.
69
+ */
70
+ trackInteraction(payload: InteractionPayload): void;
71
+ /**
72
+ * Captura métricas de performance (Web Vitals: LCP, CLS, FID, TTFB).
73
+ */
74
+ captureVitals(payload: VitalsPayload): void;
75
+ /**
76
+ * Adiciona um breadcrumb ao trail de eventos para diagnóstico de erros.
77
+ */
78
+ logBreadcrumb(payload: BreadcrumbPayload): void;
79
+ }
80
+
37
81
  interface CoreService {
38
82
  /** Cria um HttpController configurado para um contexto/endpoint */
39
83
  createController(context: string, baseEndPoint?: string): HttpController;
@@ -51,6 +95,8 @@ interface CoreService {
51
95
  handleLogout(): void;
52
96
  /** Indica se o componente está hospedado pelo Core */
53
97
  hostedByCore: boolean;
98
+ /** Porta de observabilidade — tracking, vitals e breadcrumbs */
99
+ observability: IObservabilityPort;
54
100
  }
55
101
 
56
102
  interface FederatedBridgeProps {
@@ -119,6 +165,11 @@ interface ReducersBundle {
119
165
  }
120
166
  declare function createReducersBundle(config: ReducersBundleConfig): ReducersBundle;
121
167
 
168
+ interface EmulatorConfig {
169
+ host: string;
170
+ port: number;
171
+ namespace?: string;
172
+ }
122
173
  interface StandaloneConfig {
123
174
  /**
124
175
  * Factory for creating an HttpController. The remote provides its
@@ -133,11 +184,20 @@ interface StandaloneConfig {
133
184
  * object listening via Firebase RTDB — same path the Core uses.
134
185
  *
135
186
  * If omitted, the provider auto-detects the RTDB emulator:
136
- * 1. Reads `REACT_APP_RTDB_EMULATOR_HOST` (e.g. `localhost:9000`)
137
- * 2. Falls back to probing `localhost:9000`
138
- * 3. If neither works, shows a configuration popup (dev only)
187
+ * 1. Uses `emulator` prop if provided
188
+ * 2. Reads `REACT_APP_RTDB_EMULATOR_HOST` env var
189
+ * 3. Falls back to probing `localhost:9000`
190
+ * 4. If neither works, shows a configuration popup (dev only)
139
191
  */
140
192
  firebaseConfig?: Record<string, unknown>;
193
+ /**
194
+ * Explicit emulator configuration. Preferred over env vars because
195
+ * DefinePlugin may not replace process.env.REACT_APP_* inside node_modules.
196
+ * The app should read its own env vars and pass them here.
197
+ *
198
+ * Example: `{ host: 'localhost', port: 9000, namespace: 'teraprox-default-rtdb' }`
199
+ */
200
+ emulator?: EmulatorConfig;
141
201
  /**
142
202
  * Tenant / company ID used to build the RTDB path:
143
203
  * `{tenant}/matchingObjects`
@@ -178,7 +238,7 @@ interface StandaloneConfig {
178
238
  * }
179
239
  * ```
180
240
  */
181
- declare function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
241
+ declare function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
182
242
 
183
243
  interface DevUser {
184
244
  firstName: string;
@@ -256,4 +316,4 @@ interface RemoteManifest {
256
316
  menuSections: RemoteMenuSection[];
257
317
  }
258
318
 
259
- export { type CoreService as C, DevAutoLogin as D, FederatedBridge as F, type HttpController as H, type MatchingObjectSubscription as M, type ReducersBundle as R, StandaloneProvider as S, type ToastService as T, type ReducersBundleConfig as a, type RemoteManifest as b, type RemoteMenuItem as c, type RemoteMenuSection as d, type ToastOptions as e, createReducersBundle as f };
319
+ export { type BreadcrumbPayload as B, type CoreService as C, DevAutoLogin as D, FederatedBridge as F, type HttpController as H, type IObservabilityPort as I, type MatchingObjectSubscription as M, type ReducersBundle as R, StandaloneProvider as S, type ToastService as T, type VitalsPayload as V, type InteractionPayload as a, type ReducersBundleConfig as b, type RemoteManifest as c, type RemoteMenuItem as d, type RemoteMenuSection as e, type ToastOptions as f, createReducersBundle as g };
@@ -1,3 +1,3 @@
1
- export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, f as createReducersBundle } from './federation-B4ShfmDd.mjs';
1
+ export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, b as ReducersBundleConfig, c as RemoteManifest, d as RemoteMenuItem, e as RemoteMenuSection, S as StandaloneProvider, g as createReducersBundle } from './federation-Bhx0XhSP.mjs';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -1,3 +1,3 @@
1
- export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, f as createReducersBundle } from './federation-B4ShfmDd.js';
1
+ export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, b as ReducersBundleConfig, c as RemoteManifest, d as RemoteMenuItem, e as RemoteMenuSection, S as StandaloneProvider, g as createReducersBundle } from './federation-Bhx0XhSP.js';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -95,6 +95,25 @@ function createReducersBundle(config) {
95
95
 
96
96
  // src/federation/StandaloneProvider.tsx
97
97
  var import_react3 = require("react");
98
+
99
+ // src/adapters/null/NullObservabilityAdapter.ts
100
+ var NullObservabilityAdapter = class {
101
+ trackInteraction(payload) {
102
+ var _a;
103
+ console.info(`[Observability] INTERACTION: ${payload.name}`, (_a = payload.properties) != null ? _a : {});
104
+ }
105
+ captureVitals(payload) {
106
+ var _a, _b;
107
+ const unit = (_a = payload.unit) != null ? _a : "";
108
+ console.info(`[Observability] VITAL: ${payload.name} = ${payload.value}${unit}`, (_b = payload.meta) != null ? _b : {});
109
+ }
110
+ logBreadcrumb(payload) {
111
+ var _a;
112
+ console.info(`[Observability] BREADCRUMB [${payload.category}]: ${payload.message}`, (_a = payload.data) != null ? _a : {});
113
+ }
114
+ };
115
+
116
+ // src/federation/StandaloneProvider.tsx
98
117
  var import_jsx_runtime2 = require("react/jsx-runtime");
99
118
  async function probeEmulator(host, port) {
100
119
  try {
@@ -106,13 +125,21 @@ async function probeEmulator(host, port) {
106
125
  return false;
107
126
  }
108
127
  }
109
- async function resolveRtdbStrategy(firebaseConfig) {
110
- var _a;
128
+ async function resolveRtdbStrategy(firebaseConfig, emulator) {
129
+ var _a, _b;
130
+ if (emulator) {
131
+ return {
132
+ type: "emulator",
133
+ host: emulator.host,
134
+ port: emulator.port,
135
+ namespace: (_a = emulator.namespace) != null ? _a : "teraprox-default-rtdb"
136
+ };
137
+ }
111
138
  const emulatorHostEnv = typeof process !== "undefined" && process.env.REACT_APP_RTDB_EMULATOR_HOST || void 0;
112
139
  if (emulatorHostEnv) {
113
140
  const [host, portStr] = emulatorHostEnv.split(":");
114
141
  const port = parseInt(portStr != null ? portStr : "9000", 10);
115
- const namespace = (_a = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _a : "demo-local";
142
+ const namespace = (_b = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _b : "demo-local";
116
143
  return { type: "emulator", host, port, namespace };
117
144
  }
118
145
  if (firebaseConfig && Object.keys(firebaseConfig).length > 0) {
@@ -188,7 +215,7 @@ function RtdbConfigWarning({ onDismiss }) {
188
215
  }
189
216
  );
190
217
  }
191
- function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }) {
218
+ function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }) {
192
219
  const [subscriptions] = (0, import_react3.useState)([]);
193
220
  const subscriptionsRef = (0, import_react3.useRef)(subscriptions);
194
221
  subscriptionsRef.current = subscriptions;
@@ -223,7 +250,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
223
250
  let cancelled = false;
224
251
  (async () => {
225
252
  var _a;
226
- const strategy = await resolveRtdbStrategy(firebaseConfig);
253
+ const strategy = await resolveRtdbStrategy(firebaseConfig, emulator);
227
254
  if (cancelled) return;
228
255
  if (strategy.type === "none") {
229
256
  if (process.env.NODE_ENV !== "production") setRtdbWarning(true);
@@ -291,7 +318,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
291
318
  cancelled = true;
292
319
  cleanup == null ? void 0 : cleanup();
293
320
  };
294
- }, [firebaseConfig, tenant]);
321
+ }, [firebaseConfig, emulator, tenant]);
295
322
  const value = (0, import_react3.useMemo)(
296
323
  () => ({
297
324
  createController,
@@ -304,7 +331,8 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
304
331
  },
305
332
  handleLogout: () => {
306
333
  },
307
- hostedByCore: false
334
+ hostedByCore: false,
335
+ observability: new NullObservabilityAdapter()
308
336
  }),
309
337
  [createController, toast, subscribe, unsubscribe]
310
338
  );
@@ -323,14 +351,14 @@ var DEFAULT_DEV_USER = {
323
351
  lastName: "User",
324
352
  token: "dev-standalone-token",
325
353
  email: "dev@teraprox.local",
326
- id: "dev-user-id",
354
+ id: "1",
327
355
  role: "admin",
328
356
  user: "devuser",
329
357
  userName: "devuser",
330
358
  setor: "Desenvolvimento",
331
- userSetor: { setorId: "dev-setor-id" },
359
+ userSetor: { setorId: "1" },
332
360
  companyName: "Dev Company",
333
- companyId: "dev-company-id",
361
+ companyId: "1",
334
362
  filters: []
335
363
  };
336
364
  function DevAutoLogin({ actions, devUser, children }) {
@@ -3,7 +3,7 @@ import {
3
3
  FederatedBridge,
4
4
  StandaloneProvider,
5
5
  createReducersBundle
6
- } from "./chunk-PATJPPYP.mjs";
6
+ } from "./chunk-JK654W4P.mjs";
7
7
  export {
8
8
  DevAutoLogin,
9
9
  FederatedBridge,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CoreService, H as HttpController, T as ToastService } from './federation-B4ShfmDd.mjs';
2
- export { D as DevAutoLogin, F as FederatedBridge, M as MatchingObjectSubscription, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, e as ToastOptions, f as createReducersBundle } from './federation-B4ShfmDd.mjs';
1
+ import { C as CoreService, T as ToastService, I as IObservabilityPort, H as HttpController, a as InteractionPayload, V as VitalsPayload, B as BreadcrumbPayload } from './federation-Bhx0XhSP.mjs';
2
+ export { D as DevAutoLogin, F as FederatedBridge, M as MatchingObjectSubscription, R as ReducersBundle, b as ReducersBundleConfig, c as RemoteManifest, d as RemoteMenuItem, e as RemoteMenuSection, S as StandaloneProvider, f as ToastOptions, g as createReducersBundle } from './federation-Bhx0XhSP.mjs';
3
3
  import * as React from 'react';
4
4
  import { Dispatch } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -34,8 +34,134 @@ interface NavigationConfig {
34
34
  }
35
35
  type NavigateFn = (path: string | number, config?: NavigationConfig, pageName?: string) => void;
36
36
 
37
+ type StatusSolicitacao = 'PENDENTE' | 'APROVADO' | 'REPROVADO' | 'CANCELADO' | 'EM_EXECUCAO';
38
+ interface SolicitacaoDeServico {
39
+ id: string | number;
40
+ status: StatusSolicitacao;
41
+ dataDeAbertura: string;
42
+ descricaoDoProblema: string;
43
+ solicitante: {
44
+ id: string | number;
45
+ nome: string;
46
+ };
47
+ recurso?: {
48
+ id: string | number;
49
+ nome: string;
50
+ };
51
+ recursoNome?: string;
52
+ prioridade?: 'BAIXA' | 'MEDIA' | 'ALTA' | 'URGENTE';
53
+ setor?: string;
54
+ equipamento?: string;
55
+ }
56
+
37
57
  declare const CoreServiceContext: React.Context<CoreService | null>;
38
58
 
59
+ declare class FetchHttpAdapter implements HttpController {
60
+ private endpoint;
61
+ constructor(endpoint: string);
62
+ private request;
63
+ get(path?: string): Promise<any>;
64
+ post(path?: string, data?: any): Promise<any>;
65
+ put(path?: string, data?: any): Promise<any>;
66
+ patch(path?: string, data?: any): Promise<any>;
67
+ delete(path?: string, id?: string | number): Promise<any>;
68
+ deleteSimple(path?: string): Promise<any>;
69
+ save(path?: string, data?: any): Promise<any>;
70
+ read(path?: string, id?: string | number): Promise<any>;
71
+ readAll(path?: string): Promise<any>;
72
+ readAllwithPage(path?: string): Promise<any>;
73
+ bulkDelete(path?: string): Promise<any>;
74
+ }
75
+ declare class CoreServiceBuilder {
76
+ private _toast;
77
+ private _httpEndpoint?;
78
+ private _rtdbConfig?;
79
+ private _hostedByCore;
80
+ private _observability;
81
+ private _tracing;
82
+ withToast(toast: ToastService): this;
83
+ withHttpEndpoint(url: string): this;
84
+ withRtdbConfig(config: any): this;
85
+ setHostedByCore(hosted: boolean): this;
86
+ withObservability(observability: IObservabilityPort): this;
87
+ /**
88
+ * Ativa Distributed Tracing W3C nos controllers HTTP.
89
+ * Quando habilitado, `createController` retorna `TracingHttpAdapter` em vez de `FetchHttpAdapter`.
90
+ * O header `traceparent` é injetado em todas as requisições automaticamente.
91
+ */
92
+ withTracing(enabled?: boolean): this;
93
+ build(): CoreService;
94
+ }
95
+
96
+ declare class NullToastService implements ToastService {
97
+ success(message: string): void;
98
+ warning(message: string): void;
99
+ error(message: string): void;
100
+ info(message: string): void;
101
+ }
102
+ declare class NullHttpController implements HttpController {
103
+ private logAndResolve;
104
+ get(path?: string): Promise<never[]>;
105
+ post(path?: string): Promise<never[]>;
106
+ put(path?: string): Promise<never[]>;
107
+ patch(path?: string): Promise<never[]>;
108
+ delete(path?: string, id?: string | number): Promise<never[]>;
109
+ deleteSimple(path?: string): Promise<never[]>;
110
+ save(path?: string): Promise<never[]>;
111
+ read(path?: string, id?: string | number): Promise<never[]>;
112
+ readAll(path?: string): Promise<never[]>;
113
+ readAllwithPage(path?: string): Promise<never[]>;
114
+ bulkDelete(path?: string): Promise<never[]>;
115
+ }
116
+ declare const NullCoreService: CoreService;
117
+
118
+ /**
119
+ * Null Object Pattern — implementação fallback de `IObservabilityPort`.
120
+ * Apenas loga no console; substitua pela implementação real (Datadog/Sentry/Grafana)
121
+ * via `CoreServiceBuilder.withObservability()` no host.
122
+ */
123
+ declare class NullObservabilityAdapter implements IObservabilityPort {
124
+ trackInteraction(payload: InteractionPayload): void;
125
+ captureVitals(payload: VitalsPayload): void;
126
+ logBreadcrumb(payload: BreadcrumbPayload): void;
127
+ }
128
+
129
+ /**
130
+ * Decorator de HTTP que implementa Distributed Tracing via W3C TraceContext.
131
+ *
132
+ * - Gera um `trace-id` único por instância (cobre todos os spans de um contexto/controller).
133
+ * - Gera um `span-id` único por requisição HTTP.
134
+ * - Injeta o header `traceparent` em todas as chamadas: GET, POST, PUT, PATCH, DELETE, etc.
135
+ * - Mesclado com quaisquer `extraHeaders` já presentes na chamada.
136
+ *
137
+ * Uso via CoreServiceBuilder:
138
+ * ```ts
139
+ * new CoreServiceBuilder()
140
+ * .withHttpEndpoint(process.env.REACT_APP_END_POINT)
141
+ * .withTracing()
142
+ * .build()
143
+ * ```
144
+ */
145
+ declare class TracingHttpAdapter implements HttpController {
146
+ private readonly endpoint;
147
+ /** Identificador único desta cadeia de spans — compartilhado por todas as reqs do controller. */
148
+ private readonly traceId;
149
+ constructor(endpoint: string);
150
+ private mergeHeaders;
151
+ private request;
152
+ get(path?: string): Promise<any>;
153
+ post(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
154
+ put(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
155
+ patch(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
156
+ delete(path?: string, id?: string | number, extraHeaders?: Record<string, string>): Promise<any>;
157
+ deleteSimple(path?: string, extraHeaders?: Record<string, string>): Promise<any>;
158
+ save(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
159
+ read(path?: string, id?: string | number, extraHeaders?: Record<string, string>): Promise<any>;
160
+ readAll(path?: string, extraHeaders?: Record<string, string>): Promise<any>;
161
+ readAllwithPage(path?: string): Promise<any>;
162
+ bulkDelete(path?: string, ids?: (string | number)[], extraHeaders?: Record<string, string>): Promise<any>;
163
+ }
164
+
39
165
  declare function useCoreService(): CoreService;
40
166
 
41
167
  declare function useHttpController(context: string, baseEndPoint?: string): HttpController;
@@ -80,6 +206,16 @@ interface NavigatorConfig {
80
206
  */
81
207
  declare function useNavigator(config: NavigatorConfig): NavigateFn;
82
208
 
209
+ /**
210
+ * Atalho para acessar o Port de observabilidade via React context.
211
+ * Retorna a implementação real (quando fornecida pelo host) ou o NullObservabilityAdapter.
212
+ *
213
+ * @example
214
+ * const obs = useObservability()
215
+ * obs.logBreadcrumb({ category: 'action', message: 'Solicitação aprovada', data: { id } })
216
+ */
217
+ declare function useObservability(): IObservabilityPort;
218
+
83
219
  interface FetchDataReturn<T = any> {
84
220
  data: T | null;
85
221
  loading: boolean;
@@ -198,6 +334,36 @@ declare const _default: redux.Reducer<PickerState>;
198
334
 
199
335
  declare function pickTextColorBasedOnBgColorAdvanced(bgColor: string, lightColor: string, darkColor: string): string;
200
336
 
337
+ /**
338
+ * Instala PerformanceObserver para LCP e CLS automaticamente no bootstrap do módulo.
339
+ * Fallback silencioso em ambientes que não suportam a API (Node, browsers antigos).
340
+ *
341
+ * @param observability - Implementação de IObservabilityPort para receber as métricas.
342
+ */
343
+ declare function initWebVitals(observability: IObservabilityPort): void;
344
+
345
+ /**
346
+ * Utilitários de Distributed Tracing seguindo a especificação W3C TraceContext.
347
+ * https://www.w3.org/TR/trace-context/
348
+ */
349
+ /**
350
+ * Gera um trace-id de 128 bits (32 chars hex) conforme W3C TraceContext.
351
+ * Usado uma vez por instância de adapter — identifica toda a cadeia de spans de um contexto.
352
+ */
353
+ declare function generateTraceId(): string;
354
+ /**
355
+ * Gera um span-id de 64 bits (16 chars hex) conforme W3C TraceContext.
356
+ * Chamado a cada requisição HTTP — identifica um span individual.
357
+ */
358
+ declare function generateSpanId(): string;
359
+ /**
360
+ * Monta o header `traceparent` no formato W3C:
361
+ * `{version}-{traceId}-{spanId}-{flags}`
362
+ *
363
+ * Flags: `01` = sampled (enviado ao coletor), `00` = não-amostrado.
364
+ */
365
+ declare function buildTraceparent(traceId: string, spanId: string, sampled?: boolean): string;
366
+
201
367
  /**
202
368
  * Formats a date for display in Brazilian format.
203
369
  * Corresponds to the duplicated dateUtils.js in SGM/SGP/Services/default/.
@@ -219,4 +385,4 @@ declare function removeAccents(str: string): string;
219
385
  declare function slugify(str: string): string;
220
386
  declare function isBlank(str: string | null | undefined): boolean;
221
387
 
222
- export { CoreService, CoreServiceContext, HttpController, type NavigateFn, type NavigationConfig, type Notification, type NotificationState, RecursoDisplayer, ToastService, addDays, _default$1 as branchLevelReducer, capitalize, clearBranchLevelForm, clearPicker, daysBetween, formatDate, formatDateTime, isBlank, isDateAfter, isDateBefore, pickTextColorBasedOnBgColorAdvanced, _default as pickerReducer, populateToEdit, removeAccents, setColor, setExcludeLevels, setHaveComponente, setLevel, setLevels, setNome, setPickerContext, setPickerItems, setPickerSelected, setPickerVisible, slugify, toISOString, truncate, useAnexoUpload, useCoreService, useFetchData, useFormStorage, useHttpController, useMatchingObject, useNavigator, useNotifications, usePostData, useSmartSearch, useToast, useValidation };
388
+ export { BreadcrumbPayload, CoreService, CoreServiceBuilder, CoreServiceContext, FetchHttpAdapter, HttpController, IObservabilityPort, InteractionPayload, type NavigateFn, type NavigationConfig, type Notification, type NotificationState, NullCoreService, NullHttpController, NullObservabilityAdapter, NullToastService, RecursoDisplayer, type SolicitacaoDeServico, type StatusSolicitacao, ToastService, TracingHttpAdapter, VitalsPayload, addDays, _default$1 as branchLevelReducer, buildTraceparent, capitalize, clearBranchLevelForm, clearPicker, daysBetween, formatDate, formatDateTime, generateSpanId, generateTraceId, initWebVitals, isBlank, isDateAfter, isDateBefore, pickTextColorBasedOnBgColorAdvanced, _default as pickerReducer, populateToEdit, removeAccents, setColor, setExcludeLevels, setHaveComponente, setLevel, setLevels, setNome, setPickerContext, setPickerItems, setPickerSelected, setPickerVisible, slugify, toISOString, truncate, useAnexoUpload, useCoreService, useFetchData, useFormStorage, useHttpController, useMatchingObject, useNavigator, useNotifications, useObservability, usePostData, useSmartSearch, useToast, useValidation };