@77sol-lab/form-schemas 1.2.0 → 1.3.0
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/chunk-52KJIJBF.mjs +45 -0
- package/{chunk-X4DDGGAB.mjs → chunk-KKGV43J4.mjs} +18 -1
- package/chunk-XNACW46V.mjs +105 -0
- package/financing/formalization/index.d.cts +1577 -244
- package/financing/formalization/index.d.ts +1577 -244
- package/financing/formalization/index.js +158 -0
- package/financing/formalization/index.mjs +3 -1
- package/financing/formalization/schemas/UnifiedPFSchema.d.cts +535 -0
- package/financing/formalization/schemas/UnifiedPFSchema.d.ts +535 -0
- package/financing/formalization/schemas/UnifiedPFSchema.js +248 -0
- package/financing/formalization/schemas/UnifiedPFSchema.mjs +3 -0
- package/financing/formalization/schemas/UnifiedPJSchema.d.cts +1335 -0
- package/financing/formalization/schemas/UnifiedPJSchema.d.ts +1335 -0
- package/financing/formalization/schemas/UnifiedPJSchema.js +268 -0
- package/financing/formalization/schemas/UnifiedPJSchema.mjs +3 -0
- package/index.d.cts +3 -1
- package/index.d.ts +3 -1
- package/index.js +158 -0
- package/index.mjs +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/domains/financing/formalization/schemas/UnifiedPJSchema.ts
|
|
6
|
+
var DocumentTypeEnum = zod.z.enum(["rg", "cnh", "rne"]);
|
|
7
|
+
var SexEnum = zod.z.enum(["masculino", "feminino"]);
|
|
8
|
+
function textField(maxLength) {
|
|
9
|
+
const base = zod.z.string().trim().min(1, "Campo obrigat\xF3rio");
|
|
10
|
+
return maxLength === void 0 ? base : base.max(maxLength, `M\xE1ximo ${maxLength} caracteres`);
|
|
11
|
+
}
|
|
12
|
+
zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).nonnegative("Valor n\xE3o pode ser negativo");
|
|
13
|
+
var integerField = zod.z.number({ invalid_type_error: "Valor num\xE9rico inv\xE1lido" }).int("Deve ser um n\xFAmero inteiro").nonnegative("Valor n\xE3o pode ser negativo");
|
|
14
|
+
function selectField(values) {
|
|
15
|
+
return zod.z.enum(values);
|
|
16
|
+
}
|
|
17
|
+
var MAX_UPLOAD_BYTES = 5 * 1024 * 1024;
|
|
18
|
+
var ACCEPTED_UPLOAD_MIME = ["image/jpeg", "image/png", "application/pdf"];
|
|
19
|
+
var fileUploadField = zod.z.object({
|
|
20
|
+
url: zod.z.string().url().optional(),
|
|
21
|
+
mime: zod.z.enum(ACCEPTED_UPLOAD_MIME, {
|
|
22
|
+
errorMap: () => ({ message: "Formato deve ser JPEG, PNG ou PDF" })
|
|
23
|
+
}),
|
|
24
|
+
sizeBytes: zod.z.number().max(MAX_UPLOAD_BYTES, "Arquivo deve ter no m\xE1ximo 5MB")
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// src/shared/regex/patterns.ts
|
|
28
|
+
var PATTERNS = {
|
|
29
|
+
cpf: /^\d{11}$/,
|
|
30
|
+
cnpj: /^\d{14}$/,
|
|
31
|
+
cep: /^\d{8}$/,
|
|
32
|
+
phoneBR: /^\d{11}$/,
|
|
33
|
+
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
34
|
+
dateDMY: /^\d{2}\/\d{2}\/\d{4}$/};
|
|
35
|
+
|
|
36
|
+
// src/shared/regex/validators.ts
|
|
37
|
+
function onlyDigits(value) {
|
|
38
|
+
return value.replace(/\D/g, "");
|
|
39
|
+
}
|
|
40
|
+
function isValidCPF(value) {
|
|
41
|
+
const cpf = onlyDigits(value);
|
|
42
|
+
if (cpf.length !== 11) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (/^(\d)\1{10}$/.test(cpf)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const calcCheck = (slice) => {
|
|
49
|
+
let sum = 0;
|
|
50
|
+
for (let i = 0; i < slice; i++) {
|
|
51
|
+
sum += Number(cpf[i]) * (slice + 1 - i);
|
|
52
|
+
}
|
|
53
|
+
const rest = sum * 10 % 11;
|
|
54
|
+
return rest === 10 ? 0 : rest;
|
|
55
|
+
};
|
|
56
|
+
return calcCheck(9) === Number(cpf[9]) && calcCheck(10) === Number(cpf[10]);
|
|
57
|
+
}
|
|
58
|
+
function isValidCNPJ(value) {
|
|
59
|
+
const cnpj = onlyDigits(value);
|
|
60
|
+
if (cnpj.length !== 14) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (/^(\d)\1{13}$/.test(cnpj)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const calcCheck = (length) => {
|
|
67
|
+
const weights = length === 12 ? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] : [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
68
|
+
let sum = 0;
|
|
69
|
+
for (const [i, weight] of weights.entries()) {
|
|
70
|
+
sum += Number(cnpj[i]) * weight;
|
|
71
|
+
}
|
|
72
|
+
const rest = sum % 11;
|
|
73
|
+
return rest < 2 ? 0 : 11 - rest;
|
|
74
|
+
};
|
|
75
|
+
return calcCheck(12) === Number(cnpj[12]) && calcCheck(13) === Number(cnpj[13]);
|
|
76
|
+
}
|
|
77
|
+
function parseDMY(value) {
|
|
78
|
+
const match = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(value);
|
|
79
|
+
if (!match) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const [, dd, mm, yyyy] = match;
|
|
83
|
+
const day = Number(dd);
|
|
84
|
+
const month = Number(mm);
|
|
85
|
+
const year = Number(yyyy);
|
|
86
|
+
const date = new Date(year, month - 1, day);
|
|
87
|
+
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return date;
|
|
91
|
+
}
|
|
92
|
+
function ageInYears(birth, reference = /* @__PURE__ */ new Date()) {
|
|
93
|
+
let age = reference.getFullYear() - birth.getFullYear();
|
|
94
|
+
const monthDiff = reference.getMonth() - birth.getMonth();
|
|
95
|
+
if (monthDiff < 0 || monthDiff === 0 && reference.getDate() < birth.getDate()) {
|
|
96
|
+
age--;
|
|
97
|
+
}
|
|
98
|
+
return age;
|
|
99
|
+
}
|
|
100
|
+
function isAdultDMY(value, reference) {
|
|
101
|
+
const date = parseDMY(value);
|
|
102
|
+
if (!date) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return ageInYears(date, reference) >= 18;
|
|
106
|
+
}
|
|
107
|
+
function isNotFutureDMY(value, reference = /* @__PURE__ */ new Date()) {
|
|
108
|
+
const date = parseDMY(value);
|
|
109
|
+
if (!date) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return date.getTime() <= reference.getTime();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/shared/regex/index.ts
|
|
116
|
+
var cpfSchema = zod.z.string().transform(onlyDigits).refine((v) => PATTERNS.cpf.test(v), "CPF deve ter 11 d\xEDgitos").refine(isValidCPF, "CPF inv\xE1lido");
|
|
117
|
+
var cnpjSchema = zod.z.string().transform(onlyDigits).refine((v) => PATTERNS.cnpj.test(v), "CNPJ deve ter 14 d\xEDgitos").refine(isValidCNPJ, "CNPJ inv\xE1lido");
|
|
118
|
+
zod.z.string().transform(onlyDigits).refine(
|
|
119
|
+
(v) => PATTERNS.cpf.test(v) || PATTERNS.cnpj.test(v),
|
|
120
|
+
"Documento deve ter 11 (CPF) ou 14 (CNPJ) d\xEDgitos"
|
|
121
|
+
).refine((v) => v.length === 11 ? isValidCPF(v) : isValidCNPJ(v), "Documento inv\xE1lido");
|
|
122
|
+
var cepSchema = zod.z.string().transform(onlyDigits).refine((v) => PATTERNS.cep.test(v), "CEP deve ter 8 d\xEDgitos");
|
|
123
|
+
var phoneBRSchema = zod.z.string().transform(onlyDigits).refine((v) => PATTERNS.phoneBR.test(v), "Telefone deve ter 11 d\xEDgitos com DDD");
|
|
124
|
+
var emailSchema = zod.z.string().trim().refine((v) => PATTERNS.email.test(v), "E-mail inv\xE1lido");
|
|
125
|
+
var dateDMYSchema = zod.z.string().refine((v) => PATTERNS.dateDMY.test(v), "Data deve estar no formato DD/MM/AAAA").refine((v) => parseDMY(v) !== null, "Data inexistente no calend\xE1rio");
|
|
126
|
+
var birthDateSchema = dateDMYSchema.refine(
|
|
127
|
+
(v) => isAdultDMY(v),
|
|
128
|
+
"\xC9 necess\xE1rio ser maior de idade (18+)"
|
|
129
|
+
);
|
|
130
|
+
var issueDateSchema = dateDMYSchema.refine(
|
|
131
|
+
(v) => isNotFutureDMY(v),
|
|
132
|
+
"Data de emiss\xE3o n\xE3o pode ser futura"
|
|
133
|
+
);
|
|
134
|
+
var currencySchema = zod.z.number({ invalid_type_error: "Valor monet\xE1rio inv\xE1lido" }).positive("Valor deve ser positivo");
|
|
135
|
+
zod.z.number().int("Deve ser um n\xFAmero inteiro").min(1, "M\xEDnimo 1").max(28, "M\xE1ximo 28");
|
|
136
|
+
var THIRD_PARTY_OPTIONS = [
|
|
137
|
+
"nao_se_aplica",
|
|
138
|
+
"conjuge",
|
|
139
|
+
"pai_mae",
|
|
140
|
+
"filho_filha",
|
|
141
|
+
"parente",
|
|
142
|
+
"outro"
|
|
143
|
+
];
|
|
144
|
+
var formalizationExtras = {
|
|
145
|
+
energy_bill_upload: fileUploadField,
|
|
146
|
+
account_third_party: selectField(THIRD_PARTY_OPTIONS),
|
|
147
|
+
bond_document_upload: fileUploadField.optional(),
|
|
148
|
+
document_front_upload: fileUploadField,
|
|
149
|
+
document_back_upload: fileUploadField,
|
|
150
|
+
// RN-014: seguro RD/RE começa ON.
|
|
151
|
+
rd_re_insurance_toggle: zod.z.boolean().default(true)
|
|
152
|
+
};
|
|
153
|
+
function applyCommonRefinements(data, ctx) {
|
|
154
|
+
if ("account_third_party" in data && typeof data.account_third_party === "string" && data.account_third_party !== "nao_se_aplica" && !data.bond_document_upload) {
|
|
155
|
+
ctx.addIssue({
|
|
156
|
+
code: zod.z.ZodIssueCode.custom,
|
|
157
|
+
path: ["bond_document_upload"],
|
|
158
|
+
message: "Documento de v\xEDnculo \xE9 obrigat\xF3rio quando a conta est\xE1 em nome de terceiro"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function applyPjRefinements(data, ctx) {
|
|
163
|
+
applyCommonRefinements(data, ctx);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/domains/financing/formalization/schemas/UnifiedPJSchema.ts
|
|
167
|
+
var unifiedPjObject = zod.z.object({
|
|
168
|
+
...formalizationExtras,
|
|
169
|
+
financing_company: zod.z.object({
|
|
170
|
+
corporate_name: textField(),
|
|
171
|
+
cnpj: cnpjSchema,
|
|
172
|
+
foundation_date: issueDateSchema,
|
|
173
|
+
address: textField(),
|
|
174
|
+
number: textField(),
|
|
175
|
+
email: emailSchema,
|
|
176
|
+
complement: textField(15).optional(),
|
|
177
|
+
phone: phoneBRSchema,
|
|
178
|
+
district: textField(),
|
|
179
|
+
legal_nature: textField(),
|
|
180
|
+
city: textField(),
|
|
181
|
+
state: textField(2),
|
|
182
|
+
cep: cepSchema,
|
|
183
|
+
economic_activity: textField().optional(),
|
|
184
|
+
economic_activity_group: textField().optional(),
|
|
185
|
+
monthly_income: currencySchema.optional(),
|
|
186
|
+
residence_situation: textField().optional(),
|
|
187
|
+
months_in_residence: integerField.optional(),
|
|
188
|
+
capital_social: currencySchema.optional()
|
|
189
|
+
}).strict(),
|
|
190
|
+
financing_company_guarantor: zod.z.array(
|
|
191
|
+
zod.z.object({
|
|
192
|
+
name: textField(),
|
|
193
|
+
cpf: cpfSchema,
|
|
194
|
+
birth_date: birthDateSchema,
|
|
195
|
+
address: textField(),
|
|
196
|
+
number: textField(),
|
|
197
|
+
cep: cepSchema,
|
|
198
|
+
complement: textField(15).optional(),
|
|
199
|
+
cellphone: phoneBRSchema,
|
|
200
|
+
email: emailSchema,
|
|
201
|
+
district: textField(),
|
|
202
|
+
sex: SexEnum,
|
|
203
|
+
city: textField(),
|
|
204
|
+
state: textField(2),
|
|
205
|
+
mother_name: textField(),
|
|
206
|
+
nationality: textField(),
|
|
207
|
+
office: textField().optional(),
|
|
208
|
+
phone: phoneBRSchema.optional(),
|
|
209
|
+
civil_status: textField().optional(),
|
|
210
|
+
residence_situation: textField().optional(),
|
|
211
|
+
months_in_residence: integerField.optional(),
|
|
212
|
+
type_doc: DocumentTypeEnum.optional(),
|
|
213
|
+
doc: textField().optional(),
|
|
214
|
+
issuing_body: textField().optional(),
|
|
215
|
+
uf_issuing_body: textField(2).optional(),
|
|
216
|
+
doc_issue_date: issueDateSchema.optional(),
|
|
217
|
+
doc_expiration_date: dateDMYSchema.optional(),
|
|
218
|
+
monthly_income: currencySchema.optional(),
|
|
219
|
+
patrimony: currencySchema.optional(),
|
|
220
|
+
naturalness: textField().optional(),
|
|
221
|
+
uf_naturalness: textField(2).optional(),
|
|
222
|
+
pep_relationship: textField().optional(),
|
|
223
|
+
entry_date: issueDateSchema.optional(),
|
|
224
|
+
doc_issuance_uf: textField(2).optional()
|
|
225
|
+
}).strict()
|
|
226
|
+
).optional(),
|
|
227
|
+
financing_company_qsa: zod.z.array(
|
|
228
|
+
zod.z.object({
|
|
229
|
+
name: textField(),
|
|
230
|
+
cpf: cpfSchema,
|
|
231
|
+
birth_date: birthDateSchema,
|
|
232
|
+
address: textField(),
|
|
233
|
+
number: textField(),
|
|
234
|
+
cep: cepSchema,
|
|
235
|
+
complement: textField(15).optional(),
|
|
236
|
+
cellphone: phoneBRSchema,
|
|
237
|
+
email: emailSchema,
|
|
238
|
+
district: textField(),
|
|
239
|
+
sex: SexEnum,
|
|
240
|
+
city: textField(),
|
|
241
|
+
state: textField(2),
|
|
242
|
+
mother_name: textField(),
|
|
243
|
+
nationality: textField(),
|
|
244
|
+
office: textField().optional(),
|
|
245
|
+
phone: phoneBRSchema.optional(),
|
|
246
|
+
civil_status: textField().optional(),
|
|
247
|
+
residence_situation: textField().optional(),
|
|
248
|
+
months_in_residence: integerField.optional(),
|
|
249
|
+
type_doc: DocumentTypeEnum.optional(),
|
|
250
|
+
doc: textField().optional(),
|
|
251
|
+
issuing_body: textField().optional(),
|
|
252
|
+
uf_issuing_body: textField(2).optional(),
|
|
253
|
+
doc_issue_date: issueDateSchema.optional(),
|
|
254
|
+
doc_expiration_date: dateDMYSchema.optional(),
|
|
255
|
+
monthly_income: currencySchema.optional(),
|
|
256
|
+
patrimony: currencySchema.optional(),
|
|
257
|
+
naturalness: textField().optional(),
|
|
258
|
+
uf_naturalness: textField(2).optional(),
|
|
259
|
+
pep_relationship: textField().optional(),
|
|
260
|
+
entry_date: issueDateSchema.optional(),
|
|
261
|
+
doc_issuance_uf: textField(2).optional()
|
|
262
|
+
}).strict()
|
|
263
|
+
).optional()
|
|
264
|
+
});
|
|
265
|
+
var unifiedPjSchema = unifiedPjObject.strict().superRefine(applyPjRefinements);
|
|
266
|
+
|
|
267
|
+
exports.unifiedPjObject = unifiedPjObject;
|
|
268
|
+
exports.unifiedPjSchema = unifiedPjSchema;
|
package/index.d.cts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { BANK_SLUGS, Bank, BankEnum, BankSlug, FORMALIZATION_FIELD_META, FormalizationFieldKind, FormalizationFieldMeta, NATIONALITY_BRAZIL, OCCUPATIONS_REQUIRING_CNPJ, PersonType, applyPfRefinements, applyPjRefinements, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './financing/formalization/index.cjs';
|
|
1
|
+
export { BANK_SLUGS, Bank, BankEnum, BankSlug, FORMALIZATION_FIELD_META, FormalizationFieldKind, FormalizationFieldMeta, NATIONALITY_BRAZIL, OCCUPATIONS_REQUIRING_CNPJ, PersonType, UNIFIED_SLUG, UnifiedSlug, applyPfRefinements, applyPjRefinements, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './financing/formalization/index.cjs';
|
|
2
|
+
export { unifiedPfObject, unifiedPfSchema } from './financing/formalization/schemas/UnifiedPFSchema.cjs';
|
|
3
|
+
export { unifiedPjObject, unifiedPjSchema } from './financing/formalization/schemas/UnifiedPJSchema.cjs';
|
|
2
4
|
import 'zod';
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { BANK_SLUGS, Bank, BankEnum, BankSlug, FORMALIZATION_FIELD_META, FormalizationFieldKind, FormalizationFieldMeta, NATIONALITY_BRAZIL, OCCUPATIONS_REQUIRING_CNPJ, PersonType, applyPfRefinements, applyPjRefinements, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './financing/formalization/index.js';
|
|
1
|
+
export { BANK_SLUGS, Bank, BankEnum, BankSlug, FORMALIZATION_FIELD_META, FormalizationFieldKind, FormalizationFieldMeta, NATIONALITY_BRAZIL, OCCUPATIONS_REQUIRING_CNPJ, PersonType, UNIFIED_SLUG, UnifiedSlug, applyPfRefinements, applyPjRefinements, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './financing/formalization/index.js';
|
|
2
|
+
export { unifiedPfObject, unifiedPfSchema } from './financing/formalization/schemas/UnifiedPFSchema.js';
|
|
3
|
+
export { unifiedPjObject, unifiedPjSchema } from './financing/formalization/schemas/UnifiedPJSchema.js';
|
|
2
4
|
import 'zod';
|
package/index.js
CHANGED
|
@@ -1245,8 +1245,155 @@ var solfacilPjObject = zod.z.object({
|
|
|
1245
1245
|
)
|
|
1246
1246
|
});
|
|
1247
1247
|
var solfacilPjSchema = solfacilPjObject.strict().superRefine(applyPjRefinements);
|
|
1248
|
+
var unifiedPfObject = zod.z.object({
|
|
1249
|
+
...formalizationExtras,
|
|
1250
|
+
name: textField(),
|
|
1251
|
+
cep: cepSchema,
|
|
1252
|
+
cpf: cpfSchema,
|
|
1253
|
+
address: textField(),
|
|
1254
|
+
birth_date: birthDateSchema,
|
|
1255
|
+
number: textField(),
|
|
1256
|
+
sex: SexEnum,
|
|
1257
|
+
complement: textField(15).optional(),
|
|
1258
|
+
mother_name: textField(),
|
|
1259
|
+
district: textField(),
|
|
1260
|
+
energy_account_in_requester_name: textField(),
|
|
1261
|
+
city: textField(),
|
|
1262
|
+
energy_bill_owner_document: cpfCnpjSchema.optional(),
|
|
1263
|
+
state: textField(2),
|
|
1264
|
+
nationality: textField(),
|
|
1265
|
+
cellphone: phoneBRSchema,
|
|
1266
|
+
email: emailSchema,
|
|
1267
|
+
monthly_income: currencySchema,
|
|
1268
|
+
profession: textField(),
|
|
1269
|
+
type_doc: DocumentTypeEnum,
|
|
1270
|
+
doc: textField(15),
|
|
1271
|
+
issuing_body: textField(6),
|
|
1272
|
+
doc_issue_date: issueDateSchema,
|
|
1273
|
+
residence_situation: textField().optional(),
|
|
1274
|
+
months_in_residence: integerField.optional(),
|
|
1275
|
+
is_installation_at_requester: textField().optional(),
|
|
1276
|
+
civil_status: textField().optional(),
|
|
1277
|
+
uf_naturalness: textField(2).optional(),
|
|
1278
|
+
naturalness: textField().optional(),
|
|
1279
|
+
nature_of_occupation: textField().optional(),
|
|
1280
|
+
company_time: numberField.optional(),
|
|
1281
|
+
cnpj_proprietary: cnpjSchema.optional(),
|
|
1282
|
+
equity_value: currencySchema.optional(),
|
|
1283
|
+
emitting_state: textField(2).optional(),
|
|
1284
|
+
pep_relationship: textField().optional()
|
|
1285
|
+
});
|
|
1286
|
+
var unifiedPfSchema = unifiedPfObject.strict().superRefine(applyPfRefinements);
|
|
1287
|
+
var unifiedPjObject = zod.z.object({
|
|
1288
|
+
...formalizationExtras,
|
|
1289
|
+
financing_company: zod.z.object({
|
|
1290
|
+
corporate_name: textField(),
|
|
1291
|
+
cnpj: cnpjSchema,
|
|
1292
|
+
foundation_date: issueDateSchema,
|
|
1293
|
+
address: textField(),
|
|
1294
|
+
number: textField(),
|
|
1295
|
+
email: emailSchema,
|
|
1296
|
+
complement: textField(15).optional(),
|
|
1297
|
+
phone: phoneBRSchema,
|
|
1298
|
+
district: textField(),
|
|
1299
|
+
legal_nature: textField(),
|
|
1300
|
+
city: textField(),
|
|
1301
|
+
state: textField(2),
|
|
1302
|
+
cep: cepSchema,
|
|
1303
|
+
economic_activity: textField().optional(),
|
|
1304
|
+
economic_activity_group: textField().optional(),
|
|
1305
|
+
monthly_income: currencySchema.optional(),
|
|
1306
|
+
residence_situation: textField().optional(),
|
|
1307
|
+
months_in_residence: integerField.optional(),
|
|
1308
|
+
capital_social: currencySchema.optional()
|
|
1309
|
+
}).strict(),
|
|
1310
|
+
financing_company_guarantor: zod.z.array(
|
|
1311
|
+
zod.z.object({
|
|
1312
|
+
name: textField(),
|
|
1313
|
+
cpf: cpfSchema,
|
|
1314
|
+
birth_date: birthDateSchema,
|
|
1315
|
+
address: textField(),
|
|
1316
|
+
number: textField(),
|
|
1317
|
+
cep: cepSchema,
|
|
1318
|
+
complement: textField(15).optional(),
|
|
1319
|
+
cellphone: phoneBRSchema,
|
|
1320
|
+
email: emailSchema,
|
|
1321
|
+
district: textField(),
|
|
1322
|
+
sex: SexEnum,
|
|
1323
|
+
city: textField(),
|
|
1324
|
+
state: textField(2),
|
|
1325
|
+
mother_name: textField(),
|
|
1326
|
+
nationality: textField(),
|
|
1327
|
+
office: textField().optional(),
|
|
1328
|
+
phone: phoneBRSchema.optional(),
|
|
1329
|
+
civil_status: textField().optional(),
|
|
1330
|
+
residence_situation: textField().optional(),
|
|
1331
|
+
months_in_residence: integerField.optional(),
|
|
1332
|
+
type_doc: DocumentTypeEnum.optional(),
|
|
1333
|
+
doc: textField().optional(),
|
|
1334
|
+
issuing_body: textField().optional(),
|
|
1335
|
+
uf_issuing_body: textField(2).optional(),
|
|
1336
|
+
doc_issue_date: issueDateSchema.optional(),
|
|
1337
|
+
doc_expiration_date: dateDMYSchema.optional(),
|
|
1338
|
+
monthly_income: currencySchema.optional(),
|
|
1339
|
+
patrimony: currencySchema.optional(),
|
|
1340
|
+
naturalness: textField().optional(),
|
|
1341
|
+
uf_naturalness: textField(2).optional(),
|
|
1342
|
+
pep_relationship: textField().optional(),
|
|
1343
|
+
entry_date: issueDateSchema.optional(),
|
|
1344
|
+
doc_issuance_uf: textField(2).optional()
|
|
1345
|
+
}).strict()
|
|
1346
|
+
).optional(),
|
|
1347
|
+
financing_company_qsa: zod.z.array(
|
|
1348
|
+
zod.z.object({
|
|
1349
|
+
name: textField(),
|
|
1350
|
+
cpf: cpfSchema,
|
|
1351
|
+
birth_date: birthDateSchema,
|
|
1352
|
+
address: textField(),
|
|
1353
|
+
number: textField(),
|
|
1354
|
+
cep: cepSchema,
|
|
1355
|
+
complement: textField(15).optional(),
|
|
1356
|
+
cellphone: phoneBRSchema,
|
|
1357
|
+
email: emailSchema,
|
|
1358
|
+
district: textField(),
|
|
1359
|
+
sex: SexEnum,
|
|
1360
|
+
city: textField(),
|
|
1361
|
+
state: textField(2),
|
|
1362
|
+
mother_name: textField(),
|
|
1363
|
+
nationality: textField(),
|
|
1364
|
+
office: textField().optional(),
|
|
1365
|
+
phone: phoneBRSchema.optional(),
|
|
1366
|
+
civil_status: textField().optional(),
|
|
1367
|
+
residence_situation: textField().optional(),
|
|
1368
|
+
months_in_residence: integerField.optional(),
|
|
1369
|
+
type_doc: DocumentTypeEnum.optional(),
|
|
1370
|
+
doc: textField().optional(),
|
|
1371
|
+
issuing_body: textField().optional(),
|
|
1372
|
+
uf_issuing_body: textField(2).optional(),
|
|
1373
|
+
doc_issue_date: issueDateSchema.optional(),
|
|
1374
|
+
doc_expiration_date: dateDMYSchema.optional(),
|
|
1375
|
+
monthly_income: currencySchema.optional(),
|
|
1376
|
+
patrimony: currencySchema.optional(),
|
|
1377
|
+
naturalness: textField().optional(),
|
|
1378
|
+
uf_naturalness: textField(2).optional(),
|
|
1379
|
+
pep_relationship: textField().optional(),
|
|
1380
|
+
entry_date: issueDateSchema.optional(),
|
|
1381
|
+
doc_issuance_uf: textField(2).optional()
|
|
1382
|
+
}).strict()
|
|
1383
|
+
).optional()
|
|
1384
|
+
});
|
|
1385
|
+
var unifiedPjSchema = unifiedPjObject.strict().superRefine(applyPjRefinements);
|
|
1248
1386
|
|
|
1249
1387
|
// src/domains/financing/formalization/registry.ts
|
|
1388
|
+
var UNIFIED_SLUG = "unified";
|
|
1389
|
+
var unifiedSchemaByPerson = {
|
|
1390
|
+
pf: unifiedPfSchema,
|
|
1391
|
+
pj: unifiedPjSchema
|
|
1392
|
+
};
|
|
1393
|
+
var unifiedBaseSchemaByPerson = {
|
|
1394
|
+
pf: unifiedPfObject,
|
|
1395
|
+
pj: unifiedPjObject
|
|
1396
|
+
};
|
|
1250
1397
|
var pfSchemaRegistry = {
|
|
1251
1398
|
credito77: credito77PfSchema,
|
|
1252
1399
|
losango: losangoPfSchema,
|
|
@@ -1321,12 +1468,18 @@ function isCredito77WithoutPrestamista(bank, person, options) {
|
|
|
1321
1468
|
return bank === "credito77" && person === "pf" && !options.prestamistaIncluso;
|
|
1322
1469
|
}
|
|
1323
1470
|
function getFormalizationSchema(bank, person, options = {}) {
|
|
1471
|
+
if (bank === UNIFIED_SLUG) {
|
|
1472
|
+
return unifiedSchemaByPerson[person];
|
|
1473
|
+
}
|
|
1324
1474
|
if (isCredito77WithoutPrestamista(bank, person, options)) {
|
|
1325
1475
|
return credito77PfObject.omit(CREDITO77_PRESTAMISTA_FIELDS).strict().superRefine(applyPfRefinements);
|
|
1326
1476
|
}
|
|
1327
1477
|
return person === "pf" ? pfSchemaRegistry[bank] : pjSchemaRegistry[bank];
|
|
1328
1478
|
}
|
|
1329
1479
|
function getFormalizationBaseSchema(bank, person, options = {}) {
|
|
1480
|
+
if (bank === UNIFIED_SLUG) {
|
|
1481
|
+
return unifiedBaseSchemaByPerson[person];
|
|
1482
|
+
}
|
|
1330
1483
|
if (isCredito77WithoutPrestamista(bank, person, options)) {
|
|
1331
1484
|
return credito77PfObject.omit(CREDITO77_PRESTAMISTA_FIELDS);
|
|
1332
1485
|
}
|
|
@@ -1434,6 +1587,7 @@ exports.BankEnum = BankEnum;
|
|
|
1434
1587
|
exports.FORMALIZATION_FIELD_META = FORMALIZATION_FIELD_META;
|
|
1435
1588
|
exports.NATIONALITY_BRAZIL = NATIONALITY_BRAZIL;
|
|
1436
1589
|
exports.OCCUPATIONS_REQUIRING_CNPJ = OCCUPATIONS_REQUIRING_CNPJ;
|
|
1590
|
+
exports.UNIFIED_SLUG = UNIFIED_SLUG;
|
|
1437
1591
|
exports.applyPfRefinements = applyPfRefinements;
|
|
1438
1592
|
exports.applyPjRefinements = applyPjRefinements;
|
|
1439
1593
|
exports.getFormalizationBaseSchema = getFormalizationBaseSchema;
|
|
@@ -1442,3 +1596,7 @@ exports.pfBaseSchemaRegistry = pfBaseSchemaRegistry;
|
|
|
1442
1596
|
exports.pfSchemaRegistry = pfSchemaRegistry;
|
|
1443
1597
|
exports.pjBaseSchemaRegistry = pjBaseSchemaRegistry;
|
|
1444
1598
|
exports.pjSchemaRegistry = pjSchemaRegistry;
|
|
1599
|
+
exports.unifiedPfObject = unifiedPfObject;
|
|
1600
|
+
exports.unifiedPfSchema = unifiedPfSchema;
|
|
1601
|
+
exports.unifiedPjObject = unifiedPjObject;
|
|
1602
|
+
exports.unifiedPjSchema = unifiedPjSchema;
|
package/index.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export { BANK_SLUGS, BankEnum, FORMALIZATION_FIELD_META, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './chunk-
|
|
1
|
+
export { BANK_SLUGS, BankEnum, FORMALIZATION_FIELD_META, UNIFIED_SLUG, getFormalizationBaseSchema, getFormalizationSchema, pfBaseSchemaRegistry, pfSchemaRegistry, pjBaseSchemaRegistry, pjSchemaRegistry } from './chunk-KKGV43J4.mjs';
|
|
2
2
|
import './chunk-TTHE6D3Y.mjs';
|
|
3
3
|
import './chunk-MWPQSGDD.mjs';
|
|
4
4
|
import './chunk-RMWCQ6YU.mjs';
|
|
5
5
|
import './chunk-B7RDVG4R.mjs';
|
|
6
6
|
import './chunk-KXEEZLMR.mjs';
|
|
7
7
|
import './chunk-XUMC3TQU.mjs';
|
|
8
|
+
export { unifiedPfObject, unifiedPfSchema } from './chunk-52KJIJBF.mjs';
|
|
9
|
+
export { unifiedPjObject, unifiedPjSchema } from './chunk-XNACW46V.mjs';
|
|
8
10
|
import './chunk-ORO6OVTB.mjs';
|
|
9
11
|
import './chunk-36GQASLI.mjs';
|
|
10
12
|
import './chunk-2TGZGHS3.mjs';
|
package/package.json
CHANGED