teraprox-core-sdk 0.3.5 → 0.3.7

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.mts CHANGED
@@ -58,7 +58,8 @@ declare const CoreServiceContext: React.Context<CoreService | null>;
58
58
 
59
59
  declare class FetchHttpAdapter implements HttpController {
60
60
  private endpoint;
61
- constructor(endpoint: string);
61
+ private extraHeaders?;
62
+ constructor(endpoint: string, extraHeaders?: Record<string, string> | undefined);
62
63
  private request;
63
64
  get(path?: string): Promise<any>;
64
65
  post(path?: string, data?: any): Promise<any>;
@@ -101,17 +102,160 @@ declare class NullToastService implements ToastService {
101
102
  }
102
103
  declare class NullHttpController implements HttpController {
103
104
  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[]>;
105
+ get(path?: string): Promise<{
106
+ id: number;
107
+ branchLevel: {
108
+ level: number;
109
+ nome: string;
110
+ color: string;
111
+ };
112
+ nomeRecurso: string;
113
+ branchNodes: never[];
114
+ }[]> | Promise<{
115
+ id: number;
116
+ level: number;
117
+ nome: string;
118
+ }[]>;
119
+ post(path?: string): Promise<{
120
+ id: number;
121
+ branchLevel: {
122
+ level: number;
123
+ nome: string;
124
+ color: string;
125
+ };
126
+ nomeRecurso: string;
127
+ branchNodes: never[];
128
+ }[]> | Promise<{
129
+ id: number;
130
+ level: number;
131
+ nome: string;
132
+ }[]>;
133
+ put(path?: string): Promise<{
134
+ id: number;
135
+ branchLevel: {
136
+ level: number;
137
+ nome: string;
138
+ color: string;
139
+ };
140
+ nomeRecurso: string;
141
+ branchNodes: never[];
142
+ }[]> | Promise<{
143
+ id: number;
144
+ level: number;
145
+ nome: string;
146
+ }[]>;
147
+ patch(path?: string): Promise<{
148
+ id: number;
149
+ branchLevel: {
150
+ level: number;
151
+ nome: string;
152
+ color: string;
153
+ };
154
+ nomeRecurso: string;
155
+ branchNodes: never[];
156
+ }[]> | Promise<{
157
+ id: number;
158
+ level: number;
159
+ nome: string;
160
+ }[]>;
161
+ delete(path?: string, id?: string | number): Promise<{
162
+ id: number;
163
+ branchLevel: {
164
+ level: number;
165
+ nome: string;
166
+ color: string;
167
+ };
168
+ nomeRecurso: string;
169
+ branchNodes: never[];
170
+ }[]> | Promise<{
171
+ id: number;
172
+ level: number;
173
+ nome: string;
174
+ }[]>;
175
+ deleteSimple(path?: string): Promise<{
176
+ id: number;
177
+ branchLevel: {
178
+ level: number;
179
+ nome: string;
180
+ color: string;
181
+ };
182
+ nomeRecurso: string;
183
+ branchNodes: never[];
184
+ }[]> | Promise<{
185
+ id: number;
186
+ level: number;
187
+ nome: string;
188
+ }[]>;
189
+ save(path?: string): Promise<{
190
+ id: number;
191
+ branchLevel: {
192
+ level: number;
193
+ nome: string;
194
+ color: string;
195
+ };
196
+ nomeRecurso: string;
197
+ branchNodes: never[];
198
+ }[]> | Promise<{
199
+ id: number;
200
+ level: number;
201
+ nome: string;
202
+ }[]>;
203
+ read(path?: string, id?: string | number): Promise<{
204
+ id: number;
205
+ branchLevel: {
206
+ level: number;
207
+ nome: string;
208
+ color: string;
209
+ };
210
+ nomeRecurso: string;
211
+ branchNodes: never[];
212
+ }[]> | Promise<{
213
+ id: number;
214
+ level: number;
215
+ nome: string;
216
+ }[]>;
217
+ readAll(path?: string): Promise<{
218
+ id: number;
219
+ branchLevel: {
220
+ level: number;
221
+ nome: string;
222
+ color: string;
223
+ };
224
+ nomeRecurso: string;
225
+ branchNodes: never[];
226
+ }[]> | Promise<{
227
+ id: number;
228
+ level: number;
229
+ nome: string;
230
+ }[]>;
231
+ readAllwithPage(path?: string): Promise<{
232
+ id: number;
233
+ branchLevel: {
234
+ level: number;
235
+ nome: string;
236
+ color: string;
237
+ };
238
+ nomeRecurso: string;
239
+ branchNodes: never[];
240
+ }[]> | Promise<{
241
+ id: number;
242
+ level: number;
243
+ nome: string;
244
+ }[]>;
245
+ bulkDelete(path?: string): Promise<{
246
+ id: number;
247
+ branchLevel: {
248
+ level: number;
249
+ nome: string;
250
+ color: string;
251
+ };
252
+ nomeRecurso: string;
253
+ branchNodes: never[];
254
+ }[]> | Promise<{
255
+ id: number;
256
+ level: number;
257
+ nome: string;
258
+ }[]>;
115
259
  }
116
260
  declare const NullCoreService: CoreService;
117
261
 
@@ -144,9 +288,10 @@ declare class NullObservabilityAdapter implements IObservabilityPort {
144
288
  */
145
289
  declare class TracingHttpAdapter implements HttpController {
146
290
  private readonly endpoint;
291
+ private readonly extraHeaders?;
147
292
  /** Identificador único desta cadeia de spans — compartilhado por todas as reqs do controller. */
148
293
  private readonly traceId;
149
- constructor(endpoint: string);
294
+ constructor(endpoint: string, extraHeaders?: Record<string, string> | undefined);
150
295
  private mergeHeaders;
151
296
  private request;
152
297
  get(path?: string): Promise<any>;
package/dist/index.d.ts CHANGED
@@ -58,7 +58,8 @@ declare const CoreServiceContext: React.Context<CoreService | null>;
58
58
 
59
59
  declare class FetchHttpAdapter implements HttpController {
60
60
  private endpoint;
61
- constructor(endpoint: string);
61
+ private extraHeaders?;
62
+ constructor(endpoint: string, extraHeaders?: Record<string, string> | undefined);
62
63
  private request;
63
64
  get(path?: string): Promise<any>;
64
65
  post(path?: string, data?: any): Promise<any>;
@@ -101,17 +102,160 @@ declare class NullToastService implements ToastService {
101
102
  }
102
103
  declare class NullHttpController implements HttpController {
103
104
  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[]>;
105
+ get(path?: string): Promise<{
106
+ id: number;
107
+ branchLevel: {
108
+ level: number;
109
+ nome: string;
110
+ color: string;
111
+ };
112
+ nomeRecurso: string;
113
+ branchNodes: never[];
114
+ }[]> | Promise<{
115
+ id: number;
116
+ level: number;
117
+ nome: string;
118
+ }[]>;
119
+ post(path?: string): Promise<{
120
+ id: number;
121
+ branchLevel: {
122
+ level: number;
123
+ nome: string;
124
+ color: string;
125
+ };
126
+ nomeRecurso: string;
127
+ branchNodes: never[];
128
+ }[]> | Promise<{
129
+ id: number;
130
+ level: number;
131
+ nome: string;
132
+ }[]>;
133
+ put(path?: string): Promise<{
134
+ id: number;
135
+ branchLevel: {
136
+ level: number;
137
+ nome: string;
138
+ color: string;
139
+ };
140
+ nomeRecurso: string;
141
+ branchNodes: never[];
142
+ }[]> | Promise<{
143
+ id: number;
144
+ level: number;
145
+ nome: string;
146
+ }[]>;
147
+ patch(path?: string): Promise<{
148
+ id: number;
149
+ branchLevel: {
150
+ level: number;
151
+ nome: string;
152
+ color: string;
153
+ };
154
+ nomeRecurso: string;
155
+ branchNodes: never[];
156
+ }[]> | Promise<{
157
+ id: number;
158
+ level: number;
159
+ nome: string;
160
+ }[]>;
161
+ delete(path?: string, id?: string | number): Promise<{
162
+ id: number;
163
+ branchLevel: {
164
+ level: number;
165
+ nome: string;
166
+ color: string;
167
+ };
168
+ nomeRecurso: string;
169
+ branchNodes: never[];
170
+ }[]> | Promise<{
171
+ id: number;
172
+ level: number;
173
+ nome: string;
174
+ }[]>;
175
+ deleteSimple(path?: string): Promise<{
176
+ id: number;
177
+ branchLevel: {
178
+ level: number;
179
+ nome: string;
180
+ color: string;
181
+ };
182
+ nomeRecurso: string;
183
+ branchNodes: never[];
184
+ }[]> | Promise<{
185
+ id: number;
186
+ level: number;
187
+ nome: string;
188
+ }[]>;
189
+ save(path?: string): Promise<{
190
+ id: number;
191
+ branchLevel: {
192
+ level: number;
193
+ nome: string;
194
+ color: string;
195
+ };
196
+ nomeRecurso: string;
197
+ branchNodes: never[];
198
+ }[]> | Promise<{
199
+ id: number;
200
+ level: number;
201
+ nome: string;
202
+ }[]>;
203
+ read(path?: string, id?: string | number): Promise<{
204
+ id: number;
205
+ branchLevel: {
206
+ level: number;
207
+ nome: string;
208
+ color: string;
209
+ };
210
+ nomeRecurso: string;
211
+ branchNodes: never[];
212
+ }[]> | Promise<{
213
+ id: number;
214
+ level: number;
215
+ nome: string;
216
+ }[]>;
217
+ readAll(path?: string): Promise<{
218
+ id: number;
219
+ branchLevel: {
220
+ level: number;
221
+ nome: string;
222
+ color: string;
223
+ };
224
+ nomeRecurso: string;
225
+ branchNodes: never[];
226
+ }[]> | Promise<{
227
+ id: number;
228
+ level: number;
229
+ nome: string;
230
+ }[]>;
231
+ readAllwithPage(path?: string): Promise<{
232
+ id: number;
233
+ branchLevel: {
234
+ level: number;
235
+ nome: string;
236
+ color: string;
237
+ };
238
+ nomeRecurso: string;
239
+ branchNodes: never[];
240
+ }[]> | Promise<{
241
+ id: number;
242
+ level: number;
243
+ nome: string;
244
+ }[]>;
245
+ bulkDelete(path?: string): Promise<{
246
+ id: number;
247
+ branchLevel: {
248
+ level: number;
249
+ nome: string;
250
+ color: string;
251
+ };
252
+ nomeRecurso: string;
253
+ branchNodes: never[];
254
+ }[]> | Promise<{
255
+ id: number;
256
+ level: number;
257
+ nome: string;
258
+ }[]>;
115
259
  }
116
260
  declare const NullCoreService: CoreService;
117
261
 
@@ -144,9 +288,10 @@ declare class NullObservabilityAdapter implements IObservabilityPort {
144
288
  */
145
289
  declare class TracingHttpAdapter implements HttpController {
146
290
  private readonly endpoint;
291
+ private readonly extraHeaders?;
147
292
  /** Identificador único desta cadeia de spans — compartilhado por todas as reqs do controller. */
148
293
  private readonly traceId;
149
- constructor(endpoint: string);
294
+ constructor(endpoint: string, extraHeaders?: Record<string, string> | undefined);
150
295
  private mergeHeaders;
151
296
  private request;
152
297
  get(path?: string): Promise<any>;
package/dist/index.js CHANGED
@@ -128,49 +128,71 @@ var NullToastService = class {
128
128
  }
129
129
  };
130
130
  var NullHttpController = class {
131
- logAndResolve(method, path) {
132
- console.warn(`[Http Fallback] MOCK ${method} requisitado para ${path} (Nenhum adapter injetado)`);
131
+ logAndResolve(method, path, context) {
132
+ console.warn(`[Http Fallback] MOCK ${method} requisitado para ${path} (Contexto: ${context})`);
133
+ if (process.env.NODE_ENV !== "production") {
134
+ if (context === "arvoreEstrutural" && path && path.includes("branchByBranchLevel")) {
135
+ return Promise.resolve([
136
+ {
137
+ id: 1,
138
+ branchLevel: { level: 1, nome: "Empresa", color: "#ff0000" },
139
+ nomeRecurso: "Escolha a Empresa",
140
+ branchNodes: []
141
+ }
142
+ ]);
143
+ }
144
+ if (context === "branchLevel" && method === "READ_ALL") {
145
+ return Promise.resolve([
146
+ { id: 1, level: 1, nome: "Empresa" },
147
+ { id: 2, level: 2, nome: "Unidade" },
148
+ { id: 3, level: 3, nome: "\xC1rea" },
149
+ { id: 4, level: 4, nome: "M\xE1quina" }
150
+ ]);
151
+ }
152
+ }
133
153
  return Promise.resolve([]);
134
154
  }
135
155
  get(path) {
136
- return this.logAndResolve("GET", path);
156
+ return this.logAndResolve("GET", path, this.context);
137
157
  }
138
158
  post(path) {
139
- return this.logAndResolve("POST", path);
159
+ return this.logAndResolve("POST", path, this.context);
140
160
  }
141
161
  put(path) {
142
- return this.logAndResolve("PUT", path);
162
+ return this.logAndResolve("PUT", path, this.context);
143
163
  }
144
164
  patch(path) {
145
- return this.logAndResolve("PATCH", path);
165
+ return this.logAndResolve("PATCH", path, this.context);
146
166
  }
147
167
  delete(path, id) {
148
- return this.logAndResolve("DELETE", `${path}/${id}`);
168
+ return this.logAndResolve("DELETE", `${path}/${id}`, this.context);
149
169
  }
150
170
  deleteSimple(path) {
151
- return this.logAndResolve("DELETE", path);
171
+ return this.logAndResolve("DELETE", path, this.context);
152
172
  }
153
173
  save(path) {
154
- return this.logAndResolve("SAVE", path);
174
+ return this.logAndResolve("SAVE", path, this.context);
155
175
  }
156
176
  read(path, id) {
157
- return this.logAndResolve("READ", `${path}/${id}`);
177
+ return this.logAndResolve("READ", `${path}/${id}`, this.context);
158
178
  }
159
179
  readAll(path) {
160
- return this.logAndResolve("READ_ALL", path);
180
+ return this.logAndResolve("READ_ALL", path, this.context);
161
181
  }
162
182
  readAllwithPage(path) {
163
- return this.logAndResolve("READ_ALL_PAGE", path);
183
+ return this.logAndResolve("READ_ALL_PAGE", path, this.context);
164
184
  }
165
185
  bulkDelete(path) {
166
- return this.logAndResolve("BULK_DELETE", path);
186
+ return this.logAndResolve("BULK_DELETE", path, this.context);
167
187
  }
168
188
  };
169
189
  var NullCoreService = {
170
190
  toast: new NullToastService(),
171
191
  createController: (context) => {
172
192
  console.warn(`[CoreService Fallback] createController chamado para "${context}" sem Adapter. Usando NullHttpController.`);
173
- return new NullHttpController();
193
+ const controller = new NullHttpController();
194
+ controller.context = context;
195
+ return controller;
174
196
  },
175
197
  subscribe: (mo) => console.log(`[CoreService Fallback] Inscri\xE7\xE3o simulada RTDB: ${mo.context}`),
176
198
  unsubscribe: (mo) => console.log(`[CoreService Fallback] Desinscri\xE7\xE3o simulada RTDB: ${mo.context}`),
@@ -201,14 +223,16 @@ function buildTraceparent(traceId, spanId, sampled = true) {
201
223
 
202
224
  // src/adapters/TracingHttpAdapter.ts
203
225
  var TracingHttpAdapter = class {
204
- constructor(endpoint) {
226
+ constructor(endpoint, extraHeaders) {
205
227
  this.endpoint = endpoint;
228
+ this.extraHeaders = extraHeaders;
206
229
  this.traceId = generateTraceId();
207
230
  }
208
231
  mergeHeaders(extraHeaders, withContentType = false) {
209
232
  const spanId = generateSpanId();
210
233
  const headers = {
211
234
  traceparent: buildTraceparent(this.traceId, spanId),
235
+ ...this.extraHeaders,
212
236
  ...extraHeaders
213
237
  };
214
238
  if (withContentType && !headers["Content-Type"]) {
@@ -270,15 +294,19 @@ var TracingHttpAdapter = class {
270
294
 
271
295
  // src/factories/CoreServiceBuilder.ts
272
296
  var FetchHttpAdapter = class {
273
- constructor(endpoint) {
297
+ constructor(endpoint, extraHeaders) {
274
298
  this.endpoint = endpoint;
299
+ this.extraHeaders = extraHeaders;
275
300
  }
276
301
  async request(method, extraPath, data) {
277
302
  const url = extraPath ? `${this.endpoint}/${extraPath}` : this.endpoint;
278
303
  try {
279
304
  const res = await fetch(url, {
280
305
  method,
281
- headers: data ? { "Content-Type": "application/json" } : void 0,
306
+ headers: {
307
+ ...this.extraHeaders,
308
+ ...data ? { "Content-Type": "application/json" } : {}
309
+ },
282
310
  body: data ? JSON.stringify(data) : void 0
283
311
  });
284
312
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -365,9 +393,13 @@ var CoreServiceBuilder = class {
365
393
  const endpoint = baseEndPoint != null ? baseEndPoint : this._httpEndpoint ? `${this._httpEndpoint}/${context}` : null;
366
394
  if (!endpoint) {
367
395
  console.warn(`[CoreServiceBuilder] HttpEndpoint nulo para "${context}". Usando NullHttpController.`);
368
- return new NullHttpController();
396
+ const controller = new NullHttpController();
397
+ controller.context = context;
398
+ return controller;
369
399
  }
370
- return this._tracing ? new TracingHttpAdapter(endpoint) : new FetchHttpAdapter(endpoint);
400
+ const xTeraproxHost = context === "solicitacaoDeServico" || context === "manutencao" ? "manutencao" : context;
401
+ const extraHeaders = { "x-teraprox-host": xTeraproxHost };
402
+ return this._tracing ? new TracingHttpAdapter(endpoint, extraHeaders) : new FetchHttpAdapter(endpoint, extraHeaders);
371
403
  },
372
404
  subscribe: (mo) => {
373
405
  console.log(`[CoreServiceBuilder RTDB] Subscribe > ${mo.context}`);
@@ -826,7 +858,7 @@ var BranchDropDisplay = ({
826
858
  setMultiSelected([]);
827
859
  };
828
860
  const isLastBranchClicked = () => branches.length > 0 && branches[branches.length - 1].id === branch.id;
829
- const visibleNodes = branch.branchNodes.filter(
861
+ const visibleNodes = (branch.branchNodes || []).filter(
830
862
  (bn) => bn.recurso.nome.toLowerCase().includes(searchTerm.toLowerCase())
831
863
  );
832
864
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
package/dist/index.mjs CHANGED
@@ -23,49 +23,71 @@ var NullToastService = class {
23
23
  }
24
24
  };
25
25
  var NullHttpController = class {
26
- logAndResolve(method, path) {
27
- console.warn(`[Http Fallback] MOCK ${method} requisitado para ${path} (Nenhum adapter injetado)`);
26
+ logAndResolve(method, path, context) {
27
+ console.warn(`[Http Fallback] MOCK ${method} requisitado para ${path} (Contexto: ${context})`);
28
+ if (process.env.NODE_ENV !== "production") {
29
+ if (context === "arvoreEstrutural" && path && path.includes("branchByBranchLevel")) {
30
+ return Promise.resolve([
31
+ {
32
+ id: 1,
33
+ branchLevel: { level: 1, nome: "Empresa", color: "#ff0000" },
34
+ nomeRecurso: "Escolha a Empresa",
35
+ branchNodes: []
36
+ }
37
+ ]);
38
+ }
39
+ if (context === "branchLevel" && method === "READ_ALL") {
40
+ return Promise.resolve([
41
+ { id: 1, level: 1, nome: "Empresa" },
42
+ { id: 2, level: 2, nome: "Unidade" },
43
+ { id: 3, level: 3, nome: "\xC1rea" },
44
+ { id: 4, level: 4, nome: "M\xE1quina" }
45
+ ]);
46
+ }
47
+ }
28
48
  return Promise.resolve([]);
29
49
  }
30
50
  get(path) {
31
- return this.logAndResolve("GET", path);
51
+ return this.logAndResolve("GET", path, this.context);
32
52
  }
33
53
  post(path) {
34
- return this.logAndResolve("POST", path);
54
+ return this.logAndResolve("POST", path, this.context);
35
55
  }
36
56
  put(path) {
37
- return this.logAndResolve("PUT", path);
57
+ return this.logAndResolve("PUT", path, this.context);
38
58
  }
39
59
  patch(path) {
40
- return this.logAndResolve("PATCH", path);
60
+ return this.logAndResolve("PATCH", path, this.context);
41
61
  }
42
62
  delete(path, id) {
43
- return this.logAndResolve("DELETE", `${path}/${id}`);
63
+ return this.logAndResolve("DELETE", `${path}/${id}`, this.context);
44
64
  }
45
65
  deleteSimple(path) {
46
- return this.logAndResolve("DELETE", path);
66
+ return this.logAndResolve("DELETE", path, this.context);
47
67
  }
48
68
  save(path) {
49
- return this.logAndResolve("SAVE", path);
69
+ return this.logAndResolve("SAVE", path, this.context);
50
70
  }
51
71
  read(path, id) {
52
- return this.logAndResolve("READ", `${path}/${id}`);
72
+ return this.logAndResolve("READ", `${path}/${id}`, this.context);
53
73
  }
54
74
  readAll(path) {
55
- return this.logAndResolve("READ_ALL", path);
75
+ return this.logAndResolve("READ_ALL", path, this.context);
56
76
  }
57
77
  readAllwithPage(path) {
58
- return this.logAndResolve("READ_ALL_PAGE", path);
78
+ return this.logAndResolve("READ_ALL_PAGE", path, this.context);
59
79
  }
60
80
  bulkDelete(path) {
61
- return this.logAndResolve("BULK_DELETE", path);
81
+ return this.logAndResolve("BULK_DELETE", path, this.context);
62
82
  }
63
83
  };
64
84
  var NullCoreService = {
65
85
  toast: new NullToastService(),
66
86
  createController: (context) => {
67
87
  console.warn(`[CoreService Fallback] createController chamado para "${context}" sem Adapter. Usando NullHttpController.`);
68
- return new NullHttpController();
88
+ const controller = new NullHttpController();
89
+ controller.context = context;
90
+ return controller;
69
91
  },
70
92
  subscribe: (mo) => console.log(`[CoreService Fallback] Inscri\xE7\xE3o simulada RTDB: ${mo.context}`),
71
93
  unsubscribe: (mo) => console.log(`[CoreService Fallback] Desinscri\xE7\xE3o simulada RTDB: ${mo.context}`),
@@ -96,14 +118,16 @@ function buildTraceparent(traceId, spanId, sampled = true) {
96
118
 
97
119
  // src/adapters/TracingHttpAdapter.ts
98
120
  var TracingHttpAdapter = class {
99
- constructor(endpoint) {
121
+ constructor(endpoint, extraHeaders) {
100
122
  this.endpoint = endpoint;
123
+ this.extraHeaders = extraHeaders;
101
124
  this.traceId = generateTraceId();
102
125
  }
103
126
  mergeHeaders(extraHeaders, withContentType = false) {
104
127
  const spanId = generateSpanId();
105
128
  const headers = {
106
129
  traceparent: buildTraceparent(this.traceId, spanId),
130
+ ...this.extraHeaders,
107
131
  ...extraHeaders
108
132
  };
109
133
  if (withContentType && !headers["Content-Type"]) {
@@ -165,15 +189,19 @@ var TracingHttpAdapter = class {
165
189
 
166
190
  // src/factories/CoreServiceBuilder.ts
167
191
  var FetchHttpAdapter = class {
168
- constructor(endpoint) {
192
+ constructor(endpoint, extraHeaders) {
169
193
  this.endpoint = endpoint;
194
+ this.extraHeaders = extraHeaders;
170
195
  }
171
196
  async request(method, extraPath, data) {
172
197
  const url = extraPath ? `${this.endpoint}/${extraPath}` : this.endpoint;
173
198
  try {
174
199
  const res = await fetch(url, {
175
200
  method,
176
- headers: data ? { "Content-Type": "application/json" } : void 0,
201
+ headers: {
202
+ ...this.extraHeaders,
203
+ ...data ? { "Content-Type": "application/json" } : {}
204
+ },
177
205
  body: data ? JSON.stringify(data) : void 0
178
206
  });
179
207
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -260,9 +288,13 @@ var CoreServiceBuilder = class {
260
288
  const endpoint = baseEndPoint != null ? baseEndPoint : this._httpEndpoint ? `${this._httpEndpoint}/${context}` : null;
261
289
  if (!endpoint) {
262
290
  console.warn(`[CoreServiceBuilder] HttpEndpoint nulo para "${context}". Usando NullHttpController.`);
263
- return new NullHttpController();
291
+ const controller = new NullHttpController();
292
+ controller.context = context;
293
+ return controller;
264
294
  }
265
- return this._tracing ? new TracingHttpAdapter(endpoint) : new FetchHttpAdapter(endpoint);
295
+ const xTeraproxHost = context === "solicitacaoDeServico" || context === "manutencao" ? "manutencao" : context;
296
+ const extraHeaders = { "x-teraprox-host": xTeraproxHost };
297
+ return this._tracing ? new TracingHttpAdapter(endpoint, extraHeaders) : new FetchHttpAdapter(endpoint, extraHeaders);
266
298
  },
267
299
  subscribe: (mo) => {
268
300
  console.log(`[CoreServiceBuilder RTDB] Subscribe > ${mo.context}`);
@@ -721,7 +753,7 @@ var BranchDropDisplay = ({
721
753
  setMultiSelected([]);
722
754
  };
723
755
  const isLastBranchClicked = () => branches.length > 0 && branches[branches.length - 1].id === branch.id;
724
- const visibleNodes = branch.branchNodes.filter(
756
+ const visibleNodes = (branch.branchNodes || []).filter(
725
757
  (bn) => bn.recurso.nome.toLowerCase().includes(searchTerm.toLowerCase())
726
758
  );
727
759
  return /* @__PURE__ */ jsxs(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teraprox-core-sdk",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Contrato tipado Core ↔ Federados — interfaces, context, hooks e componentes compartilhados",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",