@fiscalapi/docs-mcp 0.0.0-stage → 4.0.461
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/LICENSE +373 -0
- package/README.md +92 -2
- package/data/docs-index.json +1 -0
- package/data/operations/calculateInvoice.json +1 -0
- package/data/operations/cancelInvoice.json +1 -0
- package/data/operations/cancelTicket.json +1 -0
- package/data/operations/createApiKey.json +1 -0
- package/data/operations/createDownloadRequest.json +1 -0
- package/data/operations/createDownloadRule.json +1 -0
- package/data/operations/createDownloadRuleTestRequest.json +1 -0
- package/data/operations/createEmployeeData.json +1 -0
- package/data/operations/createEmployerData.json +1 -0
- package/data/operations/createInvoice.json +1 -0
- package/data/operations/createPerson.json +1 -0
- package/data/operations/createProduct.json +1 -0
- package/data/operations/createTaxFile.json +1 -0
- package/data/operations/createTicket.json +1 -0
- package/data/operations/createWebhook.json +1 -0
- package/data/operations/deleteDownloadRequest.json +1 -0
- package/data/operations/deleteDownloadRule.json +1 -0
- package/data/operations/deleteEmployeeData.json +1 -0
- package/data/operations/deleteEmployerData.json +1 -0
- package/data/operations/deletePerson.json +1 -0
- package/data/operations/deleteProduct.json +1 -0
- package/data/operations/deleteTaxFile.json +1 -0
- package/data/operations/deleteWebhook.json +1 -0
- package/data/operations/downloadPortalTicketInvoice.json +1 -0
- package/data/operations/getApiKey.json +1 -0
- package/data/operations/getAutoInvoiceConsumptionReport.json +1 -0
- package/data/operations/getAutoInvoicePortalName.json +1 -0
- package/data/operations/getAutoInvoicePortalNameAvailability.json +1 -0
- package/data/operations/getAutoInvoiceSettings.json +1 -0
- package/data/operations/getCatalogRecord.json +1 -0
- package/data/operations/getDownloadRequest.json +1 -0
- package/data/operations/getDownloadRequestPackage.json +1 -0
- package/data/operations/getDownloadRequestRawRequest.json +1 -0
- package/data/operations/getDownloadRequestRawResponse.json +1 -0
- package/data/operations/getDownloadRule.json +1 -0
- package/data/operations/getEmployeeData.json +1 -0
- package/data/operations/getEmployerData.json +1 -0
- package/data/operations/getEvent.json +1 -0
- package/data/operations/getInvoice.json +1 -0
- package/data/operations/getInvoicePdf.json +1 -0
- package/data/operations/getInvoiceStatus.json +1 -0
- package/data/operations/getInvoiceXml.json +1 -0
- package/data/operations/getPerson.json +1 -0
- package/data/operations/getPortalBranding.json +1 -0
- package/data/operations/getPortalTicket.json +1 -0
- package/data/operations/getProduct.json +1 -0
- package/data/operations/getSatValidationType.json +1 -0
- package/data/operations/getStampTransaction.json +1 -0
- package/data/operations/getTaxFile.json +1 -0
- package/data/operations/getTaxFileDefaultValues.json +1 -0
- package/data/operations/getTicket.json +1 -0
- package/data/operations/getTicketCode.json +1 -0
- package/data/operations/getWebhook.json +1 -0
- package/data/operations/invoicePortalTicket.json +1 -0
- package/data/operations/listApiKeys.json +1 -0
- package/data/operations/listCatalogs.json +1 -0
- package/data/operations/listDownloadCatalogRecords.json +1 -0
- package/data/operations/listDownloadCatalogs.json +1 -0
- package/data/operations/listDownloadRequestMetaItems.json +1 -0
- package/data/operations/listDownloadRequestWithholdingPackages.json +1 -0
- package/data/operations/listDownloadRequestXmls.json +1 -0
- package/data/operations/listDownloadRequests.json +1 -0
- package/data/operations/listDownloadRules.json +1 -0
- package/data/operations/listEvents.json +1 -0
- package/data/operations/listInvoices.json +1 -0
- package/data/operations/listPeople.json +1 -0
- package/data/operations/listPortalCfdiUses.json +1 -0
- package/data/operations/listPortalTaxRegimes.json +1 -0
- package/data/operations/listProductTaxes.json +1 -0
- package/data/operations/listProducts.json +1 -0
- package/data/operations/listSatValidationTypeStatuses.json +1 -0
- package/data/operations/listSatValidationTypes.json +1 -0
- package/data/operations/listStampTransactions.json +1 -0
- package/data/operations/listTaxFiles.json +1 -0
- package/data/operations/listTickets.json +1 -0
- package/data/operations/listWebhookDeliveries.json +1 -0
- package/data/operations/listWebhooks.json +1 -0
- package/data/operations/patchPerson.json +1 -0
- package/data/operations/recoverPortalTicketInvoice.json +1 -0
- package/data/operations/resendEvent.json +1 -0
- package/data/operations/resendPortalTicketInvoice.json +1 -0
- package/data/operations/revokeApiKey.json +1 -0
- package/data/operations/rotateWebhookSecret.json +1 -0
- package/data/operations/runSatValidations.json +1 -0
- package/data/operations/searchCatalogRecords.json +1 -0
- package/data/operations/searchDownloadRequests.json +1 -0
- package/data/operations/sendInvoice.json +1 -0
- package/data/operations/signManifest.json +1 -0
- package/data/operations/testWebhook.json +1 -0
- package/data/operations/transferStamps.json +1 -0
- package/data/operations/triggerEvent.json +1 -0
- package/data/operations/updateApiKey.json +1 -0
- package/data/operations/updateAutoInvoicePortalName.json +1 -0
- package/data/operations/updateAutoInvoiceSettings.json +1 -0
- package/data/operations/updateDownloadRule.json +1 -0
- package/data/operations/updateEmployeeData.json +1 -0
- package/data/operations/updateEmployerData.json +1 -0
- package/data/operations/updatePerson.json +1 -0
- package/data/operations/updateProduct.json +1 -0
- package/data/operations/updateWebhook.json +1 -0
- package/data/operations.json +1 -0
- package/data/source.json +12 -0
- package/dist/api-operations.js +55 -0
- package/dist/data-files.js +22 -0
- package/dist/docs-index-options.js +29 -0
- package/dist/docs-index.js +35 -0
- package/dist/excerpt.js +54 -0
- package/dist/index.js +25 -0
- package/dist/operation-suggestions.js +37 -0
- package/dist/server.js +17 -0
- package/dist/tools/get-operation-tool.js +34 -0
- package/dist/tools/list-operations-tool.js +40 -0
- package/dist/tools/mcp-tool.js +1 -0
- package/dist/tools/search-docs-tool.js +55 -0
- package/dist/tools/tool-conventions.js +14 -0
- package/dist/tools/tool-results.js +6 -0
- package/package.json +62 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"runSatValidations","method":"POST","path":"/api/v4/sat-validations","tag":"SatValidations","summary":"Validar un CFDI o un RFC ante el SAT","description":"Ejecuta los tipos de validationTypes sobre un CFDI timbrado en base64 (xml, máximo 4,000,000 de caracteres) o solo sobre un RFC (tin), nunca ambos; con tin solo se admiten sat.blacklist.69b y sat.blacklist.69bbis. Los tipos son sat.xml.structure, sat.cfdi.sello y sat.tfd.sello (verificador de CFDI del SAT), sat.cfdi.status (estatus ante el SAT), sat.certificate.validity (vigencia del certificado del emisor al emitir) y las listas 69-B y 69-B Bis del último corte importado; en el ambiente de pruebas cada tipo responde un estatus aleatorio sin consultar al SAT. Cada tipo consume 1 crédito de validación de la persona autenticada, todo o nada: sin saldo suficiente, o si la suscripción del tenant no incluye Emisión CFDI, responde 403 y no ejecuta ninguno; un cuerpo inválido o un tipo desconocido responde 400. Devuelve un resultado por tipo (type, status, passed) en el orden del catálogo, y un resultado adverso es 200 con passed false. Docs: [validar un CFDI](https://docs.fiscalapi.com/sat-validations#validar) y [validar solo por RFC](https://docs.fiscalapi.com/sat-validations#validar-solo-por-rfc).","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"xml":{"type":["null","string"]},"tin":{"type":["null","string"]},"validationTypes":{"type":"array","items":{"type":"string"}}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"searchCatalogRecords","method":"GET","path":"/api/v4/catalogs/{catalogName}/{searchText}","tag":"Catalogs","summary":"Buscar en un catálogo","description":"Los registros de un catálogo cuya descripción contiene searchText, de al menos 4 caracteres; no busca por clave (para eso, obtén el registro por su id). Paginado con pageNumber y pageSize (50 por omisión, de 1 a 100); un parámetro fuera de rango responde 400 y un catálogo inexistente, 404. Docs: [buscar en un catálogo](https://docs.fiscalapi.com/catalogs#buscar-en-un-catalogo).","parameters":[{"name":"catalogName","in":"path","required":true,"schema":{"type":"string"}},{"name":"searchText","in":"path","required":true,"schema":{"type":"string"}},{"name":"pageNumber","in":"query","schema":{"pattern":"^-?(?:0|[1-9]\\d*)$","type":["integer","string"],"format":"int32","default":1}},{"name":"pageSize","in":"query","schema":{"pattern":"^-?(?:0|[1-9]\\d*)$","type":["integer","string"],"format":"int32","default":50}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"searchDownloadRequests","method":"GET","path":"/api/v4/download-requests/search","tag":"DownloadRequests","summary":"Buscar solicitudes de descarga masiva por fecha de creación","description":"Las solicitudes de descarga masiva creadas el día createdAt en UTC (obligatorio, AAAA-MM-DD; sin él responde 400), sin paginar y de la más reciente a la más antigua. Docs: [listar solicitudes](https://docs.fiscalapi.com/download-requests#listar-solicitudes).","parameters":[{"name":"CreatedAt","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"sendInvoice","method":"POST","path":"/api/v4/invoices/send","tag":"Invoices","summary":"Enviar una factura por correo","description":"Envía el PDF y el XML de la factura a toEmail o, si falta, al correo del receptor. Admite el mismo logo y colores que el PDF. El envío se programa y puede tardar unos minutos. Docs: [por valores](https://docs.fiscalapi.com/invoices-by-value#enviar-factura-por-correo) y [por referencias](https://docs.fiscalapi.com/invoices-by-reference#enviar-factura-por-correo).","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"invoiceId":{"type":["null","string"]},"base64Logo":{"type":["null","string"]},"bandColor":{"type":["null","string"]},"fontColor":{"type":["null","string"]},"toEmail":{"type":["null","string"]}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"signManifest","method":"POST","path":"/api/v4/manifests","tag":"Manifests","summary":"Firmar la carta manifiesto con la FIEL","description":"Firma con el PAC la carta manifiesto del RFC de la FIEL que envías en base64Cer, base64Key y password (obligatorios; cada archivo hasta 24,576 caracteres en base64 y la contraseña hasta 256) y devuelve el PDF firmado en base64File; fileName es el RFC con extensión .pdf. Todas las personas del tenant con ese RFC quedan con manifestStatusId Signed. Responde 400 si la contraseña no abre la llave o la credencial no es una FIEL vigente, y 404 si ninguna persona del tenant tiene ese RFC. Docs: [firmar carta manifiesto](https://docs.fiscalapi.com/manifests#firmar-carta-manifiesto) y [límites](https://docs.fiscalapi.com/manifests#limites).","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"base64Cer":{"type":["null","string"]},"base64Key":{"type":["null","string"]},"password":{"type":["null","string"]}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"testWebhook","method":"POST","path":"/api/v4/webhooks/{id}/test","tag":"Webhooks","summary":"Probar un webhook","description":"Registra un evento webhook.test cuyo recurso es el webhook y lo entrega solo a él, firmado y en un solo intento, sin reintentos. 202: los ids del evento y de la entrega. 400: es una escucha de CLI o está deshabilitado. 401: sin API key o JWT válidos. 403: la persona no tiene el permiso Webhooks.Manage. 404: no existe un webhook con ese id en el tenant (una escucha de CLI solo existe para su persona y el owner), o el id no es un GUID. 429: demasiadas pruebas con la misma API key.","parameters":[{"name":"id","in":"path","description":"Id del webhook.","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"oneOf":[{"type":"null"},{"required":["eventId","deliveryId"],"type":"object","properties":{"eventId":{"type":"string"},"deliveryId":{"type":"string"}}}]},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"transferStamps","method":"POST","path":"/api/v4/stamps","tag":"Stamps","summary":"Transferir o retirar timbres entre personas","description":"Resta amount (mayor que 0) del saldo de fromPersonId y lo suma a toPersonId en un solo movimiento de transferencia; retirar timbres es la misma operación en sentido inverso. creditType elige el saldo (1 timbres por omisión, 2 validaciones, 3 tickets) y, si el del origen no alcanza, responde 403 sin mover nada. Origen y destino deben ser personas distintas del tenant con id GUID (si no, 400) y solo el owner del tenant transfiere desde una persona que no es la autenticada (403). Docs: [transferir](https://docs.fiscalapi.com/stamps#transferir-timbres) y [retirar](https://docs.fiscalapi.com/stamps#retirar-timbres).","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fromPersonId":{"type":["null","string"]},"toPersonId":{"type":["null","string"]},"amount":{"pattern":"^-?(?:0|[1-9]\\d*)$","type":["integer","string"],"format":"int32"},"comments":{"type":["null","string"]},"creditType":{"type":"integer","format":"int32"}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"triggerEvent","method":"POST","path":"/api/v4/events/trigger","tag":"Events","summary":"Disparar un evento de webhook de prueba","description":"Publica un evento del tipo pedido con la forma de uno real (el recurso y los estados de su tipo) y lo entrega solo al webhook webhookId o, si se omite, a la escucha de CLI de la persona autenticada (fiscalapi trigger); los demás webhooks no lo reciben. Como el reenvío, no filtra por las suscripciones (enabledEvents) ni las personas (personIds) del destino. La entrega es una prueba de un solo intento, sin reintentos. Sin relatedObjectId, el recurso es un id sintético cuyo GET responde 404; sin personId, el evento va sin persona. 202: eventId y webhookId, para seguirlo en GET /events/{id} y en el log de entregas. 400: el cuerpo vacío ('El cuerpo de la petición es requerido y no debe estar vacío.'); un type omitido o que no existe (\"El tipo de evento '{type}' no existe.\"); un relatedObjectId vacío (\"'Related Object Id' no debería estar vacío.\") o de más de 36 caracteres (\"'Related Object Id' debe ser menor o igual que 36 caracteres. Ingresó {n} caracteres.\"); un webhookId vacío (\"'Webhook Id' no debería estar vacío.\"); un campo que el cuerpo no admite (p. ej. webhookEndpointId), con el texto \"El campo '{field}' no existe en este recurso.\"; una persona que no es del tenant ('La persona especificada no es válida o no pertenece a tu organización.'); un webhook de URL deshabilitado ('El webhook está deshabilitado: habilítalo antes de probarlo.'). 401: sin API key o JWT válidos. 403: la persona no tiene el permiso Webhooks.Manage. También 403 fuera de los ambientes de prueba (solo Development y Test): 'fiscalapi trigger no está disponible en producción; usa el ambiente de pruebas.'. 404 ('No such resource for the given Id: {id}'): el webhook no existe, está dado de baja, es de otro tenant o es la escucha de CLI de otra persona (salvo para el owner). 409 ('La escucha de CLI no está conectada; ejecuta fiscalapi listen.'): la escucha de CLI no tiene una sesión vigente de fiscalapi listen, o quien llama no tiene escucha. 429: demasiadas peticiones con la misma API key.","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":["null","string"],"description":"El tipo de evento, uno de los que se suscriben (p. ej. invoice.canceled)."},"relatedObjectId":{"type":["null","string"],"description":"El id del recurso del evento (data.relatedObject.id); si se omite, un id sintético cuyo GET responde 404."},"personId":{"type":["null","string"],"description":"La persona del tenant dueña del recurso (personId del evento); si se omite, el evento va sin persona."},"webhookId":{"type":["null","string"],"description":"El webhook que recibe el evento; si se omite, la escucha de CLI de la persona autenticada (fiscalapi listen)."}},"additionalProperties":false}}},"required":true},"responses":{"202":{"description":"Accepted","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"oneOf":[{"type":"null"},{"required":["eventId","webhookId"],"type":"object","properties":{"eventId":{"type":"string"},"webhookId":{"type":"string"}}}]},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateApiKey","method":"PUT","path":"/api/v4/apikeys/{id}","tag":"ApiKeys","summary":"Actualizar una API key","description":"Cambia description y apiKeyStatus: con 0 la API key queda deshabilitada y deja de autenticar hasta que vuelva a 1. Un apiKeyStatus omitido se conserva, pero una description omitida se borra. El id de la ruta y el del cuerpo deben coincidir; responde 404 si no existe o si es de otra persona y la persona autenticada no es el owner del tenant. Docs: [actualizar API key](https://docs.fiscalapi.com/api-keys#actualizar-api-key).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":["null","string"]},"description":{"type":["null","string"]},"apiKeyStatus":{"oneOf":[{"type":"null"},{"type":"integer"}]}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateAutoInvoicePortalName","method":"PUT","path":"/api/v4/auto-invoice/portal-name","tag":"AutoInvoice","summary":"Cambiar el nombre del portal","description":"Asigna el nombre del portal de autofactura del tenant. El nombre anterior queda como alias del tenant y el nombre solo puede cambiarse una vez por intervalo. Exige el feature Auto CFDI. 400: un nombre con formato inválido o reservado, o un cambio antes de que termine el intervalo. 401: sin API key o JWT válidos. 403: la persona no tiene el permiso AutoInvoice.Manage (owner) o el tenant no tiene Auto CFDI. 409: otro tenant tiene el nombre, o hay otro cambio del nombre en curso.","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":["null","string"]}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"oneOf":[{"type":"null"},{"required":["name","assignedAt","nextChangeAllowedAt"],"type":"object","properties":{"name":{"type":["null","string"]},"assignedAt":{"type":["null","string"],"format":"date-time"},"nextChangeAllowedAt":{"type":["null","string"],"format":"date-time"}}}]},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateAutoInvoiceSettings","method":"PUT","path":"/api/v4/auto-invoice/settings","tag":"AutoInvoice","summary":"Actualizar la configuración de Auto CFDI","description":"Guarda la ventana de autofactura y la URL https del aviso de privacidad del portal. Permitir otro año exige permitir otro mes. Exige el feature Auto CFDI. 400: una URL de aviso de privacidad inválida o permitir otro año sin permitir otro mes. 401: sin API key o JWT válidos. 403: la persona no tiene el permiso AutoInvoice.Manage (owner) o el tenant no tiene Auto CFDI.","parameters":[{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"allowBillingOutsideMonth":{"type":"boolean"},"allowBillingOutsideYear":{"type":"boolean"},"privacyNoticeUrl":{"type":["null","string"]}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"oneOf":[{"type":"null"},{"required":["allowBillingOutsideMonth","allowBillingOutsideYear","privacyNoticeUrl"],"type":"object","properties":{"allowBillingOutsideMonth":{"type":"boolean"},"allowBillingOutsideYear":{"type":"boolean"},"privacyNoticeUrl":{"type":["null","string"]}}}]},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateDownloadRule","method":"PUT","path":"/api/v4/download-rules/{id}","tag":"DownloadRules","summary":"Actualizar la descripción de una regla de descarga masiva","description":"Solo cambia description (máximo 100 caracteres); la persona, el tipo de consulta, la dirección y el estatus de los documentos no se editan. El cuerpo lleva el mismo id de la ruta (400 si no coincide) y una description omitida deja la regla sin descripción. Responde 404 si no existe en el tenant y 403 si la regla es del owner del tenant y la persona autenticada no lo es. Docs: [actualizar regla](https://docs.fiscalapi.com/download-rules#actualizar-regla).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":["null","string"]},"description":{"type":["null","string"]}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateEmployeeData","method":"PUT","path":"/api/v4/people/{personId}/employee","tag":"People","summary":"Actualizar los datos de empleado de una persona","description":"Actualiza los datos del empleado para el recibo de nómina; employeePersonId es el personId de la ruta. Responde 404 si la persona no tiene datos de empleado. Docs: [datos de empleado](https://docs.fiscalapi.com/employee-data#actualizar-datos-de-empleado).","parameters":[{"name":"personId","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"employerPersonId":{"type":"string"},"employeePersonId":{"type":"string"},"socialSecurityNumber":{"type":["null","string"]},"laborRelationStartDate":{"type":["null","string"],"format":"date-time"},"seniority":{"type":["null","string"]},"satContractTypeId":{"type":"string"},"satUnionizedStatusId":{"type":["null","string"]},"satTaxRegimeTypeId":{"type":"string"},"satWorkdayTypeId":{"type":["null","string"]},"satJobRiskId":{"type":["null","string"]},"satPaymentPeriodicityId":{"type":"string"},"employeeNumber":{"type":"string"},"satBankId":{"type":["null","string"]},"satPayrollStateId":{"type":"string"},"department":{"type":["null","string"]},"position":{"type":["null","string"]},"bankAccount":{"type":["null","string"]},"baseSalaryForContributions":{"pattern":"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$","type":["null","number","string"],"format":"double"},"integratedDailySalary":{"pattern":"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$","type":["null","number","string"],"format":"double"},"subcontractorRfc":{"type":["null","string"]},"timePercentage":{"pattern":"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$","type":["null","number","string"],"format":"double"}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateEmployerData","method":"PUT","path":"/api/v4/people/{personId}/employer","tag":"People","summary":"Actualizar los datos de empleador de una persona","description":"Actualiza los datos del empleador (patrón) para el recibo de nómina; personId del cuerpo es el de la ruta. Responde 404 si la persona no tiene datos de empleador. Docs: [datos de empleador](https://docs.fiscalapi.com/employer-data#actualizar-datos-de-empleador).","parameters":[{"name":"personId","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"personId":{"type":["null","string"]},"employerRegistration":{"type":["null","string"]},"originEmployerTin":{"type":["null","string"]},"satFundSourceId":{"type":["null","string"]},"ownResourceAmount":{"pattern":"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$","type":["null","number","string"],"format":"double"}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updatePerson","method":"PUT","path":"/api/v4/people/{id}","tag":"People","summary":"Actualizar una persona","description":"Reemplaza los datos de la persona con el cuerpo completo: un campo omitido se borra (solo userTypeId y taxPassword se conservan). legalName y email son obligatorios. Para cambiar solo algunos campos usa la actualización parcial (PATCH). El id de la ruta y el del cuerpo deben coincidir; un cambio concurrente responde 409. Docs: [emisores](https://docs.fiscalapi.com/issuers#actualizar-emisor) y [receptores](https://docs.fiscalapi.com/recipients#actualizar-receptor).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":["null","string"]},"legalName":{"type":["null","string"]},"email":{"type":["null","string"]},"phoneNumber":{"type":["null","string"]},"password":{"type":["null","string"]},"satTaxRegimeId":{"type":["null","string"]},"satCfdiUseId":{"type":["null","string"]},"userTypeId":{"type":["null","string"]},"tin":{"type":["null","string"]},"zipCode":{"type":["null","string"]},"base64Photo":{"type":["null","string"]},"taxPassword":{"type":["null","string"]},"curp":{"type":["null","string"]},"countryId":{"type":["null","string"]},"foreignTin":{"type":["null","string"]}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateProduct","method":"PUT","path":"/api/v4/products/{id}","tag":"Products","summary":"Actualizar un producto","description":"Reemplaza el producto con el cuerpo completo: description, unitPrice, satUnitMeasurementId y satTaxObjectId son obligatorios y un satProductCodeId omitido se borra. Los productTaxes que envías reemplazan a los guardados; si omites la lista o la envías vacía, se conservan. El id de la ruta y el del cuerpo deben coincidir; responde 404 si el producto no existe. Docs: [actualizar producto](https://docs.fiscalapi.com/products#actualizar-producto).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":["null","string"]},"description":{"type":["null","string"]},"unitPrice":{"pattern":"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$","type":["number","string"],"format":"double"},"satUnitMeasurementId":{"type":["null","string"]},"satTaxObjectId":{"type":["null","string"]},"satProductCodeId":{"type":["null","string"]},"productTaxes":{"type":["null","array"],"items":{"type":"object","x-recursive":"UpdateCommand"}}}}}},"required":true},"responses":{"200":{"description":"OK"}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"operationId":"updateWebhook","method":"PUT","path":"/api/v4/webhooks/{id}","tag":"Webhooks","summary":"Reemplazar un webhook","description":"Reemplaza la URL, la descripción, los tipos de evento y las personas; status omitido conserva el estado. Habilitar uno deshabilitado limpia failingSince, disabledReason y disabledAt; deshabilitar cierra sus entregas pendientes y conserva el primer motivo. 400: los mismos del alta (salvo el tope), el id del cuerpo no es el de la ruta o es una escucha de CLI. 401: sin API key o JWT válidos. 403: la persona no tiene el permiso Webhooks.Manage. 404: no existe un webhook con ese id en el tenant (una escucha de CLI solo existe para su persona y el owner), o el id no es un GUID. 409: otro cambio a los webhooks del tenant está en curso; reintenta.","parameters":[{"name":"id","in":"path","description":"Id del webhook.","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"X-TIME-ZONE","in":"header","description":"Zona horaria IANA de las fechas sin zona del cuerpo JSON: el request las lee y la respuesta las escribe en ella. Si falta o no es válida, America/Mexico_City. No aplica a los campos que la operación documenta en UTC o en hora civil.","example":"America/Mexico_City","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":["null","string"],"description":"Id del webhook; debe ser el de la ruta."},"url":{"type":["null","string"],"description":"URL https absoluta que recibe las entregas, sin usuario ni contraseña."},"description":{"type":["null","string"],"description":"Texto libre del tenant, hasta 256 caracteres."},"enabledEvents":{"type":["null","array"],"items":{"type":"string"},"description":"Tipos de evento suscritos, o solo \"*\" para recibirlos todos."},"personIds":{"type":["null","array"],"items":{"type":"string"},"description":"Personas del tenant cuyos eventos recibe; sin ellas (o vacío), las de todas."},"status":{"oneOf":[{"type":"null"},{"enum":["enabled","disabled"],"description":"enabled o disabled; omitido, conserva el estado. Habilitar uno deshabilitado limpia failingSince, disabledReason y disabledAt; deshabilitar cierra sus entregas pendientes."}]}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"oneOf":[{"type":"null"},{"type":"object","properties":{"id":{"type":"string"},"kind":{"enum":["url","cliListener"]},"url":{"type":["null","string"]},"description":{"type":"string"},"enabledEvents":{"type":"array","items":{"type":"string"}},"personIds":{"type":["null","array"],"items":{"type":"string"}},"status":{"enum":["enabled","disabled"]},"disabledReason":{"oneOf":[{"type":"null"},{"enum":["manual","gone","failingTooLong",null]}]},"disabledAt":{"type":["null","string"],"format":"date-time"},"failingSince":{"type":["null","string"],"format":"date-time"},"listenerPersonId":{"type":["null","string"]},"sessionExpiresAt":{"type":["null","string"],"format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":["null","string"],"format":"date-time"}}}]},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"data":{},"succeeded":{"type":"boolean"},"message":{"type":["null","string"]},"details":{"type":["null","string"]},"httpStatusCode":{"type":"integer"},"traceIdentifier":{"type":["null","string"]}}}}}}},"security":[{"ApiKey":[],"TenantKey":[]}],"securitySchemes":{"ApiKey":{"type":"apiKey","name":"X-API-KEY","in":"header"},"TenantKey":{"type":"apiKey","name":"X-TENANT-KEY","in":"header"}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"operationId":"createApiKey","method":"POST","path":"/api/v4/apikeys","summary":"Crear una API key","tag":"ApiKeys"},{"operationId":"getApiKey","method":"GET","path":"/api/v4/apikeys/{id}","summary":"Obtener una API key","tag":"ApiKeys"},{"operationId":"listApiKeys","method":"GET","path":"/api/v4/apikeys","summary":"Listar API keys","tag":"ApiKeys"},{"operationId":"revokeApiKey","method":"DELETE","path":"/api/v4/apikeys/{id}","summary":"Revocar una API key","tag":"ApiKeys"},{"operationId":"updateApiKey","method":"PUT","path":"/api/v4/apikeys/{id}","summary":"Actualizar una API key","tag":"ApiKeys"},{"operationId":"getAutoInvoiceConsumptionReport","method":"GET","path":"/api/v4/auto-invoice/reports/consumption","summary":"Obtener el reporte de consumo de Auto CFDI","tag":"AutoInvoice"},{"operationId":"getAutoInvoicePortalName","method":"GET","path":"/api/v4/auto-invoice/portal-name","summary":"Obtener el nombre del portal","tag":"AutoInvoice"},{"operationId":"getAutoInvoicePortalNameAvailability","method":"GET","path":"/api/v4/auto-invoice/portal-names/availability","summary":"Consultar si un nombre de portal está disponible","tag":"AutoInvoice"},{"operationId":"getAutoInvoiceSettings","method":"GET","path":"/api/v4/auto-invoice/settings","summary":"Obtener la configuración de Auto CFDI","tag":"AutoInvoice"},{"operationId":"updateAutoInvoicePortalName","method":"PUT","path":"/api/v4/auto-invoice/portal-name","summary":"Cambiar el nombre del portal","tag":"AutoInvoice"},{"operationId":"updateAutoInvoiceSettings","method":"PUT","path":"/api/v4/auto-invoice/settings","summary":"Actualizar la configuración de Auto CFDI","tag":"AutoInvoice"},{"operationId":"getCatalogRecord","method":"GET","path":"/api/v4/catalogs/{catalogName}/key/{id}","summary":"Obtener un registro de un catálogo","tag":"Catalogs"},{"operationId":"listCatalogs","method":"GET","path":"/api/v4/catalogs","summary":"Listar catálogos","tag":"Catalogs"},{"operationId":"searchCatalogRecords","method":"GET","path":"/api/v4/catalogs/{catalogName}/{searchText}","summary":"Buscar en un catálogo","tag":"Catalogs"},{"operationId":"listDownloadCatalogRecords","method":"GET","path":"/api/v4/download-catalogs/{catalogName}","summary":"Listar los registros de un catálogo de descarga masiva","tag":"DownloadCatalogs"},{"operationId":"listDownloadCatalogs","method":"GET","path":"/api/v4/download-catalogs","summary":"Listar los catálogos de descarga masiva","tag":"DownloadCatalogs"},{"operationId":"createDownloadRequest","method":"POST","path":"/api/v4/download-requests","summary":"Crear una solicitud de descarga masiva","tag":"DownloadRequests"},{"operationId":"deleteDownloadRequest","method":"DELETE","path":"/api/v4/download-requests/{id}","summary":"Eliminar una solicitud de descarga masiva","tag":"DownloadRequests"},{"operationId":"getDownloadRequest","method":"GET","path":"/api/v4/download-requests/{id}","summary":"Obtener una solicitud de descarga masiva","tag":"DownloadRequests"},{"operationId":"getDownloadRequestPackage","method":"GET","path":"/api/v4/download-requests/{id}/package","summary":"Descargar los paquetes de una solicitud de descarga masiva","tag":"DownloadRequests"},{"operationId":"getDownloadRequestRawRequest","method":"GET","path":"/api/v4/download-requests/{id}/raw-request","summary":"Descargar la última petición enviada al SAT por una solicitud","tag":"DownloadRequests"},{"operationId":"getDownloadRequestRawResponse","method":"GET","path":"/api/v4/download-requests/{id}/raw-response","summary":"Descargar la última respuesta del SAT a una solicitud","tag":"DownloadRequests"},{"operationId":"listDownloadRequestMetaItems","method":"GET","path":"/api/v4/download-requests/{id}/meta-items","summary":"Listar la metadata de una solicitud de descarga masiva","tag":"DownloadRequests"},{"operationId":"listDownloadRequestWithholdingPackages","method":"GET","path":"/api/v4/download-requests/{id}/withholding-packages","summary":"Listar los paquetes de una solicitud de Retenciones","tag":"DownloadRequests"},{"operationId":"listDownloadRequestXmls","method":"GET","path":"/api/v4/download-requests/{id}/xmls","summary":"Listar los CFDI (XML) de una solicitud de descarga masiva","tag":"DownloadRequests"},{"operationId":"listDownloadRequests","method":"GET","path":"/api/v4/download-requests","summary":"Listar solicitudes de descarga masiva","tag":"DownloadRequests"},{"operationId":"searchDownloadRequests","method":"GET","path":"/api/v4/download-requests/search","summary":"Buscar solicitudes de descarga masiva por fecha de creación","tag":"DownloadRequests"},{"operationId":"createDownloadRule","method":"POST","path":"/api/v4/download-rules","summary":"Crear una regla de descarga masiva","tag":"DownloadRules"},{"operationId":"createDownloadRuleTestRequest","method":"POST","path":"/api/v4/download-rules/test","summary":"Simular una descarga masiva en el ambiente de pruebas","tag":"DownloadRules"},{"operationId":"deleteDownloadRule","method":"DELETE","path":"/api/v4/download-rules/{id}","summary":"Eliminar una regla de descarga masiva","tag":"DownloadRules"},{"operationId":"getDownloadRule","method":"GET","path":"/api/v4/download-rules/{id}","summary":"Obtener una regla de descarga masiva","tag":"DownloadRules"},{"operationId":"listDownloadRules","method":"GET","path":"/api/v4/download-rules","summary":"Listar reglas de descarga masiva","tag":"DownloadRules"},{"operationId":"updateDownloadRule","method":"PUT","path":"/api/v4/download-rules/{id}","summary":"Actualizar la descripción de una regla de descarga masiva","tag":"DownloadRules"},{"operationId":"getEvent","method":"GET","path":"/api/v4/events/{id}","summary":"Obtener un evento de webhook","tag":"Events"},{"operationId":"listEvents","method":"GET","path":"/api/v4/events","summary":"Listar eventos de webhook","tag":"Events"},{"operationId":"resendEvent","method":"POST","path":"/api/v4/events/{id}/resend","summary":"Reenviar un evento de webhook","tag":"Events"},{"operationId":"triggerEvent","method":"POST","path":"/api/v4/events/trigger","summary":"Disparar un evento de webhook de prueba","tag":"Events"},{"operationId":"calculateInvoice","method":"POST","path":"/api/v4/invoices/calculate","summary":"Calcular los totales de una factura sin timbrar","tag":"Invoices"},{"operationId":"cancelInvoice","method":"DELETE","path":"/api/v4/invoices","summary":"Cancelar una factura ante el SAT","tag":"Invoices"},{"operationId":"createInvoice","method":"POST","path":"/api/v4/invoices","summary":"Emitir (timbrar) una factura CFDI 4.0","tag":"Invoices"},{"operationId":"getInvoice","method":"GET","path":"/api/v4/invoices/{id}","summary":"Obtener una factura","tag":"Invoices"},{"operationId":"getInvoicePdf","method":"POST","path":"/api/v4/invoices/pdf","summary":"Generar el PDF de una factura","tag":"Invoices"},{"operationId":"getInvoiceStatus","method":"POST","path":"/api/v4/invoices/status","summary":"Consultar el estatus de una factura ante el SAT","tag":"Invoices"},{"operationId":"getInvoiceXml","method":"GET","path":"/api/v4/invoices/{id}/xml","summary":"Descargar el XML timbrado de una factura","tag":"Invoices"},{"operationId":"listInvoices","method":"GET","path":"/api/v4/invoices","summary":"Listar facturas","tag":"Invoices"},{"operationId":"sendInvoice","method":"POST","path":"/api/v4/invoices/send","summary":"Enviar una factura por correo","tag":"Invoices"},{"operationId":"signManifest","method":"POST","path":"/api/v4/manifests","summary":"Firmar la carta manifiesto con la FIEL","tag":"Manifests"},{"operationId":"createEmployeeData","method":"POST","path":"/api/v4/people/{personId}/employee","summary":"Crear los datos de empleado de una persona","tag":"People"},{"operationId":"createEmployerData","method":"POST","path":"/api/v4/people/{personId}/employer","summary":"Crear los datos de empleador de una persona","tag":"People"},{"operationId":"createPerson","method":"POST","path":"/api/v4/people","summary":"Crear una persona: emisor o cliente receptor","tag":"People"},{"operationId":"deleteEmployeeData","method":"DELETE","path":"/api/v4/people/{personId}/employee","summary":"Eliminar los datos de empleado de una persona","tag":"People"},{"operationId":"deleteEmployerData","method":"DELETE","path":"/api/v4/people/{personId}/employer","summary":"Eliminar los datos de empleador de una persona","tag":"People"},{"operationId":"deletePerson","method":"DELETE","path":"/api/v4/people/{id}","summary":"Eliminar una persona","tag":"People"},{"operationId":"getEmployeeData","method":"GET","path":"/api/v4/people/{personId}/employee","summary":"Obtener los datos de empleado de una persona","tag":"People"},{"operationId":"getEmployerData","method":"GET","path":"/api/v4/people/{personId}/employer","summary":"Obtener los datos de empleador de una persona","tag":"People"},{"operationId":"getPerson","method":"GET","path":"/api/v4/people/{id}","summary":"Obtener una persona","tag":"People"},{"operationId":"listPeople","method":"GET","path":"/api/v4/people","summary":"Listar personas: emisores, receptores, empleados y empleadores","tag":"People"},{"operationId":"patchPerson","method":"PATCH","path":"/api/v4/people/{id}","summary":"Actualizar parcialmente una persona","tag":"People"},{"operationId":"updateEmployeeData","method":"PUT","path":"/api/v4/people/{personId}/employee","summary":"Actualizar los datos de empleado de una persona","tag":"People"},{"operationId":"updateEmployerData","method":"PUT","path":"/api/v4/people/{personId}/employer","summary":"Actualizar los datos de empleador de una persona","tag":"People"},{"operationId":"updatePerson","method":"PUT","path":"/api/v4/people/{id}","summary":"Actualizar una persona","tag":"People"},{"operationId":"downloadPortalTicketInvoice","method":"GET","path":"/api/v4/portal/downloads/{downloadToken}/{format}","summary":"Descargar la factura de un ticket","tag":"Portal"},{"operationId":"getPortalBranding","method":"GET","path":"/api/v4/portal/{tenantName}/branding","summary":"Obtener la marca del portal","tag":"Portal"},{"operationId":"getPortalTicket","method":"GET","path":"/api/v4/portal/tickets/{ticketCode}","summary":"Consultar un ticket en el portal","tag":"Portal"},{"operationId":"invoicePortalTicket","method":"POST","path":"/api/v4/portal/tickets/{ticketCode}/invoice","summary":"Autofacturar un ticket","tag":"Portal"},{"operationId":"listPortalCfdiUses","method":"GET","path":"/api/v4/portal/catalogs/cfdi-uses","summary":"Listar los usos de CFDI del receptor","tag":"Portal"},{"operationId":"listPortalTaxRegimes","method":"GET","path":"/api/v4/portal/catalogs/tax-regimes","summary":"Listar los regímenes fiscales del receptor","tag":"Portal"},{"operationId":"recoverPortalTicketInvoice","method":"POST","path":"/api/v4/portal/tickets/{ticketCode}/recover","summary":"Recuperar la factura de un ticket","tag":"Portal"},{"operationId":"resendPortalTicketInvoice","method":"POST","path":"/api/v4/portal/tickets/{ticketCode}/resend","summary":"Reenviar la factura de un ticket","tag":"Portal"},{"operationId":"createProduct","method":"POST","path":"/api/v4/products","summary":"Crear un producto","tag":"Products"},{"operationId":"deleteProduct","method":"DELETE","path":"/api/v4/products/{id}","summary":"Eliminar un producto","tag":"Products"},{"operationId":"getProduct","method":"GET","path":"/api/v4/products/{id}","summary":"Obtener un producto","tag":"Products"},{"operationId":"listProductTaxes","method":"GET","path":"/api/v4/products/{id}/taxes","summary":"Listar los impuestos de un producto","tag":"Products"},{"operationId":"listProducts","method":"GET","path":"/api/v4/products","summary":"Listar productos","tag":"Products"},{"operationId":"updateProduct","method":"PUT","path":"/api/v4/products/{id}","summary":"Actualizar un producto","tag":"Products"},{"operationId":"getSatValidationType","method":"GET","path":"/api/v4/sat-validations/{id}","summary":"Obtener un tipo de validación SAT","tag":"SatValidations"},{"operationId":"listSatValidationTypeStatuses","method":"GET","path":"/api/v4/sat-validations/{id}/statuses","summary":"Listar los estatus de un tipo de validación SAT","tag":"SatValidations"},{"operationId":"listSatValidationTypes","method":"GET","path":"/api/v4/sat-validations","summary":"Listar tipos de validación SAT","tag":"SatValidations"},{"operationId":"runSatValidations","method":"POST","path":"/api/v4/sat-validations","summary":"Validar un CFDI o un RFC ante el SAT","tag":"SatValidations"},{"operationId":"getStampTransaction","method":"GET","path":"/api/v4/stamps/{id}","summary":"Obtener un movimiento de timbres","tag":"Stamps"},{"operationId":"listStampTransactions","method":"GET","path":"/api/v4/stamps","summary":"Listar movimientos de timbres","tag":"Stamps"},{"operationId":"transferStamps","method":"POST","path":"/api/v4/stamps","summary":"Transferir o retirar timbres entre personas","tag":"Stamps"},{"operationId":"createTaxFile","method":"POST","path":"/api/v4/tax-files","summary":"Subir un certificado CSD o FIEL","tag":"TaxFiles"},{"operationId":"deleteTaxFile","method":"DELETE","path":"/api/v4/tax-files/{id}","summary":"Eliminar un certificado","tag":"TaxFiles"},{"operationId":"getTaxFile","method":"GET","path":"/api/v4/tax-files/{id}","summary":"Obtener un certificado","tag":"TaxFiles"},{"operationId":"getTaxFileDefaultValues","method":"GET","path":"/api/v4/tax-files/{personId}/default-values","summary":"Obtener el CSD vigente de una persona","tag":"TaxFiles"},{"operationId":"listTaxFiles","method":"GET","path":"/api/v4/tax-files","summary":"Listar certificados CSD y FIEL","tag":"TaxFiles"},{"operationId":"cancelTicket","method":"DELETE","path":"/api/v4/tickets/{id}","summary":"Cancelar un ticket","tag":"Tickets"},{"operationId":"createTicket","method":"POST","path":"/api/v4/tickets","summary":"Crear un ticket","tag":"Tickets"},{"operationId":"getTicket","method":"GET","path":"/api/v4/tickets/{id}","summary":"Obtener un ticket","tag":"Tickets"},{"operationId":"getTicketCode","method":"GET","path":"/api/v4/tickets/{id}/code","summary":"Obtener el código de un ticket","tag":"Tickets"},{"operationId":"listTickets","method":"GET","path":"/api/v4/tickets","summary":"Listar tickets","tag":"Tickets"},{"operationId":"createWebhook","method":"POST","path":"/api/v4/webhooks","summary":"Crear un webhook","tag":"Webhooks"},{"operationId":"deleteWebhook","method":"DELETE","path":"/api/v4/webhooks/{id}","summary":"Borrar un webhook","tag":"Webhooks"},{"operationId":"getWebhook","method":"GET","path":"/api/v4/webhooks/{id}","summary":"Obtener un webhook","tag":"Webhooks"},{"operationId":"listWebhookDeliveries","method":"GET","path":"/api/v4/webhooks/{id}/deliveries","summary":"Listar las entregas de un webhook","tag":"Webhooks"},{"operationId":"listWebhooks","method":"GET","path":"/api/v4/webhooks","summary":"Listar webhooks","tag":"Webhooks"},{"operationId":"rotateWebhookSecret","method":"POST","path":"/api/v4/webhooks/{id}/rotate-secret","summary":"Rotar el secreto de un webhook","tag":"Webhooks"},{"operationId":"testWebhook","method":"POST","path":"/api/v4/webhooks/{id}/test","summary":"Probar un webhook","tag":"Webhooks"},{"operationId":"updateWebhook","method":"PUT","path":"/api/v4/webhooks/{id}","summary":"Reemplazar un webhook","tag":"Webhooks"}]
|
package/data/source.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openApi": {
|
|
3
|
+
"source": "https://live.fiscalapi.com/api/openapi/v4.json",
|
|
4
|
+
"sha256": "04bb1143e33759cbb9ed000de585a65999a4df88df9803668cc401842ee8cca0",
|
|
5
|
+
"operations": 100
|
|
6
|
+
},
|
|
7
|
+
"docs": {
|
|
8
|
+
"baseUrl": "https://docs.fiscalapi.com",
|
|
9
|
+
"sha256": "19fd40897cb257fa21dd7d2ab2407ca3b51316a138024014a9c4a080c154c235",
|
|
10
|
+
"sections": 388
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import * as z from 'zod/v4';
|
|
5
|
+
import { DATA_FILES, DataFileError, FILE_SAFE_OPERATION_ID, readDataFile } from './data-files.js';
|
|
6
|
+
import { suggestOperationIds } from './operation-suggestions.js';
|
|
7
|
+
const apiOperationSchema = z.object({
|
|
8
|
+
operationId: z.string().regex(FILE_SAFE_OPERATION_ID),
|
|
9
|
+
method: z.string(),
|
|
10
|
+
path: z.string(),
|
|
11
|
+
summary: z.string(),
|
|
12
|
+
tag: z.string(),
|
|
13
|
+
});
|
|
14
|
+
export class ApiOperations {
|
|
15
|
+
tags;
|
|
16
|
+
#operations;
|
|
17
|
+
#byId;
|
|
18
|
+
#contractsDir;
|
|
19
|
+
constructor(operations, contractsDir) {
|
|
20
|
+
this.#operations = operations;
|
|
21
|
+
this.#byId = new Map(operations.map((operation) => [operation.operationId, operation]));
|
|
22
|
+
this.#contractsDir = contractsDir;
|
|
23
|
+
this.tags = [...new Set(operations.map((operation) => operation.tag))];
|
|
24
|
+
}
|
|
25
|
+
static load(dataDir) {
|
|
26
|
+
const operations = readDataFile(dataDir, DATA_FILES.operations, (json) => z.array(apiOperationSchema).parse(JSON.parse(json)));
|
|
27
|
+
const apiOperations = new ApiOperations(operations, new URL(DATA_FILES.operationContracts, dataDir));
|
|
28
|
+
apiOperations.#assertContractsExist();
|
|
29
|
+
return apiOperations;
|
|
30
|
+
}
|
|
31
|
+
list(tag) {
|
|
32
|
+
if (tag === undefined)
|
|
33
|
+
return this.#operations;
|
|
34
|
+
const wantedTag = tag.toLowerCase();
|
|
35
|
+
return this.#operations.filter((operation) => operation.tag.toLowerCase() === wantedTag);
|
|
36
|
+
}
|
|
37
|
+
async readContract(operationId) {
|
|
38
|
+
const operation = this.#byId.get(operationId);
|
|
39
|
+
if (operation === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
return readFile(this.#contractFile(operation), 'utf8');
|
|
42
|
+
}
|
|
43
|
+
suggestSimilarIds(operationId) {
|
|
44
|
+
return suggestOperationIds([...this.#byId.keys()], operationId);
|
|
45
|
+
}
|
|
46
|
+
#contractFile(operation) {
|
|
47
|
+
return new URL(`${operation.operationId}.json`, this.#contractsDir);
|
|
48
|
+
}
|
|
49
|
+
#assertContractsExist() {
|
|
50
|
+
const missing = this.#operations.map((operation) => this.#contractFile(operation)).filter((file) => !existsSync(file));
|
|
51
|
+
if (missing.length > 0) {
|
|
52
|
+
throw new DataFileError(`Missing operation contracts: ${missing.map((file) => fileURLToPath(file)).join(', ')}.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
export const DATA_FILES = {
|
|
4
|
+
operations: 'operations.json',
|
|
5
|
+
operationContracts: 'operations/',
|
|
6
|
+
docsIndex: 'docs-index.json',
|
|
7
|
+
source: 'source.json',
|
|
8
|
+
};
|
|
9
|
+
export const FILE_SAFE_OPERATION_ID = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
10
|
+
export class DataFileError extends Error {
|
|
11
|
+
}
|
|
12
|
+
export function readDataFile(dataDir, name, parse) {
|
|
13
|
+
const file = new URL(name, dataDir);
|
|
14
|
+
try {
|
|
15
|
+
return parse(readFileSync(file, 'utf8'));
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
throw new DataFileError(`Cannot read ${fileURLToPath(file)}. Reinstall the package or regenerate the data with npm run build:data.`, {
|
|
19
|
+
cause: error,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { stemmer } from '@orama/stemmers/spanish';
|
|
2
|
+
import { stopwords } from '@orama/stopwords/spanish';
|
|
3
|
+
const MIN_FUZZY_TERM_LENGTH = 5;
|
|
4
|
+
const FUZZINESS = 0.2;
|
|
5
|
+
const COMBINING_MARKS = /\p{Mn}/gu;
|
|
6
|
+
const SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
|
|
7
|
+
const STOPWORDS = new Set(stopwords.map(withoutAccents));
|
|
8
|
+
export function tokenize(text) {
|
|
9
|
+
return text.split(SPACE_OR_PUNCTUATION);
|
|
10
|
+
}
|
|
11
|
+
export function processTerm(term) {
|
|
12
|
+
const folded = withoutAccents(term.toLowerCase());
|
|
13
|
+
return STOPWORDS.has(folded) ? null : stemmer(folded);
|
|
14
|
+
}
|
|
15
|
+
const searchOptions = {
|
|
16
|
+
boost: { title: 3, page: 1.5, endpoint: 2 },
|
|
17
|
+
prefix: false,
|
|
18
|
+
fuzzy: (term) => (term.length >= MIN_FUZZY_TERM_LENGTH ? FUZZINESS : false),
|
|
19
|
+
};
|
|
20
|
+
export const DOCS_INDEX_OPTIONS = {
|
|
21
|
+
fields: ['title', 'page', 'endpoint', 'text'],
|
|
22
|
+
storeFields: ['title', 'page', 'url', 'text'],
|
|
23
|
+
tokenize,
|
|
24
|
+
processTerm,
|
|
25
|
+
searchOptions,
|
|
26
|
+
};
|
|
27
|
+
function withoutAccents(value) {
|
|
28
|
+
return value.normalize('NFD').replace(COMBINING_MARKS, '');
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import MiniSearch from 'minisearch';
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
|
+
import { DATA_FILES, readDataFile } from './data-files.js';
|
|
4
|
+
import { DOCS_INDEX_OPTIONS } from './docs-index-options.js';
|
|
5
|
+
import { excerpt } from './excerpt.js';
|
|
6
|
+
const storedSectionSchema = z.object({
|
|
7
|
+
title: z.string(),
|
|
8
|
+
page: z.string(),
|
|
9
|
+
url: z.string(),
|
|
10
|
+
text: z.string(),
|
|
11
|
+
});
|
|
12
|
+
const serializedIndexSchema = z.object({
|
|
13
|
+
storedFields: z.record(z.string(), storedSectionSchema),
|
|
14
|
+
});
|
|
15
|
+
export class DocsIndex {
|
|
16
|
+
#index;
|
|
17
|
+
constructor(index) {
|
|
18
|
+
this.#index = index;
|
|
19
|
+
}
|
|
20
|
+
static load(dataDir) {
|
|
21
|
+
return new DocsIndex(readDataFile(dataDir, DATA_FILES.docsIndex, (json) => {
|
|
22
|
+
serializedIndexSchema.parse(JSON.parse(json));
|
|
23
|
+
return MiniSearch.loadJSON(json, DOCS_INDEX_OPTIONS);
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
search(query, limit) {
|
|
27
|
+
return this.#index
|
|
28
|
+
.search(query)
|
|
29
|
+
.slice(0, limit)
|
|
30
|
+
.map((result) => {
|
|
31
|
+
const { title, page, url, text } = storedSectionSchema.parse(result);
|
|
32
|
+
return { title, page, url, excerpt: excerpt(text, result.terms, result.queryTerms) };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/excerpt.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { processTerm, tokenize } from './docs-index-options.js';
|
|
2
|
+
export const MAX_EXCERPT_CHARS = 3_000;
|
|
3
|
+
const MAX_EXCERPT_WORDS = 300;
|
|
4
|
+
const WORDS_BEFORE_MATCH = 40;
|
|
5
|
+
const MAX_CONTEXT_CHARS = MAX_EXCERPT_CHARS / 2;
|
|
6
|
+
const ELLIPSIS = '…';
|
|
7
|
+
const BODY_BUDGET = MAX_EXCERPT_CHARS - 2 * ELLIPSIS.length;
|
|
8
|
+
const MIN_WORD_BOUNDARY_CUT = BODY_BUDGET / 2;
|
|
9
|
+
const WORD = /\S+/g;
|
|
10
|
+
export function excerpt(text, matchedTerms, queryTerms) {
|
|
11
|
+
const words = splitWords(text);
|
|
12
|
+
if (!hasWords(words))
|
|
13
|
+
return '';
|
|
14
|
+
const firstIndex = contextStart(words, firstMatchPreferringExactTerms(words, matchedTerms, queryTerms));
|
|
15
|
+
const window = words.slice(firstIndex, firstIndex + MAX_EXCERPT_WORDS);
|
|
16
|
+
if (!hasWords(window))
|
|
17
|
+
return '';
|
|
18
|
+
const body = text.slice(window[0].start, lastWord(window).end);
|
|
19
|
+
const fits = body.length <= BODY_BUDGET;
|
|
20
|
+
const cutAtStart = firstIndex > 0;
|
|
21
|
+
const cutAtEnd = !fits || firstIndex + window.length < words.length;
|
|
22
|
+
return `${cutAtStart ? ELLIPSIS : ''}${fits ? body : truncate(body, BODY_BUDGET)}${cutAtEnd ? ELLIPSIS : ''}`;
|
|
23
|
+
}
|
|
24
|
+
function splitWords(text) {
|
|
25
|
+
return [...text.matchAll(WORD)].map((match) => ({ text: match[0], start: match.index, end: match.index + match[0].length }));
|
|
26
|
+
}
|
|
27
|
+
function hasWords(words) {
|
|
28
|
+
return words.length > 0;
|
|
29
|
+
}
|
|
30
|
+
function lastWord(words) {
|
|
31
|
+
return words.reduce((_, word) => word, words[0]);
|
|
32
|
+
}
|
|
33
|
+
function firstMatchPreferringExactTerms(words, matchedTerms, queryTerms) {
|
|
34
|
+
const exactTerms = new Set(matchedTerms.filter((term) => queryTerms.includes(term)));
|
|
35
|
+
const anyTerms = new Set(matchedTerms);
|
|
36
|
+
return words.find((word) => containsTerm(word, exactTerms)) ?? words.find((word) => containsTerm(word, anyTerms)) ?? words[0];
|
|
37
|
+
}
|
|
38
|
+
function containsTerm(word, terms) {
|
|
39
|
+
return tokenize(word.text).some((token) => {
|
|
40
|
+
const term = processTerm(token);
|
|
41
|
+
return term !== null && terms.has(term);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function contextStart(words, match) {
|
|
45
|
+
const matchIndex = words.indexOf(match);
|
|
46
|
+
const earliest = Math.max(0, matchIndex - WORDS_BEFORE_MATCH);
|
|
47
|
+
const start = words.findIndex((word, index) => index >= earliest && match.end - word.start <= MAX_CONTEXT_CHARS);
|
|
48
|
+
return start === -1 || start > matchIndex ? matchIndex : start;
|
|
49
|
+
}
|
|
50
|
+
function truncate(value, maxChars) {
|
|
51
|
+
const cut = value.slice(0, maxChars);
|
|
52
|
+
const lastSpace = cut.search(/\s\S*$/);
|
|
53
|
+
return (lastSpace >= MIN_WORD_BOUNDARY_CUT ? cut.slice(0, lastSpace) : cut).trimEnd();
|
|
54
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { inspect } from 'node:util';
|
|
4
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
5
|
+
import * as z from 'zod/v4';
|
|
6
|
+
import { ApiOperations } from './api-operations.js';
|
|
7
|
+
import { DocsIndex } from './docs-index.js';
|
|
8
|
+
import { createServer, SERVER_NAME } from './server.js';
|
|
9
|
+
const packageRoot = new URL('../', import.meta.url);
|
|
10
|
+
const dataDir = new URL('data/', packageRoot);
|
|
11
|
+
function readPackageVersion() {
|
|
12
|
+
const packageJson = JSON.parse(readFileSync(new URL('package.json', packageRoot), 'utf8'));
|
|
13
|
+
return z.object({ version: z.string() }).parse(packageJson).version;
|
|
14
|
+
}
|
|
15
|
+
function logError(error) {
|
|
16
|
+
console.error(`${SERVER_NAME}: ${inspect(error, { depth: 4 })}`);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const dependencies = { operations: ApiOperations.load(dataDir), docs: DocsIndex.load(dataDir), version: readPackageVersion() };
|
|
20
|
+
serveStdio(() => createServer(dependencies), { onerror: logError });
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logError(error);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const MAX_SUGGESTIONS = 5;
|
|
2
|
+
const MIN_SHARED_PREFIX = 3;
|
|
3
|
+
export function suggestOperationIds(operationIds, input) {
|
|
4
|
+
const needle = input.trim().toLowerCase();
|
|
5
|
+
if (needle === '')
|
|
6
|
+
return [];
|
|
7
|
+
const substringMatches = idsContaining(operationIds, needle);
|
|
8
|
+
const suggestions = substringMatches.length > 0 ? substringMatches : idsSharingLongestPrefix(operationIds, needle);
|
|
9
|
+
return suggestions.slice(0, MAX_SUGGESTIONS);
|
|
10
|
+
}
|
|
11
|
+
function idsContaining(operationIds, needle) {
|
|
12
|
+
const startsWithNeedle = (id) => id.toLowerCase().startsWith(needle);
|
|
13
|
+
return [
|
|
14
|
+
...operationIds.filter(startsWithNeedle),
|
|
15
|
+
...operationIds.filter((id) => !startsWithNeedle(id) && id.toLowerCase().includes(needle)),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
function idsSharingLongestPrefix(operationIds, needle) {
|
|
19
|
+
const candidates = operationIds.map((id) => ({
|
|
20
|
+
id,
|
|
21
|
+
sharedPrefix: sharedPrefixLength(id.toLowerCase(), needle),
|
|
22
|
+
lengthGap: Math.abs(id.length - needle.length),
|
|
23
|
+
}));
|
|
24
|
+
const longest = Math.max(0, ...candidates.map((candidate) => candidate.sharedPrefix));
|
|
25
|
+
if (longest < MIN_SHARED_PREFIX)
|
|
26
|
+
return [];
|
|
27
|
+
return candidates
|
|
28
|
+
.filter((candidate) => candidate.sharedPrefix === longest)
|
|
29
|
+
.sort((a, b) => a.lengthGap - b.lengthGap)
|
|
30
|
+
.map((candidate) => candidate.id);
|
|
31
|
+
}
|
|
32
|
+
function sharedPrefixLength(a, b) {
|
|
33
|
+
let length = 0;
|
|
34
|
+
while (length < a.length && length < b.length && a[length] === b[length])
|
|
35
|
+
length++;
|
|
36
|
+
return length;
|
|
37
|
+
}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
import { GetOperationTool } from './tools/get-operation-tool.js';
|
|
3
|
+
import { ListOperationsTool } from './tools/list-operations-tool.js';
|
|
4
|
+
import { SearchDocsTool } from './tools/search-docs-tool.js';
|
|
5
|
+
export const SERVER_NAME = 'fiscalapi-docs';
|
|
6
|
+
export function createServer({ operations, docs, version }) {
|
|
7
|
+
return registerTools(new McpServer({ name: SERVER_NAME, version }), [
|
|
8
|
+
new ListOperationsTool(operations),
|
|
9
|
+
new GetOperationTool(operations),
|
|
10
|
+
new SearchDocsTool(docs),
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
function registerTools(server, tools) {
|
|
14
|
+
for (const tool of tools)
|
|
15
|
+
tool.register(server);
|
|
16
|
+
return server;
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { API_SPECIFICATION_NOTICE, MAX_IDENTIFIER_CHARS, READ_ONLY_ANNOTATIONS, TOOL_NAMES } from './tool-conventions.js';
|
|
3
|
+
import { errorResult, textResult } from './tool-results.js';
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
operationId: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.max(MAX_IDENTIFIER_CHARS)
|
|
9
|
+
.describe(`operationId exacto, tal como lo devuelve ${TOOL_NAMES.listOperations} (por ejemplo createInvoice).`),
|
|
10
|
+
});
|
|
11
|
+
export class GetOperationTool {
|
|
12
|
+
#contracts;
|
|
13
|
+
constructor(contracts) {
|
|
14
|
+
this.#contracts = contracts;
|
|
15
|
+
}
|
|
16
|
+
register(server) {
|
|
17
|
+
server.registerTool(TOOL_NAMES.getOperation, {
|
|
18
|
+
title: 'Obtener el contrato de una operación de FiscalAPI',
|
|
19
|
+
description: 'Devuelve en JSON el contrato de una operación de la API de FiscalAPI: método HTTP, ruta, descripción con el enlace a su documentación, parámetros, cuerpo de la petición y respuestas, con los esquemas resueltos. ' +
|
|
20
|
+
`Un esquema que no cabe se resume como x-truncated y uno recursivo como x-recursive, con el nombre del esquema; para conocer sus campos, búscalo por ese nombre con ${TOOL_NAMES.searchDocs}. ` +
|
|
21
|
+
`Úsala antes de escribir el código que llama a la operación. Requiere el operationId exacto que devuelve ${TOOL_NAMES.listOperations}. ${API_SPECIFICATION_NOTICE}`,
|
|
22
|
+
inputSchema,
|
|
23
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
24
|
+
}, ({ operationId }) => this.#getOperation(operationId));
|
|
25
|
+
}
|
|
26
|
+
async #getOperation(operationId) {
|
|
27
|
+
const contract = await this.#contracts.readContract(operationId);
|
|
28
|
+
if (contract !== undefined)
|
|
29
|
+
return textResult(contract);
|
|
30
|
+
const suggestions = this.#contracts.suggestSimilarIds(operationId);
|
|
31
|
+
const hint = suggestions.length > 0 ? `¿Quisiste decir ${suggestions.join(', ')}? ` : '';
|
|
32
|
+
return errorResult(`No existe la operación "${operationId}". ${hint}Usa ${TOOL_NAMES.listOperations} para ver los operationId disponibles.`);
|
|
33
|
+
}
|
|
34
|
+
}
|