@eva_solutions/auth-sdk 0.0.0-stage → 3.0.0-dev-20261109133200
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 +290 -0
- package/LICENSE +21 -0
- package/README.md +481 -2
- package/dist/admin/index.cjs +4 -0
- package/dist/admin/index.d.cts +2 -0
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +1 -0
- package/dist/admin-DjvuvuI8.js +408 -0
- package/dist/admin-DjvuvuI8.js.map +1 -0
- package/dist/admin-Q6lbWqLM.cjs +419 -0
- package/dist/admin-Q6lbWqLM.cjs.map +1 -0
- package/dist/api-path-2Ulruz7R.cjs +34 -0
- package/dist/api-path-2Ulruz7R.cjs.map +1 -0
- package/dist/api-path-B-vSkL2H.js +29 -0
- package/dist/api-path-B-vSkL2H.js.map +1 -0
- package/dist/auth-19r-Q6X2.js +84 -0
- package/dist/auth-19r-Q6X2.js.map +1 -0
- package/dist/auth-DX1N5JA4.cjs +131 -0
- package/dist/auth-DX1N5JA4.cjs.map +1 -0
- package/dist/auth-handlers-B3iJaPln.js +343 -0
- package/dist/auth-handlers-B3iJaPln.js.map +1 -0
- package/dist/auth-handlers-BTbXKJms.d.ts +15 -0
- package/dist/auth-handlers-BTbXKJms.d.ts.map +1 -0
- package/dist/auth-handlers-CDzGFDTu.cjs +404 -0
- package/dist/auth-handlers-CDzGFDTu.cjs.map +1 -0
- package/dist/auth-handlers-DRUUTEtW.d.cts +15 -0
- package/dist/auth-handlers-DRUUTEtW.d.cts.map +1 -0
- package/dist/catalog-CHPqldcj.cjs +172 -0
- package/dist/catalog-CHPqldcj.cjs.map +1 -0
- package/dist/catalog-CIqpzgsM.d.cts +75 -0
- package/dist/catalog-CIqpzgsM.d.cts.map +1 -0
- package/dist/catalog-CIqpzgsM.d.ts +75 -0
- package/dist/catalog-CIqpzgsM.d.ts.map +1 -0
- package/dist/catalog-DqPhtCKZ.js +95 -0
- package/dist/catalog-DqPhtCKZ.js.map +1 -0
- package/dist/config-3avoUa9e.d.cts +95 -0
- package/dist/config-3avoUa9e.d.cts.map +1 -0
- package/dist/config-COX7rGAP.d.ts +95 -0
- package/dist/config-COX7rGAP.d.ts.map +1 -0
- package/dist/constants-BE1_9Tod.cjs +52 -0
- package/dist/constants-BE1_9Tod.cjs.map +1 -0
- package/dist/constants-BY7QZokc.js +29 -0
- package/dist/constants-BY7QZokc.js.map +1 -0
- package/dist/constants-CcbhOaAP.cjs +153 -0
- package/dist/constants-CcbhOaAP.cjs.map +1 -0
- package/dist/constants-rNuD5qJn.js +94 -0
- package/dist/constants-rNuD5qJn.js.map +1 -0
- package/dist/contracts/index.cjs +1006 -0
- package/dist/contracts/index.cjs.map +1 -0
- package/dist/contracts/index.d.cts +488 -0
- package/dist/contracts/index.d.cts.map +1 -0
- package/dist/contracts/index.d.ts +488 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +817 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/cookies-DCIcr7uy.cjs +94 -0
- package/dist/cookies-DCIcr7uy.cjs.map +1 -0
- package/dist/cookies-DKEC7AWv.js +71 -0
- package/dist/cookies-DKEC7AWv.js.map +1 -0
- package/dist/delegated-token-CVNbMNfy.js +426 -0
- package/dist/delegated-token-CVNbMNfy.js.map +1 -0
- package/dist/delegated-token-DHSK4rHI.cjs +461 -0
- package/dist/delegated-token-DHSK4rHI.cjs.map +1 -0
- package/dist/error-helpers-0woh13Wd.d.cts +105 -0
- package/dist/error-helpers-0woh13Wd.d.cts.map +1 -0
- package/dist/error-helpers-Ct3AUK1I.d.ts +105 -0
- package/dist/error-helpers-Ct3AUK1I.d.ts.map +1 -0
- package/dist/error-helpers-XCh4ZJ-g.cjs +282 -0
- package/dist/error-helpers-XCh4ZJ-g.cjs.map +1 -0
- package/dist/error-helpers-lnwgNOw9.js +145 -0
- package/dist/error-helpers-lnwgNOw9.js.map +1 -0
- package/dist/error-messages-CGpW1fsg.d.cts +48 -0
- package/dist/error-messages-CGpW1fsg.d.cts.map +1 -0
- package/dist/error-messages-CGpW1fsg.d.ts +48 -0
- package/dist/error-messages-CGpW1fsg.d.ts.map +1 -0
- package/dist/event-codes-BBJHon-I.cjs +48 -0
- package/dist/event-codes-BBJHon-I.cjs.map +1 -0
- package/dist/event-codes-BgcJWsov.d.cts +42 -0
- package/dist/event-codes-BgcJWsov.d.cts.map +1 -0
- package/dist/event-codes-BgcJWsov.d.ts +42 -0
- package/dist/event-codes-BgcJWsov.d.ts.map +1 -0
- package/dist/event-codes-DR5_VlaR.js +43 -0
- package/dist/event-codes-DR5_VlaR.js.map +1 -0
- package/dist/generic/index.cjs +91 -0
- package/dist/generic/index.cjs.map +1 -0
- package/dist/generic/index.d.cts +27 -0
- package/dist/generic/index.d.cts.map +1 -0
- package/dist/generic/index.d.ts +27 -0
- package/dist/generic/index.d.ts.map +1 -0
- package/dist/generic/index.js +80 -0
- package/dist/generic/index.js.map +1 -0
- package/dist/hono/index.cjs +309 -0
- package/dist/hono/index.cjs.map +1 -0
- package/dist/hono/index.d.cts +272 -0
- package/dist/hono/index.d.cts.map +1 -0
- package/dist/hono/index.d.ts +272 -0
- package/dist/hono/index.d.ts.map +1 -0
- package/dist/hono/index.js +290 -0
- package/dist/hono/index.js.map +1 -0
- package/dist/hono-openapi/index.cjs +326 -0
- package/dist/hono-openapi/index.cjs.map +1 -0
- package/dist/hono-openapi/index.d.cts +14 -0
- package/dist/hono-openapi/index.d.cts.map +1 -0
- package/dist/hono-openapi/index.d.ts +14 -0
- package/dist/hono-openapi/index.d.ts.map +1 -0
- package/dist/hono-openapi/index.js +307 -0
- package/dist/hono-openapi/index.js.map +1 -0
- package/dist/http-client-BVF3iktR.cjs +211 -0
- package/dist/http-client-BVF3iktR.cjs.map +1 -0
- package/dist/http-client-Da0-OMfc.js +206 -0
- package/dist/http-client-Da0-OMfc.js.map +1 -0
- package/dist/index-CIH_2t7Y.d.ts +240 -0
- package/dist/index-CIH_2t7Y.d.ts.map +1 -0
- package/dist/index-CZru7c5T.d.cts +1711 -0
- package/dist/index-CZru7c5T.d.cts.map +1 -0
- package/dist/index-CZru7c5T.d.ts +1711 -0
- package/dist/index-CZru7c5T.d.ts.map +1 -0
- package/dist/index-DMVe5IJA.d.cts +240 -0
- package/dist/index-DMVe5IJA.d.cts.map +1 -0
- package/dist/index-DRWKobSp.d.ts +312 -0
- package/dist/index-DRWKobSp.d.ts.map +1 -0
- package/dist/index-DU9wJ-P2.d.cts +312 -0
- package/dist/index-DU9wJ-P2.d.cts.map +1 -0
- package/dist/index-DbiXllNy.d.cts +66 -0
- package/dist/index-DbiXllNy.d.cts.map +1 -0
- package/dist/index-z9r98qlk.d.ts +66 -0
- package/dist/index-z9r98qlk.d.ts.map +1 -0
- package/dist/index.cjs +89 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +114 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt-BBNqk0TV.cjs +155 -0
- package/dist/jwt-BBNqk0TV.cjs.map +1 -0
- package/dist/jwt-DhqgH94B.js +150 -0
- package/dist/jwt-DhqgH94B.js.map +1 -0
- package/dist/key-resolver-CESqj4-P.cjs +45 -0
- package/dist/key-resolver-CESqj4-P.cjs.map +1 -0
- package/dist/key-resolver-D56I2Zpz.js +34 -0
- package/dist/key-resolver-D56I2Zpz.js.map +1 -0
- package/dist/parse-error-response-6qOQS5y9.cjs +316 -0
- package/dist/parse-error-response-6qOQS5y9.cjs.map +1 -0
- package/dist/parse-error-response-BM9-kjs0.js +239 -0
- package/dist/parse-error-response-BM9-kjs0.js.map +1 -0
- package/dist/path-segment-C25i6aaH.cjs +29 -0
- package/dist/path-segment-C25i6aaH.cjs.map +1 -0
- package/dist/path-segment-CyqnaFrP.js +24 -0
- package/dist/path-segment-CyqnaFrP.js.map +1 -0
- package/dist/react/index.cjs +336 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +151 -0
- package/dist/react/index.d.cts.map +1 -0
- package/dist/react/index.d.ts +151 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +300 -0
- package/dist/react/index.js.map +1 -0
- package/dist/refresh-dedup-CKaHHe7m.js +14 -0
- package/dist/refresh-dedup-CKaHHe7m.js.map +1 -0
- package/dist/refresh-dedup-CLdACQXR.cjs +19 -0
- package/dist/refresh-dedup-CLdACQXR.cjs.map +1 -0
- package/dist/rolldown-runtime-CmQyd0Gu.cjs +27 -0
- package/dist/routes-DpAzgY1V.cjs +424 -0
- package/dist/routes-DpAzgY1V.cjs.map +1 -0
- package/dist/routes-F1g5aVqP.js +347 -0
- package/dist/routes-F1g5aVqP.js.map +1 -0
- package/dist/s2s/index.cjs +24 -0
- package/dist/s2s/index.d.cts +5 -0
- package/dist/s2s/index.d.ts +5 -0
- package/dist/s2s/index.js +5 -0
- package/dist/s2s-6wbotr78.cjs +926 -0
- package/dist/s2s-6wbotr78.cjs.map +1 -0
- package/dist/s2s-B_0SIQzn.js +897 -0
- package/dist/s2s-B_0SIQzn.js.map +1 -0
- package/dist/sign-C7y6xdvT.cjs +324 -0
- package/dist/sign-C7y6xdvT.cjs.map +1 -0
- package/dist/sign-HFtcYwa-.js +259 -0
- package/dist/sign-HFtcYwa-.js.map +1 -0
- package/dist/tokens-C1nzkn21.cjs +232 -0
- package/dist/tokens-C1nzkn21.cjs.map +1 -0
- package/dist/tokens-C3Z40qd7.js +107 -0
- package/dist/tokens-C3Z40qd7.js.map +1 -0
- package/dist/types-Ai3iIFlB.d.cts +538 -0
- package/dist/types-Ai3iIFlB.d.cts.map +1 -0
- package/dist/types-Bxg4hCMc.d.cts +52 -0
- package/dist/types-Bxg4hCMc.d.cts.map +1 -0
- package/dist/types-CEABh1Zf.d.ts +96 -0
- package/dist/types-CEABh1Zf.d.ts.map +1 -0
- package/dist/types-Ci0Jq0xB.d.cts +96 -0
- package/dist/types-Ci0Jq0xB.d.cts.map +1 -0
- package/dist/types-DXg8BvEh.d.ts +52 -0
- package/dist/types-DXg8BvEh.d.ts.map +1 -0
- package/dist/types-_zY7QbM5.d.ts +538 -0
- package/dist/types-_zY7QbM5.d.ts.map +1 -0
- package/dist/webhooks/index.cjs +8 -0
- package/dist/webhooks/index.d.cts +5 -0
- package/dist/webhooks/index.d.ts +5 -0
- package/dist/webhooks/index.js +4 -0
- package/dist/webhooks-B5sAWC9W.js +74 -0
- package/dist/webhooks-B5sAWC9W.js.map +1 -0
- package/dist/webhooks-Cx11psg1.cjs +79 -0
- package/dist/webhooks-Cx11psg1.cjs.map +1 -0
- package/package.json +192 -3
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
import { a as HEADERS, c as USERS_BATCH_MAX_IDS, i as ERROR_CODES, l as WEBHOOK_HEADERS, n as ACTIVITY_STATES, o as INTERNAL_HEADERS, r as DELIVERY_STATUSES, s as PRIVACY_STATES, t as ACCOUNT_STATES, u as WEBHOOK_TIMESTAMP_WINDOW_SECONDS } from "../constants-rNuD5qJn.js";
|
|
2
|
+
import { t as EVENT_CODES } from "../event-codes-DR5_VlaR.js";
|
|
3
|
+
import { a as productoSlugSchema, c as errorResponseSchema, i as loginResponseSchema, n as getCodeResponseSchema, o as setActiveEmpresaRequestSchema, r as loginRequestSchema, s as setActiveEmpresaResponseSchema, t as getCodeRequestSchema } from "../auth-19r-Q6X2.js";
|
|
4
|
+
import { a as INTER_EMPRESA_PERMISSION_LIST, c as interEmpresaPermissionOwner, d as isInterEmpresaPermission, f as isScopeOfAudience, i as INTER_EMPRESA_PERMISSIONS, l as isDelegableAudience, n as DELEGABLE_AUDIENCE_SCOPES, o as SERVICE_AUDIENCES, p as isServiceAudience, r as DELEGABLE_SCOPES, s as SERVICE_AUDIENCE_SCOPES, t as DELEGABLE_AUDIENCES, u as isDelegableScope } from "../catalog-DqPhtCKZ.js";
|
|
5
|
+
import { a as INTERNAL_AUTORIZACION_ROUTES, c as INTERNAL_TOKEN_EXCHANGE_ROUTES, d as SESSION_ROUTES, f as USER_ROUTES, i as DIRECTORIO_ROUTES, l as INTERNAL_TOKEN_ROUTES, n as API_PREFIX, o as INTERNAL_EMPRESA_ROUTES, p as WEBHOOK_ROUTES, r as AUTH_ROUTES, s as INTERNAL_GRUPO_ROUTES, t as ADMIN_ROUTES, u as INTERNAL_USER_ROUTES } from "../routes-F1g5aVqP.js";
|
|
6
|
+
import { _ as TOKEN_EXCHANGE_GRANT_TYPE, a as DELEGATED_TOKEN_TYP, b as USER_TOKEN_TYP, c as SERVICE_KID_PREFIX, d as SERVICE_TOKEN_TYP, f as SUBJECT_TOKEN_HEADER, g as TOKEN_EXCHANGE_ERROR_CODES, h as TOKEN_BEARING_KEYS, i as DELEGATED_TOKEN_MAX_DEPTH, l as SERVICE_TOKEN_ERROR_CODES, m as SUBJECT_TOKEN_INVALID_STATUS, n as AUTH_SERVICE_SUB, o as INTERNAL_SERVICE_TOKEN_LIFETIME_SECONDS, p as SUBJECT_TOKEN_INVALID_CODE, r as DELEGATED_TOKEN_LIFETIME_SECONDS, s as RESERVED_SERVICE_CLIENT_SLUGS, t as ACCESS_TOKEN_TYPE, u as SERVICE_TOKEN_LIFETIME_SECONDS, v as TOKEN_ISSUER, x as isReservedServiceClientSlug, y as USER_KID_PREFIX } from "../tokens-C3Z40qd7.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
// ../auth-contracts/dist/empresa-vocab.js
|
|
9
|
+
/**
|
|
10
|
+
* PURE module: it must never reference `zod` or any schema module of this package (see
|
|
11
|
+
* `constants.ts`). Vocabulary of companies shared by the API, the SDK and the products: roles,
|
|
12
|
+
* company and contract states, directions of an authorization listing.
|
|
13
|
+
*/
|
|
14
|
+
/** Role of a person in a company, from the most to the least powerful. Auth reads it from the DB on every operation. */
|
|
15
|
+
const EMPRESA_ROLES = [
|
|
16
|
+
"titular",
|
|
17
|
+
"administrador",
|
|
18
|
+
"miembro"
|
|
19
|
+
];
|
|
20
|
+
/** True when `role` is at least `minimum` (`titular` > `administrador` > `miembro`). */
|
|
21
|
+
function empresaRoleAtLeast(role, minimum) {
|
|
22
|
+
return EMPRESA_ROLES.indexOf(role) <= EMPRESA_ROLES.indexOf(minimum);
|
|
23
|
+
}
|
|
24
|
+
/** States of a company. A company in `baja` answers 404 to every mutation except `reactivar`. */
|
|
25
|
+
const EMPRESA_ESTADOS = ["activa", "baja"];
|
|
26
|
+
/** States of the contract of a product by a company (`empresa_productos.estado`). */
|
|
27
|
+
const CONTRATACION_ESTADOS = [
|
|
28
|
+
"prueba",
|
|
29
|
+
"pendiente_pago",
|
|
30
|
+
"activo",
|
|
31
|
+
"suspendido",
|
|
32
|
+
"cancelado"
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* The only states that count as contracted (and only while `hasta` is empty or in the future; Auth
|
|
36
|
+
* evaluates it on every read, no event fires when `hasta` passes).
|
|
37
|
+
*/
|
|
38
|
+
const CONTRATACION_ESTADOS_VIGENTES = ["prueba", "activo"];
|
|
39
|
+
/** States billing or the Auth admin can write on any contract row (a product only asks for `pendiente_pago` or `cancelado`). */
|
|
40
|
+
const CONTRATACION_ESTADOS_FACTURACION = [
|
|
41
|
+
"prueba",
|
|
42
|
+
"activo",
|
|
43
|
+
"suspendido",
|
|
44
|
+
"cancelado"
|
|
45
|
+
];
|
|
46
|
+
/** True when a contract in `estado` counts as contracted, ignoring `hasta`. */
|
|
47
|
+
function isContratacionVigente(estado) {
|
|
48
|
+
return CONTRATACION_ESTADOS_VIGENTES.includes(estado);
|
|
49
|
+
}
|
|
50
|
+
/** Directions of the authorizations listing of a company. */
|
|
51
|
+
const AUTORIZACION_DIRECCIONES = ["otorgadas", "recibidas"];
|
|
52
|
+
/** What happens to the previous holder when the Auth admin reassigns the holder of a company. */
|
|
53
|
+
const TITULAR_ANTERIOR_DESTINOS = ["miembro", "fuera"];
|
|
54
|
+
// ../auth-contracts/dist/common.js
|
|
55
|
+
/**
|
|
56
|
+
* SCHEMA module: generic confirmation responses shared by several routes. Descriptions are wire
|
|
57
|
+
* text and must not name routes.
|
|
58
|
+
*/
|
|
59
|
+
/** Response with a confirmation message. */
|
|
60
|
+
const messageResponseSchema = z.object({ data: z.object({ message: z.string().meta({ description: "Mensaje de confirmación" }) }) });
|
|
61
|
+
/** Response with a confirmation message and the number of affected items. */
|
|
62
|
+
const messageWithCountResponseSchema = z.object({ data: z.object({
|
|
63
|
+
message: z.string().meta({ description: "Mensaje de confirmación" }),
|
|
64
|
+
count: z.number().meta({ description: "Cantidad de elementos afectados" })
|
|
65
|
+
}) });
|
|
66
|
+
// ../auth-contracts/dist/empresas.js
|
|
67
|
+
/**
|
|
68
|
+
* SCHEMA module: companies, their branches and members, as exposed by the service-to-service API
|
|
69
|
+
* and the admin surface. Request bodies are strict BASE objects with no refinements (the API adds
|
|
70
|
+
* rules like "at least one field").
|
|
71
|
+
*
|
|
72
|
+
* One mechanism for every action of a person on a company: the backend of a product sends its
|
|
73
|
+
* service token (Bearer, `aud: auth-api`, the route permission) PLUS the access token of the person
|
|
74
|
+
* as `subjectToken` in the body (`SUBJECT_TOKEN_HEADER` on the requests that have no body). The
|
|
75
|
+
* company comes from the route, never from the session. What is reserved to the Auth admin or to
|
|
76
|
+
* billing carries no `subjectToken`.
|
|
77
|
+
*/
|
|
78
|
+
const idSchema$2 = z.string().min(1).max(64);
|
|
79
|
+
/** Access token (`at+jwt`) of the person on whose behalf a product acts. */
|
|
80
|
+
const subjectTokenSchema = z.string().min(1).max(4096).meta({ description: "Access token de la persona que pide la acción" });
|
|
81
|
+
/** Body of the requests that carry nothing but the person (`DELETE` and the like). */
|
|
82
|
+
const subjectTokenRequestSchema = z.object({ subjectToken: subjectTokenSchema }).strict();
|
|
83
|
+
/** Branch of a company. */
|
|
84
|
+
const sucursalSchema = z.object({
|
|
85
|
+
id: z.string().meta({ description: "ID de la sucursal" }),
|
|
86
|
+
empresaId: z.string().meta({ description: "ID de la empresa" }),
|
|
87
|
+
nombre: z.string().meta({ description: "Nombre de la sucursal" }),
|
|
88
|
+
direccion: z.string().nullable().meta({ description: "Dirección de la sucursal" }),
|
|
89
|
+
activa: z.boolean().meta({ description: "false tras la baja lógica de la sucursal" })
|
|
90
|
+
});
|
|
91
|
+
/** Branch as seen by an actor with no product: no address. */
|
|
92
|
+
const sucursalRecortadaSchema = sucursalSchema.pick({
|
|
93
|
+
id: true,
|
|
94
|
+
empresaId: true,
|
|
95
|
+
nombre: true,
|
|
96
|
+
activa: true
|
|
97
|
+
});
|
|
98
|
+
/** Public profile of a company (the directory shows only these fields, and only when `visible`). */
|
|
99
|
+
const empresaPerfilSchema = z.object({
|
|
100
|
+
visible: z.boolean().meta({ description: "La empresa aparece en el directorio (false por defecto)" }),
|
|
101
|
+
rubro: z.string().nullable(),
|
|
102
|
+
ciudad: z.string().nullable(),
|
|
103
|
+
descripcion: z.string().nullable()
|
|
104
|
+
});
|
|
105
|
+
const rubroSchema = z.string().trim().min(1).max(100);
|
|
106
|
+
const ciudadSchema = z.string().trim().min(1).max(100);
|
|
107
|
+
const descripcionSchema = z.string().trim().min(1).max(1e3);
|
|
108
|
+
/** Profile fields of the update body: `null` clears the value. */
|
|
109
|
+
const updateEmpresaPerfilSchema = z.object({
|
|
110
|
+
visible: z.boolean().optional(),
|
|
111
|
+
rubro: rubroSchema.nullable().optional(),
|
|
112
|
+
ciudad: ciudadSchema.nullable().optional(),
|
|
113
|
+
descripcion: descripcionSchema.nullable().optional()
|
|
114
|
+
}).strict();
|
|
115
|
+
const rucSchema = z.string().trim().min(1).max(20);
|
|
116
|
+
const razonSocialSchema = z.string().trim().min(1).max(200);
|
|
117
|
+
const direccionSchema = z.string().min(1).max(500);
|
|
118
|
+
const celularSchema = z.string().min(1).max(30);
|
|
119
|
+
const emailSchema = z.string().trim().toLowerCase().max(254).email();
|
|
120
|
+
const imgSchema = z.string().trim().url().max(2048);
|
|
121
|
+
/**
|
|
122
|
+
* `POST /internal/empresas`. The person of `subjectToken` becomes the holder (`titular`) and the
|
|
123
|
+
* product of the actor is contracted in `prueba`. An actor with no product cannot create companies.
|
|
124
|
+
*/
|
|
125
|
+
const createEmpresaRequestSchema = z.object({
|
|
126
|
+
ruc: rucSchema.meta({ description: "RUC de la empresa" }),
|
|
127
|
+
razonSocial: razonSocialSchema,
|
|
128
|
+
slug: z.string().regex(/^[a-z0-9][a-z0-9-]{1,63}$/, { error: "slug debe matchear ^[a-z0-9][a-z0-9-]{1,63}$" }),
|
|
129
|
+
direccion: direccionSchema.optional(),
|
|
130
|
+
celular: celularSchema.optional(),
|
|
131
|
+
email: emailSchema.optional(),
|
|
132
|
+
subjectToken: subjectTokenSchema
|
|
133
|
+
}).strict();
|
|
134
|
+
/**
|
|
135
|
+
* `PATCH /internal/empresas/{id}`: master data, profile and directory visibility. `ruc` and `slug`
|
|
136
|
+
* are immutable (a body carrying them is rejected by `.strict()`).
|
|
137
|
+
*/
|
|
138
|
+
const updateEmpresaRequestSchema = z.object({
|
|
139
|
+
razonSocial: razonSocialSchema.optional(),
|
|
140
|
+
direccion: direccionSchema.nullable().optional(),
|
|
141
|
+
celular: celularSchema.nullable().optional(),
|
|
142
|
+
email: emailSchema.nullable().optional(),
|
|
143
|
+
img: imgSchema.nullable().optional(),
|
|
144
|
+
perfil: updateEmpresaPerfilSchema.optional(),
|
|
145
|
+
subjectToken: subjectTokenSchema
|
|
146
|
+
}).strict();
|
|
147
|
+
/** Query of `GET /internal/empresas`: the companies that contracted the product of the actor. */
|
|
148
|
+
const listEmpresasQuerySchema = z.object({
|
|
149
|
+
q: z.string().trim().min(1).max(100).optional(),
|
|
150
|
+
cursor: z.string().min(1).max(256).optional()
|
|
151
|
+
}).strict();
|
|
152
|
+
const addEmpresaMemberRequestSchema = z.object({
|
|
153
|
+
userId: idSchema$2,
|
|
154
|
+
subjectToken: subjectTokenSchema
|
|
155
|
+
}).strict();
|
|
156
|
+
/** `PATCH /internal/empresas/{id}/miembros/{userId}`: only the holder changes roles. */
|
|
157
|
+
const updateEmpresaMemberRequestSchema = z.object({
|
|
158
|
+
rol: z.enum(EMPRESA_ROLES),
|
|
159
|
+
subjectToken: subjectTokenSchema
|
|
160
|
+
}).strict();
|
|
161
|
+
/** `DELETE /internal/empresas/{id}/miembros/{userId}`: `userId` = the person of the token leaves by their own account. */
|
|
162
|
+
const removeEmpresaMemberRequestSchema = subjectTokenRequestSchema;
|
|
163
|
+
const createSucursalRequestSchema = z.object({
|
|
164
|
+
nombre: z.string().trim().min(1).max(100),
|
|
165
|
+
direccion: direccionSchema.optional(),
|
|
166
|
+
subjectToken: subjectTokenSchema
|
|
167
|
+
}).strict();
|
|
168
|
+
const updateSucursalRequestSchema = z.object({
|
|
169
|
+
nombre: z.string().trim().min(1).max(100).optional(),
|
|
170
|
+
direccion: direccionSchema.nullable().optional(),
|
|
171
|
+
subjectToken: subjectTokenSchema
|
|
172
|
+
}).strict();
|
|
173
|
+
/** `DELETE /internal/empresas/{id}/sucursales/{sucursalId}` is a logical deactivation (`activa = false`). */
|
|
174
|
+
const deactivateSucursalRequestSchema = subjectTokenRequestSchema;
|
|
175
|
+
/**
|
|
176
|
+
* `POST /admin/empresas/{id}/titular`: dispute over a RUC or a company with no holder. The person
|
|
177
|
+
* becomes the holder; the previous holder (if any) stays as a `miembro` or leaves, as the runbook says.
|
|
178
|
+
*/
|
|
179
|
+
const reassignTitularRequestSchema = z.object({
|
|
180
|
+
userId: idSchema$2,
|
|
181
|
+
titularAnterior: z.enum(TITULAR_ANTERIOR_DESTINOS).optional().default("miembro")
|
|
182
|
+
}).strict();
|
|
183
|
+
const empresaFields = {
|
|
184
|
+
id: z.string().meta({ description: "ID de la empresa" }),
|
|
185
|
+
ruc: z.string().meta({ description: "RUC de la empresa" }),
|
|
186
|
+
razonSocial: z.string().meta({ description: "Razón social" }),
|
|
187
|
+
slug: z.string().meta({ description: "Slug identificador" }),
|
|
188
|
+
direccion: z.string().nullable().meta({ description: "Dirección de la empresa" }),
|
|
189
|
+
celular: z.string().nullable().meta({ description: "Celular de contacto" }),
|
|
190
|
+
email: z.string().nullable().meta({ description: "Email de contacto" }),
|
|
191
|
+
img: z.string().nullable().meta({ description: "URL de imagen/logo" }),
|
|
192
|
+
estado: z.enum(EMPRESA_ESTADOS),
|
|
193
|
+
grupoId: z.string().nullable().meta({ description: "Grupo de empresas al que pertenece, si tiene" }),
|
|
194
|
+
perfil: empresaPerfilSchema
|
|
195
|
+
};
|
|
196
|
+
/** Company as answered by its creation (201) and its update (200). */
|
|
197
|
+
const empresaResponseSchema = z.object({ data: z.object(empresaFields) });
|
|
198
|
+
/** Page of companies; `nextCursor` is `null` on the last page. */
|
|
199
|
+
const listEmpresasResponseSchema = z.object({ data: z.object({
|
|
200
|
+
empresas: z.array(z.object(empresaFields)),
|
|
201
|
+
nextCursor: z.string().nullable()
|
|
202
|
+
}) });
|
|
203
|
+
/** Full view (`GET /internal/empresas/{id}`) for an actor whose product the company contracted. */
|
|
204
|
+
const empresaDetailResponseSchema = z.object({ data: z.object({
|
|
205
|
+
vista: z.literal("completa"),
|
|
206
|
+
...empresaFields,
|
|
207
|
+
sucursales: z.array(sucursalSchema),
|
|
208
|
+
miembros: z.array(z.object({
|
|
209
|
+
userId: z.string(),
|
|
210
|
+
rol: z.enum(EMPRESA_ROLES)
|
|
211
|
+
}))
|
|
212
|
+
}) });
|
|
213
|
+
/** Trimmed view for an actor with no product (a shared service): no contact data, no members. */
|
|
214
|
+
const empresaRecortadaResponseSchema = z.object({ data: z.object({
|
|
215
|
+
vista: z.literal("recortada"),
|
|
216
|
+
id: z.string(),
|
|
217
|
+
razonSocial: z.string(),
|
|
218
|
+
estado: z.enum(EMPRESA_ESTADOS),
|
|
219
|
+
sucursales: z.array(sucursalRecortadaSchema)
|
|
220
|
+
}) });
|
|
221
|
+
/** `GET /internal/empresas/{id}`: one of the two views, told apart by `data.vista`. */
|
|
222
|
+
const getEmpresaResponseSchema = z.object({ data: z.discriminatedUnion("vista", [empresaDetailResponseSchema.shape.data, empresaRecortadaResponseSchema.shape.data]) });
|
|
223
|
+
/** Answer of adding a member (201) and of changing a role (200). */
|
|
224
|
+
const empresaMemberResponseSchema = z.object({ data: z.object({
|
|
225
|
+
empresaId: z.string(),
|
|
226
|
+
userId: z.string(),
|
|
227
|
+
rol: z.enum(EMPRESA_ROLES)
|
|
228
|
+
}) });
|
|
229
|
+
/** Answer of creating (201) and updating (200) a branch. */
|
|
230
|
+
const sucursalResponseSchema = z.object({ data: sucursalSchema });
|
|
231
|
+
/** Answer of `baja` and `reactivar` (internal with `empresas:baja`, and admin). */
|
|
232
|
+
const empresaEstadoResponseSchema = z.object({ data: z.object({
|
|
233
|
+
id: z.string(),
|
|
234
|
+
estado: z.enum(EMPRESA_ESTADOS)
|
|
235
|
+
}) });
|
|
236
|
+
/** Answer of the holder reassignment. */
|
|
237
|
+
const reassignTitularResponseSchema = z.object({ data: z.object({
|
|
238
|
+
empresaId: z.string(),
|
|
239
|
+
titularUserId: z.string(),
|
|
240
|
+
titularAnteriorUserId: z.string().nullable()
|
|
241
|
+
}) });
|
|
242
|
+
// ../auth-contracts/dist/users.js
|
|
243
|
+
/**
|
|
244
|
+
* SCHEMA module: the user profile and its update body. The update body is the strict BASE object
|
|
245
|
+
* with no `.refine`, so the API can plug it into `createRoute` without changing the OpenAPI
|
|
246
|
+
* document; the API adds its own rules ("at least one field", "latitude and longitude together").
|
|
247
|
+
*/
|
|
248
|
+
/** Public profile of a user (allowlist: it carries no internal fields). */
|
|
249
|
+
const publicProfileSchema = z.object({
|
|
250
|
+
id: z.string().meta({ description: "ID del usuario" }),
|
|
251
|
+
phone: z.string().meta({ description: "Teléfono del usuario" }),
|
|
252
|
+
name: z.string().nullable().meta({ description: "Nombre" }),
|
|
253
|
+
lastName: z.string().nullable().meta({ description: "Apellido" }),
|
|
254
|
+
email: z.string().nullable().meta({ description: "Correo electrónico" }),
|
|
255
|
+
dni: z.string().nullable().meta({ description: "Documento de identidad" }),
|
|
256
|
+
stateActivity: z.enum(ACTIVITY_STATES).meta({ description: "Estado de actividad" }),
|
|
257
|
+
statePrivacy: z.enum(PRIVACY_STATES).meta({ description: "Estado de privacidad" }),
|
|
258
|
+
createdAt: z.string().meta({ description: "Fecha de creación" })
|
|
259
|
+
});
|
|
260
|
+
const profileResponseSchema = z.object({ data: publicProfileSchema });
|
|
261
|
+
/** Group a company belongs to (grouping only: it grants no access). */
|
|
262
|
+
const companyGroupSchema = z.object({
|
|
263
|
+
id: z.string().meta({ description: "ID del grupo" }),
|
|
264
|
+
nombre: z.string().meta({ description: "Nombre del grupo" })
|
|
265
|
+
});
|
|
266
|
+
const companyIdentityFields = {
|
|
267
|
+
id: z.string().meta({ description: "ID de la empresa" }),
|
|
268
|
+
ruc: z.string().meta({ description: "RUC de la empresa" }),
|
|
269
|
+
razonSocial: z.string().meta({ description: "Razón social" }),
|
|
270
|
+
slug: z.string().meta({ description: "Slug identificador" }),
|
|
271
|
+
rol: z.enum(EMPRESA_ROLES).meta({ description: "Rol de la persona en la empresa (para mostrar u ocultar pantallas)" }),
|
|
272
|
+
grupo: companyGroupSchema.nullable().meta({ description: "Grupo de la empresa, si tiene" })
|
|
273
|
+
};
|
|
274
|
+
/** Company the user belongs to that has the product of the token contracted. */
|
|
275
|
+
const contractedCompanySchema = z.object({
|
|
276
|
+
...companyIdentityFields,
|
|
277
|
+
contratado: z.literal(true),
|
|
278
|
+
direccion: z.string().nullable().meta({ description: "Dirección de la empresa" }),
|
|
279
|
+
celular: z.string().nullable().meta({ description: "Celular de contacto" }),
|
|
280
|
+
email: z.string().nullable().meta({ description: "Email de contacto" }),
|
|
281
|
+
img: z.string().nullable().meta({ description: "URL de imagen/logo" }),
|
|
282
|
+
sucursales: z.array(sucursalSchema).meta({ description: "Sucursales de la empresa" })
|
|
283
|
+
});
|
|
284
|
+
/**
|
|
285
|
+
* Company the user HOLDS (`titular`) that has not contracted the product of the token: no contact
|
|
286
|
+
* data and no branches, only what is needed to ask for the contract.
|
|
287
|
+
*/
|
|
288
|
+
const uncontractedCompanySchema = z.object({
|
|
289
|
+
...companyIdentityFields,
|
|
290
|
+
contratado: z.literal(false)
|
|
291
|
+
});
|
|
292
|
+
/** Company of the user: with the product contracted (full data) or not (holder only, trimmed). */
|
|
293
|
+
const companySchema = z.discriminatedUnion("contratado", [contractedCompanySchema, uncontractedCompanySchema]);
|
|
294
|
+
/**
|
|
295
|
+
* Companies the user belongs to: the active ones that have the product of the token contracted,
|
|
296
|
+
* plus those the user holds without it (`contratado: false`).
|
|
297
|
+
*/
|
|
298
|
+
const companyListResponseSchema = z.object({ data: z.array(companySchema).meta({ description: "Lista de empresas" }) });
|
|
299
|
+
/** Update body: strict BASE object, every field optional. */
|
|
300
|
+
const updateUserRequestSchema = z.object({
|
|
301
|
+
name: z.string().min(1).max(100).nullable().optional().meta({ description: "Nombre" }),
|
|
302
|
+
lastName: z.string().min(1).max(100).nullable().optional().meta({ description: "Apellido" }),
|
|
303
|
+
email: z.string().trim().toLowerCase().max(254).email().nullable().optional().meta({ description: "Correo electrónico" }),
|
|
304
|
+
dni: z.string().trim().toUpperCase().min(1).max(20).nullable().optional().meta({ description: "Documento de identidad" }),
|
|
305
|
+
address: z.string().min(1).max(500).nullable().optional().meta({ description: "Dirección" }),
|
|
306
|
+
locationLat: z.string().regex(/^-?(?:[0-8]?\d(?:\.\d+)?|90(?:\.0+)?)$/, { error: "Formato de latitud inválido" }).nullable().optional().meta({
|
|
307
|
+
description: "Latitud",
|
|
308
|
+
example: "-34.6037"
|
|
309
|
+
}),
|
|
310
|
+
locationLon: z.string().regex(/^-?(?:\d{1,2}(?:\.\d+)?|1[0-7]\d(?:\.\d+)?|180(?:\.0+)?)$/, { error: "Formato de longitud inválido" }).nullable().optional().meta({
|
|
311
|
+
description: "Longitud",
|
|
312
|
+
example: "-58.3816"
|
|
313
|
+
})
|
|
314
|
+
}).strict();
|
|
315
|
+
// ../auth-contracts/dist/sessions.js
|
|
316
|
+
/** SCHEMA module: the active sessions of the authenticated user. */
|
|
317
|
+
/** Response of the active sessions list. */
|
|
318
|
+
const sessionListResponseSchema = z.object({ data: z.array(z.object({
|
|
319
|
+
sessionId: z.uuid().meta({ description: "ID de la sesión" }),
|
|
320
|
+
deviceType: z.string().meta({ description: "Tipo de dispositivo" }),
|
|
321
|
+
os: z.string().meta({ description: "Sistema operativo" }),
|
|
322
|
+
browser: z.string().meta({ description: "Navegador" }),
|
|
323
|
+
ipAddress: z.string().meta({ description: "Dirección IP" }),
|
|
324
|
+
createdAt: z.string().meta({ description: "Fecha de creación de la sesión" }),
|
|
325
|
+
current: z.boolean().meta({ description: "Indica si es la sesión actual" })
|
|
326
|
+
})).meta({ description: "Lista de sesiones" }) });
|
|
327
|
+
// ../auth-contracts/dist/internal-users.js
|
|
328
|
+
/**
|
|
329
|
+
* SCHEMA module: service-to-service users batch. `ids` is capped at `USERS_BATCH_MAX_IDS`
|
|
330
|
+
* (constants), the hard upper bound: the API env `USERS_BATCH_MAX_IDS` can only lower it, and the
|
|
331
|
+
* published OpenAPI document carries it as `maxItems`.
|
|
332
|
+
*/
|
|
333
|
+
const usersBatchRequestSchema = z.object({ ids: z.array(z.string()).max(100).meta({ description: "IDs de usuarios. Strings que no sean UUID v4 se filtran tolerantemente." }) }).strict();
|
|
334
|
+
const usersBatchResponseSchema = z.object({ data: z.object({ users: z.array(publicProfileSchema).meta({ description: "Usuarios activos encontrados. No se garantiza el orden." }) }) });
|
|
335
|
+
// ../auth-contracts/dist/webhooks.js
|
|
336
|
+
/**
|
|
337
|
+
* SCHEMA module: webhook subscriptions and their deliveries. Request bodies are strict BASE
|
|
338
|
+
* objects with no refinements, and descriptions are wire text: they must not name routes.
|
|
339
|
+
*/
|
|
340
|
+
const UUID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
341
|
+
const webhookUrlSchema = z.string().regex(/^[hH][tT][tT][pP][sS]?:\/\/[^\s\x00-\x1F\x7F]+$/).url({ protocol: /^https?$/ }).max(2048);
|
|
342
|
+
const eventCodesSchema = z.array(z.enum(EVENT_CODES)).min(1).max(32);
|
|
343
|
+
const createSubscriptionRequestSchema = z.object({
|
|
344
|
+
url: webhookUrlSchema,
|
|
345
|
+
eventCodes: eventCodesSchema,
|
|
346
|
+
enabled: z.boolean().optional().default(true)
|
|
347
|
+
}).strict();
|
|
348
|
+
const updateSubscriptionRequestSchema = z.object({
|
|
349
|
+
url: webhookUrlSchema.optional(),
|
|
350
|
+
eventCodes: eventCodesSchema.optional(),
|
|
351
|
+
enabled: z.boolean().optional()
|
|
352
|
+
}).strict();
|
|
353
|
+
/** Query of the deliveries listing: numbers arrive as strings and are coerced. */
|
|
354
|
+
const deliveriesQuerySchema = z.object({
|
|
355
|
+
event_id: z.string().regex(UUID_REGEX).optional(),
|
|
356
|
+
subscription_id: z.string().regex(UUID_REGEX).optional(),
|
|
357
|
+
status: z.enum(DELIVERY_STATUSES).optional(),
|
|
358
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
359
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
360
|
+
}).strict();
|
|
361
|
+
/**
|
|
362
|
+
* Query of `POST /admin/webhooks/republish-pending`: pending deliveries older than
|
|
363
|
+
* `older_than_minutes` (default 10, at most one week) are republished, `limit` per call (default
|
|
364
|
+
* and maximum 100, one QStash batch). Strict: a misspelled parameter fails instead of being ignored.
|
|
365
|
+
*/
|
|
366
|
+
const republishPendingQuerySchema = z.object({
|
|
367
|
+
older_than_minutes: z.coerce.number().int().min(1).max(10080).default(10),
|
|
368
|
+
limit: z.coerce.number().int().min(1).max(100).default(100)
|
|
369
|
+
}).strict();
|
|
370
|
+
const republishPendingResponseSchema = z.object({ data: z.object({
|
|
371
|
+
republished: z.number().int().meta({ description: "Entregas republicadas en QStash en esta llamada" }),
|
|
372
|
+
hasMore: z.boolean().meta({ description: "true si quedan más entregas pending viejas: vuelve a llamar" })
|
|
373
|
+
}) });
|
|
374
|
+
const subscriptionSchema = z.object({
|
|
375
|
+
id: z.string().meta({ description: "ID de la subscription" }),
|
|
376
|
+
clientId: z.string().meta({ description: "ID del cliente" }),
|
|
377
|
+
url: z.string().meta({ description: "URL del webhook" }),
|
|
378
|
+
eventCodes: z.array(z.string()).meta({ description: "Eventos suscritos" }),
|
|
379
|
+
enabled: z.boolean().meta({ description: "Estado activo" }),
|
|
380
|
+
createdAt: z.string().meta({ description: "Fecha de creación" }),
|
|
381
|
+
updatedAt: z.string().meta({ description: "Fecha de actualización" })
|
|
382
|
+
});
|
|
383
|
+
/** Creation answer: the signing key travels only here, one time. */
|
|
384
|
+
const subscriptionWithSecretResponseSchema = z.object({ data: z.object({
|
|
385
|
+
subscription: subscriptionSchema,
|
|
386
|
+
signingKey: z.string().meta({ description: "Signing key one-time" })
|
|
387
|
+
}) });
|
|
388
|
+
const subscriptionResponseSchema = z.object({ data: subscriptionSchema });
|
|
389
|
+
const subscriptionListResponseSchema = z.object({ data: z.object({ subscriptions: z.array(subscriptionSchema).meta({ description: "Lista de subscriptions del cliente" }) }) });
|
|
390
|
+
const rotateSubscriptionSecretResponseSchema = z.object({ data: z.object({
|
|
391
|
+
id: z.string().meta({ description: "ID de la subscription" }),
|
|
392
|
+
signingKey: z.string().meta({ description: "Nueva signing key one-time" }),
|
|
393
|
+
updatedAt: z.string().meta({ description: "Fecha de actualización" })
|
|
394
|
+
}) });
|
|
395
|
+
const deliverySchema = z.object({
|
|
396
|
+
id: z.string().meta({ description: "ID del delivery" }),
|
|
397
|
+
subscriptionId: z.string().meta({ description: "ID de la subscription" }),
|
|
398
|
+
eventId: z.string().meta({ description: "ID del evento" }),
|
|
399
|
+
status: z.enum(DELIVERY_STATUSES).meta({ description: "Estado del delivery" }),
|
|
400
|
+
attempts: z.number().meta({ description: "Número de intentos" }),
|
|
401
|
+
lastAttemptAt: z.string().nullable().meta({ description: "Último intento" }),
|
|
402
|
+
nextRetryAt: z.string().nullable().meta({ description: "Próximo retry" }),
|
|
403
|
+
responseStatus: z.number().nullable().meta({ description: "HTTP status de respuesta" }),
|
|
404
|
+
createdAt: z.string().meta({ description: "Fecha de creación" })
|
|
405
|
+
});
|
|
406
|
+
const deliveryListResponseSchema = z.object({ data: z.object({ deliveries: z.array(deliverySchema).meta({ description: "Lista de deliveries" }) }) });
|
|
407
|
+
// ../auth-contracts/dist/maintenance.js
|
|
408
|
+
/**
|
|
409
|
+
* SCHEMA module: on-demand cleanup of expired data (admin). The query is a strict BASE object with
|
|
410
|
+
* no refinements, and descriptions are wire text: they must not name routes.
|
|
411
|
+
*/
|
|
412
|
+
/**
|
|
413
|
+
* Query of `POST /admin/maintenance/cleanup`: `limit` (default and maximum 100) caps each of the two
|
|
414
|
+
* batches of one call. Strict: a misspelled parameter fails instead of being ignored.
|
|
415
|
+
*/
|
|
416
|
+
const maintenanceCleanupQuerySchema = z.object({ limit: z.coerce.number().int().min(1).max(100).default(100) }).strict();
|
|
417
|
+
const maintenanceCleanupResponseSchema = z.object({ data: z.object({
|
|
418
|
+
usersPurged: z.number().int().meta({ description: "Cuentas eliminadas con la ventana de restauración vencida, purgadas en esta llamada" }),
|
|
419
|
+
eventsDeleted: z.number().int().meta({ description: "Eventos de webhook sin entregas vivas y fuera de la retención, borrados en esta llamada" }),
|
|
420
|
+
hasMore: z.boolean().meta({ description: "true si queda más por limpiar: vuelve a llamar" })
|
|
421
|
+
}) });
|
|
422
|
+
// ../auth-contracts/dist/service-clients.js
|
|
423
|
+
/**
|
|
424
|
+
* SCHEMA module: service client provisioning (admin) and the user restore answer. The update body
|
|
425
|
+
* is the strict BASE object: the API adds its own "at least one field" rule on top of it, so this
|
|
426
|
+
* package never carries a refinement. The format of the generated key stays in the API.
|
|
427
|
+
*/
|
|
428
|
+
/** Human readable slug: starts with a lower case letter, 3 to 64 chars of `[a-z0-9-]`. */
|
|
429
|
+
const serviceClientSlugSchema = z.string().regex(/^[a-z][a-z0-9-]{2,63}$/, { error: "slug debe matchear ^[a-z][a-z0-9-]{2,63}$" });
|
|
430
|
+
/**
|
|
431
|
+
* Permissions of one audience without repeats. Duplicates are removed (first order kept) instead
|
|
432
|
+
* of rejected: repeating a scope does not change what is granted. At least one is required (a
|
|
433
|
+
* grant with no permissions is removed, not stored) and the input list is bounded (repeats
|
|
434
|
+
* included) so a request cannot carry an arbitrarily long array.
|
|
435
|
+
*/
|
|
436
|
+
const scopesOf$1 = (scopes) => z.array(z.enum(scopes)).min(1).max(16).transform((list) => [...new Set(list)]);
|
|
437
|
+
/**
|
|
438
|
+
* Create or replace the grant of a service client on one audience. One variant per audience of the
|
|
439
|
+
* catalog, so a permission typo or a permission of another audience (`admin` on `auth-api`) is
|
|
440
|
+
* rejected by the schema itself. A test pins that every audience has its variant.
|
|
441
|
+
*/
|
|
442
|
+
const setServiceClientGrantRequestSchema = z.discriminatedUnion("audience", [z.object({
|
|
443
|
+
audience: z.literal("auth-api"),
|
|
444
|
+
scopes: scopesOf$1(SERVICE_AUDIENCE_SCOPES["auth-api"])
|
|
445
|
+
}).strict(), z.object({
|
|
446
|
+
audience: z.literal("whatsapp-api"),
|
|
447
|
+
scopes: scopesOf$1(SERVICE_AUDIENCE_SCOPES["whatsapp-api"])
|
|
448
|
+
}).strict()]);
|
|
449
|
+
const serviceClientGrantSchema = z.object({
|
|
450
|
+
audience: z.enum(SERVICE_AUDIENCES),
|
|
451
|
+
scopes: z.array(z.string())
|
|
452
|
+
}).meta({ id: "ServiceClientGrant" });
|
|
453
|
+
/**
|
|
454
|
+
* Identity of a backend: the product it belongs to (FK to `productos`) and the service audience it
|
|
455
|
+
* IS. Both are set by the admin and may be absent. Product slugs and audiences never coincide.
|
|
456
|
+
* `null` clears the value on update.
|
|
457
|
+
*/
|
|
458
|
+
const productoOfClientSchema = productoSlugSchema.meta({ description: "Producto al que pertenece el backend" });
|
|
459
|
+
const audienciaOfClientSchema = z.enum(SERVICE_AUDIENCES).meta({ description: "Servicio que ES el backend (audiencia del catálogo, única)" });
|
|
460
|
+
const createServiceClientRequestSchema = z.object({
|
|
461
|
+
slug: serviceClientSlugSchema,
|
|
462
|
+
name: z.string().min(1).max(100).optional(),
|
|
463
|
+
producto: productoOfClientSchema.optional(),
|
|
464
|
+
audiencia: audienciaOfClientSchema.optional(),
|
|
465
|
+
esAdmin: z.boolean().optional().default(false).meta({ description: "Marca de administrador de Auth: autoriza la superficie /admin firmada" })
|
|
466
|
+
}).strict();
|
|
467
|
+
/** Update body: strict BASE object, every field optional. */
|
|
468
|
+
const updateServiceClientRequestSchema = z.object({
|
|
469
|
+
enabled: z.boolean().optional(),
|
|
470
|
+
esAdmin: z.boolean().optional(),
|
|
471
|
+
name: z.string().min(1).max(100).optional(),
|
|
472
|
+
producto: productoOfClientSchema.nullable().optional(),
|
|
473
|
+
audiencia: audienciaOfClientSchema.nullable().optional()
|
|
474
|
+
}).strict();
|
|
475
|
+
/** Public view of a service client: it never carries the stored key material. */
|
|
476
|
+
const serviceClientPublicSchema = z.object({
|
|
477
|
+
id: z.string().uuid(),
|
|
478
|
+
slug: z.string(),
|
|
479
|
+
name: z.string(),
|
|
480
|
+
enabled: z.boolean(),
|
|
481
|
+
esAdmin: z.boolean(),
|
|
482
|
+
producto: z.string().nullable(),
|
|
483
|
+
audiencia: z.enum(SERVICE_AUDIENCES).nullable(),
|
|
484
|
+
grants: z.array(serviceClientGrantSchema),
|
|
485
|
+
lastUsedAt: z.union([z.string(), z.null()]),
|
|
486
|
+
createdAt: z.string(),
|
|
487
|
+
updatedAt: z.string()
|
|
488
|
+
}).meta({ id: "ServiceClientPublic" });
|
|
489
|
+
/** Creation answer: the generated key travels only here, one time. */
|
|
490
|
+
const createServiceClientResponseSchema = z.object({ data: z.object({
|
|
491
|
+
id: z.string().uuid(),
|
|
492
|
+
slug: z.string(),
|
|
493
|
+
name: z.string(),
|
|
494
|
+
esAdmin: z.boolean(),
|
|
495
|
+
producto: z.string().nullable(),
|
|
496
|
+
audiencia: z.enum(SERVICE_AUDIENCES).nullable(),
|
|
497
|
+
enabled: z.literal(true),
|
|
498
|
+
secret: z.string(),
|
|
499
|
+
warning: z.string()
|
|
500
|
+
}) }).meta({ id: "AdminCreateResponse" });
|
|
501
|
+
const listServiceClientsResponseSchema = z.object({ data: z.object({ clientes: z.array(serviceClientPublicSchema) }) }).meta({ id: "AdminListResponse" });
|
|
502
|
+
const getServiceClientResponseSchema = z.object({ data: z.object({ cliente: serviceClientPublicSchema }) }).meta({ id: "AdminDetailResponse" });
|
|
503
|
+
const listServiceClientGrantsResponseSchema = z.object({ data: z.object({ grants: z.array(serviceClientGrantSchema) }) }).meta({ id: "AdminGrantsResponse" });
|
|
504
|
+
const setServiceClientGrantResponseSchema = z.object({ data: z.object({ grant: serviceClientGrantSchema }) }).meta({ id: "AdminGrantResponse" });
|
|
505
|
+
const updateServiceClientResponseSchema = z.object({ data: z.object({
|
|
506
|
+
cliente: serviceClientPublicSchema,
|
|
507
|
+
warning: z.string().optional()
|
|
508
|
+
}) }).meta({ id: "AdminUpdateResponse" });
|
|
509
|
+
const rotateServiceClientSecretResponseSchema = z.object({ data: z.object({
|
|
510
|
+
slug: z.string(),
|
|
511
|
+
secret: z.string(),
|
|
512
|
+
warning: z.string()
|
|
513
|
+
}) }).meta({ id: "AdminRotateSecretResponse" });
|
|
514
|
+
const restoreUserResponseSchema = z.object({ data: z.object({
|
|
515
|
+
userId: z.string().uuid().meta({ description: "ID del usuario restaurado" }),
|
|
516
|
+
stateAccount: z.literal("no_verificado").meta({ description: "Estado de cuenta tras la restauración (siempre no_verificado)" }),
|
|
517
|
+
previouslyDeletedAt: z.string().nullable().meta({ description: "Timestamp ISO 8601 de cuando fue eliminado originalmente" }),
|
|
518
|
+
restoredAt: z.string().meta({ description: "Timestamp ISO 8601 de la restauración" })
|
|
519
|
+
}) }).meta({ id: "AdminRestaurarUsuarioResponse" });
|
|
520
|
+
// ../auth-contracts/dist/service-tokens.js
|
|
521
|
+
/**
|
|
522
|
+
* SCHEMA module: the service token endpoint. Unlike the rest of the API its bodies are NOT wrapped
|
|
523
|
+
* in `{ data }` nor `{ error: { code, message } }`: they follow RFC 6749 (5.1 success, 5.2 errors),
|
|
524
|
+
* so any OAuth-aware client can read them.
|
|
525
|
+
*
|
|
526
|
+
* `audience` is a plain string on purpose: an unknown audience is answered with `invalid_target`
|
|
527
|
+
* (RFC 8707), not with a validation error. The API checks it against the audience catalog.
|
|
528
|
+
*/
|
|
529
|
+
const serviceTokenRequestSchema = z.object({
|
|
530
|
+
audience: z.string().min(1).max(64).meta({
|
|
531
|
+
description: "Servicio destino del token (audiencia del catálogo)",
|
|
532
|
+
example: "whatsapp-api"
|
|
533
|
+
}),
|
|
534
|
+
scope: z.string().min(1).max(512).optional().meta({ description: "Permisos pedidos separados por espacio; si falta se conceden todos los concedidos para la audiencia" })
|
|
535
|
+
}).strict();
|
|
536
|
+
const serviceTokenResponseSchema = z.object({
|
|
537
|
+
access_token: z.string().meta({ description: "JWT de servicio firmado" }),
|
|
538
|
+
token_type: z.literal("Bearer"),
|
|
539
|
+
expires_in: z.number().int().positive().meta({ description: "Segundos de vida desde la respuesta" }),
|
|
540
|
+
scope: z.string().meta({ description: "Permisos concedidos separados por espacio" })
|
|
541
|
+
}).meta({ id: "ServiceTokenResponse" });
|
|
542
|
+
const serviceTokenErrorSchema = z.object({
|
|
543
|
+
error: z.enum(SERVICE_TOKEN_ERROR_CODES),
|
|
544
|
+
error_description: z.string().optional()
|
|
545
|
+
}).meta({ id: "ServiceTokenError" });
|
|
546
|
+
// ../auth-contracts/dist/productos.js
|
|
547
|
+
/**
|
|
548
|
+
* SCHEMA module: products (the audience of the user access token) as administered through the
|
|
549
|
+
* signed `/admin` surface. There is no delete: a product is disabled. The API applies the rules
|
|
550
|
+
* the contract does not carry (no refinements here): a slug that equals a service audience
|
|
551
|
+
* (`isServiceAudience`) is a 400, and an update body with no field is a 400.
|
|
552
|
+
*/
|
|
553
|
+
const nombreSchema$1 = z.string().trim().min(1).max(100);
|
|
554
|
+
const productoSchema = z.object({
|
|
555
|
+
slug: z.string(),
|
|
556
|
+
nombre: z.string(),
|
|
557
|
+
enabled: z.boolean()
|
|
558
|
+
}).meta({ id: "Producto" });
|
|
559
|
+
const createProductoRequestSchema = z.object({
|
|
560
|
+
slug: productoSlugSchema,
|
|
561
|
+
nombre: nombreSchema$1,
|
|
562
|
+
enabled: z.boolean().optional().default(true)
|
|
563
|
+
}).strict();
|
|
564
|
+
/** Update body: strict BASE object, every field optional. */
|
|
565
|
+
const updateProductoRequestSchema = z.object({
|
|
566
|
+
nombre: nombreSchema$1.optional(),
|
|
567
|
+
enabled: z.boolean().optional()
|
|
568
|
+
}).strict();
|
|
569
|
+
const listProductosResponseSchema = z.object({ data: z.object({ productos: z.array(productoSchema) }) }).meta({ id: "AdminProductosResponse" });
|
|
570
|
+
/** Answer of creating (201) and of updating (200) a product. */
|
|
571
|
+
const productoResponseSchema = z.object({ data: z.object({ producto: productoSchema }) }).meta({ id: "AdminProductoResponse" });
|
|
572
|
+
// ../auth-contracts/dist/token-exchange.js
|
|
573
|
+
const tokenExchangeRequestSchema = z.object({
|
|
574
|
+
grant_type: z.literal(TOKEN_EXCHANGE_GRANT_TYPE),
|
|
575
|
+
subject_token: z.string().min(1).max(4096).meta({ description: "Access token del usuario (aud = producto del actor) o token delegado (aud = audiencia del actor)" }),
|
|
576
|
+
subject_token_type: z.literal(ACCESS_TOKEN_TYPE),
|
|
577
|
+
audience: z.string().min(1).max(64).meta({
|
|
578
|
+
description: "Servicio destino del token delegado (una sola audiencia)",
|
|
579
|
+
example: "whatsapp-api"
|
|
580
|
+
}),
|
|
581
|
+
scope: z.string().min(1).max(512).optional().meta({ description: "Permisos pedidos separados por espacio; si falta se emite todo lo delegable para esa arista" })
|
|
582
|
+
}).strict();
|
|
583
|
+
const tokenExchangeResponseSchema = z.object({
|
|
584
|
+
access_token: z.string().meta({ description: "JWT delegado firmado" }),
|
|
585
|
+
issued_token_type: z.literal(ACCESS_TOKEN_TYPE),
|
|
586
|
+
token_type: z.literal("Bearer"),
|
|
587
|
+
expires_in: z.number().int().positive().meta({ description: "Segundos de vida desde la respuesta" }),
|
|
588
|
+
scope: z.string().meta({ description: "Permisos emitidos separados por espacio" })
|
|
589
|
+
}).meta({ id: "TokenExchangeResponse" });
|
|
590
|
+
const tokenExchangeErrorSchema = z.object({
|
|
591
|
+
error: z.enum(TOKEN_EXCHANGE_ERROR_CODES),
|
|
592
|
+
error_description: z.string().optional()
|
|
593
|
+
}).meta({ id: "TokenExchangeError" });
|
|
594
|
+
// ../auth-contracts/dist/contrataciones.js
|
|
595
|
+
/**
|
|
596
|
+
* SCHEMA module: contracts of a product by a company (`empresa_productos`). A product asks for
|
|
597
|
+
* its own contract (`POST`) or cancels it (`DELETE`) with its service token (permission
|
|
598
|
+
* `contrataciones:pedir`, grantable to products) plus the access token
|
|
599
|
+
* of a holder (`subjectToken`, see `empresas.ts`); billing (permission `contrataciones:escribir`, never granted to a product,
|
|
600
|
+
* no product) and the Auth admin write any row with `PUT`. Only `prueba` and `activo`, with
|
|
601
|
+
* `hasta` empty or in the future, count as contracted.
|
|
602
|
+
*/
|
|
603
|
+
const contratacionSchema = z.object({
|
|
604
|
+
empresaId: z.string(),
|
|
605
|
+
producto: z.string(),
|
|
606
|
+
estado: z.enum(CONTRATACION_ESTADOS),
|
|
607
|
+
desde: z.string().meta({ description: "Timestamp ISO 8601 de inicio" }),
|
|
608
|
+
hasta: z.string().nullable().meta({ description: "Timestamp ISO 8601 de vencimiento; null = sin vencimiento" }),
|
|
609
|
+
actualizadoEn: z.string()
|
|
610
|
+
});
|
|
611
|
+
/**
|
|
612
|
+
* `PUT .../productos/{producto}` (billing and the Auth admin). `hasta` omitted leaves it as is;
|
|
613
|
+
* `null` removes the end; a value sets (or extends) it.
|
|
614
|
+
*/
|
|
615
|
+
const setContratacionRequestSchema = z.object({
|
|
616
|
+
estado: z.enum(CONTRATACION_ESTADOS_FACTURACION),
|
|
617
|
+
hasta: z.iso.datetime({ offset: true }).nullable().optional()
|
|
618
|
+
}).strict();
|
|
619
|
+
/** Answer of asking for (201) and of writing (200) a contract. */
|
|
620
|
+
const contratacionResponseSchema = z.object({ data: contratacionSchema });
|
|
621
|
+
/** `GET /internal/empresas/{id}/productos/{producto}`: for shared services that serve service-to-service calls. */
|
|
622
|
+
const contratadoResponseSchema = z.object({ data: z.object({ contratado: z.boolean() }) });
|
|
623
|
+
// ../auth-contracts/dist/grupos.js
|
|
624
|
+
/**
|
|
625
|
+
* SCHEMA module: groups of companies (grouping only, they grant no access: membership stays per
|
|
626
|
+
* company). Only a holder (`titular`) groups: every request carries the `subjectToken` of a person
|
|
627
|
+
* who holds the companies involved. A group left with no companies deletes itself.
|
|
628
|
+
*/
|
|
629
|
+
const idSchema$1 = z.string().min(1).max(64);
|
|
630
|
+
const nombreSchema = z.string().trim().min(1).max(100);
|
|
631
|
+
const grupoSchema = z.object({
|
|
632
|
+
id: z.string(),
|
|
633
|
+
nombre: z.string(),
|
|
634
|
+
empresaIds: z.array(z.string())
|
|
635
|
+
});
|
|
636
|
+
/** Creates a group with one company of the person. */
|
|
637
|
+
const createGrupoRequestSchema = z.object({
|
|
638
|
+
nombre: nombreSchema,
|
|
639
|
+
empresaId: idSchema$1,
|
|
640
|
+
subjectToken: subjectTokenSchema
|
|
641
|
+
}).strict();
|
|
642
|
+
/** Renaming: a holder of any company of the group. */
|
|
643
|
+
const renameGrupoRequestSchema = z.object({
|
|
644
|
+
nombre: nombreSchema,
|
|
645
|
+
subjectToken: subjectTokenSchema
|
|
646
|
+
}).strict();
|
|
647
|
+
const addGrupoEmpresaRequestSchema = z.object({
|
|
648
|
+
empresaId: idSchema$1,
|
|
649
|
+
subjectToken: subjectTokenSchema
|
|
650
|
+
}).strict();
|
|
651
|
+
const removeGrupoEmpresaRequestSchema = subjectTokenRequestSchema;
|
|
652
|
+
/** Answer of creating (201), renaming (200) and adding a company (201). */
|
|
653
|
+
const grupoResponseSchema = z.object({ data: grupoSchema });
|
|
654
|
+
// ../auth-contracts/dist/directorio.js
|
|
655
|
+
/**
|
|
656
|
+
* SCHEMA module: the directory of companies, the only cross-company search. Open to users with the
|
|
657
|
+
* access token of any enabled product (rate limited per user) and to services with
|
|
658
|
+
* `directorio:leer`. Only active, opted-in companies, only the public profile fields, at most 50
|
|
659
|
+
* per page.
|
|
660
|
+
*/
|
|
661
|
+
const directorioQuerySchema = z.object({
|
|
662
|
+
q: z.string().trim().min(1).max(100).optional(),
|
|
663
|
+
rubro: z.string().trim().min(1).max(100).optional(),
|
|
664
|
+
ciudad: z.string().trim().min(1).max(100).optional(),
|
|
665
|
+
cursor: z.string().min(1).max(256).optional()
|
|
666
|
+
}).strict();
|
|
667
|
+
const directorioEmpresaSchema = z.object({
|
|
668
|
+
id: z.string(),
|
|
669
|
+
razonSocial: z.string(),
|
|
670
|
+
rubro: z.string().nullable(),
|
|
671
|
+
ciudad: z.string().nullable(),
|
|
672
|
+
descripcion: z.string().nullable(),
|
|
673
|
+
img: z.string().nullable()
|
|
674
|
+
});
|
|
675
|
+
const directorioResponseSchema = z.object({ data: z.object({
|
|
676
|
+
empresas: z.array(directorioEmpresaSchema),
|
|
677
|
+
nextCursor: z.string().nullable()
|
|
678
|
+
}) });
|
|
679
|
+
// ../auth-contracts/dist/autorizaciones.js
|
|
680
|
+
/**
|
|
681
|
+
* SCHEMA module: authorizations between companies, only for private data. The permission is one
|
|
682
|
+
* of the closed inter-company catalog (`INTER_EMPRESA_PERMISSIONS`), never a service permission.
|
|
683
|
+
* An administrator or the holder of the grantor grants and revokes; one of the beneficiary can
|
|
684
|
+
* renounce (all with the `subjectToken` mechanism of `empresas.ts`). Which permissions a product
|
|
685
|
+
* may grant is administered with `producto_permisos_autorizables`.
|
|
686
|
+
*/
|
|
687
|
+
const idSchema = z.string().min(1).max(64);
|
|
688
|
+
const interEmpresaPermissionSchema = z.enum(INTER_EMPRESA_PERMISSION_LIST);
|
|
689
|
+
const createAutorizacionRequestSchema = z.object({
|
|
690
|
+
beneficiariaId: idSchema,
|
|
691
|
+
permiso: interEmpresaPermissionSchema,
|
|
692
|
+
subjectToken: subjectTokenSchema
|
|
693
|
+
}).strict();
|
|
694
|
+
/** `DELETE`: revocation by the grantor or renunciation by the beneficiary. */
|
|
695
|
+
const deleteAutorizacionRequestSchema = subjectTokenRequestSchema;
|
|
696
|
+
/** Query of `GET /internal/empresas/{id}/autorizaciones` (the person goes in `SUBJECT_TOKEN_HEADER`). */
|
|
697
|
+
const listAutorizacionesQuerySchema = z.object({ direccion: z.enum(AUTORIZACION_DIRECCIONES) }).strict();
|
|
698
|
+
/**
|
|
699
|
+
* Query of `GET /internal/autorizaciones/verificar`: only for actors whose audience owns the
|
|
700
|
+
* permission (the actor may also have a product). Valid only while both companies are active.
|
|
701
|
+
*/
|
|
702
|
+
const verificarAutorizacionQuerySchema = z.object({
|
|
703
|
+
otorgante: idSchema,
|
|
704
|
+
beneficiaria: idSchema,
|
|
705
|
+
permiso: interEmpresaPermissionSchema
|
|
706
|
+
}).strict();
|
|
707
|
+
/** Authorization in force. */
|
|
708
|
+
const autorizacionSchema = z.object({
|
|
709
|
+
id: z.string(),
|
|
710
|
+
otorganteId: z.string(),
|
|
711
|
+
beneficiariaId: z.string(),
|
|
712
|
+
permiso: z.string(),
|
|
713
|
+
creadaEn: z.string(),
|
|
714
|
+
creadaPor: z.string().meta({ description: "Persona que la concedió" })
|
|
715
|
+
});
|
|
716
|
+
const autorizacionResponseSchema = z.object({ data: autorizacionSchema });
|
|
717
|
+
const listAutorizacionesResponseSchema = z.object({ data: z.object({ autorizaciones: z.array(autorizacionSchema) }) });
|
|
718
|
+
const verificarAutorizacionResponseSchema = z.object({ data: z.object({ autorizado: z.boolean() }) });
|
|
719
|
+
/** Permissions of the inter-company catalog without repeats (first order kept); an empty list clears them. */
|
|
720
|
+
const setProductoPermisosAutorizablesRequestSchema = z.object({ permisos: z.array(interEmpresaPermissionSchema).max(64).transform((list) => [...new Set(list)]) }).strict();
|
|
721
|
+
/** Permissions a product may grant on behalf of its companies (admin). */
|
|
722
|
+
const productoPermisosAutorizablesResponseSchema = z.object({ data: z.object({
|
|
723
|
+
producto: z.string(),
|
|
724
|
+
permisos: z.array(z.string())
|
|
725
|
+
}) }).meta({ id: "AdminProductoPermisosAutorizablesResponse" });
|
|
726
|
+
// ../auth-contracts/dist/delegations.js
|
|
727
|
+
/**
|
|
728
|
+
* SCHEMA module: delegation edges of a service client (admin), `service_client_delegations`. An
|
|
729
|
+
* edge says "this client may exchange a token for a delegated one towards `audience`, carrying at
|
|
730
|
+
* most `scopes`". `auth-api` is never a destination and `admin` is never delegable: the schemas
|
|
731
|
+
* are built from `DELEGABLE_AUDIENCE_SCOPES`, so the typo or the forbidden value is rejected by the
|
|
732
|
+
* schema itself.
|
|
733
|
+
*
|
|
734
|
+
* `requiere_scope_origen` (snake case, like the rest of the token vocabulary) makes the edge usable
|
|
735
|
+
* for a RE-exchange: the incoming delegated token must carry at least one of those permissions. An
|
|
736
|
+
* edge that does not define it admits no re-exchange (only the first hop from a user access token).
|
|
737
|
+
*/
|
|
738
|
+
/** Permissions of one audience without repeats (first order kept); at least one, bounded. */
|
|
739
|
+
const scopesOf = (scopes) => z.array(z.enum(scopes)).min(1).max(16).transform((list) => [...new Set(list)]);
|
|
740
|
+
const originScopes = z.array(z.enum(DELEGABLE_SCOPES)).min(1).max(16).transform((list) => [...new Set(list)]);
|
|
741
|
+
/**
|
|
742
|
+
* Create or replace the edge of a service client towards one audience. One variant per delegable
|
|
743
|
+
* audience; a test pins that every delegable audience has its variant.
|
|
744
|
+
*/
|
|
745
|
+
const setServiceClientDelegationRequestSchema = z.discriminatedUnion("audience", [z.object({
|
|
746
|
+
audience: z.literal("whatsapp-api"),
|
|
747
|
+
scopes: scopesOf(DELEGABLE_AUDIENCE_SCOPES["whatsapp-api"]),
|
|
748
|
+
requiere_scope_origen: originScopes.optional()
|
|
749
|
+
}).strict()]);
|
|
750
|
+
const serviceClientDelegationSchema = z.object({
|
|
751
|
+
audience: z.enum(DELEGABLE_AUDIENCES),
|
|
752
|
+
scopes: z.array(z.string()),
|
|
753
|
+
requiere_scope_origen: z.array(z.string()).meta({ description: "Vacío = la arista no admite re-exchange" })
|
|
754
|
+
}).meta({ id: "ServiceClientDelegation" });
|
|
755
|
+
const listServiceClientDelegationsResponseSchema = z.object({ data: z.object({ delegations: z.array(serviceClientDelegationSchema) }) }).meta({ id: "AdminDelegationsResponse" });
|
|
756
|
+
const setServiceClientDelegationResponseSchema = z.object({ data: z.object({ delegation: serviceClientDelegationSchema }) }).meta({ id: "AdminDelegationResponse" });
|
|
757
|
+
// ../auth-contracts/dist/identity-events.js
|
|
758
|
+
/**
|
|
759
|
+
* SCHEMA module: `data` of the webhook events added by identity phase 2. Ids only: no contact
|
|
760
|
+
* data travels in an event, so the receiver reads what it needs through the API (which applies the
|
|
761
|
+
* contract and role rules). `empresa.*`, `grupo.*` and `autorizacion.*` reach only the clients that
|
|
762
|
+
* contracted the product of the affected company, or have no product.
|
|
763
|
+
*/
|
|
764
|
+
const empresaId = z.string();
|
|
765
|
+
const empresaEventPayloadSchema = z.object({ empresaId });
|
|
766
|
+
const empresaMemberRoleChangedPayloadSchema = z.object({
|
|
767
|
+
empresaId,
|
|
768
|
+
userId: z.string(),
|
|
769
|
+
rol: z.enum(EMPRESA_ROLES)
|
|
770
|
+
});
|
|
771
|
+
const empresaBranchEventPayloadSchema = z.object({
|
|
772
|
+
empresaId,
|
|
773
|
+
sucursalId: z.string()
|
|
774
|
+
});
|
|
775
|
+
const empresaProductChangedPayloadSchema = z.object({
|
|
776
|
+
empresaId,
|
|
777
|
+
producto: z.string(),
|
|
778
|
+
estado: z.enum(CONTRATACION_ESTADOS)
|
|
779
|
+
});
|
|
780
|
+
/** Phase 1 events: `empresa.member_added` and `empresa.member_removed`. */
|
|
781
|
+
const empresaMemberEventPayloadSchema = z.object({
|
|
782
|
+
empresaId,
|
|
783
|
+
userId: z.string()
|
|
784
|
+
});
|
|
785
|
+
const grupoEventPayloadSchema = z.object({ grupoId: z.string() });
|
|
786
|
+
const grupoMemberEventPayloadSchema = z.object({
|
|
787
|
+
grupoId: z.string(),
|
|
788
|
+
empresaId
|
|
789
|
+
});
|
|
790
|
+
const autorizacionEventPayloadSchema = z.object({
|
|
791
|
+
autorizacionId: z.string(),
|
|
792
|
+
otorganteId: z.string(),
|
|
793
|
+
beneficiariaId: z.string(),
|
|
794
|
+
permiso: z.string()
|
|
795
|
+
});
|
|
796
|
+
/** `data` schema of each `empresa.*`, `grupo.*` and `autorizacion.*` event (ids only: no `slug`, no first member), by event code. */
|
|
797
|
+
const IDENTITY_EVENT_PAYLOAD_SCHEMAS = {
|
|
798
|
+
[EVENT_CODES.EMPRESA_CREATED]: empresaEventPayloadSchema,
|
|
799
|
+
[EVENT_CODES.EMPRESA_MEMBER_ADDED]: empresaMemberEventPayloadSchema,
|
|
800
|
+
[EVENT_CODES.EMPRESA_MEMBER_REMOVED]: empresaMemberEventPayloadSchema,
|
|
801
|
+
[EVENT_CODES.EMPRESA_BRANCH_CREATED]: empresaBranchEventPayloadSchema,
|
|
802
|
+
[EVENT_CODES.EMPRESA_UPDATED]: empresaEventPayloadSchema,
|
|
803
|
+
[EVENT_CODES.EMPRESA_DEACTIVATED]: empresaEventPayloadSchema,
|
|
804
|
+
[EVENT_CODES.EMPRESA_REACTIVATED]: empresaEventPayloadSchema,
|
|
805
|
+
[EVENT_CODES.EMPRESA_MEMBER_ROLE_CHANGED]: empresaMemberRoleChangedPayloadSchema,
|
|
806
|
+
[EVENT_CODES.EMPRESA_BRANCH_UPDATED]: empresaBranchEventPayloadSchema,
|
|
807
|
+
[EVENT_CODES.EMPRESA_BRANCH_DEACTIVATED]: empresaBranchEventPayloadSchema,
|
|
808
|
+
[EVENT_CODES.EMPRESA_PRODUCT_CHANGED]: empresaProductChangedPayloadSchema,
|
|
809
|
+
[EVENT_CODES.GRUPO_UPDATED]: grupoEventPayloadSchema,
|
|
810
|
+
[EVENT_CODES.GRUPO_MEMBER_ADDED]: grupoMemberEventPayloadSchema,
|
|
811
|
+
[EVENT_CODES.GRUPO_MEMBER_REMOVED]: grupoMemberEventPayloadSchema,
|
|
812
|
+
[EVENT_CODES.AUTORIZACION_GRANTED]: autorizacionEventPayloadSchema,
|
|
813
|
+
[EVENT_CODES.AUTORIZACION_REVOKED]: autorizacionEventPayloadSchema
|
|
814
|
+
};
|
|
815
|
+
export { ACCESS_TOKEN_TYPE, ACCOUNT_STATES, ACTIVITY_STATES, ADMIN_ROUTES, API_PREFIX, AUTH_ROUTES, AUTH_SERVICE_SUB, AUTORIZACION_DIRECCIONES, CONTRATACION_ESTADOS, CONTRATACION_ESTADOS_FACTURACION, CONTRATACION_ESTADOS_VIGENTES, DELEGABLE_AUDIENCES, DELEGABLE_AUDIENCE_SCOPES, DELEGABLE_SCOPES, DELEGATED_TOKEN_LIFETIME_SECONDS, DELEGATED_TOKEN_MAX_DEPTH, DELEGATED_TOKEN_TYP, DELIVERY_STATUSES, DIRECTORIO_ROUTES, EMPRESA_ESTADOS, EMPRESA_ROLES, ERROR_CODES, EVENT_CODES, HEADERS, IDENTITY_EVENT_PAYLOAD_SCHEMAS, INTERNAL_AUTORIZACION_ROUTES, INTERNAL_EMPRESA_ROUTES, INTERNAL_GRUPO_ROUTES, INTERNAL_HEADERS, INTERNAL_SERVICE_TOKEN_LIFETIME_SECONDS, INTERNAL_TOKEN_EXCHANGE_ROUTES, INTERNAL_TOKEN_ROUTES, INTERNAL_USER_ROUTES, INTER_EMPRESA_PERMISSIONS, INTER_EMPRESA_PERMISSION_LIST, PRIVACY_STATES, RESERVED_SERVICE_CLIENT_SLUGS, SERVICE_AUDIENCES, SERVICE_AUDIENCE_SCOPES, SERVICE_KID_PREFIX, SERVICE_TOKEN_ERROR_CODES, SERVICE_TOKEN_LIFETIME_SECONDS, SERVICE_TOKEN_TYP, SESSION_ROUTES, SUBJECT_TOKEN_HEADER, SUBJECT_TOKEN_INVALID_CODE, SUBJECT_TOKEN_INVALID_STATUS, TITULAR_ANTERIOR_DESTINOS, TOKEN_BEARING_KEYS, TOKEN_EXCHANGE_ERROR_CODES, TOKEN_EXCHANGE_GRANT_TYPE, TOKEN_ISSUER, USERS_BATCH_MAX_IDS, USER_KID_PREFIX, USER_ROUTES, USER_TOKEN_TYP, WEBHOOK_HEADERS, WEBHOOK_ROUTES, WEBHOOK_TIMESTAMP_WINDOW_SECONDS, addEmpresaMemberRequestSchema, addGrupoEmpresaRequestSchema, autorizacionEventPayloadSchema, autorizacionResponseSchema, autorizacionSchema, companyGroupSchema, companyListResponseSchema, companySchema, contractedCompanySchema, contratacionResponseSchema, contratacionSchema, contratadoResponseSchema, createAutorizacionRequestSchema, createEmpresaRequestSchema, createGrupoRequestSchema, createProductoRequestSchema, createServiceClientRequestSchema, createServiceClientResponseSchema, createSubscriptionRequestSchema, createSucursalRequestSchema, deactivateSucursalRequestSchema, deleteAutorizacionRequestSchema, deliveriesQuerySchema, deliveryListResponseSchema, deliverySchema, directorioEmpresaSchema, directorioQuerySchema, directorioResponseSchema, empresaBranchEventPayloadSchema, empresaDetailResponseSchema, empresaEstadoResponseSchema, empresaEventPayloadSchema, empresaMemberEventPayloadSchema, empresaMemberResponseSchema, empresaMemberRoleChangedPayloadSchema, empresaPerfilSchema, empresaProductChangedPayloadSchema, empresaRecortadaResponseSchema, empresaResponseSchema, empresaRoleAtLeast, errorResponseSchema, getCodeRequestSchema, getCodeResponseSchema, getEmpresaResponseSchema, getServiceClientResponseSchema, grupoEventPayloadSchema, grupoMemberEventPayloadSchema, grupoResponseSchema, grupoSchema, interEmpresaPermissionOwner, interEmpresaPermissionSchema, isContratacionVigente, isDelegableAudience, isDelegableScope, isInterEmpresaPermission, isReservedServiceClientSlug, isScopeOfAudience, isServiceAudience, listAutorizacionesQuerySchema, listAutorizacionesResponseSchema, listEmpresasQuerySchema, listEmpresasResponseSchema, listProductosResponseSchema, listServiceClientDelegationsResponseSchema, listServiceClientGrantsResponseSchema, listServiceClientsResponseSchema, loginRequestSchema, loginResponseSchema, maintenanceCleanupQuerySchema, maintenanceCleanupResponseSchema, messageResponseSchema, messageWithCountResponseSchema, productoPermisosAutorizablesResponseSchema, productoResponseSchema, productoSchema, productoSlugSchema, profileResponseSchema, publicProfileSchema, reassignTitularRequestSchema, reassignTitularResponseSchema, removeEmpresaMemberRequestSchema, removeGrupoEmpresaRequestSchema, renameGrupoRequestSchema, republishPendingQuerySchema, republishPendingResponseSchema, restoreUserResponseSchema, rotateServiceClientSecretResponseSchema, rotateSubscriptionSecretResponseSchema, serviceClientDelegationSchema, serviceClientGrantSchema, serviceClientPublicSchema, serviceClientSlugSchema, serviceTokenErrorSchema, serviceTokenRequestSchema, serviceTokenResponseSchema, sessionListResponseSchema, setActiveEmpresaRequestSchema, setActiveEmpresaResponseSchema, setContratacionRequestSchema, setProductoPermisosAutorizablesRequestSchema, setServiceClientDelegationRequestSchema, setServiceClientDelegationResponseSchema, setServiceClientGrantRequestSchema, setServiceClientGrantResponseSchema, subjectTokenRequestSchema, subjectTokenSchema, subscriptionListResponseSchema, subscriptionResponseSchema, subscriptionSchema, subscriptionWithSecretResponseSchema, sucursalRecortadaSchema, sucursalResponseSchema, sucursalSchema, tokenExchangeErrorSchema, tokenExchangeRequestSchema, tokenExchangeResponseSchema, uncontractedCompanySchema, updateEmpresaMemberRequestSchema, updateEmpresaPerfilSchema, updateEmpresaRequestSchema, updateProductoRequestSchema, updateServiceClientRequestSchema, updateServiceClientResponseSchema, updateSubscriptionRequestSchema, updateSucursalRequestSchema, updateUserRequestSchema, usersBatchRequestSchema, usersBatchResponseSchema, verificarAutorizacionQuerySchema, verificarAutorizacionResponseSchema };
|
|
816
|
+
|
|
817
|
+
//# sourceMappingURL=index.js.map
|