attio-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/LICENSE +236 -0
- package/README.md +105 -0
- package/dist/api/attio-client.d.ts +25 -0
- package/dist/api/attio-client.d.ts.map +1 -0
- package/dist/api/attio-client.js +64 -0
- package/dist/api/attio-client.js.map +1 -0
- package/dist/api/attribute-types.d.ts +119 -0
- package/dist/api/attribute-types.d.ts.map +1 -0
- package/dist/api/attribute-types.js +320 -0
- package/dist/api/attribute-types.js.map +1 -0
- package/dist/api/client.d.ts +3 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +61 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/operations/batch.d.ts +55 -0
- package/dist/api/operations/batch.d.ts.map +1 -0
- package/dist/api/operations/batch.js +176 -0
- package/dist/api/operations/batch.js.map +1 -0
- package/dist/api/operations/crud.d.ts +61 -0
- package/dist/api/operations/crud.d.ts.map +1 -0
- package/dist/api/operations/crud.js +192 -0
- package/dist/api/operations/crud.js.map +1 -0
- package/dist/api/operations/index.d.ts +14 -0
- package/dist/api/operations/index.d.ts.map +1 -0
- package/dist/api/operations/index.js +18 -0
- package/dist/api/operations/index.js.map +1 -0
- package/dist/api/operations/lists.d.ts +66 -0
- package/dist/api/operations/lists.d.ts.map +1 -0
- package/dist/api/operations/lists.js +300 -0
- package/dist/api/operations/lists.js.map +1 -0
- package/dist/api/operations/notes.d.ts +29 -0
- package/dist/api/operations/notes.d.ts.map +1 -0
- package/dist/api/operations/notes.js +63 -0
- package/dist/api/operations/notes.js.map +1 -0
- package/dist/api/operations/retry.d.ts +48 -0
- package/dist/api/operations/retry.d.ts.map +1 -0
- package/dist/api/operations/retry.js +98 -0
- package/dist/api/operations/retry.js.map +1 -0
- package/dist/api/operations/search.d.ts +37 -0
- package/dist/api/operations/search.d.ts.map +1 -0
- package/dist/api/operations/search.js +186 -0
- package/dist/api/operations/search.js.map +1 -0
- package/dist/api/operations/tasks.d.ts +20 -0
- package/dist/api/operations/tasks.d.ts.map +1 -0
- package/dist/api/operations/tasks.js +87 -0
- package/dist/api/operations/tasks.js.map +1 -0
- package/dist/api/operations/types.d.ts +61 -0
- package/dist/api/operations/types.d.ts.map +1 -0
- package/dist/api/operations/types.js +10 -0
- package/dist/api/operations/types.js.map +1 -0
- package/dist/cli/commands/attributes.d.ts +34 -0
- package/dist/cli/commands/attributes.d.ts.map +1 -0
- package/dist/cli/commands/attributes.js +171 -0
- package/dist/cli/commands/attributes.js.map +1 -0
- package/dist/cli/discover.d.ts +3 -0
- package/dist/cli/discover.d.ts.map +1 -0
- package/dist/cli/discover.js +72 -0
- package/dist/cli/discover.js.map +1 -0
- package/dist/errors/api-errors.d.ts +191 -0
- package/dist/errors/api-errors.d.ts.map +1 -0
- package/dist/errors/api-errors.js +305 -0
- package/dist/errors/api-errors.js.map +1 -0
- package/dist/errors/company-errors.d.ts +40 -0
- package/dist/errors/company-errors.d.ts.map +1 -0
- package/dist/errors/company-errors.js +62 -0
- package/dist/errors/company-errors.js.map +1 -0
- package/dist/errors/value-match-error.d.ts +15 -0
- package/dist/errors/value-match-error.d.ts.map +1 -0
- package/dist/errors/value-match-error.js +40 -0
- package/dist/errors/value-match-error.js.map +1 -0
- package/dist/handlers/error-interceptor.d.ts +6 -0
- package/dist/handlers/error-interceptor.d.ts.map +1 -0
- package/dist/handlers/error-interceptor.js +17 -0
- package/dist/handlers/error-interceptor.js.map +1 -0
- package/dist/handlers/rate-limited-handler.d.ts +17 -0
- package/dist/handlers/rate-limited-handler.d.ts.map +1 -0
- package/dist/handlers/rate-limited-handler.js +126 -0
- package/dist/handlers/rate-limited-handler.js.map +1 -0
- package/dist/handlers/resources.d.ts +11 -0
- package/dist/handlers/resources.d.ts.map +1 -0
- package/dist/handlers/resources.js +109 -0
- package/dist/handlers/resources.js.map +1 -0
- package/dist/handlers/tool-configs/companies/attributes.d.ts +85 -0
- package/dist/handlers/tool-configs/companies/attributes.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/attributes.js +203 -0
- package/dist/handlers/tool-configs/companies/attributes.js.map +1 -0
- package/dist/handlers/tool-configs/companies/batch.d.ts +145 -0
- package/dist/handlers/tool-configs/companies/batch.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/batch.js +249 -0
- package/dist/handlers/tool-configs/companies/batch.js.map +1 -0
- package/dist/handlers/tool-configs/companies/crud.d.ts +103 -0
- package/dist/handlers/tool-configs/companies/crud.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/crud.js +157 -0
- package/dist/handlers/tool-configs/companies/crud.js.map +1 -0
- package/dist/handlers/tool-configs/companies/definitions.d.ts +5 -0
- package/dist/handlers/tool-configs/companies/definitions.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/definitions.js +9 -0
- package/dist/handlers/tool-configs/companies/definitions.js.map +1 -0
- package/dist/handlers/tool-configs/companies/formatters.d.ts +42 -0
- package/dist/handlers/tool-configs/companies/formatters.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/formatters.js +324 -0
- package/dist/handlers/tool-configs/companies/formatters.js.map +1 -0
- package/dist/handlers/tool-configs/companies/index.d.ts +642 -0
- package/dist/handlers/tool-configs/companies/index.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/index.js +86 -0
- package/dist/handlers/tool-configs/companies/index.js.map +1 -0
- package/dist/handlers/tool-configs/companies/notes.d.ts +61 -0
- package/dist/handlers/tool-configs/companies/notes.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/notes.js +109 -0
- package/dist/handlers/tool-configs/companies/notes.js.map +1 -0
- package/dist/handlers/tool-configs/companies/relationships.d.ts +137 -0
- package/dist/handlers/tool-configs/companies/relationships.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/relationships.js +163 -0
- package/dist/handlers/tool-configs/companies/relationships.js.map +1 -0
- package/dist/handlers/tool-configs/companies/search.d.ts +101 -0
- package/dist/handlers/tool-configs/companies/search.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/search.js +163 -0
- package/dist/handlers/tool-configs/companies/search.js.map +1 -0
- package/dist/handlers/tool-configs/companies/types.d.ts +6 -0
- package/dist/handlers/tool-configs/companies/types.d.ts.map +1 -0
- package/dist/handlers/tool-configs/companies/types.js +2 -0
- package/dist/handlers/tool-configs/companies/types.js.map +1 -0
- package/dist/handlers/tool-configs/index.d.ts +12 -0
- package/dist/handlers/tool-configs/index.d.ts.map +1 -0
- package/dist/handlers/tool-configs/index.js +12 -0
- package/dist/handlers/tool-configs/index.js.map +1 -0
- package/dist/handlers/tool-configs/lists.d.ts +459 -0
- package/dist/handlers/tool-configs/lists.d.ts.map +1 -0
- package/dist/handlers/tool-configs/lists.js +597 -0
- package/dist/handlers/tool-configs/lists.js.map +1 -0
- package/dist/handlers/tool-configs/paginated-people.d.ts +197 -0
- package/dist/handlers/tool-configs/paginated-people.d.ts.map +1 -0
- package/dist/handlers/tool-configs/paginated-people.js +256 -0
- package/dist/handlers/tool-configs/paginated-people.js.map +1 -0
- package/dist/handlers/tool-configs/people/activity-search.d.ts +98 -0
- package/dist/handlers/tool-configs/people/activity-search.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/activity-search.js +113 -0
- package/dist/handlers/tool-configs/people/activity-search.js.map +1 -0
- package/dist/handlers/tool-configs/people/advanced-search.d.ts +62 -0
- package/dist/handlers/tool-configs/people/advanced-search.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/advanced-search.js +74 -0
- package/dist/handlers/tool-configs/people/advanced-search.js.map +1 -0
- package/dist/handlers/tool-configs/people/crud.d.ts +63 -0
- package/dist/handlers/tool-configs/people/crud.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/crud.js +71 -0
- package/dist/handlers/tool-configs/people/crud.js.map +1 -0
- package/dist/handlers/tool-configs/people/date-search.d.ts +42 -0
- package/dist/handlers/tool-configs/people/date-search.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/date-search.js +93 -0
- package/dist/handlers/tool-configs/people/date-search.js.map +1 -0
- package/dist/handlers/tool-configs/people/formatters.d.ts +19 -0
- package/dist/handlers/tool-configs/people/formatters.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/formatters.js +98 -0
- package/dist/handlers/tool-configs/people/formatters.js.map +1 -0
- package/dist/handlers/tool-configs/people/index.d.ts +407 -0
- package/dist/handlers/tool-configs/people/index.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/index.js +30 -0
- package/dist/handlers/tool-configs/people/index.js.map +1 -0
- package/dist/handlers/tool-configs/people/notes.d.ts +38 -0
- package/dist/handlers/tool-configs/people/notes.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/notes.js +57 -0
- package/dist/handlers/tool-configs/people/notes.js.map +1 -0
- package/dist/handlers/tool-configs/people/relationships.d.ts +112 -0
- package/dist/handlers/tool-configs/people/relationships.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/relationships.js +173 -0
- package/dist/handlers/tool-configs/people/relationships.js.map +1 -0
- package/dist/handlers/tool-configs/people/search.d.ts +53 -0
- package/dist/handlers/tool-configs/people/search.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people/search.js +61 -0
- package/dist/handlers/tool-configs/people/search.js.map +1 -0
- package/dist/handlers/tool-configs/people-fix-complete.d.ts +6 -0
- package/dist/handlers/tool-configs/people-fix-complete.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people-fix-complete.js +76 -0
- package/dist/handlers/tool-configs/people-fix-complete.js.map +1 -0
- package/dist/handlers/tool-configs/people-fixed.d.ts +12 -0
- package/dist/handlers/tool-configs/people-fixed.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people-fixed.js +58 -0
- package/dist/handlers/tool-configs/people-fixed.js.map +1 -0
- package/dist/handlers/tool-configs/people-types.d.ts +32 -0
- package/dist/handlers/tool-configs/people-types.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people-types.js +5 -0
- package/dist/handlers/tool-configs/people-types.js.map +1 -0
- package/dist/handlers/tool-configs/people.d.ts +599 -0
- package/dist/handlers/tool-configs/people.d.ts.map +1 -0
- package/dist/handlers/tool-configs/people.js +817 -0
- package/dist/handlers/tool-configs/people.js.map +1 -0
- package/dist/handlers/tool-configs/prompts.d.ts +69 -0
- package/dist/handlers/tool-configs/prompts.d.ts.map +1 -0
- package/dist/handlers/tool-configs/prompts.js +90 -0
- package/dist/handlers/tool-configs/prompts.js.map +1 -0
- package/dist/handlers/tool-configs/rate-limited-people.d.ts +203 -0
- package/dist/handlers/tool-configs/rate-limited-people.d.ts.map +1 -0
- package/dist/handlers/tool-configs/rate-limited-people.js +44 -0
- package/dist/handlers/tool-configs/rate-limited-people.js.map +1 -0
- package/dist/handlers/tool-configs/records/index.d.ts +282 -0
- package/dist/handlers/tool-configs/records/index.d.ts.map +1 -0
- package/dist/handlers/tool-configs/records/index.js +277 -0
- package/dist/handlers/tool-configs/records/index.js.map +1 -0
- package/dist/handlers/tool-configs/records.d.ts +282 -0
- package/dist/handlers/tool-configs/records.d.ts.map +1 -0
- package/dist/handlers/tool-configs/records.js +277 -0
- package/dist/handlers/tool-configs/records.js.map +1 -0
- package/dist/handlers/tool-configs/resource-specific-tools.d.ts +15 -0
- package/dist/handlers/tool-configs/resource-specific-tools.d.ts.map +1 -0
- package/dist/handlers/tool-configs/resource-specific-tools.js +33 -0
- package/dist/handlers/tool-configs/resource-specific-tools.js.map +1 -0
- package/dist/handlers/tool-configs/tasks.d.ts +127 -0
- package/dist/handlers/tool-configs/tasks.d.ts.map +1 -0
- package/dist/handlers/tool-configs/tasks.js +95 -0
- package/dist/handlers/tool-configs/tasks.js.map +1 -0
- package/dist/handlers/tool-types.d.ts +47 -0
- package/dist/handlers/tool-types.d.ts.map +1 -0
- package/dist/handlers/tool-types.js +2 -0
- package/dist/handlers/tool-types.js.map +1 -0
- package/dist/handlers/tools/config-verifier.d.ts +27 -0
- package/dist/handlers/tools/config-verifier.d.ts.map +1 -0
- package/dist/handlers/tools/config-verifier.js +108 -0
- package/dist/handlers/tools/config-verifier.js.map +1 -0
- package/dist/handlers/tools/dispatcher/core.d.ts +12 -0
- package/dist/handlers/tools/dispatcher/core.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/core.js +276 -0
- package/dist/handlers/tools/dispatcher/core.js.map +1 -0
- package/dist/handlers/tools/dispatcher/formatting.d.ts +17 -0
- package/dist/handlers/tools/dispatcher/formatting.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/formatting.js +25 -0
- package/dist/handlers/tools/dispatcher/formatting.js.map +1 -0
- package/dist/handlers/tools/dispatcher/logging.d.ts +63 -0
- package/dist/handlers/tools/dispatcher/logging.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/logging.js +108 -0
- package/dist/handlers/tools/dispatcher/logging.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/batch.d.ts +29 -0
- package/dist/handlers/tools/dispatcher/operations/batch.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/batch.js +137 -0
- package/dist/handlers/tools/dispatcher/operations/batch.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/crud.d.ts +25 -0
- package/dist/handlers/tools/dispatcher/operations/crud.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/crud.js +110 -0
- package/dist/handlers/tools/dispatcher/operations/crud.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/details.d.ts +13 -0
- package/dist/handlers/tools/dispatcher/operations/details.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/details.js +52 -0
- package/dist/handlers/tools/dispatcher/operations/details.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/info.d.ts +25 -0
- package/dist/handlers/tools/dispatcher/operations/info.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/info.js +82 -0
- package/dist/handlers/tools/dispatcher/operations/info.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/lists.d.ts +62 -0
- package/dist/handlers/tools/dispatcher/operations/lists.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/lists.js +283 -0
- package/dist/handlers/tools/dispatcher/operations/lists.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/notes.d.ts +17 -0
- package/dist/handlers/tools/dispatcher/operations/notes.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/notes.js +102 -0
- package/dist/handlers/tools/dispatcher/operations/notes.js.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/search.d.ts +43 -0
- package/dist/handlers/tools/dispatcher/operations/search.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/operations/search.js +190 -0
- package/dist/handlers/tools/dispatcher/operations/search.js.map +1 -0
- package/dist/handlers/tools/dispatcher/validation.d.ts +27 -0
- package/dist/handlers/tools/dispatcher/validation.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher/validation.js +47 -0
- package/dist/handlers/tools/dispatcher/validation.js.map +1 -0
- package/dist/handlers/tools/dispatcher.d.ts +11 -0
- package/dist/handlers/tools/dispatcher.d.ts.map +1 -0
- package/dist/handlers/tools/dispatcher.js +15 -0
- package/dist/handlers/tools/dispatcher.js.map +1 -0
- package/dist/handlers/tools/error-types.d.ts +33 -0
- package/dist/handlers/tools/error-types.d.ts.map +1 -0
- package/dist/handlers/tools/error-types.js +21 -0
- package/dist/handlers/tools/error-types.js.map +1 -0
- package/dist/handlers/tools/formatters.d.ts +43 -0
- package/dist/handlers/tools/formatters.d.ts.map +1 -0
- package/dist/handlers/tools/formatters.js +170 -0
- package/dist/handlers/tools/formatters.js.map +1 -0
- package/dist/handlers/tools/index.d.ts +15 -0
- package/dist/handlers/tools/index.d.ts.map +1 -0
- package/dist/handlers/tools/index.js +34 -0
- package/dist/handlers/tools/index.js.map +1 -0
- package/dist/handlers/tools/registry.d.ts +1874 -0
- package/dist/handlers/tools/registry.d.ts.map +1 -0
- package/dist/handlers/tools/registry.js +103 -0
- package/dist/handlers/tools/registry.js.map +1 -0
- package/dist/health/http-server.d.ts +24 -0
- package/dist/health/http-server.d.ts.map +1 -0
- package/dist/health/http-server.js +106 -0
- package/dist/health/http-server.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/dist/objects/base-operations.d.ts +41 -0
- package/dist/objects/base-operations.d.ts.map +1 -0
- package/dist/objects/base-operations.js +116 -0
- package/dist/objects/base-operations.js.map +1 -0
- package/dist/objects/batch-companies.d.ts +112 -0
- package/dist/objects/batch-companies.d.ts.map +1 -0
- package/dist/objects/batch-companies.js +347 -0
- package/dist/objects/batch-companies.js.map +1 -0
- package/dist/objects/companies/attributes.d.ts +83 -0
- package/dist/objects/companies/attributes.d.ts.map +1 -0
- package/dist/objects/companies/attributes.js +426 -0
- package/dist/objects/companies/attributes.js.map +1 -0
- package/dist/objects/companies/basic.d.ts +117 -0
- package/dist/objects/companies/basic.d.ts.map +1 -0
- package/dist/objects/companies/basic.js +367 -0
- package/dist/objects/companies/basic.js.map +1 -0
- package/dist/objects/companies/batch.d.ts +6 -0
- package/dist/objects/companies/batch.d.ts.map +1 -0
- package/dist/objects/companies/batch.js +6 -0
- package/dist/objects/companies/batch.js.map +1 -0
- package/dist/objects/companies/index.d.ts +13 -0
- package/dist/objects/companies/index.d.ts.map +1 -0
- package/dist/objects/companies/index.js +17 -0
- package/dist/objects/companies/index.js.map +1 -0
- package/dist/objects/companies/notes.d.ts +26 -0
- package/dist/objects/companies/notes.d.ts.map +1 -0
- package/dist/objects/companies/notes.js +199 -0
- package/dist/objects/companies/notes.js.map +1 -0
- package/dist/objects/companies/relationships.d.ts +41 -0
- package/dist/objects/companies/relationships.d.ts.map +1 -0
- package/dist/objects/companies/relationships.js +142 -0
- package/dist/objects/companies/relationships.js.map +1 -0
- package/dist/objects/companies/search.d.ts +158 -0
- package/dist/objects/companies/search.d.ts.map +1 -0
- package/dist/objects/companies/search.js +463 -0
- package/dist/objects/companies/search.js.map +1 -0
- package/dist/objects/companies/types.d.ts +27 -0
- package/dist/objects/companies/types.d.ts.map +1 -0
- package/dist/objects/companies/types.js +3 -0
- package/dist/objects/companies/types.js.map +1 -0
- package/dist/objects/lists.d.ts +148 -0
- package/dist/objects/lists.d.ts.map +1 -0
- package/dist/objects/lists.js +586 -0
- package/dist/objects/lists.js.map +1 -0
- package/dist/objects/paginated-people.d.ts +50 -0
- package/dist/objects/paginated-people.d.ts.map +1 -0
- package/dist/objects/paginated-people.js +171 -0
- package/dist/objects/paginated-people.js.map +1 -0
- package/dist/objects/people/basic.d.ts +90 -0
- package/dist/objects/people/basic.d.ts.map +1 -0
- package/dist/objects/people/basic.js +157 -0
- package/dist/objects/people/basic.js.map +1 -0
- package/dist/objects/people/batch.d.ts +24 -0
- package/dist/objects/people/batch.d.ts.map +1 -0
- package/dist/objects/people/batch.js +145 -0
- package/dist/objects/people/batch.js.map +1 -0
- package/dist/objects/people/index.d.ts +11 -0
- package/dist/objects/people/index.d.ts.map +1 -0
- package/dist/objects/people/index.js +17 -0
- package/dist/objects/people/index.js.map +1 -0
- package/dist/objects/people/notes.d.ts +20 -0
- package/dist/objects/people/notes.d.ts.map +1 -0
- package/dist/objects/people/notes.js +60 -0
- package/dist/objects/people/notes.js.map +1 -0
- package/dist/objects/people/relationships.d.ts +23 -0
- package/dist/objects/people/relationships.d.ts.map +1 -0
- package/dist/objects/people/relationships.js +116 -0
- package/dist/objects/people/relationships.js.map +1 -0
- package/dist/objects/people/search.d.ts +83 -0
- package/dist/objects/people/search.d.ts.map +1 -0
- package/dist/objects/people/search.js +286 -0
- package/dist/objects/people/search.js.map +1 -0
- package/dist/objects/people/types.d.ts +37 -0
- package/dist/objects/people/types.d.ts.map +1 -0
- package/dist/objects/people/types.js +71 -0
- package/dist/objects/people/types.js.map +1 -0
- package/dist/objects/people-write.d.ts +71 -0
- package/dist/objects/people-write.d.ts.map +1 -0
- package/dist/objects/people-write.js +261 -0
- package/dist/objects/people-write.js.map +1 -0
- package/dist/objects/records/formatters.d.ts +20 -0
- package/dist/objects/records/formatters.d.ts.map +1 -0
- package/dist/objects/records/formatters.js +47 -0
- package/dist/objects/records/formatters.js.map +1 -0
- package/dist/objects/records/index.d.ts +74 -0
- package/dist/objects/records/index.d.ts.map +1 -0
- package/dist/objects/records/index.js +374 -0
- package/dist/objects/records/index.js.map +1 -0
- package/dist/objects/records.d.ts +88 -0
- package/dist/objects/records.d.ts.map +1 -0
- package/dist/objects/records.js +432 -0
- package/dist/objects/records.js.map +1 -0
- package/dist/objects/tasks.d.ts +19 -0
- package/dist/objects/tasks.d.ts.map +1 -0
- package/dist/objects/tasks.js +23 -0
- package/dist/objects/tasks.js.map +1 -0
- package/dist/prompts/error-handler.d.ts +28 -0
- package/dist/prompts/error-handler.d.ts.map +1 -0
- package/dist/prompts/error-handler.js +47 -0
- package/dist/prompts/error-handler.js.map +1 -0
- package/dist/prompts/handlers.d.ts +49 -0
- package/dist/prompts/handlers.d.ts.map +1 -0
- package/dist/prompts/handlers.js +353 -0
- package/dist/prompts/handlers.js.map +1 -0
- package/dist/prompts/index.d.ts +11 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +15 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/templates/companies.d.ts +10 -0
- package/dist/prompts/templates/companies.d.ts.map +1 -0
- package/dist/prompts/templates/companies.js +128 -0
- package/dist/prompts/templates/companies.js.map +1 -0
- package/dist/prompts/templates/index.d.ts +42 -0
- package/dist/prompts/templates/index.d.ts.map +1 -0
- package/dist/prompts/templates/index.js +58 -0
- package/dist/prompts/templates/index.js.map +1 -0
- package/dist/prompts/templates/lists.d.ts +10 -0
- package/dist/prompts/templates/lists.d.ts.map +1 -0
- package/dist/prompts/templates/lists.js +127 -0
- package/dist/prompts/templates/lists.js.map +1 -0
- package/dist/prompts/templates/notes.d.ts +10 -0
- package/dist/prompts/templates/notes.d.ts.map +1 -0
- package/dist/prompts/templates/notes.js +119 -0
- package/dist/prompts/templates/notes.js.map +1 -0
- package/dist/prompts/templates/people.d.ts +10 -0
- package/dist/prompts/templates/people.d.ts.map +1 -0
- package/dist/prompts/templates/people.js +127 -0
- package/dist/prompts/templates/people.js.map +1 -0
- package/dist/prompts/types.d.ts +52 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +5 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/types/attio.d.ts +424 -0
- package/dist/types/attio.d.ts.map +1 -0
- package/dist/types/attio.js +116 -0
- package/dist/types/attio.js.map +1 -0
- package/dist/types/company-types.d.ts +52 -0
- package/dist/types/company-types.d.ts.map +1 -0
- package/dist/types/company-types.js +5 -0
- package/dist/types/company-types.js.map +1 -0
- package/dist/types/tool-types.d.ts +262 -0
- package/dist/types/tool-types.d.ts.map +1 -0
- package/dist/types/tool-types.js +6 -0
- package/dist/types/tool-types.js.map +1 -0
- package/dist/utils/api-fallback.d.ts +39 -0
- package/dist/utils/api-fallback.d.ts.map +1 -0
- package/dist/utils/api-fallback.js +94 -0
- package/dist/utils/api-fallback.js.map +1 -0
- package/dist/utils/attribute-mapping/attribute-mappers.d.ts +39 -0
- package/dist/utils/attribute-mapping/attribute-mappers.d.ts.map +1 -0
- package/dist/utils/attribute-mapping/attribute-mappers.js +394 -0
- package/dist/utils/attribute-mapping/attribute-mappers.js.map +1 -0
- package/dist/utils/attribute-mapping/filter-translator.d.ts +9 -0
- package/dist/utils/attribute-mapping/filter-translator.d.ts.map +1 -0
- package/dist/utils/attribute-mapping/filter-translator.js +104 -0
- package/dist/utils/attribute-mapping/filter-translator.js.map +1 -0
- package/dist/utils/attribute-mapping/index.d.ts +10 -0
- package/dist/utils/attribute-mapping/index.d.ts.map +1 -0
- package/dist/utils/attribute-mapping/index.js +12 -0
- package/dist/utils/attribute-mapping/index.js.map +1 -0
- package/dist/utils/attribute-mapping/legacy-maps.d.ts +11 -0
- package/dist/utils/attribute-mapping/legacy-maps.d.ts.map +1 -0
- package/dist/utils/attribute-mapping/legacy-maps.js +54 -0
- package/dist/utils/attribute-mapping/legacy-maps.js.map +1 -0
- package/dist/utils/attribute-mapping/mapping-utils.d.ts +90 -0
- package/dist/utils/attribute-mapping/mapping-utils.d.ts.map +1 -0
- package/dist/utils/attribute-mapping/mapping-utils.js +145 -0
- package/dist/utils/attribute-mapping/mapping-utils.js.map +1 -0
- package/dist/utils/auto-discovery.d.ts +22 -0
- package/dist/utils/auto-discovery.d.ts.map +1 -0
- package/dist/utils/auto-discovery.js +143 -0
- package/dist/utils/auto-discovery.js.map +1 -0
- package/dist/utils/cli-colors.d.ts +36 -0
- package/dist/utils/cli-colors.d.ts.map +1 -0
- package/dist/utils/cli-colors.js +35 -0
- package/dist/utils/cli-colors.js.map +1 -0
- package/dist/utils/config-loader.d.ts +41 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +167 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/config-migration.d.ts +140 -0
- package/dist/utils/config-migration.d.ts.map +1 -0
- package/dist/utils/config-migration.js +310 -0
- package/dist/utils/config-migration.js.map +1 -0
- package/dist/utils/date-utils.d.ts +63 -0
- package/dist/utils/date-utils.d.ts.map +1 -0
- package/dist/utils/date-utils.js +329 -0
- package/dist/utils/date-utils.js.map +1 -0
- package/dist/utils/debug-b2b-segment.d.ts +2 -0
- package/dist/utils/debug-b2b-segment.d.ts.map +1 -0
- package/dist/utils/debug-b2b-segment.js +67 -0
- package/dist/utils/debug-b2b-segment.js.map +1 -0
- package/dist/utils/domain-utils.d.ts +46 -0
- package/dist/utils/domain-utils.d.ts.map +1 -0
- package/dist/utils/domain-utils.js +143 -0
- package/dist/utils/domain-utils.js.map +1 -0
- package/dist/utils/dynamic-import.d.ts +33 -0
- package/dist/utils/dynamic-import.d.ts.map +1 -0
- package/dist/utils/dynamic-import.js +41 -0
- package/dist/utils/dynamic-import.js.map +1 -0
- package/dist/utils/error-enhancer.d.ts +23 -0
- package/dist/utils/error-enhancer.d.ts.map +1 -0
- package/dist/utils/error-enhancer.js +188 -0
- package/dist/utils/error-enhancer.js.map +1 -0
- package/dist/utils/error-handler.d.ts +89 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +336 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/filters/builders/activity.d.ts +13 -0
- package/dist/utils/filters/builders/activity.d.ts.map +1 -0
- package/dist/utils/filters/builders/activity.js +65 -0
- package/dist/utils/filters/builders/activity.js.map +1 -0
- package/dist/utils/filters/builders/basic.d.ts +13 -0
- package/dist/utils/filters/builders/basic.d.ts.map +1 -0
- package/dist/utils/filters/builders/basic.js +36 -0
- package/dist/utils/filters/builders/basic.js.map +1 -0
- package/dist/utils/filters/builders/complex.d.ts +31 -0
- package/dist/utils/filters/builders/complex.d.ts.map +1 -0
- package/dist/utils/filters/builders/complex.js +92 -0
- package/dist/utils/filters/builders/complex.js.map +1 -0
- package/dist/utils/filters/builders/date.d.ts +17 -0
- package/dist/utils/filters/builders/date.d.ts.map +1 -0
- package/dist/utils/filters/builders/date.js +51 -0
- package/dist/utils/filters/builders/date.js.map +1 -0
- package/dist/utils/filters/builders/index.d.ts +8 -0
- package/dist/utils/filters/builders/index.d.ts.map +1 -0
- package/dist/utils/filters/builders/index.js +8 -0
- package/dist/utils/filters/builders/index.js.map +1 -0
- package/dist/utils/filters/builders/numeric.d.ts +17 -0
- package/dist/utils/filters/builders/numeric.d.ts.map +1 -0
- package/dist/utils/filters/builders/numeric.js +61 -0
- package/dist/utils/filters/builders/numeric.js.map +1 -0
- package/dist/utils/filters/builders/text.d.ts +17 -0
- package/dist/utils/filters/builders/text.d.ts.map +1 -0
- package/dist/utils/filters/builders/text.js +47 -0
- package/dist/utils/filters/builders/text.js.map +1 -0
- package/dist/utils/filters/builders/types.d.ts +2 -0
- package/dist/utils/filters/builders/types.d.ts.map +1 -0
- package/dist/utils/filters/builders/types.js +2 -0
- package/dist/utils/filters/builders/types.js.map +1 -0
- package/dist/utils/filters/builders.d.ts +2 -0
- package/dist/utils/filters/builders.d.ts.map +1 -0
- package/dist/utils/filters/builders.js +2 -0
- package/dist/utils/filters/builders.js.map +1 -0
- package/dist/utils/filters/cache.d.ts +80 -0
- package/dist/utils/filters/cache.d.ts.map +1 -0
- package/dist/utils/filters/cache.js +212 -0
- package/dist/utils/filters/cache.js.map +1 -0
- package/dist/utils/filters/index.d.ts +51 -0
- package/dist/utils/filters/index.d.ts.map +1 -0
- package/dist/utils/filters/index.js +67 -0
- package/dist/utils/filters/index.js.map +1 -0
- package/dist/utils/filters/operators.d.ts +65 -0
- package/dist/utils/filters/operators.d.ts.map +1 -0
- package/dist/utils/filters/operators.js +214 -0
- package/dist/utils/filters/operators.js.map +1 -0
- package/dist/utils/filters/relationship.d.ts +81 -0
- package/dist/utils/filters/relationship.d.ts.map +1 -0
- package/dist/utils/filters/relationship.js +393 -0
- package/dist/utils/filters/relationship.js.map +1 -0
- package/dist/utils/filters/translators.d.ts +120 -0
- package/dist/utils/filters/translators.d.ts.map +1 -0
- package/dist/utils/filters/translators.js +397 -0
- package/dist/utils/filters/translators.js.map +1 -0
- package/dist/utils/filters/types.d.ts +77 -0
- package/dist/utils/filters/types.d.ts.map +1 -0
- package/dist/utils/filters/types.js +85 -0
- package/dist/utils/filters/types.js.map +1 -0
- package/dist/utils/filters/utils.d.ts +86 -0
- package/dist/utils/filters/utils.d.ts.map +1 -0
- package/dist/utils/filters/utils.js +142 -0
- package/dist/utils/filters/utils.js.map +1 -0
- package/dist/utils/filters/validation-utils.d.ts +123 -0
- package/dist/utils/filters/validation-utils.d.ts.map +1 -0
- package/dist/utils/filters/validation-utils.js +282 -0
- package/dist/utils/filters/validation-utils.js.map +1 -0
- package/dist/utils/filters/validators.d.ts +73 -0
- package/dist/utils/filters/validators.d.ts.map +1 -0
- package/dist/utils/filters/validators.js +311 -0
- package/dist/utils/filters/validators.js.map +1 -0
- package/dist/utils/json-serializer.d.ts +68 -0
- package/dist/utils/json-serializer.d.ts.map +1 -0
- package/dist/utils/json-serializer.js +235 -0
- package/dist/utils/json-serializer.js.map +1 -0
- package/dist/utils/logger.d.ts +226 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +323 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/numeric-utils.d.ts +27 -0
- package/dist/utils/numeric-utils.d.ts.map +1 -0
- package/dist/utils/numeric-utils.js +83 -0
- package/dist/utils/numeric-utils.js.map +1 -0
- package/dist/utils/pagination.d.ts +85 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +169 -0
- package/dist/utils/pagination.js.map +1 -0
- package/dist/utils/person-lookup.d.ts +35 -0
- package/dist/utils/person-lookup.d.ts.map +1 -0
- package/dist/utils/person-lookup.js +67 -0
- package/dist/utils/person-lookup.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +82 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +159 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/record-utils.d.ts +74 -0
- package/dist/utils/record-utils.d.ts.map +1 -0
- package/dist/utils/record-utils.js +312 -0
- package/dist/utils/record-utils.js.map +1 -0
- package/dist/utils/relationship-utils.d.ts +61 -0
- package/dist/utils/relationship-utils.d.ts.map +1 -0
- package/dist/utils/relationship-utils.js +242 -0
- package/dist/utils/relationship-utils.js.map +1 -0
- package/dist/utils/response-formatter.d.ts +121 -0
- package/dist/utils/response-formatter.d.ts.map +1 -0
- package/dist/utils/response-formatter.js +188 -0
- package/dist/utils/response-formatter.js.map +1 -0
- package/dist/utils/uri-parser.d.ts +18 -0
- package/dist/utils/uri-parser.d.ts.map +1 -0
- package/dist/utils/uri-parser.js +31 -0
- package/dist/utils/uri-parser.js.map +1 -0
- package/dist/utils/validation.d.ts +59 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +264 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/value-matcher.d.ts +58 -0
- package/dist/utils/value-matcher.d.ts.map +1 -0
- package/dist/utils/value-matcher.js +131 -0
- package/dist/utils/value-matcher.js.map +1 -0
- package/dist/validators/attribute-validator.d.ts +59 -0
- package/dist/validators/attribute-validator.d.ts.map +1 -0
- package/dist/validators/attribute-validator.js +531 -0
- package/dist/validators/attribute-validator.js.map +1 -0
- package/dist/validators/company/field_detector.d.ts +5 -0
- package/dist/validators/company/field_detector.d.ts.map +1 -0
- package/dist/validators/company/field_detector.js +95 -0
- package/dist/validators/company/field_detector.js.map +1 -0
- package/dist/validators/company/index.d.ts +26 -0
- package/dist/validators/company/index.d.ts.map +1 -0
- package/dist/validators/company/index.js +433 -0
- package/dist/validators/company/index.js.map +1 -0
- package/dist/validators/company/type_cache.d.ts +14 -0
- package/dist/validators/company/type_cache.d.ts.map +1 -0
- package/dist/validators/company/type_cache.js +28 -0
- package/dist/validators/company/type_cache.js.map +1 -0
- package/dist/validators/company/types.d.ts +8 -0
- package/dist/validators/company/types.d.ts.map +1 -0
- package/dist/validators/company/types.js +2 -0
- package/dist/validators/company/types.js.map +1 -0
- package/dist/validators/company-validator.d.ts +2 -0
- package/dist/validators/company-validator.d.ts.map +1 -0
- package/dist/validators/company-validator.js +2 -0
- package/dist/validators/company-validator.js.map +1 -0
- package/package.json +167 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { safeJsonStringify, sanitizeMcpResponse } from './json-serializer.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enum for categorizing different types of errors
|
|
4
|
+
*/
|
|
5
|
+
export var ErrorType;
|
|
6
|
+
(function (ErrorType) {
|
|
7
|
+
ErrorType["VALIDATION_ERROR"] = "validation_error";
|
|
8
|
+
ErrorType["API_ERROR"] = "api_error";
|
|
9
|
+
ErrorType["AUTHENTICATION_ERROR"] = "authentication_error";
|
|
10
|
+
ErrorType["RATE_LIMIT_ERROR"] = "rate_limit_error";
|
|
11
|
+
ErrorType["NETWORK_ERROR"] = "network_error";
|
|
12
|
+
ErrorType["NOT_FOUND_ERROR"] = "not_found_error";
|
|
13
|
+
ErrorType["SERVER_ERROR"] = "server_error";
|
|
14
|
+
ErrorType["PARAMETER_ERROR"] = "parameter_error";
|
|
15
|
+
ErrorType["SERIALIZATION_ERROR"] = "serialization_error";
|
|
16
|
+
ErrorType["FORMAT_ERROR"] = "format_error";
|
|
17
|
+
ErrorType["UNKNOWN_ERROR"] = "unknown_error";
|
|
18
|
+
})(ErrorType || (ErrorType = {}));
|
|
19
|
+
/**
|
|
20
|
+
* Custom error class for Attio API errors
|
|
21
|
+
*/
|
|
22
|
+
export class AttioApiError extends Error {
|
|
23
|
+
status;
|
|
24
|
+
detail;
|
|
25
|
+
path;
|
|
26
|
+
method;
|
|
27
|
+
responseData;
|
|
28
|
+
type;
|
|
29
|
+
constructor(message, status, detail, path, method, type = ErrorType.API_ERROR, responseData = {}) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = 'AttioApiError';
|
|
32
|
+
this.status = status;
|
|
33
|
+
this.detail = detail;
|
|
34
|
+
this.path = path;
|
|
35
|
+
this.method = method;
|
|
36
|
+
this.type = type;
|
|
37
|
+
this.responseData = responseData;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a specific API error based on status code and context
|
|
42
|
+
*
|
|
43
|
+
* @param status - HTTP status code
|
|
44
|
+
* @param path - API path
|
|
45
|
+
* @param method - HTTP method
|
|
46
|
+
* @param responseData - Response data from API
|
|
47
|
+
* @returns Appropriate error instance
|
|
48
|
+
*/
|
|
49
|
+
export function createAttioError(error) {
|
|
50
|
+
// If it's already an AttioApiError, return it
|
|
51
|
+
if (error instanceof AttioApiError) {
|
|
52
|
+
return error;
|
|
53
|
+
}
|
|
54
|
+
// Handle Axios errors
|
|
55
|
+
if (error.isAxiosError && error.response) {
|
|
56
|
+
const { status, data, config } = error.response;
|
|
57
|
+
const path = config?.url || 'unknown';
|
|
58
|
+
const method = config?.method?.toUpperCase() || 'UNKNOWN';
|
|
59
|
+
return createApiError(status, path, method, data);
|
|
60
|
+
}
|
|
61
|
+
// Return the original error if we can't enhance it
|
|
62
|
+
return error;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a specific API error based on status code and context
|
|
66
|
+
*
|
|
67
|
+
* @param status - HTTP status code
|
|
68
|
+
* @param path - API path
|
|
69
|
+
* @param method - HTTP method
|
|
70
|
+
* @param responseData - Response data from API
|
|
71
|
+
* @returns Appropriate error instance
|
|
72
|
+
*/
|
|
73
|
+
export function createApiError(status, path, method, responseData = {}) {
|
|
74
|
+
const defaultMessage = responseData?.error?.message ||
|
|
75
|
+
responseData?.message ||
|
|
76
|
+
'Unknown API error';
|
|
77
|
+
const detail = responseData?.error?.detail ||
|
|
78
|
+
responseData?.detail ||
|
|
79
|
+
'No additional details';
|
|
80
|
+
let errorType = ErrorType.API_ERROR;
|
|
81
|
+
let message = '';
|
|
82
|
+
// Create specific error messages based on status code and context
|
|
83
|
+
switch (status) {
|
|
84
|
+
case 400:
|
|
85
|
+
// Detect common parameter and format errors in the 400 response
|
|
86
|
+
if (defaultMessage.includes('parameter') ||
|
|
87
|
+
defaultMessage.includes('param') ||
|
|
88
|
+
responseData?.error?.details?.includes('parameter')) {
|
|
89
|
+
errorType = ErrorType.PARAMETER_ERROR;
|
|
90
|
+
message = `Parameter Error: ${defaultMessage}`;
|
|
91
|
+
}
|
|
92
|
+
else if (defaultMessage.includes('format') ||
|
|
93
|
+
defaultMessage.includes('invalid')) {
|
|
94
|
+
errorType = ErrorType.FORMAT_ERROR;
|
|
95
|
+
message = `Format Error: ${defaultMessage}`;
|
|
96
|
+
}
|
|
97
|
+
else if (defaultMessage.includes('serialize') ||
|
|
98
|
+
defaultMessage.includes('parse')) {
|
|
99
|
+
errorType = ErrorType.SERIALIZATION_ERROR;
|
|
100
|
+
message = `Serialization Error: ${defaultMessage}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
errorType = ErrorType.VALIDATION_ERROR;
|
|
104
|
+
message = `Bad Request: ${defaultMessage}`;
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case 401:
|
|
108
|
+
case 403:
|
|
109
|
+
errorType = ErrorType.AUTHENTICATION_ERROR;
|
|
110
|
+
message =
|
|
111
|
+
status === 401
|
|
112
|
+
? 'Authentication failed. Please check your API key.'
|
|
113
|
+
: 'Permission denied. Your API key lacks the necessary permissions.';
|
|
114
|
+
break;
|
|
115
|
+
case 404:
|
|
116
|
+
errorType = ErrorType.NOT_FOUND_ERROR;
|
|
117
|
+
// Customize 404 message based on path
|
|
118
|
+
if (path.includes('/objects/people/')) {
|
|
119
|
+
message = `Person not found: ${path.split('/').pop()}`;
|
|
120
|
+
}
|
|
121
|
+
else if (path.includes('/objects/companies/')) {
|
|
122
|
+
message = `Company not found: ${path.split('/').pop()}`;
|
|
123
|
+
}
|
|
124
|
+
else if (path.includes('/lists/')) {
|
|
125
|
+
const listId = path.split('/').pop();
|
|
126
|
+
if (path.includes('/entries')) {
|
|
127
|
+
message = `List entry not found in list ${path.split('/')[2]}`;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
message = `List not found: ${listId}`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
message = `Resource not found: ${path}`;
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case 422:
|
|
138
|
+
errorType = ErrorType.PARAMETER_ERROR;
|
|
139
|
+
message = `Unprocessable Entity: ${defaultMessage}`;
|
|
140
|
+
break;
|
|
141
|
+
case 429:
|
|
142
|
+
errorType = ErrorType.RATE_LIMIT_ERROR;
|
|
143
|
+
message = 'Rate limit exceeded. Please try again later.';
|
|
144
|
+
break;
|
|
145
|
+
case 500:
|
|
146
|
+
case 502:
|
|
147
|
+
case 503:
|
|
148
|
+
case 504:
|
|
149
|
+
errorType = ErrorType.SERVER_ERROR;
|
|
150
|
+
message = `Attio API server error (${status}): ${defaultMessage}`;
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
if (status >= 500) {
|
|
154
|
+
errorType = ErrorType.SERVER_ERROR;
|
|
155
|
+
}
|
|
156
|
+
else if (status >= 400) {
|
|
157
|
+
errorType = ErrorType.API_ERROR;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
errorType = ErrorType.UNKNOWN_ERROR;
|
|
161
|
+
}
|
|
162
|
+
message = `API Error (${status}): ${defaultMessage}`;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
return new AttioApiError(message, status, detail, path, method, errorType, responseData);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Format an error into a standardized response based on error type
|
|
169
|
+
*
|
|
170
|
+
* @param error - The error to format
|
|
171
|
+
* @param type - The error type
|
|
172
|
+
* @param details - Additional error details
|
|
173
|
+
* @returns Formatted error response
|
|
174
|
+
*/
|
|
175
|
+
export function formatErrorResponse(error, type = ErrorType.UNKNOWN_ERROR, details) {
|
|
176
|
+
// Ensure we have a valid error object
|
|
177
|
+
const normalizedError = error instanceof Error
|
|
178
|
+
? error
|
|
179
|
+
: new Error(typeof error === 'string' ? error : 'Unknown error');
|
|
180
|
+
// Prevent "undefined" from being returned as an error message
|
|
181
|
+
const errorMessage = normalizedError.message || 'An unknown error occurred';
|
|
182
|
+
// Determine appropriate status code based on error type
|
|
183
|
+
const errorCode = type === ErrorType.VALIDATION_ERROR
|
|
184
|
+
? 400
|
|
185
|
+
: type === ErrorType.AUTHENTICATION_ERROR
|
|
186
|
+
? 401
|
|
187
|
+
: type === ErrorType.RATE_LIMIT_ERROR
|
|
188
|
+
? 429
|
|
189
|
+
: type === ErrorType.NOT_FOUND_ERROR
|
|
190
|
+
? 404
|
|
191
|
+
: type === ErrorType.SERVER_ERROR
|
|
192
|
+
? 500
|
|
193
|
+
: type === ErrorType.PARAMETER_ERROR
|
|
194
|
+
? 400
|
|
195
|
+
: type === ErrorType.FORMAT_ERROR
|
|
196
|
+
? 400
|
|
197
|
+
: type === ErrorType.SERIALIZATION_ERROR
|
|
198
|
+
? 400
|
|
199
|
+
: 500;
|
|
200
|
+
// Enhance error message with helpful tips for specific error types
|
|
201
|
+
let helpfulTip = '';
|
|
202
|
+
if (type === ErrorType.PARAMETER_ERROR) {
|
|
203
|
+
helpfulTip =
|
|
204
|
+
'\n\nTIP: Check parameter names and formats. Use direct string parameters instead of constants or placeholders.';
|
|
205
|
+
}
|
|
206
|
+
else if (type === ErrorType.FORMAT_ERROR) {
|
|
207
|
+
helpfulTip =
|
|
208
|
+
'\n\nTIP: Ensure all parameters use the correct format as specified in the API documentation.';
|
|
209
|
+
}
|
|
210
|
+
else if (type === ErrorType.SERIALIZATION_ERROR) {
|
|
211
|
+
helpfulTip =
|
|
212
|
+
'\n\nTIP: Verify objects are properly serialized to strings where needed.';
|
|
213
|
+
}
|
|
214
|
+
// Create a safe copy of details to prevent circular reference issues during JSON serialization
|
|
215
|
+
let safeDetails = null;
|
|
216
|
+
if (details) {
|
|
217
|
+
try {
|
|
218
|
+
// Use createSafeCopy which handles circular references and non-serializable values
|
|
219
|
+
safeDetails = JSON.parse(safeJsonStringify(details, {
|
|
220
|
+
includeStackTraces: process.env.NODE_ENV === 'development',
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
console.error('[formatErrorResponse] Error with safe stringification:', err instanceof Error ? err.message : String(err));
|
|
225
|
+
// Ultimate fallback
|
|
226
|
+
safeDetails = {
|
|
227
|
+
note: 'Error details could not be serialized',
|
|
228
|
+
error: String(err),
|
|
229
|
+
detailsType: typeof details,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Log the error for debugging purposes
|
|
234
|
+
if (process.env.DEBUG || process.env.NODE_ENV === 'development') {
|
|
235
|
+
console.error(`[formatErrorResponse] Formatted error [${type}]:`, errorMessage);
|
|
236
|
+
}
|
|
237
|
+
// Return properly formatted MCP error response
|
|
238
|
+
const errorResponse = {
|
|
239
|
+
content: [
|
|
240
|
+
{
|
|
241
|
+
type: 'text',
|
|
242
|
+
text: `ERROR [${type}]: ${errorMessage}${helpfulTip}${safeDetails
|
|
243
|
+
? '\n\nDetails: ' + safeJsonStringify(safeDetails, { indent: 0 })
|
|
244
|
+
: ''}`,
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
isError: true,
|
|
248
|
+
error: {
|
|
249
|
+
code: errorCode,
|
|
250
|
+
message: errorMessage,
|
|
251
|
+
type,
|
|
252
|
+
details: safeDetails,
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
// Sanitize the final error response to ensure it's MCP-compatible
|
|
256
|
+
return sanitizeMcpResponse(errorResponse);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Creates a detailed error response for API errors, suitable for returning to MCP clients
|
|
260
|
+
*
|
|
261
|
+
* @param error - The caught error
|
|
262
|
+
* @param url - The API URL that was called
|
|
263
|
+
* @param method - The HTTP method used
|
|
264
|
+
* @param responseData - Any response data received
|
|
265
|
+
* @returns Formatted error result
|
|
266
|
+
*/
|
|
267
|
+
export function createErrorResult(error, url, method, responseData = {}) {
|
|
268
|
+
// Ensure we have a valid error object to work with
|
|
269
|
+
const normalizedError = error instanceof Error
|
|
270
|
+
? error
|
|
271
|
+
: new Error(typeof error === 'string' ? error : 'Unknown error');
|
|
272
|
+
if (process.env.DEBUG || process.env.NODE_ENV === 'development') {
|
|
273
|
+
console.error(`[createErrorResult] Processing error for ${method} ${url}:`, normalizedError.message);
|
|
274
|
+
}
|
|
275
|
+
// If it's already an AttioApiError, use it directly
|
|
276
|
+
if (error instanceof AttioApiError) {
|
|
277
|
+
const errorDetails = {
|
|
278
|
+
status: error.status,
|
|
279
|
+
method: error.method,
|
|
280
|
+
path: error.path,
|
|
281
|
+
detail: error.detail,
|
|
282
|
+
responseData: error.responseData,
|
|
283
|
+
};
|
|
284
|
+
return formatErrorResponse(error, error.type, errorDetails);
|
|
285
|
+
}
|
|
286
|
+
// For Axios errors with response data
|
|
287
|
+
if (responseData && responseData.status) {
|
|
288
|
+
try {
|
|
289
|
+
// Create a specific API error
|
|
290
|
+
const apiError = createApiError(responseData.status, url, method, responseData);
|
|
291
|
+
const errorDetails = {
|
|
292
|
+
status: apiError.status,
|
|
293
|
+
method: apiError.method,
|
|
294
|
+
path: apiError.path,
|
|
295
|
+
detail: apiError.detail,
|
|
296
|
+
responseData: apiError.responseData,
|
|
297
|
+
originalError: normalizedError.message,
|
|
298
|
+
};
|
|
299
|
+
return formatErrorResponse(apiError, apiError.type, errorDetails);
|
|
300
|
+
}
|
|
301
|
+
catch (formattingError) {
|
|
302
|
+
// If error formatting fails, preserve the original error
|
|
303
|
+
console.error('Error while formatting API error:', formattingError);
|
|
304
|
+
const originalErrorDetails = {
|
|
305
|
+
url,
|
|
306
|
+
method,
|
|
307
|
+
status: responseData.status,
|
|
308
|
+
originalError: normalizedError.message,
|
|
309
|
+
formattingError: formattingError instanceof Error
|
|
310
|
+
? formattingError.message
|
|
311
|
+
: 'Unknown formatting error',
|
|
312
|
+
};
|
|
313
|
+
return formatErrorResponse(normalizedError, ErrorType.UNKNOWN_ERROR, originalErrorDetails);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// For network or unknown errors
|
|
317
|
+
let errorType = ErrorType.UNKNOWN_ERROR;
|
|
318
|
+
// Try to determine error type based on message or instance
|
|
319
|
+
if (normalizedError.message.includes('network') ||
|
|
320
|
+
normalizedError.message.includes('connection')) {
|
|
321
|
+
errorType = ErrorType.NETWORK_ERROR;
|
|
322
|
+
}
|
|
323
|
+
else if (normalizedError.message.includes('timeout')) {
|
|
324
|
+
errorType = ErrorType.NETWORK_ERROR;
|
|
325
|
+
}
|
|
326
|
+
const errorDetails = {
|
|
327
|
+
method,
|
|
328
|
+
url,
|
|
329
|
+
status: responseData.status || 'Unknown',
|
|
330
|
+
headers: responseData.headers || {},
|
|
331
|
+
data: responseData.data || {},
|
|
332
|
+
rawError: typeof error === 'object' ? JSON.stringify(error) : String(error),
|
|
333
|
+
};
|
|
334
|
+
return formatErrorResponse(normalizedError, errorType, errorDetails);
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,kDAAqC,CAAA;IACrC,oCAAuB,CAAA;IACvB,0DAA6C,CAAA;IAC7C,kDAAqC,CAAA;IACrC,4CAA+B,CAAA;IAC/B,gDAAmC,CAAA;IACnC,0CAA6B,CAAA;IAC7B,gDAAmC,CAAA;IACnC,wDAA2C,CAAA;IAC3C,0CAA6B,CAAA;IAC7B,4CAA+B,CAAA;AACjC,CAAC,EAZW,SAAS,KAAT,SAAS,QAYpB;AAoBD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAS;IACf,MAAM,CAAS;IACf,IAAI,CAAS;IACb,MAAM,CAAS;IACf,YAAY,CAAM;IAClB,IAAI,CAAY;IAEhB,YACE,OAAe,EACf,MAAc,EACd,MAAc,EACd,IAAY,EACZ,MAAc,EACd,OAAkB,SAAS,CAAC,SAAS,EACrC,eAAoB,EAAE;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF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AAY,CAAC,EAC9C,CAAC;QACD,SAAS,GAAG,SAAS,CAAC,aAAa,CAAC;IACtC,CAAC;SAAM,IAAI,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACvD,SAAS,GAAG,SAAS,CAAC,aAAa,CAAC;IACtC,CAAC;IAED,MAAM,YAAY,GAAG;QACnB,MAAM;QACN,GAAG;QACH,MAAM,EAAE,YAAY,CAAC,MAAM,IAAI,SAAS;QACxC,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;QACnC,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE;QAC7B,QAAQ,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;KAC5E,CAAC;IAEF,OAAO,mBAAmB,CAAC,eAAe,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity related filter builders.
|
|
3
|
+
*/
|
|
4
|
+
import { ListEntryFilters, DateRange, ActivityFilter, InteractionType } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates an activity filter for finding records with specific interaction types within a date range.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createActivityFilter(activityFilter: ActivityFilter): ListEntryFilters;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a filter for records based on their last interaction date.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLastInteractionFilter(dateRange: DateRange, interactionType?: InteractionType): ListEntryFilters;
|
|
13
|
+
//# sourceMappingURL=activity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../../src/utils/filters/builders/activity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAGL,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,eAAe,EAEhB,MAAM,YAAY,CAAC;AAIpB;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,cAAc,GAC7B,gBAAgB,CAqBlB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,SAAS,EACpB,eAAe,CAAC,EAAE,eAAe,GAChC,gBAAgB,CAoClB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity related filter builders.
|
|
3
|
+
*/
|
|
4
|
+
// External imports
|
|
5
|
+
import { FilterValidationError } from '../../../errors/api-errors.js';
|
|
6
|
+
import { resolveDateRange } from '../../date-utils.js';
|
|
7
|
+
// Internal imports
|
|
8
|
+
import { FilterConditionType, InteractionType, ATTRIBUTES, } from './types.js';
|
|
9
|
+
import { validateActivityFilter } from '../validators.js';
|
|
10
|
+
import { createDateRangeFilter } from './date.js';
|
|
11
|
+
/**
|
|
12
|
+
* Creates an activity filter for finding records with specific interaction types within a date range.
|
|
13
|
+
*/
|
|
14
|
+
export function createActivityFilter(activityFilter) {
|
|
15
|
+
const validated = validateActivityFilter(activityFilter);
|
|
16
|
+
const filters = [];
|
|
17
|
+
const dateFilter = createDateRangeFilter(ATTRIBUTES.LAST_INTERACTION, validated.dateRange);
|
|
18
|
+
if (dateFilter.filters) {
|
|
19
|
+
filters.push(...dateFilter.filters);
|
|
20
|
+
}
|
|
21
|
+
if (validated.interactionType) {
|
|
22
|
+
filters.push({
|
|
23
|
+
attribute: { slug: ATTRIBUTES.INTERACTION_TYPE },
|
|
24
|
+
condition: FilterConditionType.EQUALS,
|
|
25
|
+
value: validated.interactionType,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return { filters, matchAny: false };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a filter for records based on their last interaction date.
|
|
32
|
+
*/
|
|
33
|
+
export function createLastInteractionFilter(dateRange, interactionType) {
|
|
34
|
+
try {
|
|
35
|
+
const filters = [];
|
|
36
|
+
const resolvedRange = resolveDateRange(dateRange);
|
|
37
|
+
if (resolvedRange.start) {
|
|
38
|
+
filters.push({
|
|
39
|
+
attribute: { slug: ATTRIBUTES.LAST_INTERACTION },
|
|
40
|
+
condition: FilterConditionType.GREATER_THAN_OR_EQUALS,
|
|
41
|
+
value: resolvedRange.start,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (resolvedRange.end) {
|
|
45
|
+
filters.push({
|
|
46
|
+
attribute: { slug: ATTRIBUTES.LAST_INTERACTION },
|
|
47
|
+
condition: FilterConditionType.LESS_THAN_OR_EQUALS,
|
|
48
|
+
value: resolvedRange.end,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (interactionType && interactionType !== InteractionType.ANY) {
|
|
52
|
+
filters.push({
|
|
53
|
+
attribute: { slug: ATTRIBUTES.INTERACTION_TYPE },
|
|
54
|
+
condition: FilterConditionType.EQUALS,
|
|
55
|
+
value: interactionType,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return { filters, matchAny: false };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
throw new FilterValidationError(`Failed to create interaction filter: ${message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=activity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../../../src/utils/filters/builders/activity.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mBAAmB;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EAKnB,eAAe,EACf,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kB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,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,gBAAgB,EAAE;gBAChD,SAAS,EAAE,mBAAmB,CAAC,mBAAmB;gBAClD,KAAK,EAAE,aAAa,CAAC,GAAG;aACzB,CAAC,CAAC;QACL,CAAC;QAED,IAAI,eAAe,IAAI,eAAe,KAAK,eAAe,CAAC,GAAG,EAAE,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC;gBACX,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,gBAAgB,EAAE;gBAChD,SAAS,EAAE,mBAAmB,CAAC,MAAM;gBACrC,KAAK,EAAE,eAAe;aACvB,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,qBAAqB,CAC7B,wCAAwC,OAAO,EAAE,CAClD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic comparison filter builders.
|
|
3
|
+
*/
|
|
4
|
+
import { ListEntryFilters } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a simple equals filter for any attribute.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createEqualsFilter(attributeSlug: string, value: any): ListEntryFilters;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a simple contains filter for text attributes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createContainsFilter(attributeSlug: string, value: string): ListEntryFilters;
|
|
13
|
+
//# sourceMappingURL=basic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../../src/utils/filters/builders/basic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAuB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,GAAG,GACT,gBAAgB,CAWlB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,GACZ,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic comparison filter builders.
|
|
3
|
+
*/
|
|
4
|
+
// Internal imports
|
|
5
|
+
import { FilterConditionType } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a simple equals filter for any attribute.
|
|
8
|
+
*/
|
|
9
|
+
export function createEqualsFilter(attributeSlug, value) {
|
|
10
|
+
return {
|
|
11
|
+
filters: [
|
|
12
|
+
{
|
|
13
|
+
attribute: { slug: attributeSlug },
|
|
14
|
+
condition: FilterConditionType.EQUALS,
|
|
15
|
+
value,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
matchAny: false,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a simple contains filter for text attributes.
|
|
23
|
+
*/
|
|
24
|
+
export function createContainsFilter(attributeSlug, value) {
|
|
25
|
+
return {
|
|
26
|
+
filters: [
|
|
27
|
+
{
|
|
28
|
+
attribute: { slug: attributeSlug },
|
|
29
|
+
condition: FilterConditionType.CONTAINS,
|
|
30
|
+
value,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
matchAny: false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=basic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../../src/utils/filters/builders/basic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mBAAmB;AACnB,OAAO,EAAE,mBAAmB,EAAoB,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,aAAqB,EACrB,KAAU;IAEV,OAAO;QACL,OAAO,EAAE;YACP;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;gBAClC,SAAS,EAAE,mBAAmB,CAAC,MAAM;gBACrC,KAAK;aACN;SACF;QACD,QAAQ,EAAE,KAAK;KAChB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,aAAqB,EACrB,KAAa;IAEb,OAAO;QACL,OAAO,EAAE;YACP;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;gBAClC,SAAS,EAAE,mBAAmB,CAAC,QAAQ;gBACvC,KAAK;aACN;SACF;QACD,QAAQ,EAAE,KAAK;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complex and utility filter builders.
|
|
3
|
+
*/
|
|
4
|
+
import { ListEntryFilters } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a filter for objects in a specific list.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createListFilter(listId: string): ListEntryFilters;
|
|
9
|
+
/**
|
|
10
|
+
* Creates filters using special field handling rules.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createFilterWithSpecialHandling(attributeSlug: string, operator: string, value: any): ListEntryFilters;
|
|
13
|
+
/**
|
|
14
|
+
* Combines multiple filter sets using OR logic.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createOrFilter(...filterSets: ListEntryFilters[]): ListEntryFilters;
|
|
17
|
+
/**
|
|
18
|
+
* Combines multiple filter sets using AND logic.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createAndFilter(...filterSets: ListEntryFilters[]): ListEntryFilters;
|
|
21
|
+
/**
|
|
22
|
+
* Combines multiple filters with AND logic.
|
|
23
|
+
*/
|
|
24
|
+
export declare function combineWithAnd(...filters: ListEntryFilters[]): ListEntryFilters;
|
|
25
|
+
/**
|
|
26
|
+
* Combines multiple filters with OR logic.
|
|
27
|
+
*/
|
|
28
|
+
export declare function combineWithOr(...filters: ListEntryFilters[]): ListEntryFilters;
|
|
29
|
+
export declare const combineFiltersWithAnd: typeof combineWithAnd;
|
|
30
|
+
export declare const combineFiltersWithOr: typeof combineWithOr;
|
|
31
|
+
//# sourceMappingURL=complex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex.d.ts","sourceRoot":"","sources":["../../../../src/utils/filters/builders/complex.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAGL,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,GAAG,GACT,gBAAgB,CAiClB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,UAAU,EAAE,gBAAgB,EAAE,GAChC,gBAAgB,CAQlB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,GAAG,UAAU,EAAE,gBAAgB,EAAE,GAChC,gBAAgB,CAQlB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,OAAO,EAAE,gBAAgB,EAAE,GAC7B,gBAAgB,CAElB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,OAAO,EAAE,gBAAgB,EAAE,GAC7B,gBAAgB,CAElB;AAED,eAAO,MAAM,qBAAqB,uBAAiB,CAAC;AACpD,eAAO,MAAM,oBAAoB,sBAAgB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complex and utility filter builders.
|
|
3
|
+
*/
|
|
4
|
+
// Internal imports
|
|
5
|
+
import { FilterConditionType, ATTRIBUTES, FIELD_SPECIAL_HANDLING, } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a filter for objects in a specific list.
|
|
8
|
+
*/
|
|
9
|
+
export function createListFilter(listId) {
|
|
10
|
+
return {
|
|
11
|
+
filters: [
|
|
12
|
+
{
|
|
13
|
+
attribute: { slug: ATTRIBUTES.LIST_ID },
|
|
14
|
+
condition: FilterConditionType.EQUALS,
|
|
15
|
+
value: listId,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
matchAny: false,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates filters using special field handling rules.
|
|
23
|
+
*/
|
|
24
|
+
export function createFilterWithSpecialHandling(attributeSlug, operator, value) {
|
|
25
|
+
const specialHandling = FIELD_SPECIAL_HANDLING[attributeSlug];
|
|
26
|
+
if (!specialHandling) {
|
|
27
|
+
return {
|
|
28
|
+
filters: [
|
|
29
|
+
{
|
|
30
|
+
attribute: { slug: attributeSlug },
|
|
31
|
+
condition: operator,
|
|
32
|
+
value,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
matchAny: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const mappedOperator = specialHandling[operator] || operator;
|
|
39
|
+
let processedValue = value;
|
|
40
|
+
if (specialHandling.allowStringValue && typeof value === 'string') {
|
|
41
|
+
processedValue = value;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
filters: [
|
|
45
|
+
{
|
|
46
|
+
attribute: { slug: attributeSlug },
|
|
47
|
+
condition: mappedOperator,
|
|
48
|
+
value: processedValue,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
matchAny: false,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Combines multiple filter sets using OR logic.
|
|
56
|
+
*/
|
|
57
|
+
export function createOrFilter(...filterSets) {
|
|
58
|
+
const allFilters = [];
|
|
59
|
+
filterSets.forEach((filterSet) => {
|
|
60
|
+
if (filterSet.filters) {
|
|
61
|
+
allFilters.push(...filterSet.filters);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return { filters: allFilters, matchAny: true };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Combines multiple filter sets using AND logic.
|
|
68
|
+
*/
|
|
69
|
+
export function createAndFilter(...filterSets) {
|
|
70
|
+
const allFilters = [];
|
|
71
|
+
filterSets.forEach((filterSet) => {
|
|
72
|
+
if (filterSet.filters) {
|
|
73
|
+
allFilters.push(...filterSet.filters);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return { filters: allFilters, matchAny: false };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Combines multiple filters with AND logic.
|
|
80
|
+
*/
|
|
81
|
+
export function combineWithAnd(...filters) {
|
|
82
|
+
return createAndFilter(...filters);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Combines multiple filters with OR logic.
|
|
86
|
+
*/
|
|
87
|
+
export function combineWithOr(...filters) {
|
|
88
|
+
return createOrFilter(...filters);
|
|
89
|
+
}
|
|
90
|
+
export const combineFiltersWithAnd = combineWithAnd;
|
|
91
|
+
export const combineFiltersWithOr = combineWithOr;
|
|
92
|
+
//# sourceMappingURL=complex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex.js","sourceRoot":"","sources":["../../../../src/utils/filters/builders/complex.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EAGnB,UAAU,EACV,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE;gBACvC,SAAS,EAAE,mBAAmB,CA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CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAG,UAA8B;IAEjC,MAAM,UAAU,GAAsB,EAAE,CAAC;IACzC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC/B,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACtB,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAG,OAA2B;IAE9B,OAAO,eAAe,CAAC,GAAG,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAG,OAA2B;IAE9B,OAAO,cAAc,CAAC,GAAG,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date related filter builders.
|
|
3
|
+
*/
|
|
4
|
+
import { ListEntryFilters, DateRange } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a date range filter for a specific attribute.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createDateRangeFilter(attributeSlug: string, dateRange: DateRange): ListEntryFilters;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a filter for records based on their creation date.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createCreatedDateFilter(dateRange: DateRange): ListEntryFilters;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a filter for records based on their last modification date.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createModifiedDateFilter(dateRange: DateRange): ListEntryFilters;
|
|
17
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../../src/utils/filters/builders/date.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAGL,gBAAgB,EAChB,SAAS,EAEV,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,SAAS,GACnB,gBAAgB,CA6BlB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,GACnB,gBAAgB,CAElB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,GACnB,gBAAgB,CAElB"}
|