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,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relationship filtering utilities
|
|
3
|
+
* These utilities help create filters based on relationships between records
|
|
4
|
+
*/
|
|
5
|
+
// External dependencies
|
|
6
|
+
import { FilterValidationError, RelationshipFilterError, ListRelationshipError, } from '../../errors/api-errors.js';
|
|
7
|
+
// Internal module dependencies
|
|
8
|
+
import { FilterConditionType, RelationshipType, ResourceType, ATTRIBUTES, RelationshipRateLimitError, } from './types.js';
|
|
9
|
+
// import { isValidListId } from "../../validation.js";
|
|
10
|
+
import { createEqualsFilter } from './builders.js';
|
|
11
|
+
import { getCachedRelationshipFilter, cacheRelationshipFilter, getCachedListFilter, cacheListFilter, hashFilters, } from './cache.js';
|
|
12
|
+
/**
|
|
13
|
+
* Applies rate limiting to relationship queries
|
|
14
|
+
* Throws RelationshipRateLimitError if the rate limit is exceeded
|
|
15
|
+
*
|
|
16
|
+
* @param req - Request object
|
|
17
|
+
* @param relationshipType - Type of relationship query
|
|
18
|
+
* @param isNested - Whether this is a nested relationship query
|
|
19
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
20
|
+
*/
|
|
21
|
+
export function applyRateLimit(req, relationshipType, isNested = false) {
|
|
22
|
+
// Check the rate limit
|
|
23
|
+
// TODO: Restore when checkRelationshipQueryRateLimit is available
|
|
24
|
+
// const result = checkRelationshipQueryRateLimit(req, relationshipType, isNested);
|
|
25
|
+
// If not allowed, throw rate limit error
|
|
26
|
+
// if (!result.allowed) {
|
|
27
|
+
// throw new RelationshipRateLimitError(
|
|
28
|
+
// `Rate limit exceeded for ${isNested ? 'nested ' : ''}relationship query of type '${relationshipType}'. Try again in ${Math.ceil(result.msUntilReset / 1000)} seconds.`,
|
|
29
|
+
// relationshipType,
|
|
30
|
+
// result.resetTime,
|
|
31
|
+
// result.msUntilReset
|
|
32
|
+
// );
|
|
33
|
+
// }
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Core function to create relationship-based filters
|
|
37
|
+
* This translates our internal representation to the format expected by the Attio API
|
|
38
|
+
*
|
|
39
|
+
* @param config - Relationship filter configuration
|
|
40
|
+
* @returns Filter in the format expected by Attio API
|
|
41
|
+
*/
|
|
42
|
+
function createRelationshipFilter(config) {
|
|
43
|
+
// Map our ResourceType to Attio API object names
|
|
44
|
+
const getObjectName = (type) => {
|
|
45
|
+
switch (type) {
|
|
46
|
+
case ResourceType.PEOPLE:
|
|
47
|
+
return 'people';
|
|
48
|
+
case ResourceType.COMPANIES:
|
|
49
|
+
return 'companies';
|
|
50
|
+
case ResourceType.LISTS:
|
|
51
|
+
return 'lists';
|
|
52
|
+
case ResourceType.RECORDS:
|
|
53
|
+
return 'records';
|
|
54
|
+
default:
|
|
55
|
+
throw new Error(`Unsupported resource type: ${type}`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// The relationship field should be a custom attribute in the filter
|
|
59
|
+
return {
|
|
60
|
+
filters: [
|
|
61
|
+
{
|
|
62
|
+
attribute: {
|
|
63
|
+
slug: ATTRIBUTES.RELATIONSHIP,
|
|
64
|
+
},
|
|
65
|
+
condition: FilterConditionType.EQUALS,
|
|
66
|
+
value: {
|
|
67
|
+
type: config.relationshipType,
|
|
68
|
+
target: {
|
|
69
|
+
object: getObjectName(config.targetType),
|
|
70
|
+
filter: config.targetFilters,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
matchAny: false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a filter for people based on their associated company attributes
|
|
80
|
+
* Includes rate limiting for this resource-intensive operation
|
|
81
|
+
*
|
|
82
|
+
* @param companyFilter - Filters to apply to the related companies
|
|
83
|
+
* @param req - Optional request object for rate limiting (if not provided, rate limiting is skipped)
|
|
84
|
+
* @returns Filter for finding people based on company attributes
|
|
85
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
86
|
+
*/
|
|
87
|
+
export function createPeopleByCompanyFilter(companyFilter, req) {
|
|
88
|
+
try {
|
|
89
|
+
// Apply rate limiting if request object is provided
|
|
90
|
+
if (req) {
|
|
91
|
+
applyRateLimit(req, RelationshipType.WORKS_AT, false);
|
|
92
|
+
}
|
|
93
|
+
// Validate company filters
|
|
94
|
+
if (!companyFilter ||
|
|
95
|
+
!companyFilter.filters ||
|
|
96
|
+
companyFilter.filters.length === 0) {
|
|
97
|
+
throw new RelationshipFilterError('Company filter must contain at least one valid filter condition', ResourceType.PEOPLE.toString(), ResourceType.COMPANIES.toString(), RelationshipType.WORKS_AT);
|
|
98
|
+
}
|
|
99
|
+
// Create a relationship filter configuration
|
|
100
|
+
const relationshipConfig = {
|
|
101
|
+
sourceType: ResourceType.PEOPLE,
|
|
102
|
+
targetType: ResourceType.COMPANIES,
|
|
103
|
+
relationshipType: RelationshipType.WORKS_AT,
|
|
104
|
+
targetFilters: companyFilter,
|
|
105
|
+
};
|
|
106
|
+
// Convert to an Attio API compatible filter
|
|
107
|
+
return createRelationshipFilter(relationshipConfig);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
// Re-throw if it's already a rate limit error
|
|
111
|
+
if (error instanceof RelationshipRateLimitError) {
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
// Check if it's already another specialized error
|
|
115
|
+
if (error instanceof RelationshipFilterError) {
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
// Otherwise, wrap in a FilterValidationError
|
|
119
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
120
|
+
throw new FilterValidationError(`Failed to create people-by-company filter: ${errorMessage}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Creates a filter for companies based on their associated people attributes
|
|
125
|
+
* Includes rate limiting for this resource-intensive operation
|
|
126
|
+
*
|
|
127
|
+
* @param peopleFilter - Filters to apply to the related people
|
|
128
|
+
* @param req - Optional request object for rate limiting (if not provided, rate limiting is skipped)
|
|
129
|
+
* @returns Filter for finding companies based on people attributes
|
|
130
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
131
|
+
*/
|
|
132
|
+
export function createCompaniesByPeopleFilter(peopleFilter, req) {
|
|
133
|
+
try {
|
|
134
|
+
// Apply rate limiting if request object is provided
|
|
135
|
+
if (req) {
|
|
136
|
+
applyRateLimit(req, RelationshipType.EMPLOYS, false);
|
|
137
|
+
}
|
|
138
|
+
// Validate people filters
|
|
139
|
+
if (!peopleFilter ||
|
|
140
|
+
!peopleFilter.filters ||
|
|
141
|
+
peopleFilter.filters.length === 0) {
|
|
142
|
+
throw new RelationshipFilterError('People filter must contain at least one valid filter condition', ResourceType.COMPANIES.toString(), ResourceType.PEOPLE.toString(), RelationshipType.EMPLOYS);
|
|
143
|
+
}
|
|
144
|
+
// Create a relationship filter configuration
|
|
145
|
+
const relationshipConfig = {
|
|
146
|
+
sourceType: ResourceType.COMPANIES,
|
|
147
|
+
targetType: ResourceType.PEOPLE,
|
|
148
|
+
relationshipType: RelationshipType.EMPLOYS,
|
|
149
|
+
targetFilters: peopleFilter,
|
|
150
|
+
};
|
|
151
|
+
// Convert to an Attio API compatible filter
|
|
152
|
+
return createRelationshipFilter(relationshipConfig);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
// Re-throw if it's already a rate limit error
|
|
156
|
+
if (error instanceof RelationshipRateLimitError) {
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
// Check if it's already another specialized error
|
|
160
|
+
if (error instanceof RelationshipFilterError) {
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
// Otherwise, wrap in a FilterValidationError
|
|
164
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
165
|
+
throw new FilterValidationError(`Failed to create companies-by-people filter: ${errorMessage}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a filter for records that belong to a specific list
|
|
170
|
+
* Includes rate limiting for this operation and caching for better performance
|
|
171
|
+
*
|
|
172
|
+
* @param resourceType - The type of records to filter (people or companies)
|
|
173
|
+
* @param listId - The ID of the list to filter by
|
|
174
|
+
* @param req - Optional request object for rate limiting (if not provided, rate limiting is skipped)
|
|
175
|
+
* @param useCache - Whether to use caching (default: true)
|
|
176
|
+
* @returns Filter for finding records that belong to the list
|
|
177
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
178
|
+
*/
|
|
179
|
+
export function createRecordsByListFilter(resourceType, listId, req, useCache = true) {
|
|
180
|
+
try {
|
|
181
|
+
// Check cache first if caching is enabled
|
|
182
|
+
if (useCache) {
|
|
183
|
+
const cachedFilter = getCachedListFilter(listId, resourceType);
|
|
184
|
+
if (cachedFilter) {
|
|
185
|
+
return cachedFilter;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Apply rate limiting if request object is provided
|
|
189
|
+
if (req) {
|
|
190
|
+
applyRateLimit(req, RelationshipType.BELONGS_TO_LIST, false);
|
|
191
|
+
}
|
|
192
|
+
// Validate list ID format and security using imported function
|
|
193
|
+
// Validate list ID format and security
|
|
194
|
+
// TODO: Fix import issue with validation.js
|
|
195
|
+
if (!listId || !/^list_[a-zA-Z0-9]+$/.test(listId)) {
|
|
196
|
+
throw new ListRelationshipError('Invalid list ID format. Expected format: list_[alphanumeric]', resourceType.toString(), listId);
|
|
197
|
+
}
|
|
198
|
+
// Create a relationship filter configuration
|
|
199
|
+
const relationshipConfig = {
|
|
200
|
+
sourceType: resourceType,
|
|
201
|
+
targetType: ResourceType.LISTS,
|
|
202
|
+
relationshipType: RelationshipType.BELONGS_TO_LIST,
|
|
203
|
+
targetFilters: createEqualsFilter(ATTRIBUTES.LIST_ID, listId),
|
|
204
|
+
};
|
|
205
|
+
// Convert to an Attio API compatible filter
|
|
206
|
+
const result = createRelationshipFilter(relationshipConfig);
|
|
207
|
+
// Cache the result if caching is enabled
|
|
208
|
+
if (useCache) {
|
|
209
|
+
cacheListFilter(listId, resourceType, result);
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
// Re-throw if it's already a rate limit error
|
|
215
|
+
if (error instanceof RelationshipRateLimitError) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
// Check if it's already another specialized error
|
|
219
|
+
if (error instanceof ListRelationshipError ||
|
|
220
|
+
error instanceof RelationshipFilterError) {
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
// Otherwise, wrap in a FilterValidationError
|
|
224
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
225
|
+
throw new FilterValidationError(`Failed to create records-by-list filter: ${errorMessage}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Creates a filter for finding people who work at companies in a specific list
|
|
230
|
+
* This is a nested relationship query with rate limiting and caching applied
|
|
231
|
+
*
|
|
232
|
+
* @param listId - The ID of the list that contains companies
|
|
233
|
+
* @param req - Optional request object for rate limiting (if not provided, rate limiting is skipped)
|
|
234
|
+
* @param useCache - Whether to use caching (default: true)
|
|
235
|
+
* @returns Filter for finding people who work at companies in the specified list
|
|
236
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
237
|
+
*/
|
|
238
|
+
export function createPeopleByCompanyListFilter(listId, req, useCache = true) {
|
|
239
|
+
try {
|
|
240
|
+
// Create a cache key for this nested relationship
|
|
241
|
+
const cacheKey = {
|
|
242
|
+
relationshipType: RelationshipType.WORKS_AT,
|
|
243
|
+
sourceType: ResourceType.PEOPLE,
|
|
244
|
+
targetType: ResourceType.COMPANIES,
|
|
245
|
+
targetFilterHash: '', // Will be set later
|
|
246
|
+
listId: listId,
|
|
247
|
+
isNested: true,
|
|
248
|
+
};
|
|
249
|
+
// Check cache first if caching is enabled
|
|
250
|
+
if (useCache) {
|
|
251
|
+
const cachedFilter = getCachedRelationshipFilter(cacheKey);
|
|
252
|
+
if (cachedFilter) {
|
|
253
|
+
return cachedFilter;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Apply rate limiting if request object is provided
|
|
257
|
+
if (req) {
|
|
258
|
+
applyRateLimit(req, RelationshipType.WORKS_AT, true);
|
|
259
|
+
}
|
|
260
|
+
// Validate list ID format and security using imported function
|
|
261
|
+
// Validate list ID format and security
|
|
262
|
+
// TODO: Fix import issue with validation.js
|
|
263
|
+
if (!listId || !/^list_[a-zA-Z0-9]+$/.test(listId)) {
|
|
264
|
+
throw new Error('Invalid list ID format. Expected format: list_[alphanumeric]');
|
|
265
|
+
}
|
|
266
|
+
// First, create a filter for companies in the list
|
|
267
|
+
const companiesInListFilter = createRecordsByListFilter(ResourceType.COMPANIES, listId, undefined, useCache);
|
|
268
|
+
// Update cache key with the hash of the target filter
|
|
269
|
+
cacheKey.targetFilterHash = hashFilters(companiesInListFilter);
|
|
270
|
+
// Then, create a filter for people who work at those companies
|
|
271
|
+
const result = createPeopleByCompanyFilter(companiesInListFilter);
|
|
272
|
+
// Cache the result if caching is enabled
|
|
273
|
+
if (useCache) {
|
|
274
|
+
cacheRelationshipFilter(cacheKey, result);
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
// Re-throw if it's already a rate limit error
|
|
280
|
+
if (error instanceof RelationshipRateLimitError) {
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
284
|
+
throw new FilterValidationError(`Failed to create people-by-company-list filter: ${errorMessage}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Creates a filter for finding companies that have people in a specific list
|
|
289
|
+
* This is a nested relationship query with rate limiting and caching applied
|
|
290
|
+
*
|
|
291
|
+
* @param listId - The ID of the list that contains people
|
|
292
|
+
* @param req - Optional request object for rate limiting (if not provided, rate limiting is skipped)
|
|
293
|
+
* @param useCache - Whether to use caching (default: true)
|
|
294
|
+
* @returns Filter for finding companies that have people in the specified list
|
|
295
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
296
|
+
*/
|
|
297
|
+
export function createCompaniesByPeopleListFilter(listId, req, useCache = true) {
|
|
298
|
+
try {
|
|
299
|
+
// Create a cache key for this nested relationship
|
|
300
|
+
const cacheKey = {
|
|
301
|
+
relationshipType: RelationshipType.EMPLOYS,
|
|
302
|
+
sourceType: ResourceType.COMPANIES,
|
|
303
|
+
targetType: ResourceType.PEOPLE,
|
|
304
|
+
targetFilterHash: '', // Will be set later
|
|
305
|
+
listId: listId,
|
|
306
|
+
isNested: true,
|
|
307
|
+
};
|
|
308
|
+
// Check cache first if caching is enabled
|
|
309
|
+
if (useCache) {
|
|
310
|
+
const cachedFilter = getCachedRelationshipFilter(cacheKey);
|
|
311
|
+
if (cachedFilter) {
|
|
312
|
+
return cachedFilter;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// Apply rate limiting if request object is provided
|
|
316
|
+
if (req) {
|
|
317
|
+
applyRateLimit(req, RelationshipType.EMPLOYS, true);
|
|
318
|
+
}
|
|
319
|
+
// Validate list ID format and security using imported function
|
|
320
|
+
// Validate list ID format and security
|
|
321
|
+
// TODO: Fix import issue with validation.js
|
|
322
|
+
if (!listId || !/^list_[a-zA-Z0-9]+$/.test(listId)) {
|
|
323
|
+
throw new Error('Invalid list ID format. Expected format: list_[alphanumeric]');
|
|
324
|
+
}
|
|
325
|
+
// First, create a filter for people in the list
|
|
326
|
+
const peopleInListFilter = createRecordsByListFilter(ResourceType.PEOPLE, listId, undefined, useCache);
|
|
327
|
+
// Update cache key with the hash of the target filter
|
|
328
|
+
cacheKey.targetFilterHash = hashFilters(peopleInListFilter);
|
|
329
|
+
// Then, create a filter for companies that have those people
|
|
330
|
+
const result = createCompaniesByPeopleFilter(peopleInListFilter);
|
|
331
|
+
// Cache the result if caching is enabled
|
|
332
|
+
if (useCache) {
|
|
333
|
+
cacheRelationshipFilter(cacheKey, result);
|
|
334
|
+
}
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
// Re-throw if it's already a rate limit error
|
|
339
|
+
if (error instanceof RelationshipRateLimitError) {
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
343
|
+
throw new FilterValidationError(`Failed to create companies-by-people-list filter: ${errorMessage}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Creates a filter for records that have associated notes matching criteria
|
|
348
|
+
* Includes rate limiting for text search operations
|
|
349
|
+
*
|
|
350
|
+
* @param resourceType - The type of records to filter (people or companies)
|
|
351
|
+
* @param textSearch - Text to search for in the notes
|
|
352
|
+
* @param req - Optional request object for rate limiting (if not provided, rate limiting is skipped)
|
|
353
|
+
* @returns Filter for finding records with matching notes
|
|
354
|
+
* @throws RelationshipRateLimitError if rate limit exceeded
|
|
355
|
+
*/
|
|
356
|
+
export function createRecordsByNotesFilter(resourceType, textSearch, req) {
|
|
357
|
+
try {
|
|
358
|
+
// Apply rate limiting if request object is provided
|
|
359
|
+
if (req) {
|
|
360
|
+
applyRateLimit(req, RelationshipType.HAS_NOTE, false);
|
|
361
|
+
}
|
|
362
|
+
if (!textSearch || textSearch.trim() === '') {
|
|
363
|
+
throw new Error('Text search query must be provided');
|
|
364
|
+
}
|
|
365
|
+
// Create a relationship filter configuration
|
|
366
|
+
const relationshipConfig = {
|
|
367
|
+
sourceType: resourceType,
|
|
368
|
+
targetType: ResourceType.LISTS, // Notes don't have a ResourceType, using LISTS as a placeholder
|
|
369
|
+
relationshipType: RelationshipType.HAS_NOTE,
|
|
370
|
+
targetFilters: {
|
|
371
|
+
filters: [
|
|
372
|
+
{
|
|
373
|
+
attribute: { slug: ATTRIBUTES.NOTE_CONTENT },
|
|
374
|
+
condition: FilterConditionType.CONTAINS,
|
|
375
|
+
value: textSearch,
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
matchAny: false,
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
// Convert to an Attio API compatible filter
|
|
382
|
+
return createRelationshipFilter(relationshipConfig);
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
// Re-throw if it's already a rate limit error
|
|
386
|
+
if (error instanceof RelationshipRateLimitError) {
|
|
387
|
+
throw error;
|
|
388
|
+
}
|
|
389
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
390
|
+
throw new FilterValidationError(`Failed to create records-by-notes filter: ${errorMessage}`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=relationship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship.js","sourceRoot":"","sources":["../../../src/utils/filters/relationship.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAwB;AACxB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,+BAA+B;AAC/B,OAAO,EAEL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EAEZ,UAAU,EACV,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,uDAAuD;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAQ,EACR,gBAAwB,EACxB,WAAoB,KAAK;IAEzB,uBAAuB;IACvB,kEAAkE;IAClE,mFAAmF;IACnF,yCAAyC;IACzC,yBAAyB;IACzB,0CAA0C;IAC1C,8KAA8K;IAC9K,wBAAwB;IACxB,wBAAwB;IACxB,0BAA0B;IAC1B,OAAO;IACP,IAAI;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAS,wBAAwB,CAC/B,MAAgC;IAEhC,iDAAiD;IACjD,MAAM,aAAa,GAAG,CAAC,IAAkB,EAAU,EAAE;QACnD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,YAAY,CAAC,MAAM;gBACtB,OAAO,QAAQ,CAAC;YAClB,KAAK,YAAY,CAAC,SAAS;gBACzB,OAAO,WAAW,CAAC;YACrB,KAAK,YAAY,CAAC,KAAK;gBACrB,OAAO,OAAO,CAAC;YACjB,KAAK,YAAY,CAAC,OAAO;gBACvB,OAAO,SAAS,CAAC;YACnB;gBACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC,CAAC;IAEF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K,YAAY,0BAA0B,EAAE,CAAC;YAChD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,IAAI,qBAAqB,CAC7B,6CAA6C,YAAY,EAAE,CAC5D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module translators
|
|
3
|
+
*
|
|
4
|
+
* Filter translation utilities for converting between formats
|
|
5
|
+
* Handles transformation between MCP filter format and Attio API format
|
|
6
|
+
*
|
|
7
|
+
* This module provides:
|
|
8
|
+
* - MCP to Attio API format transformation
|
|
9
|
+
* - Support for AND/OR logical operators
|
|
10
|
+
* - Operator conversion utilities
|
|
11
|
+
* - Attribute name transformations
|
|
12
|
+
* - Reverse transformation (API to MCP)
|
|
13
|
+
*/
|
|
14
|
+
import { ListEntryFilters, ListEntryFilter, AttioApiFilter, FilterConditionType } from './types.js';
|
|
15
|
+
/**
|
|
16
|
+
* Transforms list entry filters to the format expected by the Attio API
|
|
17
|
+
*
|
|
18
|
+
* This is the main transformation function that converts MCP filter specifications
|
|
19
|
+
* into the format expected by the Attio API. It handles both AND and OR logical
|
|
20
|
+
* operators and provides comprehensive validation.
|
|
21
|
+
*
|
|
22
|
+
* **Key Features:**
|
|
23
|
+
* - Validates filter structure using centralized validation utilities
|
|
24
|
+
* - Supports both AND logic (default) and OR logic (matchAny: true)
|
|
25
|
+
* - Handles empty filter arrays gracefully (returns empty object)
|
|
26
|
+
* - Preserves filter condition types and values
|
|
27
|
+
* - Provides detailed error messages with examples on validation failure
|
|
28
|
+
*
|
|
29
|
+
* @param filters - Filter configuration from the MCP API (may have optional filters array)
|
|
30
|
+
* @param validateConditions - Whether to validate condition types against known Attio API operators
|
|
31
|
+
* @returns Transformed filter object for Attio API, or empty object if no valid filters
|
|
32
|
+
* @throws FilterValidationError if validation fails with consistent error messages and examples
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Simple filter with a single condition
|
|
36
|
+
* const simpleFilter = {
|
|
37
|
+
* filters: [
|
|
38
|
+
* {
|
|
39
|
+
* attribute: { slug: 'name' },
|
|
40
|
+
* condition: 'contains',
|
|
41
|
+
* value: 'Company Inc'
|
|
42
|
+
* }
|
|
43
|
+
* ]
|
|
44
|
+
* };
|
|
45
|
+
*
|
|
46
|
+
* // Filter with OR logic between conditions
|
|
47
|
+
* const orFilter = {
|
|
48
|
+
* filters: [
|
|
49
|
+
* {
|
|
50
|
+
* attribute: { slug: 'name' },
|
|
51
|
+
* condition: 'contains',
|
|
52
|
+
* value: 'Inc'
|
|
53
|
+
* },
|
|
54
|
+
* {
|
|
55
|
+
* attribute: { slug: 'industry' },
|
|
56
|
+
* condition: 'equals',
|
|
57
|
+
* value: 'Technology'
|
|
58
|
+
* }
|
|
59
|
+
* ],
|
|
60
|
+
* matchAny: true // Use OR logic
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* // Filter with multiple conditions (AND logic by default)
|
|
64
|
+
* const multipleFilter = {
|
|
65
|
+
* filters: [
|
|
66
|
+
* {
|
|
67
|
+
* attribute: { slug: 'name' },
|
|
68
|
+
* condition: 'contains',
|
|
69
|
+
* value: 'Inc'
|
|
70
|
+
* },
|
|
71
|
+
* {
|
|
72
|
+
* attribute: { slug: 'website' },
|
|
73
|
+
* condition: 'contains',
|
|
74
|
+
* value: '.com'
|
|
75
|
+
* }
|
|
76
|
+
* ]
|
|
77
|
+
* };
|
|
78
|
+
*/
|
|
79
|
+
export declare function transformFiltersToApiFormat(filters: ListEntryFilters | undefined, validateConditions?: boolean): {
|
|
80
|
+
filter?: AttioApiFilter;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Converts a single filter operator to API format
|
|
84
|
+
*
|
|
85
|
+
* @param operator - The operator to convert (e.g., 'equals', 'contains')
|
|
86
|
+
* @returns The operator in API format (e.g., '$equals', '$contains')
|
|
87
|
+
*/
|
|
88
|
+
export declare function convertOperatorToApiFormat(operator: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Transforms attribute names if they require special handling
|
|
91
|
+
*
|
|
92
|
+
* @param attributeSlug - The attribute slug to transform
|
|
93
|
+
* @returns The transformed attribute name
|
|
94
|
+
*/
|
|
95
|
+
export declare function transformAttributeName(attributeSlug: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Processes a filter value for API submission
|
|
98
|
+
* Handles any special value transformations needed
|
|
99
|
+
*
|
|
100
|
+
* @param value - The value to process
|
|
101
|
+
* @param condition - The filter condition being used
|
|
102
|
+
* @returns The processed value
|
|
103
|
+
*/
|
|
104
|
+
export declare function processFilterValue(value: any, condition: FilterConditionType): any;
|
|
105
|
+
/**
|
|
106
|
+
* Transforms a simple filter to API format
|
|
107
|
+
*
|
|
108
|
+
* @param filter - The filter to transform
|
|
109
|
+
* @returns API-formatted filter object
|
|
110
|
+
*/
|
|
111
|
+
export declare function transformSingleFilterToApi(filter: ListEntryFilter): AttioApiFilter;
|
|
112
|
+
/**
|
|
113
|
+
* Converts API filter format back to MCP filter format
|
|
114
|
+
* Useful for debugging and reverse transformation
|
|
115
|
+
*
|
|
116
|
+
* @param apiFilter - API format filter
|
|
117
|
+
* @returns MCP format filters
|
|
118
|
+
*/
|
|
119
|
+
export declare function transformApiFormatToFilters(apiFilter: AttioApiFilter): ListEntryFilters;
|
|
120
|
+
//# sourceMappingURL=translators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translators.d.ts","sourceRoot":"","sources":["../../../src/utils/filters/translators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAUpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,kBAAkB,GAAE,OAAc,GACjC;IAAE,MAAM,CAAC,EAAE,cAAc,CAAA;CAAE,CAmF7B;AA4MD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAOpE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,mBAAmB,GAC7B,GAAG,CAaL;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,eAAe,GACtB,cAAc,CAoBhB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,GACxB,gBAAgB,CA6ClB"}
|