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
package/dist/index.js
CHANGED
|
@@ -1,1252 +1,2130 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var MESSAGE_REJECTED_LOCALLY = "The SDK rejected the request before sending it.";
|
|
7
|
-
var MESSAGES = {
|
|
8
|
-
UNAUTHORIZED: "SGP rejected the credentials (token or app).",
|
|
9
|
-
ROUTE_NOT_ALLOWED: "SGP does not allow this app to call this route.",
|
|
10
|
-
NOT_FOUND: "SGP resource not found.",
|
|
11
|
-
METHOD_NOT_ALLOWED: "SGP does not accept this HTTP method on this route.",
|
|
12
|
-
VALIDATION: "SGP rejected the request parameters.",
|
|
13
|
-
SCHEMA_MISMATCH: "SGP response does not match the expected schema.",
|
|
14
|
-
UPSTREAM: "SGP failed to process the request.",
|
|
15
|
-
TIMEOUT: "Request to SGP timed out.",
|
|
16
|
-
NETWORK: "Could not reach SGP.",
|
|
17
|
-
UNKNOWN: "Unexpected response from SGP."
|
|
18
|
-
};
|
|
19
|
-
var readErrors = (errors) => {
|
|
20
|
-
let parts = [];
|
|
21
|
-
if (Array.isArray(errors)) {
|
|
22
|
-
parts = errors.filter((item) => typeof item === "string");
|
|
23
|
-
} else if (typeof errors === "object" && errors !== null) {
|
|
24
|
-
parts = Object.entries(errors).flatMap(([key, value]) => typeof value === "string" ? [`${key}: ${value}`] : []);
|
|
1
|
+
// src/retry.ts
|
|
2
|
+
var sleepFor = (ms, signal) => new Promise((resolve) => {
|
|
3
|
+
if (signal.aborted) {
|
|
4
|
+
resolve();
|
|
5
|
+
return;
|
|
25
6
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
7
|
+
const finish = () => {
|
|
8
|
+
clearTimeout(timer);
|
|
9
|
+
signal.removeEventListener("abort", finish);
|
|
10
|
+
resolve();
|
|
11
|
+
};
|
|
12
|
+
const timer = setTimeout(finish, ms);
|
|
13
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
14
|
+
});
|
|
15
|
+
var defaultRuntime = {
|
|
16
|
+
now: () => Date.now(),
|
|
17
|
+
random: () => Math.random(),
|
|
18
|
+
sleep: sleepFor
|
|
28
19
|
};
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var hasErrorList = (body) => typeof body === "object" && body !== null && ("errors" in body) && Array.isArray(body.errors);
|
|
42
|
-
var codeForHttpStatus = (status, detail) => {
|
|
43
|
-
if (status === 401 || status === 403) {
|
|
44
|
-
if (detail === DETAIL_UNAUTHORIZED)
|
|
45
|
-
return "UNAUTHORIZED";
|
|
46
|
-
if (detail === DETAIL_ROUTE_NOT_ALLOWED)
|
|
47
|
-
return "ROUTE_NOT_ALLOWED";
|
|
48
|
-
return "UNKNOWN";
|
|
20
|
+
var BASE_BACKOFF_MS = 500;
|
|
21
|
+
var MAX_BACKOFF_MS = 1e4;
|
|
22
|
+
var TRANSIENT_UPSTREAM_STATUSES = new Set([502, 503, 504]);
|
|
23
|
+
var isTransientFailure = (failure) => {
|
|
24
|
+
switch (failure.error.code) {
|
|
25
|
+
case "RATE_LIMITED":
|
|
26
|
+
case "NETWORK":
|
|
27
|
+
return true;
|
|
28
|
+
case "UPSTREAM":
|
|
29
|
+
return failure.response !== null && TRANSIENT_UPSTREAM_STATUSES.has(failure.response.status);
|
|
30
|
+
default:
|
|
31
|
+
return false;
|
|
49
32
|
}
|
|
50
|
-
if (status === 404)
|
|
51
|
-
return "NOT_FOUND";
|
|
52
|
-
if (status === 405)
|
|
53
|
-
return "METHOD_NOT_ALLOWED";
|
|
54
|
-
if (status >= 400 && status < 500)
|
|
55
|
-
return "VALIDATION";
|
|
56
|
-
if (status >= 500 && status < 600)
|
|
57
|
-
return "UPSTREAM";
|
|
58
|
-
return "UNKNOWN";
|
|
59
33
|
};
|
|
60
|
-
var
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
error.detail = detail;
|
|
64
|
-
return error;
|
|
34
|
+
var backoffMs = (retryNumber, random) => {
|
|
35
|
+
const ceiling = Math.min(MAX_BACKOFF_MS, BASE_BACKOFF_MS * 2 ** (retryNumber - 1));
|
|
36
|
+
return ceiling / 2 + random() * ceiling / 2;
|
|
65
37
|
};
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
38
|
+
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
39
|
+
var IMF_FIXDATE = /^[A-Za-z]{3}, (\d{2}) ([A-Za-z]{3}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
40
|
+
var RFC_850 = /^[A-Za-z]{6,9}, (\d{2})-([A-Za-z]{3})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) GMT$/;
|
|
41
|
+
var ASCTIME = /^[A-Za-z]{3} ([A-Za-z]{3}) ([ \d]\d) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/;
|
|
42
|
+
var utcMs = (year, monthName, day, hour, minute, second) => {
|
|
43
|
+
const month = MONTHS.indexOf(monthName.toLowerCase());
|
|
44
|
+
if (month === -1)
|
|
45
|
+
return;
|
|
46
|
+
const at = new Date(Date.UTC(year, month, day, hour, minute, second));
|
|
47
|
+
const isReal = at.getUTCFullYear() === year && at.getUTCMonth() === month && at.getUTCDate() === day && at.getUTCHours() === hour && at.getUTCMinutes() === minute && at.getUTCSeconds() === second;
|
|
48
|
+
return isReal ? at.getTime() : undefined;
|
|
69
49
|
};
|
|
70
|
-
var
|
|
71
|
-
const
|
|
72
|
-
|
|
50
|
+
var parseHttpDate = (value, now) => {
|
|
51
|
+
const imf = IMF_FIXDATE.exec(value);
|
|
52
|
+
if (imf !== null) {
|
|
53
|
+
const [, day, month, year, hour, minute, second] = imf;
|
|
54
|
+
return utcMs(Number(year), month ?? "", Number(day), Number(hour), Number(minute), Number(second));
|
|
55
|
+
}
|
|
56
|
+
const rfc850 = RFC_850.exec(value);
|
|
57
|
+
if (rfc850 !== null) {
|
|
58
|
+
const [, day, month, shortYear, hour, minute, second] = rfc850;
|
|
59
|
+
let year = 2000 + Number(shortYear);
|
|
60
|
+
if (year > new Date(now).getUTCFullYear() + 50)
|
|
61
|
+
year -= 100;
|
|
62
|
+
return utcMs(year, month ?? "", Number(day), Number(hour), Number(minute), Number(second));
|
|
63
|
+
}
|
|
64
|
+
const asctime = ASCTIME.exec(value);
|
|
65
|
+
if (asctime !== null) {
|
|
66
|
+
const [, month, day, hour, minute, second, year] = asctime;
|
|
67
|
+
return utcMs(Number(year), month ?? "", Number(day), Number(hour), Number(minute), Number(second));
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
73
70
|
};
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
...isClientError && isGenericFailure && { message: MESSAGE_WRITE_FAILED_GENERICALLY },
|
|
83
|
-
outcome: isRejectedLocally || isRejectedBySgp ? "not_applied" : "unknown"
|
|
84
|
-
};
|
|
71
|
+
var parseRetryAfter = (value, now) => {
|
|
72
|
+
if (value === null)
|
|
73
|
+
return;
|
|
74
|
+
const trimmed = value.trim();
|
|
75
|
+
if (/^\d+$/.test(trimmed))
|
|
76
|
+
return Number(trimmed) * 1000;
|
|
77
|
+
const at = parseHttpDate(trimmed, now);
|
|
78
|
+
return at === undefined ? undefined : Math.max(0, at - now);
|
|
85
79
|
};
|
|
86
80
|
|
|
87
|
-
// src/
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
var valueAt = (input, path) => {
|
|
109
|
-
let current = input;
|
|
110
|
-
for (const segment of path) {
|
|
111
|
-
if (typeof current !== "object" || current === null)
|
|
112
|
-
return;
|
|
113
|
-
current = Reflect.get(current, segment);
|
|
81
|
+
// src/config.ts
|
|
82
|
+
var DEFAULT_TIMEOUT_MS = 20000;
|
|
83
|
+
var MAX_TIMEOUT_MS = 2147483647;
|
|
84
|
+
|
|
85
|
+
class InvalidConfigurationError extends Error {
|
|
86
|
+
name = "InvalidConfigurationError";
|
|
87
|
+
}
|
|
88
|
+
var isValidTimeoutMs = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 && value <= MAX_TIMEOUT_MS;
|
|
89
|
+
var isAbortSignalLike = (value) => typeof value === "object" && value !== null && ("aborted" in value) && typeof value.aborted === "boolean" && ("addEventListener" in value) && typeof value.addEventListener === "function" && ("removeEventListener" in value) && typeof value.removeEventListener === "function";
|
|
90
|
+
var isValidMaxRetries = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
91
|
+
var isNonEmptyString = (value) => typeof value === "string" && value.trim() !== "";
|
|
92
|
+
var HOOK_NAMES = ["onRequest", "onResponse", "onError"];
|
|
93
|
+
var resolveOrigin = (baseUrl) => {
|
|
94
|
+
if (!isNonEmptyString(baseUrl))
|
|
95
|
+
throw new InvalidConfigurationError("baseUrl must be a URL");
|
|
96
|
+
let url;
|
|
97
|
+
try {
|
|
98
|
+
url = new URL(baseUrl);
|
|
99
|
+
} catch {
|
|
100
|
+
throw new InvalidConfigurationError("baseUrl must be a valid URL");
|
|
114
101
|
}
|
|
115
|
-
|
|
102
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
103
|
+
throw new InvalidConfigurationError("baseUrl must use http or https");
|
|
104
|
+
}
|
|
105
|
+
if (url.username !== "" || url.password !== "") {
|
|
106
|
+
throw new InvalidConfigurationError("baseUrl must not carry credentials");
|
|
107
|
+
}
|
|
108
|
+
if (url.pathname !== "/" && url.pathname !== "" || url.search !== "" || url.hash !== "") {
|
|
109
|
+
throw new InvalidConfigurationError("baseUrl must be an origin without path, query or hash");
|
|
110
|
+
}
|
|
111
|
+
return url.origin;
|
|
116
112
|
};
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
var resolveConfig = (options, runtime = defaultRuntime) => {
|
|
114
|
+
if (typeof options !== "object" || options === null) {
|
|
115
|
+
throw new InvalidConfigurationError("options must be an object");
|
|
116
|
+
}
|
|
117
|
+
const origin = resolveOrigin(options.baseUrl);
|
|
118
|
+
const { credentials } = options;
|
|
119
|
+
if (typeof credentials !== "object" || credentials === null || credentials.kind !== "token") {
|
|
120
|
+
throw new InvalidConfigurationError('credentials must be { kind: "token", token, app }');
|
|
121
|
+
}
|
|
122
|
+
if (!isNonEmptyString(credentials.token)) {
|
|
123
|
+
throw new InvalidConfigurationError("credentials.token must be a non-empty string");
|
|
124
|
+
}
|
|
125
|
+
if (!isNonEmptyString(credentials.app)) {
|
|
126
|
+
throw new InvalidConfigurationError("credentials.app must be a non-empty string");
|
|
127
|
+
}
|
|
128
|
+
if (options.timeoutMs !== undefined && !isValidTimeoutMs(options.timeoutMs)) {
|
|
129
|
+
throw new InvalidConfigurationError(`timeoutMs must be a positive finite number up to ${MAX_TIMEOUT_MS}`);
|
|
130
|
+
}
|
|
131
|
+
if (options.maxRetries !== undefined && !isValidMaxRetries(options.maxRetries)) {
|
|
132
|
+
throw new InvalidConfigurationError("maxRetries must be a non-negative integer");
|
|
133
|
+
}
|
|
134
|
+
if (options.fetch !== undefined && typeof options.fetch !== "function") {
|
|
135
|
+
throw new InvalidConfigurationError("fetch must be a function");
|
|
136
|
+
}
|
|
137
|
+
const hooks = options.hooks ?? {};
|
|
138
|
+
if (typeof hooks !== "object" || hooks === null) {
|
|
139
|
+
throw new InvalidConfigurationError("hooks must be an object");
|
|
140
|
+
}
|
|
141
|
+
for (const name of HOOK_NAMES) {
|
|
142
|
+
if (hooks[name] !== undefined && typeof hooks[name] !== "function") {
|
|
143
|
+
throw new InvalidConfigurationError(`hooks.${name} must be a function`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return Object.freeze({
|
|
147
|
+
origin,
|
|
148
|
+
credentials: Object.freeze({ kind: "token", token: credentials.token, app: credentials.app }),
|
|
149
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
150
|
+
maxRetries: options.maxRetries ?? 0,
|
|
151
|
+
runtime,
|
|
152
|
+
hooks: Object.freeze({
|
|
153
|
+
onRequest: hooks.onRequest,
|
|
154
|
+
onResponse: hooks.onResponse,
|
|
155
|
+
onError: hooks.onError
|
|
156
|
+
}),
|
|
157
|
+
fetch: options.fetch ?? ((input, init) => fetch(input, init))
|
|
158
|
+
});
|
|
124
159
|
};
|
|
125
160
|
|
|
126
|
-
// src/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
161
|
+
// src/budget.ts
|
|
162
|
+
class BudgetStopped extends Error {
|
|
163
|
+
name = "BudgetStopped";
|
|
164
|
+
}
|
|
165
|
+
var isBudgetStopped = (error) => error instanceof BudgetStopped;
|
|
166
|
+
var startBudget = (timeoutMs, callerSignal, now = Date.now) => {
|
|
167
|
+
const deadline = now() + timeoutMs;
|
|
168
|
+
const controller = new AbortController;
|
|
169
|
+
let cause;
|
|
170
|
+
const stop = (why) => {
|
|
171
|
+
cause ??= why;
|
|
172
|
+
controller.abort();
|
|
173
|
+
};
|
|
174
|
+
const onCallerAbort = () => stop("aborted");
|
|
175
|
+
if (callerSignal !== undefined) {
|
|
176
|
+
try {
|
|
177
|
+
if (callerSignal.aborted)
|
|
178
|
+
onCallerAbort();
|
|
179
|
+
else
|
|
180
|
+
callerSignal.addEventListener("abort", onCallerAbort, { once: true });
|
|
181
|
+
} catch {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const timer = setTimeout(() => stop("timeout"), timeoutMs);
|
|
186
|
+
const race = async (work) => {
|
|
187
|
+
let onStop;
|
|
188
|
+
const stopped = new Promise((_resolve, reject) => {
|
|
189
|
+
onStop = () => reject(new BudgetStopped("budget stopped"));
|
|
190
|
+
if (controller.signal.aborted)
|
|
191
|
+
onStop();
|
|
192
|
+
else
|
|
193
|
+
controller.signal.addEventListener("abort", onStop, { once: true });
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
return await Promise.race([work, stopped]);
|
|
197
|
+
} finally {
|
|
198
|
+
if (onStop !== undefined)
|
|
199
|
+
controller.signal.removeEventListener("abort", onStop);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
130
202
|
return {
|
|
131
|
-
|
|
132
|
-
|
|
203
|
+
signal: controller.signal,
|
|
204
|
+
cause: () => cause,
|
|
205
|
+
remainingMs: () => Math.max(0, deadline - now()),
|
|
206
|
+
race,
|
|
207
|
+
dispose: () => {
|
|
208
|
+
clearTimeout(timer);
|
|
209
|
+
try {
|
|
210
|
+
callerSignal?.removeEventListener("abort", onCallerAbort);
|
|
211
|
+
} catch {}
|
|
212
|
+
}
|
|
133
213
|
};
|
|
134
214
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
215
|
+
|
|
216
|
+
// src/guards.ts
|
|
217
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
218
|
+
|
|
219
|
+
// src/classify.ts
|
|
220
|
+
var ROUTE_NOT_ALLOWED_DETAIL = /credenciais.*n[ãa]o foram fornecidas/i;
|
|
221
|
+
var WRONG_CREDENTIALS_DETAIL = /credenciais.*incorretas/i;
|
|
222
|
+
var MESSAGES = {
|
|
223
|
+
INVALID_INPUT: "The input of this call is invalid; nothing was sent.",
|
|
224
|
+
UNAUTHORIZED: "SGP rejected the credentials (token or app).",
|
|
225
|
+
FORBIDDEN: "SGP refused the call for this token.",
|
|
226
|
+
RATE_LIMITED: "SGP is rate limiting this client.",
|
|
227
|
+
ROUTE_NOT_ALLOWED: "The SDK does not allow this route.",
|
|
228
|
+
NOT_FOUND: "SGP route or resource not found.",
|
|
229
|
+
REJECTED: "SGP rejected the request.",
|
|
230
|
+
UPSTREAM: "SGP failed to process the request.",
|
|
231
|
+
NETWORK: "Could not exchange data with SGP.",
|
|
232
|
+
TIMEOUT: "The time budget of the call expired.",
|
|
233
|
+
ABORTED: "The call was aborted by the caller.",
|
|
234
|
+
INVALID_RESPONSE: "SGP answered outside the contract of this method."
|
|
141
235
|
};
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
236
|
+
var projectSgpFields = (body) => {
|
|
237
|
+
if (body.kind !== "json" || !isRecord(body.value))
|
|
238
|
+
return;
|
|
239
|
+
const fields = {};
|
|
240
|
+
for (const key of ["detail", "msg", "error", "errors"]) {
|
|
241
|
+
if (Object.hasOwn(body.value, key))
|
|
242
|
+
fields[key] = body.value[key];
|
|
243
|
+
}
|
|
244
|
+
return Object.keys(fields).length === 0 ? undefined : fields;
|
|
147
245
|
};
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const target = findRemovalTarget(input, issue.path);
|
|
156
|
-
if (target === undefined || isKeyPathOf(target, keyFields)) {
|
|
157
|
-
return schemaMismatch(issues, endpoint);
|
|
246
|
+
var classifyStatus = (status, body) => {
|
|
247
|
+
if (status === 401)
|
|
248
|
+
return { code: "UNAUTHORIZED" };
|
|
249
|
+
if (status === 403) {
|
|
250
|
+
const detail = projectSgpFields(body)?.detail;
|
|
251
|
+
if (typeof detail === "string" && ROUTE_NOT_ALLOWED_DETAIL.test(detail)) {
|
|
252
|
+
return { code: "FORBIDDEN", reason: "TOKEN_ROUTE_NOT_ALLOWED" };
|
|
158
253
|
}
|
|
159
|
-
|
|
254
|
+
if (typeof detail === "string" && WRONG_CREDENTIALS_DETAIL.test(detail)) {
|
|
255
|
+
return { code: "UNAUTHORIZED" };
|
|
256
|
+
}
|
|
257
|
+
return { code: "FORBIDDEN" };
|
|
160
258
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return {
|
|
259
|
+
if (status === 404)
|
|
260
|
+
return { code: "NOT_FOUND" };
|
|
261
|
+
if (status === 429)
|
|
262
|
+
return { code: "RATE_LIMITED" };
|
|
263
|
+
if (status >= 400 && status < 500)
|
|
264
|
+
return { code: "REJECTED" };
|
|
265
|
+
if (status >= 500 && status < 600)
|
|
266
|
+
return { code: "UPSTREAM" };
|
|
267
|
+
return { code: "INVALID_RESPONSE" };
|
|
268
|
+
};
|
|
269
|
+
var buildError = (code, operation, extra = {}) => {
|
|
270
|
+
const error = { code, message: MESSAGES[code], operation };
|
|
271
|
+
if (extra.reason !== undefined)
|
|
272
|
+
error.reason = extra.reason;
|
|
273
|
+
if (extra.effect !== undefined)
|
|
274
|
+
error.effect = extra.effect;
|
|
275
|
+
if (extra.sgp !== undefined)
|
|
276
|
+
error.sgp = extra.sgp;
|
|
277
|
+
if (extra.issues !== undefined)
|
|
278
|
+
error.issues = extra.issues;
|
|
279
|
+
return error;
|
|
170
280
|
};
|
|
171
281
|
|
|
172
|
-
// src/
|
|
173
|
-
var
|
|
282
|
+
// src/effect.ts
|
|
283
|
+
var isNonBlankString = (value) => typeof value === "string" && value.trim() !== "";
|
|
284
|
+
var isClientError = (status) => status >= 400 && status < 500;
|
|
285
|
+
var hasFieldErrorShape = (body) => {
|
|
286
|
+
if (body.kind !== "json" || !isRecord(body.value))
|
|
287
|
+
return false;
|
|
288
|
+
const { errors, error, detail } = body.value;
|
|
289
|
+
if (Array.isArray(errors))
|
|
290
|
+
return false;
|
|
291
|
+
return isRecord(errors) && Object.keys(errors).length > 0 || isNonBlankString(error) || isNonBlankString(detail);
|
|
292
|
+
};
|
|
293
|
+
var errorStringRejection = (status, text, reason) => ({
|
|
294
|
+
status,
|
|
295
|
+
reason,
|
|
296
|
+
matches: (body) => body.kind === "json" && isRecord(body.value) && !("errors" in body.value) && typeof body.value.error === "string" && text.test(body.value.error.trim())
|
|
297
|
+
});
|
|
298
|
+
var singleErrorsEntryRejection = (status, text, reason) => ({
|
|
299
|
+
status,
|
|
300
|
+
reason,
|
|
301
|
+
matches: (body) => {
|
|
302
|
+
if (body.kind !== "json" || !isRecord(body.value))
|
|
303
|
+
return false;
|
|
304
|
+
const { errors } = body.value;
|
|
305
|
+
return Object.keys(body.value).length === 1 && Array.isArray(errors) && errors.length === 1 && typeof errors[0] === "string" && text.test(errors[0].trim());
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
var findKnownRejection = (write, status, body) => isClientError(status) ? write.knownRejections?.find((rejection) => rejection.status === status && rejection.matches(body)) : undefined;
|
|
309
|
+
var effectOfHttpFailure = (status, body, known) => known !== undefined || isClientError(status) && hasFieldErrorShape(body) ? "none" : "unknown";
|
|
310
|
+
|
|
311
|
+
// src/exposure.ts
|
|
312
|
+
var withheld = () => ({ kind: "withheld", reason: "bulk-privacy" });
|
|
313
|
+
var exposedBody = (body, exposure) => exposure !== undefined && (body.kind === "json" || body.kind === "text") ? withheld() : body;
|
|
314
|
+
var isText = (value) => typeof value === "string";
|
|
315
|
+
var isMessage = (value) => isText(value) || Array.isArray(value) && value.every(isText) || isRecord(value) && Object.values(value).every(isText);
|
|
316
|
+
var exposedSgp = (sgp, exposure) => {
|
|
317
|
+
if (exposure === undefined || sgp === undefined)
|
|
318
|
+
return sgp;
|
|
319
|
+
const kept = {};
|
|
320
|
+
for (const key of ["detail", "msg", "error"]) {
|
|
321
|
+
if (isText(sgp[key]))
|
|
322
|
+
kept[key] = sgp[key];
|
|
323
|
+
}
|
|
324
|
+
if (sgp.errors !== undefined && isMessage(sgp.errors))
|
|
325
|
+
kept.errors = sgp.errors;
|
|
326
|
+
return Object.keys(kept).length === 0 ? undefined : kept;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// src/hooks.ts
|
|
330
|
+
var isThenable = (value) => typeof value === "object" && value !== null && ("then" in value) && typeof value.then === "function";
|
|
331
|
+
var createHookRunner = (hooks) => {
|
|
332
|
+
const diagnostics = [];
|
|
333
|
+
const guarded = (hook, callback) => {
|
|
334
|
+
return (metadata) => {
|
|
335
|
+
if (callback === undefined)
|
|
336
|
+
return;
|
|
337
|
+
const copy = Object.freeze({ ...metadata });
|
|
338
|
+
try {
|
|
339
|
+
const returned = callback(copy);
|
|
340
|
+
if (isThenable(returned)) {
|
|
341
|
+
diagnostics.push({ hook, occurrence: metadata.attempt });
|
|
342
|
+
Promise.resolve(returned).then(undefined, () => {
|
|
343
|
+
return;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
} catch {
|
|
347
|
+
diagnostics.push({ hook, occurrence: metadata.attempt });
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
return {
|
|
352
|
+
onRequest: guarded("onRequest", hooks.onRequest),
|
|
353
|
+
onResponse: guarded("onResponse", hooks.onResponse),
|
|
354
|
+
onError: guarded("onError", hooks.onError),
|
|
355
|
+
diagnostics: () => [...diagnostics]
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// src/path.ts
|
|
174
360
|
var PLACEHOLDER = /\{([^{}]+)\}/g;
|
|
175
|
-
var resolvePath = (
|
|
176
|
-
const pathParams = spec.pathParams ?? {};
|
|
361
|
+
var resolvePath = (template, pathParams = {}) => {
|
|
177
362
|
const usedNames = new Set;
|
|
178
363
|
let invalidName;
|
|
179
|
-
const path =
|
|
364
|
+
const path = template.replace(PLACEHOLDER, (_placeholder, name) => {
|
|
180
365
|
usedNames.add(name);
|
|
181
366
|
const value = Object.hasOwn(pathParams, name) ? pathParams[name] : undefined;
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
367
|
+
const valueText = value === undefined ? "" : String(value);
|
|
368
|
+
if (valueText === "" || valueText === "." || valueText === ".." || typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
184
369
|
invalidName ??= name;
|
|
185
370
|
return "";
|
|
186
371
|
}
|
|
187
372
|
try {
|
|
188
|
-
return encodeURIComponent(
|
|
189
|
-
} catch {
|
|
373
|
+
return encodeURIComponent(valueText);
|
|
374
|
+
} catch (cause) {
|
|
375
|
+
if (!(cause instanceof URIError))
|
|
376
|
+
throw cause;
|
|
190
377
|
invalidName ??= name;
|
|
191
378
|
return "";
|
|
192
379
|
}
|
|
193
380
|
});
|
|
194
381
|
if (invalidName !== undefined)
|
|
195
|
-
return { problem: `invalid path param: ${invalidName}` };
|
|
382
|
+
return { ok: false, problem: `invalid path param: ${invalidName}` };
|
|
196
383
|
const unusedName = Object.keys(pathParams).find((name) => !usedNames.has(name));
|
|
197
384
|
if (unusedName !== undefined)
|
|
198
|
-
return { problem: `unexpected path param: ${unusedName}` };
|
|
199
|
-
return { path };
|
|
200
|
-
};
|
|
201
|
-
var definedParams = (params) => {
|
|
202
|
-
const defined = {};
|
|
203
|
-
for (const [key, value] of Object.entries(params ?? {})) {
|
|
204
|
-
if (value !== undefined)
|
|
205
|
-
defined[key] = value;
|
|
206
|
-
}
|
|
207
|
-
return defined;
|
|
385
|
+
return { ok: false, problem: `unexpected path param: ${unusedName}` };
|
|
386
|
+
return { ok: true, path };
|
|
208
387
|
};
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
388
|
+
|
|
389
|
+
// src/request.ts
|
|
390
|
+
var isQueryValue = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
391
|
+
var encodeRequest = (config, definition, path, built = {}) => {
|
|
392
|
+
const { params = {}, files = {}, query: queryParams = {} } = built;
|
|
393
|
+
const { token, app } = config.credentials;
|
|
394
|
+
const url = `${config.origin}${path}`;
|
|
395
|
+
const queryEntries = Object.entries(queryParams).filter(([, value]) => value !== undefined);
|
|
396
|
+
if (definition.method === "GET") {
|
|
397
|
+
if (queryEntries.length > 0)
|
|
398
|
+
return;
|
|
399
|
+
const query = new URLSearchParams;
|
|
400
|
+
for (const [key, value] of Object.entries(params)) {
|
|
401
|
+
if (value === undefined)
|
|
402
|
+
continue;
|
|
403
|
+
if (!isQueryValue(value))
|
|
404
|
+
return;
|
|
405
|
+
query.set(key, String(value));
|
|
406
|
+
}
|
|
407
|
+
query.set("token", token);
|
|
408
|
+
query.set("app", app);
|
|
409
|
+
return { url: `${url}?${query.toString()}` };
|
|
219
410
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
var buildMultipartBody = (config, spec, files) => {
|
|
226
|
-
const form = new FormData;
|
|
227
|
-
for (const [key, value] of Object.entries(definedParams(spec.params))) {
|
|
228
|
-
form.append(key, isPrimitive(value) ? String(value) : JSON.stringify(value));
|
|
411
|
+
const bodyQuery = new URLSearchParams;
|
|
412
|
+
for (const [key, value] of queryEntries) {
|
|
413
|
+
if (!isQueryValue(value) || key === "token" || key === "app")
|
|
414
|
+
return;
|
|
415
|
+
bodyQuery.set(key, String(value));
|
|
229
416
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
417
|
+
const target = bodyQuery.size === 0 ? url : `${url}?${bodyQuery.toString()}`;
|
|
418
|
+
switch (definition.encoding) {
|
|
419
|
+
case "form":
|
|
420
|
+
case "form-files": {
|
|
421
|
+
const form = new FormData;
|
|
422
|
+
for (const [key, value] of Object.entries(params)) {
|
|
423
|
+
if (value === undefined || key === "token" || key === "app")
|
|
424
|
+
continue;
|
|
425
|
+
if (!isQueryValue(value))
|
|
426
|
+
return;
|
|
427
|
+
form.append(key, String(value));
|
|
428
|
+
}
|
|
429
|
+
if (definition.encoding === "form-files") {
|
|
430
|
+
for (const [field, file] of Object.entries(files)) {
|
|
431
|
+
const type = file.contentType ?? (file.data instanceof Blob ? file.data.type : undefined);
|
|
432
|
+
form.append(field, new Blob([file.data], { type }), file.filename);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
form.append("token", token);
|
|
436
|
+
form.append("app", app);
|
|
437
|
+
return { url: target, body: form };
|
|
438
|
+
}
|
|
439
|
+
case "json":
|
|
440
|
+
return {
|
|
441
|
+
url: target,
|
|
442
|
+
headers: { "content-type": "application/json" },
|
|
443
|
+
body: JSON.stringify({ ...params, token, app })
|
|
444
|
+
};
|
|
235
445
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/executor.ts
|
|
449
|
+
var UNAVAILABLE_REASON = {
|
|
450
|
+
TIMEOUT: "timeout",
|
|
451
|
+
ABORTED: "aborted",
|
|
452
|
+
NETWORK: "network"
|
|
453
|
+
};
|
|
454
|
+
var failure = (error, response, attempts) => ({ ok: false, error, response, attempts });
|
|
455
|
+
var effectFor = (definition, effect) => definition.write === undefined ? undefined : effect;
|
|
456
|
+
var refused = (definition, code) => failure(buildError(code, definition.name, { effect: effectFor(definition, "none") }), null, 0);
|
|
457
|
+
var decodeBody = (text) => {
|
|
458
|
+
if (text === "")
|
|
459
|
+
return { kind: "empty" };
|
|
460
|
+
try {
|
|
461
|
+
return { kind: "json", value: JSON.parse(text) };
|
|
462
|
+
} catch (cause) {
|
|
463
|
+
if (!(cause instanceof SyntaxError))
|
|
464
|
+
throw cause;
|
|
465
|
+
return { kind: "text", text };
|
|
248
466
|
}
|
|
249
|
-
return {
|
|
250
|
-
method: spec.method,
|
|
251
|
-
headers: { "content-type": "application/json" },
|
|
252
|
-
body: buildJsonBody(config, spec),
|
|
253
|
-
redirect: "manual",
|
|
254
|
-
signal
|
|
255
|
-
};
|
|
256
467
|
};
|
|
257
|
-
var
|
|
468
|
+
var REDACTED = "<redacted>";
|
|
469
|
+
var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
470
|
+
var MIN_REDACTED_VALUE_LENGTH = 8;
|
|
471
|
+
var credentialValues = ({ token, app }) => {
|
|
472
|
+
const values = [...new Set([token, app, encodeURIComponent(token), encodeURIComponent(app)])].filter((value) => value.length >= MIN_REDACTED_VALUE_LENGTH).sort((first, second) => second.length - first.length);
|
|
473
|
+
return values.length === 0 ? undefined : new RegExp(values.map(escapeRegExp).join("|"), "g");
|
|
474
|
+
};
|
|
475
|
+
var CREDENTIAL_PARAMETER = /([?&;#](?:token|app)=)[^&;#>,\s"]*/gi;
|
|
476
|
+
var readHeaders = (headers, values) => {
|
|
477
|
+
const captured = {};
|
|
478
|
+
headers.forEach((value, name) => {
|
|
479
|
+
const byParameter = value.replace(CREDENTIAL_PARAMETER, `$1${REDACTED}`);
|
|
480
|
+
captured[name] = values === undefined ? byParameter : byParameter.replace(values, REDACTED);
|
|
481
|
+
});
|
|
482
|
+
return captured;
|
|
483
|
+
};
|
|
484
|
+
var ignore = () => {
|
|
485
|
+
return;
|
|
486
|
+
};
|
|
487
|
+
var discardLateResponse = (pending) => {
|
|
488
|
+
pending.then((late) => late.body?.cancel().catch(ignore), ignore);
|
|
489
|
+
};
|
|
490
|
+
var readBody = async (raw, budget, failureFor) => {
|
|
491
|
+
let text;
|
|
258
492
|
try {
|
|
259
|
-
|
|
493
|
+
text = await budget.race(raw.text());
|
|
260
494
|
} catch {
|
|
261
|
-
return {
|
|
495
|
+
return { ok: false, failure: failureFor() };
|
|
262
496
|
}
|
|
497
|
+
return { ok: true, body: decodeBody(text) };
|
|
263
498
|
};
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
if ("problem" in resolved)
|
|
267
|
-
return rejectedLocally(resolved.problem, spec.path);
|
|
268
|
-
const structuredName = spec.method === "GET" ? Object.entries(definedParams(spec.params)).find(([, value]) => !isPrimitive(value))?.[0] : undefined;
|
|
269
|
-
if (structuredName !== undefined) {
|
|
270
|
-
return rejectedLocally(`structured value in GET param: ${structuredName}`, spec.path);
|
|
271
|
-
}
|
|
272
|
-
const { path } = resolved;
|
|
273
|
-
const fetchImpl = config.fetch ?? fetch;
|
|
274
|
-
const signal = AbortSignal.timeout(config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
275
|
-
let status;
|
|
276
|
-
let text;
|
|
499
|
+
var forDecoding = (body) => body.kind === "json" ? { kind: "json", value: structuredClone(body.value) } : body;
|
|
500
|
+
var snapshotOf = (input) => {
|
|
277
501
|
try {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
text = await response.text();
|
|
282
|
-
} catch (cause) {
|
|
283
|
-
return { ok: false, error: mapFetchFailure(cause, spec.path) };
|
|
502
|
+
return { ok: true, value: structuredClone(input) };
|
|
503
|
+
} catch {
|
|
504
|
+
return { ok: false };
|
|
284
505
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
506
|
+
};
|
|
507
|
+
var settingsOf = (options) => {
|
|
508
|
+
try {
|
|
509
|
+
if (!isRecord(options))
|
|
510
|
+
return;
|
|
511
|
+
const { timeoutMs, maxRetries, abortSignal } = options;
|
|
512
|
+
if (timeoutMs !== undefined && !isValidTimeoutMs(timeoutMs))
|
|
513
|
+
return;
|
|
514
|
+
if (maxRetries !== undefined && !isValidMaxRetries(maxRetries))
|
|
515
|
+
return;
|
|
516
|
+
if (abortSignal === undefined) {
|
|
517
|
+
return { timeoutMs, maxRetries, abortSignal, isAborted: false };
|
|
518
|
+
}
|
|
519
|
+
if (!isAbortSignalLike(abortSignal))
|
|
520
|
+
return;
|
|
521
|
+
return { timeoutMs, maxRetries, abortSignal, isAborted: abortSignal.aborted };
|
|
522
|
+
} catch {
|
|
523
|
+
return;
|
|
292
524
|
}
|
|
293
|
-
const parsed = parseJson(text);
|
|
294
|
-
const body = parsed.isJson ? parsed.value : undefined;
|
|
295
|
-
return {
|
|
296
|
-
ok: false,
|
|
297
|
-
error: mapHttpFailure(status, body, spec.path),
|
|
298
|
-
hasErrorList: hasErrorList(body)
|
|
299
|
-
};
|
|
300
525
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
526
|
+
var execute = async (config, definition, input, options = {}) => {
|
|
527
|
+
const { name: operation } = definition;
|
|
528
|
+
const declared = definition;
|
|
529
|
+
if (declared.write !== undefined && declared.repeatable === true) {
|
|
530
|
+
throw new Error(`${operation}: a write can never be repeatable`);
|
|
531
|
+
}
|
|
532
|
+
const settings = settingsOf(options);
|
|
533
|
+
if (settings === undefined)
|
|
534
|
+
return refused(definition, "INVALID_INPUT");
|
|
535
|
+
const snapshot = snapshotOf(input);
|
|
536
|
+
if (!snapshot.ok)
|
|
537
|
+
return refused(definition, "INVALID_INPUT");
|
|
538
|
+
const built = definition.buildRequest(snapshot.value);
|
|
539
|
+
if (!built.ok)
|
|
540
|
+
return refused(definition, "INVALID_INPUT");
|
|
541
|
+
const resolved = resolvePath(definition.pathTemplate, built.pathParams);
|
|
542
|
+
if (!resolved.ok)
|
|
543
|
+
return refused(definition, "INVALID_INPUT");
|
|
544
|
+
const request = encodeRequest(config, definition, resolved.path, built);
|
|
545
|
+
if (request === undefined)
|
|
546
|
+
return refused(definition, "INVALID_INPUT");
|
|
547
|
+
if (settings.isAborted)
|
|
548
|
+
return refused(definition, "ABORTED");
|
|
549
|
+
const hooks = createHookRunner(config.hooks);
|
|
550
|
+
const callId = crypto.randomUUID();
|
|
551
|
+
const maxRetries = definition.repeatable === true ? settings.maxRetries ?? config.maxRetries : 0;
|
|
552
|
+
const { runtime } = config;
|
|
553
|
+
const secrets = credentialValues(config.credentials);
|
|
554
|
+
const budget = startBudget(settings.timeoutMs ?? config.timeoutMs, settings.abortSignal, runtime.now);
|
|
555
|
+
if (budget === undefined)
|
|
556
|
+
return refused(definition, "INVALID_INPUT");
|
|
557
|
+
try {
|
|
558
|
+
const transportFailure = () => {
|
|
559
|
+
const cause = budget.cause();
|
|
560
|
+
if (cause === "timeout")
|
|
561
|
+
return "TIMEOUT";
|
|
562
|
+
return cause === "aborted" ? "ABORTED" : "NETWORK";
|
|
563
|
+
};
|
|
564
|
+
const send = async (number2, metadata, startedAt) => {
|
|
565
|
+
hooks.onRequest(metadata);
|
|
566
|
+
const init = {
|
|
567
|
+
method: definition.method,
|
|
568
|
+
headers: request.headers,
|
|
569
|
+
body: request.body,
|
|
570
|
+
redirect: "manual",
|
|
571
|
+
signal: budget.signal
|
|
572
|
+
};
|
|
573
|
+
let raw;
|
|
574
|
+
let pending;
|
|
575
|
+
try {
|
|
576
|
+
pending = config.fetch(request.url, init);
|
|
577
|
+
raw = await budget.race(pending);
|
|
578
|
+
} catch {
|
|
579
|
+
const code = transportFailure();
|
|
580
|
+
if (code !== "NETWORK" && pending !== undefined)
|
|
581
|
+
discardLateResponse(pending);
|
|
582
|
+
const effect = effectFor(definition, "unknown");
|
|
583
|
+
return failure(buildError(code, operation, { effect }), null, number2);
|
|
584
|
+
}
|
|
585
|
+
hooks.onResponse({
|
|
586
|
+
...metadata,
|
|
587
|
+
status: raw.status,
|
|
588
|
+
durationMs: performance.now() - startedAt
|
|
589
|
+
});
|
|
590
|
+
const headers = readHeaders(raw.headers, secrets);
|
|
591
|
+
const read = await readBody(raw, budget, transportFailure);
|
|
592
|
+
const body = read.ok ? read.body : { kind: "unavailable", reason: UNAVAILABLE_REASON[read.failure] };
|
|
593
|
+
const { exposure } = definition;
|
|
594
|
+
const response = {
|
|
595
|
+
status: raw.status,
|
|
596
|
+
headers,
|
|
597
|
+
body: exposedBody(body, exposure)
|
|
598
|
+
};
|
|
599
|
+
if (response.status < 200 || response.status >= 300) {
|
|
600
|
+
const { code, reason } = classifyStatus(response.status, body);
|
|
601
|
+
const sgp = exposedSgp(projectSgpFields(body), exposure);
|
|
602
|
+
const known = definition.write && findKnownRejection(definition.write, response.status, body);
|
|
603
|
+
const effect = effectFor(definition, definition.write?.effectUnknownAfterSend === true ? "unknown" : effectOfHttpFailure(response.status, body, known));
|
|
604
|
+
const error2 = buildError(code, operation, { reason: known?.reason ?? reason, sgp, effect });
|
|
605
|
+
return failure(error2, response, number2);
|
|
606
|
+
}
|
|
607
|
+
const unknownEffect = effectFor(definition, "unknown");
|
|
608
|
+
if (!read.ok) {
|
|
609
|
+
const error2 = buildError(read.failure, operation, { effect: unknownEffect });
|
|
610
|
+
return failure(error2, response, number2);
|
|
611
|
+
}
|
|
612
|
+
const refusal = definition.detectRefusal?.(body);
|
|
613
|
+
if (refusal !== undefined) {
|
|
614
|
+
const sgp = exposedSgp(projectSgpFields(body), exposure);
|
|
615
|
+
const error2 = buildError("REJECTED", operation, {
|
|
616
|
+
reason: refusal.reason,
|
|
617
|
+
sgp,
|
|
618
|
+
effect: unknownEffect
|
|
619
|
+
});
|
|
620
|
+
return failure(error2, response, number2);
|
|
621
|
+
}
|
|
622
|
+
const decoded = definition.decode(forDecoding(body));
|
|
623
|
+
if (decoded.ok) {
|
|
624
|
+
const { warnings } = decoded;
|
|
625
|
+
const success = { ok: true, data: decoded.data, response, attempts: number2 };
|
|
626
|
+
return warnings === undefined || warnings.length === 0 ? success : { ...success, warnings };
|
|
627
|
+
}
|
|
628
|
+
const error = buildError("INVALID_RESPONSE", operation, {
|
|
629
|
+
issues: decoded.issues,
|
|
630
|
+
effect: unknownEffect
|
|
631
|
+
});
|
|
632
|
+
return failure(error, response, number2);
|
|
327
633
|
};
|
|
634
|
+
const attempt = async (number2) => {
|
|
635
|
+
const metadata = {
|
|
636
|
+
callId,
|
|
637
|
+
attempt: number2,
|
|
638
|
+
operation,
|
|
639
|
+
method: definition.method,
|
|
640
|
+
...definition.omitPathFromHooks !== true && { pathTemplate: definition.pathTemplate }
|
|
641
|
+
};
|
|
642
|
+
const startedAt = performance.now();
|
|
643
|
+
const result = await send(number2, metadata, startedAt);
|
|
644
|
+
if (!result.ok) {
|
|
645
|
+
hooks.onError({
|
|
646
|
+
...metadata,
|
|
647
|
+
code: result.error.code,
|
|
648
|
+
...result.response !== null && { status: result.response.status },
|
|
649
|
+
durationMs: performance.now() - startedAt
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
return result;
|
|
653
|
+
};
|
|
654
|
+
const nextWait = (failed, number2) => {
|
|
655
|
+
if (number2 > maxRetries || budget.cause() !== undefined || !isTransientFailure(failed)) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const retryAfter = parseRetryAfter(failed.response === null ? null : failed.response.headers["retry-after"] ?? null, runtime.now());
|
|
659
|
+
const wait = Math.max(backoffMs(number2, runtime.random), retryAfter ?? 0);
|
|
660
|
+
return wait < budget.remainingMs() ? wait : undefined;
|
|
661
|
+
};
|
|
662
|
+
const sleepOrStop = async (ms) => {
|
|
663
|
+
try {
|
|
664
|
+
await budget.race(runtime.sleep(ms, budget.signal));
|
|
665
|
+
} catch (error) {
|
|
666
|
+
if (!isBudgetStopped(error))
|
|
667
|
+
throw error;
|
|
668
|
+
}
|
|
669
|
+
return budget.cause();
|
|
670
|
+
};
|
|
671
|
+
let number = 1;
|
|
672
|
+
let outcome = await attempt(number);
|
|
673
|
+
while (!outcome.ok) {
|
|
674
|
+
const wait = nextWait(outcome, number);
|
|
675
|
+
if (wait === undefined)
|
|
676
|
+
break;
|
|
677
|
+
const stoppedBy = await sleepOrStop(wait);
|
|
678
|
+
if (stoppedBy === "aborted") {
|
|
679
|
+
const effect = effectFor(definition, "unknown");
|
|
680
|
+
outcome = failure(buildError("ABORTED", operation, { effect }), outcome.response, number);
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
if (stoppedBy === "timeout")
|
|
684
|
+
break;
|
|
685
|
+
number += 1;
|
|
686
|
+
outcome = await attempt(number);
|
|
687
|
+
}
|
|
688
|
+
const diagnostics = hooks.diagnostics();
|
|
689
|
+
return diagnostics.length === 0 ? outcome : { ...outcome, diagnostics };
|
|
690
|
+
} finally {
|
|
691
|
+
budget.dispose();
|
|
328
692
|
}
|
|
329
|
-
const parsed = parseResponse(def.schema, def.keyFields, raw.body, def.path);
|
|
330
|
-
if (parsed.success)
|
|
331
|
-
return parsed;
|
|
332
|
-
return {
|
|
333
|
-
success: false,
|
|
334
|
-
error: unconfirmedWrite(raw.status, def.path, readSgpDetail(raw.body) ?? parsed.error.detail)
|
|
335
|
-
};
|
|
336
693
|
};
|
|
337
694
|
|
|
338
|
-
// src/
|
|
695
|
+
// src/operations/catalogs-list-billing-profiles.ts
|
|
339
696
|
import { z } from "zod";
|
|
340
697
|
|
|
341
|
-
// src/
|
|
342
|
-
var
|
|
343
|
-
|
|
344
|
-
for (const
|
|
345
|
-
if (
|
|
346
|
-
|
|
698
|
+
// src/tolerant.ts
|
|
699
|
+
var valueAt = (input, path) => {
|
|
700
|
+
let current = input;
|
|
701
|
+
for (const segment of path) {
|
|
702
|
+
if (typeof current !== "object" || current === null)
|
|
703
|
+
return;
|
|
704
|
+
current = Reflect.get(current, segment);
|
|
347
705
|
}
|
|
348
|
-
return
|
|
706
|
+
return current;
|
|
349
707
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
carne: 3,
|
|
356
|
-
cobrancaRecorrente: 4,
|
|
357
|
-
pix: 6
|
|
708
|
+
var typeNameAt = (input, path) => {
|
|
709
|
+
const value = valueAt(input, path);
|
|
710
|
+
if (value === null)
|
|
711
|
+
return "null";
|
|
712
|
+
return Array.isArray(value) ? "array" : typeof value;
|
|
358
713
|
};
|
|
359
|
-
var
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
var
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
714
|
+
var formatPath = (path) => path.reduce((joined, segment) => {
|
|
715
|
+
if (typeof segment === "number")
|
|
716
|
+
return `${joined}[${segment}]`;
|
|
717
|
+
return joined === "" ? String(segment) : `${joined}.${String(segment)}`;
|
|
718
|
+
}, "");
|
|
719
|
+
var segmentsOf = (path) => path.match(/\[\]|[^.[\]]+/g) ?? [];
|
|
720
|
+
var isInvariant = (path, invariants) => invariants.some((invariant) => {
|
|
721
|
+
const segments = segmentsOf(invariant);
|
|
722
|
+
return path.length === segments.length && path.every((segment, index) => typeof segment === "number" ? segments[index] === "[]" : segments[index] === segment);
|
|
723
|
+
});
|
|
724
|
+
var hasInvariantInElements = (path, invariants) => invariants.some((invariant) => {
|
|
725
|
+
const segments = segmentsOf(invariant);
|
|
726
|
+
return segments.length > path.length && segments[path.length] === "[]" && path.every((segment, index) => typeof segment === "number" ? segments[index] === "[]" : segments[index] === segment);
|
|
727
|
+
});
|
|
728
|
+
var unionTypeNames = (issue) => {
|
|
729
|
+
if (issue.code !== "invalid_union")
|
|
730
|
+
return;
|
|
731
|
+
const names = new Set;
|
|
732
|
+
for (const optionIssues of issue.errors) {
|
|
733
|
+
const first = optionIssues[0];
|
|
734
|
+
if (first?.code !== "invalid_type")
|
|
735
|
+
return;
|
|
736
|
+
names.add(first.expected);
|
|
737
|
+
}
|
|
738
|
+
return names.size === 0 ? undefined : [...names].sort().join(" | ");
|
|
739
|
+
};
|
|
740
|
+
var expectedTypeOf = (issue) => issue.code === "invalid_type" ? issue.expected : unionTypeNames(issue) ?? "valid value";
|
|
741
|
+
var findRemovalTarget = (input, path) => {
|
|
742
|
+
for (let end = path.length;end > 0; end -= 1) {
|
|
743
|
+
if (isRecord(valueAt(input, path.slice(0, end - 1))))
|
|
744
|
+
return path.slice(0, end);
|
|
745
|
+
}
|
|
746
|
+
return;
|
|
747
|
+
};
|
|
748
|
+
var removeAt = (root, path) => {
|
|
749
|
+
const parent = valueAt(root, path.slice(0, -1));
|
|
750
|
+
const key = path.at(-1);
|
|
751
|
+
if (isRecord(parent) && key !== undefined)
|
|
752
|
+
Reflect.deleteProperty(parent, key);
|
|
753
|
+
};
|
|
754
|
+
var issuePaths = (issues) => [
|
|
755
|
+
...new Set(issues.map((issue) => issue.path.join(".") || "(root)"))
|
|
756
|
+
];
|
|
757
|
+
var tolerantDecoder = (schema, invariants) => (body) => {
|
|
758
|
+
if (body.kind !== "json")
|
|
759
|
+
return { ok: false, issues: ["(body)"] };
|
|
760
|
+
const input = body.value;
|
|
761
|
+
const first = schema.safeParse(input);
|
|
762
|
+
if (first.success)
|
|
763
|
+
return { ok: true, data: first.data };
|
|
764
|
+
const pruned = structuredClone(input);
|
|
765
|
+
const droppedPaths = [];
|
|
766
|
+
for (const issue of first.error.issues) {
|
|
767
|
+
const target = findRemovalTarget(input, issue.path);
|
|
768
|
+
const isElementOfInvariantArray = target !== undefined && target.length < issue.path.length && hasInvariantInElements(target, invariants);
|
|
769
|
+
if (target === undefined || isInvariant(target, invariants) || isElementOfInvariantArray) {
|
|
770
|
+
return { ok: false, issues: issuePaths(first.error.issues) };
|
|
771
|
+
}
|
|
772
|
+
removeAt(pruned, target);
|
|
773
|
+
droppedPaths.push(formatPath(target));
|
|
774
|
+
}
|
|
775
|
+
const second = schema.safeParse(pruned);
|
|
776
|
+
if (!second.success)
|
|
777
|
+
return { ok: false, issues: issuePaths(second.error.issues) };
|
|
778
|
+
const warnings = first.error.issues.map((issue, index) => ({
|
|
779
|
+
path: formatPath(issue.path),
|
|
780
|
+
dropped: droppedPaths[index] ?? formatPath(issue.path),
|
|
781
|
+
expected: expectedTypeOf(issue),
|
|
782
|
+
received: typeNameAt(input, issue.path)
|
|
783
|
+
}));
|
|
784
|
+
return { ok: true, data: second.data, warnings };
|
|
384
785
|
};
|
|
385
786
|
|
|
386
|
-
// src/
|
|
787
|
+
// src/operations/catalogs-list-billing-profiles.ts
|
|
788
|
+
var billingProfileSchema = z.looseObject({
|
|
789
|
+
id: z.number(),
|
|
790
|
+
descricao: z.string().optional().nullable(),
|
|
791
|
+
codigo_banco: z.string().optional().nullable()
|
|
792
|
+
});
|
|
793
|
+
var billingProfilesSchema = z.array(billingProfileSchema);
|
|
794
|
+
var billingProfilesInvariants = ["[].id"];
|
|
795
|
+
var buildRequest = () => ({ ok: true });
|
|
796
|
+
var catalogsListBillingProfilesSensitivity = { input: [], output: [] };
|
|
797
|
+
var catalogsListBillingProfiles = {
|
|
798
|
+
name: "catalogs.listBillingProfiles",
|
|
799
|
+
method: "GET",
|
|
800
|
+
pathTemplate: "/api/ura/portador/",
|
|
801
|
+
encoding: "json",
|
|
802
|
+
buildRequest,
|
|
803
|
+
repeatable: true,
|
|
804
|
+
decode: tolerantDecoder(billingProfilesSchema, billingProfilesInvariants),
|
|
805
|
+
sensitivity: catalogsListBillingProfilesSensitivity
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
// src/operations/catalogs-list-nas.ts
|
|
387
809
|
import { z as z2 } from "zod";
|
|
388
|
-
var
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
var
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
secretKeys:
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
kind: "write",
|
|
810
|
+
var nasPopSchema = z2.looseObject({
|
|
811
|
+
id: z2.number().optional().nullable(),
|
|
812
|
+
cidade: z2.string().optional().nullable(),
|
|
813
|
+
uf: z2.string().optional().nullable(),
|
|
814
|
+
codigo_ibge: z2.number().optional().nullable(),
|
|
815
|
+
ativo: z2.boolean().optional().nullable()
|
|
816
|
+
});
|
|
817
|
+
var nasSchema = z2.looseObject({
|
|
818
|
+
id: z2.number(),
|
|
819
|
+
descricao: z2.string().optional().nullable(),
|
|
820
|
+
identificador: z2.string().optional().nullable(),
|
|
821
|
+
endereco_ip: z2.string().optional().nullable(),
|
|
822
|
+
ativo: z2.boolean().optional().nullable(),
|
|
823
|
+
pops: z2.array(nasPopSchema).optional().nullable()
|
|
824
|
+
});
|
|
825
|
+
var nasListSchema = z2.array(nasSchema);
|
|
826
|
+
var nasInvariants = ["[].id"];
|
|
827
|
+
var buildRequest2 = () => ({ ok: true });
|
|
828
|
+
var catalogsListNasSensitivity = {
|
|
829
|
+
input: [],
|
|
830
|
+
output: [{ path: "[]", secretKeys: ["endereco_ip"], personalKeys: [] }]
|
|
831
|
+
};
|
|
832
|
+
var catalogsListNas = {
|
|
833
|
+
name: "catalogs.listNas",
|
|
413
834
|
method: "POST",
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
835
|
+
pathTemplate: "/api/ura/nas/list/",
|
|
836
|
+
encoding: "json",
|
|
837
|
+
buildRequest: buildRequest2,
|
|
838
|
+
repeatable: true,
|
|
839
|
+
decode: tolerantDecoder(nasListSchema, nasInvariants),
|
|
840
|
+
sensitivity: catalogsListNasSensitivity
|
|
420
841
|
};
|
|
421
842
|
|
|
422
|
-
// src/
|
|
843
|
+
// src/operations/catalogs-list-pops.ts
|
|
423
844
|
import { z as z3 } from "zod";
|
|
424
|
-
var
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
reprovado: 3,
|
|
428
|
-
aguardandoContato: 4,
|
|
429
|
-
tentandoContato: 5,
|
|
430
|
-
contratoRealizadoNoSgp: 6,
|
|
431
|
-
inviabilidadeTecnica: 7,
|
|
432
|
-
contratoEmProspeccao: 8,
|
|
433
|
-
reprovadoSpcSerasa: 9,
|
|
434
|
-
analiseViabilidadeTecnica: 10
|
|
435
|
-
};
|
|
436
|
-
var updateCustomerStatusSchema = z3.object({
|
|
437
|
-
cliente_id: z3.number(),
|
|
438
|
-
message: z3.string().optional().nullable(),
|
|
439
|
-
novo_status: z3.object({
|
|
440
|
-
codigo: z3.number(),
|
|
441
|
-
descricao: z3.string().optional().nullable()
|
|
442
|
-
})
|
|
845
|
+
var popSchema = z3.looseObject({
|
|
846
|
+
id: z3.number(),
|
|
847
|
+
pop: z3.string().optional().nullable()
|
|
443
848
|
});
|
|
444
|
-
var
|
|
445
|
-
var
|
|
446
|
-
var
|
|
447
|
-
var
|
|
448
|
-
var
|
|
449
|
-
|
|
849
|
+
var popsSchema = z3.array(popSchema);
|
|
850
|
+
var popsInvariants = ["[].id"];
|
|
851
|
+
var buildRequest3 = () => ({ ok: true });
|
|
852
|
+
var catalogsListPopsSensitivity = { input: [], output: [] };
|
|
853
|
+
var catalogsListPops = {
|
|
854
|
+
name: "catalogs.listPops",
|
|
450
855
|
method: "POST",
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
856
|
+
pathTemplate: "/api/ura/pops/",
|
|
857
|
+
encoding: "json",
|
|
858
|
+
buildRequest: buildRequest3,
|
|
859
|
+
repeatable: true,
|
|
860
|
+
decode: tolerantDecoder(popsSchema, popsInvariants),
|
|
861
|
+
sensitivity: catalogsListPopsSensitivity
|
|
457
862
|
};
|
|
458
863
|
|
|
459
|
-
// src/
|
|
864
|
+
// src/operations/contracts-list.ts
|
|
865
|
+
import { z as z5 } from "zod";
|
|
866
|
+
|
|
867
|
+
// src/ids.ts
|
|
460
868
|
import { z as z4 } from "zod";
|
|
461
|
-
var
|
|
462
|
-
id: z4.number(),
|
|
463
|
-
codigo: z4.number(),
|
|
464
|
-
descricao: z4.string(),
|
|
465
|
-
ativo: z4.boolean(),
|
|
466
|
-
classificacoes: z4.array(z4.object({})).optional().nullable(),
|
|
467
|
-
classificacoes_obrigatorio: z4.boolean().optional().nullable(),
|
|
468
|
-
setores: z4.array(z4.object({})).optional().nullable()
|
|
469
|
-
});
|
|
470
|
-
var listOccurrenceReasonsSchema = z4.array(occurrenceReasonSchema);
|
|
471
|
-
var listOccurrenceReasonsKeyFields = [
|
|
472
|
-
"[].id",
|
|
473
|
-
"[].codigo",
|
|
474
|
-
"[].descricao",
|
|
475
|
-
"[].ativo"
|
|
476
|
-
];
|
|
477
|
-
var occurrenceReasonItemPath = "[]";
|
|
478
|
-
var occurrenceReasonSecretKeys = [];
|
|
479
|
-
var occurrenceReasonPersonalKeys = [];
|
|
480
|
-
var listOccurrenceReasonsDefinition = {
|
|
481
|
-
method: "GET",
|
|
482
|
-
path: "/api/os/ocorrencia/motivo/list/",
|
|
483
|
-
schema: listOccurrenceReasonsSchema,
|
|
484
|
-
keyFields: listOccurrenceReasonsKeyFields,
|
|
485
|
-
itemPath: occurrenceReasonItemPath,
|
|
486
|
-
secretKeys: occurrenceReasonSecretKeys,
|
|
487
|
-
personalKeys: occurrenceReasonPersonalKeys
|
|
488
|
-
};
|
|
869
|
+
var customerIdSchema = z4.number().brand();
|
|
489
870
|
|
|
490
|
-
// src/
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
871
|
+
// src/operations/contracts-list.ts
|
|
872
|
+
var contractSummarySchema = z5.looseObject({
|
|
873
|
+
id_contrato: z5.number(),
|
|
874
|
+
id_cliente: customerIdSchema,
|
|
875
|
+
status: z5.string().optional().nullable(),
|
|
876
|
+
pop_id: z5.number().optional().nullable(),
|
|
877
|
+
nome: z5.string().optional().nullable(),
|
|
878
|
+
cpfcnpj: z5.string().optional().nullable(),
|
|
879
|
+
email: z5.string().optional().nullable(),
|
|
880
|
+
telefone: z5.string().optional().nullable(),
|
|
881
|
+
data_status: z5.string().optional().nullable(),
|
|
882
|
+
data_cadastro: z5.string().optional().nullable(),
|
|
883
|
+
motivo_status: z5.string().optional().nullable()
|
|
884
|
+
});
|
|
885
|
+
var contractsSchema = z5.array(contractSummarySchema);
|
|
886
|
+
var contractsInvariants = ["[].id_contrato", "[].id_cliente"];
|
|
887
|
+
var contractsListInputSchema = z5.strictObject({
|
|
888
|
+
contrato: z5.number().int().optional(),
|
|
889
|
+
plano: z5.number().int().optional(),
|
|
890
|
+
tipo: z5.string().optional(),
|
|
891
|
+
status: z5.number().int().optional(),
|
|
892
|
+
exibir_endereco: z5.boolean().optional()
|
|
893
|
+
});
|
|
894
|
+
var buildRequest4 = (input) => {
|
|
895
|
+
const parsed = contractsListInputSchema.safeParse(input);
|
|
896
|
+
if (!parsed.success)
|
|
897
|
+
return { ok: false, problem: "invalid contracts.list input" };
|
|
898
|
+
return { ok: true, params: parsed.data };
|
|
899
|
+
};
|
|
900
|
+
var contractsListSensitivity = {
|
|
901
|
+
input: [],
|
|
902
|
+
output: [
|
|
903
|
+
{
|
|
904
|
+
path: "[]",
|
|
905
|
+
secretKeys: [],
|
|
906
|
+
personalKeys: ["nome", "cpfcnpj", "email", "telefone", "motivo_status"]
|
|
907
|
+
}
|
|
908
|
+
]
|
|
909
|
+
};
|
|
910
|
+
var contractsList = {
|
|
911
|
+
name: "contracts.list",
|
|
912
|
+
method: "POST",
|
|
913
|
+
pathTemplate: "/api/ura/listacontrato/",
|
|
914
|
+
encoding: "json",
|
|
915
|
+
buildRequest: buildRequest4,
|
|
916
|
+
repeatable: true,
|
|
917
|
+
decode: tolerantDecoder(contractsSchema, contractsInvariants),
|
|
918
|
+
sensitivity: contractsListSensitivity
|
|
520
919
|
};
|
|
521
920
|
|
|
522
|
-
// src/
|
|
921
|
+
// src/operations/contracts-list-status-reasons.ts
|
|
523
922
|
import { z as z6 } from "zod";
|
|
524
|
-
var
|
|
923
|
+
var statusReasonSchema = z6.looseObject({
|
|
525
924
|
id: z6.number(),
|
|
526
|
-
|
|
527
|
-
});
|
|
528
|
-
var
|
|
529
|
-
var
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
var
|
|
533
|
-
|
|
925
|
+
motivo: z6.string().optional().nullable()
|
|
926
|
+
});
|
|
927
|
+
var statusReasonsSchema = z6.array(statusReasonSchema);
|
|
928
|
+
var statusReasonsInvariants = ["[].id"];
|
|
929
|
+
var buildRequest5 = () => ({ ok: true });
|
|
930
|
+
var contractsListStatusReasonsSensitivity = { input: [], output: [] };
|
|
931
|
+
var contractsListStatusReasons = {
|
|
932
|
+
name: "contracts.listStatusReasons",
|
|
534
933
|
method: "POST",
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
934
|
+
pathTemplate: "/api/ura/contrato/status/motivos/",
|
|
935
|
+
encoding: "json",
|
|
936
|
+
buildRequest: buildRequest5,
|
|
937
|
+
repeatable: true,
|
|
938
|
+
decode: tolerantDecoder(statusReasonsSchema, statusReasonsInvariants),
|
|
939
|
+
sensitivity: contractsListStatusReasonsSensitivity
|
|
541
940
|
};
|
|
542
941
|
|
|
543
|
-
// src/
|
|
942
|
+
// src/operations/contracts-update.ts
|
|
544
943
|
import { z as z7 } from "zod";
|
|
545
|
-
var
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
var
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
944
|
+
var id = z7.number().int().nonnegative();
|
|
945
|
+
var contractsUpdateInputSchema = z7.strictObject({ contrato: id, forma_cobranca: id });
|
|
946
|
+
var buildRequest6 = (input) => {
|
|
947
|
+
const parsed = contractsUpdateInputSchema.safeParse(input);
|
|
948
|
+
if (!parsed.success)
|
|
949
|
+
return { ok: false, problem: "invalid contracts.update input" };
|
|
950
|
+
return { ok: true, params: parsed.data };
|
|
951
|
+
};
|
|
952
|
+
var contractUpdatedSchema = z7.looseObject({
|
|
953
|
+
resposta: z7.looseObject({
|
|
954
|
+
mensagem: z7.string().optional().nullable(),
|
|
955
|
+
contrato: z7.number(),
|
|
956
|
+
alterados: z7.array(z7.string())
|
|
957
|
+
})
|
|
958
|
+
});
|
|
959
|
+
var contractUpdatedInvariants = ["resposta", "resposta.contrato", "resposta.alterados"];
|
|
960
|
+
var contractsUpdateSensitivity = { input: [], output: [] };
|
|
961
|
+
var contractsUpdate = {
|
|
962
|
+
name: "contracts.update",
|
|
557
963
|
method: "POST",
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
964
|
+
pathTemplate: "/api/ura/contrato/edit/",
|
|
965
|
+
encoding: "json",
|
|
966
|
+
repeatable: false,
|
|
967
|
+
write: {},
|
|
968
|
+
buildRequest: buildRequest6,
|
|
969
|
+
decode: tolerantDecoder(contractUpdatedSchema, contractUpdatedInvariants),
|
|
970
|
+
sensitivity: contractsUpdateSensitivity
|
|
564
971
|
};
|
|
565
972
|
|
|
566
|
-
// src/
|
|
973
|
+
// src/operations/contracts-update-status.ts
|
|
567
974
|
import { z as z8 } from "zod";
|
|
568
|
-
var
|
|
569
|
-
var
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
975
|
+
var id2 = z8.number().int().nonnegative();
|
|
976
|
+
var contractsUpdateStatusInputSchema = z8.strictObject({
|
|
977
|
+
contrato: id2,
|
|
978
|
+
status: id2,
|
|
979
|
+
motivo: id2.optional()
|
|
980
|
+
});
|
|
981
|
+
var buildRequest7 = (input) => {
|
|
982
|
+
const parsed = contractsUpdateStatusInputSchema.safeParse(input);
|
|
983
|
+
if (!parsed.success)
|
|
984
|
+
return { ok: false, problem: "invalid contracts.updateStatus input" };
|
|
985
|
+
return { ok: true, params: parsed.data };
|
|
986
|
+
};
|
|
987
|
+
var statusChangedSchema = z8.looseObject({
|
|
988
|
+
resposta: z8.looseObject({
|
|
989
|
+
mensagem: z8.string().optional().nullable(),
|
|
990
|
+
contrato: z8.number(),
|
|
991
|
+
contrato_status: z8.string()
|
|
992
|
+
})
|
|
993
|
+
});
|
|
994
|
+
var statusChangedInvariants = [
|
|
995
|
+
"resposta",
|
|
996
|
+
"resposta.contrato",
|
|
997
|
+
"resposta.contrato_status"
|
|
998
|
+
];
|
|
999
|
+
var STATUS_NOT_CHANGED_TEXT = /^status de contrato não alterado\.?$/i;
|
|
1000
|
+
var statusNotChanged = errorStringRejection(400, STATUS_NOT_CHANGED_TEXT, "STATUS_NOT_CHANGED");
|
|
1001
|
+
var contractsUpdateStatusSensitivity = { input: [], output: [] };
|
|
1002
|
+
var contractsUpdateStatus = {
|
|
1003
|
+
name: "contracts.updateStatus",
|
|
1004
|
+
method: "POST",
|
|
1005
|
+
pathTemplate: "/api/ura/contrato/status/edit/",
|
|
1006
|
+
encoding: "json",
|
|
1007
|
+
repeatable: false,
|
|
1008
|
+
write: { knownRejections: [statusNotChanged] },
|
|
1009
|
+
buildRequest: buildRequest7,
|
|
1010
|
+
decode: tolerantDecoder(statusChangedSchema, statusChangedInvariants),
|
|
1011
|
+
sensitivity: contractsUpdateStatusSensitivity
|
|
582
1012
|
};
|
|
583
1013
|
|
|
584
|
-
// src/
|
|
1014
|
+
// src/operations/coverage-check.ts
|
|
585
1015
|
import { z as z9 } from "zod";
|
|
586
|
-
var
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
var
|
|
1016
|
+
var coverageCheckInputSchema = z9.strictObject({
|
|
1017
|
+
gateway: z9.number().int().positive(),
|
|
1018
|
+
raio: z9.number().nonnegative(),
|
|
1019
|
+
coordenada: z9.string().min(1)
|
|
1020
|
+
});
|
|
1021
|
+
var buildRequest8 = (input) => {
|
|
1022
|
+
const parsed = coverageCheckInputSchema.safeParse(input);
|
|
1023
|
+
if (!parsed.success)
|
|
1024
|
+
return { ok: false, problem: "invalid coverage.check input" };
|
|
1025
|
+
const { gateway, raio, coordenada } = parsed.data;
|
|
1026
|
+
return { ok: true, params: { gateway, raio, coordenada } };
|
|
1027
|
+
};
|
|
1028
|
+
var numberOrText = z9.union([z9.number(), z9.string()]);
|
|
1029
|
+
var ctoSchema = z9.looseObject({
|
|
1030
|
+
lat: numberOrText.optional().nullable(),
|
|
1031
|
+
lng: numberOrText.optional().nullable(),
|
|
1032
|
+
distancia: numberOrText.optional().nullable(),
|
|
1033
|
+
id: numberOrText.optional().nullable(),
|
|
1034
|
+
nome: z9.string().optional().nullable()
|
|
1035
|
+
});
|
|
1036
|
+
var ctoListDecoder = tolerantDecoder(z9.array(ctoSchema), []);
|
|
1037
|
+
var setOwn = (target, key, value) => {
|
|
1038
|
+
Object.defineProperty(target, key, {
|
|
1039
|
+
value,
|
|
1040
|
+
enumerable: true,
|
|
1041
|
+
writable: true,
|
|
1042
|
+
configurable: true
|
|
1043
|
+
});
|
|
1044
|
+
};
|
|
1045
|
+
var failed = (...issues) => ({ ok: false, issues });
|
|
1046
|
+
var decode = (body) => {
|
|
1047
|
+
if (body.kind !== "json")
|
|
1048
|
+
return failed("(body)");
|
|
1049
|
+
const root = body.value;
|
|
1050
|
+
if (!Array.isArray(root))
|
|
1051
|
+
return failed("(root)");
|
|
1052
|
+
const data = [];
|
|
1053
|
+
const warnings = [];
|
|
1054
|
+
const entries = root;
|
|
1055
|
+
for (const [index, entry] of entries.entries()) {
|
|
1056
|
+
if (!isRecord(entry))
|
|
1057
|
+
return failed(String(index));
|
|
1058
|
+
const answers = {};
|
|
1059
|
+
for (const [gateway, answer] of Object.entries(entry)) {
|
|
1060
|
+
if (typeof answer === "string") {
|
|
1061
|
+
setOwn(answers, gateway, answer);
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
const where = `${index}.${gateway}`;
|
|
1065
|
+
if (!Array.isArray(answer))
|
|
1066
|
+
return failed(where);
|
|
1067
|
+
const ctos = ctoListDecoder({ kind: "json", value: structuredClone(answer) });
|
|
1068
|
+
if (!ctos.ok)
|
|
1069
|
+
return failed(...ctos.issues.map((issue) => `${where}.${issue}`));
|
|
1070
|
+
setOwn(answers, gateway, ctos.data);
|
|
1071
|
+
for (const warning of ctos.warnings ?? []) {
|
|
1072
|
+
const prefix = `[${index}].${gateway}`;
|
|
1073
|
+
warnings.push({
|
|
1074
|
+
...warning,
|
|
1075
|
+
path: `${prefix}${warning.path}`,
|
|
1076
|
+
dropped: `${prefix}${warning.dropped}`
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
data.push(answers);
|
|
1081
|
+
}
|
|
1082
|
+
return warnings.length === 0 ? { ok: true, data } : { ok: true, data, warnings };
|
|
1083
|
+
};
|
|
1084
|
+
var coverageCheckSensitivity = {
|
|
1085
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["coordenada"] }],
|
|
1086
|
+
output: []
|
|
1087
|
+
};
|
|
1088
|
+
var coverageCheck = {
|
|
1089
|
+
name: "coverage.check",
|
|
599
1090
|
method: "GET",
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
1091
|
+
pathTemplate: "/api/ura/viabilidadeinstalacao",
|
|
1092
|
+
encoding: "json",
|
|
1093
|
+
buildRequest: buildRequest8,
|
|
1094
|
+
repeatable: true,
|
|
1095
|
+
decode,
|
|
1096
|
+
sensitivity: coverageCheckSensitivity
|
|
606
1097
|
};
|
|
607
1098
|
|
|
608
|
-
// src/
|
|
1099
|
+
// src/operations/crm-contracts-create.ts
|
|
1100
|
+
import { z as z12 } from "zod";
|
|
1101
|
+
|
|
1102
|
+
// src/address.ts
|
|
609
1103
|
import { z as z10 } from "zod";
|
|
610
|
-
var
|
|
611
|
-
z10.
|
|
612
|
-
z10.string().
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
var checkCoverageKeyFields = ["[].*"];
|
|
623
|
-
var coverageItemPath = "[]";
|
|
624
|
-
var coverageSecretKeys = [];
|
|
625
|
-
var coveragePersonalKeys = [];
|
|
626
|
-
var checkCoverageDefinition = {
|
|
627
|
-
method: "GET",
|
|
628
|
-
path: "/api/ura/viabilidadeinstalacao",
|
|
629
|
-
schema: checkCoverageSchema,
|
|
630
|
-
keyFields: checkCoverageKeyFields,
|
|
631
|
-
itemPath: coverageItemPath,
|
|
632
|
-
secretKeys: coverageSecretKeys,
|
|
633
|
-
personalKeys: coveragePersonalKeys
|
|
1104
|
+
var addressShape = {
|
|
1105
|
+
logradouro: z10.string().optional(),
|
|
1106
|
+
numero: z10.union([z10.string(), z10.number()]).optional(),
|
|
1107
|
+
complemento: z10.string().optional(),
|
|
1108
|
+
bairro: z10.string().optional(),
|
|
1109
|
+
cidade: z10.string().optional(),
|
|
1110
|
+
cep: z10.string().optional(),
|
|
1111
|
+
uf: z10.string().optional(),
|
|
1112
|
+
pais: z10.string().optional(),
|
|
1113
|
+
pontoreferencia: z10.string().optional(),
|
|
1114
|
+
map_ll: z10.string().optional(),
|
|
1115
|
+
condominio: z10.union([z10.string(), z10.number()]).optional()
|
|
634
1116
|
};
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
id: z11.number(),
|
|
641
|
-
cliente: z11.number(),
|
|
642
|
-
clientecontrato: z11.number().nullable(),
|
|
643
|
-
anotacao: z11.string(),
|
|
644
|
-
usuario: z11.number().optional().nullable(),
|
|
645
|
-
tipo: z11.number().optional().nullable(),
|
|
646
|
-
alerta_modo: z11.number().optional().nullable(),
|
|
647
|
-
data_cadastro: z11.string().optional().nullable(),
|
|
648
|
-
data_alteracao: z11.string().optional().nullable()
|
|
649
|
-
});
|
|
650
|
-
var listAnnotationsSchema = z11.array(annotationSchema);
|
|
651
|
-
var listAnnotationsKeyFields = [
|
|
652
|
-
"[].id",
|
|
653
|
-
"[].cliente",
|
|
654
|
-
"[].clientecontrato",
|
|
655
|
-
"[].anotacao"
|
|
656
|
-
];
|
|
657
|
-
var annotationItemPath = "[]";
|
|
658
|
-
var annotationSecretKeys = [];
|
|
659
|
-
var annotationPersonalKeys = ["anotacao", "usuario"];
|
|
660
|
-
var validFilter = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
661
|
-
var listAnnotations = async (config, params) => {
|
|
662
|
-
const customer = params?.cliente_id;
|
|
663
|
-
const contract = params?.contrato_id;
|
|
664
|
-
if (customer === undefined && contract === undefined || customer !== undefined && !validFilter(customer) || contract !== undefined && !validFilter(contract)) {
|
|
665
|
-
return {
|
|
666
|
-
success: false,
|
|
667
|
-
error: createError("VALIDATION", 0, PATH, "cliente_id / contrato_id: supply at least one positive safe integer", MESSAGE_REJECTED_LOCALLY)
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
const raw = await sendRequest(config, {
|
|
671
|
-
method: "GET",
|
|
672
|
-
path: PATH,
|
|
673
|
-
params: { cliente_id: customer, contrato_id: contract }
|
|
674
|
-
});
|
|
675
|
-
if (!raw.ok)
|
|
676
|
-
return { success: false, error: raw.error };
|
|
677
|
-
if (!Array.isArray(raw.body)) {
|
|
678
|
-
return { success: false, error: createError("SCHEMA_MISMATCH", 200, PATH, "(root)") };
|
|
679
|
-
}
|
|
680
|
-
const rows = raw.body;
|
|
681
|
-
const selected = [];
|
|
682
|
-
for (const row of rows) {
|
|
683
|
-
const record = typeof row === "object" && row !== null && !Array.isArray(row) ? row : {};
|
|
684
|
-
const customerIsNumber = typeof record.cliente === "number" && Number.isFinite(record.cliente);
|
|
685
|
-
const contractIsNumber = typeof record.clientecontrato === "number" && Number.isFinite(record.clientecontrato);
|
|
686
|
-
const customerMismatch = customer !== undefined && customerIsNumber && record.cliente !== customer;
|
|
687
|
-
const contractMismatch = contract !== undefined && (record.clientecontrato === null || contractIsNumber && record.clientecontrato !== contract);
|
|
688
|
-
if (customerMismatch || contractMismatch)
|
|
689
|
-
continue;
|
|
690
|
-
const ambiguousPaths = [];
|
|
691
|
-
if (customer !== undefined && !customerIsNumber)
|
|
692
|
-
ambiguousPaths.push("[].cliente");
|
|
693
|
-
if (contract !== undefined && !contractIsNumber)
|
|
694
|
-
ambiguousPaths.push("[].clientecontrato");
|
|
695
|
-
if (ambiguousPaths.length > 0) {
|
|
696
|
-
return {
|
|
697
|
-
success: false,
|
|
698
|
-
error: createError("SCHEMA_MISMATCH", 200, PATH, ambiguousPaths.join(", "))
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
selected.push(row);
|
|
1117
|
+
var flatAddress = (address) => {
|
|
1118
|
+
const flat = {};
|
|
1119
|
+
for (const [key, value] of Object.entries(address)) {
|
|
1120
|
+
if (value !== undefined)
|
|
1121
|
+
flat[key] = value;
|
|
702
1122
|
}
|
|
703
|
-
return
|
|
1123
|
+
return flat;
|
|
704
1124
|
};
|
|
705
1125
|
|
|
706
|
-
// src/
|
|
707
|
-
import { z as
|
|
708
|
-
var
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
});
|
|
719
|
-
var contactsSchema = z12.object({
|
|
720
|
-
telefones: z12.array(z12.string()).optional().nullable(),
|
|
721
|
-
celulares: z12.array(z12.string()).optional().nullable(),
|
|
722
|
-
emails: z12.array(z12.string()).optional().nullable(),
|
|
723
|
-
outros: z12.array(z12.string()).optional().nullable()
|
|
724
|
-
});
|
|
725
|
-
var clientSchema = z12.object({
|
|
726
|
-
id: z12.number(),
|
|
727
|
-
nome: z12.string(),
|
|
728
|
-
tipo: z12.string(),
|
|
729
|
-
cpfcnpj: z12.string(),
|
|
730
|
-
sexo: z12.string().optional().nullable(),
|
|
731
|
-
dataCadastro: z12.string().optional().nullable(),
|
|
732
|
-
endereco: addressSchema.optional().nullable(),
|
|
733
|
-
contratos: z12.array(z12.object({})).optional().nullable(),
|
|
734
|
-
titulos: z12.array(z12.object({})).optional().nullable(),
|
|
735
|
-
contatos: contactsSchema.optional().nullable()
|
|
1126
|
+
// src/validation.ts
|
|
1127
|
+
import { z as z11 } from "zod";
|
|
1128
|
+
var nonBlank = z11.string().refine((value) => value.trim() !== "", "blank");
|
|
1129
|
+
|
|
1130
|
+
// src/operations/crm-contracts-create.ts
|
|
1131
|
+
var addressSchema = z12.strictObject({
|
|
1132
|
+
...addressShape,
|
|
1133
|
+
logradouro: nonBlank,
|
|
1134
|
+
bairro: nonBlank,
|
|
1135
|
+
cidade: nonBlank,
|
|
1136
|
+
cep: nonBlank,
|
|
1137
|
+
uf: nonBlank
|
|
736
1138
|
});
|
|
737
|
-
var
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
1139
|
+
var customerId = customerIdSchema.int().positive();
|
|
1140
|
+
var id3 = z12.number().int().nonnegative();
|
|
1141
|
+
var amount = z12.number().nonnegative();
|
|
1142
|
+
var crmContractsCreateInputSchema = z12.strictObject({
|
|
1143
|
+
cliente_id: customerId,
|
|
1144
|
+
pop_id: id3,
|
|
1145
|
+
plano_id: id3.brand(),
|
|
1146
|
+
portador_id: id3,
|
|
1147
|
+
forma_cobranca_codigo: id3,
|
|
1148
|
+
vencimento_dia: id3,
|
|
1149
|
+
endereco_instalacao: addressSchema,
|
|
1150
|
+
endereco_cobranca: addressSchema,
|
|
1151
|
+
login: z12.string().optional(),
|
|
1152
|
+
senha: z12.string().optional(),
|
|
1153
|
+
modoaquisicao: z12.union([z12.literal(0), z12.literal(1)]).optional(),
|
|
1154
|
+
nas: z12.string().optional(),
|
|
1155
|
+
isento: amount.optional(),
|
|
1156
|
+
autocobranca: z12.boolean().optional(),
|
|
1157
|
+
servicodesc: z12.string().optional(),
|
|
1158
|
+
observacao: z12.string().optional(),
|
|
1159
|
+
vendedor_id: id3.optional(),
|
|
1160
|
+
comissao_tipo: z12.union([z12.literal(1), z12.literal(2)]).optional(),
|
|
1161
|
+
comissao: amount.optional(),
|
|
1162
|
+
contrato_id: id3.optional(),
|
|
1163
|
+
fidelidade_id: id3.optional(),
|
|
1164
|
+
midia_id: id3.optional(),
|
|
1165
|
+
central_login: z12.string().optional(),
|
|
1166
|
+
central_senha: z12.string().optional(),
|
|
1167
|
+
ip: z12.string().optional(),
|
|
1168
|
+
ippool_id: id3.optional(),
|
|
1169
|
+
mac_dhcp: z12.string().optional(),
|
|
1170
|
+
mac: z12.string().optional(),
|
|
1171
|
+
logins_simult: id3.optional(),
|
|
1172
|
+
splitter_id: id3.optional(),
|
|
1173
|
+
splitter_port: id3.optional(),
|
|
1174
|
+
tipo_equipamento: z12.string().optional(),
|
|
1175
|
+
usuarioalt_id: id3.optional(),
|
|
1176
|
+
os_instalacao: z12.boolean().optional(),
|
|
1177
|
+
conteudo: z12.string().optional(),
|
|
1178
|
+
instalacao_quantidade_parcelas: id3.optional(),
|
|
1179
|
+
instalacao_preco: amount.optional(),
|
|
1180
|
+
instalacao_desconto: amount.optional(),
|
|
1181
|
+
instalacao_entrada: amount.optional(),
|
|
1182
|
+
instalacao_entrada_forma: id3.optional(),
|
|
1183
|
+
instalacao_parcela_forma: id3.optional(),
|
|
1184
|
+
instalacao_portador: id3.optional()
|
|
745
1185
|
});
|
|
746
|
-
var
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
1186
|
+
var crmContractBody = ({
|
|
1187
|
+
endereco_instalacao,
|
|
1188
|
+
endereco_cobranca,
|
|
1189
|
+
...fields
|
|
1190
|
+
}) => {
|
|
1191
|
+
const installation = flatAddress(endereco_instalacao);
|
|
1192
|
+
return {
|
|
1193
|
+
...fields,
|
|
1194
|
+
endereco_instalacao: installation,
|
|
1195
|
+
endereco_cobranca: flatAddress(endereco_cobranca),
|
|
1196
|
+
...installation
|
|
1197
|
+
};
|
|
1198
|
+
};
|
|
1199
|
+
var buildRequest9 = (input) => {
|
|
1200
|
+
const parsed = crmContractsCreateInputSchema.safeParse(input);
|
|
1201
|
+
if (!parsed.success)
|
|
1202
|
+
return { ok: false, problem: "invalid crm.contracts.create input" };
|
|
1203
|
+
const { cliente_id, ...contract } = parsed.data;
|
|
1204
|
+
return { ok: true, pathParams: { cliente_id }, params: crmContractBody(contract) };
|
|
1205
|
+
};
|
|
1206
|
+
var crmContractCreatedSchema = z12.looseObject({
|
|
1207
|
+
message: z12.string().optional().nullable(),
|
|
1208
|
+
clientecontrato: z12.number(),
|
|
1209
|
+
cliente: z12.string().optional().nullable()
|
|
1210
|
+
});
|
|
1211
|
+
var crmContractCreatedInvariants = ["clientecontrato"];
|
|
1212
|
+
var CUSTOMER_NOT_IN_CRM_TEXT = /^ocorreu um erro: não encontrado cliente crm com id \d+\.?$/i;
|
|
1213
|
+
var customerNotInCrm = singleErrorsEntryRejection(400, CUSTOMER_NOT_IN_CRM_TEXT, "CUSTOMER_NOT_IN_CRM");
|
|
1214
|
+
var crmContractsCreateSensitivity = {
|
|
1215
|
+
input: [
|
|
1216
|
+
{
|
|
1217
|
+
path: "",
|
|
1218
|
+
secretKeys: ["login", "senha", "central_login", "central_senha", "ip", "mac", "mac_dhcp"],
|
|
1219
|
+
personalKeys: [
|
|
1220
|
+
"endereco_instalacao",
|
|
1221
|
+
"endereco_cobranca",
|
|
1222
|
+
"servicodesc",
|
|
1223
|
+
"observacao",
|
|
1224
|
+
"conteudo"
|
|
1225
|
+
]
|
|
1226
|
+
}
|
|
1227
|
+
],
|
|
1228
|
+
output: [{ path: "", secretKeys: [], personalKeys: ["cliente"] }]
|
|
1229
|
+
};
|
|
1230
|
+
var crmContractsCreate = {
|
|
1231
|
+
name: "crm.contracts.create",
|
|
758
1232
|
method: "POST",
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1233
|
+
pathTemplate: "/api/crm/cliente/{cliente_id}/contratos/",
|
|
1234
|
+
encoding: "json",
|
|
1235
|
+
repeatable: false,
|
|
1236
|
+
write: { knownRejections: [customerNotInCrm] },
|
|
1237
|
+
buildRequest: buildRequest9,
|
|
1238
|
+
decode: tolerantDecoder(crmContractCreatedSchema, crmContractCreatedInvariants),
|
|
1239
|
+
sensitivity: crmContractsCreateSensitivity
|
|
765
1240
|
};
|
|
766
1241
|
|
|
767
|
-
// src/
|
|
1242
|
+
// src/operations/crm-contracts-create-by-cpf-cnpj.ts
|
|
1243
|
+
var crmContractsCreateByCpfCnpjInputSchema = crmContractsCreateInputSchema.omit({ cliente_id: true }).extend({ cpfcnpj: nonBlank });
|
|
1244
|
+
var buildRequest10 = (input) => {
|
|
1245
|
+
const parsed = crmContractsCreateByCpfCnpjInputSchema.safeParse(input);
|
|
1246
|
+
if (!parsed.success) {
|
|
1247
|
+
return { ok: false, problem: "invalid crm.contracts.createByCpfCnpj input" };
|
|
1248
|
+
}
|
|
1249
|
+
const { cpfcnpj, ...contract } = parsed.data;
|
|
1250
|
+
return { ok: true, query: { cpfcnpj }, params: crmContractBody(contract) };
|
|
1251
|
+
};
|
|
1252
|
+
var CUSTOMER_NOT_IN_CRM_TEXT2 = /^ocorreu um erro: não encontrado cliente crm com documento [\d./-]+\.?$/i;
|
|
1253
|
+
var customerNotInCrm2 = singleErrorsEntryRejection(400, CUSTOMER_NOT_IN_CRM_TEXT2, "CUSTOMER_NOT_IN_CRM");
|
|
1254
|
+
var crmContractsCreateByCpfCnpjSensitivity = {
|
|
1255
|
+
input: crmContractsCreateSensitivity.input.map((scope) => ({
|
|
1256
|
+
...scope,
|
|
1257
|
+
personalKeys: [...scope.personalKeys, "cpfcnpj"]
|
|
1258
|
+
})),
|
|
1259
|
+
output: crmContractsCreateSensitivity.output
|
|
1260
|
+
};
|
|
1261
|
+
var crmContractsCreateByCpfCnpj = {
|
|
1262
|
+
name: "crm.contracts.createByCpfCnpj",
|
|
1263
|
+
method: "POST",
|
|
1264
|
+
pathTemplate: "/api/crm/cliente/contratos/",
|
|
1265
|
+
encoding: "json",
|
|
1266
|
+
repeatable: false,
|
|
1267
|
+
write: { knownRejections: [customerNotInCrm2] },
|
|
1268
|
+
buildRequest: buildRequest10,
|
|
1269
|
+
decode: tolerantDecoder(crmContractCreatedSchema, crmContractCreatedInvariants),
|
|
1270
|
+
sensitivity: crmContractsCreateByCpfCnpjSensitivity
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// src/operations/crm-contracts-list.ts
|
|
768
1274
|
import { z as z13 } from "zod";
|
|
769
|
-
var
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
1275
|
+
var crmContractsListInputSchema = z13.strictObject({ cpfcnpj: nonBlank });
|
|
1276
|
+
var buildRequest11 = (input) => {
|
|
1277
|
+
const parsed = crmContractsListInputSchema.safeParse(input);
|
|
1278
|
+
if (!parsed.success)
|
|
1279
|
+
return { ok: false, problem: "invalid crm.contracts.list input" };
|
|
1280
|
+
return { ok: true, params: parsed.data };
|
|
1281
|
+
};
|
|
1282
|
+
var serviceSchema = z13.looseObject({
|
|
1283
|
+
plano: z13.string().optional().nullable(),
|
|
1284
|
+
login: z13.string().optional().nullable(),
|
|
1285
|
+
contrato_tipo: z13.string().optional().nullable(),
|
|
1286
|
+
situacao: z13.string().optional().nullable(),
|
|
1287
|
+
aquisicao: z13.string().optional().nullable()
|
|
1288
|
+
});
|
|
1289
|
+
var contractSchema = z13.looseObject({
|
|
1290
|
+
cliente_contrato_id: z13.number(),
|
|
779
1291
|
data_cadastro: z13.string().optional().nullable(),
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
var
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1292
|
+
vencimento_dia: z13.number().optional().nullable(),
|
|
1293
|
+
pop: z13.string().optional().nullable(),
|
|
1294
|
+
endereco: z13.string().optional().nullable(),
|
|
1295
|
+
forma_cobranca: z13.string().optional().nullable(),
|
|
1296
|
+
status: z13.string().optional().nullable(),
|
|
1297
|
+
data_status: z13.string().optional().nullable(),
|
|
1298
|
+
modo_status: z13.string().optional().nullable(),
|
|
1299
|
+
motivo_status: z13.string().optional().nullable(),
|
|
1300
|
+
vendedor: z13.string().optional().nullable(),
|
|
1301
|
+
servicos: z13.array(serviceSchema).optional().nullable()
|
|
1302
|
+
});
|
|
1303
|
+
var contractsSchema2 = z13.looseObject({
|
|
1304
|
+
cliente: z13.string().optional().nullable(),
|
|
1305
|
+
cpf_cnpj: z13.string().optional().nullable(),
|
|
1306
|
+
contratos: z13.array(contractSchema)
|
|
1307
|
+
});
|
|
1308
|
+
var contractsInvariants2 = ["contratos", "contratos[].cliente_contrato_id"];
|
|
1309
|
+
var crmContractsListSensitivity = {
|
|
1310
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["cpfcnpj"] }],
|
|
1311
|
+
output: [
|
|
1312
|
+
{ path: "", secretKeys: [], personalKeys: ["cliente", "cpf_cnpj"] },
|
|
1313
|
+
{
|
|
1314
|
+
path: "contratos[]",
|
|
1315
|
+
secretKeys: [],
|
|
1316
|
+
personalKeys: ["endereco", "motivo_status", "vendedor"]
|
|
1317
|
+
},
|
|
1318
|
+
{ path: "contratos[].servicos[]", secretKeys: ["login"], personalKeys: ["email"] }
|
|
1319
|
+
]
|
|
1320
|
+
};
|
|
1321
|
+
var crmContractsList = {
|
|
1322
|
+
name: "crm.contracts.list",
|
|
1323
|
+
method: "GET",
|
|
1324
|
+
pathTemplate: "/api/crm/cliente/contratos/",
|
|
1325
|
+
encoding: "json",
|
|
1326
|
+
buildRequest: buildRequest11,
|
|
1327
|
+
repeatable: true,
|
|
1328
|
+
decode: tolerantDecoder(contractsSchema2, contractsInvariants2),
|
|
1329
|
+
sensitivity: crmContractsListSensitivity
|
|
806
1330
|
};
|
|
807
1331
|
|
|
808
|
-
// src/
|
|
1332
|
+
// src/operations/crm-customers-create.ts
|
|
809
1333
|
import { z as z14 } from "zod";
|
|
810
|
-
var
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
});
|
|
841
|
-
var listInvoicesSchema = z14.object({
|
|
842
|
-
paginacao: z14.object({
|
|
843
|
-
offset: z14.number().optional().nullable(),
|
|
844
|
-
limit: z14.number().optional().nullable(),
|
|
845
|
-
parcial: z14.number().optional().nullable(),
|
|
846
|
-
total: z14.number()
|
|
1334
|
+
var crmCustomerAddressSchema = z14.strictObject({
|
|
1335
|
+
...addressShape,
|
|
1336
|
+
logradouro: nonBlank,
|
|
1337
|
+
bairro: nonBlank,
|
|
1338
|
+
cidade: nonBlank,
|
|
1339
|
+
cep: nonBlank,
|
|
1340
|
+
uf: nonBlank
|
|
1341
|
+
});
|
|
1342
|
+
var commonShape = {
|
|
1343
|
+
nome: nonBlank,
|
|
1344
|
+
cpfcnpj: nonBlank,
|
|
1345
|
+
endereco: crmCustomerAddressSchema,
|
|
1346
|
+
email: z14.string().optional(),
|
|
1347
|
+
celular: z14.string().optional(),
|
|
1348
|
+
observacao: z14.string().optional()
|
|
1349
|
+
};
|
|
1350
|
+
var crmCustomersCreateInputSchema = z14.discriminatedUnion("personType", [
|
|
1351
|
+
z14.strictObject({
|
|
1352
|
+
personType: z14.literal("F"),
|
|
1353
|
+
...commonShape,
|
|
1354
|
+
datanasc: z14.string().optional(),
|
|
1355
|
+
rg: z14.string().optional(),
|
|
1356
|
+
rg_emissor: z14.string().optional(),
|
|
1357
|
+
sexo: z14.enum(["M", "F"]).optional(),
|
|
1358
|
+
estadocivil: z14.enum(["C", "S", "V", "D"]).optional(),
|
|
1359
|
+
nomemae: z14.string().optional(),
|
|
1360
|
+
nomepai: z14.string().optional(),
|
|
1361
|
+
profissao: z14.string().optional(),
|
|
1362
|
+
nacionalidade: z14.string().optional(),
|
|
1363
|
+
naturalidade: z14.string().optional()
|
|
847
1364
|
}),
|
|
848
|
-
|
|
1365
|
+
z14.strictObject({
|
|
1366
|
+
personType: z14.literal("J"),
|
|
1367
|
+
...commonShape,
|
|
1368
|
+
nomefantasia: z14.string().optional(),
|
|
1369
|
+
respempresa: z14.string().optional(),
|
|
1370
|
+
respcpf: z14.string().optional(),
|
|
1371
|
+
insc_estadual: z14.string().optional(),
|
|
1372
|
+
insc_municipal: z14.string().optional(),
|
|
1373
|
+
datafundacao: z14.string().optional()
|
|
1374
|
+
})
|
|
1375
|
+
]);
|
|
1376
|
+
var buildRequest12 = (input) => {
|
|
1377
|
+
const parsed = crmCustomersCreateInputSchema.safeParse(input);
|
|
1378
|
+
if (!parsed.success)
|
|
1379
|
+
return { ok: false, problem: "invalid crm.customers.create input" };
|
|
1380
|
+
const { personType, endereco, ...fields } = parsed.data;
|
|
1381
|
+
const flat = flatAddress(endereco);
|
|
1382
|
+
return { ok: true, pathParams: { personType }, params: { ...fields, endereco: flat, ...flat } };
|
|
1383
|
+
};
|
|
1384
|
+
var createdSchema = z14.looseObject({
|
|
1385
|
+
cliente_id: customerIdSchema,
|
|
1386
|
+
message: z14.string().optional().nullable()
|
|
849
1387
|
});
|
|
850
|
-
var
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1388
|
+
var createdInvariants = ["cliente_id"];
|
|
1389
|
+
var crmCustomersCreateSensitivity = {
|
|
1390
|
+
input: [
|
|
1391
|
+
{
|
|
1392
|
+
path: "",
|
|
1393
|
+
secretKeys: [],
|
|
1394
|
+
personalKeys: [
|
|
1395
|
+
"nome",
|
|
1396
|
+
"cpfcnpj",
|
|
1397
|
+
"endereco",
|
|
1398
|
+
"email",
|
|
1399
|
+
"celular",
|
|
1400
|
+
"observacao",
|
|
1401
|
+
"datanasc",
|
|
1402
|
+
"rg",
|
|
1403
|
+
"rg_emissor",
|
|
1404
|
+
"sexo",
|
|
1405
|
+
"estadocivil",
|
|
1406
|
+
"nomemae",
|
|
1407
|
+
"nomepai",
|
|
1408
|
+
"profissao",
|
|
1409
|
+
"nacionalidade",
|
|
1410
|
+
"naturalidade",
|
|
1411
|
+
"nomefantasia",
|
|
1412
|
+
"respempresa",
|
|
1413
|
+
"respcpf",
|
|
1414
|
+
"insc_estadual",
|
|
1415
|
+
"insc_municipal",
|
|
1416
|
+
"datafundacao"
|
|
1417
|
+
]
|
|
1418
|
+
}
|
|
1419
|
+
],
|
|
1420
|
+
output: [{ path: "", secretKeys: [], personalKeys: ["message"] }]
|
|
1421
|
+
};
|
|
1422
|
+
var crmCustomersCreate = {
|
|
1423
|
+
name: "crm.customers.create",
|
|
869
1424
|
method: "POST",
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
1425
|
+
pathTemplate: "/api/crm/cliente/{personType}",
|
|
1426
|
+
encoding: "json",
|
|
1427
|
+
repeatable: false,
|
|
1428
|
+
write: {},
|
|
1429
|
+
buildRequest: buildRequest12,
|
|
1430
|
+
decode: tolerantDecoder(createdSchema, createdInvariants),
|
|
1431
|
+
sensitivity: crmCustomersCreateSensitivity
|
|
876
1432
|
};
|
|
877
1433
|
|
|
878
|
-
// src/
|
|
1434
|
+
// src/operations/crm-customers-update-status.ts
|
|
879
1435
|
import { z as z15 } from "zod";
|
|
880
|
-
var
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
1436
|
+
var customerId2 = customerIdSchema.int().positive();
|
|
1437
|
+
var crmCustomersUpdateStatusInputSchema = z15.strictObject({
|
|
1438
|
+
cliente_id: customerId2,
|
|
1439
|
+
status_id: z15.number().int().nonnegative(),
|
|
1440
|
+
motivo: z15.string().optional()
|
|
1441
|
+
});
|
|
1442
|
+
var buildRequest13 = (input) => {
|
|
1443
|
+
const parsed = crmCustomersUpdateStatusInputSchema.safeParse(input);
|
|
1444
|
+
if (!parsed.success)
|
|
1445
|
+
return { ok: false, problem: "invalid crm.customers.updateStatus input" };
|
|
1446
|
+
const { cliente_id, ...fields } = parsed.data;
|
|
1447
|
+
return { ok: true, pathParams: { cliente_id }, params: fields };
|
|
1448
|
+
};
|
|
1449
|
+
var statusUpdatedSchema = z15.looseObject({
|
|
1450
|
+
cliente_id: customerIdSchema,
|
|
1451
|
+
message: z15.string().optional().nullable(),
|
|
1452
|
+
novo_status: z15.looseObject({
|
|
1453
|
+
codigo: z15.number(),
|
|
1454
|
+
descricao: z15.string().optional().nullable()
|
|
1455
|
+
})
|
|
1456
|
+
});
|
|
1457
|
+
var statusUpdatedInvariants = ["cliente_id", "novo_status", "novo_status.codigo"];
|
|
1458
|
+
var crmCustomersUpdateStatusSensitivity = {
|
|
1459
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["motivo"] }],
|
|
1460
|
+
output: [{ path: "", secretKeys: [], personalKeys: ["message"] }]
|
|
1461
|
+
};
|
|
1462
|
+
var crmCustomersUpdateStatus = {
|
|
1463
|
+
name: "crm.customers.updateStatus",
|
|
901
1464
|
method: "POST",
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1465
|
+
pathTemplate: "/api/crm/cliente/{cliente_id}/status/",
|
|
1466
|
+
encoding: "json",
|
|
1467
|
+
repeatable: false,
|
|
1468
|
+
write: {},
|
|
1469
|
+
buildRequest: buildRequest13,
|
|
1470
|
+
decode: tolerantDecoder(statusUpdatedSchema, statusUpdatedInvariants),
|
|
1471
|
+
sensitivity: crmCustomersUpdateStatusSensitivity
|
|
908
1472
|
};
|
|
909
1473
|
|
|
910
|
-
// src/
|
|
1474
|
+
// src/operations/customers-list.ts
|
|
911
1475
|
import { z as z16 } from "zod";
|
|
912
|
-
var
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
1476
|
+
var addressSchema2 = z16.looseObject({
|
|
1477
|
+
logradouro: z16.string().optional().nullable(),
|
|
1478
|
+
numero: z16.union([z16.number(), z16.string()]).optional().nullable(),
|
|
1479
|
+
bairro: z16.string().optional().nullable(),
|
|
1480
|
+
cidade: z16.string().optional().nullable(),
|
|
1481
|
+
uf: z16.string().optional().nullable(),
|
|
1482
|
+
cep: z16.string().optional().nullable(),
|
|
1483
|
+
complemento: z16.string().optional().nullable(),
|
|
1484
|
+
latitude: z16.string().optional().nullable(),
|
|
1485
|
+
longitude: z16.string().optional().nullable()
|
|
1486
|
+
});
|
|
1487
|
+
var planSchema = z16.looseObject({
|
|
1488
|
+
id: z16.number().brand(),
|
|
1489
|
+
descricao: z16.string().optional().nullable()
|
|
1490
|
+
});
|
|
1491
|
+
var serviceSchema2 = z16.looseObject({
|
|
1492
|
+
id: z16.number(),
|
|
1493
|
+
tipo: z16.string().optional().nullable(),
|
|
1494
|
+
plano: planSchema.optional().nullable(),
|
|
1495
|
+
status: z16.string().optional().nullable(),
|
|
1496
|
+
endereco: addressSchema2.optional().nullable()
|
|
1497
|
+
});
|
|
1498
|
+
var contractSchema2 = z16.looseObject({
|
|
1499
|
+
id: z16.number(),
|
|
1500
|
+
status: z16.string().optional().nullable(),
|
|
1501
|
+
endereco: addressSchema2.optional().nullable(),
|
|
1502
|
+
servicos: z16.array(serviceSchema2).optional().nullable()
|
|
1503
|
+
});
|
|
1504
|
+
var contactsSchema = z16.looseObject({
|
|
1505
|
+
telefones: z16.array(z16.string()).optional().nullable(),
|
|
1506
|
+
celulares: z16.array(z16.string()).optional().nullable(),
|
|
1507
|
+
emails: z16.array(z16.string()).optional().nullable(),
|
|
1508
|
+
outros: z16.array(z16.unknown()).optional().nullable()
|
|
1509
|
+
});
|
|
1510
|
+
var customerSchema = z16.looseObject({
|
|
1511
|
+
id: customerIdSchema,
|
|
1512
|
+
nome: z16.string(),
|
|
1513
|
+
tipo: z16.string(),
|
|
1514
|
+
cpfcnpj: z16.string(),
|
|
1515
|
+
sexo: z16.string().optional().nullable(),
|
|
1516
|
+
dataCadastro: z16.string().optional().nullable(),
|
|
1517
|
+
endereco: addressSchema2.optional().nullable(),
|
|
1518
|
+
contratos: z16.array(contractSchema2).optional().nullable(),
|
|
1519
|
+
titulos: z16.array(z16.looseObject({})).optional().nullable(),
|
|
1520
|
+
contatos: contactsSchema.optional().nullable()
|
|
1521
|
+
});
|
|
1522
|
+
var pageSchema = z16.looseObject({
|
|
1523
|
+
paginacao: z16.looseObject({
|
|
1524
|
+
offset: z16.number().optional().nullable(),
|
|
1525
|
+
limit: z16.number().optional().nullable(),
|
|
1526
|
+
parcial: z16.number().optional().nullable(),
|
|
1527
|
+
total: z16.number()
|
|
1528
|
+
}),
|
|
1529
|
+
clientes: z16.array(customerSchema)
|
|
1530
|
+
});
|
|
1531
|
+
var pageInvariants = [
|
|
1532
|
+
"paginacao",
|
|
1533
|
+
"paginacao.total",
|
|
1534
|
+
"clientes",
|
|
1535
|
+
"clientes[].id",
|
|
1536
|
+
"clientes[].nome",
|
|
1537
|
+
"clientes[].cpfcnpj",
|
|
1538
|
+
"clientes[].tipo",
|
|
1539
|
+
"clientes[].contratos[].id",
|
|
1540
|
+
"clientes[].contratos[].servicos[].id",
|
|
1541
|
+
"clientes[].contratos[].servicos[].plano.id"
|
|
1542
|
+
];
|
|
1543
|
+
var customersListInputSchema = z16.strictObject({
|
|
1544
|
+
offset: z16.number().int().nonnegative().optional(),
|
|
1545
|
+
limit: z16.number().int().nonnegative().optional(),
|
|
1546
|
+
cliente_id: customerIdSchema.int().optional(),
|
|
1547
|
+
cpfcnpj: z16.string().optional(),
|
|
1548
|
+
cliente_nome: z16.string().optional()
|
|
1549
|
+
});
|
|
1550
|
+
var buildRequest14 = (input) => {
|
|
1551
|
+
const parsed = customersListInputSchema.safeParse(input);
|
|
1552
|
+
if (!parsed.success)
|
|
1553
|
+
return { ok: false, problem: "invalid customers.list input" };
|
|
1554
|
+
return { ok: true, params: parsed.data };
|
|
1555
|
+
};
|
|
1556
|
+
var customersListSensitivity = {
|
|
1557
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["cpfcnpj", "cliente_nome"] }],
|
|
1558
|
+
output: [
|
|
1559
|
+
{
|
|
1560
|
+
path: "clientes[]",
|
|
1561
|
+
secretKeys: [],
|
|
1562
|
+
personalKeys: ["nome", "cpfcnpj", "sexo", "endereco", "contatos"]
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
path: "clientes[].contratos[]",
|
|
1566
|
+
secretKeys: ["contratoCentralLogin", "contratoCentralSenha"],
|
|
1567
|
+
personalKeys: ["motivo_status", "endereco"]
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
path: "clientes[].contratos[].servicos[]",
|
|
1571
|
+
secretKeys: [
|
|
1572
|
+
"login",
|
|
1573
|
+
"senha",
|
|
1574
|
+
"mac",
|
|
1575
|
+
"serial",
|
|
1576
|
+
"ip",
|
|
1577
|
+
"wifi_ssid",
|
|
1578
|
+
"wifi_password",
|
|
1579
|
+
"wifi_ssid_5",
|
|
1580
|
+
"wifi_password_5"
|
|
1581
|
+
],
|
|
1582
|
+
personalKeys: ["endereco"]
|
|
1583
|
+
}
|
|
1584
|
+
]
|
|
1585
|
+
};
|
|
1586
|
+
var customersList = {
|
|
1587
|
+
name: "customers.list",
|
|
1588
|
+
method: "POST",
|
|
1589
|
+
pathTemplate: "/api/ura/clientes/",
|
|
1590
|
+
encoding: "json",
|
|
1591
|
+
buildRequest: buildRequest14,
|
|
1592
|
+
repeatable: true,
|
|
1593
|
+
decode: tolerantDecoder(pageSchema, pageInvariants),
|
|
1594
|
+
sensitivity: customersListSensitivity
|
|
929
1595
|
};
|
|
930
1596
|
|
|
931
|
-
// src/
|
|
1597
|
+
// src/operations/customers-search.ts
|
|
932
1598
|
import { z as z17 } from "zod";
|
|
933
|
-
var
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
});
|
|
938
|
-
var
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1599
|
+
var contactSchema = z17.looseObject({
|
|
1600
|
+
inscricoes: z17.array(z17.string()).optional().nullable(),
|
|
1601
|
+
tipoContato: z17.string().optional().nullable(),
|
|
1602
|
+
contato: z17.string().optional().nullable()
|
|
1603
|
+
});
|
|
1604
|
+
var tagSchema = z17.looseObject({
|
|
1605
|
+
color: z17.string().optional().nullable(),
|
|
1606
|
+
font: z17.string().optional().nullable(),
|
|
1607
|
+
tag: z17.string().optional().nullable(),
|
|
1608
|
+
id: z17.number().optional().nullable(),
|
|
1609
|
+
categoria_id: z17.unknown().optional()
|
|
1610
|
+
});
|
|
1611
|
+
var loyaltySchema = z17.looseObject({
|
|
1612
|
+
data_inicio: z17.string().optional().nullable(),
|
|
1613
|
+
descricao: z17.string().optional().nullable(),
|
|
1614
|
+
data_fim: z17.string().optional().nullable()
|
|
1615
|
+
});
|
|
1616
|
+
var candidateSchema = z17.looseObject({
|
|
1617
|
+
contratoId: z17.number(),
|
|
1618
|
+
clienteId: customerIdSchema,
|
|
1619
|
+
contratoStatus: z17.number().optional().nullable(),
|
|
1620
|
+
contratoStatusDisplay: z17.string().optional().nullable(),
|
|
1621
|
+
contratoValorAberto: z17.number().optional().nullable(),
|
|
1622
|
+
contratoTitulosAReceber: z17.number().optional().nullable(),
|
|
1623
|
+
cobVencimento: z17.number().optional().nullable(),
|
|
1624
|
+
contratoStatusModo: z17.number().optional().nullable(),
|
|
1625
|
+
motivo_status: z17.string().optional().nullable(),
|
|
1626
|
+
dataCadastro: z17.string().optional().nullable(),
|
|
1627
|
+
dataAlteracao: z17.string().optional().nullable(),
|
|
1628
|
+
popId: z17.number().optional().nullable(),
|
|
1629
|
+
popNome: z17.string().optional().nullable(),
|
|
1630
|
+
cobPermuta: z17.boolean().optional().nullable(),
|
|
1631
|
+
cobIsento: z17.number().optional().nullable(),
|
|
1632
|
+
promessasPagamentoMes: z17.number().optional().nullable(),
|
|
1633
|
+
link_quitacao: z17.string().optional().nullable(),
|
|
1634
|
+
planointernet: z17.string().optional().nullable(),
|
|
1635
|
+
fidelidade: loyaltySchema.optional().nullable(),
|
|
1636
|
+
contrato_unificado_principal: z17.unknown().optional(),
|
|
1637
|
+
contrato_unificado_filhos: z17.unknown().optional(),
|
|
1638
|
+
tags: z17.array(tagSchema).optional().nullable(),
|
|
1639
|
+
anotacoes: z17.array(z17.unknown()).optional().nullable(),
|
|
1640
|
+
contratoCentralLogin: z17.string().optional().nullable(),
|
|
1641
|
+
contratoCentralSenha: z17.string().optional().nullable(),
|
|
1642
|
+
servico_login: z17.string().optional().nullable(),
|
|
1643
|
+
servico_senha: z17.string().optional().nullable(),
|
|
1644
|
+
servico_plano: z17.string().optional().nullable(),
|
|
1645
|
+
servico_grupo: z17.string().optional().nullable(),
|
|
1646
|
+
servico_tipo_conexao: z17.string().optional().nullable(),
|
|
1647
|
+
servico_vlan: z17.string().optional().nullable(),
|
|
1648
|
+
servico_mac: z17.string().optional().nullable(),
|
|
1649
|
+
servico_mac2: z17.string().optional().nullable(),
|
|
1650
|
+
servico_wifi_ssid: z17.string().optional().nullable(),
|
|
1651
|
+
servico_wifi_ssid_5: z17.string().optional().nullable(),
|
|
1652
|
+
servico_wifi_password: z17.string().optional().nullable(),
|
|
1653
|
+
servico_wifi_password_5: z17.string().optional().nullable(),
|
|
1654
|
+
servico_wifi_channel: z17.string().optional().nullable(),
|
|
1655
|
+
servico_wifi_channel_5: z17.string().optional().nullable(),
|
|
1656
|
+
razaoSocial: z17.string().optional().nullable(),
|
|
1657
|
+
cpfCnpj: z17.string().optional().nullable(),
|
|
1658
|
+
dataNascimento: z17.string().optional().nullable(),
|
|
1659
|
+
telefones: z17.array(contactSchema).optional().nullable(),
|
|
1660
|
+
telefones_cargos: z17.array(z17.unknown()).optional().nullable(),
|
|
1661
|
+
emails: z17.array(contactSchema).optional().nullable(),
|
|
1662
|
+
outros: z17.array(z17.unknown()).optional().nullable(),
|
|
1663
|
+
endereco_logradouro: z17.string().optional().nullable(),
|
|
1664
|
+
endereco_numero: z17.union([z17.number(), z17.string()]).optional().nullable(),
|
|
1665
|
+
endereco_complemento: z17.string().optional().nullable(),
|
|
1666
|
+
endereco_bairro: z17.string().optional().nullable(),
|
|
1667
|
+
endereco_cidade: z17.string().optional().nullable(),
|
|
1668
|
+
endereco_uf: z17.string().optional().nullable(),
|
|
1669
|
+
endereco_cep: z17.string().optional().nullable(),
|
|
1670
|
+
endereco_pontoreferencia: z17.unknown().optional(),
|
|
1671
|
+
endereco_ll: z17.string().optional().nullable()
|
|
1672
|
+
});
|
|
1673
|
+
var searchSchema = z17.looseObject({
|
|
1674
|
+
msg: z17.string().optional().nullable(),
|
|
1675
|
+
contratos: z17.array(candidateSchema)
|
|
1676
|
+
});
|
|
1677
|
+
var searchInvariants = ["contratos", "contratos[].contratoId", "contratos[].clienteId"];
|
|
1678
|
+
var customersSearchInputSchema = z17.strictObject({
|
|
1679
|
+
cpfcnpj: z17.string().min(1).optional(),
|
|
1680
|
+
contrato: z17.number().int().optional(),
|
|
1681
|
+
nome: z17.string().min(1).optional(),
|
|
1682
|
+
login: z17.string().min(1).optional(),
|
|
1683
|
+
telefone: z17.string().min(1).optional()
|
|
1684
|
+
}).refine((criteria) => Object.values(criteria).some((value) => value !== undefined), {
|
|
1685
|
+
message: "at least one criterion is required"
|
|
1686
|
+
});
|
|
1687
|
+
var buildRequest15 = (input) => {
|
|
1688
|
+
const parsed = customersSearchInputSchema.safeParse(input);
|
|
1689
|
+
if (!parsed.success)
|
|
1690
|
+
return { ok: false, problem: "invalid customers.search input" };
|
|
1691
|
+
return { ok: true, params: parsed.data };
|
|
1692
|
+
};
|
|
1693
|
+
var customersSearchSensitivity = {
|
|
1694
|
+
input: [
|
|
1695
|
+
{
|
|
1696
|
+
path: "",
|
|
1697
|
+
secretKeys: ["login"],
|
|
1698
|
+
personalKeys: ["cpfcnpj", "nome", "telefone"]
|
|
1699
|
+
}
|
|
1700
|
+
],
|
|
1701
|
+
output: [
|
|
1702
|
+
{
|
|
1703
|
+
path: "contratos[]",
|
|
1704
|
+
secretKeys: [
|
|
1705
|
+
"contratoCentralLogin",
|
|
1706
|
+
"contratoCentralSenha",
|
|
1707
|
+
"servico_login",
|
|
1708
|
+
"servico_senha",
|
|
1709
|
+
"servico_vlan",
|
|
1710
|
+
"servico_mac",
|
|
1711
|
+
"servico_mac2",
|
|
1712
|
+
"servico_wifi_ssid",
|
|
1713
|
+
"servico_wifi_ssid_5",
|
|
1714
|
+
"servico_wifi_password",
|
|
1715
|
+
"servico_wifi_password_5",
|
|
1716
|
+
"link_quitacao"
|
|
1717
|
+
],
|
|
1718
|
+
personalKeys: [
|
|
1719
|
+
"motivo_status",
|
|
1720
|
+
"razaoSocial",
|
|
1721
|
+
"cpfCnpj",
|
|
1722
|
+
"dataNascimento",
|
|
1723
|
+
"telefones",
|
|
1724
|
+
"telefones_cargos",
|
|
1725
|
+
"emails",
|
|
1726
|
+
"outros",
|
|
1727
|
+
"anotacoes",
|
|
1728
|
+
"endereco_logradouro",
|
|
1729
|
+
"endereco_numero",
|
|
1730
|
+
"endereco_complemento",
|
|
1731
|
+
"endereco_bairro",
|
|
1732
|
+
"endereco_cidade",
|
|
1733
|
+
"endereco_uf",
|
|
1734
|
+
"endereco_cep",
|
|
1735
|
+
"endereco_pontoreferencia",
|
|
1736
|
+
"endereco_ll"
|
|
1737
|
+
]
|
|
1738
|
+
},
|
|
1739
|
+
{
|
|
1740
|
+
path: "contratos[].tags[]",
|
|
1741
|
+
secretKeys: [],
|
|
1742
|
+
personalKeys: ["tag"]
|
|
1743
|
+
},
|
|
1744
|
+
{
|
|
1745
|
+
path: "contratos[].fidelidade",
|
|
1746
|
+
secretKeys: [],
|
|
1747
|
+
personalKeys: ["descricao"]
|
|
1748
|
+
}
|
|
1749
|
+
]
|
|
1750
|
+
};
|
|
1751
|
+
var customersSearch = {
|
|
1752
|
+
name: "customers.search",
|
|
1753
|
+
method: "POST",
|
|
1754
|
+
pathTemplate: "/api/ura/consultacliente/",
|
|
1755
|
+
encoding: "json",
|
|
1756
|
+
buildRequest: buildRequest15,
|
|
1757
|
+
repeatable: true,
|
|
1758
|
+
decode: tolerantDecoder(searchSchema, searchInvariants),
|
|
1759
|
+
sensitivity: customersSearchSensitivity
|
|
951
1760
|
};
|
|
952
1761
|
|
|
953
|
-
// src/
|
|
1762
|
+
// src/operations/documents-add.ts
|
|
954
1763
|
import { z as z18 } from "zod";
|
|
955
|
-
var
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
dias_bloqueio_aviso: z18.number().optional().nullable(),
|
|
988
|
-
dias_reducao_velocidade: z18.number().optional().nullable(),
|
|
989
|
-
download: z18.number().optional().nullable(),
|
|
990
|
-
upload: z18.number().optional().nullable(),
|
|
991
|
-
trafego_mensal: z18.number().optional().nullable(),
|
|
992
|
-
contabilizacao_trafego_mensal: z18.string().optional().nullable(),
|
|
993
|
-
trafego_excedente_acao: z18.string().optional().nullable(),
|
|
994
|
-
valor_trafego_excedido: z18.number().optional().nullable(),
|
|
995
|
-
duplicacao_noturna: z18.boolean().optional().nullable(),
|
|
996
|
-
inicio_duplicacao_noturna: z18.string().optional().nullable(),
|
|
997
|
-
fim_duplicacao_noturna: z18.string().optional().nullable(),
|
|
998
|
-
modo_velocidade_reduzida: z18.string().optional().nullable(),
|
|
999
|
-
download_red_financeiro: z18.number().optional().nullable(),
|
|
1000
|
-
upload_red_financeiro: z18.number().optional().nullable(),
|
|
1001
|
-
modo_velocidade_red_franquia: z18.string().optional().nullable(),
|
|
1002
|
-
download_red_franquia: z18.number().optional().nullable(),
|
|
1003
|
-
upload_red_franquia: z18.number().optional().nullable(),
|
|
1004
|
-
combo: z18.array(z18.object({})).optional().nullable(),
|
|
1005
|
-
qtd_servicos: z18.number().optional().nullable()
|
|
1006
|
-
});
|
|
1007
|
-
var listPlansSchema = z18.object({
|
|
1008
|
-
planos: z18.array(planSchema),
|
|
1009
|
-
total_planos: z18.number().optional().nullable(),
|
|
1010
|
-
total_qtd_servicos: z18.number().optional().nullable()
|
|
1011
|
-
});
|
|
1012
|
-
var listPlansKeyFields = [
|
|
1013
|
-
"planos",
|
|
1014
|
-
"planos[].id",
|
|
1015
|
-
"planos[].descricao",
|
|
1016
|
-
"planos[].preco",
|
|
1017
|
-
"planos[].ativo"
|
|
1018
|
-
];
|
|
1019
|
-
var planItemPath = "planos[]";
|
|
1020
|
-
var planSecretKeys = [];
|
|
1021
|
-
var planPersonalKeys = [];
|
|
1022
|
-
var listPlansDefinition = {
|
|
1023
|
-
method: "GET",
|
|
1024
|
-
path: "/api/ura/consultaplano/",
|
|
1025
|
-
schema: listPlansSchema,
|
|
1026
|
-
keyFields: listPlansKeyFields,
|
|
1027
|
-
itemPath: planItemPath,
|
|
1028
|
-
secretKeys: planSecretKeys,
|
|
1029
|
-
personalKeys: planPersonalKeys
|
|
1764
|
+
var isFileData = (value) => value instanceof Blob || value instanceof Uint8Array || value instanceof ArrayBuffer;
|
|
1765
|
+
var fileSchema = z18.strictObject({
|
|
1766
|
+
data: z18.custom(isFileData),
|
|
1767
|
+
filename: nonBlank,
|
|
1768
|
+
contentType: z18.string().optional()
|
|
1769
|
+
});
|
|
1770
|
+
var documentsAddInputSchema = z18.strictObject({
|
|
1771
|
+
cliente_id: customerIdSchema.int().positive(),
|
|
1772
|
+
file: fileSchema,
|
|
1773
|
+
descricao: z18.string().optional()
|
|
1774
|
+
});
|
|
1775
|
+
var buildRequest16 = (input) => {
|
|
1776
|
+
const parsed = documentsAddInputSchema.safeParse(input);
|
|
1777
|
+
if (!parsed.success)
|
|
1778
|
+
return { ok: false, problem: "invalid documents.add input" };
|
|
1779
|
+
const { cliente_id, file, ...fields } = parsed.data;
|
|
1780
|
+
return { ok: true, pathParams: { cliente_id }, params: fields, files: { file } };
|
|
1781
|
+
};
|
|
1782
|
+
var documentsAddSensitivity = {
|
|
1783
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["file", "descricao"] }],
|
|
1784
|
+
output: []
|
|
1785
|
+
};
|
|
1786
|
+
var documentsAdd = {
|
|
1787
|
+
name: "documents.add",
|
|
1788
|
+
method: "PUT",
|
|
1789
|
+
pathTemplate: "/api/suporte/cliente/{cliente_id}/documento/add/",
|
|
1790
|
+
encoding: "form-files",
|
|
1791
|
+
repeatable: false,
|
|
1792
|
+
write: {},
|
|
1793
|
+
buildRequest: buildRequest16,
|
|
1794
|
+
decode: (body) => body.kind === "empty" ? { ok: true, data: null } : { ok: false, issues: ["(body)"] },
|
|
1795
|
+
sensitivity: documentsAddSensitivity
|
|
1030
1796
|
};
|
|
1031
1797
|
|
|
1032
|
-
// src/
|
|
1798
|
+
// src/operations/documents-list.ts
|
|
1033
1799
|
import { z as z19 } from "zod";
|
|
1034
|
-
var
|
|
1800
|
+
var documentsListInputSchema = z19.strictObject({
|
|
1801
|
+
cliente_id: customerIdSchema.int().positive()
|
|
1802
|
+
});
|
|
1803
|
+
var buildRequest17 = (input) => {
|
|
1804
|
+
const parsed = documentsListInputSchema.safeParse(input);
|
|
1805
|
+
if (!parsed.success)
|
|
1806
|
+
return { ok: false, problem: "invalid documents.list input" };
|
|
1807
|
+
return { ok: true, pathParams: { cliente_id: parsed.data.cliente_id } };
|
|
1808
|
+
};
|
|
1809
|
+
var documentSchema = z19.looseObject({
|
|
1035
1810
|
id: z19.number(),
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
var
|
|
1042
|
-
var
|
|
1043
|
-
var
|
|
1044
|
-
|
|
1045
|
-
path: "
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1811
|
+
cliente_id: customerIdSchema,
|
|
1812
|
+
arquivo: z19.string().optional().nullable(),
|
|
1813
|
+
descricao: z19.string().optional().nullable(),
|
|
1814
|
+
usuario: z19.string().optional().nullable()
|
|
1815
|
+
});
|
|
1816
|
+
var documentsSchema = z19.array(documentSchema);
|
|
1817
|
+
var documentsInvariants = ["[].id", "[].cliente_id"];
|
|
1818
|
+
var documentsListSensitivity = {
|
|
1819
|
+
input: [],
|
|
1820
|
+
output: [{ path: "[]", secretKeys: [], personalKeys: ["arquivo", "descricao", "usuario"] }]
|
|
1821
|
+
};
|
|
1822
|
+
var documentsList = {
|
|
1823
|
+
name: "documents.list",
|
|
1824
|
+
method: "GET",
|
|
1825
|
+
pathTemplate: "/api/suporte/cliente/{cliente_id}/documento/list/",
|
|
1826
|
+
encoding: "json",
|
|
1827
|
+
buildRequest: buildRequest17,
|
|
1828
|
+
repeatable: true,
|
|
1829
|
+
decode: tolerantDecoder(documentsSchema, documentsInvariants),
|
|
1830
|
+
sensitivity: documentsListSensitivity
|
|
1051
1831
|
};
|
|
1052
1832
|
|
|
1053
|
-
// src/
|
|
1833
|
+
// src/operations/experimental-annotations-list.ts
|
|
1054
1834
|
import { z as z20 } from "zod";
|
|
1055
|
-
|
|
1835
|
+
|
|
1836
|
+
// src/annotation-selection.ts
|
|
1837
|
+
var isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
1838
|
+
var NESTED_CUSTOMER = "[].(nested).cliente";
|
|
1839
|
+
var NESTED_CONTRACT = "[].(nested).clientecontrato";
|
|
1840
|
+
var CUSTOMER_KEY = /^(id_?)?clientes?(_?id)?$/i;
|
|
1841
|
+
var CONTRACT_KEY = /^(id_?)?(cliente_?)?contratos?(_?id)?$/i;
|
|
1842
|
+
var isIdentity = (value, expected) => Array.isArray(value) ? value.every((item) => isNumber(item) && item === expected) : isNumber(value) && value === expected;
|
|
1843
|
+
var nestedProblem = (record, { cliente_id: customer, contrato_id: contract }) => {
|
|
1844
|
+
const expectedCustomer = customer ?? record.cliente;
|
|
1845
|
+
const pending = [{ value: record, isTop: true }];
|
|
1846
|
+
while (pending.length > 0) {
|
|
1847
|
+
const { value, isTop } = pending.pop() ?? { value: undefined, isTop: false };
|
|
1848
|
+
const children = Array.isArray(value) ? value : isRecord(value) ? Object.values(value) : [];
|
|
1849
|
+
if (isRecord(value)) {
|
|
1850
|
+
let hasCustomerKey = false;
|
|
1851
|
+
let hasContractKey = false;
|
|
1852
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1853
|
+
if (isTop && (key === "cliente" || key === "clientecontrato"))
|
|
1854
|
+
continue;
|
|
1855
|
+
if (CUSTOMER_KEY.test(key)) {
|
|
1856
|
+
hasCustomerKey = true;
|
|
1857
|
+
if (!isIdentity(item, expectedCustomer))
|
|
1858
|
+
return NESTED_CUSTOMER;
|
|
1859
|
+
} else if (CONTRACT_KEY.test(key)) {
|
|
1860
|
+
hasContractKey = true;
|
|
1861
|
+
if (contract !== undefined && !isIdentity(item, contract))
|
|
1862
|
+
return NESTED_CONTRACT;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
if (!isTop && customer !== undefined && contract === undefined) {
|
|
1866
|
+
if (hasContractKey && !hasCustomerKey)
|
|
1867
|
+
return NESTED_CUSTOMER;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
for (const child of children) {
|
|
1871
|
+
if (typeof child === "object" && child !== null)
|
|
1872
|
+
pending.push({ value: child, isTop: false });
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
return;
|
|
1876
|
+
};
|
|
1877
|
+
var selectAnnotations = (rows, filters) => {
|
|
1878
|
+
const { cliente_id: customer, contrato_id: contract } = filters;
|
|
1879
|
+
const selected = [];
|
|
1880
|
+
for (const row of rows) {
|
|
1881
|
+
const record = isRecord(row) ? row : {};
|
|
1882
|
+
const customerIsNumber = isNumber(record.cliente);
|
|
1883
|
+
const contractIsNumber = isNumber(record.clientecontrato);
|
|
1884
|
+
const customerMismatch = customer !== undefined && customerIsNumber && record.cliente !== customer;
|
|
1885
|
+
const contractMismatch = contract !== undefined && (record.clientecontrato === null || contractIsNumber && record.clientecontrato !== contract);
|
|
1886
|
+
if (customerMismatch || contractMismatch)
|
|
1887
|
+
continue;
|
|
1888
|
+
const undecidable = [];
|
|
1889
|
+
if (customer !== undefined && !customerIsNumber)
|
|
1890
|
+
undecidable.push("[].cliente");
|
|
1891
|
+
if (contract !== undefined && !contractIsNumber)
|
|
1892
|
+
undecidable.push("[].clientecontrato");
|
|
1893
|
+
if (undecidable.length > 0)
|
|
1894
|
+
return { ok: false, paths: undecidable };
|
|
1895
|
+
const nested = nestedProblem(record, filters);
|
|
1896
|
+
if (nested !== undefined)
|
|
1897
|
+
return { ok: false, paths: [nested] };
|
|
1898
|
+
selected.push(row);
|
|
1899
|
+
}
|
|
1900
|
+
return { ok: true, selected };
|
|
1901
|
+
};
|
|
1902
|
+
|
|
1903
|
+
// src/operations/experimental-annotations-list.ts
|
|
1904
|
+
var annotationSchema = z20.looseObject({
|
|
1056
1905
|
id: z20.number(),
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
ocorrencia: z20.string().optional().nullable(),
|
|
1066
|
-
hora_cadastro: z20.string().optional().nullable(),
|
|
1067
|
-
data_agendamento: z20.string().optional().nullable(),
|
|
1068
|
-
hora_agendamento: z20.string().optional().nullable(),
|
|
1069
|
-
data_finalizacao: z20.string().optional().nullable(),
|
|
1070
|
-
hora_finalizacao: z20.string().optional().nullable(),
|
|
1071
|
-
tipo: z20.string().optional().nullable(),
|
|
1072
|
-
motivo: z20.string().optional().nullable(),
|
|
1073
|
-
pop: z20.string().optional().nullable(),
|
|
1074
|
-
conteudo: z20.string().optional().nullable(),
|
|
1075
|
-
responsavel: z20.string().optional().nullable(),
|
|
1076
|
-
tecnicos_auxiliares: z20.array(z20.object({})).optional().nullable(),
|
|
1077
|
-
usuario: z20.string().optional().nullable(),
|
|
1078
|
-
usuario_finalizacao: z20.string().optional().nullable(),
|
|
1079
|
-
classificacoes: z20.array(z20.object({})).optional().nullable()
|
|
1080
|
-
});
|
|
1081
|
-
var listServiceOrdersSchema = z20.object({
|
|
1082
|
-
paginacao: z20.object({
|
|
1083
|
-
offset: z20.number().optional().nullable(),
|
|
1084
|
-
limit: z20.number().optional().nullable(),
|
|
1085
|
-
parcial: z20.number().optional().nullable(),
|
|
1086
|
-
total: z20.number()
|
|
1087
|
-
}),
|
|
1088
|
-
ordens_servicos: z20.array(serviceOrderSchema)
|
|
1906
|
+
cliente: customerIdSchema,
|
|
1907
|
+
clientecontrato: z20.number().nullable(),
|
|
1908
|
+
anotacao: z20.string(),
|
|
1909
|
+
usuario: z20.number().optional().nullable(),
|
|
1910
|
+
tipo: z20.number().optional().nullable(),
|
|
1911
|
+
alerta_modo: z20.number().optional().nullable(),
|
|
1912
|
+
data_cadastro: z20.string().optional().nullable(),
|
|
1913
|
+
data_alteracao: z20.string().optional().nullable()
|
|
1089
1914
|
});
|
|
1090
|
-
var
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
]
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1915
|
+
var annotationsSchema = z20.array(annotationSchema);
|
|
1916
|
+
var annotationInvariants = ["[].id", "[].cliente", "[].clientecontrato", "[].anotacao"];
|
|
1917
|
+
var identity = z20.number().int().positive();
|
|
1918
|
+
var customerIdentity = customerIdSchema.int().positive();
|
|
1919
|
+
var experimentalAnnotationsListInputSchema = z20.strictObject({
|
|
1920
|
+
cliente_id: customerIdentity.optional(),
|
|
1921
|
+
contrato_id: identity.optional()
|
|
1922
|
+
}).refine((filters) => filters.cliente_id !== undefined || filters.contrato_id !== undefined);
|
|
1923
|
+
var experimentalAnnotationsListSensitivity = {
|
|
1924
|
+
input: [],
|
|
1925
|
+
output: [
|
|
1926
|
+
{
|
|
1927
|
+
path: "[]",
|
|
1928
|
+
secretKeys: [],
|
|
1929
|
+
personalKeys: ["anotacao", "usuario", "raw"]
|
|
1930
|
+
}
|
|
1931
|
+
]
|
|
1932
|
+
};
|
|
1933
|
+
var NAME = "experimental.annotations.list";
|
|
1934
|
+
var refuseWithoutFilters = () => ({
|
|
1935
|
+
ok: false,
|
|
1936
|
+
problem: "experimental.annotations.list needs a positive cliente_id and/or contrato_id"
|
|
1937
|
+
});
|
|
1938
|
+
var failClosed = () => ({
|
|
1939
|
+
ok: false,
|
|
1940
|
+
issues: ["(filters)"]
|
|
1941
|
+
});
|
|
1942
|
+
var base = {
|
|
1943
|
+
name: NAME,
|
|
1944
|
+
method: "GET",
|
|
1945
|
+
pathTemplate: "/api/ura/cliente/anotacao/list/",
|
|
1946
|
+
encoding: "json",
|
|
1947
|
+
sensitivity: experimentalAnnotationsListSensitivity,
|
|
1948
|
+
exposure: { body: "withhold", sgp: "strings-only" },
|
|
1949
|
+
repeatable: true
|
|
1950
|
+
};
|
|
1951
|
+
var experimentalAnnotationsList = { ...base, buildRequest: refuseWithoutFilters, decode: failClosed };
|
|
1952
|
+
var decodeSelection = tolerantDecoder(annotationsSchema, annotationInvariants);
|
|
1953
|
+
var decodeSelected = (filters) => (body) => {
|
|
1954
|
+
if (body.kind !== "json")
|
|
1955
|
+
return { ok: false, issues: ["(body)"] };
|
|
1956
|
+
if (!Array.isArray(body.value))
|
|
1957
|
+
return { ok: false, issues: ["(root)"] };
|
|
1958
|
+
const rows = body.value;
|
|
1959
|
+
const selection = selectAnnotations(rows, filters);
|
|
1960
|
+
if (!selection.ok)
|
|
1961
|
+
return { ok: false, issues: selection.paths };
|
|
1962
|
+
const decoded = decodeSelection({ kind: "json", value: selection.selected });
|
|
1963
|
+
if (!decoded.ok)
|
|
1964
|
+
return decoded;
|
|
1965
|
+
const data = [];
|
|
1966
|
+
for (const [index, typed] of decoded.data.entries()) {
|
|
1967
|
+
const raw = structuredClone(selection.selected[index]);
|
|
1968
|
+
if (!isRecord(raw))
|
|
1969
|
+
return { ok: false, issues: [`[${index}]`] };
|
|
1970
|
+
data.push({ ...typed, raw });
|
|
1971
|
+
}
|
|
1972
|
+
return decoded.warnings === undefined ? { ok: true, data } : { ok: true, data, warnings: decoded.warnings };
|
|
1973
|
+
};
|
|
1974
|
+
var annotationsListForCall = () => {
|
|
1975
|
+
let decode2 = failClosed;
|
|
1976
|
+
return {
|
|
1977
|
+
...base,
|
|
1978
|
+
buildRequest: (input) => {
|
|
1979
|
+
const parsed = experimentalAnnotationsListInputSchema.safeParse(input);
|
|
1980
|
+
if (!parsed.success)
|
|
1981
|
+
return refuseWithoutFilters();
|
|
1982
|
+
decode2 = decodeSelected(parsed.data);
|
|
1983
|
+
return { ok: true, params: parsed.data };
|
|
1984
|
+
},
|
|
1985
|
+
decode: (body) => decode2(body)
|
|
1986
|
+
};
|
|
1111
1987
|
};
|
|
1112
1988
|
|
|
1113
|
-
// src/
|
|
1989
|
+
// src/operations/invoices-list.ts
|
|
1114
1990
|
import { z as z21 } from "zod";
|
|
1115
|
-
var
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
var
|
|
1204
|
-
|
|
1205
|
-
"contratoCentralLogin",
|
|
1206
|
-
"contratoCentralSenha",
|
|
1207
|
-
"servico_login",
|
|
1208
|
-
"servico_senha",
|
|
1209
|
-
"servico_wifi_password",
|
|
1210
|
-
"servico_wifi_password_5",
|
|
1211
|
-
"servico_wifi_ssid",
|
|
1212
|
-
"servico_wifi_ssid_5",
|
|
1213
|
-
"servico_mac",
|
|
1214
|
-
"servico_mac2",
|
|
1215
|
-
"link_quitacao"
|
|
1216
|
-
];
|
|
1217
|
-
var customerContractPersonalKeys = [
|
|
1218
|
-
"motivo_status",
|
|
1219
|
-
"razaoSocial",
|
|
1220
|
-
"cpfCnpj",
|
|
1221
|
-
"dataNascimento",
|
|
1222
|
-
"telefones",
|
|
1223
|
-
"telefones_cargos",
|
|
1224
|
-
"emails",
|
|
1225
|
-
"outros",
|
|
1226
|
-
"anotacoes",
|
|
1227
|
-
"endereco_logradouro",
|
|
1228
|
-
"endereco_numero",
|
|
1229
|
-
"endereco_complemento",
|
|
1230
|
-
"endereco_bairro",
|
|
1231
|
-
"endereco_cidade",
|
|
1232
|
-
"endereco_uf",
|
|
1233
|
-
"endereco_cep",
|
|
1234
|
-
"endereco_pontoreferencia",
|
|
1235
|
-
"endereco_ll"
|
|
1236
|
-
];
|
|
1237
|
-
var lookupCustomerDefinition = {
|
|
1991
|
+
var agreementSchema = z21.looseObject({
|
|
1992
|
+
acordados: z21.array(z21.unknown()).optional().nullable(),
|
|
1993
|
+
cobrados: z21.array(z21.unknown()).optional().nullable()
|
|
1994
|
+
});
|
|
1995
|
+
var invoiceSchema = z21.looseObject({
|
|
1996
|
+
id: z21.number(),
|
|
1997
|
+
status: z21.string().optional().nullable(),
|
|
1998
|
+
valor: z21.number().optional().nullable(),
|
|
1999
|
+
dataVencimento: z21.string().optional().nullable(),
|
|
2000
|
+
clienteNome: z21.string().optional().nullable(),
|
|
2001
|
+
clienteCpfcnpj: z21.string().optional().nullable(),
|
|
2002
|
+
clienteContrato: z21.number().optional().nullable(),
|
|
2003
|
+
portador: z21.string().optional().nullable(),
|
|
2004
|
+
numeroDocumento: z21.union([z21.number(), z21.string()]).optional().nullable(),
|
|
2005
|
+
nossoNumero: z21.string().optional().nullable(),
|
|
2006
|
+
link: z21.string().optional().nullable(),
|
|
2007
|
+
link_cobranca: z21.string().optional().nullable(),
|
|
2008
|
+
valorDesconto: z21.number().optional().nullable(),
|
|
2009
|
+
valorCorrigido: z21.number().optional().nullable(),
|
|
2010
|
+
valorPago: z21.number().optional().nullable(),
|
|
2011
|
+
valorPagoParcial: z21.number().optional().nullable(),
|
|
2012
|
+
codigoBarras: z21.string().optional().nullable(),
|
|
2013
|
+
linhaDigitavel: z21.string().optional().nullable(),
|
|
2014
|
+
codigoPix: z21.string().optional().nullable(),
|
|
2015
|
+
dataEmissao: z21.string().optional().nullable(),
|
|
2016
|
+
dataPagamento: z21.string().optional().nullable(),
|
|
2017
|
+
dataCancelamento: z21.string().optional().nullable(),
|
|
2018
|
+
demonstrativo: z21.string().optional().nullable(),
|
|
2019
|
+
acordoPagamento: agreementSchema.optional().nullable(),
|
|
2020
|
+
formaPagamento: z21.string().optional().nullable(),
|
|
2021
|
+
usuario_baixa: z21.string().optional().nullable()
|
|
2022
|
+
});
|
|
2023
|
+
var pageSchema2 = z21.looseObject({
|
|
2024
|
+
paginacao: z21.looseObject({
|
|
2025
|
+
offset: z21.number().optional().nullable(),
|
|
2026
|
+
limit: z21.number().optional().nullable(),
|
|
2027
|
+
parcial: z21.number().optional().nullable(),
|
|
2028
|
+
total: z21.number()
|
|
2029
|
+
}),
|
|
2030
|
+
titulos: z21.array(invoiceSchema)
|
|
2031
|
+
});
|
|
2032
|
+
var pageInvariants2 = ["paginacao", "paginacao.total", "titulos", "titulos[].id"];
|
|
2033
|
+
var invoicesListInputSchema = z21.strictObject({
|
|
2034
|
+
offset: z21.number().int().nonnegative().optional(),
|
|
2035
|
+
limit: z21.number().int().nonnegative().optional(),
|
|
2036
|
+
titulo_id: z21.number().int().optional(),
|
|
2037
|
+
cliente_id: customerIdSchema.int().optional(),
|
|
2038
|
+
cpfcnpj: z21.string().optional(),
|
|
2039
|
+
contrato: z21.number().int().optional(),
|
|
2040
|
+
status: z21.enum(["abertos", "pagos", "cancelados"]).optional(),
|
|
2041
|
+
portador: z21.number().int().optional(),
|
|
2042
|
+
ordenar: z21.enum(["data_documento", "data_vencimento", "data_pagamento"]).optional(),
|
|
2043
|
+
ordenar_ordem: z21.enum(["asc", "desc"]).optional(),
|
|
2044
|
+
empresa_cnpj: z21.string().optional(),
|
|
2045
|
+
tipo_pessoa: z21.enum(["F", "J", "E", "EJ"]).optional(),
|
|
2046
|
+
data_vencimento_inicio: z21.string().optional(),
|
|
2047
|
+
data_vencimento_fim: z21.string().optional(),
|
|
2048
|
+
data_pagamento_inicio: z21.string().optional(),
|
|
2049
|
+
data_pagamento_fim: z21.string().optional(),
|
|
2050
|
+
data_cancelamento_inicio: z21.string().optional(),
|
|
2051
|
+
data_cancelamento_fim: z21.string().optional(),
|
|
2052
|
+
data_acordo_inicio: z21.string().optional(),
|
|
2053
|
+
data_acordo_fim: z21.string().optional()
|
|
2054
|
+
});
|
|
2055
|
+
var buildRequest18 = (input) => {
|
|
2056
|
+
const parsed = invoicesListInputSchema.safeParse(input);
|
|
2057
|
+
if (!parsed.success)
|
|
2058
|
+
return { ok: false, problem: "invalid invoices.list input" };
|
|
2059
|
+
return { ok: true, params: parsed.data };
|
|
2060
|
+
};
|
|
2061
|
+
var invoicesListSensitivity = {
|
|
2062
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["cpfcnpj"] }],
|
|
2063
|
+
output: [
|
|
2064
|
+
{
|
|
2065
|
+
path: "titulos[]",
|
|
2066
|
+
secretKeys: [],
|
|
2067
|
+
personalKeys: [
|
|
2068
|
+
"clienteNome",
|
|
2069
|
+
"clienteCpfcnpj",
|
|
2070
|
+
"demonstrativo",
|
|
2071
|
+
"link",
|
|
2072
|
+
"link_cobranca",
|
|
2073
|
+
"codigoPix",
|
|
2074
|
+
"usuario_baixa"
|
|
2075
|
+
]
|
|
2076
|
+
}
|
|
2077
|
+
]
|
|
2078
|
+
};
|
|
2079
|
+
var invoicesList = {
|
|
2080
|
+
name: "invoices.list",
|
|
1238
2081
|
method: "POST",
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
2082
|
+
pathTemplate: "/api/ura/titulos/",
|
|
2083
|
+
encoding: "json",
|
|
2084
|
+
buildRequest: buildRequest18,
|
|
2085
|
+
repeatable: true,
|
|
2086
|
+
decode: tolerantDecoder(pageSchema2, pageInvariants2),
|
|
2087
|
+
sensitivity: invoicesListSensitivity
|
|
1245
2088
|
};
|
|
1246
2089
|
|
|
1247
|
-
// src/
|
|
2090
|
+
// src/operations/occurrences-create.ts
|
|
1248
2091
|
import { z as z22 } from "zod";
|
|
1249
|
-
var
|
|
2092
|
+
var id4 = z22.number().int().nonnegative();
|
|
2093
|
+
var flag = z22.union([z22.literal(0), z22.literal(1)]);
|
|
2094
|
+
var occurrencesCreateInputSchema = z22.strictObject({
|
|
2095
|
+
contrato: z22.number().int().positive(),
|
|
2096
|
+
conteudo: z22.string().optional(),
|
|
2097
|
+
conteudolimpo: flag.optional(),
|
|
2098
|
+
observacao: z22.string().optional(),
|
|
2099
|
+
ocorrenciatipo: id4.optional(),
|
|
2100
|
+
tipoclassificacoes: z22.array(id4).optional(),
|
|
2101
|
+
metodo: id4.optional(),
|
|
2102
|
+
setor: id4.optional(),
|
|
2103
|
+
usuario: z22.string().optional(),
|
|
2104
|
+
responsaveloc: z22.string().optional(),
|
|
2105
|
+
contato_nome: z22.string().optional(),
|
|
2106
|
+
contato_telefone: z22.string().optional(),
|
|
2107
|
+
desativa_os: flag.optional(),
|
|
2108
|
+
status_encerrado: flag.optional(),
|
|
2109
|
+
notificar_cliente: flag.optional(),
|
|
2110
|
+
motivoos: id4.optional(),
|
|
2111
|
+
motivoclassificacoes: z22.array(id4).optional(),
|
|
2112
|
+
responsavel: z22.string().optional(),
|
|
2113
|
+
tecnicos: z22.array(z22.string()).optional(),
|
|
2114
|
+
data_hora_agendamento: z22.string().optional(),
|
|
2115
|
+
sms_tecnico: flag.optional(),
|
|
2116
|
+
tipo_servico: z22.enum(["internet", "telefonia", "tv", "multimidia", "generico"]).optional(),
|
|
2117
|
+
servico_id: id4.optional(),
|
|
2118
|
+
empresa_id: id4.optional()
|
|
2119
|
+
});
|
|
2120
|
+
var buildRequest19 = (input) => {
|
|
2121
|
+
const parsed = occurrencesCreateInputSchema.safeParse(input);
|
|
2122
|
+
if (!parsed.success)
|
|
2123
|
+
return { ok: false, problem: "invalid occurrences.create input" };
|
|
2124
|
+
return { ok: true, params: parsed.data };
|
|
2125
|
+
};
|
|
2126
|
+
var detectRefusal = (body) => body.kind === "json" && isRecord(body.value) && body.value.status === 0 ? {} : undefined;
|
|
2127
|
+
var openedSchema = z22.looseObject({
|
|
1250
2128
|
status: z22.literal(1),
|
|
1251
2129
|
protocolo: z22.string(),
|
|
1252
2130
|
id: z22.number(),
|
|
@@ -1255,195 +2133,972 @@ var openTicketSchema = z22.object({
|
|
|
1255
2133
|
cpfCnpj: z22.string().optional().nullable(),
|
|
1256
2134
|
msg: z22.string().optional().nullable()
|
|
1257
2135
|
});
|
|
1258
|
-
var
|
|
1259
|
-
var
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
2136
|
+
var openedInvariants = ["status", "protocolo", "id"];
|
|
2137
|
+
var occurrencesCreateSensitivity = {
|
|
2138
|
+
input: [
|
|
2139
|
+
{
|
|
2140
|
+
path: "",
|
|
2141
|
+
secretKeys: [],
|
|
2142
|
+
personalKeys: [
|
|
2143
|
+
"conteudo",
|
|
2144
|
+
"observacao",
|
|
2145
|
+
"contato_nome",
|
|
2146
|
+
"contato_telefone",
|
|
2147
|
+
"usuario",
|
|
2148
|
+
"responsaveloc",
|
|
2149
|
+
"responsavel",
|
|
2150
|
+
"tecnicos"
|
|
2151
|
+
]
|
|
2152
|
+
}
|
|
2153
|
+
],
|
|
2154
|
+
output: [{ path: "", secretKeys: [], personalKeys: ["razaoSocial", "cpfCnpj"] }]
|
|
2155
|
+
};
|
|
2156
|
+
var occurrencesCreate = {
|
|
2157
|
+
name: "occurrences.create",
|
|
1264
2158
|
method: "POST",
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
2159
|
+
pathTemplate: "/api/ura/chamado/",
|
|
2160
|
+
encoding: "json",
|
|
2161
|
+
repeatable: false,
|
|
2162
|
+
write: {},
|
|
2163
|
+
buildRequest: buildRequest19,
|
|
2164
|
+
detectRefusal,
|
|
2165
|
+
decode: tolerantDecoder(openedSchema, openedInvariants),
|
|
2166
|
+
sensitivity: occurrencesCreateSensitivity
|
|
1271
2167
|
};
|
|
1272
2168
|
|
|
1273
|
-
// src/
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
2169
|
+
// src/operations/occurrences-list-methods.ts
|
|
2170
|
+
import { z as z23 } from "zod";
|
|
2171
|
+
var occurrenceMethodSchema = z23.looseObject({
|
|
2172
|
+
codigo: z23.number(),
|
|
2173
|
+
descricao: z23.string().optional().nullable()
|
|
2174
|
+
});
|
|
2175
|
+
var occurrenceMethodsSchema = z23.array(occurrenceMethodSchema);
|
|
2176
|
+
var occurrenceMethodsInvariants = ["[].codigo"];
|
|
2177
|
+
var buildRequest20 = () => ({ ok: true });
|
|
2178
|
+
var occurrencesListMethodsSensitivity = { input: [], output: [] };
|
|
2179
|
+
var occurrencesListMethods = {
|
|
2180
|
+
name: "occurrences.listMethods",
|
|
2181
|
+
method: "GET",
|
|
2182
|
+
pathTemplate: "/api/ura/ocorrencia/metodo/list/",
|
|
2183
|
+
encoding: "json",
|
|
2184
|
+
buildRequest: buildRequest20,
|
|
2185
|
+
repeatable: true,
|
|
2186
|
+
decode: tolerantDecoder(occurrenceMethodsSchema, occurrenceMethodsInvariants),
|
|
2187
|
+
sensitivity: occurrencesListMethodsSensitivity
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
// src/operations/occurrences-list-types.ts
|
|
2191
|
+
import { z as z24 } from "zod";
|
|
2192
|
+
var occurrenceTypeSchema = z24.looseObject({
|
|
2193
|
+
id: z24.number(),
|
|
2194
|
+
codigo: z24.number(),
|
|
2195
|
+
descricao: z24.string().optional().nullable(),
|
|
2196
|
+
ativo: z24.boolean().optional().nullable(),
|
|
2197
|
+
classificacoes: z24.array(z24.unknown()).optional().nullable(),
|
|
2198
|
+
classificacoes_obrigatorio: z24.boolean().optional().nullable(),
|
|
2199
|
+
setores: z24.array(z24.unknown()).optional().nullable(),
|
|
2200
|
+
classificacoes_obrigatorio_encerramento: z24.boolean().optional().nullable()
|
|
2201
|
+
});
|
|
2202
|
+
var occurrenceTypesSchema = z24.array(occurrenceTypeSchema);
|
|
2203
|
+
var occurrenceTypesInvariants = ["[].id", "[].codigo"];
|
|
2204
|
+
var buildRequest21 = () => ({ ok: true });
|
|
2205
|
+
var occurrencesListTypesSensitivity = { input: [], output: [] };
|
|
2206
|
+
var occurrencesListTypes = {
|
|
2207
|
+
name: "occurrences.listTypes",
|
|
2208
|
+
method: "GET",
|
|
2209
|
+
pathTemplate: "/api/os/ocorrencia/tipo/list/",
|
|
2210
|
+
encoding: "json",
|
|
2211
|
+
buildRequest: buildRequest21,
|
|
2212
|
+
repeatable: true,
|
|
2213
|
+
decode: tolerantDecoder(occurrenceTypesSchema, occurrenceTypesInvariants),
|
|
2214
|
+
sensitivity: occurrencesListTypesSensitivity
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
// src/operations/plans-list.ts
|
|
2218
|
+
import { z as z25 } from "zod";
|
|
2219
|
+
var popSchema2 = z25.looseObject({
|
|
2220
|
+
id: z25.number().optional().nullable(),
|
|
2221
|
+
uf: z25.string().optional().nullable(),
|
|
2222
|
+
pop: z25.string().optional().nullable()
|
|
2223
|
+
});
|
|
2224
|
+
var planSchema2 = z25.looseObject({
|
|
2225
|
+
id: z25.number().brand(),
|
|
2226
|
+
descricao: z25.string().optional().nullable(),
|
|
2227
|
+
preco: z25.number().optional().nullable(),
|
|
2228
|
+
ativo: z25.boolean().optional().nullable(),
|
|
2229
|
+
grupo: z25.string().optional().nullable(),
|
|
2230
|
+
tipo: z25.string().optional().nullable(),
|
|
2231
|
+
pos_pago: z25.boolean().optional().nullable(),
|
|
2232
|
+
desconto: z25.number().optional().nullable(),
|
|
2233
|
+
desconto_venc: z25.number().optional().nullable(),
|
|
2234
|
+
desconto_venc_modo: z25.string().optional().nullable(),
|
|
2235
|
+
valor_desconto_temporario: z25.number().optional().nullable(),
|
|
2236
|
+
desconto_temporario_modo: z25.string().optional().nullable(),
|
|
2237
|
+
desconto_temporario_quantidade: z25.number().optional().nullable(),
|
|
2238
|
+
descricao_desconto_temporario: z25.string().optional().nullable(),
|
|
2239
|
+
desconto_temporario_proporcional: z25.boolean().optional().nullable(),
|
|
2240
|
+
observacao: z25.string().optional().nullable(),
|
|
2241
|
+
instalacao_qtd_parcelas: z25.number().optional().nullable(),
|
|
2242
|
+
instalacao_valor: z25.number().optional().nullable(),
|
|
2243
|
+
instalacao_desconto_max: z25.number().optional().nullable(),
|
|
2244
|
+
instalacao_desconto_min: z25.number().optional().nullable(),
|
|
2245
|
+
disponivel_pre_cadastro: z25.boolean().optional().nullable(),
|
|
2246
|
+
disponivel_pre_cadastro_publico: z25.boolean().optional().nullable(),
|
|
2247
|
+
data_validade: z25.string().optional().nullable(),
|
|
2248
|
+
pops: z25.array(popSchema2).optional().nullable(),
|
|
2249
|
+
auto_bloqueio: z25.boolean().optional().nullable(),
|
|
2250
|
+
dias_bloqueio_pos_venc: z25.number().optional().nullable(),
|
|
2251
|
+
dias_bloqueio_aviso: z25.number().optional().nullable(),
|
|
2252
|
+
dias_reducao_velocidade: z25.number().optional().nullable(),
|
|
2253
|
+
download: z25.number().optional().nullable(),
|
|
2254
|
+
upload: z25.number().optional().nullable(),
|
|
2255
|
+
trafego_mensal: z25.number().optional().nullable(),
|
|
2256
|
+
contabilizacao_trafego_mensal: z25.string().optional().nullable(),
|
|
2257
|
+
trafego_excedente_acao: z25.string().optional().nullable(),
|
|
2258
|
+
valor_trafego_excedido: z25.number().optional().nullable(),
|
|
2259
|
+
duplicacao_noturna: z25.boolean().optional().nullable(),
|
|
2260
|
+
inicio_duplicacao_noturna: z25.string().optional().nullable(),
|
|
2261
|
+
fim_duplicacao_noturna: z25.string().optional().nullable(),
|
|
2262
|
+
modo_velocidade_reduzida: z25.string().optional().nullable(),
|
|
2263
|
+
download_red_financeiro: z25.number().optional().nullable(),
|
|
2264
|
+
upload_red_financeiro: z25.number().optional().nullable(),
|
|
2265
|
+
modo_velocidade_red_franquia: z25.string().optional().nullable(),
|
|
2266
|
+
download_red_franquia: z25.number().optional().nullable(),
|
|
2267
|
+
upload_red_franquia: z25.number().optional().nullable(),
|
|
2268
|
+
combo: z25.array(z25.unknown()).optional().nullable(),
|
|
2269
|
+
qtd_servicos: z25.number().optional().nullable()
|
|
2270
|
+
});
|
|
2271
|
+
var catalogSchema = z25.looseObject({
|
|
2272
|
+
planos: z25.array(planSchema2),
|
|
2273
|
+
total_planos: z25.number().optional().nullable(),
|
|
2274
|
+
total_qtd_servicos: z25.number().optional().nullable()
|
|
2275
|
+
});
|
|
2276
|
+
var catalogInvariants = ["planos", "planos[].id"];
|
|
2277
|
+
var buildRequest22 = () => ({ ok: true });
|
|
2278
|
+
var plansListSensitivity = { input: [], output: [] };
|
|
2279
|
+
var plansList = {
|
|
2280
|
+
name: "plans.list",
|
|
2281
|
+
method: "GET",
|
|
2282
|
+
pathTemplate: "/api/ura/consultaplano/",
|
|
2283
|
+
encoding: "json",
|
|
2284
|
+
buildRequest: buildRequest22,
|
|
2285
|
+
repeatable: true,
|
|
2286
|
+
decode: tolerantDecoder(catalogSchema, catalogInvariants),
|
|
2287
|
+
sensitivity: plansListSensitivity
|
|
2288
|
+
};
|
|
2289
|
+
|
|
2290
|
+
// src/operations/pre-registrations-create.ts
|
|
2291
|
+
import { z as z26 } from "zod";
|
|
2292
|
+
var id5 = z26.number().int().nonnegative();
|
|
2293
|
+
var amount2 = z26.number().nonnegative();
|
|
2294
|
+
var commonShape2 = {
|
|
2295
|
+
nome: nonBlank,
|
|
2296
|
+
cpfcnpj: z26.string().optional(),
|
|
2297
|
+
...addressShape,
|
|
2298
|
+
logradouro: nonBlank,
|
|
2299
|
+
email: z26.string().optional(),
|
|
2300
|
+
celular: z26.string().optional(),
|
|
2301
|
+
datanasc: z26.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
2302
|
+
observacao: z26.string().optional(),
|
|
2303
|
+
usuariocad_id: id5.optional(),
|
|
2304
|
+
precadastro_ativar: z26.literal(1).optional(),
|
|
2305
|
+
pop_id: id5.optional(),
|
|
2306
|
+
portador_id: id5.optional(),
|
|
2307
|
+
nas_id: id5.optional(),
|
|
2308
|
+
plano_id: id5.brand().optional(),
|
|
2309
|
+
vencimento_id: id5.optional(),
|
|
2310
|
+
formacobranca_id: id5.optional(),
|
|
2311
|
+
fidelidade_id: id5.optional(),
|
|
2312
|
+
login: z26.string().optional(),
|
|
2313
|
+
senha: z26.string().optional(),
|
|
2314
|
+
central_senha: z26.string().optional(),
|
|
2315
|
+
modoaquisicao: z26.union([z26.literal(0), z26.literal(1)]).optional(),
|
|
2316
|
+
servicodesc: z26.string().optional(),
|
|
2317
|
+
midia_id: id5.optional(),
|
|
2318
|
+
vendedor_id: id5.optional(),
|
|
2319
|
+
tecnico_id: id5.optional(),
|
|
2320
|
+
os_instalacao: z26.literal(1).optional(),
|
|
2321
|
+
instalacao_preco: amount2.optional(),
|
|
2322
|
+
instalacao_desconto: amount2.optional(),
|
|
2323
|
+
instalacao_entrada: amount2.optional(),
|
|
2324
|
+
instalacao_quantidade_parcelas: id5.optional(),
|
|
2325
|
+
instalacao_entrada_forma: id5.optional(),
|
|
2326
|
+
instalacao_parcela_forma: id5.optional()
|
|
2327
|
+
};
|
|
2328
|
+
var preRegistrationsCreateInputSchema = z26.discriminatedUnion("personType", [
|
|
2329
|
+
z26.strictObject({
|
|
2330
|
+
personType: z26.literal("F"),
|
|
2331
|
+
...commonShape2,
|
|
2332
|
+
rg: z26.string().optional(),
|
|
2333
|
+
rg_emissor: z26.string().optional(),
|
|
2334
|
+
nomepai: z26.string().optional(),
|
|
2335
|
+
nomemae: z26.string().optional(),
|
|
2336
|
+
nacionalidade: z26.string().optional(),
|
|
2337
|
+
naturalidade: z26.string().optional(),
|
|
2338
|
+
estadocivil: z26.enum(["S", "C", "D", "V"]).optional(),
|
|
2339
|
+
sexo: z26.enum(["M", "F"]).optional(),
|
|
2340
|
+
profissao: z26.string().optional()
|
|
2341
|
+
}),
|
|
2342
|
+
z26.strictObject({
|
|
2343
|
+
personType: z26.literal("J"),
|
|
2344
|
+
...commonShape2,
|
|
2345
|
+
nomefantasia: z26.string().optional(),
|
|
2346
|
+
respempresa: z26.string().optional(),
|
|
2347
|
+
respcpf: z26.string().optional()
|
|
2348
|
+
})
|
|
2349
|
+
]);
|
|
2350
|
+
var buildRequest23 = (input) => {
|
|
2351
|
+
const parsed = preRegistrationsCreateInputSchema.safeParse(input);
|
|
2352
|
+
if (!parsed.success)
|
|
2353
|
+
return { ok: false, problem: "invalid preRegistrations.create input" };
|
|
2354
|
+
const {
|
|
2355
|
+
personType,
|
|
2356
|
+
logradouro,
|
|
2357
|
+
numero,
|
|
2358
|
+
complemento,
|
|
2359
|
+
bairro,
|
|
2360
|
+
cidade,
|
|
2361
|
+
cep,
|
|
2362
|
+
uf,
|
|
2363
|
+
pais,
|
|
2364
|
+
pontoreferencia,
|
|
2365
|
+
map_ll,
|
|
2366
|
+
condominio,
|
|
2367
|
+
...fields
|
|
2368
|
+
} = parsed.data;
|
|
2369
|
+
const address = {
|
|
2370
|
+
logradouro,
|
|
2371
|
+
numero,
|
|
2372
|
+
complemento,
|
|
2373
|
+
bairro,
|
|
2374
|
+
cidade,
|
|
2375
|
+
cep,
|
|
2376
|
+
uf,
|
|
2377
|
+
pais,
|
|
2378
|
+
pontoreferencia,
|
|
2379
|
+
map_ll,
|
|
2380
|
+
condominio
|
|
2381
|
+
};
|
|
2382
|
+
return {
|
|
2383
|
+
ok: true,
|
|
2384
|
+
pathParams: { personType },
|
|
2385
|
+
params: { ...fields, ...flatAddress(address) }
|
|
2386
|
+
};
|
|
2387
|
+
};
|
|
2388
|
+
var createdSchema2 = z26.looseObject({ message: z26.string() });
|
|
2389
|
+
var createdInvariants2 = ["message"];
|
|
2390
|
+
var DOCUMENT_ALREADY_REGISTERED_TEXT = /^já existe um cliente com o cpf informado\.?$/i;
|
|
2391
|
+
var documentAlreadyRegistered = errorStringRejection(402, DOCUMENT_ALREADY_REGISTERED_TEXT, "DOCUMENT_ALREADY_REGISTERED");
|
|
2392
|
+
var preRegistrationsCreateSensitivity = {
|
|
2393
|
+
input: [
|
|
2394
|
+
{
|
|
2395
|
+
path: "",
|
|
2396
|
+
secretKeys: ["senha", "central_senha", "login"],
|
|
2397
|
+
personalKeys: [
|
|
2398
|
+
"nome",
|
|
2399
|
+
"cpfcnpj",
|
|
2400
|
+
"logradouro",
|
|
2401
|
+
"numero",
|
|
2402
|
+
"complemento",
|
|
2403
|
+
"bairro",
|
|
2404
|
+
"cidade",
|
|
2405
|
+
"cep",
|
|
2406
|
+
"uf",
|
|
2407
|
+
"pais",
|
|
2408
|
+
"pontoreferencia",
|
|
2409
|
+
"map_ll",
|
|
2410
|
+
"condominio",
|
|
2411
|
+
"email",
|
|
2412
|
+
"celular",
|
|
2413
|
+
"datanasc",
|
|
2414
|
+
"observacao",
|
|
2415
|
+
"servicodesc",
|
|
2416
|
+
"rg",
|
|
2417
|
+
"rg_emissor",
|
|
2418
|
+
"nomepai",
|
|
2419
|
+
"nomemae",
|
|
2420
|
+
"nacionalidade",
|
|
2421
|
+
"naturalidade",
|
|
2422
|
+
"estadocivil",
|
|
2423
|
+
"sexo",
|
|
2424
|
+
"profissao",
|
|
2425
|
+
"nomefantasia",
|
|
2426
|
+
"respempresa",
|
|
2427
|
+
"respcpf"
|
|
2428
|
+
]
|
|
2429
|
+
}
|
|
2430
|
+
],
|
|
2431
|
+
output: []
|
|
2432
|
+
};
|
|
2433
|
+
var preRegistrationsCreate = {
|
|
2434
|
+
name: "preRegistrations.create",
|
|
2435
|
+
method: "POST",
|
|
2436
|
+
pathTemplate: "/api/precadastro/{personType}",
|
|
2437
|
+
encoding: "form",
|
|
2438
|
+
repeatable: false,
|
|
2439
|
+
write: { knownRejections: [documentAlreadyRegistered] },
|
|
2440
|
+
buildRequest: buildRequest23,
|
|
2441
|
+
decode: tolerantDecoder(createdSchema2, createdInvariants2),
|
|
2442
|
+
sensitivity: preRegistrationsCreateSensitivity
|
|
2443
|
+
};
|
|
2444
|
+
|
|
2445
|
+
// src/operations/pre-registrations-list-due-days.ts
|
|
2446
|
+
import { z as z27 } from "zod";
|
|
2447
|
+
var dueDaySchema = z27.looseObject({
|
|
2448
|
+
id: z27.number(),
|
|
2449
|
+
dia: z27.number().optional().nullable()
|
|
2450
|
+
});
|
|
2451
|
+
var dueDaysSchema = z27.array(dueDaySchema);
|
|
2452
|
+
var dueDaysInvariants = ["[].id"];
|
|
2453
|
+
var buildRequest24 = () => ({ ok: true });
|
|
2454
|
+
var preRegistrationsListDueDaysSensitivity = { input: [], output: [] };
|
|
2455
|
+
var preRegistrationsListDueDays = {
|
|
2456
|
+
name: "preRegistrations.listDueDays",
|
|
2457
|
+
method: "POST",
|
|
2458
|
+
pathTemplate: "/api/precadastro/vencimento/list",
|
|
2459
|
+
encoding: "json",
|
|
2460
|
+
buildRequest: buildRequest24,
|
|
2461
|
+
repeatable: true,
|
|
2462
|
+
decode: tolerantDecoder(dueDaysSchema, dueDaysInvariants),
|
|
2463
|
+
sensitivity: preRegistrationsListDueDaysSensitivity
|
|
2464
|
+
};
|
|
2465
|
+
|
|
2466
|
+
// src/operations/pre-registrations-list-plans.ts
|
|
2467
|
+
import { z as z28 } from "zod";
|
|
2468
|
+
var gatewaySchema = z28.looseObject({
|
|
2469
|
+
gateway_id: z28.union([z28.string(), z28.number()]).optional().nullable(),
|
|
2470
|
+
id: z28.union([z28.string(), z28.number()]).optional().nullable(),
|
|
2471
|
+
descricao: z28.string().optional().nullable()
|
|
2472
|
+
});
|
|
2473
|
+
var preRegistrationPlanSchema = z28.looseObject({
|
|
2474
|
+
id: z28.number().brand(),
|
|
2475
|
+
tipo: z28.string().optional().nullable(),
|
|
2476
|
+
valor: z28.number().optional().nullable(),
|
|
2477
|
+
descricao: z28.string().optional().nullable(),
|
|
2478
|
+
observacao: z28.string().optional().nullable(),
|
|
2479
|
+
gateway: gatewaySchema.optional().nullable()
|
|
2480
|
+
});
|
|
2481
|
+
var preRegistrationPlansSchema = z28.array(preRegistrationPlanSchema);
|
|
2482
|
+
var preRegistrationPlansInvariants = ["[].id"];
|
|
2483
|
+
var buildRequest25 = () => ({ ok: true });
|
|
2484
|
+
var preRegistrationsListPlansSensitivity = { input: [], output: [] };
|
|
2485
|
+
var preRegistrationsListPlans = {
|
|
2486
|
+
name: "preRegistrations.listPlans",
|
|
2487
|
+
method: "POST",
|
|
2488
|
+
pathTemplate: "/api/precadastro/plano/list",
|
|
2489
|
+
encoding: "form",
|
|
2490
|
+
buildRequest: buildRequest25,
|
|
2491
|
+
repeatable: true,
|
|
2492
|
+
decode: tolerantDecoder(preRegistrationPlansSchema, preRegistrationPlansInvariants),
|
|
2493
|
+
sensitivity: preRegistrationsListPlansSensitivity
|
|
2494
|
+
};
|
|
2495
|
+
|
|
2496
|
+
// src/operations/pre-registrations-list-sellers.ts
|
|
2497
|
+
import { z as z29 } from "zod";
|
|
2498
|
+
var sellerSchema = z29.looseObject({
|
|
2499
|
+
id: z29.number(),
|
|
2500
|
+
nome: z29.string().optional().nullable(),
|
|
2501
|
+
cpf: z29.string().optional().nullable(),
|
|
2502
|
+
email: z29.string().optional().nullable()
|
|
2503
|
+
});
|
|
2504
|
+
var sellersSchema = z29.array(sellerSchema);
|
|
2505
|
+
var sellersInvariants = ["[].id"];
|
|
2506
|
+
var buildRequest26 = () => ({ ok: true });
|
|
2507
|
+
var preRegistrationsListSellersSensitivity = {
|
|
2508
|
+
input: [],
|
|
2509
|
+
output: [{ path: "[]", secretKeys: [], personalKeys: ["nome", "cpf", "email"] }]
|
|
2510
|
+
};
|
|
2511
|
+
var preRegistrationsListSellers = {
|
|
2512
|
+
name: "preRegistrations.listSellers",
|
|
2513
|
+
method: "POST",
|
|
2514
|
+
pathTemplate: "/api/precadastro/vendedor/list",
|
|
2515
|
+
encoding: "json",
|
|
2516
|
+
buildRequest: buildRequest26,
|
|
2517
|
+
repeatable: true,
|
|
2518
|
+
decode: tolerantDecoder(sellersSchema, sellersInvariants),
|
|
2519
|
+
sensitivity: preRegistrationsListSellersSensitivity
|
|
2520
|
+
};
|
|
2521
|
+
|
|
2522
|
+
// src/operations/services-add-tv.ts
|
|
2523
|
+
import { z as z30 } from "zod";
|
|
2524
|
+
var id6 = z30.number().int().positive();
|
|
2525
|
+
var servicesAddTvInputSchema = z30.strictObject({
|
|
2526
|
+
clientecontrato_id: id6,
|
|
2527
|
+
planobase_id: id6.brand(),
|
|
2528
|
+
info_extra: z30.string().optional(),
|
|
2529
|
+
tipo_equipamento: id6.optional(),
|
|
2530
|
+
endereco_id: id6.optional()
|
|
2531
|
+
});
|
|
2532
|
+
var buildRequest27 = (input) => {
|
|
2533
|
+
const parsed = servicesAddTvInputSchema.safeParse(input);
|
|
2534
|
+
if (!parsed.success)
|
|
2535
|
+
return { ok: false, problem: "invalid services.addTv input" };
|
|
2536
|
+
return { ok: true, params: parsed.data };
|
|
2537
|
+
};
|
|
2538
|
+
var tvAddedSchema = z30.looseObject({
|
|
2539
|
+
msg: z30.string(),
|
|
2540
|
+
clientecontrato_id: z30.string().optional(),
|
|
2541
|
+
servico_id: z30.number()
|
|
2542
|
+
});
|
|
2543
|
+
var tvAddedInvariants = ["servico_id", "msg"];
|
|
2544
|
+
var CONTRACT_NOT_ACTIVE_TEXT = /^clientecontrato_id: só é possível adicionar serviços em contratos ativos\.?$/i;
|
|
2545
|
+
var contractNotActive = singleErrorsEntryRejection(400, CONTRACT_NOT_ACTIVE_TEXT, "CONTRACT_NOT_ACTIVE");
|
|
2546
|
+
var servicesAddTvSensitivity = {
|
|
2547
|
+
input: [{ path: "", secretKeys: [], personalKeys: ["info_extra"] }],
|
|
2548
|
+
output: []
|
|
2549
|
+
};
|
|
2550
|
+
var servicesAddTv = {
|
|
2551
|
+
name: "services.addTv",
|
|
2552
|
+
method: "POST",
|
|
2553
|
+
pathTemplate: "/api/servico/tv",
|
|
2554
|
+
encoding: "form",
|
|
2555
|
+
repeatable: false,
|
|
2556
|
+
write: { knownRejections: [contractNotActive] },
|
|
2557
|
+
buildRequest: buildRequest27,
|
|
2558
|
+
decode: tolerantDecoder(tvAddedSchema, tvAddedInvariants),
|
|
2559
|
+
sensitivity: servicesAddTvSensitivity
|
|
2560
|
+
};
|
|
2561
|
+
|
|
2562
|
+
// src/operations/services-change-plan.ts
|
|
2563
|
+
import { z as z31 } from "zod";
|
|
2564
|
+
var id7 = z31.number().int().positive();
|
|
2565
|
+
var servicesChangePlanInputSchema = z31.strictObject({
|
|
2566
|
+
servico_id: id7,
|
|
2567
|
+
servico_tipo: id7,
|
|
2568
|
+
plano_id: id7.brand()
|
|
2569
|
+
});
|
|
2570
|
+
var buildRequest28 = (input) => {
|
|
2571
|
+
const parsed = servicesChangePlanInputSchema.safeParse(input);
|
|
2572
|
+
if (!parsed.success)
|
|
2573
|
+
return { ok: false, problem: "invalid services.changePlan input" };
|
|
2574
|
+
const { servico_id, servico_tipo, plano_id } = parsed.data;
|
|
2575
|
+
return {
|
|
2576
|
+
ok: true,
|
|
2577
|
+
pathParams: { servico_id },
|
|
2578
|
+
params: { servico_tipo, action: "change_plano", plano_id }
|
|
2579
|
+
};
|
|
2580
|
+
};
|
|
2581
|
+
var planChangedSchema = z31.looseObject({ msg: z31.string() });
|
|
2582
|
+
var planChangedInvariants = ["msg"];
|
|
2583
|
+
var servicesChangePlanSensitivity = { input: [], output: [] };
|
|
2584
|
+
var servicesChangePlan = {
|
|
2585
|
+
name: "services.changePlan",
|
|
2586
|
+
method: "POST",
|
|
2587
|
+
pathTemplate: "/api/suporte/service/update/{servico_id}/",
|
|
2588
|
+
encoding: "form",
|
|
2589
|
+
repeatable: false,
|
|
2590
|
+
write: {},
|
|
2591
|
+
buildRequest: buildRequest28,
|
|
2592
|
+
decode: tolerantDecoder(planChangedSchema, planChangedInvariants),
|
|
2593
|
+
sensitivity: servicesChangePlanSensitivity
|
|
2594
|
+
};
|
|
2595
|
+
|
|
2596
|
+
// src/operations/services-remove-tv.ts
|
|
2597
|
+
import { z as z32 } from "zod";
|
|
2598
|
+
var id8 = z32.number().int().positive();
|
|
2599
|
+
var servicesRemoveTvInputSchema = z32.strictObject({
|
|
2600
|
+
servico_id: id8,
|
|
2601
|
+
clientecontrato_id: id8
|
|
2602
|
+
});
|
|
2603
|
+
var buildRequest29 = (input) => {
|
|
2604
|
+
const parsed = servicesRemoveTvInputSchema.safeParse(input);
|
|
2605
|
+
if (!parsed.success)
|
|
2606
|
+
return { ok: false, problem: "invalid services.removeTv input" };
|
|
2607
|
+
const { servico_id, clientecontrato_id } = parsed.data;
|
|
2608
|
+
return { ok: true, pathParams: { servico_id }, params: { clientecontrato_id } };
|
|
2609
|
+
};
|
|
2610
|
+
var tvRemovedSchema = z32.looseObject({
|
|
2611
|
+
msg: z32.string(),
|
|
2612
|
+
clientecontrato_id: z32.string().optional(),
|
|
2613
|
+
servico_id: z32.number()
|
|
2614
|
+
});
|
|
2615
|
+
var tvRemovedInvariants = ["servico_id", "msg"];
|
|
2616
|
+
var servicesRemoveTvSensitivity = { input: [], output: [] };
|
|
2617
|
+
var servicesRemoveTv = {
|
|
2618
|
+
name: "services.removeTv",
|
|
2619
|
+
method: "DELETE",
|
|
2620
|
+
pathTemplate: "/api/servico/tv/{servico_id}",
|
|
2621
|
+
encoding: "form",
|
|
2622
|
+
repeatable: false,
|
|
2623
|
+
write: {},
|
|
2624
|
+
buildRequest: buildRequest29,
|
|
2625
|
+
decode: tolerantDecoder(tvRemovedSchema, tvRemovedInvariants),
|
|
2626
|
+
sensitivity: servicesRemoveTvSensitivity
|
|
2627
|
+
};
|
|
2628
|
+
|
|
2629
|
+
// src/operations/work-orders-list.ts
|
|
2630
|
+
import { z as z33 } from "zod";
|
|
2631
|
+
var workOrderSchema = z33.looseObject({
|
|
2632
|
+
id: z33.number(),
|
|
2633
|
+
contrato: z33.number().optional().nullable(),
|
|
2634
|
+
status_id: z33.number().optional().nullable(),
|
|
2635
|
+
status: z33.string().optional().nullable(),
|
|
2636
|
+
tipo_id: z33.number().optional().nullable(),
|
|
2637
|
+
data_cadastro: z33.string().optional().nullable(),
|
|
2638
|
+
cliente: z33.string().optional().nullable(),
|
|
2639
|
+
contrato_status: z33.string().optional().nullable(),
|
|
2640
|
+
contrato_status_id: z33.number().optional().nullable(),
|
|
2641
|
+
ocorrencia: z33.string().optional().nullable(),
|
|
2642
|
+
hora_cadastro: z33.string().optional().nullable(),
|
|
2643
|
+
data_agendamento: z33.string().optional().nullable(),
|
|
2644
|
+
hora_agendamento: z33.string().optional().nullable(),
|
|
2645
|
+
data_finalizacao: z33.string().optional().nullable(),
|
|
2646
|
+
hora_finalizacao: z33.string().optional().nullable(),
|
|
2647
|
+
tipo: z33.string().optional().nullable(),
|
|
2648
|
+
motivo: z33.string().optional().nullable(),
|
|
2649
|
+
pop: z33.string().optional().nullable(),
|
|
2650
|
+
conteudo: z33.string().optional().nullable(),
|
|
2651
|
+
responsavel: z33.string().optional().nullable(),
|
|
2652
|
+
tecnicos_auxiliares: z33.array(z33.unknown()).optional().nullable(),
|
|
2653
|
+
usuario: z33.string().optional().nullable(),
|
|
2654
|
+
usuario_finalizacao: z33.string().optional().nullable(),
|
|
2655
|
+
classificacoes: z33.array(z33.unknown()).optional().nullable()
|
|
2656
|
+
});
|
|
2657
|
+
var pageSchema3 = z33.looseObject({
|
|
2658
|
+
paginacao: z33.looseObject({
|
|
2659
|
+
offset: z33.number().optional().nullable(),
|
|
2660
|
+
limit: z33.number().optional().nullable(),
|
|
2661
|
+
parcial: z33.number().optional().nullable(),
|
|
2662
|
+
total: z33.number()
|
|
2663
|
+
}),
|
|
2664
|
+
ordens_servicos: z33.array(workOrderSchema)
|
|
2665
|
+
});
|
|
2666
|
+
var pageInvariants3 = [
|
|
2667
|
+
"paginacao",
|
|
2668
|
+
"paginacao.total",
|
|
2669
|
+
"ordens_servicos",
|
|
2670
|
+
"ordens_servicos[].id"
|
|
2671
|
+
];
|
|
2672
|
+
var workOrdersListInputSchema = z33.strictObject({
|
|
2673
|
+
offset: z33.number().int().nonnegative().optional(),
|
|
2674
|
+
limit: z33.number().int().nonnegative().optional(),
|
|
2675
|
+
ordem_servico: z33.number().int().optional(),
|
|
2676
|
+
status: z33.number().int().optional(),
|
|
2677
|
+
pop: z33.number().int().optional(),
|
|
2678
|
+
motivo: z33.number().int().optional(),
|
|
2679
|
+
contrato: z33.number().int().optional()
|
|
2680
|
+
});
|
|
2681
|
+
var buildRequest30 = (input) => {
|
|
2682
|
+
const parsed = workOrdersListInputSchema.safeParse(input);
|
|
2683
|
+
if (!parsed.success)
|
|
2684
|
+
return { ok: false, problem: "invalid workOrders.list input" };
|
|
2685
|
+
return { ok: true, params: parsed.data };
|
|
2686
|
+
};
|
|
2687
|
+
var workOrdersListSensitivity = {
|
|
2688
|
+
input: [],
|
|
2689
|
+
output: [
|
|
2690
|
+
{
|
|
2691
|
+
path: "ordens_servicos[]",
|
|
2692
|
+
secretKeys: [],
|
|
2693
|
+
personalKeys: [
|
|
2694
|
+
"cliente",
|
|
2695
|
+
"conteudo",
|
|
2696
|
+
"responsavel",
|
|
2697
|
+
"tecnicos_auxiliares",
|
|
2698
|
+
"usuario",
|
|
2699
|
+
"usuario_finalizacao"
|
|
2700
|
+
]
|
|
2701
|
+
}
|
|
2702
|
+
]
|
|
2703
|
+
};
|
|
2704
|
+
var workOrdersList = {
|
|
2705
|
+
name: "workOrders.list",
|
|
2706
|
+
method: "POST",
|
|
2707
|
+
pathTemplate: "/api/ura/ordemservico/list/",
|
|
2708
|
+
encoding: "json",
|
|
2709
|
+
buildRequest: buildRequest30,
|
|
2710
|
+
repeatable: true,
|
|
2711
|
+
decode: tolerantDecoder(pageSchema3, pageInvariants3),
|
|
2712
|
+
sensitivity: workOrdersListSensitivity
|
|
2713
|
+
};
|
|
2714
|
+
|
|
2715
|
+
// src/operations/work-orders-list-reasons.ts
|
|
2716
|
+
import { z as z34 } from "zod";
|
|
2717
|
+
var workOrderReasonSchema = z34.looseObject({
|
|
2718
|
+
id: z34.number(),
|
|
2719
|
+
codigo: z34.number(),
|
|
2720
|
+
descricao: z34.string().optional().nullable(),
|
|
2721
|
+
ativo: z34.boolean().optional().nullable(),
|
|
2722
|
+
classificacoes: z34.array(z34.unknown()).optional().nullable(),
|
|
2723
|
+
classificacoes_obrigatorio: z34.boolean().optional().nullable(),
|
|
2724
|
+
setores: z34.array(z34.unknown()).optional().nullable()
|
|
2725
|
+
});
|
|
2726
|
+
var workOrderReasonsSchema = z34.array(workOrderReasonSchema);
|
|
2727
|
+
var workOrderReasonsInvariants = ["[].id", "[].codigo"];
|
|
2728
|
+
var buildRequest31 = () => ({ ok: true });
|
|
2729
|
+
var workOrdersListReasonsSensitivity = { input: [], output: [] };
|
|
2730
|
+
var workOrdersListReasons = {
|
|
2731
|
+
name: "workOrders.listReasons",
|
|
2732
|
+
method: "GET",
|
|
2733
|
+
pathTemplate: "/api/os/ocorrencia/motivo/list/",
|
|
2734
|
+
encoding: "json",
|
|
2735
|
+
buildRequest: buildRequest31,
|
|
2736
|
+
repeatable: true,
|
|
2737
|
+
decode: tolerantDecoder(workOrderReasonsSchema, workOrderReasonsInvariants),
|
|
2738
|
+
sensitivity: workOrdersListReasonsSensitivity
|
|
2739
|
+
};
|
|
2740
|
+
|
|
2741
|
+
// src/raw-request.ts
|
|
2742
|
+
var METHODS = ["GET", "POST", "PUT", "DELETE"];
|
|
2743
|
+
var ENCODINGS = ["json", "form"];
|
|
2744
|
+
var isAllowedPath = (path, base2) => {
|
|
2745
|
+
if (typeof path !== "string" || !path.startsWith("/api/"))
|
|
2746
|
+
return false;
|
|
2747
|
+
if (path.includes("//") || path.includes("%"))
|
|
2748
|
+
return false;
|
|
2749
|
+
return new URL(path, base2).pathname === path;
|
|
2750
|
+
};
|
|
2751
|
+
var snapshotOf2 = (body, method, encoding) => {
|
|
2752
|
+
try {
|
|
2753
|
+
if (!isRecord(body))
|
|
2754
|
+
return;
|
|
2755
|
+
const copy = encoding === "json" && method !== "GET" ? JSON.parse(JSON.stringify(body)) : Object.fromEntries(Object.entries(body));
|
|
2756
|
+
return isRecord(copy) ? copy : undefined;
|
|
2757
|
+
} catch {
|
|
2758
|
+
return;
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
var readFields = (input) => {
|
|
2762
|
+
try {
|
|
2763
|
+
if (!isRecord(input))
|
|
2764
|
+
return;
|
|
2765
|
+
const { method, path, body, encoding = "json" } = input;
|
|
2766
|
+
return { method, path, body, encoding };
|
|
2767
|
+
} catch {
|
|
2768
|
+
return;
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
var ANNOTATIONS_ROUTE = "/api/ura/cliente/anotacao/list";
|
|
2772
|
+
var isAnnotationsRoute = (path) => path.toLowerCase().split(";")[0]?.startsWith(ANNOTATIONS_ROUTE) === true;
|
|
2773
|
+
var ANNOTATIONS_ROUTE_MESSAGE = "This route answers with other customers' notes; use experimental.annotations.list. Nothing was sent.";
|
|
2774
|
+
var check = (base2, input) => {
|
|
2775
|
+
const fields = readFields(input);
|
|
2776
|
+
if (fields === undefined)
|
|
2777
|
+
return;
|
|
2778
|
+
const { method, path, body, encoding } = fields;
|
|
2779
|
+
const knownMethod = METHODS.find((candidate) => candidate === method);
|
|
2780
|
+
const knownEncoding = ENCODINGS.find((candidate) => candidate === encoding);
|
|
2781
|
+
if (knownMethod === undefined || knownEncoding === undefined)
|
|
2782
|
+
return;
|
|
2783
|
+
if (!isAllowedPath(path, base2))
|
|
2784
|
+
return;
|
|
2785
|
+
if (body === undefined) {
|
|
2786
|
+
return { method: knownMethod, path, body, encoding: knownEncoding };
|
|
1323
2787
|
}
|
|
2788
|
+
const snapshot = snapshotOf2(body, knownMethod, knownEncoding);
|
|
2789
|
+
if (snapshot === undefined)
|
|
2790
|
+
return;
|
|
2791
|
+
return { method: knownMethod, path, body: snapshot, encoding: knownEncoding };
|
|
2792
|
+
};
|
|
2793
|
+
var rawDefinition = (checked) => ({
|
|
2794
|
+
name: "request",
|
|
2795
|
+
method: checked.method,
|
|
2796
|
+
pathTemplate: checked.path,
|
|
2797
|
+
omitPathFromHooks: true,
|
|
2798
|
+
encoding: checked.encoding,
|
|
2799
|
+
sensitivity: { input: [], output: [] },
|
|
2800
|
+
write: { effectUnknownAfterSend: true },
|
|
2801
|
+
buildRequest: () => ({ ok: true, params: checked.body }),
|
|
2802
|
+
decode: (body) => {
|
|
2803
|
+
switch (body.kind) {
|
|
2804
|
+
case "json":
|
|
2805
|
+
return { ok: true, data: body.value };
|
|
2806
|
+
case "text":
|
|
2807
|
+
return { ok: true, data: body.text };
|
|
2808
|
+
case "empty":
|
|
2809
|
+
return { ok: true, data: undefined };
|
|
2810
|
+
case "unavailable":
|
|
2811
|
+
case "withheld":
|
|
2812
|
+
return { ok: false, issues: ["body"] };
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
});
|
|
2816
|
+
var refusal = (error) => ({
|
|
2817
|
+
ok: false,
|
|
2818
|
+
error,
|
|
2819
|
+
response: null,
|
|
2820
|
+
attempts: 0
|
|
1324
2821
|
});
|
|
2822
|
+
var executeRawRequest = async (config, input, options) => {
|
|
2823
|
+
const checked = check(config.origin, input);
|
|
2824
|
+
if (checked === undefined) {
|
|
2825
|
+
return refusal(buildError("INVALID_INPUT", "request", { effect: "none" }));
|
|
2826
|
+
}
|
|
2827
|
+
if (isAnnotationsRoute(checked.path)) {
|
|
2828
|
+
const error = buildError("ROUTE_NOT_ALLOWED", "request", { effect: "none" });
|
|
2829
|
+
return refusal({ ...error, message: ANNOTATIONS_ROUTE_MESSAGE });
|
|
2830
|
+
}
|
|
2831
|
+
return await execute(config, rawDefinition(checked), undefined, options);
|
|
2832
|
+
};
|
|
2833
|
+
|
|
2834
|
+
// src/client.ts
|
|
2835
|
+
var createSgpClient = (options) => {
|
|
2836
|
+
const config = resolveConfig(options);
|
|
2837
|
+
return {
|
|
2838
|
+
request: (input, callOptions) => executeRawRequest(config, input, callOptions),
|
|
2839
|
+
catalogs: {
|
|
2840
|
+
listPops: (callOptions) => execute(config, catalogsListPops, undefined, callOptions),
|
|
2841
|
+
listNas: (callOptions) => execute(config, catalogsListNas, undefined, callOptions),
|
|
2842
|
+
listBillingProfiles: (callOptions) => execute(config, catalogsListBillingProfiles, undefined, callOptions)
|
|
2843
|
+
},
|
|
2844
|
+
contracts: {
|
|
2845
|
+
list: (input = {}, callOptions) => execute(config, contractsList, input, callOptions),
|
|
2846
|
+
update: (input, callOptions) => execute(config, contractsUpdate, input, callOptions),
|
|
2847
|
+
listStatusReasons: (callOptions) => execute(config, contractsListStatusReasons, undefined, callOptions),
|
|
2848
|
+
updateStatus: (input, callOptions) => execute(config, contractsUpdateStatus, input, callOptions)
|
|
2849
|
+
},
|
|
2850
|
+
coverage: {
|
|
2851
|
+
check: (input, callOptions) => execute(config, coverageCheck, input, callOptions)
|
|
2852
|
+
},
|
|
2853
|
+
crm: {
|
|
2854
|
+
customers: {
|
|
2855
|
+
create: (input, callOptions) => execute(config, crmCustomersCreate, input, callOptions),
|
|
2856
|
+
updateStatus: (input, callOptions) => execute(config, crmCustomersUpdateStatus, input, callOptions)
|
|
2857
|
+
},
|
|
2858
|
+
contracts: {
|
|
2859
|
+
create: (input, callOptions) => execute(config, crmContractsCreate, input, callOptions),
|
|
2860
|
+
createByCpfCnpj: (input, callOptions) => execute(config, crmContractsCreateByCpfCnpj, input, callOptions),
|
|
2861
|
+
list: (input, callOptions) => execute(config, crmContractsList, input, callOptions)
|
|
2862
|
+
}
|
|
2863
|
+
},
|
|
2864
|
+
customers: {
|
|
2865
|
+
list: (input = {}, callOptions) => execute(config, customersList, input, callOptions),
|
|
2866
|
+
search: (input, callOptions) => execute(config, customersSearch, input, callOptions)
|
|
2867
|
+
},
|
|
2868
|
+
experimental: {
|
|
2869
|
+
annotations: {
|
|
2870
|
+
list: (input, callOptions) => execute(config, annotationsListForCall(), input, callOptions)
|
|
2871
|
+
}
|
|
2872
|
+
},
|
|
2873
|
+
documents: {
|
|
2874
|
+
add: (input, callOptions) => execute(config, documentsAdd, input, callOptions),
|
|
2875
|
+
list: (input, callOptions) => execute(config, documentsList, input, callOptions)
|
|
2876
|
+
},
|
|
2877
|
+
invoices: {
|
|
2878
|
+
list: (input = {}, callOptions) => execute(config, invoicesList, input, callOptions)
|
|
2879
|
+
},
|
|
2880
|
+
occurrences: {
|
|
2881
|
+
create: (input, callOptions) => execute(config, occurrencesCreate, input, callOptions),
|
|
2882
|
+
listTypes: (callOptions) => execute(config, occurrencesListTypes, undefined, callOptions),
|
|
2883
|
+
listMethods: (callOptions) => execute(config, occurrencesListMethods, undefined, callOptions)
|
|
2884
|
+
},
|
|
2885
|
+
plans: {
|
|
2886
|
+
list: (callOptions) => execute(config, plansList, undefined, callOptions)
|
|
2887
|
+
},
|
|
2888
|
+
preRegistrations: {
|
|
2889
|
+
create: (input, callOptions) => execute(config, preRegistrationsCreate, input, callOptions),
|
|
2890
|
+
listPlans: (callOptions) => execute(config, preRegistrationsListPlans, undefined, callOptions),
|
|
2891
|
+
listDueDays: (callOptions) => execute(config, preRegistrationsListDueDays, undefined, callOptions),
|
|
2892
|
+
listSellers: (callOptions) => execute(config, preRegistrationsListSellers, undefined, callOptions)
|
|
2893
|
+
},
|
|
2894
|
+
workOrders: {
|
|
2895
|
+
list: (input = {}, callOptions) => execute(config, workOrdersList, input, callOptions),
|
|
2896
|
+
listReasons: (callOptions) => execute(config, workOrdersListReasons, undefined, callOptions)
|
|
2897
|
+
},
|
|
2898
|
+
services: {
|
|
2899
|
+
addTv: (input, callOptions) => execute(config, servicesAddTv, input, callOptions),
|
|
2900
|
+
changePlan: (input, callOptions) => execute(config, servicesChangePlan, input, callOptions),
|
|
2901
|
+
removeTv: (input, callOptions) => execute(config, servicesRemoveTv, input, callOptions)
|
|
2902
|
+
}
|
|
2903
|
+
};
|
|
2904
|
+
};
|
|
2905
|
+
// src/constants.ts
|
|
2906
|
+
var ACQUISITION_MODE = { owned: 0, loan: 1 };
|
|
2907
|
+
var BILLING_METHOD = {
|
|
2908
|
+
boleto: 1,
|
|
2909
|
+
automaticDebit: 2,
|
|
2910
|
+
booklet: 3,
|
|
2911
|
+
recurringCharge: 4,
|
|
2912
|
+
pix: 6
|
|
2913
|
+
};
|
|
2914
|
+
var CONTRACT_STATUS = {
|
|
2915
|
+
active: 1,
|
|
2916
|
+
inactive: 2,
|
|
2917
|
+
canceled: 3,
|
|
2918
|
+
suspended: 4,
|
|
2919
|
+
technicalInfeasibility: 5,
|
|
2920
|
+
new: 6,
|
|
2921
|
+
activeReducedSpeed: 7
|
|
2922
|
+
};
|
|
2923
|
+
var SERVICE_TYPE = { internet: 1 };
|
|
2924
|
+
var CRM_STATUS = {
|
|
2925
|
+
underAnalysis: 1,
|
|
2926
|
+
approved: 2,
|
|
2927
|
+
rejected: 3,
|
|
2928
|
+
awaitingContact: 4,
|
|
2929
|
+
tryingContact: 5,
|
|
2930
|
+
contractMadeInSgp: 6,
|
|
2931
|
+
technicalInfeasibility: 7,
|
|
2932
|
+
contractInProspecting: 8,
|
|
2933
|
+
rejectedCreditBureau: 9,
|
|
2934
|
+
technicalFeasibilityAnalysis: 10
|
|
2935
|
+
};
|
|
2936
|
+
// src/operation-sensitivity.ts
|
|
2937
|
+
var shippedOperations = [
|
|
2938
|
+
customersList,
|
|
2939
|
+
customersSearch,
|
|
2940
|
+
preRegistrationsCreate,
|
|
2941
|
+
contractsUpdateStatus,
|
|
2942
|
+
contractsUpdate,
|
|
2943
|
+
contractsList,
|
|
2944
|
+
invoicesList,
|
|
2945
|
+
plansList,
|
|
2946
|
+
workOrdersList,
|
|
2947
|
+
servicesChangePlan,
|
|
2948
|
+
servicesAddTv,
|
|
2949
|
+
servicesRemoveTv,
|
|
2950
|
+
experimentalAnnotationsList,
|
|
2951
|
+
catalogsListPops,
|
|
2952
|
+
catalogsListNas,
|
|
2953
|
+
catalogsListBillingProfiles,
|
|
2954
|
+
occurrencesListTypes,
|
|
2955
|
+
occurrencesListMethods,
|
|
2956
|
+
workOrdersListReasons,
|
|
2957
|
+
preRegistrationsListPlans,
|
|
2958
|
+
preRegistrationsListDueDays,
|
|
2959
|
+
preRegistrationsListSellers,
|
|
2960
|
+
contractsListStatusReasons,
|
|
2961
|
+
documentsList,
|
|
2962
|
+
coverageCheck,
|
|
2963
|
+
crmCustomersCreate,
|
|
2964
|
+
crmCustomersUpdateStatus,
|
|
2965
|
+
crmContractsCreate,
|
|
2966
|
+
crmContractsCreateByCpfCnpj,
|
|
2967
|
+
crmContractsList,
|
|
2968
|
+
occurrencesCreate,
|
|
2969
|
+
documentsAdd
|
|
2970
|
+
];
|
|
2971
|
+
var getSensitivity = (operation) => {
|
|
2972
|
+
const found = shippedOperations.find((definition) => definition.name === operation);
|
|
2973
|
+
if (found === undefined)
|
|
2974
|
+
throw new Error(`unknown operation: ${operation}`);
|
|
2975
|
+
return found.sensitivity;
|
|
2976
|
+
};
|
|
1325
2977
|
// src/sensitivity.ts
|
|
1326
|
-
var
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
2978
|
+
var ITEMS = "[]";
|
|
2979
|
+
var RAW_RESPONSE_KEYS = new Set(["body", "headers"]);
|
|
2980
|
+
var EVERYTHING = { all: true, children: new Map };
|
|
2981
|
+
var SEGMENT = /^([^.[\]]*)((?:\[\])*)$/;
|
|
2982
|
+
var parsePath = (path) => {
|
|
2983
|
+
const steps = [];
|
|
2984
|
+
for (const segment of path.split(".")) {
|
|
2985
|
+
const parts = SEGMENT.exec(segment);
|
|
2986
|
+
if (parts === null)
|
|
2987
|
+
return;
|
|
2988
|
+
const [, name = "", items = ""] = parts;
|
|
2989
|
+
if (name === "" && items === "")
|
|
2990
|
+
return;
|
|
2991
|
+
if (name !== "")
|
|
2992
|
+
steps.push(name);
|
|
2993
|
+
for (let index = 0;index < items.length; index += ITEMS.length)
|
|
2994
|
+
steps.push(ITEMS);
|
|
2995
|
+
}
|
|
2996
|
+
return steps;
|
|
2997
|
+
};
|
|
2998
|
+
var buildAllowed = (allowlist) => {
|
|
2999
|
+
const root = { all: false, children: new Map };
|
|
3000
|
+
for (const path of allowlist) {
|
|
3001
|
+
const steps = parsePath(path);
|
|
3002
|
+
if (steps === undefined)
|
|
3003
|
+
continue;
|
|
3004
|
+
let node = root;
|
|
3005
|
+
for (const step of steps) {
|
|
3006
|
+
let next = node.children.get(step);
|
|
3007
|
+
if (next === undefined) {
|
|
3008
|
+
next = { all: false, children: new Map };
|
|
3009
|
+
node.children.set(step, next);
|
|
3010
|
+
}
|
|
3011
|
+
node = next;
|
|
3012
|
+
}
|
|
3013
|
+
node.all = true;
|
|
3014
|
+
}
|
|
3015
|
+
const response = root.children.get("response");
|
|
3016
|
+
if (response?.all)
|
|
3017
|
+
response.withheld = RAW_RESPONSE_KEYS;
|
|
3018
|
+
return root;
|
|
3019
|
+
};
|
|
3020
|
+
var isPlainObject = (value) => {
|
|
3021
|
+
if (!isRecord(value))
|
|
3022
|
+
return false;
|
|
3023
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3024
|
+
return prototype === Object.prototype || prototype === null;
|
|
3025
|
+
};
|
|
3026
|
+
var setOwn2 = (target, key, value) => {
|
|
3027
|
+
Object.defineProperty(target, key, {
|
|
3028
|
+
value,
|
|
3029
|
+
enumerable: true,
|
|
3030
|
+
writable: true,
|
|
3031
|
+
configurable: true
|
|
3032
|
+
});
|
|
3033
|
+
};
|
|
3034
|
+
var project = (value, allowed, ancestors) => {
|
|
3035
|
+
if (typeof value !== "object" || value === null) {
|
|
3036
|
+
const isJson = value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
3037
|
+
return isJson && allowed.all ? value : undefined;
|
|
3038
|
+
}
|
|
3039
|
+
if (ancestors.has(value))
|
|
3040
|
+
return;
|
|
3041
|
+
ancestors.add(value);
|
|
3042
|
+
try {
|
|
3043
|
+
if (Array.isArray(value)) {
|
|
3044
|
+
const itemAllowed = allowed.all ? EVERYTHING : allowed.children.get(ITEMS);
|
|
3045
|
+
if (itemAllowed === undefined)
|
|
3046
|
+
return;
|
|
3047
|
+
const items = [];
|
|
3048
|
+
for (const item of value) {
|
|
3049
|
+
const projected = project(item, itemAllowed, ancestors);
|
|
3050
|
+
if (projected !== undefined)
|
|
3051
|
+
items.push(projected);
|
|
3052
|
+
}
|
|
3053
|
+
return items;
|
|
3054
|
+
}
|
|
3055
|
+
if (!isPlainObject(value))
|
|
3056
|
+
return;
|
|
3057
|
+
const output = {};
|
|
3058
|
+
for (const key of Object.keys(value)) {
|
|
3059
|
+
const named = allowed.children.get(key);
|
|
3060
|
+
const child = allowed.all && !allowed.withheld?.has(key) ? EVERYTHING : named;
|
|
3061
|
+
if (child === undefined || key === ITEMS)
|
|
3062
|
+
continue;
|
|
3063
|
+
const projected = project(value[key], child, ancestors);
|
|
3064
|
+
if (projected !== undefined)
|
|
3065
|
+
setOwn2(output, key, projected);
|
|
3066
|
+
}
|
|
3067
|
+
return output;
|
|
3068
|
+
} finally {
|
|
3069
|
+
ancestors.delete(value);
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
var pick = (source, allowlist) => project(source, buildAllowed(allowlist), new Set) ?? {};
|
|
3073
|
+
var SAFE_LOG_PATHS = [
|
|
3074
|
+
"ok",
|
|
3075
|
+
"attempts",
|
|
3076
|
+
"diagnostics",
|
|
3077
|
+
"warnings",
|
|
3078
|
+
"response.status",
|
|
3079
|
+
"error.code",
|
|
3080
|
+
"error.message",
|
|
3081
|
+
"error.operation",
|
|
3082
|
+
"error.reason",
|
|
3083
|
+
"error.effect",
|
|
3084
|
+
"error.issues",
|
|
3085
|
+
"error.sgpFields"
|
|
3086
|
+
];
|
|
3087
|
+
var toSafeLog = (result) => {
|
|
3088
|
+
const view = result.ok ? result : { ...result, error: { ...result.error, sgpFields: Object.keys(result.error.sgp ?? {}) } };
|
|
3089
|
+
return pick(view, SAFE_LOG_PATHS);
|
|
1331
3090
|
};
|
|
1332
3091
|
export {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
ticketOpenedPersonalKeys,
|
|
1337
|
-
ticketOpenedItemPath,
|
|
1338
|
-
serviceOrderSecretKeys,
|
|
1339
|
-
serviceOrderPersonalKeys,
|
|
1340
|
-
serviceOrderItemPath,
|
|
1341
|
-
sellerSecretKeys,
|
|
1342
|
-
sellerPersonalKeys,
|
|
1343
|
-
sellerItemPath,
|
|
1344
|
-
popSecretKeys,
|
|
1345
|
-
popPersonalKeys,
|
|
1346
|
-
popItemPath,
|
|
1347
|
-
planSecretKeys,
|
|
1348
|
-
planPersonalKeys,
|
|
1349
|
-
planItemPath,
|
|
1350
|
-
paymentCarrierSecretKeys,
|
|
1351
|
-
paymentCarrierPersonalKeys,
|
|
1352
|
-
paymentCarrierItemPath,
|
|
1353
|
-
openTicketKeyFields,
|
|
1354
|
-
openTicketDefinition,
|
|
1355
|
-
omitSensitive,
|
|
1356
|
-
occurrenceTypeSecretKeys,
|
|
1357
|
-
occurrenceTypePersonalKeys,
|
|
1358
|
-
occurrenceTypeItemPath,
|
|
1359
|
-
occurrenceReasonSecretKeys,
|
|
1360
|
-
occurrenceReasonPersonalKeys,
|
|
1361
|
-
occurrenceReasonItemPath,
|
|
1362
|
-
occurrenceMethodSecretKeys,
|
|
1363
|
-
occurrenceMethodPersonalKeys,
|
|
1364
|
-
occurrenceMethodItemPath,
|
|
1365
|
-
nasSecretKeys,
|
|
1366
|
-
nasPersonalKeys,
|
|
1367
|
-
nasItemPath,
|
|
1368
|
-
modoAquisicao,
|
|
1369
|
-
lookupCustomerKeyFields,
|
|
1370
|
-
lookupCustomerDefinition,
|
|
1371
|
-
listServiceOrdersKeyFields,
|
|
1372
|
-
listServiceOrdersDefinition,
|
|
1373
|
-
listSellersKeyFields,
|
|
1374
|
-
listSellersDefinition,
|
|
1375
|
-
listPopsKeyFields,
|
|
1376
|
-
listPopsDefinition,
|
|
1377
|
-
listPlansKeyFields,
|
|
1378
|
-
listPlansDefinition,
|
|
1379
|
-
listPaymentCarriersKeyFields,
|
|
1380
|
-
listPaymentCarriersDefinition,
|
|
1381
|
-
listOccurrenceTypesKeyFields,
|
|
1382
|
-
listOccurrenceTypesDefinition,
|
|
1383
|
-
listOccurrenceReasonsKeyFields,
|
|
1384
|
-
listOccurrenceReasonsDefinition,
|
|
1385
|
-
listOccurrenceMethodsKeyFields,
|
|
1386
|
-
listOccurrenceMethodsDefinition,
|
|
1387
|
-
listNasKeyFields,
|
|
1388
|
-
listNasDefinition,
|
|
1389
|
-
listInvoicesKeyFields,
|
|
1390
|
-
listInvoicesDefinition,
|
|
1391
|
-
listDueDaysKeyFields,
|
|
1392
|
-
listDueDaysDefinition,
|
|
1393
|
-
listCustomerDocumentsKeyFields,
|
|
1394
|
-
listCustomerDocumentsDefinition,
|
|
1395
|
-
listContractsKeyFields,
|
|
1396
|
-
listContractsDefinition,
|
|
1397
|
-
listClientsKeyFields,
|
|
1398
|
-
listClientsDefinition,
|
|
1399
|
-
listAnnotationsSchema,
|
|
1400
|
-
listAnnotationsKeyFields,
|
|
1401
|
-
invoiceSecretKeys,
|
|
1402
|
-
invoicePersonalKeys,
|
|
1403
|
-
invoiceItemPath,
|
|
1404
|
-
formaCobrancaCodigo,
|
|
1405
|
-
dueDaySecretKeys,
|
|
1406
|
-
dueDayPersonalKeys,
|
|
1407
|
-
dueDayItemPath,
|
|
1408
|
-
customerStatusSecretKeys,
|
|
1409
|
-
customerStatusPersonalKeys,
|
|
1410
|
-
customerStatusItemPath,
|
|
1411
|
-
customerDocumentSecretKeys,
|
|
1412
|
-
customerDocumentPersonalKeys,
|
|
1413
|
-
customerDocumentItemPath,
|
|
1414
|
-
customerDocumentAddedSecretKeys,
|
|
1415
|
-
customerDocumentAddedPersonalKeys,
|
|
1416
|
-
customerDocumentAddedItemPath,
|
|
1417
|
-
customerCreatedSecretKeys,
|
|
1418
|
-
customerCreatedPersonalKeys,
|
|
1419
|
-
customerCreatedItemPath,
|
|
1420
|
-
customerContractSecretKeys,
|
|
1421
|
-
customerContractPersonalKeys,
|
|
1422
|
-
customerContractItemPath,
|
|
1423
|
-
crmStatus,
|
|
3092
|
+
toSafeLog,
|
|
3093
|
+
pick,
|
|
3094
|
+
getSensitivity,
|
|
1424
3095
|
createSgpClient,
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
contractSummarySecretKeys,
|
|
1434
|
-
contractSummaryPersonalKeys,
|
|
1435
|
-
contractSummaryItemPath,
|
|
1436
|
-
contractCreatedSecretKeys,
|
|
1437
|
-
contractCreatedPersonalKeys,
|
|
1438
|
-
contractCreatedItemPath,
|
|
1439
|
-
clientSecretKeys,
|
|
1440
|
-
clientPersonalKeys,
|
|
1441
|
-
clientItemPath,
|
|
1442
|
-
checkCoverageKeyFields,
|
|
1443
|
-
checkCoverageDefinition,
|
|
1444
|
-
annotationSecretKeys,
|
|
1445
|
-
annotationPersonalKeys,
|
|
1446
|
-
annotationItemPath,
|
|
1447
|
-
addCustomerDocumentKeyFields,
|
|
1448
|
-
addCustomerDocumentDefinition
|
|
3096
|
+
SERVICE_TYPE,
|
|
3097
|
+
MAX_TIMEOUT_MS,
|
|
3098
|
+
InvalidConfigurationError,
|
|
3099
|
+
DEFAULT_TIMEOUT_MS,
|
|
3100
|
+
CRM_STATUS,
|
|
3101
|
+
CONTRACT_STATUS,
|
|
3102
|
+
BILLING_METHOD,
|
|
3103
|
+
ACQUISITION_MODE
|
|
1449
3104
|
};
|