teraprox-core-sdk 0.3.7 → 0.3.9

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
@@ -1,4 +1,4 @@
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';
1
+ import { C as CoreService, T as ToastService, H as HttpController, I as IObservabilityPort, a as InteractionPayload, V as VitalsPayload, B as BreadcrumbPayload } from './federation-Bhx0XhSP.mjs';
2
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';
@@ -80,8 +80,12 @@ declare class CoreServiceBuilder {
80
80
  private _hostedByCore;
81
81
  private _observability;
82
82
  private _tracing;
83
+ private _gatewayHost?;
84
+ private _fallbackControllers;
83
85
  withToast(toast: ToastService): this;
84
86
  withHttpEndpoint(url: string): this;
87
+ withGatewayHost(host: string): this;
88
+ withFallbackController(context: string, controller: HttpController): this;
85
89
  withRtdbConfig(config: any): this;
86
90
  setHostedByCore(hosted: boolean): this;
87
91
  withObservability(observability: IObservabilityPort): this;
@@ -102,160 +106,17 @@ declare class NullToastService implements ToastService {
102
106
  }
103
107
  declare class NullHttpController implements HttpController {
104
108
  private logAndResolve;
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
- }[]>;
109
+ get(path?: string): Promise<any[]>;
110
+ post(path?: string): Promise<any[]>;
111
+ put(path?: string): Promise<any[]>;
112
+ patch(path?: string): Promise<any[]>;
113
+ delete(path?: string, id?: string | number): Promise<any[]>;
114
+ deleteSimple(path?: string): Promise<any[]>;
115
+ save(path?: string): Promise<any[]>;
116
+ read(path?: string, id?: string | number): Promise<any[]>;
117
+ readAll(path?: string): Promise<any[]>;
118
+ readAllwithPage(path?: string): Promise<any[]>;
119
+ bulkDelete(path?: string): Promise<any[]>;
259
120
  }
260
121
  declare const NullCoreService: CoreService;
261
122
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ import { C as CoreService, T as ToastService, H as HttpController, I as IObservabilityPort, a as InteractionPayload, V as VitalsPayload, B as BreadcrumbPayload } from './federation-Bhx0XhSP.js';
2
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';
@@ -80,8 +80,12 @@ declare class CoreServiceBuilder {
80
80
  private _hostedByCore;
81
81
  private _observability;
82
82
  private _tracing;
83
+ private _gatewayHost?;
84
+ private _fallbackControllers;
83
85
  withToast(toast: ToastService): this;
84
86
  withHttpEndpoint(url: string): this;
87
+ withGatewayHost(host: string): this;
88
+ withFallbackController(context: string, controller: HttpController): this;
85
89
  withRtdbConfig(config: any): this;
86
90
  setHostedByCore(hosted: boolean): this;
87
91
  withObservability(observability: IObservabilityPort): this;
@@ -102,160 +106,17 @@ declare class NullToastService implements ToastService {
102
106
  }
103
107
  declare class NullHttpController implements HttpController {
104
108
  private logAndResolve;
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
- }[]>;
109
+ get(path?: string): Promise<any[]>;
110
+ post(path?: string): Promise<any[]>;
111
+ put(path?: string): Promise<any[]>;
112
+ patch(path?: string): Promise<any[]>;
113
+ delete(path?: string, id?: string | number): Promise<any[]>;
114
+ deleteSimple(path?: string): Promise<any[]>;
115
+ save(path?: string): Promise<any[]>;
116
+ read(path?: string, id?: string | number): Promise<any[]>;
117
+ readAll(path?: string): Promise<any[]>;
118
+ readAllwithPage(path?: string): Promise<any[]>;
119
+ bulkDelete(path?: string): Promise<any[]>;
259
120
  }
260
121
  declare const NullCoreService: CoreService;
261
122
 
package/dist/index.js CHANGED
@@ -130,26 +130,6 @@ var NullToastService = class {
130
130
  var NullHttpController = class {
131
131
  logAndResolve(method, path, context) {
132
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
- }
153
133
  return Promise.resolve([]);
154
134
  }
155
135
  get(path) {
@@ -356,6 +336,7 @@ var CoreServiceBuilder = class {
356
336
  this._hostedByCore = false;
357
337
  this._observability = new NullObservabilityAdapter();
358
338
  this._tracing = false;
339
+ this._fallbackControllers = {};
359
340
  }
360
341
  withToast(toast) {
361
342
  this._toast = toast;
@@ -365,6 +346,14 @@ var CoreServiceBuilder = class {
365
346
  this._httpEndpoint = url;
366
347
  return this;
367
348
  }
349
+ withGatewayHost(host) {
350
+ this._gatewayHost = host;
351
+ return this;
352
+ }
353
+ withFallbackController(context, controller) {
354
+ this._fallbackControllers[context] = controller;
355
+ return this;
356
+ }
368
357
  withRtdbConfig(config) {
369
358
  this._rtdbConfig = config;
370
359
  return this;
@@ -390,6 +379,9 @@ var CoreServiceBuilder = class {
390
379
  return {
391
380
  toast: this._toast,
392
381
  createController: (context, baseEndPoint) => {
382
+ if (this._fallbackControllers[context]) {
383
+ return this._fallbackControllers[context];
384
+ }
393
385
  const endpoint = baseEndPoint != null ? baseEndPoint : this._httpEndpoint ? `${this._httpEndpoint}/${context}` : null;
394
386
  if (!endpoint) {
395
387
  console.warn(`[CoreServiceBuilder] HttpEndpoint nulo para "${context}". Usando NullHttpController.`);
@@ -397,8 +389,9 @@ var CoreServiceBuilder = class {
397
389
  controller.context = context;
398
390
  return controller;
399
391
  }
400
- const xTeraproxHost = context === "solicitacaoDeServico" || context === "manutencao" ? "manutencao" : context;
401
- const extraHeaders = { "x-teraprox-host": xTeraproxHost };
392
+ const envHost = typeof process !== "undefined" && process.env ? process.env.REACT_APP_TERAPROX_GATEWAY_HOST || process.env.VITE_TERAPROX_GATEWAY_HOST : void 0;
393
+ const hostHeader = this._gatewayHost || envHost || context;
394
+ const extraHeaders = { "x-teraprox-host": hostHeader };
402
395
  return this._tracing ? new TracingHttpAdapter(endpoint, extraHeaders) : new FetchHttpAdapter(endpoint, extraHeaders);
403
396
  },
404
397
  subscribe: (mo) => {
package/dist/index.mjs CHANGED
@@ -25,26 +25,6 @@ var NullToastService = class {
25
25
  var NullHttpController = class {
26
26
  logAndResolve(method, path, context) {
27
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
- }
48
28
  return Promise.resolve([]);
49
29
  }
50
30
  get(path) {
@@ -251,6 +231,7 @@ var CoreServiceBuilder = class {
251
231
  this._hostedByCore = false;
252
232
  this._observability = new NullObservabilityAdapter();
253
233
  this._tracing = false;
234
+ this._fallbackControllers = {};
254
235
  }
255
236
  withToast(toast) {
256
237
  this._toast = toast;
@@ -260,6 +241,14 @@ var CoreServiceBuilder = class {
260
241
  this._httpEndpoint = url;
261
242
  return this;
262
243
  }
244
+ withGatewayHost(host) {
245
+ this._gatewayHost = host;
246
+ return this;
247
+ }
248
+ withFallbackController(context, controller) {
249
+ this._fallbackControllers[context] = controller;
250
+ return this;
251
+ }
263
252
  withRtdbConfig(config) {
264
253
  this._rtdbConfig = config;
265
254
  return this;
@@ -285,6 +274,9 @@ var CoreServiceBuilder = class {
285
274
  return {
286
275
  toast: this._toast,
287
276
  createController: (context, baseEndPoint) => {
277
+ if (this._fallbackControllers[context]) {
278
+ return this._fallbackControllers[context];
279
+ }
288
280
  const endpoint = baseEndPoint != null ? baseEndPoint : this._httpEndpoint ? `${this._httpEndpoint}/${context}` : null;
289
281
  if (!endpoint) {
290
282
  console.warn(`[CoreServiceBuilder] HttpEndpoint nulo para "${context}". Usando NullHttpController.`);
@@ -292,8 +284,9 @@ var CoreServiceBuilder = class {
292
284
  controller.context = context;
293
285
  return controller;
294
286
  }
295
- const xTeraproxHost = context === "solicitacaoDeServico" || context === "manutencao" ? "manutencao" : context;
296
- const extraHeaders = { "x-teraprox-host": xTeraproxHost };
287
+ const envHost = typeof process !== "undefined" && process.env ? process.env.REACT_APP_TERAPROX_GATEWAY_HOST || process.env.VITE_TERAPROX_GATEWAY_HOST : void 0;
288
+ const hostHeader = this._gatewayHost || envHost || context;
289
+ const extraHeaders = { "x-teraprox-host": hostHeader };
297
290
  return this._tracing ? new TracingHttpAdapter(endpoint, extraHeaders) : new FetchHttpAdapter(endpoint, extraHeaders);
298
291
  },
299
292
  subscribe: (mo) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teraprox-core-sdk",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
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",
@@ -33,7 +33,8 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "qr-scanner": "^1.4.2"
36
+ "qr-scanner": "^1.4.2",
37
+ "teraprox-core-sdk": "^0.3.8"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "@reduxjs/toolkit": ">=1.9.0",