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.
- package/CHANGELOG.md +234 -0
- package/COMPATIBILITY.md +231 -0
- package/MIGRATION.md +344 -0
- package/README.md +464 -265
- 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 +938 -165
- package/dist/config.d.ts +115 -0
- package/dist/constants.d.ts +85 -0
- package/dist/document.d.ts +11 -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 +55 -49
- package/dist/index.js +3750 -1293
- package/dist/normalize.d.ts +9 -0
- package/dist/operation-sensitivity.d.ts +729 -0
- package/dist/operation.d.ts +145 -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-check-connection.d.ts +56 -0
- package/dist/operations/contracts-list-services.d.ts +103 -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-address.d.ts +46 -0
- package/dist/operations/coverage-check.d.ts +43 -0
- package/dist/operations/coverage-list-gateways.d.ts +16 -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 +165 -0
- package/dist/operations/crm-customers-update-status.d.ts +41 -0
- package/dist/operations/customers-list.d.ts +104 -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 +148 -0
- package/dist/operations/maintenance-list.d.ts +35 -0
- package/dist/operations/occurrences-create.d.ts +125 -0
- package/dist/operations/occurrences-list-methods.d.ts +14 -0
- package/dist/operations/occurrences-list-types.d.ts +20 -0
- package/dist/operations/occurrences-list.d.ts +127 -0
- package/dist/{endpoints/ura/list-plans.d.ts → operations/plans-list.d.ts} +33 -23
- package/dist/operations/pre-registrations-create.d.ts +276 -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-generic.d.ts +52 -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-generic.d.ts +28 -0
- package/dist/operations/services-remove-tv.d.ts +29 -0
- package/dist/operations/work-orders-get.d.ts +99 -0
- package/dist/operations/work-orders-list-comments.d.ts +34 -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 +113 -41
- 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-annotations.d.ts +0 -32
- 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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OperationDefinition } from "../operation.js";
|
|
3
|
+
declare const preRegistrationPlansSchema: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.core.$ZodBranded<z.ZodNumber, "PreRegistrationPlanId", "out">;
|
|
5
|
+
tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
valor: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
+
descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
observacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
gateway: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
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
|
+
descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
13
|
+
}, z.core.$loose>>>;
|
|
14
|
+
}, z.core.$loose>>;
|
|
15
|
+
/**
|
|
16
|
+
* The response of `POST /api/precadastro/plano/list`, in SGP's own shape: a bare array with one
|
|
17
|
+
* entry per plan of the pré-cadastro catalog. The route is not paginated, so there is no envelope
|
|
18
|
+
* and no total. Each `id` is a `PreRegistrationPlanId`, a type apart from the `PlanId` of
|
|
19
|
+
* `plans.list`.
|
|
20
|
+
*/
|
|
21
|
+
export type PreRegistrationsListPlansData = z.output<typeof preRegistrationPlansSchema>;
|
|
22
|
+
/** INTERNAL definition of `preRegistrations.listPlans`. */
|
|
23
|
+
export declare const preRegistrationsListPlans: OperationDefinition<PreRegistrationsListPlansData, "preRegistrations.listPlans">;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OperationDefinition } from "../operation.js";
|
|
3
|
+
declare const sellersSchema: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodNumber;
|
|
5
|
+
nome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
cpf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
email: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
}, z.core.$loose>>;
|
|
9
|
+
/**
|
|
10
|
+
* The response of `POST /api/precadastro/vendedor/list`, in SGP's own shape: a bare array with one
|
|
11
|
+
* entry per seller. The route is not paginated, so there is no envelope and no total.
|
|
12
|
+
*/
|
|
13
|
+
export type PreRegistrationsListSellersData = z.output<typeof sellersSchema>;
|
|
14
|
+
/** INTERNAL definition of `preRegistrations.listSellers`. */
|
|
15
|
+
export declare const preRegistrationsListSellers: OperationDefinition<PreRegistrationsListSellersData, "preRegistrations.listSellers">;
|
|
16
|
+
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
|
+
/** 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 {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OperationDefinition } from "../operation.js";
|
|
3
|
+
import type { PlanId } from "./plans-list.js";
|
|
4
|
+
/** Input of `services.addTv`, named as SGP names the fields. */
|
|
5
|
+
export interface ServiceAddTvInput {
|
|
6
|
+
/** Exercised. ID of the contract; it must be active (SGP refuses otherwise). */
|
|
7
|
+
clientecontrato_id: number;
|
|
8
|
+
/**
|
|
9
|
+
* Exercised. ID of the TV plan, a `PlanId` from the URA plan list (`plans.list`): a TV plan was
|
|
10
|
+
* accepted and a read-back confirmed the plan. The ID spaces differ: a plan id from this list
|
|
11
|
+
* was refused (400) as `plano_id` on the pré-cadastro route while accepted (200) as
|
|
12
|
+
* `planobase_id` here.
|
|
13
|
+
*/
|
|
14
|
+
planobase_id: PlanId;
|
|
15
|
+
/** Exercised. Free-text note about the service. Personal data: never log it. */
|
|
16
|
+
info_extra?: string;
|
|
17
|
+
/** Documented, never sent. ID of the equipment type. */
|
|
18
|
+
tipo_equipamento?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Documented, never sent. ID of the address to copy to the installation (omitted: the
|
|
21
|
+
* customer's).
|
|
22
|
+
*/
|
|
23
|
+
endereco_id?: number;
|
|
24
|
+
}
|
|
25
|
+
/** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
|
|
26
|
+
export declare const servicesAddTvInputSchema: z.ZodObject<{
|
|
27
|
+
clientecontrato_id: z.ZodNumber;
|
|
28
|
+
planobase_id: z.core.$ZodBranded<z.ZodNumber, "PlanId", "out">;
|
|
29
|
+
info_extra: z.ZodOptional<z.ZodString>;
|
|
30
|
+
tipo_equipamento: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
endereco_id: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
/**
|
|
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 text (`"<n>"`) and `data` carries as a number
|
|
36
|
+
* (changed versus 2.0.0-beta.1). Other keys SGP may add are kept.
|
|
37
|
+
*/
|
|
38
|
+
declare const tvAddedSchema: z.ZodObject<{
|
|
39
|
+
msg: z.ZodString;
|
|
40
|
+
clientecontrato_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
|
|
41
|
+
servico_id: z.ZodNumber;
|
|
42
|
+
}, z.core.$loose>;
|
|
43
|
+
/** Response of `services.addTv`. */
|
|
44
|
+
export type ServiceAddTvData = z.output<typeof tvAddedSchema>;
|
|
45
|
+
/** INTERNAL definition of `services.addTv`. */
|
|
46
|
+
export declare const servicesAddTv: OperationDefinition<ServiceAddTvData, "services.addTv">;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OperationDefinition } from "../operation.js";
|
|
3
|
+
import type { PlanId } from "./plans-list.js";
|
|
4
|
+
/**
|
|
5
|
+
* Input of `services.changePlan`, named as SGP names the fields. `action` is fixed by the method
|
|
6
|
+
* (`change_plano`) and is not an input.
|
|
7
|
+
*/
|
|
8
|
+
export interface ServiceChangePlanInput {
|
|
9
|
+
/** Exercised. ID of the serviço to change (the `id` of `customers.list` -> `servicos[]`). */
|
|
10
|
+
servico_id: number;
|
|
11
|
+
/**
|
|
12
|
+
* Exercised with `1` only (`SERVICE_TYPE.internet`). Type of the serviço; required. Any
|
|
13
|
+
* positive integer is sent and SGP decides what it takes, but only internet was ever exercised.
|
|
14
|
+
*/
|
|
15
|
+
servico_tipo: number;
|
|
16
|
+
/**
|
|
17
|
+
* Exercised. ID of the new plan, a `PlanId` from the URA catalog (`plans.list`), which is the ID
|
|
18
|
+
* space of operations on existing services (not the pré-cadastro catalog of
|
|
19
|
+
* `preRegistrations.listPlans`, whose ids are `PreRegistrationPlanId`).
|
|
20
|
+
*/
|
|
21
|
+
plano_id: PlanId;
|
|
22
|
+
}
|
|
23
|
+
/** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
|
|
24
|
+
export declare const servicesChangePlanInputSchema: z.ZodObject<{
|
|
25
|
+
servico_id: z.ZodNumber;
|
|
26
|
+
servico_tipo: z.ZodNumber;
|
|
27
|
+
plano_id: z.core.$ZodBranded<z.ZodNumber, "PlanId", "out">;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
/**
|
|
30
|
+
* Success body of `POST /api/suporte/service/update/{servico_id}/`: SGP's `msg`. It names neither
|
|
31
|
+
* the service nor the plan. Other keys SGP may add are kept.
|
|
32
|
+
*/
|
|
33
|
+
declare const planChangedSchema: z.ZodObject<{
|
|
34
|
+
msg: z.ZodString;
|
|
35
|
+
}, z.core.$loose>;
|
|
36
|
+
/** Response of `services.changePlan`. */
|
|
37
|
+
export type ServiceChangePlanData = z.output<typeof planChangedSchema>;
|
|
38
|
+
/** INTERNAL definition of `services.changePlan`. */
|
|
39
|
+
export declare const servicesChangePlan: OperationDefinition<ServiceChangePlanData, "services.changePlan">;
|
|
40
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OperationDefinition } from "../operation.js";
|
|
3
|
+
/** Input of `services.removeTv`, named as SGP names the fields. */
|
|
4
|
+
export interface ServiceRemoveTvInput {
|
|
5
|
+
/** Exercised. ID of the TV serviço to remove (the `servico_id` of `services.addTv`). */
|
|
6
|
+
servico_id: number;
|
|
7
|
+
/** Exercised. ID of the contract the serviço belongs to. */
|
|
8
|
+
clientecontrato_id: number;
|
|
9
|
+
}
|
|
10
|
+
/** INTERNAL. Validation of the input, exported so a test can check it against the public type. */
|
|
11
|
+
export declare const servicesRemoveTvInputSchema: z.ZodObject<{
|
|
12
|
+
servico_id: z.ZodNumber;
|
|
13
|
+
clientecontrato_id: z.ZodNumber;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
/**
|
|
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 text and `data` carries as a number (changed
|
|
18
|
+
* versus 2.0.0-beta.1). Other keys SGP may add are kept.
|
|
19
|
+
*/
|
|
20
|
+
declare const tvRemovedSchema: z.ZodObject<{
|
|
21
|
+
msg: z.ZodString;
|
|
22
|
+
clientecontrato_id: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<number | null, unknown>>>;
|
|
23
|
+
servico_id: z.ZodNumber;
|
|
24
|
+
}, z.core.$loose>;
|
|
25
|
+
/** Response of `services.removeTv`. */
|
|
26
|
+
export type ServiceRemoveTvData = z.output<typeof tvRemovedSchema>;
|
|
27
|
+
/** INTERNAL definition of `services.removeTv`. */
|
|
28
|
+
export declare const servicesRemoveTv: OperationDefinition<ServiceRemoveTvData, "services.removeTv">;
|
|
29
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { OperationDefinition } from "../operation.js";
|
|
3
|
+
declare const workOrderReasonsSchema: z.ZodArray<z.ZodObject<{
|
|
4
|
+
id: z.ZodNumber;
|
|
5
|
+
codigo: z.ZodNumber;
|
|
6
|
+
descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
classificacoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
|
|
9
|
+
classificacoes_obrigatorio: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
10
|
+
setores: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
|
|
11
|
+
}, z.core.$loose>>;
|
|
12
|
+
/**
|
|
13
|
+
* The response of `GET /api/os/ocorrencia/motivo/list/`, in SGP's own shape: a bare array with one
|
|
14
|
+
* entry per occurrence reason (the `motivo` of a work order). The route is not paginated, so there
|
|
15
|
+
* is no envelope and no total.
|
|
16
|
+
*/
|
|
17
|
+
export type WorkOrdersListReasonsData = z.output<typeof workOrderReasonsSchema>;
|
|
18
|
+
/** INTERNAL definition of `workOrders.listReasons`. */
|
|
19
|
+
export declare const workOrdersListReasons: OperationDefinition<WorkOrdersListReasonsData, "workOrders.listReasons">;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
ordens_servicos: z.ZodArray<z.ZodObject<{
|
|
11
|
+
id: z.ZodNumber;
|
|
12
|
+
contrato: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
13
|
+
status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
14
|
+
status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
tipo_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
16
|
+
data_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
cliente: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
contrato_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
contrato_status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
20
|
+
ocorrencia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
hora_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
data_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
23
|
+
hora_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
24
|
+
data_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
25
|
+
hora_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
26
|
+
tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
27
|
+
motivo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
28
|
+
pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
29
|
+
conteudo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
30
|
+
responsavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
tecnicos_auxiliares: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
|
|
32
|
+
usuario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
33
|
+
usuario_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
34
|
+
classificacoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodUnknown>>>;
|
|
35
|
+
}, z.core.$loose>>;
|
|
36
|
+
}, z.core.$loose>;
|
|
37
|
+
/**
|
|
38
|
+
* One page of `POST /api/ura/ordemservico/list/`, with SGP's own `paginacao`, returned as received:
|
|
39
|
+
*
|
|
40
|
+
* - `offset`: index of the first work order of the page (SGP starts at 0);
|
|
41
|
+
* - `limit`: page size SGP applied, which may differ from the one requested;
|
|
42
|
+
* - `parcial`: how many work orders this page holds (observed equal to `ordens_servicos.length`);
|
|
43
|
+
* - `total`: how many work orders match the filters in all, across every page.
|
|
44
|
+
*
|
|
45
|
+
* `total` is SGP's and never computed by the SDK: a page without a numeric `total` is
|
|
46
|
+
* `INVALID_RESPONSE`. Nothing here fetches the next page: ask for it with `offset`.
|
|
47
|
+
*/
|
|
48
|
+
export type WorkOrdersListData = z.output<typeof pageSchema>;
|
|
49
|
+
/** Filters and paging of `workOrders.list`, named as SGP names them. All optional. */
|
|
50
|
+
export interface WorkOrdersListInput {
|
|
51
|
+
/** Index of the first work order of the page; SGP starts at 0. Non-negative integer. */
|
|
52
|
+
offset?: number;
|
|
53
|
+
/** Work orders per page. Non-negative integer; SGP decides the cap. */
|
|
54
|
+
limit?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Work order id. SGP's collection describes it as the id of the occurrence (the OS); whether it
|
|
57
|
+
* matches `ordens_servicos[].id` or the `ocorrencia` number was not verified.
|
|
58
|
+
*/
|
|
59
|
+
ordem_servico?: number;
|
|
60
|
+
/** Work order status id (`status_id` in the result; 0 is "Aberta" in the captures). */
|
|
61
|
+
status?: number;
|
|
62
|
+
/** POP id. */
|
|
63
|
+
pop?: number;
|
|
64
|
+
/** Occurrence reason id. */
|
|
65
|
+
motivo?: number;
|
|
66
|
+
/** Only work orders of this contract. */
|
|
67
|
+
contrato?: number;
|
|
68
|
+
}
|
|
69
|
+
/** INTERNAL. Validation of the input, exported so a test can check its keys are classified. */
|
|
70
|
+
export declare const workOrdersListInputSchema: z.ZodObject<{
|
|
71
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
ordem_servico: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
pop: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
motivo: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
contrato: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
/** INTERNAL definition of `workOrders.list`. */
|
|
80
|
+
export declare const workOrdersList: OperationDefinition<WorkOrdersListData, "workOrders.list">;
|
|
81
|
+
export {};
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills the `{name}` placeholders of `template` with URL-encoded `pathParams`. Otherwise the first
|
|
3
|
+
* problem, named without its value: a placeholder with no value, an empty value, `.`/`..` (dot
|
|
4
|
+
* segments would change the route), a number that is not a safe integer, a value that cannot be
|
|
5
|
+
* encoded (lone surrogate), or a `pathParams` key that is not in the template.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolvePath: (template: string, pathParams?: Readonly<Record<string, string | number>>) => {
|
|
8
|
+
ok: true;
|
|
9
|
+
path: string;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
problem: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CallOptions, ResolvedConfig } from "./config.js";
|
|
2
|
+
import type { Encoding } from "./operation.js";
|
|
3
|
+
import type { SgpResult } from "./result.js";
|
|
4
|
+
/** Input of `request()`. */
|
|
5
|
+
export interface RawRequestInput {
|
|
6
|
+
/** HTTP method. Which one a route needs is for the caller to know: the SDK never infers it. */
|
|
7
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
8
|
+
/**
|
|
9
|
+
* Route on the configured SGP instance, e.g. `/api/ura/clientes/`: it starts with `/api/` and is
|
|
10
|
+
* already in its final form (no query, no fragment, no `//`, no `.`/`..` segments, no `%`).
|
|
11
|
+
* Anything else is refused locally with `INVALID_INPUT` before a request is sent. Put query
|
|
12
|
+
* parameters of a GET in `body`. `;` is sent literally (it stays on the same origin, under `/api/`).
|
|
13
|
+
*/
|
|
14
|
+
path: string;
|
|
15
|
+
/**
|
|
16
|
+
* Request fields. A GET has no body: they go in the query string (primitives only). Other
|
|
17
|
+
* methods send them in `encoding`; a `json` body must be serializable (no `BigInt`, no cycle)
|
|
18
|
+
* and a `form` body takes primitives only. It is copied once when the call starts. Credentials are added by the SDK and cannot be
|
|
19
|
+
* overridden.
|
|
20
|
+
*/
|
|
21
|
+
body?: Readonly<Record<string, unknown>>;
|
|
22
|
+
/** Body encoding of POST/PUT/DELETE: `json` (default) or `form` (multipart text fields). */
|
|
23
|
+
encoding?: Encoding;
|
|
24
|
+
}
|
|
25
|
+
/** INTERNAL. Runs `request()`: validates the destination, then the shared executor. */
|
|
26
|
+
export declare const executeRawRequest: (config: ResolvedConfig, input: RawRequestInput, options?: CallOptions) => Promise<SgpResult<unknown>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "./config.js";
|
|
2
|
+
import type { OperationDefinition, RequestBuild } from "./operation.js";
|
|
3
|
+
/** What goes on the wire for one attempt. */
|
|
4
|
+
export interface EncodedRequest {
|
|
5
|
+
url: string;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
body?: string | FormData;
|
|
8
|
+
}
|
|
9
|
+
/** The parts of a successful `buildRequest` that the encoder writes: body fields, files, URL query. */
|
|
10
|
+
type BuiltRequest = Pick<Extract<RequestBuild, {
|
|
11
|
+
ok: true;
|
|
12
|
+
}>, "params" | "files" | "query">;
|
|
13
|
+
/**
|
|
14
|
+
* Encodes one request. A GET never has a body: params and credentials go in the query string
|
|
15
|
+
* (primitives only, `undefined` omitted). Every other method (POST, PUT and DELETE alike) sends
|
|
16
|
+
* the body in the operation's encoding: `json`, or `form` (multipart text fields, no content-type
|
|
17
|
+
* header so `fetch` adds the boundary), or `form-files`, the same plus one part per file (written
|
|
18
|
+
* before the credentials, so these stay last). Credentials are written once and last, so a param
|
|
19
|
+
* can never replace or repeat them. `undefined` when a GET or form param is not a primitive.
|
|
20
|
+
*
|
|
21
|
+
* `query` is for a request that has a body: its entries go in the URL after the path (primitives
|
|
22
|
+
* only, `undefined` omitted; none, or only `undefined`, leaves the URL as it was) while the
|
|
23
|
+
* credentials stay in the body. A GET already puts everything in the query string, so a GET with a
|
|
24
|
+
* `query`, a `query` that is not made of primitives, or one that names `token` or `app` gives
|
|
25
|
+
* `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const encodeRequest: (config: ResolvedConfig, definition: Pick<OperationDefinition<unknown>, "method" | "encoding">, path: string, built?: BuiltRequest) => EncodedRequest | undefined;
|
|
28
|
+
export {};
|