sgp-sdk 1.2.0 → 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 +422 -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 +661 -165
- 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 -49
- package/dist/index.js +2947 -1292
- 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-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,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Address as SGP takes it. Pass it once: operations that take an address send it as the loose
|
|
4
|
+
* fields (`logradouro`, `numero`, ...) SGP reads, with the names unchanged. Every key is optional
|
|
5
|
+
* here: each operation declares which ones it requires.
|
|
6
|
+
*/
|
|
7
|
+
export interface SgpAddress {
|
|
8
|
+
/** Street name. */
|
|
9
|
+
logradouro?: string;
|
|
10
|
+
/** A label, not a count: `"S/N"` and `"12-A"` are valid. */
|
|
11
|
+
numero?: string | number;
|
|
12
|
+
/** Complement (apartment, block, ...). */
|
|
13
|
+
complemento?: string;
|
|
14
|
+
/** Neighbourhood. */
|
|
15
|
+
bairro?: string;
|
|
16
|
+
/** City. */
|
|
17
|
+
cidade?: string;
|
|
18
|
+
/** Postal code (CEP). */
|
|
19
|
+
cep?: string;
|
|
20
|
+
/** State code, e.g. `"SC"`. */
|
|
21
|
+
uf?: string;
|
|
22
|
+
/** Country code, e.g. `"BR"` (SGP's default). */
|
|
23
|
+
pais?: string;
|
|
24
|
+
/** Reference point. */
|
|
25
|
+
pontoreferencia?: string;
|
|
26
|
+
/** Map position, `"lat,lng"`. */
|
|
27
|
+
map_ll?: string;
|
|
28
|
+
/** Condominium ID. */
|
|
29
|
+
condominio?: string | number;
|
|
30
|
+
}
|
|
31
|
+
/** Validation shape of an {@link SgpAddress}, every key optional; operations override what they require. */
|
|
32
|
+
export declare const addressShape: {
|
|
33
|
+
logradouro: z.ZodOptional<z.ZodString>;
|
|
34
|
+
numero: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
35
|
+
complemento: z.ZodOptional<z.ZodString>;
|
|
36
|
+
bairro: z.ZodOptional<z.ZodString>;
|
|
37
|
+
cidade: z.ZodOptional<z.ZodString>;
|
|
38
|
+
cep: z.ZodOptional<z.ZodString>;
|
|
39
|
+
uf: z.ZodOptional<z.ZodString>;
|
|
40
|
+
pais: z.ZodOptional<z.ZodString>;
|
|
41
|
+
pontoreferencia: z.ZodOptional<z.ZodString>;
|
|
42
|
+
map_ll: z.ZodOptional<z.ZodString>;
|
|
43
|
+
condominio: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
44
|
+
};
|
|
45
|
+
/** The address as the loose fields to send: same keys, no `undefined` ones. */
|
|
46
|
+
export declare const flatAddress: (address: SgpAddress) => Record<string, string | number>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The requested identities; at least one is present, and both mean AND. */
|
|
2
|
+
export interface AnnotationFilters {
|
|
3
|
+
cliente_id?: number;
|
|
4
|
+
contrato_id?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Outcome of the local selection. `paths` names the identity fields (`[].cliente`,
|
|
8
|
+
* `[].clientecontrato`) that kept a row's membership undecidable: paths only, never values.
|
|
9
|
+
*/
|
|
10
|
+
type AnnotationSelection = {
|
|
11
|
+
ok: true;
|
|
12
|
+
selected: unknown[];
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
paths: readonly string[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* INTERNAL. Local selection of the rows of one SGP annotation response, by raw identity and BEFORE
|
|
19
|
+
* any row is parsed: SGP ignores the customer and contract filters and answers with other
|
|
20
|
+
* customers' notes, so nothing but a row that provably matches may go on.
|
|
21
|
+
*
|
|
22
|
+
* - One definite mismatch excludes a row (AND), even when the other identity is malformed or the
|
|
23
|
+
* rest of the row is garbage: a foreign row is never looked at again.
|
|
24
|
+
* - A `null` contract is a definite mismatch when a contract was requested.
|
|
25
|
+
* - A row that no definite mismatch excludes, and whose requested identity is missing or not a
|
|
26
|
+
* number, is undecidable: the whole selection fails at the first such row (never a silent skip,
|
|
27
|
+
* never a partial success).
|
|
28
|
+
* - A selected note whose nested objects carry another identity fails the selection too.
|
|
29
|
+
* - Order and duplicates are kept; nothing is parsed, coerced or deduplicated.
|
|
30
|
+
*/
|
|
31
|
+
export declare const selectAnnotations: (rows: readonly unknown[], filters: AnnotationFilters) => AnnotationSelection;
|
|
32
|
+
export {};
|
package/dist/budget.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Who stopped the call: the SDK's own deadline or the caller's signal. */
|
|
2
|
+
export type StopCause = "timeout" | "aborted";
|
|
3
|
+
/** Whether `error` is the unwinding of a race that the budget won, and nothing else. */
|
|
4
|
+
export declare const isBudgetStopped: (error: unknown) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The one time budget of a logical call: a deadline plus the caller's signal, merged into a single
|
|
7
|
+
* signal for `fetch`. It is never reset, so it covers every wait of the call (headers, body,
|
|
8
|
+
* retries and backoff). The deadline is enforced by a real timer; `now` only measures what is left.
|
|
9
|
+
*/
|
|
10
|
+
export interface Budget {
|
|
11
|
+
/** Aborts when the deadline expires or the caller's signal aborts. */
|
|
12
|
+
readonly signal: AbortSignal;
|
|
13
|
+
/** Why the budget stopped; `undefined` while it is still running. */
|
|
14
|
+
cause: () => StopCause | undefined;
|
|
15
|
+
/** Milliseconds left until the deadline, by the injected clock. Never negative. */
|
|
16
|
+
remainingMs: () => number;
|
|
17
|
+
/**
|
|
18
|
+
* Settles with `work`, or rejects as soon as the budget stops, even when `work` ignores the
|
|
19
|
+
* signal. The caller decides what the rejection means from {@link Budget.cause}.
|
|
20
|
+
*/
|
|
21
|
+
race: <T>(work: Promise<T>) => Promise<T>;
|
|
22
|
+
/** Clears the timer and the listener on the caller's signal. Safe to call twice. */
|
|
23
|
+
dispose: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Starts the budget. `undefined` when the caller's signal cannot be read or listened to (it is unusable):
|
|
27
|
+
* nothing is left running in that case, because the listener is registered before the timer.
|
|
28
|
+
*/
|
|
29
|
+
export declare const startBudget: (timeoutMs: number, callerSignal: AbortSignal | undefined, now?: () => number) => Budget | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ResponseBody, SgpError, SgpErrorCode, SgpErrorFields } from "./result.js";
|
|
2
|
+
/** SGP's own error fields found in a JSON object body, values untouched. `undefined` when none. */
|
|
3
|
+
export declare const projectSgpFields: (body: ResponseBody) => SgpErrorFields | undefined;
|
|
4
|
+
interface Classification {
|
|
5
|
+
code: SgpErrorCode;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Classifies a complete HTTP response by status alone: the body can only refine a 403, and
|
|
10
|
+
* a body that cannot be read or parsed never erases the status already received.
|
|
11
|
+
*/
|
|
12
|
+
export declare const classifyStatus: (status: number, body: ResponseBody) => Classification;
|
|
13
|
+
/** Builds an error with the SDK-authored message for `code`. */
|
|
14
|
+
export declare const buildError: (code: SgpErrorCode, operation: string, extra?: Partial<Pick<SgpError, "reason" | "effect" | "sgp" | "issues">>) => SgpError;
|
|
15
|
+
export {};
|