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,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced structured logging utility for consistent logging across the application
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Log level enum for controlling verbosity
|
|
6
|
+
*/
|
|
7
|
+
export declare enum LogLevel {
|
|
8
|
+
DEBUG = 0,
|
|
9
|
+
INFO = 1,
|
|
10
|
+
WARN = 2,
|
|
11
|
+
ERROR = 3,
|
|
12
|
+
NONE = 4
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Operation types for better log categorization
|
|
16
|
+
*/
|
|
17
|
+
export declare enum OperationType {
|
|
18
|
+
API_CALL = "api_call",
|
|
19
|
+
TOOL_EXECUTION = "tool_execution",
|
|
20
|
+
DATA_PROCESSING = "data_processing",
|
|
21
|
+
VALIDATION = "validation",
|
|
22
|
+
TRANSFORMATION = "transformation",
|
|
23
|
+
SYSTEM = "system"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Structured log metadata interface
|
|
27
|
+
*/
|
|
28
|
+
export interface LogMetadata {
|
|
29
|
+
timestamp: string;
|
|
30
|
+
level: string;
|
|
31
|
+
module: string;
|
|
32
|
+
operation?: string;
|
|
33
|
+
operationType?: OperationType;
|
|
34
|
+
correlationId?: string;
|
|
35
|
+
sessionId?: string;
|
|
36
|
+
duration?: number;
|
|
37
|
+
requestId?: string;
|
|
38
|
+
userId?: string;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Structured log entry interface
|
|
43
|
+
*/
|
|
44
|
+
export interface LogEntry {
|
|
45
|
+
message: string;
|
|
46
|
+
metadata: LogMetadata;
|
|
47
|
+
data?: any;
|
|
48
|
+
error?: {
|
|
49
|
+
message: string;
|
|
50
|
+
name: string;
|
|
51
|
+
stack?: string;
|
|
52
|
+
code?: string | number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Context for tracking related operations
|
|
57
|
+
*/
|
|
58
|
+
interface LogContext {
|
|
59
|
+
correlationId?: string;
|
|
60
|
+
sessionId?: string;
|
|
61
|
+
requestId?: string;
|
|
62
|
+
userId?: string;
|
|
63
|
+
operation?: string;
|
|
64
|
+
operationType?: OperationType;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Current log level based on environment
|
|
68
|
+
*/
|
|
69
|
+
export declare const CURRENT_LOG_LEVEL: LogLevel;
|
|
70
|
+
/**
|
|
71
|
+
* Set global logging context for correlation tracking
|
|
72
|
+
*/
|
|
73
|
+
export declare function setLogContext(context: Partial<LogContext>): void;
|
|
74
|
+
/**
|
|
75
|
+
* Get current logging context
|
|
76
|
+
*/
|
|
77
|
+
export declare function getLogContext(): LogContext;
|
|
78
|
+
/**
|
|
79
|
+
* Clear logging context
|
|
80
|
+
*/
|
|
81
|
+
export declare function clearLogContext(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Generate a new correlation ID
|
|
84
|
+
*/
|
|
85
|
+
export declare function generateCorrelationId(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Log a debug message (only in development)
|
|
88
|
+
*
|
|
89
|
+
* @param module - Name of the module/function logging the message
|
|
90
|
+
* @param message - Message to log
|
|
91
|
+
* @param data - Optional data to include with the log
|
|
92
|
+
* @param operation - Optional operation name
|
|
93
|
+
* @param operationType - Optional operation type
|
|
94
|
+
*/
|
|
95
|
+
export declare function debug(module: string, message: string, data?: any, operation?: string, operationType?: OperationType): void;
|
|
96
|
+
/**
|
|
97
|
+
* Log an info message
|
|
98
|
+
*
|
|
99
|
+
* @param module - Name of the module/function logging the message
|
|
100
|
+
* @param message - Message to log
|
|
101
|
+
* @param data - Optional data to include with the log
|
|
102
|
+
* @param operation - Optional operation name
|
|
103
|
+
* @param operationType - Optional operation type
|
|
104
|
+
*/
|
|
105
|
+
export declare function info(module: string, message: string, data?: any, operation?: string, operationType?: OperationType): void;
|
|
106
|
+
/**
|
|
107
|
+
* Log a warning message
|
|
108
|
+
*
|
|
109
|
+
* @param module - Name of the module/function logging the message
|
|
110
|
+
* @param message - Message to log
|
|
111
|
+
* @param data - Optional data to include with the log
|
|
112
|
+
* @param operation - Optional operation name
|
|
113
|
+
* @param operationType - Optional operation type
|
|
114
|
+
*/
|
|
115
|
+
export declare function warn(module: string, message: string, data?: any, operation?: string, operationType?: OperationType): void;
|
|
116
|
+
/**
|
|
117
|
+
* Log an error message
|
|
118
|
+
*
|
|
119
|
+
* @param module - Name of the module/function logging the message
|
|
120
|
+
* @param message - Message to log
|
|
121
|
+
* @param errorObj - Optional error object
|
|
122
|
+
* @param data - Optional additional data
|
|
123
|
+
* @param operation - Optional operation name
|
|
124
|
+
* @param operationType - Optional operation type
|
|
125
|
+
*/
|
|
126
|
+
export declare function error(module: string, message: string, errorObj?: any, data?: any, operation?: string, operationType?: OperationType): void;
|
|
127
|
+
/**
|
|
128
|
+
* Performance timing utility for tracking operation duration
|
|
129
|
+
*/
|
|
130
|
+
export declare class PerformanceTimer {
|
|
131
|
+
private startTime;
|
|
132
|
+
private module;
|
|
133
|
+
private operation;
|
|
134
|
+
private operationType;
|
|
135
|
+
constructor(module: string, operation: string, operationType?: OperationType);
|
|
136
|
+
/**
|
|
137
|
+
* End timing and log the duration
|
|
138
|
+
*/
|
|
139
|
+
end(message?: string, data?: any): number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Enhanced operation start logging with timing
|
|
143
|
+
*
|
|
144
|
+
* @param module - Name of the module/function
|
|
145
|
+
* @param operation - Name of the operation being performed
|
|
146
|
+
* @param operationType - Type of operation for categorization
|
|
147
|
+
* @param params - Parameters for the operation
|
|
148
|
+
* @returns PerformanceTimer instance for tracking duration
|
|
149
|
+
*/
|
|
150
|
+
export declare function operationStart(module: string, operation: string, operationType?: OperationType, params?: any): PerformanceTimer;
|
|
151
|
+
/**
|
|
152
|
+
* Logs the successful completion of an API operation
|
|
153
|
+
*
|
|
154
|
+
* @param module - Name of the module/function
|
|
155
|
+
* @param operation - Name of the operation being performed
|
|
156
|
+
* @param resultSummary - Summary of the operation result (e.g., count of items)
|
|
157
|
+
* @param operationType - Type of operation for categorization
|
|
158
|
+
* @param duration - Optional duration in milliseconds
|
|
159
|
+
*/
|
|
160
|
+
export declare function operationSuccess(module: string, operation: string, resultSummary?: any, operationType?: OperationType, duration?: number): void;
|
|
161
|
+
/**
|
|
162
|
+
* Logs the failure of an API operation
|
|
163
|
+
*
|
|
164
|
+
* @param module - Name of the module/function
|
|
165
|
+
* @param operation - Name of the operation that failed
|
|
166
|
+
* @param errorObj - The error object
|
|
167
|
+
* @param context - Additional context information
|
|
168
|
+
* @param operationType - Type of operation for categorization
|
|
169
|
+
* @param duration - Optional duration in milliseconds
|
|
170
|
+
*/
|
|
171
|
+
export declare function operationFailure(module: string, operation: string, errorObj: any, context?: any, operationType?: OperationType, duration?: number): void;
|
|
172
|
+
/**
|
|
173
|
+
* Logs the start of a fallback API operation
|
|
174
|
+
*
|
|
175
|
+
* @param module - Name of the module/function
|
|
176
|
+
* @param operation - Name of the fallback operation
|
|
177
|
+
* @param reason - Reason for falling back
|
|
178
|
+
* @param operationType - Type of operation for categorization
|
|
179
|
+
*/
|
|
180
|
+
export declare function fallbackStart(module: string, operation: string, reason: string, operationType?: OperationType): void;
|
|
181
|
+
/**
|
|
182
|
+
* Creates a scoped logger instance with pre-configured context
|
|
183
|
+
*/
|
|
184
|
+
export declare function createScopedLogger(module: string, operation?: string, operationType?: OperationType): {
|
|
185
|
+
debug: (message: string, data?: any) => void;
|
|
186
|
+
info: (message: string, data?: any) => void;
|
|
187
|
+
warn: (message: string, data?: any) => void;
|
|
188
|
+
error: (message: string, errorObj?: any, data?: any) => void;
|
|
189
|
+
operationStart: (op?: string, opType?: OperationType, params?: any) => PerformanceTimer;
|
|
190
|
+
operationSuccess: (op?: string, resultSummary?: any, opType?: OperationType, duration?: number) => void;
|
|
191
|
+
operationFailure: (op?: string, errorObj?: any, context?: any, opType?: OperationType, duration?: number) => void;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Utility for wrapping async operations with automatic logging
|
|
195
|
+
*/
|
|
196
|
+
export declare function withLogging<T>(module: string, operation: string, operationType: OperationType, fn: () => Promise<T>, context?: any): Promise<T>;
|
|
197
|
+
/**
|
|
198
|
+
* Safe logging function that never interferes with MCP protocol
|
|
199
|
+
* Always use this for any direct console logging that might occur during MCP operations
|
|
200
|
+
*
|
|
201
|
+
* @param message - Message to log
|
|
202
|
+
* @param args - Additional arguments to log
|
|
203
|
+
*/
|
|
204
|
+
export declare function safeMcpLog(message: string, ...args: any[]): void;
|
|
205
|
+
declare const _default: {
|
|
206
|
+
debug: typeof debug;
|
|
207
|
+
info: typeof info;
|
|
208
|
+
warn: typeof warn;
|
|
209
|
+
error: typeof error;
|
|
210
|
+
operationStart: typeof operationStart;
|
|
211
|
+
operationSuccess: typeof operationSuccess;
|
|
212
|
+
operationFailure: typeof operationFailure;
|
|
213
|
+
fallbackStart: typeof fallbackStart;
|
|
214
|
+
setLogContext: typeof setLogContext;
|
|
215
|
+
getLogContext: typeof getLogContext;
|
|
216
|
+
clearLogContext: typeof clearLogContext;
|
|
217
|
+
generateCorrelationId: typeof generateCorrelationId;
|
|
218
|
+
createScopedLogger: typeof createScopedLogger;
|
|
219
|
+
withLogging: typeof withLogging;
|
|
220
|
+
safeMcpLog: typeof safeMcpLog;
|
|
221
|
+
PerformanceTimer: typeof PerformanceTimer;
|
|
222
|
+
LogLevel: typeof LogLevel;
|
|
223
|
+
OperationType: typeof OperationType;
|
|
224
|
+
};
|
|
225
|
+
export default _default;
|
|
226
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;CACT;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,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|
|
1
|
+
/**
|
|
2
|
+
* Enhanced structured logging utility for consistent logging across the application
|
|
3
|
+
*/
|
|
4
|
+
import { randomUUID } from 'crypto';
|
|
5
|
+
import { safeJsonStringify } from './json-serializer.js';
|
|
6
|
+
/**
|
|
7
|
+
* Log level enum for controlling verbosity
|
|
8
|
+
*/
|
|
9
|
+
export var LogLevel;
|
|
10
|
+
(function (LogLevel) {
|
|
11
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
12
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
13
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
14
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
15
|
+
LogLevel[LogLevel["NONE"] = 4] = "NONE";
|
|
16
|
+
})(LogLevel || (LogLevel = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Operation types for better log categorization
|
|
19
|
+
*/
|
|
20
|
+
export var OperationType;
|
|
21
|
+
(function (OperationType) {
|
|
22
|
+
OperationType["API_CALL"] = "api_call";
|
|
23
|
+
OperationType["TOOL_EXECUTION"] = "tool_execution";
|
|
24
|
+
OperationType["DATA_PROCESSING"] = "data_processing";
|
|
25
|
+
OperationType["VALIDATION"] = "validation";
|
|
26
|
+
OperationType["TRANSFORMATION"] = "transformation";
|
|
27
|
+
OperationType["SYSTEM"] = "system";
|
|
28
|
+
})(OperationType || (OperationType = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Current log level based on environment
|
|
31
|
+
*/
|
|
32
|
+
export const CURRENT_LOG_LEVEL = process.env.NODE_ENV === 'production'
|
|
33
|
+
? LogLevel.INFO // In production, only log INFO and above
|
|
34
|
+
: LogLevel.DEBUG; // In development, log everything
|
|
35
|
+
/**
|
|
36
|
+
* Global log context storage
|
|
37
|
+
*/
|
|
38
|
+
let globalContext = {};
|
|
39
|
+
/**
|
|
40
|
+
* Set global logging context for correlation tracking
|
|
41
|
+
*/
|
|
42
|
+
export function setLogContext(context) {
|
|
43
|
+
globalContext = { ...globalContext, ...context };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get current logging context
|
|
47
|
+
*/
|
|
48
|
+
export function getLogContext() {
|
|
49
|
+
return { ...globalContext };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Clear logging context
|
|
53
|
+
*/
|
|
54
|
+
export function clearLogContext() {
|
|
55
|
+
globalContext = {};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Generate a new correlation ID
|
|
59
|
+
*/
|
|
60
|
+
export function generateCorrelationId() {
|
|
61
|
+
return randomUUID();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create structured log metadata
|
|
65
|
+
*/
|
|
66
|
+
function createLogMetadata(level, module, operation, operationType, additionalMetadata) {
|
|
67
|
+
return {
|
|
68
|
+
timestamp: new Date().toISOString(),
|
|
69
|
+
level,
|
|
70
|
+
module,
|
|
71
|
+
operation: operation || globalContext.operation,
|
|
72
|
+
operationType: operationType || globalContext.operationType,
|
|
73
|
+
correlationId: globalContext.correlationId,
|
|
74
|
+
sessionId: globalContext.sessionId,
|
|
75
|
+
requestId: globalContext.requestId,
|
|
76
|
+
userId: globalContext.userId,
|
|
77
|
+
...additionalMetadata,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Format and output structured log entry
|
|
82
|
+
*/
|
|
83
|
+
function outputLog(entry, logFunction) {
|
|
84
|
+
if (process.env.LOG_FORMAT === 'json') {
|
|
85
|
+
// Output compact JSON using safe stringify to prevent errors
|
|
86
|
+
logFunction(safeJsonStringify(entry, { indent: 0 }));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Output pretty-printed JSON to maintain human readability for console,
|
|
90
|
+
// while ensuring it's a single, valid JSON string to prevent MCP parsing errors.
|
|
91
|
+
logFunction(safeJsonStringify(entry, { indent: 2 }));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Log a debug message (only in development)
|
|
96
|
+
*
|
|
97
|
+
* @param module - Name of the module/function logging the message
|
|
98
|
+
* @param message - Message to log
|
|
99
|
+
* @param data - Optional data to include with the log
|
|
100
|
+
* @param operation - Optional operation name
|
|
101
|
+
* @param operationType - Optional operation type
|
|
102
|
+
*/
|
|
103
|
+
export function debug(module, message, data, operation, operationType) {
|
|
104
|
+
if (CURRENT_LOG_LEVEL <= LogLevel.DEBUG) {
|
|
105
|
+
const entry = {
|
|
106
|
+
message,
|
|
107
|
+
metadata: createLogMetadata('DEBUG', module, operation, operationType),
|
|
108
|
+
...(data && { data }),
|
|
109
|
+
};
|
|
110
|
+
outputLog(entry, console.error); // Use stderr instead of stdout to avoid interfering with MCP protocol
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Log an info message
|
|
115
|
+
*
|
|
116
|
+
* @param module - Name of the module/function logging the message
|
|
117
|
+
* @param message - Message to log
|
|
118
|
+
* @param data - Optional data to include with the log
|
|
119
|
+
* @param operation - Optional operation name
|
|
120
|
+
* @param operationType - Optional operation type
|
|
121
|
+
*/
|
|
122
|
+
export function info(module, message, data, operation, operationType) {
|
|
123
|
+
if (CURRENT_LOG_LEVEL <= LogLevel.INFO) {
|
|
124
|
+
const entry = {
|
|
125
|
+
message,
|
|
126
|
+
metadata: createLogMetadata('INFO', module, operation, operationType),
|
|
127
|
+
...(data && { data }),
|
|
128
|
+
};
|
|
129
|
+
outputLog(entry, console.error); // Use stderr instead of stdout to avoid interfering with MCP protocol
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Log a warning message
|
|
134
|
+
*
|
|
135
|
+
* @param module - Name of the module/function logging the message
|
|
136
|
+
* @param message - Message to log
|
|
137
|
+
* @param data - Optional data to include with the log
|
|
138
|
+
* @param operation - Optional operation name
|
|
139
|
+
* @param operationType - Optional operation type
|
|
140
|
+
*/
|
|
141
|
+
export function warn(module, message, data, operation, operationType) {
|
|
142
|
+
if (CURRENT_LOG_LEVEL <= LogLevel.WARN) {
|
|
143
|
+
const entry = {
|
|
144
|
+
message,
|
|
145
|
+
metadata: createLogMetadata('WARN', module, operation, operationType),
|
|
146
|
+
...(data && { data }),
|
|
147
|
+
};
|
|
148
|
+
outputLog(entry, console.warn);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Log an error message
|
|
153
|
+
*
|
|
154
|
+
* @param module - Name of the module/function logging the message
|
|
155
|
+
* @param message - Message to log
|
|
156
|
+
* @param errorObj - Optional error object
|
|
157
|
+
* @param data - Optional additional data
|
|
158
|
+
* @param operation - Optional operation name
|
|
159
|
+
* @param operationType - Optional operation type
|
|
160
|
+
*/
|
|
161
|
+
export function error(module, message, errorObj, data, operation, operationType) {
|
|
162
|
+
if (CURRENT_LOG_LEVEL <= LogLevel.ERROR) {
|
|
163
|
+
const entry = {
|
|
164
|
+
message,
|
|
165
|
+
metadata: createLogMetadata('ERROR', module, operation, operationType),
|
|
166
|
+
...(data && { data }),
|
|
167
|
+
...(errorObj && {
|
|
168
|
+
error: errorObj instanceof Error
|
|
169
|
+
? {
|
|
170
|
+
message: errorObj.message,
|
|
171
|
+
name: errorObj.name,
|
|
172
|
+
stack: errorObj.stack,
|
|
173
|
+
code: errorObj.code,
|
|
174
|
+
}
|
|
175
|
+
: { message: String(errorObj), name: 'Unknown' },
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
outputLog(entry, console.error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Performance timing utility for tracking operation duration
|
|
183
|
+
*/
|
|
184
|
+
export class PerformanceTimer {
|
|
185
|
+
startTime;
|
|
186
|
+
module;
|
|
187
|
+
operation;
|
|
188
|
+
operationType;
|
|
189
|
+
constructor(module, operation, operationType = OperationType.SYSTEM) {
|
|
190
|
+
this.module = module;
|
|
191
|
+
this.operation = operation;
|
|
192
|
+
this.operationType = operationType;
|
|
193
|
+
this.startTime = Date.now();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* End timing and log the duration
|
|
197
|
+
*/
|
|
198
|
+
end(message, data) {
|
|
199
|
+
const duration = Date.now() - this.startTime;
|
|
200
|
+
debug(this.module, message || `Operation completed: ${this.operation}`, { ...data, duration: `${duration}ms` }, this.operation, this.operationType);
|
|
201
|
+
return duration;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Enhanced operation start logging with timing
|
|
206
|
+
*
|
|
207
|
+
* @param module - Name of the module/function
|
|
208
|
+
* @param operation - Name of the operation being performed
|
|
209
|
+
* @param operationType - Type of operation for categorization
|
|
210
|
+
* @param params - Parameters for the operation
|
|
211
|
+
* @returns PerformanceTimer instance for tracking duration
|
|
212
|
+
*/
|
|
213
|
+
export function operationStart(module, operation, operationType = OperationType.SYSTEM, params) {
|
|
214
|
+
debug(module, `Starting operation: ${operation}`, params, operation, operationType);
|
|
215
|
+
return new PerformanceTimer(module, operation, operationType);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Logs the successful completion of an API operation
|
|
219
|
+
*
|
|
220
|
+
* @param module - Name of the module/function
|
|
221
|
+
* @param operation - Name of the operation being performed
|
|
222
|
+
* @param resultSummary - Summary of the operation result (e.g., count of items)
|
|
223
|
+
* @param operationType - Type of operation for categorization
|
|
224
|
+
* @param duration - Optional duration in milliseconds
|
|
225
|
+
*/
|
|
226
|
+
export function operationSuccess(module, operation, resultSummary, operationType = OperationType.SYSTEM, duration) {
|
|
227
|
+
const logData = {
|
|
228
|
+
...resultSummary,
|
|
229
|
+
...(duration && { duration: `${duration}ms` }),
|
|
230
|
+
};
|
|
231
|
+
info(module, `Operation successful: ${operation}`, logData, operation, operationType);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Logs the failure of an API operation
|
|
235
|
+
*
|
|
236
|
+
* @param module - Name of the module/function
|
|
237
|
+
* @param operation - Name of the operation that failed
|
|
238
|
+
* @param errorObj - The error object
|
|
239
|
+
* @param context - Additional context information
|
|
240
|
+
* @param operationType - Type of operation for categorization
|
|
241
|
+
* @param duration - Optional duration in milliseconds
|
|
242
|
+
*/
|
|
243
|
+
export function operationFailure(module, operation, errorObj, context, operationType = OperationType.SYSTEM, duration) {
|
|
244
|
+
const logData = {
|
|
245
|
+
...context,
|
|
246
|
+
...(duration && { duration: `${duration}ms` }),
|
|
247
|
+
};
|
|
248
|
+
error(module, `Operation failed: ${operation}`, errorObj, logData, operation, operationType);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Logs the start of a fallback API operation
|
|
252
|
+
*
|
|
253
|
+
* @param module - Name of the module/function
|
|
254
|
+
* @param operation - Name of the fallback operation
|
|
255
|
+
* @param reason - Reason for falling back
|
|
256
|
+
* @param operationType - Type of operation for categorization
|
|
257
|
+
*/
|
|
258
|
+
export function fallbackStart(module, operation, reason, operationType = OperationType.API_CALL) {
|
|
259
|
+
warn(module, `Trying fallback: ${operation}. Reason: ${reason}`, { reason }, operation, operationType);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Creates a scoped logger instance with pre-configured context
|
|
263
|
+
*/
|
|
264
|
+
export function createScopedLogger(module, operation, operationType) {
|
|
265
|
+
return {
|
|
266
|
+
debug: (message, data) => debug(module, message, data, operation, operationType),
|
|
267
|
+
info: (message, data) => info(module, message, data, operation, operationType),
|
|
268
|
+
warn: (message, data) => warn(module, message, data, operation, operationType),
|
|
269
|
+
error: (message, errorObj, data) => error(module, message, errorObj, data, operation, operationType),
|
|
270
|
+
operationStart: (op, opType, params) => operationStart(module, op || operation || 'unknown', opType || operationType || OperationType.SYSTEM, params),
|
|
271
|
+
operationSuccess: (op, resultSummary, opType, duration) => operationSuccess(module, op || operation || 'unknown', resultSummary, opType || operationType || OperationType.SYSTEM, duration),
|
|
272
|
+
operationFailure: (op, errorObj, context, opType, duration) => operationFailure(module, op || operation || 'unknown', errorObj, context, opType || operationType || OperationType.SYSTEM, duration),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Utility for wrapping async operations with automatic logging
|
|
277
|
+
*/
|
|
278
|
+
export async function withLogging(module, operation, operationType, fn, context) {
|
|
279
|
+
const timer = operationStart(module, operation, operationType, context);
|
|
280
|
+
try {
|
|
281
|
+
const result = await fn();
|
|
282
|
+
const duration = timer.end();
|
|
283
|
+
operationSuccess(module, operation, { success: true }, operationType, duration);
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
const duration = timer.end();
|
|
288
|
+
operationFailure(module, operation, error, context, operationType, duration);
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Safe logging function that never interferes with MCP protocol
|
|
294
|
+
* Always use this for any direct console logging that might occur during MCP operations
|
|
295
|
+
*
|
|
296
|
+
* @param message - Message to log
|
|
297
|
+
* @param args - Additional arguments to log
|
|
298
|
+
*/
|
|
299
|
+
export function safeMcpLog(message, ...args) {
|
|
300
|
+
// Always use console.error to avoid interfering with MCP protocol
|
|
301
|
+
console.error(`[MCP_SAFE_LOG] ${message}`, ...args);
|
|
302
|
+
}
|
|
303
|
+
export default {
|
|
304
|
+
debug,
|
|
305
|
+
info,
|
|
306
|
+
warn,
|
|
307
|
+
error,
|
|
308
|
+
operationStart,
|
|
309
|
+
operationSuccess,
|
|
310
|
+
operationFailure,
|
|
311
|
+
fallbackStart,
|
|
312
|
+
setLogContext,
|
|
313
|
+
getLogContext,
|
|
314
|
+
clearLogContext,
|
|
315
|
+
generateCorrelationId,
|
|
316
|
+
createScopedLogger,
|
|
317
|
+
withLogging,
|
|
318
|
+
safeMcpLog,
|
|
319
|
+
PerformanceTimer,
|
|
320
|
+
LogLevel,
|
|
321
|
+
OperationType,
|
|
322
|
+
};
|
|
323
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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BAAgB;IAChB,QAAQ;IACR,aAAa;CACd,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ListEntryFilters } from '../api/operations/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for numeric range
|
|
4
|
+
*/
|
|
5
|
+
export interface NumericRange {
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
equals?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validates a numeric range specification
|
|
12
|
+
*
|
|
13
|
+
* @param range - The numeric range to validate
|
|
14
|
+
* @returns True if valid, throws an error if invalid
|
|
15
|
+
* @throws Error when range is invalid
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateNumericRange(range: NumericRange): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a numeric range filter for a specific attribute
|
|
20
|
+
*
|
|
21
|
+
* @param attributeSlug - The attribute slug to filter on (e.g., 'revenue', 'employee_count')
|
|
22
|
+
* @param range - Numeric range specification
|
|
23
|
+
* @returns Configured filter object
|
|
24
|
+
* @throws Error when range is invalid
|
|
25
|
+
*/
|
|
26
|
+
export declare function createNumericRangeFilter(attributeSlug: string, range: NumericRange): ListEntryFilters;
|
|
27
|
+
//# sourceMappingURL=numeric-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-utils.d.ts","sourceRoot":"","sources":["../../src/utils/numeric-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CA+BjE;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,YAAY,GAClB,gBAAgB,CA4ClB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeric utility functions for working with Attio numeric filters
|
|
3
|
+
* Provides functions for handling numeric ranges and comparison operations.
|
|
4
|
+
*/
|
|
5
|
+
import { FilterConditionType } from '../types/attio.js';
|
|
6
|
+
/**
|
|
7
|
+
* Validates a numeric range specification
|
|
8
|
+
*
|
|
9
|
+
* @param range - The numeric range to validate
|
|
10
|
+
* @returns True if valid, throws an error if invalid
|
|
11
|
+
* @throws Error when range is invalid
|
|
12
|
+
*/
|
|
13
|
+
export function validateNumericRange(range) {
|
|
14
|
+
// Check if we have an equals value (exact match)
|
|
15
|
+
if (range.equals !== undefined) {
|
|
16
|
+
// If equals is specified, min and max should not be
|
|
17
|
+
if (range.min !== undefined || range.max !== undefined) {
|
|
18
|
+
throw new Error('Cannot specify both equals and min/max in a numeric range');
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
// Check if we have min or max
|
|
23
|
+
if (range.min === undefined && range.max === undefined) {
|
|
24
|
+
throw new Error('Numeric range must specify at least one of: min, max, or equals');
|
|
25
|
+
}
|
|
26
|
+
// If both min and max are specified, ensure min <= max
|
|
27
|
+
if (range.min !== undefined &&
|
|
28
|
+
range.max !== undefined &&
|
|
29
|
+
range.min > range.max) {
|
|
30
|
+
throw new Error(`Invalid numeric range: min (${range.min}) cannot be greater than max (${range.max})`);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a numeric range filter for a specific attribute
|
|
36
|
+
*
|
|
37
|
+
* @param attributeSlug - The attribute slug to filter on (e.g., 'revenue', 'employee_count')
|
|
38
|
+
* @param range - Numeric range specification
|
|
39
|
+
* @returns Configured filter object
|
|
40
|
+
* @throws Error when range is invalid
|
|
41
|
+
*/
|
|
42
|
+
export function createNumericRangeFilter(attributeSlug, range) {
|
|
43
|
+
try {
|
|
44
|
+
// Validate the numeric range
|
|
45
|
+
validateNumericRange(range);
|
|
46
|
+
const filters = [];
|
|
47
|
+
// Handle exact match case
|
|
48
|
+
if (range.equals !== undefined) {
|
|
49
|
+
filters.push({
|
|
50
|
+
attribute: { slug: attributeSlug },
|
|
51
|
+
condition: FilterConditionType.EQUALS,
|
|
52
|
+
value: range.equals,
|
|
53
|
+
});
|
|
54
|
+
return { filters, matchAny: false };
|
|
55
|
+
}
|
|
56
|
+
// Handle min value (greater than or equal)
|
|
57
|
+
if (range.min !== undefined) {
|
|
58
|
+
filters.push({
|
|
59
|
+
attribute: { slug: attributeSlug },
|
|
60
|
+
condition: FilterConditionType.GREATER_THAN_OR_EQUALS,
|
|
61
|
+
value: range.min,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Handle max value (less than or equal)
|
|
65
|
+
if (range.max !== undefined) {
|
|
66
|
+
filters.push({
|
|
67
|
+
attribute: { slug: attributeSlug },
|
|
68
|
+
condition: FilterConditionType.LESS_THAN_OR_EQUALS,
|
|
69
|
+
value: range.max,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
filters,
|
|
74
|
+
// When both min and max are specified, we want records that match both (AND logic)
|
|
75
|
+
matchAny: false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
80
|
+
throw new Error(`Failed to create numeric filter: ${errorMessage}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=numeric-utils.js.map
|