teraprox-core-sdk 0.3.3 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CoreService, H as HttpController, T as ToastService } from './federation-UNcGnNB-.js';
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-UNcGnNB-.js';
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.js';
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.js';
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,257 @@ 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
+ private extraHeaders?;
62
+ constructor(endpoint: string, extraHeaders?: Record<string, string> | undefined);
63
+ private request;
64
+ get(path?: string): Promise<any>;
65
+ post(path?: string, data?: any): Promise<any>;
66
+ put(path?: string, data?: any): Promise<any>;
67
+ patch(path?: string, data?: any): Promise<any>;
68
+ delete(path?: string, id?: string | number): Promise<any>;
69
+ deleteSimple(path?: string): Promise<any>;
70
+ save(path?: string, data?: any): Promise<any>;
71
+ read(path?: string, id?: string | number): Promise<any>;
72
+ readAll(path?: string): Promise<any>;
73
+ readAllwithPage(path?: string): Promise<any>;
74
+ bulkDelete(path?: string): Promise<any>;
75
+ }
76
+ declare class CoreServiceBuilder {
77
+ private _toast;
78
+ private _httpEndpoint?;
79
+ private _rtdbConfig?;
80
+ private _hostedByCore;
81
+ private _observability;
82
+ private _tracing;
83
+ withToast(toast: ToastService): this;
84
+ withHttpEndpoint(url: string): this;
85
+ withRtdbConfig(config: any): this;
86
+ setHostedByCore(hosted: boolean): this;
87
+ withObservability(observability: IObservabilityPort): this;
88
+ /**
89
+ * Ativa Distributed Tracing W3C nos controllers HTTP.
90
+ * Quando habilitado, `createController` retorna `TracingHttpAdapter` em vez de `FetchHttpAdapter`.
91
+ * O header `traceparent` é injetado em todas as requisições automaticamente.
92
+ */
93
+ withTracing(enabled?: boolean): this;
94
+ build(): CoreService;
95
+ }
96
+
97
+ declare class NullToastService implements ToastService {
98
+ success(message: string): void;
99
+ warning(message: string): void;
100
+ error(message: string): void;
101
+ info(message: string): void;
102
+ }
103
+ declare class NullHttpController implements HttpController {
104
+ private logAndResolve;
105
+ get(path?: string): Promise<{
106
+ id: number;
107
+ nome: string;
108
+ branchLevel: {
109
+ level: number;
110
+ };
111
+ status: string;
112
+ }[]> | Promise<{
113
+ id: number;
114
+ level: number;
115
+ nome: string;
116
+ }[]>;
117
+ post(path?: string): Promise<{
118
+ id: number;
119
+ nome: string;
120
+ branchLevel: {
121
+ level: number;
122
+ };
123
+ status: string;
124
+ }[]> | Promise<{
125
+ id: number;
126
+ level: number;
127
+ nome: string;
128
+ }[]>;
129
+ put(path?: string): Promise<{
130
+ id: number;
131
+ nome: string;
132
+ branchLevel: {
133
+ level: number;
134
+ };
135
+ status: string;
136
+ }[]> | Promise<{
137
+ id: number;
138
+ level: number;
139
+ nome: string;
140
+ }[]>;
141
+ patch(path?: string): Promise<{
142
+ id: number;
143
+ nome: string;
144
+ branchLevel: {
145
+ level: number;
146
+ };
147
+ status: string;
148
+ }[]> | Promise<{
149
+ id: number;
150
+ level: number;
151
+ nome: string;
152
+ }[]>;
153
+ delete(path?: string, id?: string | number): Promise<{
154
+ id: number;
155
+ nome: string;
156
+ branchLevel: {
157
+ level: number;
158
+ };
159
+ status: string;
160
+ }[]> | Promise<{
161
+ id: number;
162
+ level: number;
163
+ nome: string;
164
+ }[]>;
165
+ deleteSimple(path?: string): Promise<{
166
+ id: number;
167
+ nome: string;
168
+ branchLevel: {
169
+ level: number;
170
+ };
171
+ status: string;
172
+ }[]> | Promise<{
173
+ id: number;
174
+ level: number;
175
+ nome: string;
176
+ }[]>;
177
+ save(path?: string): Promise<{
178
+ id: number;
179
+ nome: string;
180
+ branchLevel: {
181
+ level: number;
182
+ };
183
+ status: string;
184
+ }[]> | Promise<{
185
+ id: number;
186
+ level: number;
187
+ nome: string;
188
+ }[]>;
189
+ read(path?: string, id?: string | number): Promise<{
190
+ id: number;
191
+ nome: string;
192
+ branchLevel: {
193
+ level: number;
194
+ };
195
+ status: string;
196
+ }[]> | Promise<{
197
+ id: number;
198
+ level: number;
199
+ nome: string;
200
+ }[]>;
201
+ readAll(path?: string): Promise<{
202
+ id: number;
203
+ nome: string;
204
+ branchLevel: {
205
+ level: number;
206
+ };
207
+ status: string;
208
+ }[]> | Promise<{
209
+ id: number;
210
+ level: number;
211
+ nome: string;
212
+ }[]>;
213
+ readAllwithPage(path?: string): Promise<{
214
+ id: number;
215
+ nome: string;
216
+ branchLevel: {
217
+ level: number;
218
+ };
219
+ status: string;
220
+ }[]> | Promise<{
221
+ id: number;
222
+ level: number;
223
+ nome: string;
224
+ }[]>;
225
+ bulkDelete(path?: string): Promise<{
226
+ id: number;
227
+ nome: string;
228
+ branchLevel: {
229
+ level: number;
230
+ };
231
+ status: string;
232
+ }[]> | Promise<{
233
+ id: number;
234
+ level: number;
235
+ nome: string;
236
+ }[]>;
237
+ }
238
+ declare const NullCoreService: CoreService;
239
+
240
+ /**
241
+ * Null Object Pattern — implementação fallback de `IObservabilityPort`.
242
+ * Apenas loga no console; substitua pela implementação real (Datadog/Sentry/Grafana)
243
+ * via `CoreServiceBuilder.withObservability()` no host.
244
+ */
245
+ declare class NullObservabilityAdapter implements IObservabilityPort {
246
+ trackInteraction(payload: InteractionPayload): void;
247
+ captureVitals(payload: VitalsPayload): void;
248
+ logBreadcrumb(payload: BreadcrumbPayload): void;
249
+ }
250
+
251
+ /**
252
+ * Decorator de HTTP que implementa Distributed Tracing via W3C TraceContext.
253
+ *
254
+ * - Gera um `trace-id` único por instância (cobre todos os spans de um contexto/controller).
255
+ * - Gera um `span-id` único por requisição HTTP.
256
+ * - Injeta o header `traceparent` em todas as chamadas: GET, POST, PUT, PATCH, DELETE, etc.
257
+ * - Mesclado com quaisquer `extraHeaders` já presentes na chamada.
258
+ *
259
+ * Uso via CoreServiceBuilder:
260
+ * ```ts
261
+ * new CoreServiceBuilder()
262
+ * .withHttpEndpoint(process.env.REACT_APP_END_POINT)
263
+ * .withTracing()
264
+ * .build()
265
+ * ```
266
+ */
267
+ declare class TracingHttpAdapter implements HttpController {
268
+ private readonly endpoint;
269
+ private readonly extraHeaders?;
270
+ /** Identificador único desta cadeia de spans — compartilhado por todas as reqs do controller. */
271
+ private readonly traceId;
272
+ constructor(endpoint: string, extraHeaders?: Record<string, string> | undefined);
273
+ private mergeHeaders;
274
+ private request;
275
+ get(path?: string): Promise<any>;
276
+ post(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
277
+ put(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
278
+ patch(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
279
+ delete(path?: string, id?: string | number, extraHeaders?: Record<string, string>): Promise<any>;
280
+ deleteSimple(path?: string, extraHeaders?: Record<string, string>): Promise<any>;
281
+ save(path?: string, data?: any, extraHeaders?: Record<string, string>): Promise<any>;
282
+ read(path?: string, id?: string | number, extraHeaders?: Record<string, string>): Promise<any>;
283
+ readAll(path?: string, extraHeaders?: Record<string, string>): Promise<any>;
284
+ readAllwithPage(path?: string): Promise<any>;
285
+ bulkDelete(path?: string, ids?: (string | number)[], extraHeaders?: Record<string, string>): Promise<any>;
286
+ }
287
+
39
288
  declare function useCoreService(): CoreService;
40
289
 
41
290
  declare function useHttpController(context: string, baseEndPoint?: string): HttpController;
@@ -80,6 +329,16 @@ interface NavigatorConfig {
80
329
  */
81
330
  declare function useNavigator(config: NavigatorConfig): NavigateFn;
82
331
 
332
+ /**
333
+ * Atalho para acessar o Port de observabilidade via React context.
334
+ * Retorna a implementação real (quando fornecida pelo host) ou o NullObservabilityAdapter.
335
+ *
336
+ * @example
337
+ * const obs = useObservability()
338
+ * obs.logBreadcrumb({ category: 'action', message: 'Solicitação aprovada', data: { id } })
339
+ */
340
+ declare function useObservability(): IObservabilityPort;
341
+
83
342
  interface FetchDataReturn<T = any> {
84
343
  data: T | null;
85
344
  loading: boolean;
@@ -198,6 +457,36 @@ declare const _default: redux.Reducer<PickerState>;
198
457
 
199
458
  declare function pickTextColorBasedOnBgColorAdvanced(bgColor: string, lightColor: string, darkColor: string): string;
200
459
 
460
+ /**
461
+ * Instala PerformanceObserver para LCP e CLS automaticamente no bootstrap do módulo.
462
+ * Fallback silencioso em ambientes que não suportam a API (Node, browsers antigos).
463
+ *
464
+ * @param observability - Implementação de IObservabilityPort para receber as métricas.
465
+ */
466
+ declare function initWebVitals(observability: IObservabilityPort): void;
467
+
468
+ /**
469
+ * Utilitários de Distributed Tracing seguindo a especificação W3C TraceContext.
470
+ * https://www.w3.org/TR/trace-context/
471
+ */
472
+ /**
473
+ * Gera um trace-id de 128 bits (32 chars hex) conforme W3C TraceContext.
474
+ * Usado uma vez por instância de adapter — identifica toda a cadeia de spans de um contexto.
475
+ */
476
+ declare function generateTraceId(): string;
477
+ /**
478
+ * Gera um span-id de 64 bits (16 chars hex) conforme W3C TraceContext.
479
+ * Chamado a cada requisição HTTP — identifica um span individual.
480
+ */
481
+ declare function generateSpanId(): string;
482
+ /**
483
+ * Monta o header `traceparent` no formato W3C:
484
+ * `{version}-{traceId}-{spanId}-{flags}`
485
+ *
486
+ * Flags: `01` = sampled (enviado ao coletor), `00` = não-amostrado.
487
+ */
488
+ declare function buildTraceparent(traceId: string, spanId: string, sampled?: boolean): string;
489
+
201
490
  /**
202
491
  * Formats a date for display in Brazilian format.
203
492
  * Corresponds to the duplicated dateUtils.js in SGM/SGP/Services/default/.
@@ -219,4 +508,4 @@ declare function removeAccents(str: string): string;
219
508
  declare function slugify(str: string): string;
220
509
  declare function isBlank(str: string | null | undefined): boolean;
221
510
 
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 };
511
+ 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 };