sgp-sdk 2.0.0-beta.1 → 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 (33) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/COMPATIBILITY.md +161 -81
  3. package/MIGRATION.md +66 -5
  4. package/README.md +111 -69
  5. package/dist/client.d.ts +303 -26
  6. package/dist/constants.d.ts +13 -0
  7. package/dist/document.d.ts +11 -0
  8. package/dist/index.d.ts +13 -3
  9. package/dist/index.js +1510 -708
  10. package/dist/normalize.d.ts +9 -0
  11. package/dist/operation-sensitivity.d.ts +239 -6
  12. package/dist/operation.d.ts +7 -1
  13. package/dist/operations/contracts-check-connection.d.ts +56 -0
  14. package/dist/operations/contracts-list-services.d.ts +103 -0
  15. package/dist/operations/coverage-check-address.d.ts +46 -0
  16. package/dist/operations/coverage-check.d.ts +8 -7
  17. package/dist/operations/coverage-list-gateways.d.ts +16 -0
  18. package/dist/operations/crm-customers-create.d.ts +13 -3
  19. package/dist/operations/customers-list.d.ts +6 -0
  20. package/dist/operations/invoices-list.d.ts +11 -5
  21. package/dist/operations/maintenance-list.d.ts +35 -0
  22. package/dist/operations/occurrences-create.d.ts +10 -1
  23. package/dist/operations/occurrences-list.d.ts +127 -0
  24. package/dist/operations/pre-registrations-create.d.ts +29 -6
  25. package/dist/operations/pre-registrations-list-plans.d.ts +2 -2
  26. package/dist/operations/services-add-generic.d.ts +52 -0
  27. package/dist/operations/services-add-tv.d.ts +3 -3
  28. package/dist/operations/services-remove-generic.d.ts +28 -0
  29. package/dist/operations/services-remove-tv.d.ts +3 -3
  30. package/dist/operations/work-orders-get.d.ts +99 -0
  31. package/dist/operations/work-orders-list-comments.d.ts +34 -0
  32. package/dist/result.d.ts +5 -1
  33. package/package.json +1 -1
@@ -11,7 +11,7 @@ declare const pageSchema: z.ZodObject<{
11
11
  titulos: z.ZodArray<z.ZodObject<{
12
12
  id: z.ZodNumber;
13
13
  status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
- valor: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
14
+ valor: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
15
15
  dataVencimento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
16
16
  clienteNome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
17
  clienteCpfcnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -21,10 +21,10 @@ declare const pageSchema: z.ZodObject<{
21
21
  nossoNumero: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
22
  link: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
23
  link_cobranca: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
- valorDesconto: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
25
- valorCorrigido: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
26
- valorPago: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
27
- valorPagoParcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
24
+ valorDesconto: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
25
+ valorCorrigido: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
26
+ valorPago: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
27
+ valorPagoParcial: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
28
28
  codigoBarras: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
29
  linhaDigitavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
30
  codigoPix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -48,6 +48,12 @@ declare const pageSchema: z.ZodObject<{
48
48
  * - `parcial`: how many invoices this page holds (observed equal to `titulos.length`);
49
49
  * - `total`: how many invoices match the filters in all, across every page.
50
50
  *
51
+ * Money is normalized: `valor`, `valorDesconto`, `valorCorrigido`, `valorPago` and
52
+ * `valorPagoParcial` are a `number` (reais) or `null`. SGP sends `valor` as a number or as `""` for an
53
+ * absent amount (`null`, never `0`); numeric text with `.` is read as a number; formatted text such
54
+ * as `"1.234,56"` is never guessed: the field leaves `data` with a warning and stays in
55
+ * `response.body`. Changed versus 2.0.0-beta.1 (where `""` dropped the field).
56
+ *
51
57
  * `total` is SGP's and never computed by the SDK: a page without a numeric `total` is
52
58
  * `INVALID_RESPONSE`. Nothing here fetches the next page: ask for it with `offset`.
53
59
  */
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const maintenancesSchema: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ data_inicial: z.ZodNullable<z.ZodOptional<z.ZodString>>;
7
+ data_final: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ observacoes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
9
+ mensagem_central: z.ZodNullable<z.ZodOptional<z.ZodString>>;
10
+ mensagem_ura: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
+ enviar_sms: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
12
+ ativa: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
13
+ severidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
15
+ pops: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
16
+ nas: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
17
+ aps: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
18
+ sources: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
19
+ switches: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
20
+ olts: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
21
+ oltpons: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
22
+ ctos: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
23
+ vlans: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
24
+ }, z.core.$loose>>;
25
+ /**
26
+ * The response of `GET /api/ura/manutencao/list/`, in SGP's own shape: a bare array with one entry
27
+ * per maintenance notice (SGP "manutenção"), INACTIVE ONES INCLUDED (the one capture held three
28
+ * past notices, all with `ativa: false`). The route takes no filter, is not paginated and has no
29
+ * envelope or total: filter by `ativa` and by the period (`data_inicial`, `data_final`) yourself.
30
+ * An empty array means no notice.
31
+ */
32
+ export type MaintenanceListData = z.output<typeof maintenancesSchema>;
33
+ /** INTERNAL definition of `maintenance.list`. */
34
+ export declare const maintenanceList: OperationDefinition<MaintenanceListData, "maintenance.list">;
35
+ export {};
@@ -4,6 +4,10 @@ import type { OperationDefinition } from "../operation.js";
4
4
  * Input of `occurrences.create`, named as SGP names the fields. An occurrence (SGP "chamado" or
5
5
  * "ocorrência") is the support ticket; SGP opens a work order (OS) with it unless told not to
6
6
  * (`desativa_os`). Only `contrato` is required.
7
+ *
8
+ * Observed live: an occurrence WITHOUT `motivoos` is accepted and SGP still creates a work order;
9
+ * `status_encerrado: 1` closes both the occurrence and the work order; closing an installation work
10
+ * order (`motivoos` 10) did not change the contract status (it stayed inactive; observed once).
7
11
  */
8
12
  export interface OccurrenceCreateInput {
9
13
  /** ID of the contract. Required. */
@@ -51,7 +55,12 @@ export interface OccurrenceCreateInput {
51
55
  responsavel?: string;
52
56
  /** Usernames of the auxiliary technicians. Staff usernames: personal data. */
53
57
  tecnicos?: string[];
54
- /** Schedules the occurrence and the work order: `AAAA-MM-DD HH:MM`. */
58
+ /**
59
+ * Schedules the occurrence and the work order. Send `AAAA-MM-DD HH:MM` (the format SGP's refusal names): SGP
60
+ * refused seconds (`2026-11-13 09:00:00`), observed once live with HTTP 200 and `status` 0 (`REJECTED`, reason
61
+ * `INVALID_SCHEDULE`, effect `none`). SGP decides what is a valid date, so the SDK does not check
62
+ * the format before sending.
63
+ */
55
64
  data_hora_agendamento?: string;
56
65
  /** `1` warns the responsible technician; needs `data_hora_agendamento` and a messaging gateway in SGP. */
57
66
  sms_tecnico?: 0 | 1;
@@ -0,0 +1,127 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const pageSchema: z.ZodObject<{
4
+ paginacao: z.ZodObject<{
5
+ offset: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
6
+ limit: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
+ parcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
8
+ total: z.ZodNumber;
9
+ }, z.core.$loose>;
10
+ ocorrencias: z.ZodArray<z.ZodObject<{
11
+ id: z.ZodNumber;
12
+ cliente: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ contrato: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
14
+ contrato_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
15
+ contrato_status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
16
+ pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
+ numero: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
19
+ status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
20
+ data_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
21
+ data_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
+ data_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ metodo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
25
+ conteudo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
26
+ responsavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
27
+ usuario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
28
+ usuario_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ protocolos_externos: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
30
+ servico: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
31
+ comentarios: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
32
+ ordens_servicos: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
33
+ id: z.ZodNumber;
34
+ status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
35
+ status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
36
+ data_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
37
+ data_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
38
+ data_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
39
+ tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
40
+ tipo_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
41
+ motivo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
42
+ pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
43
+ conteudo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
44
+ responsavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
45
+ tecnicos_auxiliares: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
46
+ usuario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
+ usuario_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
+ }, z.core.$loose>>>>;
49
+ }, z.core.$loose>>;
50
+ }, z.core.$loose>;
51
+ /**
52
+ * One page of `POST /api/ura/ocorrencia/list/`, with SGP's own `paginacao`, returned as received:
53
+ *
54
+ * - `offset`: index of the first occurrence of the page (SGP starts at 0);
55
+ * - `limit`: page size SGP applied, which may differ from the one requested;
56
+ * - `parcial`: how many occurrences this page holds (observed equal to `ocorrencias.length`);
57
+ * - `total`: how many occurrences match the filters in all, across every page.
58
+ *
59
+ * `total` is SGP's and never computed by the SDK: a page without a numeric `total` is
60
+ * `INVALID_RESPONSE`. Nothing here fetches the next page: ask for it with `offset`. Each
61
+ * occurrence carries its work orders in `ordens_servicos`; their `id` is the work order id.
62
+ */
63
+ export type OccurrencesListData = z.output<typeof pageSchema>;
64
+ /**
65
+ * Filters and paging of `occurrences.list`, named as SGP names them (the vendor's collection
66
+ * documents them). All optional: the vendor marks none as required.
67
+ *
68
+ * At least one filter is required: without one SGP lists the occurrences of EVERY customer (the
69
+ * vendor documents up to 1000 per call), with names and free text, so the SDK refuses the call
70
+ * locally (`INVALID_INPUT`, `attempts` 0, nothing sent). `offset` and `limit` are paging, not
71
+ * filters, and do not count. Filter by `contrato` whenever you can. The vendor also documents the array filters
72
+ * `pop` and `tipo` and the hour filters (`hora_*`); they are not offered here, and no key other
73
+ * than those below is accepted.
74
+ */
75
+ export interface OccurrencesListInput {
76
+ /** Documented, never sent. Index of the first occurrence of the page; SGP starts at 0. */
77
+ offset?: number;
78
+ /** Exercised (with `contrato`). Occurrences per page. Non-negative integer; the vendor caps it at 1000. */
79
+ limit?: number;
80
+ /**
81
+ * Documented, never sent. Only the occurrence with this number (`numero` of the result; the vendor
82
+ * calls it "Número da Ocorrência"). Text, as SGP keeps it.
83
+ */
84
+ ocorrencia?: string;
85
+ /**
86
+ * Documented, never sent. Status id of the occurrence (`status_id` of the result). The vendor
87
+ * lists 0 Aberta, 1 Encerrada, 2 Em execução, 3 Pendente.
88
+ */
89
+ status?: number;
90
+ /** Exercised. Only the occurrences of this contract (the `contrato` of the result). */
91
+ contrato?: number;
92
+ /**
93
+ * Documented, never sent. Status id of the contract (`contrato_status_id` of the result), the
94
+ * values of `CONTRACT_STATUS`.
95
+ */
96
+ contrato_status?: number;
97
+ /** Documented, never sent. Registration date from, `AAAA-MM-DD`; use with `data_cadastro_fim`. */
98
+ data_cadastro_inicio?: string;
99
+ /** Documented, never sent. Registration date until, `AAAA-MM-DD`; use with the initial one. */
100
+ data_cadastro_fim?: string;
101
+ /** Documented, never sent. Scheduling date from, `AAAA-MM-DD`; use with `data_agendamento_fim`. */
102
+ data_agendamento_inicio?: string;
103
+ /** Documented, never sent. Scheduling date until, `AAAA-MM-DD`; use with the initial one. */
104
+ data_agendamento_fim?: string;
105
+ /** Documented, never sent. Closing date from, `AAAA-MM-DD`; use with `data_finalizacao_fim`. */
106
+ data_finalizacao_inicio?: string;
107
+ /** Documented, never sent. Closing date until, `AAAA-MM-DD`; use with the initial one. */
108
+ data_finalizacao_fim?: string;
109
+ }
110
+ /** INTERNAL. Validation of the input, exported so a test can check its keys are classified. */
111
+ export declare const occurrencesListInputSchema: z.ZodObject<{
112
+ offset: z.ZodOptional<z.ZodNumber>;
113
+ limit: z.ZodOptional<z.ZodNumber>;
114
+ ocorrencia: z.ZodOptional<z.ZodString>;
115
+ status: z.ZodOptional<z.ZodNumber>;
116
+ contrato: z.ZodOptional<z.ZodNumber>;
117
+ contrato_status: z.ZodOptional<z.ZodNumber>;
118
+ data_cadastro_inicio: z.ZodOptional<z.ZodString>;
119
+ data_cadastro_fim: z.ZodOptional<z.ZodString>;
120
+ data_agendamento_inicio: z.ZodOptional<z.ZodString>;
121
+ data_agendamento_fim: z.ZodOptional<z.ZodString>;
122
+ data_finalizacao_inicio: z.ZodOptional<z.ZodString>;
123
+ data_finalizacao_fim: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strict>;
125
+ /** INTERNAL definition of `occurrences.list`. */
126
+ export declare const occurrencesList: OperationDefinition<OccurrencesListData, "occurrences.list">;
127
+ export {};
@@ -23,7 +23,18 @@ interface PreRegistrationAddress extends SgpAddress {
23
23
  interface PreRegistrationCreateCommon extends PreRegistrationAddress {
24
24
  /** Exercised. Customer name; for a company, its corporate name. Required by SGP. */
25
25
  nome: string;
26
- /** Exercised. CPF (`F`) or CNPJ (`J`), in the format SGP stores it. */
26
+ /**
27
+ * Exercised. A CPF on `personType: "F"`, a CNPJ on `"J"`. SGP stores it exactly as sent, so the
28
+ * SDK sends it in the canonical mask the rest of the base holds (a digits-only one escaped the
29
+ * CRM duplicate check). After removing `.`, `-`, `/` and spaces: exactly 11 digits go as
30
+ * `999.999.999-99` (`F`); exactly 14 alphanumerics, the last 2 digits, go as `AA.AAA.AAA/AAAA-99`,
31
+ * letters uppercased as the Receita writes them (`J`). An input already in the mask goes
32
+ * unchanged. Anything else, an empty text included, is refused locally: `INVALID_INPUT`,
33
+ * `error.issues` is `["cpfcnpj: expected ..."]`, `attempts` 0, nothing sent, `effect` `"none"`.
34
+ * That covers a wrong length, other characters, letters in a CPF or in the last 2 positions of a
35
+ * CNPJ, and the wrong kind for the route (a CNPJ on `F`, a CPF on `J`). Omit the key to send no
36
+ * document. Format only: the check digits are not verified.
37
+ */
27
38
  cpfcnpj?: string;
28
39
  /** Exercised. Contact e-mail. */
29
40
  email?: string;
@@ -144,7 +155,7 @@ export declare const preRegistrationsCreateInputSchema: z.ZodDiscriminatedUnion<
144
155
  map_ll: z.ZodOptional<z.ZodString>;
145
156
  condominio: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
146
157
  nome: z.ZodString;
147
- cpfcnpj: z.ZodOptional<z.ZodString>;
158
+ cpfcnpj: z.ZodOptional<z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
148
159
  logradouro: z.ZodString;
149
160
  email: z.ZodOptional<z.ZodString>;
150
161
  celular: z.ZodOptional<z.ZodString>;
@@ -204,7 +215,7 @@ export declare const preRegistrationsCreateInputSchema: z.ZodDiscriminatedUnion<
204
215
  map_ll: z.ZodOptional<z.ZodString>;
205
216
  condominio: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
206
217
  nome: z.ZodString;
207
- cpfcnpj: z.ZodOptional<z.ZodString>;
218
+ cpfcnpj: z.ZodOptional<z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
208
219
  logradouro: z.ZodString;
209
220
  email: z.ZodOptional<z.ZodString>;
210
221
  celular: z.ZodOptional<z.ZodString>;
@@ -240,13 +251,25 @@ export declare const preRegistrationsCreateInputSchema: z.ZodDiscriminatedUnion<
240
251
  respcpf: z.ZodOptional<z.ZodString>;
241
252
  }, z.core.$strict>], "personType">;
242
253
  /**
243
- * Success body of `POST /api/precadastro/{F|J}`: SGP's `message`. It carries no ID of the customer,
244
- * the contract or the pré-cadastro. Other keys SGP may add are kept.
254
+ * Success body of `POST /api/precadastro/{F|J}`: SGP's `message` and, when it sends them, the
255
+ * IDs it created: `precadastro_id`, `new_cliente_id` (the `CustomerId` that `customers.list` shows)
256
+ * and `new_contrato_id` (a contract is created only with a sufficient plan and billing data). The
257
+ * three are optional, not invariants: older records list only `message` (the 1.x decoder dropped
258
+ * unknown keys, so whether the IDs were sent before is unknown), and a missing ID is never
259
+ * fabricated. Numbers are normalized (a numeric text becomes a number, `""` becomes `null`).
260
+ * Other keys SGP may add are kept.
245
261
  */
246
262
  declare const createdSchema: z.ZodObject<{
247
263
  message: z.ZodString;
264
+ precadastro_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
265
+ new_cliente_id: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>, z.ZodNullable<z.core.$ZodBranded<z.ZodNumber, "CustomerId", "out">>>>;
266
+ new_contrato_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
248
267
  }, z.core.$loose>;
249
- /** Response of `preRegistrations.create`. */
268
+ /**
269
+ * Response of `preRegistrations.create`. When SGP answers with the IDs it created, take them from
270
+ * here (`new_cliente_id`, `new_contrato_id`, `precadastro_id`); when they are absent, read the
271
+ * customer back with `customers.list({ cpfcnpj })`, as before. The SDK never fabricates them.
272
+ */
250
273
  export type PreRegistrationCreateData = z.output<typeof createdSchema>;
251
274
  /** INTERNAL definition of `preRegistrations.create`. */
252
275
  export declare const preRegistrationsCreate: OperationDefinition<PreRegistrationCreateData, "preRegistrations.create">;
@@ -7,8 +7,8 @@ declare const preRegistrationPlansSchema: z.ZodArray<z.ZodObject<{
7
7
  descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
8
  observacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
9
9
  gateway: z.ZodNullable<z.ZodOptional<z.ZodObject<{
10
- gateway_id: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
11
- id: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
10
+ gateway_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
11
+ id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
12
12
  descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
13
  }, z.core.$loose>>>;
14
14
  }, z.core.$loose>>;
@@ -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
+ /** Input of `services.addGeneric`, named as SGP names the fields. */
5
+ export interface ServiceAddGenericInput {
6
+ /**
7
+ * Exercised only in the refused call. ID of the contract; SGP's TV route refuses a contract
8
+ * that is not active, and this route is not known to differ.
9
+ */
10
+ clientecontrato_id: number;
11
+ /**
12
+ * Exercised only with a plan of another type, which SGP refused (400). ID of a plan of the
13
+ * generic type: a `PlanId` from the URA plan list (`plans.list`), where the provider has created
14
+ * one in the panel (Administração > Planos > Cadastrar > Serviços). SGP refuses any other plan
15
+ * type. Whether the URA list shows generic plans is not confirmed.
16
+ */
17
+ planobase_id: PlanId;
18
+ /**
19
+ * Sent in the refused call (which was refused for its plan), so its effect on a service is
20
+ * unobserved. Free-text description of the service. Personal data: never log it.
21
+ */
22
+ descricao?: string;
23
+ /** Documented, never sent. The panel's "Gateway ID". Treated as a network identifier. */
24
+ identificador_gateway?: string;
25
+ /** Documented, never sent. The panel's "Gateway Extra". Treated as a network identifier. */
26
+ identificador_gateway_extra?: string;
27
+ /** Documented, never sent. Login of the service. Secret: never log it. */
28
+ login?: string;
29
+ /** Documented, never sent. Password of the service. Secret: never log it. */
30
+ senha?: string;
31
+ }
32
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
33
+ export declare const servicesAddGenericInputSchema: z.ZodObject<{
34
+ clientecontrato_id: z.ZodNumber;
35
+ planobase_id: z.core.$ZodBranded<z.ZodNumber, "PlanId", "out">;
36
+ descricao: z.ZodOptional<z.ZodString>;
37
+ identificador_gateway: z.ZodOptional<z.ZodString>;
38
+ identificador_gateway_extra: z.ZodOptional<z.ZodString>;
39
+ login: z.ZodOptional<z.ZodString>;
40
+ senha: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strict>;
42
+ /**
43
+ * Success body of `POST /api/servico/generico`: documented, never observed (the provider has no
44
+ * generic plan, and plans are not created for tests). Nothing is assumed beyond a JSON object;
45
+ * whatever SGP sends is kept as received.
46
+ */
47
+ declare const genericAddedSchema: z.ZodObject<{}, z.core.$loose>;
48
+ /** Response of `services.addGeneric`: the JSON object SGP sent, unread. */
49
+ export type ServiceAddGenericData = z.output<typeof genericAddedSchema>;
50
+ /** INTERNAL definition of `services.addGeneric`. */
51
+ export declare const servicesAddGeneric: OperationDefinition<ServiceAddGenericData, "services.addGeneric">;
52
+ export {};
@@ -32,12 +32,12 @@ export declare const servicesAddTvInputSchema: z.ZodObject<{
32
32
  }, z.core.$strict>;
33
33
  /**
34
34
  * Success body of `POST /api/servico/tv` (HTTP 201): SGP's `msg`, the new `servico_id` (a number)
35
- * and `clientecontrato_id`, which SGP sends as a string (`"<n>"`) and is kept as such. Other keys
36
- * SGP may add are kept.
35
+ * and `clientecontrato_id`, which SGP sends as text (`"<n>"`) and `data` carries as a number
36
+ * (changed versus 2.0.0-beta.1). Other keys SGP may add are kept.
37
37
  */
38
38
  declare const tvAddedSchema: z.ZodObject<{
39
39
  msg: z.ZodString;
40
- clientecontrato_id: z.ZodOptional<z.ZodString>;
40
+ clientecontrato_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
41
41
  servico_id: z.ZodNumber;
42
42
  }, z.core.$loose>;
43
43
  /** Response of `services.addTv`. */
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ /** Input of `services.removeGeneric`, named as SGP names the fields. */
4
+ export interface ServiceRemoveGenericInput {
5
+ /**
6
+ * Documented, never sent. ID of the generic serviço to remove (the id of the service that
7
+ * `services.addGeneric` created; read it from the contract with `customers.list`).
8
+ */
9
+ servico_id: number;
10
+ /** Documented, never sent. ID of the contract the serviço belongs to. */
11
+ clientecontrato_id: number;
12
+ }
13
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
14
+ export declare const servicesRemoveGenericInputSchema: z.ZodObject<{
15
+ servico_id: z.ZodNumber;
16
+ clientecontrato_id: z.ZodNumber;
17
+ }, z.core.$strict>;
18
+ /**
19
+ * Success body of `DELETE /api/servico/generico/{servico_id}`: documented, never observed (no
20
+ * generic service was ever created, so none could be removed). Nothing is assumed beyond a JSON
21
+ * object; whatever SGP sends is kept as received.
22
+ */
23
+ declare const genericRemovedSchema: z.ZodObject<{}, z.core.$loose>;
24
+ /** Response of `services.removeGeneric`: the JSON object SGP sent, unread. */
25
+ export type ServiceRemoveGenericData = z.output<typeof genericRemovedSchema>;
26
+ /** INTERNAL definition of `services.removeGeneric`. */
27
+ export declare const servicesRemoveGeneric: OperationDefinition<ServiceRemoveGenericData, "services.removeGeneric">;
28
+ export {};
@@ -14,12 +14,12 @@ export declare const servicesRemoveTvInputSchema: z.ZodObject<{
14
14
  }, z.core.$strict>;
15
15
  /**
16
16
  * Success body of `DELETE /api/servico/tv/{servico_id}`: SGP's `msg`, the removed `servico_id` (a
17
- * number) and `clientecontrato_id`, which SGP sends as a string and is kept as such. Other keys SGP
18
- * may add are kept.
17
+ * number) and `clientecontrato_id`, which SGP sends as text and `data` carries as a number (changed
18
+ * versus 2.0.0-beta.1). Other keys SGP may add are kept.
19
19
  */
20
20
  declare const tvRemovedSchema: z.ZodObject<{
21
21
  msg: z.ZodString;
22
- clientecontrato_id: z.ZodOptional<z.ZodString>;
22
+ clientecontrato_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
23
23
  servico_id: z.ZodNumber;
24
24
  }, z.core.$loose>;
25
25
  /** Response of `services.removeTv`. */
@@ -0,0 +1,99 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const workOrderDetailSchema: z.ZodObject<{
4
+ os_id: z.ZodNumber;
5
+ os_protocolo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ os_status: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
+ os_status_txt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ os_prioridade: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
9
+ os_motivo_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
10
+ os_motivo_descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
+ os_data_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
+ os_data_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ os_data_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ os_conteudo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
15
+ os_observacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
16
+ os_anotacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
+ os_servicoprestado: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ os_setor_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
19
+ os_setor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ os_tecnico_responsavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
21
+ os_tecnicos_auxiliares: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
22
+ os_agendamento_confirmado: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
23
+ os_agendamento_confirmacao_data: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ os_agendamento_confirmacao_status: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
25
+ os_agendamento_confirmacao_status_txt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
26
+ os_close_edit: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
27
+ os_encerrada_impedir_estorno: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
28
+ os_encerrada_impedir_lancamento_avulso: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
29
+ os_finalizada_permite_add_imagem: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
30
+ os_lancamento_comodato: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
31
+ os_djson: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
32
+ comentarios: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
33
+ cliente_id: z.ZodNullable<z.ZodOptional<z.core.$ZodBranded<z.ZodNumber, "CustomerId", "out">>>;
34
+ cliente: z.ZodNullable<z.ZodOptional<z.ZodString>>;
35
+ cliente_email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
36
+ cliente_contato: z.ZodNullable<z.ZodOptional<z.ZodString>>;
37
+ contrato_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
38
+ contrato_status: z.ZodNullable<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
39
+ contrato_status_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
40
+ contrato_status_data: z.ZodNullable<z.ZodOptional<z.ZodString>>;
41
+ contrato_pop_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
42
+ contrato_pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
43
+ contrato_endereco_ll: z.ZodNullable<z.ZodOptional<z.ZodString>>;
44
+ endereco_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
45
+ endereco_logradouro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
46
+ endereco_numero: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
47
+ endereco_complemento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
+ endereco_bairro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
49
+ endereco_cidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
50
+ endereco_uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
51
+ endereco_pontoreferencia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
52
+ endereco_ll: z.ZodNullable<z.ZodOptional<z.ZodString>>;
53
+ plano_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
54
+ plano: z.ZodNullable<z.ZodOptional<z.ZodString>>;
55
+ plano_download: z.ZodNullable<z.ZodOptional<z.ZodString>>;
56
+ plano_upload: z.ZodNullable<z.ZodOptional<z.ZodString>>;
57
+ servico_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
58
+ servico_tipo: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
59
+ servico_login: z.ZodNullable<z.ZodOptional<z.ZodString>>;
60
+ servico_password: z.ZodNullable<z.ZodOptional<z.ZodString>>;
61
+ servico_online: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
62
+ servico_mac: z.ZodNullable<z.ZodOptional<z.ZodString>>;
63
+ servico_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
64
+ servico_online_mac: z.ZodNullable<z.ZodOptional<z.ZodString>>;
65
+ servico_online_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
66
+ servico_online_ipv6_pd: z.ZodOptional<z.ZodUnknown>;
67
+ nas_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
+ wifi_ssid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
69
+ wifi_password: z.ZodNullable<z.ZodOptional<z.ZodString>>;
70
+ wifi_channel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
71
+ wifi_ssid_5: z.ZodNullable<z.ZodOptional<z.ZodString>>;
72
+ wifi_password_5: z.ZodNullable<z.ZodOptional<z.ZodString>>;
73
+ wifi_channel_5: z.ZodNullable<z.ZodOptional<z.ZodString>>;
74
+ wan_user: z.ZodNullable<z.ZodOptional<z.ZodString>>;
75
+ wan_password: z.ZodNullable<z.ZodOptional<z.ZodString>>;
76
+ }, z.core.$loose>;
77
+ /**
78
+ * The response of `POST /api/os/list/id/{id}`, in SGP's own shape: ONE flat object with the work
79
+ * order, its customer, contract, address, plan and service together (72 fields observed). The
80
+ * vendor's collection shows a one-element array; SGP sent the bare object. Most fields are as
81
+ * received; normalized (changed versus 2.0.0-beta.1): `servico_id`, `contrato_status_id` and
82
+ * `os_setor_id` are numbers (`""` becomes `null`) and `contrato_status` is trimmed.
83
+ *
84
+ * It holds PLAINTEXT CREDENTIALS (`servico_password`, `wan_password`, `wifi_password`,
85
+ * `wifi_password_5`) and the customer's data: see `getSensitivity("workOrders.get")`.
86
+ */
87
+ export type WorkOrdersGetData = z.output<typeof workOrderDetailSchema>;
88
+ /** Input of `workOrders.get`, named as SGP names the path parameter. */
89
+ export interface WorkOrdersGetInput {
90
+ /** Exercised. The id of the work order (the `id` of `workOrders.list`; `os_id` in the result). */
91
+ id: number;
92
+ }
93
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
94
+ export declare const workOrdersGetInputSchema: z.ZodObject<{
95
+ id: z.ZodNumber;
96
+ }, z.core.$strict>;
97
+ /** INTERNAL definition of `workOrders.get`. */
98
+ export declare const workOrdersGet: OperationDefinition<WorkOrdersGetData, "workOrders.get">;
99
+ export {};
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import type { OperationDefinition } from "../operation.js";
3
+ declare const commentsSchema: z.ZodArray<z.ZodObject<{
4
+ comentario_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
5
+ comentario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ usuario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
7
+ data_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ checklist_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
9
+ checklist_descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
10
+ usuario_setores: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
11
+ }, z.core.$loose>>;
12
+ /**
13
+ * The response of `GET /api/os/{id}/comentario/list/`, in SGP's own shape: a bare array with one
14
+ * entry per comment of the work order. The route is not paginated, so there is no envelope and no
15
+ * total. An empty array means no comment.
16
+ *
17
+ * DOCUMENTED ONLY: the one live read returned `[]`. The item fields (`comentario_id`,
18
+ * `comentario`, `usuario`, `data_cadastro`, `checklist_id`, `checklist_descricao`,
19
+ * `usuario_setores`) come from the vendor's collection and were never seen; an element that is not
20
+ * an object fails the response (`INVALID_RESPONSE`), as everywhere in the client.
21
+ */
22
+ export type WorkOrdersListCommentsData = z.output<typeof commentsSchema>;
23
+ /** Input of `workOrders.listComments`, named as SGP names the path parameter. */
24
+ export interface WorkOrdersListCommentsInput {
25
+ /** Exercised. The id of the work order (the `id` of `workOrders.list`). */
26
+ id: number;
27
+ }
28
+ /** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
29
+ export declare const workOrdersListCommentsInputSchema: z.ZodObject<{
30
+ id: z.ZodNumber;
31
+ }, z.core.$strict>;
32
+ /** INTERNAL definition of `workOrders.listComments`. */
33
+ export declare const workOrdersListComments: OperationDefinition<WorkOrdersListCommentsData, "workOrders.listComments">;
34
+ export {};
package/dist/result.d.ts CHANGED
@@ -64,7 +64,11 @@ export interface SgpError {
64
64
  effect?: Effect;
65
65
  /** Projection of the SGP error fields found in the response body. */
66
66
  sgp?: SgpErrorFields;
67
- /** On `INVALID_RESPONSE`: the paths that broke the contract, never values. */
67
+ /**
68
+ * On `INVALID_RESPONSE`: the paths that broke the contract, never values. On `INVALID_INPUT`:
69
+ * only when the SDK names the broken field (a `cpfcnpj` in a format no storing write accepts:
70
+ * `"cpfcnpj: expected ..."`); most local refusals carry none.
71
+ */
68
72
  issues?: readonly string[];
69
73
  }
70
74
  /** A hook that threw. Only its name and the attempt it ran on are kept, never the thrown value. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sgp-sdk",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Unofficial TypeScript client for the SGP (TSMX) ISP ERP HTTP API, with normalized errors and explicit write outcomes. Not affiliated with TSMX.",
5
5
  "license": "MIT",
6
6
  "type": "module",