sgp-sdk 1.2.0 → 2.0.0-beta.2

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 (100) hide show
  1. package/CHANGELOG.md +234 -0
  2. package/COMPATIBILITY.md +231 -0
  3. package/MIGRATION.md +344 -0
  4. package/README.md +464 -265
  5. package/dist/address.d.ts +46 -0
  6. package/dist/annotation-selection.d.ts +32 -0
  7. package/dist/budget.d.ts +29 -0
  8. package/dist/classify.d.ts +15 -0
  9. package/dist/client.d.ts +938 -165
  10. package/dist/config.d.ts +115 -0
  11. package/dist/constants.d.ts +85 -0
  12. package/dist/document.d.ts +11 -0
  13. package/dist/effect.d.ts +22 -0
  14. package/dist/executor.d.ts +9 -0
  15. package/dist/exposure.d.ts +21 -0
  16. package/dist/guards.d.ts +2 -0
  17. package/dist/hooks.d.ts +16 -0
  18. package/dist/ids.d.ts +19 -0
  19. package/dist/index.d.ts +55 -49
  20. package/dist/index.js +3750 -1293
  21. package/dist/normalize.d.ts +9 -0
  22. package/dist/operation-sensitivity.d.ts +729 -0
  23. package/dist/operation.d.ts +145 -0
  24. package/dist/operations/catalogs-list-billing-profiles.d.ts +16 -0
  25. package/dist/operations/catalogs-list-nas.d.ts +25 -0
  26. package/dist/operations/catalogs-list-pops.d.ts +14 -0
  27. package/dist/operations/contracts-check-connection.d.ts +56 -0
  28. package/dist/operations/contracts-list-services.d.ts +103 -0
  29. package/dist/operations/contracts-list-status-reasons.d.ts +15 -0
  30. package/dist/operations/contracts-list.d.ts +52 -0
  31. package/dist/operations/contracts-update-status.d.ts +41 -0
  32. package/dist/operations/contracts-update.d.ts +39 -0
  33. package/dist/operations/coverage-check-address.d.ts +46 -0
  34. package/dist/operations/coverage-check.d.ts +43 -0
  35. package/dist/operations/coverage-list-gateways.d.ts +16 -0
  36. package/dist/operations/crm-contracts-create-by-cpf-cnpj.d.ts +97 -0
  37. package/dist/operations/crm-contracts-create.d.ts +221 -0
  38. package/dist/operations/crm-contracts-list.d.ts +50 -0
  39. package/dist/operations/crm-customers-create.d.ts +165 -0
  40. package/dist/operations/crm-customers-update-status.d.ts +41 -0
  41. package/dist/operations/customers-list.d.ts +104 -0
  42. package/dist/{endpoints/ura/lookup-customer.d.ts → operations/customers-search.d.ts} +56 -46
  43. package/dist/operations/documents-add.d.ts +29 -0
  44. package/dist/operations/documents-list.d.ts +31 -0
  45. package/dist/operations/experimental-annotations-list.d.ts +67 -0
  46. package/dist/operations/invoices-list.d.ts +148 -0
  47. package/dist/operations/maintenance-list.d.ts +35 -0
  48. package/dist/operations/occurrences-create.d.ts +125 -0
  49. package/dist/operations/occurrences-list-methods.d.ts +14 -0
  50. package/dist/operations/occurrences-list-types.d.ts +20 -0
  51. package/dist/operations/occurrences-list.d.ts +127 -0
  52. package/dist/{endpoints/ura/list-plans.d.ts → operations/plans-list.d.ts} +33 -23
  53. package/dist/operations/pre-registrations-create.d.ts +276 -0
  54. package/dist/operations/pre-registrations-list-due-days.d.ts +15 -0
  55. package/dist/operations/pre-registrations-list-plans.d.ts +24 -0
  56. package/dist/operations/pre-registrations-list-sellers.d.ts +16 -0
  57. package/dist/operations/services-add-generic.d.ts +52 -0
  58. package/dist/operations/services-add-tv.d.ts +47 -0
  59. package/dist/operations/services-change-plan.d.ts +40 -0
  60. package/dist/operations/services-remove-generic.d.ts +28 -0
  61. package/dist/operations/services-remove-tv.d.ts +29 -0
  62. package/dist/operations/work-orders-get.d.ts +99 -0
  63. package/dist/operations/work-orders-list-comments.d.ts +34 -0
  64. package/dist/operations/work-orders-list-reasons.d.ts +20 -0
  65. package/dist/operations/work-orders-list.d.ts +81 -0
  66. package/dist/path.d.ts +13 -0
  67. package/dist/raw-request.d.ts +26 -0
  68. package/dist/request.d.ts +28 -0
  69. package/dist/result.d.ts +113 -41
  70. package/dist/retry.d.ts +34 -0
  71. package/dist/sensitivity.d.ts +89 -4
  72. package/dist/tolerant.d.ts +21 -0
  73. package/dist/validation.d.ts +3 -0
  74. package/package.json +6 -3
  75. package/dist/endpoint.d.ts +0 -66
  76. package/dist/endpoints/crm/address.d.ts +0 -20
  77. package/dist/endpoints/crm/create-contract.d.ts +0 -109
  78. package/dist/endpoints/crm/create-customer.d.ts +0 -65
  79. package/dist/endpoints/crm/update-customer-status.d.ts +0 -43
  80. package/dist/endpoints/os/list-occurrence-reasons.d.ts +0 -24
  81. package/dist/endpoints/os/list-occurrence-types.d.ts +0 -25
  82. package/dist/endpoints/precadastro/list-due-days.d.ts +0 -19
  83. package/dist/endpoints/precadastro/list-sellers.d.ts +0 -21
  84. package/dist/endpoints/suporte/add-customer-document.d.ts +0 -24
  85. package/dist/endpoints/suporte/list-customer-documents.d.ts +0 -25
  86. package/dist/endpoints/ura/check-coverage.d.ts +0 -46
  87. package/dist/endpoints/ura/list-annotations.d.ts +0 -32
  88. package/dist/endpoints/ura/list-clients.d.ts +0 -58
  89. package/dist/endpoints/ura/list-contracts.d.ts +0 -45
  90. package/dist/endpoints/ura/list-invoices.d.ts +0 -107
  91. package/dist/endpoints/ura/list-nas.d.ts +0 -29
  92. package/dist/endpoints/ura/list-occurrence-methods.d.ts +0 -19
  93. package/dist/endpoints/ura/list-payment-carriers.d.ts +0 -20
  94. package/dist/endpoints/ura/list-pops.d.ts +0 -19
  95. package/dist/endpoints/ura/list-service-orders.d.ts +0 -64
  96. package/dist/endpoints/ura/open-ticket.d.ts +0 -81
  97. package/dist/errors.d.ts +0 -59
  98. package/dist/schema/parse.d.ts +0 -19
  99. package/dist/schema/paths.d.ts +0 -38
  100. package/dist/transport.d.ts +0 -65
@@ -0,0 +1,145 @@
1
+ import type { Exposure } from "./exposure.js";
2
+ import type { ResponseBody, SchemaWarning } from "./result.js";
3
+ import type { OperationSensitivity } from "./sensitivity.js";
4
+ /**
5
+ * How a request body is encoded; the executor switches on it. `form` is `multipart/form-data`
6
+ * without files: every param is a text field and the content-type (with its boundary) is left to
7
+ * `fetch`.
8
+ */
9
+ export type Encoding = "json" | "form";
10
+ /**
11
+ * The encodings an operation may declare: {@link Encoding} plus `form-files`, `multipart/form-data`
12
+ * with file parts next to the text fields (the file parts come from `RequestBuild.files`). Only
13
+ * typed operations use it: `request()` takes {@link Encoding}.
14
+ */
15
+ type OperationEncoding = Encoding | "form-files";
16
+ /** A file sent as one part of a `form-files` body. */
17
+ export interface FilePart {
18
+ /** The bytes of the file: a `Blob`, raw bytes or an `ArrayBuffer`, sent as they are. */
19
+ data: Blob | Uint8Array | ArrayBuffer;
20
+ /** Name SGP sees for the part. */
21
+ filename: string;
22
+ /** MIME type of the part. Defaults to the `type` of a `Blob`; none for raw bytes. */
23
+ contentType?: string;
24
+ }
25
+ /** The fields every operation has, read or write. */
26
+ interface OperationFields<Data, Name extends string> {
27
+ /** Public name, e.g. `customers.list`; also the `operation` of hooks and errors. */
28
+ name: Name;
29
+ method: "GET" | "POST" | "PUT" | "DELETE";
30
+ /** Path template starting with `/`; `{name}` placeholders are filled from `pathParams`. */
31
+ pathTemplate: string;
32
+ /**
33
+ * Hook metadata leaves out `pathTemplate`: for a call whose path is a literal chosen by the
34
+ * caller (`request()`), not a template. Absent means the template is shown.
35
+ */
36
+ omitPathFromHooks?: boolean;
37
+ /** Body encoding of POST/PUT/DELETE. A GET has no body: its params go in the query string. */
38
+ encoding: OperationEncoding;
39
+ /** Validates the raw input and builds the request. No I/O. */
40
+ buildRequest: (input: unknown) => RequestBuild;
41
+ /**
42
+ * Recognizes a 2xx body that is a known refusal (a 200 that did not do what was asked). Pure.
43
+ * `undefined` when the body is not a refusal.
44
+ */
45
+ detectRefusal?: (body: ResponseBody) => Refusal | undefined;
46
+ /** Checks a 2xx body against the contract the method promises. Pure, no I/O. */
47
+ decode: (body: ResponseBody) => DecodeOutcome<Data>;
48
+ /**
49
+ * Secret and personal keys of the request and of the 2xx body, per item path. Required: the
50
+ * single source `getSensitivity` reads. A definition with nothing sensitive says
51
+ * `{ input: [], output: [] }`.
52
+ */
53
+ sensitivity: OperationSensitivity;
54
+ /**
55
+ * For an operation whose response mixes records outside the requested scope: the executor
56
+ * withholds the body and keeps only message strings in `error.sgp`, on every status and path,
57
+ * before it builds any public object. Absent means the body is the evidence, as everywhere else.
58
+ */
59
+ exposure?: Exposure;
60
+ }
61
+ /**
62
+ * INTERNAL. An operation is data plus a few small pure functions; the executor does everything else.
63
+ * Not exported from the package: consumers only see the client methods, their types and options.
64
+ *
65
+ * A read may be `repeatable` (the retry gate of the operation contract; absent means `false`). A write, marked by
66
+ * `write`, carries an `effect` on every failure and is never repeatable: the type forbids
67
+ * `repeatable: true` next to `write`, and the executor refuses such a definition.
68
+ */
69
+ export type OperationDefinition<Data, Name extends string = string> = (OperationFields<Data, Name> & {
70
+ repeatable?: boolean;
71
+ write?: undefined;
72
+ }) | (OperationFields<Data, Name> & {
73
+ repeatable?: false;
74
+ write: WriteSpec;
75
+ });
76
+ /** What a write declares about itself on top of the default effect rules of the operation contract. */
77
+ export interface WriteSpec {
78
+ /**
79
+ * Every failure after a request was sent has effect `unknown`, whatever the status and body say:
80
+ * for a call the SDK does not interpret (`request()`), where no rejection is known to apply
81
+ * nothing. Absent means the default rules of the operation contract.
82
+ */
83
+ effectUnknownAfterSend?: boolean;
84
+ /**
85
+ * Remote rejections this operation is proven to apply no effect for, whatever their body shape
86
+ * (in particular SGP's generic `errors` array, which is `unknown` by default). Declare one only
87
+ * with captured evidence for this operation.
88
+ */
89
+ knownRejections?: readonly KnownRejection[];
90
+ }
91
+ /** A remote 4xx known to leave the requested change unapplied. Gives the failure its `reason`. */
92
+ export interface KnownRejection {
93
+ /** HTTP status of the rejection. Must be 4xx: any other status is never matched. */
94
+ status: number;
95
+ /** Recognizes the rejection from the body. Pure; must say `false` for a body it cannot read. */
96
+ matches: (body: ResponseBody) => boolean;
97
+ /** Value of `SgpError.reason`. */
98
+ reason: string;
99
+ }
100
+ /** What `buildRequest` returns: the request to send, or the first problem with the input. */
101
+ export type RequestBuild = {
102
+ ok: true;
103
+ /** Values for the `{name}` placeholders of the path template. */
104
+ pathParams?: Readonly<Record<string, string | number>>;
105
+ /**
106
+ * Request fields: the body for POST/PUT/DELETE, the query string for GET. `undefined` values
107
+ * are omitted. A GET or a `form` body takes primitives only (a `json` body takes any value).
108
+ */
109
+ params?: Readonly<Record<string, unknown>>;
110
+ /**
111
+ * Fields that go in the URL of a request that has a body (POST/PUT/DELETE), after the path;
112
+ * `params` and the credentials stay in the body. Primitives only, `undefined` omitted, never
113
+ * `token` or `app`. A GET puts everything in its query string already: a GET with `query` is
114
+ * refused (`INVALID_INPUT`).
115
+ */
116
+ query?: Readonly<Record<string, unknown>>;
117
+ /** File parts by field name; only a `form-files` body sends them, after the text fields. */
118
+ files?: Readonly<Record<string, FilePart>>;
119
+ } | {
120
+ ok: false;
121
+ problem: string;
122
+ /** Value-free issues (field path, then what was expected) that become `error.issues`. */
123
+ issues?: readonly string[];
124
+ };
125
+ /**
126
+ * A recognized refusal inside a 2xx response. `effect: "none"` only with a read-back that showed
127
+ * nothing was created; absent, the effect of a write stays `unknown`.
128
+ */
129
+ export interface Refusal {
130
+ reason?: string;
131
+ effect?: "none";
132
+ }
133
+ /**
134
+ * Result of checking a 2xx body. `warnings` lists the non-essential fields the decoder had to drop
135
+ * from `data`; it is absent when nothing was dropped.
136
+ */
137
+ export type DecodeOutcome<Data> = {
138
+ ok: true;
139
+ data: Data;
140
+ warnings?: readonly SchemaWarning[];
141
+ } | {
142
+ ok: false;
143
+ issues: readonly string[];
144
+ };
145
+ export {};
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const billingProfilesSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ codigo_banco: z.ZodNullable<z.ZodOptional<z.ZodString>>;
7
+ }, z.core.$loose>>;
8
+ /**
9
+ * The response of `GET /api/ura/portador/`, in SGP's own shape: a bare array with one entry per
10
+ * billing profile (SGP "portador"). The route is not paginated, so there is no envelope and no
11
+ * total.
12
+ */
13
+ export type CatalogsListBillingProfilesData = z.output<typeof billingProfilesSchema>;
14
+ /** INTERNAL definition of `catalogs.listBillingProfiles`. */
15
+ export declare const catalogsListBillingProfiles: OperationDefinition<CatalogsListBillingProfilesData, "catalogs.listBillingProfiles">;
16
+ export {};
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const nasListSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ identificador: z.ZodNullable<z.ZodOptional<z.ZodString>>;
7
+ endereco_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
9
+ pops: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
10
+ id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
11
+ cidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
+ uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ codigo_ibge: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
14
+ ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
15
+ }, z.core.$loose>>>>;
16
+ }, z.core.$loose>>;
17
+ /**
18
+ * The response of `POST /api/ura/nas/list/`, in SGP's own shape: a bare array with one entry per
19
+ * NAS (network access server) and the POPs each one serves. The route is not paginated, so there is
20
+ * no envelope and no total.
21
+ */
22
+ export type CatalogsListNasData = z.output<typeof nasListSchema>;
23
+ /** INTERNAL definition of `catalogs.listNas`. */
24
+ export declare const catalogsListNas: OperationDefinition<CatalogsListNasData, "catalogs.listNas">;
25
+ export {};
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const popsSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ }, z.core.$loose>>;
7
+ /**
8
+ * The response of `POST /api/ura/pops/`, in SGP's own shape: a bare array with one entry per POP
9
+ * (point of presence). The route is not paginated, so there is no envelope and no total.
10
+ */
11
+ export type CatalogsListPopsData = z.output<typeof popsSchema>;
12
+ /** INTERNAL definition of `catalogs.listPops`. */
13
+ export declare const catalogsListPops: OperationDefinition<CatalogsListPopsData, "catalogs.listPops">;
14
+ export {};
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const connectionsSchema: z.ZodArray<z.ZodObject<{
4
+ status: z.ZodNumber;
5
+ msg: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ servico_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
+ contratoId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
8
+ login: z.ZodNullable<z.ZodOptional<z.ZodString>>;
9
+ razaoSocial: z.ZodNullable<z.ZodOptional<z.ZodString>>;
10
+ cpfCnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
+ }, z.core.$loose>>;
12
+ /**
13
+ * The verdict of SGP on a contract's connection: ALWAYS an array, one item per internet service
14
+ * (`status`, `msg`, and the service, contract and holder it speaks of). SGP's answer varies: an
15
+ * array, `[]` when the contract is outside its default filter (observed on a suspended contract
16
+ * without `status_all`), or ONE bare object (observed on an active contract without `status_all`).
17
+ * The SDK wraps the bare object, so a consumer reads one shape; `response.body` keeps what SGP sent,
18
+ * and the paths of `warnings` and `issues` refer to the array form (`[0].login`). `[]` is not
19
+ * "offline": it means SGP gave no verdict (try `status_all: 1`).
20
+ */
21
+ export type ContractsCheckConnectionData = z.output<typeof connectionsSchema>;
22
+ /**
23
+ * Input of `contracts.checkConnection`, named as SGP names the fields. At least one of `contrato`
24
+ * and `telefone`. `protocolo_ura` is NOT offered: it explicitly asks SGP to open an occurrence (use
25
+ * `occurrences.create`).
26
+ */
27
+ export interface ContractsCheckConnectionInput {
28
+ /** Exercised. The contract to check. */
29
+ contrato?: number;
30
+ /** Documented, never sent. The phone of the customer, instead of the contract. */
31
+ telefone?: string;
32
+ /**
33
+ * Exercised. Also checks the contracts the default filter leaves out (suspended ones): without it a
34
+ * suspended contract answered `[]`. Sent as `1`.
35
+ */
36
+ status_all?: 1;
37
+ /** Documented, never sent. SGP's status filter; its accepted values are not documented. */
38
+ status_filter?: string;
39
+ /** Documented, never sent. SGP's URA contact; its meaning and format are not documented. */
40
+ uracontato?: string;
41
+ }
42
+ /** INTERNAL. Validation of the input, exported so a test can check its keys are classified. */
43
+ export declare const contractsCheckConnectionInputSchema: z.ZodObject<{
44
+ contrato: z.ZodOptional<z.ZodNumber>;
45
+ telefone: z.ZodOptional<z.ZodString>;
46
+ status_all: z.ZodOptional<z.ZodLiteral<1>>;
47
+ status_filter: z.ZodOptional<z.ZodString>;
48
+ uracontato: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strict>;
50
+ /**
51
+ * INTERNAL definition of `contracts.checkConnection`. A WRITE, though it looks like a read: the
52
+ * vendor documents that, under an active maintenance, SGP opens an occurrence by default, even
53
+ * without `protocolo_ura` (never tested). So it is never retried and its failures carry an effect.
54
+ */
55
+ export declare const contractsCheckConnection: OperationDefinition<ContractsCheckConnectionData, "contracts.checkConnection">;
56
+ export {};
@@ -0,0 +1,103 @@
1
+ import { z } from "zod";
2
+ import { type CustomerId } from "../ids.js";
3
+ import type { OperationDefinition } from "../operation.js";
4
+ declare const rowsSchema: z.ZodArray<z.ZodObject<{
5
+ servico_id: z.ZodPipe<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>, z.ZodNumber>;
6
+ servico_tipo: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
+ servico_login: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ servico_password: z.ZodNullable<z.ZodOptional<z.ZodString>>;
9
+ servico_mac: z.ZodNullable<z.ZodOptional<z.ZodString>>;
10
+ servico_online: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
11
+ nas_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
+ servicos: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
13
+ contrato_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
14
+ contrato_status: z.ZodNullable<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
15
+ contrato_status_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
16
+ contrato_status_data: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
+ contrato_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ contrato_pop_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
19
+ contrato_pop_nome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ contrato_endereco_ll: z.ZodNullable<z.ZodOptional<z.ZodString>>;
21
+ cliente_id: z.ZodNullable<z.ZodOptional<z.core.$ZodBranded<z.ZodNumber, "CustomerId", "out">>>;
22
+ cliente_nome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ cliente_email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ cliente_contato: z.ZodNullable<z.ZodOptional<z.ZodString>>;
25
+ endereco_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
26
+ endereco_logradouro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
27
+ endereco_numero: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
28
+ endereco_complemento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ endereco_bairro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
+ endereco_cidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
31
+ endereco_uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ endereco_pontoreferencia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
33
+ endereco_ll: z.ZodNullable<z.ZodOptional<z.ZodString>>;
34
+ plano_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
35
+ plano: z.ZodNullable<z.ZodOptional<z.ZodString>>;
36
+ plano_download: z.ZodNullable<z.ZodOptional<z.ZodString>>;
37
+ plano_upload: z.ZodNullable<z.ZodOptional<z.ZodString>>;
38
+ os_servicoprestado: z.ZodNullable<z.ZodOptional<z.ZodString>>;
39
+ rad_username: z.ZodNullable<z.ZodOptional<z.ZodString>>;
40
+ rad_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
41
+ rad_mac: z.ZodNullable<z.ZodOptional<z.ZodString>>;
42
+ rad_nasipaddress: z.ZodNullable<z.ZodOptional<z.ZodString>>;
43
+ rad_nasportid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
44
+ rad_nasporttype: z.ZodNullable<z.ZodOptional<z.ZodString>>;
45
+ rad_calledstationid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
46
+ rad_acctsessionid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
+ rad_radacctid: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
48
+ rad_dataconexao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
49
+ rad_tempo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
50
+ rad_tempo_ordem: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
51
+ rad_acctinputoctets: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
52
+ rad_acctoutputoctets: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
53
+ rad_framedprotocol: z.ZodNullable<z.ZodOptional<z.ZodString>>;
54
+ rad_framedipv6prefix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
55
+ rad_delegatedipv6prefix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
56
+ }, z.core.$loose>>;
57
+ /**
58
+ * The response of `POST /api/suporte/contrato/list/`, in SGP's own shape: a bare array with ONE ROW
59
+ * PER SERVICE (internet and TV) of the matching contracts, each repeating the customer, contract,
60
+ * address and plan. `[]` when nothing matches. A row of an ONLINE internet service also carries the
61
+ * RADIUS session (`rad_*`: user, IP, MAC, NAS, session ids, connection time, octet counters).
62
+ *
63
+ * Normalized: `servico_id`, `contrato_id`, `contrato_status_id`, `contrato_pop_id`,
64
+ * `rad_radacctid`, `rad_tempo_ordem`, `rad_acctinputoctets` and `rad_acctoutputoctets` are numbers
65
+ * (SGP sends the first four as text); `contrato_status` is trimmed (SGP pads it with spaces). The
66
+ * row's `servico_id` is an invariant: a row without a numeric one is `INVALID_RESPONSE`.
67
+ *
68
+ * It holds PLAINTEXT CREDENTIALS and network identifiers (`servico_password`, `servico_login`,
69
+ * MACs, IPs, NAS, session ids): see `getSensitivity("contracts.listServices")` and project with
70
+ * `pick` before logging or handing it on.
71
+ */
72
+ export type ContractsListServicesData = z.output<typeof rowsSchema>;
73
+ /**
74
+ * Filters of `contracts.listServices`, named as SGP names them (the vendor's collection documents
75
+ * all five). All optional, as the vendor marks none as required.
76
+ *
77
+ * At least one filter is required: without one SGP lists the services of EVERY customer, with
78
+ * plaintext service passwords, so the SDK refuses the call locally (`INVALID_INPUT`, `attempts` 0,
79
+ * nothing sent). There is no paging input. Filter by `contrato_id` whenever you can. Text filters are sent as given; SGP decides how it matches them.
80
+ */
81
+ export interface ContractsListServicesInput {
82
+ /** Exercised. Only the services of this contract (the `contrato_id` of a row, a number). */
83
+ contrato_id?: number;
84
+ /** Exercised. Only the services of the customer with this id (a `CustomerId`, never a contract id). */
85
+ cliente_id?: CustomerId;
86
+ /** Documented, never sent. Only the customer with this name. */
87
+ cliente_nome?: string;
88
+ /** Documented, never sent. Only the customer with this CPF/CNPJ. */
89
+ cliente_cpfcnpj?: string;
90
+ /** Documented, never sent. Only the service with this login. */
91
+ servico_login?: string;
92
+ }
93
+ /** INTERNAL. Validation of the input, exported so a test can check its keys are classified. */
94
+ export declare const contractsListServicesInputSchema: z.ZodObject<{
95
+ contrato_id: z.ZodOptional<z.ZodNumber>;
96
+ cliente_id: z.ZodOptional<z.core.$ZodBranded<z.ZodNumber, "CustomerId", "out">>;
97
+ cliente_nome: z.ZodOptional<z.ZodString>;
98
+ cliente_cpfcnpj: z.ZodOptional<z.ZodString>;
99
+ servico_login: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strict>;
101
+ /** INTERNAL definition of `contracts.listServices`. */
102
+ export declare const contractsListServices: OperationDefinition<ContractsListServicesData, "contracts.listServices">;
103
+ export {};
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const statusReasonsSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ motivo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ }, z.core.$loose>>;
7
+ /**
8
+ * The response of `POST /api/ura/contrato/status/motivos/`, in SGP's own shape: a bare array of
9
+ * `{ id, motivo }`, one entry per reason the provider can register with a status change. Each
10
+ * provider has its own list. The route is not paginated, so there is no envelope and no total.
11
+ */
12
+ export type ContractsListStatusReasonsData = z.output<typeof statusReasonsSchema>;
13
+ /** INTERNAL definition of `contracts.listStatusReasons`. */
14
+ export declare const contractsListStatusReasons: OperationDefinition<ContractsListStatusReasonsData, "contracts.listStatusReasons">;
15
+ export {};
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ import type { PlanId } from "./plans-list.js";
4
+ declare const contractsSchema: z.ZodArray<z.ZodObject<{
5
+ id_contrato: z.ZodNumber;
6
+ id_cliente: z.core.$ZodBranded<z.ZodNumber, "CustomerId", "out">;
7
+ status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ pop_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
9
+ nome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
10
+ cpfcnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
+ email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
+ telefone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ data_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ data_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
15
+ motivo_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
16
+ }, z.core.$loose>>;
17
+ /**
18
+ * The response of `POST /api/ura/listacontrato/`, in SGP's own shape: a bare array with one summary
19
+ * per matching contract. The route is not paginated, so there is no `paginacao`, no total and no
20
+ * envelope. An empty array means no contract matched.
21
+ */
22
+ export type ContractsListData = z.output<typeof contractsSchema>;
23
+ /** Filters of `contracts.list`, named as SGP names them. All optional. */
24
+ export interface ContractsListInput {
25
+ /** Only the contract with this id. */
26
+ contrato?: number;
27
+ /**
28
+ * Only contracts linked to this plan. The id comes from `plans.list` (the catalog of existing
29
+ * services and contracts), never from `preRegistrations.listPlans`.
30
+ */
31
+ plano?: PlanId;
32
+ /** Person type, as SGP names it (see SGP's public documentation for the values). */
33
+ tipo?: string;
34
+ /** Contract status code (see `CONTRACT_STATUS`; any number is sent). */
35
+ status?: number;
36
+ /**
37
+ * Ask SGP to include the address. The address fields were never captured: they reach `data` as
38
+ * received but untyped, and they are personal data (see `getSensitivity`; use `pick`).
39
+ */
40
+ exibir_endereco?: boolean;
41
+ }
42
+ /** INTERNAL. Validation of the input, exported so a test can check its keys are classified. */
43
+ export declare const contractsListInputSchema: z.ZodObject<{
44
+ contrato: z.ZodOptional<z.ZodNumber>;
45
+ plano: z.ZodOptional<z.ZodNumber>;
46
+ tipo: z.ZodOptional<z.ZodString>;
47
+ status: z.ZodOptional<z.ZodNumber>;
48
+ exibir_endereco: z.ZodOptional<z.ZodBoolean>;
49
+ }, z.core.$strict>;
50
+ /** INTERNAL definition of `contracts.list`. */
51
+ export declare const contractsList: OperationDefinition<ContractsListData, "contracts.list">;
52
+ export {};
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ /**
4
+ * Input of `contracts.updateStatus`, named as SGP names the fields. Both codes are sent as given:
5
+ * SGP decides what it takes and which transitions it allows.
6
+ */
7
+ export interface ContractUpdateStatusInput {
8
+ /** Exercised. ID of the contract (the `id` of `customers.list` -> `contratos[]`). */
9
+ contrato: number;
10
+ /** Exercised with 1 and 4. Status code to move to (`CONTRACT_STATUS`); any number is sent. */
11
+ status: number;
12
+ /**
13
+ * Documented, always sent in observed calls (1 and 5); a call without it was never exercised.
14
+ * ID of the reason (motivo de status) registered with the change. The list is the provider's
15
+ * own: read it with `contracts.listStatusReasons`, never assume a value. Omitted: no `motivo`
16
+ * is sent.
17
+ */
18
+ motivo?: number;
19
+ }
20
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
21
+ export declare const contractsUpdateStatusInputSchema: z.ZodObject<{
22
+ contrato: z.ZodNumber;
23
+ status: z.ZodNumber;
24
+ motivo: z.ZodOptional<z.ZodNumber>;
25
+ }, z.core.$strict>;
26
+ /**
27
+ * Success body of `POST /api/ura/contrato/status/edit/`: SGP's `resposta`, which names the contract
28
+ * and the status it is in now. Other keys SGP may add are kept.
29
+ */
30
+ declare const statusChangedSchema: z.ZodObject<{
31
+ resposta: z.ZodObject<{
32
+ mensagem: z.ZodNullable<z.ZodOptional<z.ZodString>>;
33
+ contrato: z.ZodNumber;
34
+ contrato_status: z.ZodString;
35
+ }, z.core.$loose>;
36
+ }, z.core.$loose>;
37
+ /** Response of `contracts.updateStatus`. */
38
+ export type ContractUpdateStatusData = z.output<typeof statusChangedSchema>;
39
+ /** INTERNAL definition of `contracts.updateStatus`. */
40
+ export declare const contractsUpdateStatus: OperationDefinition<ContractUpdateStatusData, "contracts.updateStatus">;
41
+ export {};
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ /**
4
+ * Input of `contracts.update`. Only the field whose format and behavior are known is accepted: the
5
+ * other keys the vendor documents (`portador`, `debito_*`, `sms_desativado`, `tag_add`,
6
+ * `tag_remove`) have no known types, so they stay reachable through `request()` until documented.
7
+ */
8
+ export interface ContractUpdateInput {
9
+ /** Exercised. ID of the contract (the `id` of `customers.list` -> `contratos[]`). */
10
+ contrato: number;
11
+ /**
12
+ * Exercised with 3 and 1. Billing-method code (`BILLING_METHOD`: 1 boleto, 2 automatic debit, 3
13
+ * booklet, 4 recurring charge, 6 PIX); any number is sent as given. Code 5 appears in SGP's panel
14
+ * select for this route only and was never confirmed, so it has no constant. Changing it changes
15
+ * how the contract is billed.
16
+ */
17
+ forma_cobranca: number;
18
+ }
19
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
20
+ export declare const contractsUpdateInputSchema: z.ZodObject<{
21
+ contrato: z.ZodNumber;
22
+ forma_cobranca: z.ZodNumber;
23
+ }, z.core.$strict>;
24
+ /**
25
+ * Success body of `POST /api/ura/contrato/edit/`: SGP's `resposta`, with the contract and the list
26
+ * of fields SGP says it applied (`alterados`, returned as-is). Other keys SGP may add are kept.
27
+ */
28
+ declare const contractUpdatedSchema: z.ZodObject<{
29
+ resposta: z.ZodObject<{
30
+ mensagem: z.ZodNullable<z.ZodOptional<z.ZodString>>;
31
+ contrato: z.ZodNumber;
32
+ alterados: z.ZodArray<z.ZodString>;
33
+ }, z.core.$loose>;
34
+ }, z.core.$loose>;
35
+ /** Response of `contracts.update`. */
36
+ export type ContractUpdateData = z.output<typeof contractUpdatedSchema>;
37
+ /** INTERNAL definition of `contracts.update`. */
38
+ export declare const contractsUpdate: OperationDefinition<ContractUpdateData, "contracts.update">;
39
+ export {};
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ /**
4
+ * Input of `coverage.checkAddress`, named as SGP names the fields. The vendor's collection says
5
+ * "use one of the filters", so at least one is required, or the call is refused locally
6
+ * (`INVALID_INPUT`, nothing sent). How filters combine is SGP's decision: only `cep` alone and
7
+ * `cidade` alone were exercised.
8
+ */
9
+ export interface CoverageCheckAddressInput {
10
+ /** Exercised. Postal code, as SGP keeps it (digits only in the capture). */
11
+ cep?: string;
12
+ /** Exercised. City name, as SGP spells it (upper case in the capture). */
13
+ cidade?: string;
14
+ /** Documented, never sent. Street. */
15
+ logradouro?: string;
16
+ /** Documented, never sent. Neighborhood. */
17
+ bairro?: string;
18
+ /** Documented, never sent. Lowest street number to include (the vendor: "from a street number"). */
19
+ numero_inicial?: number | string;
20
+ /** Documented, never sent. Highest street number to include (the vendor: "up to a street number"). */
21
+ numero_final?: number | string;
22
+ }
23
+ /** INTERNAL. Validation of the input, exported so a test can check its keys are classified. */
24
+ export declare const coverageCheckAddressInputSchema: z.ZodObject<{
25
+ cep: z.ZodOptional<z.ZodString>;
26
+ cidade: z.ZodOptional<z.ZodString>;
27
+ logradouro: z.ZodOptional<z.ZodString>;
28
+ bairro: z.ZodOptional<z.ZodString>;
29
+ numero_inicial: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
30
+ numero_final: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
31
+ }, z.core.$strict>;
32
+ declare const answerSchema: z.ZodObject<{
33
+ viabilidade: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
34
+ }, z.core.$loose>;
35
+ /**
36
+ * The response of `POST /api/ura/viabilidade/`, in SGP's own shape, kept as received. Observed:
37
+ * `{ "viabilidade": true }` (a postal code) and `{}` (a city alone).
38
+ *
39
+ * A MISSING `viabilidade` MEANS UNKNOWN, NEVER "NO COVERAGE": SGP answered `{}` for a city it
40
+ * could not decide on. Do not read `data.viabilidade ?? false`. The "no coverage" answer was NEVER
41
+ * OBSERVED: whether SGP sends `false` is not known, so a `false` is passed through as it comes.
42
+ */
43
+ export type CoverageCheckAddressData = z.output<typeof answerSchema>;
44
+ /** INTERNAL definition of `coverage.checkAddress`. */
45
+ export declare const coverageCheckAddress: OperationDefinition<CoverageCheckAddressData, "coverage.checkAddress">;
46
+ export {};
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ /** Input of `coverage.check`, named as SGP names the fields. All three are required. */
4
+ export interface CoverageCheckInput {
5
+ /**
6
+ * Exercised. ID of the map gateway SGP checks against. Read the provider's own list with
7
+ * `coverage.listGateways`, never assume a value.
8
+ */
9
+ gateway: number;
10
+ /** Exercised. Search radius in meters. */
11
+ raio: number;
12
+ /**
13
+ * Exercised. The coordinate to check, `"lat,lng"` (for example `"-23.55,-46.63"`). The SDK does
14
+ * not geocode: bring the coordinate yourself. Sent as given; SGP decides what it accepts.
15
+ */
16
+ coordenada: string;
17
+ }
18
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
19
+ export declare const coverageCheckInputSchema: z.ZodObject<{
20
+ gateway: z.ZodNumber;
21
+ raio: z.ZodNumber;
22
+ coordenada: z.ZodString;
23
+ }, z.core.$strict>;
24
+ declare const ctoSchema: z.ZodObject<{
25
+ lat: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
26
+ lng: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
27
+ distancia: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
28
+ id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
29
+ nome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
+ }, z.core.$loose>;
31
+ /** One CTO (the nearest network box) within the radius, as the gateway reports it. */
32
+ export type CoverageCto = z.output<typeof ctoSchema>;
33
+ /**
34
+ * The response of `GET /api/ura/viabilidadeinstalacao`, in SGP's own shape: an array whose
35
+ * element is an object keyed by the gateway's own name (`"SGPMaps"`, `"Geogrid"`: data-defined),
36
+ * holding either the CTOs within the radius or a message (`"Localização inviável"`) when there
37
+ * are none. A CTO's `lat`, `lng`, `distancia` and `id` are numbers (`null` for `""`/`null`): Geogrid's
38
+ * numeric strings are converted, SGPMaps' numbers pass through (changed versus 2.0.0-beta.1).
39
+ */
40
+ export type CoverageCheckData = Array<Record<string, string | CoverageCto[]>>;
41
+ /** INTERNAL definition of `coverage.check`. */
42
+ export declare const coverageCheck: OperationDefinition<CoverageCheckData, "coverage.check">;
43
+ export {};
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const gatewaysSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ descricao: z.ZodString;
6
+ gateway: z.ZodNullable<z.ZodOptional<z.ZodString>>;
7
+ }, z.core.$loose>>;
8
+ /**
9
+ * The response of `GET /api/ura/listgatewaymapa`, in SGP's own shape: a bare array with one entry
10
+ * per map gateway (SGP "Mapa FTTH"). The `id` is the `gateway` that `coverage.check` takes. The
11
+ * route is not paginated, so there is no envelope and no total.
12
+ */
13
+ export type CoverageListGatewaysData = z.output<typeof gatewaysSchema>;
14
+ /** INTERNAL definition of `coverage.listGateways`. */
15
+ export declare const coverageListGateways: OperationDefinition<CoverageListGatewaysData, "coverage.listGateways">;
16
+ export {};