sgp-sdk 0.0.0-stage → 1.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 (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +303 -2
  3. package/dist/client.d.ts +228 -0
  4. package/dist/endpoint.d.ts +66 -0
  5. package/dist/endpoints/crm/address.d.ts +20 -0
  6. package/dist/endpoints/crm/create-contract.d.ts +109 -0
  7. package/dist/endpoints/crm/create-customer.d.ts +65 -0
  8. package/dist/endpoints/crm/update-customer-status.d.ts +43 -0
  9. package/dist/endpoints/os/list-occurrence-reasons.d.ts +24 -0
  10. package/dist/endpoints/os/list-occurrence-types.d.ts +25 -0
  11. package/dist/endpoints/precadastro/list-due-days.d.ts +19 -0
  12. package/dist/endpoints/precadastro/list-sellers.d.ts +21 -0
  13. package/dist/endpoints/suporte/add-customer-document.d.ts +24 -0
  14. package/dist/endpoints/suporte/list-customer-documents.d.ts +25 -0
  15. package/dist/endpoints/ura/check-coverage.d.ts +46 -0
  16. package/dist/endpoints/ura/list-annotations.d.ts +32 -0
  17. package/dist/endpoints/ura/list-clients.d.ts +58 -0
  18. package/dist/endpoints/ura/list-contracts.d.ts +45 -0
  19. package/dist/endpoints/ura/list-invoices.d.ts +107 -0
  20. package/dist/endpoints/ura/list-nas.d.ts +29 -0
  21. package/dist/endpoints/ura/list-occurrence-methods.d.ts +19 -0
  22. package/dist/endpoints/ura/list-payment-carriers.d.ts +20 -0
  23. package/dist/endpoints/ura/list-plans.d.ts +70 -0
  24. package/dist/endpoints/ura/list-pops.d.ts +19 -0
  25. package/dist/endpoints/ura/list-service-orders.d.ts +64 -0
  26. package/dist/endpoints/ura/lookup-customer.d.ts +121 -0
  27. package/dist/endpoints/ura/open-ticket.d.ts +81 -0
  28. package/dist/errors.d.ts +59 -0
  29. package/dist/index.d.ts +50 -0
  30. package/dist/index.js +1449 -0
  31. package/dist/result.d.ts +55 -0
  32. package/dist/schema/parse.d.ts +19 -0
  33. package/dist/schema/paths.d.ts +38 -0
  34. package/dist/sensitivity.d.ts +7 -0
  35. package/dist/transport.d.ts +65 -0
  36. package/package.json +34 -4
package/dist/index.js ADDED
@@ -0,0 +1,1449 @@
1
+ // src/errors.ts
2
+ var DETAIL_UNAUTHORIZED = "Credenciais de autenticação incorretas.";
3
+ var DETAIL_ROUTE_NOT_ALLOWED = "As credenciais de autenticação não foram fornecidas.";
4
+ var MESSAGE_WRITE_NOT_CONFIRMED = "SGP answered with a success status but the response does not confirm the write; it may have been applied.";
5
+ var MESSAGE_WRITE_FAILED_GENERICALLY = "SGP reported an error while processing the write; it may have been applied.";
6
+ var MESSAGE_REJECTED_LOCALLY = "The SDK rejected the request before sending it.";
7
+ var MESSAGES = {
8
+ UNAUTHORIZED: "SGP rejected the credentials (token or app).",
9
+ ROUTE_NOT_ALLOWED: "SGP does not allow this app to call this route.",
10
+ NOT_FOUND: "SGP resource not found.",
11
+ METHOD_NOT_ALLOWED: "SGP does not accept this HTTP method on this route.",
12
+ VALIDATION: "SGP rejected the request parameters.",
13
+ SCHEMA_MISMATCH: "SGP response does not match the expected schema.",
14
+ UPSTREAM: "SGP failed to process the request.",
15
+ TIMEOUT: "Request to SGP timed out.",
16
+ NETWORK: "Could not reach SGP.",
17
+ UNKNOWN: "Unexpected response from SGP."
18
+ };
19
+ var readErrors = (errors) => {
20
+ let parts = [];
21
+ if (Array.isArray(errors)) {
22
+ parts = errors.filter((item) => typeof item === "string");
23
+ } else if (typeof errors === "object" && errors !== null) {
24
+ parts = Object.entries(errors).flatMap(([key, value]) => typeof value === "string" ? [`${key}: ${value}`] : []);
25
+ }
26
+ const joined = parts.join("; ");
27
+ return joined === "" ? undefined : joined;
28
+ };
29
+ var readSgpDetail = (body) => {
30
+ if (typeof body !== "object" || body === null)
31
+ return;
32
+ if ("detail" in body && typeof body.detail === "string")
33
+ return body.detail;
34
+ if ("msg" in body && typeof body.msg === "string" && body.msg !== "")
35
+ return body.msg;
36
+ const fromErrors = "errors" in body ? readErrors(body.errors) : undefined;
37
+ if (fromErrors !== undefined)
38
+ return fromErrors;
39
+ return "error" in body && typeof body.error === "string" && body.error !== "" ? body.error : undefined;
40
+ };
41
+ var hasErrorList = (body) => typeof body === "object" && body !== null && ("errors" in body) && Array.isArray(body.errors);
42
+ var codeForHttpStatus = (status, detail) => {
43
+ if (status === 401 || status === 403) {
44
+ if (detail === DETAIL_UNAUTHORIZED)
45
+ return "UNAUTHORIZED";
46
+ if (detail === DETAIL_ROUTE_NOT_ALLOWED)
47
+ return "ROUTE_NOT_ALLOWED";
48
+ return "UNKNOWN";
49
+ }
50
+ if (status === 404)
51
+ return "NOT_FOUND";
52
+ if (status === 405)
53
+ return "METHOD_NOT_ALLOWED";
54
+ if (status >= 400 && status < 500)
55
+ return "VALIDATION";
56
+ if (status >= 500 && status < 600)
57
+ return "UPSTREAM";
58
+ return "UNKNOWN";
59
+ };
60
+ var createError = (code, status, endpoint, detail, message = MESSAGES[code]) => {
61
+ const error = { status, code, message, endpoint };
62
+ if (detail !== undefined)
63
+ error.detail = detail;
64
+ return error;
65
+ };
66
+ var mapHttpFailure = (status, body, endpoint) => {
67
+ const detail = readSgpDetail(body);
68
+ return createError(codeForHttpStatus(status, detail), status, endpoint, detail);
69
+ };
70
+ var mapFetchFailure = (cause, endpoint) => {
71
+ const isTimeout = cause instanceof Error && (cause.name === "TimeoutError" || cause.name === "AbortError");
72
+ return createError(isTimeout ? "TIMEOUT" : "NETWORK", 0, endpoint);
73
+ };
74
+ var EXPLICIT_REFUSALS = [401, 403, 404, 405, 422];
75
+ var toWriteError = (error, isErrorListBody = false) => {
76
+ const isRejectedLocally = error.code === "VALIDATION" && error.status === 0;
77
+ const isClientError = error.status >= 400 && error.status <= 499;
78
+ const isGenericFailure = isErrorListBody && !EXPLICIT_REFUSALS.includes(error.status);
79
+ const isRejectedBySgp = isClientError && !isGenericFailure;
80
+ return {
81
+ ...error,
82
+ ...isClientError && isGenericFailure && { message: MESSAGE_WRITE_FAILED_GENERICALLY },
83
+ outcome: isRejectedLocally || isRejectedBySgp ? "not_applied" : "unknown"
84
+ };
85
+ };
86
+
87
+ // src/schema/paths.ts
88
+ var normalizePath = (path) => path.reduce((joined, segment) => {
89
+ if (typeof segment === "number")
90
+ return `${joined}[]`;
91
+ return joined === "" ? String(segment) : `${joined}.${String(segment)}`;
92
+ }, "");
93
+ var formatPath = (path) => path.reduce((joined, segment) => {
94
+ if (typeof segment === "number")
95
+ return `${joined}[${segment}]`;
96
+ return joined === "" ? String(segment) : `${joined}.${String(segment)}`;
97
+ }, "");
98
+ var segmentsOf = (path) => path.match(/\[\]|[^.[\]]+/g) ?? [];
99
+ var isKeyPathOf = (path, keyFields) => keyFields.some((key) => {
100
+ const keySegments = segmentsOf(key);
101
+ return path.length <= keySegments.length && path.every((segment, index) => {
102
+ const keySegment = keySegments[index];
103
+ if (typeof segment === "number")
104
+ return keySegment === "[]";
105
+ return keySegment === "*" || keySegment !== "[]" && keySegment === segment;
106
+ });
107
+ });
108
+ var valueAt = (input, path) => {
109
+ let current = input;
110
+ for (const segment of path) {
111
+ if (typeof current !== "object" || current === null)
112
+ return;
113
+ current = Reflect.get(current, segment);
114
+ }
115
+ return current;
116
+ };
117
+ var typeNameAt = (input, path) => {
118
+ const value = valueAt(input, path);
119
+ if (value === null)
120
+ return "null";
121
+ if (Array.isArray(value))
122
+ return "array";
123
+ return typeof value;
124
+ };
125
+
126
+ // src/schema/parse.ts
127
+ var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
128
+ var schemaMismatch = (issues, endpoint) => {
129
+ const paths = new Set(issues.map((issue) => normalizePath(issue.path) || "(root)"));
130
+ return {
131
+ success: false,
132
+ error: createError("SCHEMA_MISMATCH", 200, endpoint, [...paths].join(", "))
133
+ };
134
+ };
135
+ var findRemovalTarget = (input, path) => {
136
+ for (let end = path.length;end > 0; end -= 1) {
137
+ if (isPlainObject(valueAt(input, path.slice(0, end - 1))))
138
+ return path.slice(0, end);
139
+ }
140
+ return;
141
+ };
142
+ var removeAt = (root, path) => {
143
+ const parent = valueAt(root, path.slice(0, -1));
144
+ const key = path.at(-1);
145
+ if (isPlainObject(parent) && key !== undefined)
146
+ Reflect.deleteProperty(parent, key);
147
+ };
148
+ var parseResponse = (schema, keyFields, input, endpoint) => {
149
+ const first = schema.safeParse(input);
150
+ if (first.success)
151
+ return { success: true, data: first.data };
152
+ const { issues } = first.error;
153
+ const pruned = structuredClone(input);
154
+ for (const issue of issues) {
155
+ const target = findRemovalTarget(input, issue.path);
156
+ if (target === undefined || isKeyPathOf(target, keyFields)) {
157
+ return schemaMismatch(issues, endpoint);
158
+ }
159
+ removeAt(pruned, target);
160
+ }
161
+ const second = schema.safeParse(pruned);
162
+ if (!second.success)
163
+ return schemaMismatch(second.error.issues, endpoint);
164
+ const warnings = issues.map((issue) => ({
165
+ path: formatPath(issue.path),
166
+ expected: issue.code === "invalid_type" ? issue.expected : issue.code,
167
+ received: typeNameAt(input, issue.path)
168
+ }));
169
+ return { success: true, data: second.data, warnings };
170
+ };
171
+
172
+ // src/transport.ts
173
+ var DEFAULT_TIMEOUT_MS = 20000;
174
+ var PLACEHOLDER = /\{([^{}]+)\}/g;
175
+ var resolvePath = (spec) => {
176
+ const pathParams = spec.pathParams ?? {};
177
+ const usedNames = new Set;
178
+ let invalidName;
179
+ const path = spec.path.replace(PLACEHOLDER, (_placeholder, name) => {
180
+ usedNames.add(name);
181
+ const value = Object.hasOwn(pathParams, name) ? pathParams[name] : undefined;
182
+ const text = value === undefined ? "" : String(value);
183
+ if (text === "" || text === "." || text === ".." || typeof value === "number" && !Number.isSafeInteger(value)) {
184
+ invalidName ??= name;
185
+ return "";
186
+ }
187
+ try {
188
+ return encodeURIComponent(text);
189
+ } catch {
190
+ invalidName ??= name;
191
+ return "";
192
+ }
193
+ });
194
+ if (invalidName !== undefined)
195
+ return { problem: `invalid path param: ${invalidName}` };
196
+ const unusedName = Object.keys(pathParams).find((name) => !usedNames.has(name));
197
+ if (unusedName !== undefined)
198
+ return { problem: `unexpected path param: ${unusedName}` };
199
+ return { path };
200
+ };
201
+ var definedParams = (params) => {
202
+ const defined = {};
203
+ for (const [key, value] of Object.entries(params ?? {})) {
204
+ if (value !== undefined)
205
+ defined[key] = value;
206
+ }
207
+ return defined;
208
+ };
209
+ var isPrimitive = (value) => typeof value !== "object" || value === null;
210
+ var endpointUrl = (config, path) => `${config.baseUrl.replace(/\/+$/, "")}${path}`;
211
+ var rejectedLocally = (problem, endpoint) => ({
212
+ ok: false,
213
+ error: createError("VALIDATION", 0, endpoint, problem, MESSAGE_REJECTED_LOCALLY)
214
+ });
215
+ var buildGetUrl = (config, spec, path) => {
216
+ const query = new URLSearchParams;
217
+ for (const [key, value] of Object.entries(definedParams(spec.params))) {
218
+ query.set(key, String(value));
219
+ }
220
+ query.set("token", config.token);
221
+ query.set("app", config.app);
222
+ return `${endpointUrl(config, path)}?${query.toString()}`;
223
+ };
224
+ var buildJsonBody = (config, spec) => JSON.stringify({ ...definedParams(spec.params), token: config.token, app: config.app });
225
+ var buildMultipartBody = (config, spec, files) => {
226
+ const form = new FormData;
227
+ for (const [key, value] of Object.entries(definedParams(spec.params))) {
228
+ form.append(key, isPrimitive(value) ? String(value) : JSON.stringify(value));
229
+ }
230
+ form.set("token", config.token);
231
+ form.set("app", config.app);
232
+ for (const [field, file] of Object.entries(files)) {
233
+ const type = file.contentType ?? (file.data instanceof Blob ? file.data.type : undefined);
234
+ form.append(field, new Blob([file.data], { type }), file.filename);
235
+ }
236
+ return form;
237
+ };
238
+ var buildInit = (config, spec, signal) => {
239
+ if (spec.method === "GET")
240
+ return { method: "GET", redirect: "manual", signal };
241
+ if (spec.files !== undefined) {
242
+ return {
243
+ method: spec.method,
244
+ body: buildMultipartBody(config, spec, spec.files),
245
+ redirect: "manual",
246
+ signal
247
+ };
248
+ }
249
+ return {
250
+ method: spec.method,
251
+ headers: { "content-type": "application/json" },
252
+ body: buildJsonBody(config, spec),
253
+ redirect: "manual",
254
+ signal
255
+ };
256
+ };
257
+ var parseJson = (text) => {
258
+ try {
259
+ return { isJson: true, value: JSON.parse(text) };
260
+ } catch {
261
+ return { isJson: false };
262
+ }
263
+ };
264
+ var sendRequest = async (config, spec) => {
265
+ const resolved = resolvePath(spec);
266
+ if ("problem" in resolved)
267
+ return rejectedLocally(resolved.problem, spec.path);
268
+ const structuredName = spec.method === "GET" ? Object.entries(definedParams(spec.params)).find(([, value]) => !isPrimitive(value))?.[0] : undefined;
269
+ if (structuredName !== undefined) {
270
+ return rejectedLocally(`structured value in GET param: ${structuredName}`, spec.path);
271
+ }
272
+ const { path } = resolved;
273
+ const fetchImpl = config.fetch ?? fetch;
274
+ const signal = AbortSignal.timeout(config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
275
+ let status;
276
+ let text;
277
+ try {
278
+ const url = spec.method === "GET" ? buildGetUrl(config, spec, path) : endpointUrl(config, path);
279
+ const response = await fetchImpl(url, buildInit(config, spec, signal));
280
+ status = response.status;
281
+ text = await response.text();
282
+ } catch (cause) {
283
+ return { ok: false, error: mapFetchFailure(cause, spec.path) };
284
+ }
285
+ if (status >= 200 && status < 300) {
286
+ if (text.trim() === "")
287
+ return { ok: true, body: null, status };
288
+ const parsed2 = parseJson(text);
289
+ if (!parsed2.isJson)
290
+ return { ok: false, error: createError("SCHEMA_MISMATCH", status, spec.path) };
291
+ return { ok: true, body: parsed2.value, status };
292
+ }
293
+ const parsed = parseJson(text);
294
+ const body = parsed.isJson ? parsed.value : undefined;
295
+ return {
296
+ ok: false,
297
+ error: mapHttpFailure(status, body, spec.path),
298
+ hasErrorList: hasErrorList(body)
299
+ };
300
+ };
301
+
302
+ // src/endpoint.ts
303
+ var callEndpoint = async (config, def, params, pathParams) => {
304
+ const raw = await sendRequest(config, { method: def.method, path: def.path, params, pathParams });
305
+ if (!raw.ok)
306
+ return { success: false, error: raw.error };
307
+ return parseResponse(def.schema, def.keyFields, raw.body, def.path);
308
+ };
309
+ var unconfirmedWrite = (status, endpoint, detail) => ({
310
+ ...createError("VALIDATION", status, endpoint, detail, MESSAGE_WRITE_NOT_CONFIRMED),
311
+ outcome: "unknown"
312
+ });
313
+ var callWriteEndpoint = async (config, def, call) => {
314
+ const raw = await sendRequest(config, {
315
+ method: def.method,
316
+ path: def.path,
317
+ pathParams: call?.pathParams,
318
+ params: call?.params,
319
+ files: call?.files
320
+ });
321
+ if (!raw.ok) {
322
+ const { error } = raw;
323
+ const isUnreadable2xx = error.code === "SCHEMA_MISMATCH" && error.status >= 200 && error.status < 300;
324
+ return {
325
+ success: false,
326
+ error: isUnreadable2xx ? unconfirmedWrite(error.status, def.path) : toWriteError(error, raw.hasErrorList)
327
+ };
328
+ }
329
+ const parsed = parseResponse(def.schema, def.keyFields, raw.body, def.path);
330
+ if (parsed.success)
331
+ return parsed;
332
+ return {
333
+ success: false,
334
+ error: unconfirmedWrite(raw.status, def.path, readSgpDetail(raw.body) ?? parsed.error.detail)
335
+ };
336
+ };
337
+
338
+ // src/endpoints/crm/create-contract.ts
339
+ import { z } from "zod";
340
+
341
+ // src/endpoints/crm/address.ts
342
+ var flatAddress = (address) => {
343
+ const flat = {};
344
+ for (const [key, value] of Object.entries(address)) {
345
+ if (value !== undefined)
346
+ flat[key] = value;
347
+ }
348
+ return flat;
349
+ };
350
+
351
+ // src/endpoints/crm/create-contract.ts
352
+ var formaCobrancaCodigo = {
353
+ boleto: 1,
354
+ debitoAutomatico: 2,
355
+ carne: 3,
356
+ cobrancaRecorrente: 4,
357
+ pix: 6
358
+ };
359
+ var modoAquisicao = { proprio: 0, comodato: 1 };
360
+ var createContractSchema = z.object({
361
+ message: z.string().optional().nullable(),
362
+ clientecontrato: z.number(),
363
+ cliente: z.string().optional().nullable()
364
+ });
365
+ var createContractKeyFields = ["clientecontrato"];
366
+ var contractCreatedItemPath = "";
367
+ var contractCreatedSecretKeys = [];
368
+ var contractCreatedPersonalKeys = ["cliente"];
369
+ var toContractBody = (params) => ({
370
+ ...params,
371
+ endereco_instalacao: flatAddress(params.endereco_instalacao),
372
+ endereco_cobranca: flatAddress(params.endereco_cobranca),
373
+ ...flatAddress(params.endereco_instalacao)
374
+ });
375
+ var createContractDefinition = {
376
+ kind: "write",
377
+ method: "POST",
378
+ path: "/api/crm/cliente/{cliente_id}/contratos/",
379
+ schema: createContractSchema,
380
+ keyFields: createContractKeyFields,
381
+ itemPath: contractCreatedItemPath,
382
+ secretKeys: contractCreatedSecretKeys,
383
+ personalKeys: contractCreatedPersonalKeys
384
+ };
385
+
386
+ // src/endpoints/crm/create-customer.ts
387
+ import { z as z2 } from "zod";
388
+ var createCustomerSchema = z2.object({
389
+ cliente_id: z2.number(),
390
+ message: z2.string().optional().nullable()
391
+ });
392
+ var createCustomerKeyFields = ["cliente_id"];
393
+ var customerCreatedItemPath = "";
394
+ var customerCreatedSecretKeys = [];
395
+ var customerCreatedPersonalKeys = ["message"];
396
+ var toCustomerBody = (params) => ({
397
+ ...params,
398
+ endereco: flatAddress(params.endereco),
399
+ ...flatAddress(params.endereco)
400
+ });
401
+ var createIndividualCustomerDefinition = {
402
+ kind: "write",
403
+ method: "POST",
404
+ path: "/api/crm/cliente/F",
405
+ schema: createCustomerSchema,
406
+ keyFields: createCustomerKeyFields,
407
+ itemPath: customerCreatedItemPath,
408
+ secretKeys: customerCreatedSecretKeys,
409
+ personalKeys: customerCreatedPersonalKeys
410
+ };
411
+ var createCompanyCustomerDefinition = {
412
+ kind: "write",
413
+ method: "POST",
414
+ path: "/api/crm/cliente/J",
415
+ schema: createCustomerSchema,
416
+ keyFields: createCustomerKeyFields,
417
+ itemPath: customerCreatedItemPath,
418
+ secretKeys: customerCreatedSecretKeys,
419
+ personalKeys: customerCreatedPersonalKeys
420
+ };
421
+
422
+ // src/endpoints/crm/update-customer-status.ts
423
+ import { z as z3 } from "zod";
424
+ var crmStatus = {
425
+ emAnalise: 1,
426
+ aprovado: 2,
427
+ reprovado: 3,
428
+ aguardandoContato: 4,
429
+ tentandoContato: 5,
430
+ contratoRealizadoNoSgp: 6,
431
+ inviabilidadeTecnica: 7,
432
+ contratoEmProspeccao: 8,
433
+ reprovadoSpcSerasa: 9,
434
+ analiseViabilidadeTecnica: 10
435
+ };
436
+ var updateCustomerStatusSchema = z3.object({
437
+ cliente_id: z3.number(),
438
+ message: z3.string().optional().nullable(),
439
+ novo_status: z3.object({
440
+ codigo: z3.number(),
441
+ descricao: z3.string().optional().nullable()
442
+ })
443
+ });
444
+ var updateCustomerStatusKeyFields = ["cliente_id", "novo_status.codigo"];
445
+ var customerStatusItemPath = "";
446
+ var customerStatusSecretKeys = [];
447
+ var customerStatusPersonalKeys = ["message"];
448
+ var updateCustomerStatusDefinition = {
449
+ kind: "write",
450
+ method: "POST",
451
+ path: "/api/crm/cliente/{cliente_id}/status/",
452
+ schema: updateCustomerStatusSchema,
453
+ keyFields: updateCustomerStatusKeyFields,
454
+ itemPath: customerStatusItemPath,
455
+ secretKeys: customerStatusSecretKeys,
456
+ personalKeys: customerStatusPersonalKeys
457
+ };
458
+
459
+ // src/endpoints/os/list-occurrence-reasons.ts
460
+ import { z as z4 } from "zod";
461
+ var occurrenceReasonSchema = z4.object({
462
+ id: z4.number(),
463
+ codigo: z4.number(),
464
+ descricao: z4.string(),
465
+ ativo: z4.boolean(),
466
+ classificacoes: z4.array(z4.object({})).optional().nullable(),
467
+ classificacoes_obrigatorio: z4.boolean().optional().nullable(),
468
+ setores: z4.array(z4.object({})).optional().nullable()
469
+ });
470
+ var listOccurrenceReasonsSchema = z4.array(occurrenceReasonSchema);
471
+ var listOccurrenceReasonsKeyFields = [
472
+ "[].id",
473
+ "[].codigo",
474
+ "[].descricao",
475
+ "[].ativo"
476
+ ];
477
+ var occurrenceReasonItemPath = "[]";
478
+ var occurrenceReasonSecretKeys = [];
479
+ var occurrenceReasonPersonalKeys = [];
480
+ var listOccurrenceReasonsDefinition = {
481
+ method: "GET",
482
+ path: "/api/os/ocorrencia/motivo/list/",
483
+ schema: listOccurrenceReasonsSchema,
484
+ keyFields: listOccurrenceReasonsKeyFields,
485
+ itemPath: occurrenceReasonItemPath,
486
+ secretKeys: occurrenceReasonSecretKeys,
487
+ personalKeys: occurrenceReasonPersonalKeys
488
+ };
489
+
490
+ // src/endpoints/os/list-occurrence-types.ts
491
+ import { z as z5 } from "zod";
492
+ var occurrenceTypeSchema = z5.object({
493
+ id: z5.number(),
494
+ codigo: z5.number(),
495
+ descricao: z5.string(),
496
+ ativo: z5.boolean(),
497
+ classificacoes: z5.array(z5.object({})).optional().nullable(),
498
+ classificacoes_obrigatorio: z5.boolean().optional().nullable(),
499
+ setores: z5.array(z5.object({})).optional().nullable(),
500
+ classificacoes_obrigatorio_encerramento: z5.boolean().optional().nullable()
501
+ });
502
+ var listOccurrenceTypesSchema = z5.array(occurrenceTypeSchema);
503
+ var listOccurrenceTypesKeyFields = [
504
+ "[].id",
505
+ "[].codigo",
506
+ "[].descricao",
507
+ "[].ativo"
508
+ ];
509
+ var occurrenceTypeItemPath = "[]";
510
+ var occurrenceTypeSecretKeys = [];
511
+ var occurrenceTypePersonalKeys = [];
512
+ var listOccurrenceTypesDefinition = {
513
+ method: "GET",
514
+ path: "/api/os/ocorrencia/tipo/list/",
515
+ schema: listOccurrenceTypesSchema,
516
+ keyFields: listOccurrenceTypesKeyFields,
517
+ itemPath: occurrenceTypeItemPath,
518
+ secretKeys: occurrenceTypeSecretKeys,
519
+ personalKeys: occurrenceTypePersonalKeys
520
+ };
521
+
522
+ // src/endpoints/precadastro/list-due-days.ts
523
+ import { z as z6 } from "zod";
524
+ var dueDaySchema = z6.object({
525
+ id: z6.number(),
526
+ dia: z6.number()
527
+ });
528
+ var listDueDaysSchema = z6.array(dueDaySchema);
529
+ var listDueDaysKeyFields = ["[].id", "[].dia"];
530
+ var dueDayItemPath = "[]";
531
+ var dueDaySecretKeys = [];
532
+ var dueDayPersonalKeys = [];
533
+ var listDueDaysDefinition = {
534
+ method: "POST",
535
+ path: "/api/precadastro/vencimento/list",
536
+ schema: listDueDaysSchema,
537
+ keyFields: listDueDaysKeyFields,
538
+ itemPath: dueDayItemPath,
539
+ secretKeys: dueDaySecretKeys,
540
+ personalKeys: dueDayPersonalKeys
541
+ };
542
+
543
+ // src/endpoints/precadastro/list-sellers.ts
544
+ import { z as z7 } from "zod";
545
+ var sellerSchema = z7.object({
546
+ id: z7.number(),
547
+ nome: z7.string(),
548
+ cpf: z7.string().optional().nullable(),
549
+ email: z7.string().optional().nullable()
550
+ });
551
+ var listSellersSchema = z7.array(sellerSchema);
552
+ var listSellersKeyFields = ["[].id", "[].nome"];
553
+ var sellerItemPath = "[]";
554
+ var sellerSecretKeys = [];
555
+ var sellerPersonalKeys = ["nome", "cpf", "email"];
556
+ var listSellersDefinition = {
557
+ method: "POST",
558
+ path: "/api/precadastro/vendedor/list",
559
+ schema: listSellersSchema,
560
+ keyFields: listSellersKeyFields,
561
+ itemPath: sellerItemPath,
562
+ secretKeys: sellerSecretKeys,
563
+ personalKeys: sellerPersonalKeys
564
+ };
565
+
566
+ // src/endpoints/suporte/add-customer-document.ts
567
+ import { z as z8 } from "zod";
568
+ var addCustomerDocumentSchema = z8.null();
569
+ var addCustomerDocumentKeyFields = [];
570
+ var customerDocumentAddedItemPath = "";
571
+ var customerDocumentAddedSecretKeys = [];
572
+ var customerDocumentAddedPersonalKeys = [];
573
+ var addCustomerDocumentDefinition = {
574
+ kind: "write",
575
+ method: "PUT",
576
+ path: "/api/suporte/cliente/{cliente_id}/documento/add/",
577
+ schema: addCustomerDocumentSchema,
578
+ keyFields: addCustomerDocumentKeyFields,
579
+ itemPath: customerDocumentAddedItemPath,
580
+ secretKeys: customerDocumentAddedSecretKeys,
581
+ personalKeys: customerDocumentAddedPersonalKeys
582
+ };
583
+
584
+ // src/endpoints/suporte/list-customer-documents.ts
585
+ import { z as z9 } from "zod";
586
+ var customerDocumentSchema = z9.object({
587
+ id: z9.number(),
588
+ cliente_id: z9.number(),
589
+ arquivo: z9.string().optional().nullable(),
590
+ descricao: z9.string().optional().nullable(),
591
+ usuario: z9.string().optional().nullable()
592
+ });
593
+ var listCustomerDocumentsSchema = z9.array(customerDocumentSchema);
594
+ var listCustomerDocumentsKeyFields = ["[].id", "[].cliente_id"];
595
+ var customerDocumentItemPath = "[]";
596
+ var customerDocumentSecretKeys = [];
597
+ var customerDocumentPersonalKeys = ["arquivo", "descricao", "usuario"];
598
+ var listCustomerDocumentsDefinition = {
599
+ method: "GET",
600
+ path: "/api/suporte/cliente/{cliente_id}/documento/list/",
601
+ schema: listCustomerDocumentsSchema,
602
+ keyFields: listCustomerDocumentsKeyFields,
603
+ itemPath: customerDocumentItemPath,
604
+ secretKeys: customerDocumentSecretKeys,
605
+ personalKeys: customerDocumentPersonalKeys
606
+ };
607
+
608
+ // src/endpoints/ura/check-coverage.ts
609
+ import { z as z10 } from "zod";
610
+ var numberOrNumericString = z10.union([
611
+ z10.number(),
612
+ z10.string().regex(/^-?\d+(\.\d+)?$/).transform(Number)
613
+ ]);
614
+ var ctoSchema = z10.object({
615
+ lat: numberOrNumericString.optional().nullable(),
616
+ lng: numberOrNumericString.optional().nullable(),
617
+ distancia: numberOrNumericString.optional().nullable(),
618
+ id: z10.union([z10.string(), z10.number().transform(String)]).optional().nullable(),
619
+ nome: z10.string().optional().nullable()
620
+ });
621
+ var checkCoverageSchema = z10.array(z10.record(z10.string(), z10.union([z10.array(ctoSchema), z10.string()])));
622
+ var checkCoverageKeyFields = ["[].*"];
623
+ var coverageItemPath = "[]";
624
+ var coverageSecretKeys = [];
625
+ var coveragePersonalKeys = [];
626
+ var checkCoverageDefinition = {
627
+ method: "GET",
628
+ path: "/api/ura/viabilidadeinstalacao",
629
+ schema: checkCoverageSchema,
630
+ keyFields: checkCoverageKeyFields,
631
+ itemPath: coverageItemPath,
632
+ secretKeys: coverageSecretKeys,
633
+ personalKeys: coveragePersonalKeys
634
+ };
635
+
636
+ // src/endpoints/ura/list-annotations.ts
637
+ import { z as z11 } from "zod";
638
+ var PATH = "/api/ura/cliente/anotacao/list/";
639
+ var annotationSchema = z11.object({
640
+ id: z11.number(),
641
+ cliente: z11.number(),
642
+ clientecontrato: z11.number().nullable(),
643
+ anotacao: z11.string(),
644
+ usuario: z11.number().optional().nullable(),
645
+ tipo: z11.number().optional().nullable(),
646
+ alerta_modo: z11.number().optional().nullable(),
647
+ data_cadastro: z11.string().optional().nullable(),
648
+ data_alteracao: z11.string().optional().nullable()
649
+ });
650
+ var listAnnotationsSchema = z11.array(annotationSchema);
651
+ var listAnnotationsKeyFields = [
652
+ "[].id",
653
+ "[].cliente",
654
+ "[].clientecontrato",
655
+ "[].anotacao"
656
+ ];
657
+ var annotationItemPath = "[]";
658
+ var annotationSecretKeys = [];
659
+ var annotationPersonalKeys = ["anotacao", "usuario"];
660
+ var validFilter = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
661
+ var listAnnotations = async (config, params) => {
662
+ const customer = params?.cliente_id;
663
+ const contract = params?.contrato_id;
664
+ if (customer === undefined && contract === undefined || customer !== undefined && !validFilter(customer) || contract !== undefined && !validFilter(contract)) {
665
+ return {
666
+ success: false,
667
+ error: createError("VALIDATION", 0, PATH, "cliente_id / contrato_id: supply at least one positive safe integer", MESSAGE_REJECTED_LOCALLY)
668
+ };
669
+ }
670
+ const raw = await sendRequest(config, {
671
+ method: "GET",
672
+ path: PATH,
673
+ params: { cliente_id: customer, contrato_id: contract }
674
+ });
675
+ if (!raw.ok)
676
+ return { success: false, error: raw.error };
677
+ if (!Array.isArray(raw.body)) {
678
+ return { success: false, error: createError("SCHEMA_MISMATCH", 200, PATH, "(root)") };
679
+ }
680
+ const rows = raw.body;
681
+ const selected = [];
682
+ for (const row of rows) {
683
+ const record = typeof row === "object" && row !== null && !Array.isArray(row) ? row : {};
684
+ const customerIsNumber = typeof record.cliente === "number" && Number.isFinite(record.cliente);
685
+ const contractIsNumber = typeof record.clientecontrato === "number" && Number.isFinite(record.clientecontrato);
686
+ const customerMismatch = customer !== undefined && customerIsNumber && record.cliente !== customer;
687
+ const contractMismatch = contract !== undefined && (record.clientecontrato === null || contractIsNumber && record.clientecontrato !== contract);
688
+ if (customerMismatch || contractMismatch)
689
+ continue;
690
+ const ambiguousPaths = [];
691
+ if (customer !== undefined && !customerIsNumber)
692
+ ambiguousPaths.push("[].cliente");
693
+ if (contract !== undefined && !contractIsNumber)
694
+ ambiguousPaths.push("[].clientecontrato");
695
+ if (ambiguousPaths.length > 0) {
696
+ return {
697
+ success: false,
698
+ error: createError("SCHEMA_MISMATCH", 200, PATH, ambiguousPaths.join(", "))
699
+ };
700
+ }
701
+ selected.push(row);
702
+ }
703
+ return parseResponse(listAnnotationsSchema, listAnnotationsKeyFields, selected, PATH);
704
+ };
705
+
706
+ // src/endpoints/ura/list-clients.ts
707
+ import { z as z12 } from "zod";
708
+ var addressSchema = z12.object({
709
+ logradouro: z12.string().optional().nullable(),
710
+ numero: z12.number().optional().nullable(),
711
+ bairro: z12.string().optional().nullable(),
712
+ cidade: z12.string().optional().nullable(),
713
+ uf: z12.string().optional().nullable(),
714
+ cep: z12.string().optional().nullable(),
715
+ complemento: z12.string().optional().nullable(),
716
+ latitude: z12.string().optional().nullable(),
717
+ longitude: z12.string().optional().nullable()
718
+ });
719
+ var contactsSchema = z12.object({
720
+ telefones: z12.array(z12.string()).optional().nullable(),
721
+ celulares: z12.array(z12.string()).optional().nullable(),
722
+ emails: z12.array(z12.string()).optional().nullable(),
723
+ outros: z12.array(z12.string()).optional().nullable()
724
+ });
725
+ var clientSchema = z12.object({
726
+ id: z12.number(),
727
+ nome: z12.string(),
728
+ tipo: z12.string(),
729
+ cpfcnpj: z12.string(),
730
+ sexo: z12.string().optional().nullable(),
731
+ dataCadastro: z12.string().optional().nullable(),
732
+ endereco: addressSchema.optional().nullable(),
733
+ contratos: z12.array(z12.object({})).optional().nullable(),
734
+ titulos: z12.array(z12.object({})).optional().nullable(),
735
+ contatos: contactsSchema.optional().nullable()
736
+ });
737
+ var listClientsSchema = z12.object({
738
+ paginacao: z12.object({
739
+ offset: z12.number().optional().nullable(),
740
+ limit: z12.number().optional().nullable(),
741
+ parcial: z12.number().optional().nullable(),
742
+ total: z12.number()
743
+ }),
744
+ clientes: z12.array(clientSchema)
745
+ });
746
+ var listClientsKeyFields = [
747
+ "paginacao.total",
748
+ "clientes",
749
+ "clientes[].id",
750
+ "clientes[].nome",
751
+ "clientes[].cpfcnpj",
752
+ "clientes[].tipo"
753
+ ];
754
+ var clientItemPath = "clientes[]";
755
+ var clientSecretKeys = [];
756
+ var clientPersonalKeys = ["nome", "cpfcnpj", "sexo", "endereco", "contatos"];
757
+ var listClientsDefinition = {
758
+ method: "POST",
759
+ path: "/api/ura/clientes/",
760
+ schema: listClientsSchema,
761
+ keyFields: listClientsKeyFields,
762
+ itemPath: clientItemPath,
763
+ secretKeys: clientSecretKeys,
764
+ personalKeys: clientPersonalKeys
765
+ };
766
+
767
+ // src/endpoints/ura/list-contracts.ts
768
+ import { z as z13 } from "zod";
769
+ var contractSummarySchema = z13.object({
770
+ id_contrato: z13.number(),
771
+ id_cliente: z13.number(),
772
+ status: z13.string(),
773
+ pop_id: z13.number(),
774
+ nome: z13.string().optional().nullable(),
775
+ cpfcnpj: z13.string().optional().nullable(),
776
+ email: z13.string().optional().nullable(),
777
+ telefone: z13.string().optional().nullable(),
778
+ data_status: z13.string().optional().nullable(),
779
+ data_cadastro: z13.string().optional().nullable(),
780
+ motivo_status: z13.string().optional().nullable()
781
+ });
782
+ var listContractsSchema = z13.array(contractSummarySchema);
783
+ var listContractsKeyFields = [
784
+ "[].id_contrato",
785
+ "[].id_cliente",
786
+ "[].status",
787
+ "[].pop_id"
788
+ ];
789
+ var contractSummaryItemPath = "[]";
790
+ var contractSummarySecretKeys = [];
791
+ var contractSummaryPersonalKeys = [
792
+ "nome",
793
+ "cpfcnpj",
794
+ "email",
795
+ "telefone",
796
+ "motivo_status"
797
+ ];
798
+ var listContractsDefinition = {
799
+ method: "POST",
800
+ path: "/api/ura/listacontrato/",
801
+ schema: listContractsSchema,
802
+ keyFields: listContractsKeyFields,
803
+ itemPath: contractSummaryItemPath,
804
+ secretKeys: contractSummarySecretKeys,
805
+ personalKeys: contractSummaryPersonalKeys
806
+ };
807
+
808
+ // src/endpoints/ura/list-invoices.ts
809
+ import { z as z14 } from "zod";
810
+ var invoiceSchema = z14.object({
811
+ id: z14.number(),
812
+ status: z14.string(),
813
+ valor: z14.number(),
814
+ dataVencimento: z14.string(),
815
+ clienteNome: z14.string().optional().nullable(),
816
+ clienteCpfcnpj: z14.string().optional().nullable(),
817
+ clienteContrato: z14.number().optional().nullable(),
818
+ portador: z14.string().optional().nullable(),
819
+ numeroDocumento: z14.number().optional().nullable(),
820
+ nossoNumero: z14.string().optional().nullable(),
821
+ link: z14.string().optional().nullable(),
822
+ link_cobranca: z14.string().optional().nullable(),
823
+ valorDesconto: z14.number().optional().nullable(),
824
+ valorCorrigido: z14.number().optional().nullable(),
825
+ valorPago: z14.number().optional().nullable(),
826
+ valorPagoParcial: z14.number().optional().nullable(),
827
+ codigoBarras: z14.string().optional().nullable(),
828
+ linhaDigitavel: z14.string().optional().nullable(),
829
+ codigoPix: z14.string().optional().nullable(),
830
+ dataEmissao: z14.string().optional().nullable(),
831
+ dataPagamento: z14.string().optional().nullable(),
832
+ dataCancelamento: z14.string().optional().nullable(),
833
+ demonstrativo: z14.string().optional().nullable(),
834
+ acordoPagamento: z14.object({
835
+ acordados: z14.array(z14.object({})).optional().nullable(),
836
+ cobrados: z14.array(z14.object({})).optional().nullable()
837
+ }).optional().nullable(),
838
+ formaPagamento: z14.string().optional().nullable(),
839
+ usuario_baixa: z14.string().optional().nullable()
840
+ });
841
+ var listInvoicesSchema = z14.object({
842
+ paginacao: z14.object({
843
+ offset: z14.number().optional().nullable(),
844
+ limit: z14.number().optional().nullable(),
845
+ parcial: z14.number().optional().nullable(),
846
+ total: z14.number()
847
+ }),
848
+ titulos: z14.array(invoiceSchema)
849
+ });
850
+ var listInvoicesKeyFields = [
851
+ "paginacao.total",
852
+ "titulos",
853
+ "titulos[].id",
854
+ "titulos[].status",
855
+ "titulos[].valor",
856
+ "titulos[].dataVencimento"
857
+ ];
858
+ var invoiceItemPath = "titulos[]";
859
+ var invoiceSecretKeys = [];
860
+ var invoicePersonalKeys = [
861
+ "clienteNome",
862
+ "clienteCpfcnpj",
863
+ "demonstrativo",
864
+ "link",
865
+ "link_cobranca",
866
+ "codigoPix"
867
+ ];
868
+ var listInvoicesDefinition = {
869
+ method: "POST",
870
+ path: "/api/ura/titulos/",
871
+ schema: listInvoicesSchema,
872
+ keyFields: listInvoicesKeyFields,
873
+ itemPath: invoiceItemPath,
874
+ secretKeys: invoiceSecretKeys,
875
+ personalKeys: invoicePersonalKeys
876
+ };
877
+
878
+ // src/endpoints/ura/list-nas.ts
879
+ import { z as z15 } from "zod";
880
+ var nasPopSchema = z15.object({
881
+ id: z15.number().optional().nullable(),
882
+ cidade: z15.string().optional().nullable(),
883
+ uf: z15.string().optional().nullable(),
884
+ codigo_ibge: z15.number().optional().nullable(),
885
+ ativo: z15.boolean().optional().nullable()
886
+ });
887
+ var nasSchema = z15.object({
888
+ id: z15.number(),
889
+ descricao: z15.string(),
890
+ identificador: z15.string(),
891
+ endereco_ip: z15.string().optional().nullable(),
892
+ ativo: z15.boolean().optional().nullable(),
893
+ pops: z15.array(nasPopSchema).optional().nullable()
894
+ });
895
+ var listNasSchema = z15.array(nasSchema);
896
+ var listNasKeyFields = ["[].id", "[].descricao", "[].identificador"];
897
+ var nasItemPath = "[]";
898
+ var nasSecretKeys = ["endereco_ip"];
899
+ var nasPersonalKeys = [];
900
+ var listNasDefinition = {
901
+ method: "POST",
902
+ path: "/api/ura/nas/list/",
903
+ schema: listNasSchema,
904
+ keyFields: listNasKeyFields,
905
+ itemPath: nasItemPath,
906
+ secretKeys: nasSecretKeys,
907
+ personalKeys: nasPersonalKeys
908
+ };
909
+
910
+ // src/endpoints/ura/list-occurrence-methods.ts
911
+ import { z as z16 } from "zod";
912
+ var occurrenceMethodSchema = z16.object({
913
+ codigo: z16.number(),
914
+ descricao: z16.string()
915
+ });
916
+ var listOccurrenceMethodsSchema = z16.array(occurrenceMethodSchema);
917
+ var listOccurrenceMethodsKeyFields = ["[].codigo", "[].descricao"];
918
+ var occurrenceMethodItemPath = "[]";
919
+ var occurrenceMethodSecretKeys = [];
920
+ var occurrenceMethodPersonalKeys = [];
921
+ var listOccurrenceMethodsDefinition = {
922
+ method: "GET",
923
+ path: "/api/ura/ocorrencia/metodo/list/",
924
+ schema: listOccurrenceMethodsSchema,
925
+ keyFields: listOccurrenceMethodsKeyFields,
926
+ itemPath: occurrenceMethodItemPath,
927
+ secretKeys: occurrenceMethodSecretKeys,
928
+ personalKeys: occurrenceMethodPersonalKeys
929
+ };
930
+
931
+ // src/endpoints/ura/list-payment-carriers.ts
932
+ import { z as z17 } from "zod";
933
+ var paymentCarrierSchema = z17.object({
934
+ id: z17.number(),
935
+ descricao: z17.string(),
936
+ codigo_banco: z17.string().optional().nullable()
937
+ });
938
+ var listPaymentCarriersSchema = z17.array(paymentCarrierSchema);
939
+ var listPaymentCarriersKeyFields = ["[].id", "[].descricao"];
940
+ var paymentCarrierItemPath = "[]";
941
+ var paymentCarrierSecretKeys = [];
942
+ var paymentCarrierPersonalKeys = [];
943
+ var listPaymentCarriersDefinition = {
944
+ method: "GET",
945
+ path: "/api/ura/portador/",
946
+ schema: listPaymentCarriersSchema,
947
+ keyFields: listPaymentCarriersKeyFields,
948
+ itemPath: paymentCarrierItemPath,
949
+ secretKeys: paymentCarrierSecretKeys,
950
+ personalKeys: paymentCarrierPersonalKeys
951
+ };
952
+
953
+ // src/endpoints/ura/list-plans.ts
954
+ import { z as z18 } from "zod";
955
+ var planPopSchema = z18.object({
956
+ id: z18.number().optional().nullable(),
957
+ uf: z18.string().optional().nullable(),
958
+ pop: z18.string().optional().nullable()
959
+ });
960
+ var planSchema = z18.object({
961
+ id: z18.number(),
962
+ descricao: z18.string(),
963
+ preco: z18.number(),
964
+ ativo: z18.boolean(),
965
+ grupo: z18.string().optional().nullable(),
966
+ tipo: z18.string().optional().nullable(),
967
+ pos_pago: z18.boolean().optional().nullable(),
968
+ desconto: z18.number().optional().nullable(),
969
+ desconto_venc: z18.number().optional().nullable(),
970
+ desconto_venc_modo: z18.string().optional().nullable(),
971
+ valor_desconto_temporario: z18.number().optional().nullable(),
972
+ desconto_temporario_modo: z18.string().optional().nullable(),
973
+ desconto_temporario_quantidade: z18.number().optional().nullable(),
974
+ descricao_desconto_temporario: z18.string().optional().nullable(),
975
+ desconto_temporario_proporcional: z18.boolean().optional().nullable(),
976
+ observacao: z18.string().optional().nullable(),
977
+ instalacao_qtd_parcelas: z18.number().optional().nullable(),
978
+ instalacao_valor: z18.number().optional().nullable(),
979
+ instalacao_desconto_max: z18.number().optional().nullable(),
980
+ instalacao_desconto_min: z18.number().optional().nullable(),
981
+ disponivel_pre_cadastro: z18.boolean().optional().nullable(),
982
+ disponivel_pre_cadastro_publico: z18.boolean().optional().nullable(),
983
+ data_validade: z18.string().optional().nullable(),
984
+ pops: z18.array(planPopSchema).optional().nullable(),
985
+ auto_bloqueio: z18.boolean().optional().nullable(),
986
+ dias_bloqueio_pos_venc: z18.number().optional().nullable(),
987
+ dias_bloqueio_aviso: z18.number().optional().nullable(),
988
+ dias_reducao_velocidade: z18.number().optional().nullable(),
989
+ download: z18.number().optional().nullable(),
990
+ upload: z18.number().optional().nullable(),
991
+ trafego_mensal: z18.number().optional().nullable(),
992
+ contabilizacao_trafego_mensal: z18.string().optional().nullable(),
993
+ trafego_excedente_acao: z18.string().optional().nullable(),
994
+ valor_trafego_excedido: z18.number().optional().nullable(),
995
+ duplicacao_noturna: z18.boolean().optional().nullable(),
996
+ inicio_duplicacao_noturna: z18.string().optional().nullable(),
997
+ fim_duplicacao_noturna: z18.string().optional().nullable(),
998
+ modo_velocidade_reduzida: z18.string().optional().nullable(),
999
+ download_red_financeiro: z18.number().optional().nullable(),
1000
+ upload_red_financeiro: z18.number().optional().nullable(),
1001
+ modo_velocidade_red_franquia: z18.string().optional().nullable(),
1002
+ download_red_franquia: z18.number().optional().nullable(),
1003
+ upload_red_franquia: z18.number().optional().nullable(),
1004
+ combo: z18.array(z18.object({})).optional().nullable(),
1005
+ qtd_servicos: z18.number().optional().nullable()
1006
+ });
1007
+ var listPlansSchema = z18.object({
1008
+ planos: z18.array(planSchema),
1009
+ total_planos: z18.number().optional().nullable(),
1010
+ total_qtd_servicos: z18.number().optional().nullable()
1011
+ });
1012
+ var listPlansKeyFields = [
1013
+ "planos",
1014
+ "planos[].id",
1015
+ "planos[].descricao",
1016
+ "planos[].preco",
1017
+ "planos[].ativo"
1018
+ ];
1019
+ var planItemPath = "planos[]";
1020
+ var planSecretKeys = [];
1021
+ var planPersonalKeys = [];
1022
+ var listPlansDefinition = {
1023
+ method: "GET",
1024
+ path: "/api/ura/consultaplano/",
1025
+ schema: listPlansSchema,
1026
+ keyFields: listPlansKeyFields,
1027
+ itemPath: planItemPath,
1028
+ secretKeys: planSecretKeys,
1029
+ personalKeys: planPersonalKeys
1030
+ };
1031
+
1032
+ // src/endpoints/ura/list-pops.ts
1033
+ import { z as z19 } from "zod";
1034
+ var popSchema = z19.object({
1035
+ id: z19.number(),
1036
+ pop: z19.string()
1037
+ });
1038
+ var listPopsSchema = z19.array(popSchema);
1039
+ var listPopsKeyFields = ["[].id", "[].pop"];
1040
+ var popItemPath = "[]";
1041
+ var popSecretKeys = [];
1042
+ var popPersonalKeys = [];
1043
+ var listPopsDefinition = {
1044
+ method: "POST",
1045
+ path: "/api/ura/pops/",
1046
+ schema: listPopsSchema,
1047
+ keyFields: listPopsKeyFields,
1048
+ itemPath: popItemPath,
1049
+ secretKeys: popSecretKeys,
1050
+ personalKeys: popPersonalKeys
1051
+ };
1052
+
1053
+ // src/endpoints/ura/list-service-orders.ts
1054
+ import { z as z20 } from "zod";
1055
+ var serviceOrderSchema = z20.object({
1056
+ id: z20.number(),
1057
+ contrato: z20.number(),
1058
+ status_id: z20.number(),
1059
+ status: z20.string(),
1060
+ tipo_id: z20.number(),
1061
+ data_cadastro: z20.string(),
1062
+ cliente: z20.string().optional().nullable(),
1063
+ contrato_status: z20.string().optional().nullable(),
1064
+ contrato_status_id: z20.number().optional().nullable(),
1065
+ ocorrencia: z20.string().optional().nullable(),
1066
+ hora_cadastro: z20.string().optional().nullable(),
1067
+ data_agendamento: z20.string().optional().nullable(),
1068
+ hora_agendamento: z20.string().optional().nullable(),
1069
+ data_finalizacao: z20.string().optional().nullable(),
1070
+ hora_finalizacao: z20.string().optional().nullable(),
1071
+ tipo: z20.string().optional().nullable(),
1072
+ motivo: z20.string().optional().nullable(),
1073
+ pop: z20.string().optional().nullable(),
1074
+ conteudo: z20.string().optional().nullable(),
1075
+ responsavel: z20.string().optional().nullable(),
1076
+ tecnicos_auxiliares: z20.array(z20.object({})).optional().nullable(),
1077
+ usuario: z20.string().optional().nullable(),
1078
+ usuario_finalizacao: z20.string().optional().nullable(),
1079
+ classificacoes: z20.array(z20.object({})).optional().nullable()
1080
+ });
1081
+ var listServiceOrdersSchema = z20.object({
1082
+ paginacao: z20.object({
1083
+ offset: z20.number().optional().nullable(),
1084
+ limit: z20.number().optional().nullable(),
1085
+ parcial: z20.number().optional().nullable(),
1086
+ total: z20.number()
1087
+ }),
1088
+ ordens_servicos: z20.array(serviceOrderSchema)
1089
+ });
1090
+ var listServiceOrdersKeyFields = [
1091
+ "paginacao.total",
1092
+ "ordens_servicos",
1093
+ "ordens_servicos[].id",
1094
+ "ordens_servicos[].contrato",
1095
+ "ordens_servicos[].status_id",
1096
+ "ordens_servicos[].status",
1097
+ "ordens_servicos[].tipo_id",
1098
+ "ordens_servicos[].data_cadastro"
1099
+ ];
1100
+ var serviceOrderItemPath = "ordens_servicos[]";
1101
+ var serviceOrderSecretKeys = [];
1102
+ var serviceOrderPersonalKeys = ["cliente", "conteudo"];
1103
+ var listServiceOrdersDefinition = {
1104
+ method: "POST",
1105
+ path: "/api/ura/ordemservico/list/",
1106
+ schema: listServiceOrdersSchema,
1107
+ keyFields: listServiceOrdersKeyFields,
1108
+ itemPath: serviceOrderItemPath,
1109
+ secretKeys: serviceOrderSecretKeys,
1110
+ personalKeys: serviceOrderPersonalKeys
1111
+ };
1112
+
1113
+ // src/endpoints/ura/lookup-customer.ts
1114
+ import { z as z21 } from "zod";
1115
+ var contactEntrySchema = z21.object({
1116
+ inscricoes: z21.array(z21.string()).optional().nullable(),
1117
+ tipoContato: z21.string().optional().nullable(),
1118
+ contato: z21.string().optional().nullable()
1119
+ });
1120
+ var tagSchema = z21.object({
1121
+ color: z21.string().optional().nullable(),
1122
+ font: z21.string().optional().nullable(),
1123
+ tag: z21.string().optional().nullable(),
1124
+ id: z21.number().optional().nullable(),
1125
+ categoria_id: z21.number().optional().nullable()
1126
+ });
1127
+ var loyaltySchema = z21.object({
1128
+ data_inicio: z21.string().optional().nullable(),
1129
+ descricao: z21.string().optional().nullable(),
1130
+ data_fim: z21.string().optional().nullable()
1131
+ });
1132
+ var customerContractSchema = z21.object({
1133
+ contratoId: z21.number(),
1134
+ clienteId: z21.number(),
1135
+ contratoStatus: z21.number(),
1136
+ contratoStatusDisplay: z21.string(),
1137
+ contratoValorAberto: z21.number(),
1138
+ contratoTitulosAReceber: z21.number(),
1139
+ cobVencimento: z21.number(),
1140
+ contratoStatusModo: z21.number().optional().nullable(),
1141
+ motivo_status: z21.string().optional().nullable(),
1142
+ dataCadastro: z21.string().optional().nullable(),
1143
+ dataAlteracao: z21.string().optional().nullable(),
1144
+ popId: z21.number().optional().nullable(),
1145
+ popNome: z21.string().optional().nullable(),
1146
+ cobPermuta: z21.boolean().optional().nullable(),
1147
+ cobIsento: z21.number().optional().nullable(),
1148
+ promessasPagamentoMes: z21.number().optional().nullable(),
1149
+ link_quitacao: z21.string().optional().nullable(),
1150
+ planointernet: z21.string().optional().nullable(),
1151
+ fidelidade: loyaltySchema.optional().nullable(),
1152
+ contrato_unificado_principal: z21.number().optional().nullable(),
1153
+ contrato_unificado_filhos: z21.array(z21.number()).optional().nullable(),
1154
+ tags: z21.array(tagSchema).optional().nullable(),
1155
+ anotacoes: z21.array(z21.object({})).optional().nullable(),
1156
+ contratoCentralLogin: z21.string().optional().nullable(),
1157
+ contratoCentralSenha: z21.string().optional().nullable(),
1158
+ servico_login: z21.string().optional().nullable(),
1159
+ servico_senha: z21.string().optional().nullable(),
1160
+ servico_plano: z21.string().optional().nullable(),
1161
+ servico_grupo: z21.string().optional().nullable(),
1162
+ servico_tipo_conexao: z21.string().optional().nullable(),
1163
+ servico_vlan: z21.string().optional().nullable(),
1164
+ servico_mac: z21.string().optional().nullable(),
1165
+ servico_mac2: z21.string().optional().nullable(),
1166
+ servico_wifi_ssid: z21.string().optional().nullable(),
1167
+ servico_wifi_ssid_5: z21.string().optional().nullable(),
1168
+ servico_wifi_password: z21.string().optional().nullable(),
1169
+ servico_wifi_password_5: z21.string().optional().nullable(),
1170
+ servico_wifi_channel: z21.string().optional().nullable(),
1171
+ servico_wifi_channel_5: z21.string().optional().nullable(),
1172
+ razaoSocial: z21.string().optional().nullable(),
1173
+ cpfCnpj: z21.string().optional().nullable(),
1174
+ dataNascimento: z21.string().optional().nullable(),
1175
+ telefones: z21.array(contactEntrySchema).optional().nullable(),
1176
+ telefones_cargos: z21.array(z21.object({})).optional().nullable(),
1177
+ emails: z21.array(contactEntrySchema).optional().nullable(),
1178
+ outros: z21.array(z21.object({})).optional().nullable(),
1179
+ endereco_logradouro: z21.string().optional().nullable(),
1180
+ endereco_numero: z21.number().optional().nullable(),
1181
+ endereco_complemento: z21.string().optional().nullable(),
1182
+ endereco_bairro: z21.string().optional().nullable(),
1183
+ endereco_cidade: z21.string().optional().nullable(),
1184
+ endereco_uf: z21.string().optional().nullable(),
1185
+ endereco_cep: z21.string().optional().nullable(),
1186
+ endereco_pontoreferencia: z21.string().optional().nullable(),
1187
+ endereco_ll: z21.string().optional().nullable()
1188
+ });
1189
+ var lookupCustomerSchema = z21.object({
1190
+ msg: z21.string().optional().nullable(),
1191
+ contratos: z21.array(customerContractSchema)
1192
+ });
1193
+ var lookupCustomerKeyFields = [
1194
+ "contratos",
1195
+ "contratos[].contratoId",
1196
+ "contratos[].clienteId",
1197
+ "contratos[].contratoStatus",
1198
+ "contratos[].contratoStatusDisplay",
1199
+ "contratos[].contratoValorAberto",
1200
+ "contratos[].contratoTitulosAReceber",
1201
+ "contratos[].cobVencimento"
1202
+ ];
1203
+ var customerContractItemPath = "contratos[]";
1204
+ var customerContractSecretKeys = [
1205
+ "contratoCentralLogin",
1206
+ "contratoCentralSenha",
1207
+ "servico_login",
1208
+ "servico_senha",
1209
+ "servico_wifi_password",
1210
+ "servico_wifi_password_5",
1211
+ "servico_wifi_ssid",
1212
+ "servico_wifi_ssid_5",
1213
+ "servico_mac",
1214
+ "servico_mac2",
1215
+ "link_quitacao"
1216
+ ];
1217
+ var customerContractPersonalKeys = [
1218
+ "motivo_status",
1219
+ "razaoSocial",
1220
+ "cpfCnpj",
1221
+ "dataNascimento",
1222
+ "telefones",
1223
+ "telefones_cargos",
1224
+ "emails",
1225
+ "outros",
1226
+ "anotacoes",
1227
+ "endereco_logradouro",
1228
+ "endereco_numero",
1229
+ "endereco_complemento",
1230
+ "endereco_bairro",
1231
+ "endereco_cidade",
1232
+ "endereco_uf",
1233
+ "endereco_cep",
1234
+ "endereco_pontoreferencia",
1235
+ "endereco_ll"
1236
+ ];
1237
+ var lookupCustomerDefinition = {
1238
+ method: "POST",
1239
+ path: "/api/ura/consultacliente/",
1240
+ schema: lookupCustomerSchema,
1241
+ keyFields: lookupCustomerKeyFields,
1242
+ itemPath: customerContractItemPath,
1243
+ secretKeys: customerContractSecretKeys,
1244
+ personalKeys: customerContractPersonalKeys
1245
+ };
1246
+
1247
+ // src/endpoints/ura/open-ticket.ts
1248
+ import { z as z22 } from "zod";
1249
+ var openTicketSchema = z22.object({
1250
+ status: z22.literal(1),
1251
+ protocolo: z22.string(),
1252
+ id: z22.number(),
1253
+ contratoId: z22.number().optional().nullable(),
1254
+ razaoSocial: z22.string().optional().nullable(),
1255
+ cpfCnpj: z22.string().optional().nullable(),
1256
+ msg: z22.string().optional().nullable()
1257
+ });
1258
+ var openTicketKeyFields = ["status", "protocolo", "id"];
1259
+ var ticketOpenedItemPath = "";
1260
+ var ticketOpenedSecretKeys = [];
1261
+ var ticketOpenedPersonalKeys = ["razaoSocial", "cpfCnpj"];
1262
+ var openTicketDefinition = {
1263
+ kind: "write",
1264
+ method: "POST",
1265
+ path: "/api/ura/chamado/",
1266
+ schema: openTicketSchema,
1267
+ keyFields: openTicketKeyFields,
1268
+ itemPath: ticketOpenedItemPath,
1269
+ secretKeys: ticketOpenedSecretKeys,
1270
+ personalKeys: ticketOpenedPersonalKeys
1271
+ };
1272
+
1273
+ // src/client.ts
1274
+ var createSgpClient = (config) => ({
1275
+ ura: {
1276
+ listAnnotations: (params) => listAnnotations(config, params),
1277
+ listClients: (params) => callEndpoint(config, listClientsDefinition, { ...params }),
1278
+ lookupCustomer: (params) => callEndpoint(config, lookupCustomerDefinition, { ...params }),
1279
+ listContracts: (params) => callEndpoint(config, listContractsDefinition, { ...params }),
1280
+ listServiceOrders: (params) => callEndpoint(config, listServiceOrdersDefinition, { ...params }),
1281
+ listPlans: () => callEndpoint(config, listPlansDefinition),
1282
+ listOccurrenceMethods: () => callEndpoint(config, listOccurrenceMethodsDefinition),
1283
+ listInvoices: (params) => callEndpoint(config, listInvoicesDefinition, { ...params }),
1284
+ listPops: () => callEndpoint(config, listPopsDefinition),
1285
+ listNas: () => callEndpoint(config, listNasDefinition),
1286
+ listPaymentCarriers: () => callEndpoint(config, listPaymentCarriersDefinition),
1287
+ checkCoverage: (params) => callEndpoint(config, checkCoverageDefinition, { ...params }),
1288
+ openTicket: (params) => callWriteEndpoint(config, openTicketDefinition, {
1289
+ params: { ...params }
1290
+ })
1291
+ },
1292
+ os: {
1293
+ listOccurrenceTypes: () => callEndpoint(config, listOccurrenceTypesDefinition),
1294
+ listOccurrenceReasons: () => callEndpoint(config, listOccurrenceReasonsDefinition)
1295
+ },
1296
+ precadastro: {
1297
+ listDueDays: () => callEndpoint(config, listDueDaysDefinition),
1298
+ listSellers: () => callEndpoint(config, listSellersDefinition)
1299
+ },
1300
+ crm: {
1301
+ createIndividualCustomer: (params) => callWriteEndpoint(config, createIndividualCustomerDefinition, {
1302
+ params: toCustomerBody(params)
1303
+ }),
1304
+ createCompanyCustomer: (params) => callWriteEndpoint(config, createCompanyCustomerDefinition, {
1305
+ params: toCustomerBody(params)
1306
+ }),
1307
+ createContract: (clienteId, params) => callWriteEndpoint(config, createContractDefinition, {
1308
+ pathParams: { cliente_id: clienteId },
1309
+ params: toContractBody(params)
1310
+ }),
1311
+ updateCustomerStatus: (clienteId, params) => callWriteEndpoint(config, updateCustomerStatusDefinition, {
1312
+ pathParams: { cliente_id: clienteId },
1313
+ params: { ...params }
1314
+ })
1315
+ },
1316
+ suporte: {
1317
+ addCustomerDocument: (clienteId, file, params) => callWriteEndpoint(config, addCustomerDocumentDefinition, {
1318
+ pathParams: { cliente_id: clienteId },
1319
+ params: { ...params },
1320
+ files: { file }
1321
+ }),
1322
+ listCustomerDocuments: (clienteId) => callEndpoint(config, listCustomerDocumentsDefinition, undefined, { cliente_id: clienteId })
1323
+ }
1324
+ });
1325
+ // src/sensitivity.ts
1326
+ var omitSensitive = (obj, keys) => {
1327
+ const copy = { ...obj };
1328
+ for (const key of keys)
1329
+ Reflect.deleteProperty(copy, key);
1330
+ return copy;
1331
+ };
1332
+ export {
1333
+ updateCustomerStatusKeyFields,
1334
+ updateCustomerStatusDefinition,
1335
+ ticketOpenedSecretKeys,
1336
+ ticketOpenedPersonalKeys,
1337
+ ticketOpenedItemPath,
1338
+ serviceOrderSecretKeys,
1339
+ serviceOrderPersonalKeys,
1340
+ serviceOrderItemPath,
1341
+ sellerSecretKeys,
1342
+ sellerPersonalKeys,
1343
+ sellerItemPath,
1344
+ popSecretKeys,
1345
+ popPersonalKeys,
1346
+ popItemPath,
1347
+ planSecretKeys,
1348
+ planPersonalKeys,
1349
+ planItemPath,
1350
+ paymentCarrierSecretKeys,
1351
+ paymentCarrierPersonalKeys,
1352
+ paymentCarrierItemPath,
1353
+ openTicketKeyFields,
1354
+ openTicketDefinition,
1355
+ omitSensitive,
1356
+ occurrenceTypeSecretKeys,
1357
+ occurrenceTypePersonalKeys,
1358
+ occurrenceTypeItemPath,
1359
+ occurrenceReasonSecretKeys,
1360
+ occurrenceReasonPersonalKeys,
1361
+ occurrenceReasonItemPath,
1362
+ occurrenceMethodSecretKeys,
1363
+ occurrenceMethodPersonalKeys,
1364
+ occurrenceMethodItemPath,
1365
+ nasSecretKeys,
1366
+ nasPersonalKeys,
1367
+ nasItemPath,
1368
+ modoAquisicao,
1369
+ lookupCustomerKeyFields,
1370
+ lookupCustomerDefinition,
1371
+ listServiceOrdersKeyFields,
1372
+ listServiceOrdersDefinition,
1373
+ listSellersKeyFields,
1374
+ listSellersDefinition,
1375
+ listPopsKeyFields,
1376
+ listPopsDefinition,
1377
+ listPlansKeyFields,
1378
+ listPlansDefinition,
1379
+ listPaymentCarriersKeyFields,
1380
+ listPaymentCarriersDefinition,
1381
+ listOccurrenceTypesKeyFields,
1382
+ listOccurrenceTypesDefinition,
1383
+ listOccurrenceReasonsKeyFields,
1384
+ listOccurrenceReasonsDefinition,
1385
+ listOccurrenceMethodsKeyFields,
1386
+ listOccurrenceMethodsDefinition,
1387
+ listNasKeyFields,
1388
+ listNasDefinition,
1389
+ listInvoicesKeyFields,
1390
+ listInvoicesDefinition,
1391
+ listDueDaysKeyFields,
1392
+ listDueDaysDefinition,
1393
+ listCustomerDocumentsKeyFields,
1394
+ listCustomerDocumentsDefinition,
1395
+ listContractsKeyFields,
1396
+ listContractsDefinition,
1397
+ listClientsKeyFields,
1398
+ listClientsDefinition,
1399
+ listAnnotationsSchema,
1400
+ listAnnotationsKeyFields,
1401
+ invoiceSecretKeys,
1402
+ invoicePersonalKeys,
1403
+ invoiceItemPath,
1404
+ formaCobrancaCodigo,
1405
+ dueDaySecretKeys,
1406
+ dueDayPersonalKeys,
1407
+ dueDayItemPath,
1408
+ customerStatusSecretKeys,
1409
+ customerStatusPersonalKeys,
1410
+ customerStatusItemPath,
1411
+ customerDocumentSecretKeys,
1412
+ customerDocumentPersonalKeys,
1413
+ customerDocumentItemPath,
1414
+ customerDocumentAddedSecretKeys,
1415
+ customerDocumentAddedPersonalKeys,
1416
+ customerDocumentAddedItemPath,
1417
+ customerCreatedSecretKeys,
1418
+ customerCreatedPersonalKeys,
1419
+ customerCreatedItemPath,
1420
+ customerContractSecretKeys,
1421
+ customerContractPersonalKeys,
1422
+ customerContractItemPath,
1423
+ crmStatus,
1424
+ createSgpClient,
1425
+ createIndividualCustomerDefinition,
1426
+ createCustomerKeyFields,
1427
+ createContractKeyFields,
1428
+ createContractDefinition,
1429
+ createCompanyCustomerDefinition,
1430
+ coverageSecretKeys,
1431
+ coveragePersonalKeys,
1432
+ coverageItemPath,
1433
+ contractSummarySecretKeys,
1434
+ contractSummaryPersonalKeys,
1435
+ contractSummaryItemPath,
1436
+ contractCreatedSecretKeys,
1437
+ contractCreatedPersonalKeys,
1438
+ contractCreatedItemPath,
1439
+ clientSecretKeys,
1440
+ clientPersonalKeys,
1441
+ clientItemPath,
1442
+ checkCoverageKeyFields,
1443
+ checkCoverageDefinition,
1444
+ annotationSecretKeys,
1445
+ annotationPersonalKeys,
1446
+ annotationItemPath,
1447
+ addCustomerDocumentKeyFields,
1448
+ addCustomerDocumentDefinition
1449
+ };