sgp-sdk 1.1.3 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -0
- package/COMPATIBILITY.md +151 -0
- package/MIGRATION.md +283 -0
- package/README.md +424 -225
- package/dist/address.d.ts +46 -0
- package/dist/annotation-selection.d.ts +32 -0
- package/dist/budget.d.ts +29 -0
- package/dist/classify.d.ts +15 -0
- package/dist/client.d.ts +662 -155
- package/dist/config.d.ts +115 -0
- package/dist/constants.d.ts +72 -0
- package/dist/effect.d.ts +22 -0
- package/dist/executor.d.ts +9 -0
- package/dist/exposure.d.ts +21 -0
- package/dist/guards.d.ts +2 -0
- package/dist/hooks.d.ts +16 -0
- package/dist/ids.d.ts +19 -0
- package/dist/index.d.ts +45 -47
- package/dist/index.js +2954 -1223
- package/dist/operation-sensitivity.d.ts +496 -0
- package/dist/operation.d.ts +139 -0
- package/dist/operations/catalogs-list-billing-profiles.d.ts +16 -0
- package/dist/operations/catalogs-list-nas.d.ts +25 -0
- package/dist/operations/catalogs-list-pops.d.ts +14 -0
- package/dist/operations/contracts-list-status-reasons.d.ts +15 -0
- package/dist/operations/contracts-list.d.ts +52 -0
- package/dist/operations/contracts-update-status.d.ts +41 -0
- package/dist/operations/contracts-update.d.ts +39 -0
- package/dist/operations/coverage-check.d.ts +42 -0
- package/dist/operations/crm-contracts-create-by-cpf-cnpj.d.ts +97 -0
- package/dist/operations/crm-contracts-create.d.ts +221 -0
- package/dist/operations/crm-contracts-list.d.ts +50 -0
- package/dist/operations/crm-customers-create.d.ts +155 -0
- package/dist/operations/crm-customers-update-status.d.ts +41 -0
- package/dist/operations/customers-list.d.ts +98 -0
- package/dist/{endpoints/ura/lookup-customer.d.ts → operations/customers-search.d.ts} +56 -46
- package/dist/operations/documents-add.d.ts +29 -0
- package/dist/operations/documents-list.d.ts +31 -0
- package/dist/operations/experimental-annotations-list.d.ts +67 -0
- package/dist/operations/invoices-list.d.ts +142 -0
- package/dist/operations/occurrences-create.d.ts +116 -0
- package/dist/operations/occurrences-list-methods.d.ts +14 -0
- package/dist/operations/occurrences-list-types.d.ts +20 -0
- package/dist/{endpoints/ura/list-plans.d.ts → operations/plans-list.d.ts} +33 -23
- package/dist/operations/pre-registrations-create.d.ts +253 -0
- package/dist/operations/pre-registrations-list-due-days.d.ts +15 -0
- package/dist/operations/pre-registrations-list-plans.d.ts +24 -0
- package/dist/operations/pre-registrations-list-sellers.d.ts +16 -0
- package/dist/operations/services-add-tv.d.ts +47 -0
- package/dist/operations/services-change-plan.d.ts +40 -0
- package/dist/operations/services-remove-tv.d.ts +29 -0
- package/dist/operations/work-orders-list-reasons.d.ts +20 -0
- package/dist/operations/work-orders-list.d.ts +81 -0
- package/dist/path.d.ts +13 -0
- package/dist/raw-request.d.ts +26 -0
- package/dist/request.d.ts +28 -0
- package/dist/result.d.ts +111 -43
- package/dist/retry.d.ts +34 -0
- package/dist/sensitivity.d.ts +89 -4
- package/dist/tolerant.d.ts +21 -0
- package/dist/validation.d.ts +3 -0
- package/package.json +6 -3
- package/dist/endpoint.d.ts +0 -66
- package/dist/endpoints/crm/address.d.ts +0 -20
- package/dist/endpoints/crm/create-contract.d.ts +0 -109
- package/dist/endpoints/crm/create-customer.d.ts +0 -65
- package/dist/endpoints/crm/update-customer-status.d.ts +0 -43
- package/dist/endpoints/os/list-occurrence-reasons.d.ts +0 -24
- package/dist/endpoints/os/list-occurrence-types.d.ts +0 -25
- package/dist/endpoints/precadastro/list-due-days.d.ts +0 -19
- package/dist/endpoints/precadastro/list-sellers.d.ts +0 -21
- package/dist/endpoints/suporte/add-customer-document.d.ts +0 -24
- package/dist/endpoints/suporte/list-customer-documents.d.ts +0 -25
- package/dist/endpoints/ura/check-coverage.d.ts +0 -46
- package/dist/endpoints/ura/list-clients.d.ts +0 -58
- package/dist/endpoints/ura/list-contracts.d.ts +0 -45
- package/dist/endpoints/ura/list-invoices.d.ts +0 -107
- package/dist/endpoints/ura/list-nas.d.ts +0 -29
- package/dist/endpoints/ura/list-occurrence-methods.d.ts +0 -19
- package/dist/endpoints/ura/list-payment-carriers.d.ts +0 -20
- package/dist/endpoints/ura/list-pops.d.ts +0 -19
- package/dist/endpoints/ura/list-service-orders.d.ts +0 -64
- package/dist/endpoints/ura/open-ticket.d.ts +0 -81
- package/dist/errors.d.ts +0 -59
- package/dist/schema/parse.d.ts +0 -19
- package/dist/schema/paths.d.ts +0 -38
- package/dist/transport.d.ts +0 -65
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `POST /api/ura/listacontrato/`: a bare array with one summary per contract. */
|
|
4
|
-
export declare const listContractsSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
-
id_contrato: z.ZodNumber;
|
|
6
|
-
id_cliente: z.ZodNumber;
|
|
7
|
-
status: z.ZodString;
|
|
8
|
-
pop_id: 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.$strip>>;
|
|
17
|
-
/** Key fields of `ura/listacontrato`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
18
|
-
export declare const listContractsKeyFields: readonly ["[].id_contrato", "[].id_cliente", "[].status", "[].pop_id"];
|
|
19
|
-
/** Normalized path of each contract item in the `ura/listacontrato` response (the root array). */
|
|
20
|
-
export declare const contractSummaryItemPath = "[]";
|
|
21
|
-
/** Keys of a contract summary holding secrets (none in `ura/listacontrato`). */
|
|
22
|
-
export declare const contractSummarySecretKeys: readonly [];
|
|
23
|
-
/** Keys of a contract summary holding personal data. */
|
|
24
|
-
export declare const contractSummaryPersonalKeys: readonly ["nome", "cpfcnpj", "email", "telefone", "motivo_status"];
|
|
25
|
-
/**
|
|
26
|
-
* Body parameters of `POST /api/ura/listacontrato/` (besides credentials); all optional filters.
|
|
27
|
-
*
|
|
28
|
-
* Without any filter the response may carry the whole contract base.
|
|
29
|
-
*/
|
|
30
|
-
export interface ListContractsParams {
|
|
31
|
-
/** Contract ID. */
|
|
32
|
-
contrato?: number;
|
|
33
|
-
/** ID of the plan linked to the contract. */
|
|
34
|
-
plano?: number;
|
|
35
|
-
/** Person type (see the public SGP documentation for the values). */
|
|
36
|
-
tipo?: string;
|
|
37
|
-
/** Contract status ID (see the public SGP documentation for the values). */
|
|
38
|
-
status?: number;
|
|
39
|
-
/** Ask SGP to include the address; address fields are not transcribed yet, so the schema drops them. */
|
|
40
|
-
exibir_endereco?: boolean;
|
|
41
|
-
}
|
|
42
|
-
/** Parsed response of `POST /api/ura/listacontrato/`. */
|
|
43
|
-
export type ListContractsResponse = z.output<typeof listContractsSchema>;
|
|
44
|
-
/** Definition of `POST /api/ura/listacontrato/`. */
|
|
45
|
-
export declare const listContractsDefinition: EndpointDefinition<typeof listContractsSchema>;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `POST /api/ura/titulos/`: one page of invoices (titulos). */
|
|
4
|
-
export declare const listInvoicesSchema: z.ZodObject<{
|
|
5
|
-
paginacao: z.ZodObject<{
|
|
6
|
-
offset: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
-
limit: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
-
parcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
-
total: z.ZodNumber;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
titulos: z.ZodArray<z.ZodObject<{
|
|
12
|
-
id: z.ZodNumber;
|
|
13
|
-
status: z.ZodString;
|
|
14
|
-
valor: z.ZodNumber;
|
|
15
|
-
dataVencimento: z.ZodString;
|
|
16
|
-
clienteNome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
-
clienteCpfcnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
18
|
-
clienteContrato: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
19
|
-
portador: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
-
numeroDocumento: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
21
|
-
nossoNumero: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
-
link: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
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>>;
|
|
28
|
-
codigoBarras: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
29
|
-
linhaDigitavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
30
|
-
codigoPix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
31
|
-
dataEmissao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
32
|
-
dataPagamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
33
|
-
dataCancelamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
34
|
-
demonstrativo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
35
|
-
acordoPagamento: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
36
|
-
acordados: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
|
|
37
|
-
cobrados: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
|
|
38
|
-
}, z.core.$strip>>>;
|
|
39
|
-
formaPagamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
40
|
-
usuario_baixa: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
41
|
-
}, z.core.$strip>>;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
|
-
/** Key fields of `ura/titulos`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
44
|
-
export declare const listInvoicesKeyFields: readonly ["paginacao.total", "titulos", "titulos[].id", "titulos[].status", "titulos[].valor", "titulos[].dataVencimento"];
|
|
45
|
-
/** Normalized path of each invoice in the `ura/titulos` response. */
|
|
46
|
-
export declare const invoiceItemPath = "titulos[]";
|
|
47
|
-
/** Keys of an invoice holding secrets (none in `ura/titulos`). */
|
|
48
|
-
export declare const invoiceSecretKeys: readonly [];
|
|
49
|
-
/**
|
|
50
|
-
* Keys of an invoice holding personal data: customer name and CPF/CNPJ, the statement text, the
|
|
51
|
-
* payment links and the PIX code.
|
|
52
|
-
*
|
|
53
|
-
* `link` and `link_cobranca` open the boleto, which prints the payer's name, CPF/CNPJ and address,
|
|
54
|
-
* and a dynamic PIX code may resolve to the debtor. `codigoBarras`, `linhaDigitavel`, `nossoNumero`
|
|
55
|
-
* and `usuario_baixa` are deliberately not classified.
|
|
56
|
-
*/
|
|
57
|
-
export declare const invoicePersonalKeys: readonly ["clienteNome", "clienteCpfcnpj", "demonstrativo", "link", "link_cobranca", "codigoPix"];
|
|
58
|
-
/**
|
|
59
|
-
* Body parameters of `POST /api/ura/titulos/` (besides credentials); all optional filters, paging
|
|
60
|
-
* and ordering, with the names and choices of SGP's public Postman collection.
|
|
61
|
-
*/
|
|
62
|
-
export interface ListInvoicesParams {
|
|
63
|
-
/** Offset of the query; SGP starts at 0. */
|
|
64
|
-
offset?: number;
|
|
65
|
-
/** Page size; SGP documents a maximum of 250. */
|
|
66
|
-
limit?: number;
|
|
67
|
-
/** Invoice (titulo) ID. */
|
|
68
|
-
titulo_id?: number;
|
|
69
|
-
/** ID of the client linked to the invoices. */
|
|
70
|
-
cliente_id?: number;
|
|
71
|
-
/** CPF or CNPJ of the client linked to the invoices. */
|
|
72
|
-
cpfcnpj?: string;
|
|
73
|
-
/** ID of the service contract linked to the invoices. */
|
|
74
|
-
contrato?: number;
|
|
75
|
-
/** Invoice status filter. */
|
|
76
|
-
status?: "abertos" | "pagos" | "cancelados";
|
|
77
|
-
/** ID of the payment carrier (portador) that generated the invoices. */
|
|
78
|
-
portador?: number;
|
|
79
|
-
/** Field the invoices are ordered by. */
|
|
80
|
-
ordenar?: "data_documento" | "data_vencimento" | "data_pagamento";
|
|
81
|
-
/** Ascending or descending order. */
|
|
82
|
-
ordenar_ordem?: "asc" | "desc";
|
|
83
|
-
/** CNPJ of the company that issued the invoices; several allowed, separated by comma. */
|
|
84
|
-
empresa_cnpj?: string;
|
|
85
|
-
/** Person type linked to the invoices: F (individual), J (company), E (foreign individual), EJ (foreign company). */
|
|
86
|
-
tipo_pessoa?: "F" | "J" | "E" | "EJ";
|
|
87
|
-
/** Initial due date, `AAAA-MM-DD`; required when `data_vencimento_fim` is sent. */
|
|
88
|
-
data_vencimento_inicio?: string;
|
|
89
|
-
/** Final due date, `AAAA-MM-DD`. */
|
|
90
|
-
data_vencimento_fim?: string;
|
|
91
|
-
/** Initial payment date, `AAAA-MM-DD`; required when `data_pagamento_fim` is sent. */
|
|
92
|
-
data_pagamento_inicio?: string;
|
|
93
|
-
/** Final payment date, `AAAA-MM-DD`. */
|
|
94
|
-
data_pagamento_fim?: string;
|
|
95
|
-
/** Initial cancellation date, `AAAA-MM-DD`; alone, matches invoices cancelled on that day. */
|
|
96
|
-
data_cancelamento_inicio?: string;
|
|
97
|
-
/** Final cancellation date, `AAAA-MM-DD`; use with the initial one. */
|
|
98
|
-
data_cancelamento_fim?: string;
|
|
99
|
-
/** Initial date on which payment-agreement invoices were generated, `AAAA-MM-DD`; alone, matches that day. */
|
|
100
|
-
data_acordo_inicio?: string;
|
|
101
|
-
/** Final date on which payment-agreement invoices were generated, `AAAA-MM-DD`. */
|
|
102
|
-
data_acordo_fim?: string;
|
|
103
|
-
}
|
|
104
|
-
/** Parsed response of `POST /api/ura/titulos/`. */
|
|
105
|
-
export type ListInvoicesResponse = z.output<typeof listInvoicesSchema>;
|
|
106
|
-
/** Definition of `POST /api/ura/titulos/`. */
|
|
107
|
-
export declare const listInvoicesDefinition: EndpointDefinition<typeof listInvoicesSchema>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `POST /api/ura/nas/list/`: a bare array with the NAS (network access servers) and the POPs each serves. */
|
|
4
|
-
export declare const listNasSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
-
id: z.ZodNumber;
|
|
6
|
-
descricao: z.ZodString;
|
|
7
|
-
identificador: z.ZodString;
|
|
8
|
-
endereco_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
-
ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
10
|
-
pops: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
|
-
id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
-
cidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
13
|
-
uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
14
|
-
codigo_ibge: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
-
ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
16
|
-
}, z.core.$strip>>>>;
|
|
17
|
-
}, z.core.$strip>>;
|
|
18
|
-
/** Key fields of `ura/nas/list`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
19
|
-
export declare const listNasKeyFields: readonly ["[].id", "[].descricao", "[].identificador"];
|
|
20
|
-
/** Normalized path of each NAS in the `ura/nas/list` response (the root array). */
|
|
21
|
-
export declare const nasItemPath = "[]";
|
|
22
|
-
/** Keys of a NAS holding secrets: its IP address, which is network infrastructure. */
|
|
23
|
-
export declare const nasSecretKeys: readonly ["endereco_ip"];
|
|
24
|
-
/** Keys of a NAS holding personal data (none in `ura/nas/list`). */
|
|
25
|
-
export declare const nasPersonalKeys: readonly [];
|
|
26
|
-
/** Parsed response of `POST /api/ura/nas/list/`. */
|
|
27
|
-
export type ListNasResponse = z.output<typeof listNasSchema>;
|
|
28
|
-
/** Definition of `POST /api/ura/nas/list/`. */
|
|
29
|
-
export declare const listNasDefinition: EndpointDefinition<typeof listNasSchema>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `GET /api/ura/ocorrencia/metodo/list/`: a bare array with the occurrence methods. */
|
|
4
|
-
export declare const listOccurrenceMethodsSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
-
codigo: z.ZodNumber;
|
|
6
|
-
descricao: z.ZodString;
|
|
7
|
-
}, z.core.$strip>>;
|
|
8
|
-
/** Key fields of `ura/ocorrencia/metodo/list`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
9
|
-
export declare const listOccurrenceMethodsKeyFields: readonly ["[].codigo", "[].descricao"];
|
|
10
|
-
/** Normalized path of each method in the `ura/ocorrencia/metodo/list` response (the root array). */
|
|
11
|
-
export declare const occurrenceMethodItemPath = "[]";
|
|
12
|
-
/** Keys of an occurrence method holding secrets (none in `ura/ocorrencia/metodo/list`). */
|
|
13
|
-
export declare const occurrenceMethodSecretKeys: readonly [];
|
|
14
|
-
/** Keys of an occurrence method holding personal data (none in `ura/ocorrencia/metodo/list`). */
|
|
15
|
-
export declare const occurrenceMethodPersonalKeys: readonly [];
|
|
16
|
-
/** Parsed response of `GET /api/ura/ocorrencia/metodo/list/`. */
|
|
17
|
-
export type ListOccurrenceMethodsResponse = z.output<typeof listOccurrenceMethodsSchema>;
|
|
18
|
-
/** Definition of `GET /api/ura/ocorrencia/metodo/list/`. */
|
|
19
|
-
export declare const listOccurrenceMethodsDefinition: EndpointDefinition<typeof listOccurrenceMethodsSchema>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `GET /api/ura/portador/`: a bare array with the payment carriers (portadores). */
|
|
4
|
-
export declare const listPaymentCarriersSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
-
id: z.ZodNumber;
|
|
6
|
-
descricao: z.ZodString;
|
|
7
|
-
codigo_banco: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
-
}, z.core.$strip>>;
|
|
9
|
-
/** Key fields of `ura/portador`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
10
|
-
export declare const listPaymentCarriersKeyFields: readonly ["[].id", "[].descricao"];
|
|
11
|
-
/** Normalized path of each carrier in the `ura/portador` response (the root array). */
|
|
12
|
-
export declare const paymentCarrierItemPath = "[]";
|
|
13
|
-
/** Keys of a payment carrier holding secrets (none in `ura/portador`). */
|
|
14
|
-
export declare const paymentCarrierSecretKeys: readonly [];
|
|
15
|
-
/** Keys of a payment carrier holding personal data (none in `ura/portador`). */
|
|
16
|
-
export declare const paymentCarrierPersonalKeys: readonly [];
|
|
17
|
-
/** Parsed response of `GET /api/ura/portador/`. */
|
|
18
|
-
export type ListPaymentCarriersResponse = z.output<typeof listPaymentCarriersSchema>;
|
|
19
|
-
/** Definition of `GET /api/ura/portador/`. */
|
|
20
|
-
export declare const listPaymentCarriersDefinition: EndpointDefinition<typeof listPaymentCarriersSchema>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `POST /api/ura/pops/`: a bare array with the POPs (points of presence). */
|
|
4
|
-
export declare const listPopsSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
-
id: z.ZodNumber;
|
|
6
|
-
pop: z.ZodString;
|
|
7
|
-
}, z.core.$strip>>;
|
|
8
|
-
/** Key fields of `ura/pops`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
9
|
-
export declare const listPopsKeyFields: readonly ["[].id", "[].pop"];
|
|
10
|
-
/** Normalized path of each POP in the `ura/pops` response (the root array). */
|
|
11
|
-
export declare const popItemPath = "[]";
|
|
12
|
-
/** Keys of a POP holding secrets (none in `ura/pops`). */
|
|
13
|
-
export declare const popSecretKeys: readonly [];
|
|
14
|
-
/** Keys of a POP holding personal data (none in `ura/pops`). */
|
|
15
|
-
export declare const popPersonalKeys: readonly [];
|
|
16
|
-
/** Parsed response of `POST /api/ura/pops/`. */
|
|
17
|
-
export type ListPopsResponse = z.output<typeof listPopsSchema>;
|
|
18
|
-
/** Definition of `POST /api/ura/pops/`. */
|
|
19
|
-
export declare const listPopsDefinition: EndpointDefinition<typeof listPopsSchema>;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { EndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/** Response of `POST /api/ura/ordemservico/list/`: one page of service orders (OS). */
|
|
4
|
-
export declare const listServiceOrdersSchema: z.ZodObject<{
|
|
5
|
-
paginacao: z.ZodObject<{
|
|
6
|
-
offset: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
-
limit: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
-
parcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
-
total: z.ZodNumber;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
ordens_servicos: z.ZodArray<z.ZodObject<{
|
|
12
|
-
id: z.ZodNumber;
|
|
13
|
-
contrato: z.ZodNumber;
|
|
14
|
-
status_id: z.ZodNumber;
|
|
15
|
-
status: z.ZodString;
|
|
16
|
-
tipo_id: z.ZodNumber;
|
|
17
|
-
data_cadastro: z.ZodString;
|
|
18
|
-
cliente: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
-
contrato_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
-
contrato_status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
21
|
-
ocorrencia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
-
hora_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
23
|
-
data_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
24
|
-
hora_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
25
|
-
data_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
26
|
-
hora_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
27
|
-
tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
28
|
-
motivo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
29
|
-
pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
30
|
-
conteudo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
31
|
-
responsavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
32
|
-
tecnicos_auxiliares: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
|
|
33
|
-
usuario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
34
|
-
usuario_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
35
|
-
classificacoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
|
|
36
|
-
}, z.core.$strip>>;
|
|
37
|
-
}, z.core.$strip>;
|
|
38
|
-
/** Key fields of `ura/ordemservico/list`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
|
|
39
|
-
export declare const listServiceOrdersKeyFields: readonly ["paginacao.total", "ordens_servicos", "ordens_servicos[].id", "ordens_servicos[].contrato", "ordens_servicos[].status_id", "ordens_servicos[].status", "ordens_servicos[].tipo_id", "ordens_servicos[].data_cadastro"];
|
|
40
|
-
/** Normalized path of each service order in the `ura/ordemservico/list` response. */
|
|
41
|
-
export declare const serviceOrderItemPath = "ordens_servicos[]";
|
|
42
|
-
/** Keys of a service order holding secrets (none in `ura/ordemservico/list`). */
|
|
43
|
-
export declare const serviceOrderSecretKeys: readonly [];
|
|
44
|
-
/** Keys of a service order holding personal data: customer name and the free-text content. */
|
|
45
|
-
export declare const serviceOrderPersonalKeys: readonly ["cliente", "conteudo"];
|
|
46
|
-
/** Body parameters of `POST /api/ura/ordemservico/list/` (besides credentials); all optional filters and paging. */
|
|
47
|
-
export interface ListServiceOrdersParams {
|
|
48
|
-
offset?: number;
|
|
49
|
-
limit?: number;
|
|
50
|
-
/** ID of the occurrence (the OS). */
|
|
51
|
-
ordem_servico?: number;
|
|
52
|
-
/** Service order status ID. */
|
|
53
|
-
status?: number;
|
|
54
|
-
/** POP ID. */
|
|
55
|
-
pop?: number;
|
|
56
|
-
/** Occurrence reason ID. */
|
|
57
|
-
motivo?: number;
|
|
58
|
-
/** Contract ID. */
|
|
59
|
-
contrato?: number;
|
|
60
|
-
}
|
|
61
|
-
/** Parsed response of `POST /api/ura/ordemservico/list/`. */
|
|
62
|
-
export type ListServiceOrdersResponse = z.output<typeof listServiceOrdersSchema>;
|
|
63
|
-
/** Definition of `POST /api/ura/ordemservico/list/`. */
|
|
64
|
-
export declare const listServiceOrdersDefinition: EndpointDefinition<typeof listServiceOrdersSchema>;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { WriteEndpointDefinition } from "../../endpoint.js";
|
|
3
|
-
/**
|
|
4
|
-
* Success body of `POST /api/ura/chamado/`: `status` 1, the ticket protocol and the ID of the
|
|
5
|
-
* occurrence, plus the contract and customer SGP echoes back. `status` 0 is SGP's refusal.
|
|
6
|
-
*/
|
|
7
|
-
export declare const openTicketSchema: z.ZodObject<{
|
|
8
|
-
status: z.ZodLiteral<1>;
|
|
9
|
-
protocolo: z.ZodString;
|
|
10
|
-
id: z.ZodNumber;
|
|
11
|
-
contratoId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
-
razaoSocial: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
13
|
-
cpfCnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
14
|
-
msg: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
/**
|
|
17
|
-
* Key fields of `ura/chamado`: required and strict. A 2xx is only a success with `status` 1 and a
|
|
18
|
-
* `protocolo`; anything else (e.g. `status` 0 with a `msg`) is `VALIDATION` with `outcome: "unknown"`.
|
|
19
|
-
*/
|
|
20
|
-
export declare const openTicketKeyFields: readonly ["status", "protocolo", "id"];
|
|
21
|
-
/** Normalized path of the opened ticket in the response (the root object). */
|
|
22
|
-
export declare const ticketOpenedItemPath = "";
|
|
23
|
-
/** Keys of the response holding secrets (none in `ura/chamado`). */
|
|
24
|
-
export declare const ticketOpenedSecretKeys: readonly [];
|
|
25
|
-
/** Keys of the response holding personal data: the customer's name and CPF/CNPJ. */
|
|
26
|
-
export declare const ticketOpenedPersonalKeys: readonly ["razaoSocial", "cpfCnpj"];
|
|
27
|
-
/** Parsed response of `POST /api/ura/chamado/`. */
|
|
28
|
-
export type OpenTicketResponse = z.output<typeof openTicketSchema>;
|
|
29
|
-
/**
|
|
30
|
-
* Params of `POST /api/ura/chamado/`; only `contrato` is required. `contato_nome` and
|
|
31
|
-
* `contato_telefone` are personal data.
|
|
32
|
-
*/
|
|
33
|
-
export interface OpenTicketParams {
|
|
34
|
-
/** Contract ID. */
|
|
35
|
-
contrato: number;
|
|
36
|
-
/** Content of the occurrence and the service order. */
|
|
37
|
-
conteudo?: string;
|
|
38
|
-
/** 1 removes SGP's default opening message ("via URA"). */
|
|
39
|
-
conteudolimpo?: 0 | 1;
|
|
40
|
-
observacao?: string;
|
|
41
|
-
/** Occurrence type code (SGP's default is 5). */
|
|
42
|
-
ocorrenciatipo?: number;
|
|
43
|
-
/** Classification IDs linked to the occurrence. */
|
|
44
|
-
tipoclassificacoes?: number[];
|
|
45
|
-
/** Occurrence method code (see `ura.listOccurrenceMethods`). */
|
|
46
|
-
metodo?: number;
|
|
47
|
-
/** Sector ID. */
|
|
48
|
-
setor?: number;
|
|
49
|
-
/** Username shown as who opened the occurrence. */
|
|
50
|
-
usuario?: string;
|
|
51
|
-
/** Username of the occurrence's responsible. */
|
|
52
|
-
responsaveloc?: string;
|
|
53
|
-
contato_nome?: string;
|
|
54
|
-
contato_telefone?: string;
|
|
55
|
-
/** 1 does not open a service order. */
|
|
56
|
-
desativa_os?: 0 | 1;
|
|
57
|
-
/** 1 creates the occurrence and the service order already closed. */
|
|
58
|
-
status_encerrado?: 0 | 1;
|
|
59
|
-
/** 1 notifies the customer of the closing, when created already closed. */
|
|
60
|
-
notificar_cliente?: 0 | 1;
|
|
61
|
-
/** Service order reason code; each SGP instance has its own (see `os.listOccurrenceReasons`). */
|
|
62
|
-
motivoos?: number;
|
|
63
|
-
/** Classification IDs linked to the service order. */
|
|
64
|
-
motivoclassificacoes?: number[];
|
|
65
|
-
/** Username of the service order's responsible technician. */
|
|
66
|
-
responsavel?: string;
|
|
67
|
-
/** Usernames of the auxiliary technicians. */
|
|
68
|
-
tecnicos?: string[];
|
|
69
|
-
/** Schedules the occurrence and the service order: `"AAAA-MM-DD HH:MM"`. */
|
|
70
|
-
data_hora_agendamento?: string;
|
|
71
|
-
/** 1 warns the responsible technician of the new service order; needs `data_hora_agendamento` and a messaging gateway in SGP. */
|
|
72
|
-
sms_tecnico?: 0 | 1;
|
|
73
|
-
/** With `servico_id`, links a specific contract service to the occurrence. */
|
|
74
|
-
tipo_servico?: "internet" | "telefonia" | "tv" | "multimidia" | "generico";
|
|
75
|
-
/** ID of the contract's service; use with `tipo_servico`. */
|
|
76
|
-
servico_id?: number;
|
|
77
|
-
/** ID of the company to link. */
|
|
78
|
-
empresa_id?: number;
|
|
79
|
-
}
|
|
80
|
-
/** Definition of `POST /api/ura/chamado/` (trailing slash required by the token whitelist). */
|
|
81
|
-
export declare const openTicketDefinition: WriteEndpointDefinition<typeof openTicketSchema>;
|
package/dist/errors.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { SgpError, SgpErrorCode, SgpWriteError } from "./result.js";
|
|
2
|
-
/** SGP `detail` for 401/403 caused by wrong token/app credentials. */
|
|
3
|
-
export declare const DETAIL_UNAUTHORIZED = "Credenciais de autentica\u00E7\u00E3o incorretas.";
|
|
4
|
-
/** SGP `detail` for 401/403 when the app has no permission for the route (credentials "not provided"). */
|
|
5
|
-
export declare const DETAIL_ROUTE_NOT_ALLOWED = "As credenciais de autentica\u00E7\u00E3o n\u00E3o foram fornecidas.";
|
|
6
|
-
/** `message` of a write whose 2xx answer does not confirm it: the write may have been applied. */
|
|
7
|
-
export declare const MESSAGE_WRITE_NOT_CONFIRMED = "SGP answered with a success status but the response does not confirm the write; it may have been applied.";
|
|
8
|
-
/** `message` of a write SGP answered with its generic exception wrapper (a 4xx `errors` list): it may have been applied. */
|
|
9
|
-
export declare const MESSAGE_WRITE_FAILED_GENERICALLY = "SGP reported an error while processing the write; it may have been applied.";
|
|
10
|
-
/** `message` of a request the SDK refused before sending it (nothing left the process). */
|
|
11
|
-
export declare const MESSAGE_REJECTED_LOCALLY = "The SDK rejected the request before sending it.";
|
|
12
|
-
/**
|
|
13
|
-
* Reads the SGP error text from a response body: a string `detail`, else a non-empty string `msg`,
|
|
14
|
-
* else `errors`, else a non-empty string `error` (see {@link mapHttpFailure}). `undefined` when the
|
|
15
|
-
* body carries none.
|
|
16
|
-
*/
|
|
17
|
-
export declare const readSgpDetail: (body: unknown) => string | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Whether the body is SGP's generic exception wrapper: `errors` is an array (e.g.
|
|
20
|
-
* `{"errors":["Ocorreu um erro: ..."]}`), as opposed to an object of field messages.
|
|
21
|
-
*/
|
|
22
|
-
export declare const hasErrorList: (body: unknown) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Builds a normalized error with the SDK-authored message for `code`, or with `message` when given.
|
|
25
|
-
*
|
|
26
|
-
* The `detail` key is omitted when `detail` is undefined.
|
|
27
|
-
*/
|
|
28
|
-
export declare const createError: (code: SgpErrorCode, status: number, endpoint: string, detail?: string, message?: string) => SgpError;
|
|
29
|
-
/**
|
|
30
|
-
* Maps a non-2xx SGP response to a normalized error.
|
|
31
|
-
*
|
|
32
|
-
* `detail` is read from the first of these that yields text: a string `detail` (SGP's DRF message),
|
|
33
|
-
* a non-empty string `msg` (e.g. `{"msg":"Informe um Raio válido."}`), then `errors` (the CRM format):
|
|
34
|
-
* an array of strings joined by `"; "`, or an object of string values as `"key: value"` joined by
|
|
35
|
-
* `"; "` in key order. Non-string items and values are ignored. Last, a non-empty string `error`
|
|
36
|
-
* (e.g. `{"error":"Cadastro não encontrado"}`, a 404 on CRM routes). A body with none of these
|
|
37
|
-
* leaves `detail` undefined. The raw body is never retained.
|
|
38
|
-
*/
|
|
39
|
-
export declare const mapHttpFailure: (status: number, body: unknown, endpoint: string) => SgpError;
|
|
40
|
-
/**
|
|
41
|
-
* Maps an exception thrown by `fetch` to a normalized error (status 0).
|
|
42
|
-
*
|
|
43
|
-
* `TimeoutError` and `AbortError` become `TIMEOUT`; anything else becomes `NETWORK`.
|
|
44
|
-
* The cause's message is never copied, since it can embed the request URL with credentials.
|
|
45
|
-
*/
|
|
46
|
-
export declare const mapFetchFailure: (cause: unknown, endpoint: string) => SgpError;
|
|
47
|
-
/**
|
|
48
|
-
* Tags a failed write with whether SGP applied it: `"not_applied"` for a 4xx (SGP rejected the
|
|
49
|
-
* request) and for a `VALIDATION` with status 0 (rejected locally, nothing was sent), `"unknown"`
|
|
50
|
-
* for anything else (timeout/network, 5xx, 2xx that failed validation, 1xx/3xx).
|
|
51
|
-
*
|
|
52
|
-
* `isErrorListBody` (the {@link hasErrorList} result for the response body) marks a 4xx body that is
|
|
53
|
-
* SGP's generic exception wrapper: SGP may have failed after applying part of the write, so that 4xx
|
|
54
|
-
* is `"unknown"` too and carries {@link MESSAGE_WRITE_FAILED_GENERICALLY} as its `message`, except
|
|
55
|
-
* 401/403/404/405/422, which stay `"not_applied"`. Omit it when the body is not known.
|
|
56
|
-
*
|
|
57
|
-
* Returns a new object; the input is not mutated.
|
|
58
|
-
*/
|
|
59
|
-
export declare const toWriteError: (error: SgpError, isErrorListBody?: boolean) => SgpWriteError;
|
package/dist/schema/parse.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import type { SgpResult } from "../result.js";
|
|
3
|
-
/**
|
|
4
|
-
* Validates an SGP response body, tolerating type drift in non-key fields.
|
|
5
|
-
*
|
|
6
|
-
* 1. Parses with `schema` (unknown keys are stripped at every level). Success → `data`.
|
|
7
|
-
* 2. Otherwise picks, per issue, the property to remove: the property the issue points at or, when
|
|
8
|
-
* the issue sits on an array element, the nearest enclosing object property (the whole array
|
|
9
|
-
* field, e.g. `clientes[0].contatos.telefones`). If none exists, or it is a key field or an
|
|
10
|
-
* ancestor of one (`keyFields`, normalized paths like `clientes[].id`) → `SCHEMA_MISMATCH`.
|
|
11
|
-
* That property is the issue's own path or a prefix of it, so every issue on a key field or on
|
|
12
|
-
* an ancestor of one ends here.
|
|
13
|
-
* 3. Removes those properties from a clone of `input` and parses exactly once more. Success →
|
|
14
|
-
* `data` plus one `SchemaWarning` per issue, with the precise issue location
|
|
15
|
-
* (e.g. `clientes[0].contatos.telefones[0]`) and type names only. Failure → `SCHEMA_MISMATCH`.
|
|
16
|
-
*
|
|
17
|
-
* `SCHEMA_MISMATCH.detail` lists the failing normalized paths (`(root)` for the body itself), never values.
|
|
18
|
-
*/
|
|
19
|
-
export declare const parseResponse: <S extends z.ZodType>(schema: S, keyFields: readonly string[], input: unknown, endpoint: string) => SgpResult<z.output<S>>;
|
package/dist/schema/paths.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Joins a Zod issue path with array indices collapsed to `[]`, the form used by `keyFields`.
|
|
3
|
-
*
|
|
4
|
-
* `["contratos", 0, "contratoId"]` → `"contratos[].contratoId"`; `[0, "id"]` → `"[].id"`; `[]` → `""`.
|
|
5
|
-
*/
|
|
6
|
-
export declare const normalizePath: (path: ReadonlyArray<PropertyKey>) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Joins a Zod issue path keeping the real array indices, the form used in `SchemaWarning.path`.
|
|
9
|
-
*
|
|
10
|
-
* `["clientes", 0, "sexo"]` → `"clientes[0].sexo"`.
|
|
11
|
-
*/
|
|
12
|
-
export declare const formatPath: (path: ReadonlyArray<PropertyKey>) => string;
|
|
13
|
-
/**
|
|
14
|
-
* Tells whether a raw Zod issue path is a key field or an ancestor of one.
|
|
15
|
-
*
|
|
16
|
-
* Segments are compared as they are, never joined into a string, so a data-defined property name
|
|
17
|
-
* holding `.`, `[` or `]` stays one segment. The root (`[]`) is an ancestor of every key.
|
|
18
|
-
* A numeric segment matches only a `[]` key segment. A string segment matches a `*` key segment
|
|
19
|
-
* (any name, the empty one included) or an equal name, never `[]`: `["[].*"]` covers `[0, "Geogrid"]`
|
|
20
|
-
* and `[0, "Geo.grid"]` (data-defined names), but not what sits below them.
|
|
21
|
-
*/
|
|
22
|
-
export declare const isKeyPathOf: (path: ReadonlyArray<PropertyKey>, keyFields: readonly string[]) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Tells whether a normalized path is a key field or an ancestor of one.
|
|
25
|
-
*
|
|
26
|
-
* The root (`""`) is an ancestor of every key. `"cliente"` is not an ancestor of `"clientes[].id"`.
|
|
27
|
-
* A `*` segment in a key matches exactly one property name, never an array index: `"[].*"` covers
|
|
28
|
-
* `"[].SGPMaps"` and `"[].Geogrid"` (data-defined names), but not what sits below them.
|
|
29
|
-
*/
|
|
30
|
-
export declare const isKeyPath: (path: string, keyFields: readonly string[]) => boolean;
|
|
31
|
-
/** Reads the value at `path`, or `undefined` when any step is missing or not indexable. */
|
|
32
|
-
export declare const valueAt: (input: unknown, path: ReadonlyArray<PropertyKey>) => unknown;
|
|
33
|
-
/**
|
|
34
|
-
* Names the type of the value at `path`; never returns the value itself.
|
|
35
|
-
*
|
|
36
|
-
* One of `"string" | "number" | "boolean" | "null" | "undefined" | "array" | "object"` for JSON input.
|
|
37
|
-
*/
|
|
38
|
-
export declare const typeNameAt: (input: unknown, path: ReadonlyArray<PropertyKey>) => string;
|
package/dist/transport.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { SgpError } from "./result.js";
|
|
2
|
-
/** Default request timeout in milliseconds. */
|
|
3
|
-
export declare const DEFAULT_TIMEOUT_MS = 20000;
|
|
4
|
-
/** Connection settings shared by every SDK method. */
|
|
5
|
-
export interface SgpClientConfig {
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
token: string;
|
|
8
|
-
app: string;
|
|
9
|
-
/** Request timeout in milliseconds. Defaults to {@link DEFAULT_TIMEOUT_MS}. */
|
|
10
|
-
timeoutMs?: number;
|
|
11
|
-
/** Custom `fetch`, mainly for tests. Defaults to the global `fetch`. */
|
|
12
|
-
fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* A request parameter value. Arrays and objects are only valid on POST/PUT; `undefined` object keys
|
|
16
|
-
* are omitted at any depth.
|
|
17
|
-
*/
|
|
18
|
-
export type ParamValue = string | number | boolean | null | readonly ParamValue[] | {
|
|
19
|
-
readonly [key: string]: ParamValue | undefined;
|
|
20
|
-
};
|
|
21
|
-
/** A file sent as one part of a multipart request. */
|
|
22
|
-
export interface SgpFile {
|
|
23
|
-
data: Blob | Uint8Array | ArrayBuffer;
|
|
24
|
-
filename: string;
|
|
25
|
-
/** MIME type of the part. Defaults to the `type` of a `Blob`; none for bytes. */
|
|
26
|
-
contentType?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* One SGP request; `path` starts with `/` and may hold `{name}` placeholders filled from
|
|
30
|
-
* `pathParams`. `params` with `undefined` values are dropped. POST/PUT with `files` is sent as
|
|
31
|
-
* multipart; otherwise as JSON.
|
|
32
|
-
*/
|
|
33
|
-
export interface RequestSpec {
|
|
34
|
-
method: "GET" | "POST" | "PUT";
|
|
35
|
-
path: string;
|
|
36
|
-
pathParams?: Record<string, string | number>;
|
|
37
|
-
params?: Record<string, ParamValue | undefined>;
|
|
38
|
-
files?: Record<string, SgpFile>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Parsed JSON body of a 2xx response with its HTTP status, or the normalized failure.
|
|
42
|
-
* `hasErrorList` is set on a non-2xx answer: its JSON body is SGP's generic exception wrapper
|
|
43
|
-
* (`errors` is an array). The body itself is never kept.
|
|
44
|
-
*/
|
|
45
|
-
export type RawResponse = {
|
|
46
|
-
ok: true;
|
|
47
|
-
body: unknown;
|
|
48
|
-
status: number;
|
|
49
|
-
} | {
|
|
50
|
-
ok: false;
|
|
51
|
-
error: SgpError;
|
|
52
|
-
hasErrorList?: boolean;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Sends one request to SGP and returns the parsed JSON body or a normalized error.
|
|
56
|
-
*
|
|
57
|
-
* GET sends `token` and `app` in the query string and only accepts primitive params; POST/PUT send
|
|
58
|
-
* them in a JSON body, or as multipart fields when `files` is set. A 2xx response with an empty
|
|
59
|
-
* body yields `body: null`. The success result carries the real 2xx `status`. Redirects are never
|
|
60
|
-
* followed (`redirect: "manual"`): a 3xx comes back as an `UNKNOWN` error with its status.
|
|
61
|
-
* Never throws: invalid path params or structured GET params (`VALIDATION`, status 0, no request
|
|
62
|
-
* sent), network failures, timeouts, non-2xx statuses and non-JSON 2xx bodies all come back as
|
|
63
|
-
* `{ ok: false, error }`, where `error.endpoint` is `spec.path` (the template) only.
|
|
64
|
-
*/
|
|
65
|
-
export declare const sendRequest: (config: SgpClientConfig, spec: RequestSpec) => Promise<RawResponse>;
|