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,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* General filter utility functions
|
|
3
|
+
* Consolidates utilities from filter-utils.ts and filter-utils-additions.ts
|
|
4
|
+
*/
|
|
5
|
+
import { ATTRIBUTES, FilterConditionType, } from './types.js';
|
|
6
|
+
import { resolveDateRange } from '../date-utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a filter for records based on their creation date
|
|
9
|
+
*
|
|
10
|
+
* @param dateRange - Date range specification
|
|
11
|
+
* @returns Configured filter object
|
|
12
|
+
*/
|
|
13
|
+
export function createCreatedDateFilter(dateRange) {
|
|
14
|
+
return createDateRangeFilter(ATTRIBUTES.CREATED_AT, dateRange);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a filter for records based on their last modification date
|
|
18
|
+
*
|
|
19
|
+
* @param dateRange - Date range specification
|
|
20
|
+
* @returns Configured filter object
|
|
21
|
+
*/
|
|
22
|
+
export function createModifiedDateFilter(dateRange) {
|
|
23
|
+
return createDateRangeFilter(ATTRIBUTES.UPDATED_AT, dateRange);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a filter for B2B Segment (type_persona)
|
|
27
|
+
*
|
|
28
|
+
* @param value - B2B Segment value to filter by
|
|
29
|
+
* @returns Configured filter object
|
|
30
|
+
*/
|
|
31
|
+
export function createB2BSegmentFilter(value) {
|
|
32
|
+
// Using a simple equals filter that will be transformed using the shorthand format
|
|
33
|
+
return {
|
|
34
|
+
filters: [
|
|
35
|
+
{
|
|
36
|
+
attribute: { slug: 'type_persona' },
|
|
37
|
+
condition: FilterConditionType.EQUALS, // This won't be used for type_persona due to shorthand format
|
|
38
|
+
value,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
matchAny: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validates if a value falls within a numeric range
|
|
46
|
+
*
|
|
47
|
+
* @param value - The value to check
|
|
48
|
+
* @param range - The numeric range to validate against
|
|
49
|
+
* @returns True if value is within range
|
|
50
|
+
*/
|
|
51
|
+
export function isInNumericRange(value, range) {
|
|
52
|
+
if (range.equals !== undefined) {
|
|
53
|
+
return value === range.equals;
|
|
54
|
+
}
|
|
55
|
+
if (range.min !== undefined && value < range.min) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (range.max !== undefined && value > range.max) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Checks if a date string falls within a date range
|
|
65
|
+
*
|
|
66
|
+
* @param dateStr - ISO date string to check
|
|
67
|
+
* @param range - Date range to validate against
|
|
68
|
+
* @returns True if date is within range
|
|
69
|
+
*/
|
|
70
|
+
export function isInDateRange(dateStr, range) {
|
|
71
|
+
const date = new Date(dateStr);
|
|
72
|
+
const resolvedRange = resolveDateRange(range);
|
|
73
|
+
if (resolvedRange.start) {
|
|
74
|
+
const startDate = new Date(resolvedRange.start);
|
|
75
|
+
if (date < startDate)
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (resolvedRange.end) {
|
|
79
|
+
const endDate = new Date(resolvedRange.end);
|
|
80
|
+
if (date > endDate)
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Debug logging for filter operations
|
|
87
|
+
*
|
|
88
|
+
* @param operation - The operation being performed
|
|
89
|
+
* @param details - Additional details to log
|
|
90
|
+
*/
|
|
91
|
+
export function debugFilterLog(operation, details) {
|
|
92
|
+
if (process.env.NODE_ENV === 'development') {
|
|
93
|
+
console.log(`[Filter ${operation}]`, details);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Determines if a filter attribute represents a date field
|
|
98
|
+
*
|
|
99
|
+
* @param attributeSlug - The attribute slug to check
|
|
100
|
+
* @returns True if the attribute is a date field
|
|
101
|
+
*/
|
|
102
|
+
export function isDateAttribute(attributeSlug) {
|
|
103
|
+
const dateAttributes = [
|
|
104
|
+
ATTRIBUTES.CREATED_AT,
|
|
105
|
+
ATTRIBUTES.UPDATED_AT,
|
|
106
|
+
ATTRIBUTES.LAST_INTERACTION,
|
|
107
|
+
];
|
|
108
|
+
return dateAttributes.includes(attributeSlug);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Determines if a filter attribute represents a numeric field
|
|
112
|
+
*
|
|
113
|
+
* @param attributeSlug - The attribute slug to check
|
|
114
|
+
* @returns True if the attribute is a numeric field
|
|
115
|
+
*/
|
|
116
|
+
export function isNumericAttribute(attributeSlug) {
|
|
117
|
+
const numericAttributes = [ATTRIBUTES.REVENUE, ATTRIBUTES.EMPLOYEE_COUNT];
|
|
118
|
+
return numericAttributes.includes(attributeSlug);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Determines if a filter attribute represents a text field
|
|
122
|
+
*
|
|
123
|
+
* @param attributeSlug - The attribute slug to check
|
|
124
|
+
* @returns True if the attribute is a text field
|
|
125
|
+
*/
|
|
126
|
+
export function isTextAttribute(attributeSlug) {
|
|
127
|
+
const textAttributes = [
|
|
128
|
+
ATTRIBUTES.NAME,
|
|
129
|
+
ATTRIBUTES.EMAIL,
|
|
130
|
+
ATTRIBUTES.WEBSITE,
|
|
131
|
+
ATTRIBUTES.NOTE_CONTENT,
|
|
132
|
+
ATTRIBUTES.INDUSTRY,
|
|
133
|
+
];
|
|
134
|
+
return textAttributes.includes(attributeSlug);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Helper function to extract attribute mappings as needed
|
|
138
|
+
* Re-exports builder functions as utilities for backward compatibility
|
|
139
|
+
*/
|
|
140
|
+
import { createDateRangeFilter, createEqualsFilter, createContainsFilter, } from './builders.js';
|
|
141
|
+
export { createDateRangeFilter, createEqualsFilter, createContainsFilter };
|
|
142
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/filters/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,UAAU,EACV,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAoB;IAC1D,OAAO,qBAAqB,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAoB;IAC3D,OAAO,qBAAqB,C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BAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module validation-utils
|
|
3
|
+
*
|
|
4
|
+
* Centralized validation utilities for filter structures
|
|
5
|
+
* Provides consistent error message formatting and reusable validation functions
|
|
6
|
+
*/
|
|
7
|
+
import { ListEntryFilter, ListEntryFilters } from './types.js';
|
|
8
|
+
import { ValidatedListEntryFilters } from '../../api/operations/types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Error message templates for consistent error formatting
|
|
11
|
+
*/
|
|
12
|
+
export declare const ERROR_MESSAGES: {
|
|
13
|
+
MISSING_FILTERS: string;
|
|
14
|
+
FILTERS_NOT_ARRAY: (type: string) => string;
|
|
15
|
+
MISSING_FILTERS_PROPERTY: string;
|
|
16
|
+
EMPTY_FILTERS_ARRAY: string;
|
|
17
|
+
INVALID_FILTER_STRUCTURE: (index: number, reason: string) => string;
|
|
18
|
+
MISSING_ATTRIBUTE: string;
|
|
19
|
+
MISSING_ATTRIBUTE_SLUG: string;
|
|
20
|
+
MISSING_CONDITION: string;
|
|
21
|
+
INVALID_CONDITION: (condition: string, validConditions: string[]) => string;
|
|
22
|
+
ALL_FILTERS_INVALID: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Standard example format for filter structures to include in error messages
|
|
26
|
+
*/
|
|
27
|
+
export declare const FILTER_EXAMPLES: {
|
|
28
|
+
SIMPLE: string;
|
|
29
|
+
OR_LOGIC: string;
|
|
30
|
+
MULTIPLE_CONDITIONS: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Validates the basic filter structure ensuring filters object has required properties
|
|
34
|
+
*
|
|
35
|
+
* This function performs structural validation to ensure:
|
|
36
|
+
* - The filters parameter is not null/undefined
|
|
37
|
+
* - The filters object has a 'filters' property
|
|
38
|
+
* - The 'filters' property is an array
|
|
39
|
+
*
|
|
40
|
+
* @param filters - The filters object to validate (may be undefined/null from user input)
|
|
41
|
+
* @returns Validated filters object with guaranteed filters array
|
|
42
|
+
* @throws FilterValidationError with consistent error messages and appropriate categories
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const validated = validateFiltersObject({
|
|
47
|
+
* filters: [{ attribute: { slug: 'name' }, condition: 'equals', value: 'test' }]
|
|
48
|
+
* });
|
|
49
|
+
* // validated.filters is guaranteed to be an array
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateFiltersObject(filters: ListEntryFilters | undefined): ValidatedListEntryFilters;
|
|
53
|
+
/**
|
|
54
|
+
* Validates each individual filter in a filters array
|
|
55
|
+
* Returns list of invalid filters with reasons
|
|
56
|
+
*
|
|
57
|
+
* @param filters - Array of filter objects to validate
|
|
58
|
+
* @param validateConditions - Whether to validate condition values
|
|
59
|
+
* @returns Array of objects containing invalid filter index, reason and filter object
|
|
60
|
+
*/
|
|
61
|
+
export declare function collectInvalidFilters(filters: ListEntryFilter[], validateConditions?: boolean): {
|
|
62
|
+
index: number;
|
|
63
|
+
reason: string;
|
|
64
|
+
filter: any;
|
|
65
|
+
}[];
|
|
66
|
+
/**
|
|
67
|
+
* Creates a consistently formatted error message for invalid filters
|
|
68
|
+
*
|
|
69
|
+
* @param invalidFilters - Array of invalid filter objects with reasons
|
|
70
|
+
* @returns Formatted error message with details
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatInvalidFiltersError(invalidFilters: {
|
|
73
|
+
index: number;
|
|
74
|
+
reason: string;
|
|
75
|
+
filter: any;
|
|
76
|
+
}[]): string;
|
|
77
|
+
/**
|
|
78
|
+
* Full validation of filters with detailed error messages and examples
|
|
79
|
+
*
|
|
80
|
+
* This is the primary entry point for filter validation. It performs:
|
|
81
|
+
* 1. Structural validation using validateFiltersObject()
|
|
82
|
+
* 2. Individual filter validation for each filter in the array
|
|
83
|
+
* 3. Condition validation if enabled
|
|
84
|
+
* 4. Comprehensive error reporting with examples
|
|
85
|
+
*
|
|
86
|
+
* @param filters - Filter object to validate (may have optional filters array)
|
|
87
|
+
* @param validateConditions - Whether to validate condition values against known operators
|
|
88
|
+
* @returns Validated filters with guaranteed filters array and valid structure
|
|
89
|
+
* @throws FilterValidationError with detailed messages, examples, and appropriate categories
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* // Valid usage
|
|
94
|
+
* const validated = validateFilters({
|
|
95
|
+
* filters: [
|
|
96
|
+
* { attribute: { slug: 'name' }, condition: 'equals', value: 'John' },
|
|
97
|
+
* { attribute: { slug: 'age' }, condition: 'greater_than', value: 18 }
|
|
98
|
+
* ],
|
|
99
|
+
* matchAny: false
|
|
100
|
+
* }, true);
|
|
101
|
+
*
|
|
102
|
+
* // validated.filters is guaranteed to exist and be valid
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @see validateFiltersObject For structural validation
|
|
106
|
+
* @see collectInvalidFilters For individual filter validation logic
|
|
107
|
+
*/
|
|
108
|
+
export declare function validateFilters(filters: ListEntryFilters | undefined, validateConditions?: boolean): ValidatedListEntryFilters;
|
|
109
|
+
/**
|
|
110
|
+
* Helper function to get a descriptive reason for an invalid filter
|
|
111
|
+
*
|
|
112
|
+
* @param filter - The filter to analyze
|
|
113
|
+
* @returns A string describing what's wrong with the filter
|
|
114
|
+
*/
|
|
115
|
+
export declare function getInvalidFilterReason(filter: any): string;
|
|
116
|
+
/**
|
|
117
|
+
* Generate examples for different filter scenarios
|
|
118
|
+
*
|
|
119
|
+
* @param filterType - The type of filter example to generate (simple, or, multiple)
|
|
120
|
+
* @returns A string with the example in JSON format
|
|
121
|
+
*/
|
|
122
|
+
export declare function getFilterExample(filterType?: 'simple' | 'or' | 'multiple'): string;
|
|
123
|
+
//# sourceMappingURL=validation-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/filters/validation-utils.ts"],"names":[],"mappings":"AAAA;;;;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
|
3
|
+
*
|
|
4
|
+
* Centralized validation utilities for filter structures
|
|
5
|
+
* Provides consistent error message formatting and reusable validation functions
|
|
6
|
+
*/
|
|
7
|
+
import { FilterValidationError, FilterErrorCategory, } from '../../errors/api-errors.js';
|
|
8
|
+
import { isValidFilterCondition } from '../../types/attio.js';
|
|
9
|
+
/**
|
|
10
|
+
* Error message templates for consistent error formatting
|
|
11
|
+
*/
|
|
12
|
+
export const ERROR_MESSAGES = {
|
|
13
|
+
MISSING_FILTERS: 'Filter object is required but was undefined or null',
|
|
14
|
+
FILTERS_NOT_ARRAY: (type) => `Invalid filter structure: 'filters' property must be an array but got ${type}`,
|
|
15
|
+
MISSING_FILTERS_PROPERTY: 'Filters must include a "filters" array property',
|
|
16
|
+
EMPTY_FILTERS_ARRAY: 'No filters provided in the filters array',
|
|
17
|
+
INVALID_FILTER_STRUCTURE: (index, reason) => `Invalid filter structure at index ${index}: ${reason}`,
|
|
18
|
+
MISSING_ATTRIBUTE: 'missing attribute object',
|
|
19
|
+
MISSING_ATTRIBUTE_SLUG: 'missing attribute.slug property',
|
|
20
|
+
MISSING_CONDITION: 'missing condition property',
|
|
21
|
+
INVALID_CONDITION: (condition, validConditions) => `Invalid filter condition '${condition}'. Valid conditions are: ${validConditions.join(', ')}`,
|
|
22
|
+
ALL_FILTERS_INVALID: 'All filters are invalid. Please provide at least one valid filter.',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Standard example format for filter structures to include in error messages
|
|
26
|
+
*/
|
|
27
|
+
export const FILTER_EXAMPLES = {
|
|
28
|
+
SIMPLE: `{
|
|
29
|
+
"filters": [
|
|
30
|
+
{
|
|
31
|
+
"attribute": { "slug": "name" },
|
|
32
|
+
"condition": "contains",
|
|
33
|
+
"value": "Company Inc"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}`,
|
|
37
|
+
OR_LOGIC: `{
|
|
38
|
+
"filters": [
|
|
39
|
+
{
|
|
40
|
+
"attribute": { "slug": "name" },
|
|
41
|
+
"condition": "contains",
|
|
42
|
+
"value": "Inc"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"attribute": { "slug": "industry" },
|
|
46
|
+
"condition": "equals",
|
|
47
|
+
"value": "Technology"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"matchAny": true
|
|
51
|
+
}`,
|
|
52
|
+
MULTIPLE_CONDITIONS: `{
|
|
53
|
+
"filters": [
|
|
54
|
+
{
|
|
55
|
+
"attribute": { "slug": "name" },
|
|
56
|
+
"condition": "contains",
|
|
57
|
+
"value": "Inc"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"attribute": { "slug": "website" },
|
|
61
|
+
"condition": "contains",
|
|
62
|
+
"value": ".com"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}`,
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Validates the basic filter structure ensuring filters object has required properties
|
|
69
|
+
*
|
|
70
|
+
* This function performs structural validation to ensure:
|
|
71
|
+
* - The filters parameter is not null/undefined
|
|
72
|
+
* - The filters object has a 'filters' property
|
|
73
|
+
* - The 'filters' property is an array
|
|
74
|
+
*
|
|
75
|
+
* @param filters - The filters object to validate (may be undefined/null from user input)
|
|
76
|
+
* @returns Validated filters object with guaranteed filters array
|
|
77
|
+
* @throws FilterValidationError with consistent error messages and appropriate categories
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const validated = validateFiltersObject({
|
|
82
|
+
* filters: [{ attribute: { slug: 'name' }, condition: 'equals', value: 'test' }]
|
|
83
|
+
* });
|
|
84
|
+
* // validated.filters is guaranteed to be an array
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function validateFiltersObject(filters) {
|
|
88
|
+
// Check if filters is undefined or null
|
|
89
|
+
if (!filters) {
|
|
90
|
+
throw new FilterValidationError(ERROR_MESSAGES.MISSING_FILTERS, FilterErrorCategory.STRUCTURE);
|
|
91
|
+
}
|
|
92
|
+
// Check if filters has a filters property
|
|
93
|
+
if (!('filters' in filters)) {
|
|
94
|
+
throw new FilterValidationError(ERROR_MESSAGES.MISSING_FILTERS_PROPERTY, FilterErrorCategory.STRUCTURE);
|
|
95
|
+
}
|
|
96
|
+
// Check if filters.filters is an array
|
|
97
|
+
if (!Array.isArray(filters.filters)) {
|
|
98
|
+
throw new FilterValidationError(ERROR_MESSAGES.FILTERS_NOT_ARRAY(typeof filters.filters), FilterErrorCategory.STRUCTURE);
|
|
99
|
+
}
|
|
100
|
+
// Return the validated filters with the correct type
|
|
101
|
+
return filters;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Validates each individual filter in a filters array
|
|
105
|
+
* Returns list of invalid filters with reasons
|
|
106
|
+
*
|
|
107
|
+
* @param filters - Array of filter objects to validate
|
|
108
|
+
* @param validateConditions - Whether to validate condition values
|
|
109
|
+
* @returns Array of objects containing invalid filter index, reason and filter object
|
|
110
|
+
*/
|
|
111
|
+
export function collectInvalidFilters(filters, validateConditions = true) {
|
|
112
|
+
const invalidFilters = [];
|
|
113
|
+
// Check each filter in the array
|
|
114
|
+
filters.forEach((filter, index) => {
|
|
115
|
+
// Check if filter is a valid object
|
|
116
|
+
if (!filter || typeof filter !== 'object') {
|
|
117
|
+
invalidFilters.push({
|
|
118
|
+
index,
|
|
119
|
+
reason: `Filter at index ${index} is ${filter === null ? 'null' : typeof filter}`,
|
|
120
|
+
filter,
|
|
121
|
+
});
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// Check for required properties
|
|
125
|
+
if (!filter.attribute) {
|
|
126
|
+
invalidFilters.push({
|
|
127
|
+
index,
|
|
128
|
+
reason: ERROR_MESSAGES.MISSING_ATTRIBUTE,
|
|
129
|
+
filter,
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!filter.attribute.slug) {
|
|
134
|
+
invalidFilters.push({
|
|
135
|
+
index,
|
|
136
|
+
reason: ERROR_MESSAGES.MISSING_ATTRIBUTE_SLUG,
|
|
137
|
+
filter,
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!filter.condition) {
|
|
142
|
+
invalidFilters.push({
|
|
143
|
+
index,
|
|
144
|
+
reason: ERROR_MESSAGES.MISSING_CONDITION,
|
|
145
|
+
filter,
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Validate condition if enabled
|
|
150
|
+
if (validateConditions && !isValidFilterCondition(filter.condition)) {
|
|
151
|
+
invalidFilters.push({
|
|
152
|
+
index,
|
|
153
|
+
reason: `Invalid condition '${filter.condition}'`,
|
|
154
|
+
filter,
|
|
155
|
+
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return invalidFilters;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Creates a consistently formatted error message for invalid filters
|
|
163
|
+
*
|
|
164
|
+
* @param invalidFilters - Array of invalid filter objects with reasons
|
|
165
|
+
* @returns Formatted error message with details
|
|
166
|
+
*/
|
|
167
|
+
export function formatInvalidFiltersError(invalidFilters) {
|
|
168
|
+
if (invalidFilters.length === 0) {
|
|
169
|
+
return '';
|
|
170
|
+
}
|
|
171
|
+
const errorDetails = invalidFilters
|
|
172
|
+
.map((f) => `Filter [${f.index}]: ${f.reason}`)
|
|
173
|
+
.join('; ');
|
|
174
|
+
return errorDetails;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Full validation of filters with detailed error messages and examples
|
|
178
|
+
*
|
|
179
|
+
* This is the primary entry point for filter validation. It performs:
|
|
180
|
+
* 1. Structural validation using validateFiltersObject()
|
|
181
|
+
* 2. Individual filter validation for each filter in the array
|
|
182
|
+
* 3. Condition validation if enabled
|
|
183
|
+
* 4. Comprehensive error reporting with examples
|
|
184
|
+
*
|
|
185
|
+
* @param filters - Filter object to validate (may have optional filters array)
|
|
186
|
+
* @param validateConditions - Whether to validate condition values against known operators
|
|
187
|
+
* @returns Validated filters with guaranteed filters array and valid structure
|
|
188
|
+
* @throws FilterValidationError with detailed messages, examples, and appropriate categories
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* // Valid usage
|
|
193
|
+
* const validated = validateFilters({
|
|
194
|
+
* filters: [
|
|
195
|
+
* { attribute: { slug: 'name' }, condition: 'equals', value: 'John' },
|
|
196
|
+
* { attribute: { slug: 'age' }, condition: 'greater_than', value: 18 }
|
|
197
|
+
* ],
|
|
198
|
+
* matchAny: false
|
|
199
|
+
* }, true);
|
|
200
|
+
*
|
|
201
|
+
* // validated.filters is guaranteed to exist and be valid
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @see validateFiltersObject For structural validation
|
|
205
|
+
* @see collectInvalidFilters For individual filter validation logic
|
|
206
|
+
*/
|
|
207
|
+
export function validateFilters(filters, validateConditions = true) {
|
|
208
|
+
// First validate basic structure
|
|
209
|
+
const validatedFilters = validateFiltersObject(filters);
|
|
210
|
+
// Handle empty or undefined filters array (valid but returns no results)
|
|
211
|
+
if (!validatedFilters.filters || validatedFilters.filters.length === 0) {
|
|
212
|
+
return validatedFilters;
|
|
213
|
+
}
|
|
214
|
+
// Collect invalid filters
|
|
215
|
+
const invalidFilters = collectInvalidFilters(validatedFilters.filters, validateConditions);
|
|
216
|
+
// If all filters are invalid, throw error with examples
|
|
217
|
+
if (invalidFilters.length === validatedFilters.filters.length) {
|
|
218
|
+
const errorDetails = formatInvalidFiltersError(invalidFilters);
|
|
219
|
+
let errorMessage = `${ERROR_MESSAGES.ALL_FILTERS_INVALID} ${errorDetails}`;
|
|
220
|
+
// Add examples to help the user fix their filters
|
|
221
|
+
errorMessage +=
|
|
222
|
+
'\n\nExample of valid filter structure: \n' + FILTER_EXAMPLES.SIMPLE;
|
|
223
|
+
// Determine most appropriate error category based on invalid filters
|
|
224
|
+
let category = FilterErrorCategory.STRUCTURE;
|
|
225
|
+
// If we have specific attribute issues
|
|
226
|
+
if (invalidFilters.some((f) => f.reason.includes('attribute'))) {
|
|
227
|
+
category = FilterErrorCategory.ATTRIBUTE;
|
|
228
|
+
}
|
|
229
|
+
// If we have specific condition issues
|
|
230
|
+
else if (invalidFilters.some((f) => f.reason.includes('condition'))) {
|
|
231
|
+
category = FilterErrorCategory.CONDITION;
|
|
232
|
+
}
|
|
233
|
+
// If we have specific value issues
|
|
234
|
+
else if (invalidFilters.some((f) => f.reason.includes('value'))) {
|
|
235
|
+
category = FilterErrorCategory.VALUE;
|
|
236
|
+
}
|
|
237
|
+
throw new FilterValidationError(errorMessage, category);
|
|
238
|
+
}
|
|
239
|
+
return validatedFilters;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Helper function to get a descriptive reason for an invalid filter
|
|
243
|
+
*
|
|
244
|
+
* @param filter - The filter to analyze
|
|
245
|
+
* @returns A string describing what's wrong with the filter
|
|
246
|
+
*/
|
|
247
|
+
export function getInvalidFilterReason(filter) {
|
|
248
|
+
if (!filter || typeof filter !== 'object') {
|
|
249
|
+
return `filter is ${filter === null ? 'null' : typeof filter}`;
|
|
250
|
+
}
|
|
251
|
+
if (!filter.attribute) {
|
|
252
|
+
return ERROR_MESSAGES.MISSING_ATTRIBUTE;
|
|
253
|
+
}
|
|
254
|
+
if (!filter.attribute.slug) {
|
|
255
|
+
return ERROR_MESSAGES.MISSING_ATTRIBUTE_SLUG;
|
|
256
|
+
}
|
|
257
|
+
if (!filter.condition) {
|
|
258
|
+
return ERROR_MESSAGES.MISSING_CONDITION;
|
|
259
|
+
}
|
|
260
|
+
if (!isValidFilterCondition(filter.condition)) {
|
|
261
|
+
return `invalid condition '${filter.condition}'`;
|
|
262
|
+
}
|
|
263
|
+
return 'unknown issue';
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Generate examples for different filter scenarios
|
|
267
|
+
*
|
|
268
|
+
* @param filterType - The type of filter example to generate (simple, or, multiple)
|
|
269
|
+
* @returns A string with the example in JSON format
|
|
270
|
+
*/
|
|
271
|
+
export function getFilterExample(filterType = 'simple') {
|
|
272
|
+
switch (filterType) {
|
|
273
|
+
case 'or':
|
|
274
|
+
return FILTER_EXAMPLES.OR_LOGIC;
|
|
275
|
+
case 'multiple':
|
|
276
|
+
return FILTER_EXAMPLES.MULTIPLE_CONDITIONS;
|
|
277
|
+
case 'simple':
|
|
278
|
+
default:
|
|
279
|
+
return FILTER_EXAMPLES.SIMPLE;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=validation-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-utils.js","sourceRoot":"","sources":["../../../src/utils/filters/validation-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE,qDAAqD;IACtE,iBAAiB,EAAE,CAAC,IAAY,EAAE,EAAE,CAClC,yEAAyE,IAAI,EAAE;IACjF,wBAAwB,EAAE,iDAAiD;IAC3E,mBAAmB,EAAE,0CAA0C;IAC/D,wBAAwB,EAAE,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE,CAC1D,qCAAqC,KAAK,KAAK,MAAM,EAAE;IACzD,iBAAiB,EAAE,0BAA0B;IAC7C,sBAAsB,EAAE,iCAAiC;IACzD,iBAAiB,EAAE,4BAA4B;IAC/C,iBAAiB,EAAE,CAAC,SAAiB,EAAE,eAAyB,EAAE,EAAE,CAClE,6BAA6B,SAAS,4BAA4B,eAAe,CAAC,IAAI,CACpF,IAAI,CACL,EAAE;IACL,mBAAmB,EACjB,oEAAoE;CACvE,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,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AAQ,CAAC;QAClC,KAAK,UAAU;YACb,OAAO,eAAe,CAAC,mBAAmB,CAAC;QAC7C,KAAK,QAAQ,CAAC;QACd;YACE,OAAO,eAAe,CAAC,MAAM,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module validators
|
|
3
|
+
*
|
|
4
|
+
* Consolidated filter validation utilities
|
|
5
|
+
* Provides functions to validate and normalize filter parameters
|
|
6
|
+
*
|
|
7
|
+
* This module provides:
|
|
8
|
+
* - Structure validation for filter objects
|
|
9
|
+
* - Date range validation and normalization
|
|
10
|
+
* - Numeric range validation
|
|
11
|
+
* - Activity filter validation
|
|
12
|
+
* - Filter condition validation
|
|
13
|
+
* - Parameter type validation and conversion
|
|
14
|
+
*/
|
|
15
|
+
import { DateRange, ActivityFilter, NumericRange, FilterConditionType, ListEntryFilter } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Validates a filter structure for basic required properties
|
|
18
|
+
*
|
|
19
|
+
* @param filter - The filter to validate
|
|
20
|
+
* @returns True if filter is valid, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateFilterStructure(filter: ListEntryFilter): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Validates a date range object
|
|
25
|
+
*
|
|
26
|
+
* @param dateRange - The date range to validate
|
|
27
|
+
* @returns Validated and normalized date range
|
|
28
|
+
* @throws FilterValidationError if validation fails
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateDateRange(dateRange: any): DateRange;
|
|
31
|
+
/**
|
|
32
|
+
* Validates an activity filter object
|
|
33
|
+
*
|
|
34
|
+
* @param activityFilter - The activity filter to validate
|
|
35
|
+
* @returns Validated and normalized activity filter
|
|
36
|
+
* @throws FilterValidationError if validation fails
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateActivityFilter(activityFilter: any): ActivityFilter;
|
|
39
|
+
/**
|
|
40
|
+
* Validates a numeric range object
|
|
41
|
+
*
|
|
42
|
+
* @param range - The numeric range to validate
|
|
43
|
+
* @returns Validated and normalized numeric range
|
|
44
|
+
* @throws FilterValidationError if validation fails
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateNumericRange(range: any): NumericRange;
|
|
47
|
+
/**
|
|
48
|
+
* Validates a filter condition string
|
|
49
|
+
*
|
|
50
|
+
* @param condition - The condition to validate
|
|
51
|
+
* @returns The validated condition
|
|
52
|
+
* @throws FilterValidationError if validation fails
|
|
53
|
+
*/
|
|
54
|
+
export declare function validateFilterCondition(condition: string): FilterConditionType;
|
|
55
|
+
/**
|
|
56
|
+
* Ensures a value is a number, converting if necessary
|
|
57
|
+
*
|
|
58
|
+
* @param value - The value to validate and convert
|
|
59
|
+
* @param paramName - Name of the parameter (for error messages)
|
|
60
|
+
* @param defaultValue - Optional default value if undefined
|
|
61
|
+
* @returns The validated number
|
|
62
|
+
* @throws FilterValidationError if validation fails
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateNumericParam(value: any, paramName: string, defaultValue?: number): number;
|
|
65
|
+
/**
|
|
66
|
+
* Validates filter structure and conditions
|
|
67
|
+
*
|
|
68
|
+
* @param filter - The filter to validate
|
|
69
|
+
* @param validateConditions - Whether to validate condition types (default: true)
|
|
70
|
+
* @throws FilterValidationError if validation fails
|
|
71
|
+
*/
|
|
72
|
+
export declare function validateFilterWithConditions(filter: ListEntryFilter, validateConditions?: boolean): void;
|
|
73
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/utils/filters/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,OAAO,EACL,SAAS,EACT,cAAc,EAEd,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAcxE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,CAoJ3D;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,GAAG,GAAG,cAAc,CA2D1E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,YAAY,CAgF7D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAChB,mBAAmB,CAerB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAcR;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,eAAe,EACvB,kBAAkB,GAAE,OAAc,GACjC,IAAI,CAgBN"}
|