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,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration loader for Attio MCP Server
|
|
3
|
+
* Handles loading and merging of configuration files
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
/**
|
|
8
|
+
* Default paths for configuration files
|
|
9
|
+
*/
|
|
10
|
+
const CONFIG_PATHS = {
|
|
11
|
+
default: path.resolve(process.cwd(), 'config/mappings/default.json'),
|
|
12
|
+
user: path.resolve(process.cwd(), 'config/mappings/user.json'),
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Deep merges two objects, with values from the source object taking precedence
|
|
16
|
+
*
|
|
17
|
+
* @param target - The target object
|
|
18
|
+
* @param source - The source object to merge in
|
|
19
|
+
* @returns The merged object
|
|
20
|
+
*/
|
|
21
|
+
function deepMerge(target, source) {
|
|
22
|
+
const result = { ...target };
|
|
23
|
+
for (const key in source) {
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
if (source[key] &&
|
|
26
|
+
typeof source[key] === 'object' &&
|
|
27
|
+
!Array.isArray(source[key])) {
|
|
28
|
+
// If both target and source have an object at this key, merge them
|
|
29
|
+
if (result[key] &&
|
|
30
|
+
typeof result[key] === 'object' &&
|
|
31
|
+
!Array.isArray(result[key])) {
|
|
32
|
+
result[key] = deepMerge(result[key], source[key]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Otherwise, just use the source value
|
|
36
|
+
result[key] = { ...source[key] };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// For non-objects, use the source value
|
|
41
|
+
result[key] = source[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates an empty mapping configuration with default structure
|
|
49
|
+
*
|
|
50
|
+
* @returns An empty mapping configuration
|
|
51
|
+
*/
|
|
52
|
+
function createEmptyConfig() {
|
|
53
|
+
return {
|
|
54
|
+
version: '1.0',
|
|
55
|
+
metadata: {
|
|
56
|
+
generated: new Date().toISOString(),
|
|
57
|
+
description: 'Generated empty configuration',
|
|
58
|
+
},
|
|
59
|
+
mappings: {
|
|
60
|
+
attributes: {
|
|
61
|
+
common: {},
|
|
62
|
+
objects: {},
|
|
63
|
+
custom: {},
|
|
64
|
+
},
|
|
65
|
+
objects: {},
|
|
66
|
+
lists: {},
|
|
67
|
+
relationships: {},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Loads a JSON configuration file
|
|
73
|
+
*
|
|
74
|
+
* @param filePath - Path to the JSON file
|
|
75
|
+
* @returns Parsed JSON object, or null if the file doesn't exist
|
|
76
|
+
*/
|
|
77
|
+
function loadJsonFile(filePath) {
|
|
78
|
+
try {
|
|
79
|
+
if (fs.existsSync(filePath)) {
|
|
80
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
81
|
+
return JSON.parse(content);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.warn(`Warning: Failed to load config file ${filePath}:`, error);
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Loads and merges the mapping configuration from default and user files
|
|
91
|
+
*
|
|
92
|
+
* @returns The merged mapping configuration
|
|
93
|
+
*/
|
|
94
|
+
export function loadMappingConfig() {
|
|
95
|
+
// Start with empty configuration
|
|
96
|
+
let config = createEmptyConfig();
|
|
97
|
+
// Load and merge the default configuration
|
|
98
|
+
const defaultConfig = loadJsonFile(CONFIG_PATHS.default);
|
|
99
|
+
if (defaultConfig) {
|
|
100
|
+
config = deepMerge(config, defaultConfig);
|
|
101
|
+
}
|
|
102
|
+
// Load and merge the user configuration
|
|
103
|
+
const userConfig = loadJsonFile(CONFIG_PATHS.user);
|
|
104
|
+
if (userConfig) {
|
|
105
|
+
config = deepMerge(config, userConfig);
|
|
106
|
+
}
|
|
107
|
+
return config;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Writes a mapping configuration to a file
|
|
111
|
+
*
|
|
112
|
+
* @param config - The configuration to write
|
|
113
|
+
* @param filePath - The file path to write to (defaults to user.json)
|
|
114
|
+
*/
|
|
115
|
+
export async function writeMappingConfig(config, filePath = CONFIG_PATHS.user) {
|
|
116
|
+
try {
|
|
117
|
+
// Ensure the directory exists
|
|
118
|
+
const dir = path.dirname(filePath);
|
|
119
|
+
if (!fs.existsSync(dir)) {
|
|
120
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
121
|
+
}
|
|
122
|
+
// Update metadata
|
|
123
|
+
if (!config.metadata) {
|
|
124
|
+
config.metadata = {};
|
|
125
|
+
}
|
|
126
|
+
config.metadata.generated = new Date().toISOString();
|
|
127
|
+
// Write the file
|
|
128
|
+
const content = JSON.stringify(config, null, 2);
|
|
129
|
+
await fs.promises.writeFile(filePath, content, 'utf8');
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
throw new Error(`Failed to write config file ${filePath}: ${error}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Updates a specific section of the mapping configuration
|
|
137
|
+
*
|
|
138
|
+
* @param section - The section to update (e.g., 'attributes.common')
|
|
139
|
+
* @param mappings - The mappings to set or merge
|
|
140
|
+
* @param merge - Whether to merge with existing mappings (default: true)
|
|
141
|
+
* @param filePath - The file path to write to (defaults to user.json)
|
|
142
|
+
*/
|
|
143
|
+
export async function updateMappingSection(section, mappings, merge = true, filePath = CONFIG_PATHS.user) {
|
|
144
|
+
// Load the current config
|
|
145
|
+
const config = loadMappingConfig();
|
|
146
|
+
// Parse the section path and navigate to the target section
|
|
147
|
+
const sectionParts = section.split('.');
|
|
148
|
+
let target = config.mappings;
|
|
149
|
+
for (let i = 0; i < sectionParts.length - 1; i++) {
|
|
150
|
+
const part = sectionParts[i];
|
|
151
|
+
if (!target[part]) {
|
|
152
|
+
target[part] = {};
|
|
153
|
+
}
|
|
154
|
+
target = target[part];
|
|
155
|
+
}
|
|
156
|
+
const finalPart = sectionParts[sectionParts.length - 1];
|
|
157
|
+
// Update the target section
|
|
158
|
+
if (merge && target[finalPart]) {
|
|
159
|
+
target[finalPart] = { ...target[finalPart], ...mappings };
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
target[finalPart] = mappings;
|
|
163
|
+
}
|
|
164
|
+
// Write the updated config
|
|
165
|
+
await writeMappingConfig(config, filePath);
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=config-loader.js.map
|
|
@@ -0,0 +1 @@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oBAAoB,CACxC,OAAe,EACf,QAA6B,EAC7B,QAAiB,IAAI,EACrB,WAAmB,YAAY,CAAC,IAAI;IAEpC,0BAA0B;IAC1B,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;IAEnC,4DAA4D;IAC5D,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;QACD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExD,4BAA4B;IAC5B,IAAI,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,2BAA2B;IAC3B,MAAM,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { MappingConfig } from './config-loader.js';
|
|
2
|
+
export type { MappingConfig };
|
|
3
|
+
export interface MigrationResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
backupPath?: string;
|
|
7
|
+
changesApplied?: string[];
|
|
8
|
+
errors?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface MigrationDetection {
|
|
11
|
+
needsMigration: boolean;
|
|
12
|
+
outdatedMappings: string[];
|
|
13
|
+
filePath: string;
|
|
14
|
+
exists: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Detects if user.json needs migration for postal code mappings
|
|
18
|
+
*
|
|
19
|
+
* Scans the user configuration file for outdated postal code mappings
|
|
20
|
+
* that use "zip" instead of the correct "postal_code" attribute name.
|
|
21
|
+
*
|
|
22
|
+
* @returns MigrationDetection object containing:
|
|
23
|
+
* - needsMigration: whether migration is required
|
|
24
|
+
* - outdatedMappings: array of problematic mappings found
|
|
25
|
+
* - filePath: path to the user config file
|
|
26
|
+
* - exists: whether the config file exists
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const detection = detectMigrationNeeds();
|
|
31
|
+
* if (detection.needsMigration) {
|
|
32
|
+
* console.log('Found outdated mappings:', detection.outdatedMappings);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectMigrationNeeds(): MigrationDetection;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a timestamped backup of the user.json file
|
|
39
|
+
*
|
|
40
|
+
* Creates a backup in config/mappings/backup/ directory with ISO timestamp.
|
|
41
|
+
* Ensures the backup directory exists before creating the backup file.
|
|
42
|
+
*
|
|
43
|
+
* @returns Object containing:
|
|
44
|
+
* - success: whether backup creation succeeded
|
|
45
|
+
* - backupPath: path to the created backup file (if successful)
|
|
46
|
+
* - error: error message (if failed)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const backup = createBackup();
|
|
51
|
+
* if (backup.success) {
|
|
52
|
+
* console.log('Backup created at:', backup.backupPath);
|
|
53
|
+
* } else {
|
|
54
|
+
* console.error('Backup failed:', backup.error);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function createBackup(): {
|
|
59
|
+
success: boolean;
|
|
60
|
+
backupPath?: string;
|
|
61
|
+
error?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Applies the postal code mapping migration to user.json
|
|
65
|
+
*
|
|
66
|
+
* Performs the complete migration workflow:
|
|
67
|
+
* 1. Detects if migration is needed
|
|
68
|
+
* 2. Creates a backup of the current configuration
|
|
69
|
+
* 3. Applies the postal code mapping fixes
|
|
70
|
+
* 4. Updates metadata to track migration history
|
|
71
|
+
*
|
|
72
|
+
* @returns MigrationResult object containing:
|
|
73
|
+
* - success: whether the migration succeeded
|
|
74
|
+
* - message: descriptive message about the operation
|
|
75
|
+
* - backupPath: path to the backup file (if created)
|
|
76
|
+
* - changesApplied: array of changes that were made
|
|
77
|
+
* - errors: array of error messages (if any failures occurred)
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const result = applyMigration();
|
|
82
|
+
* if (result.success) {
|
|
83
|
+
* console.log('Migration completed:', result.message);
|
|
84
|
+
* console.log('Changes:', result.changesApplied);
|
|
85
|
+
* } else {
|
|
86
|
+
* console.error('Migration failed:', result.message);
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function applyMigration(): MigrationResult;
|
|
91
|
+
/**
|
|
92
|
+
* Validates that the migration was applied correctly
|
|
93
|
+
*
|
|
94
|
+
* Checks if the user configuration still contains any outdated postal
|
|
95
|
+
* code mappings after migration has been applied.
|
|
96
|
+
*
|
|
97
|
+
* @returns Object containing:
|
|
98
|
+
* - valid: whether the configuration passes validation
|
|
99
|
+
* - issues: array of validation issues found (if any)
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const validation = validateMigration();
|
|
104
|
+
* if (!validation.valid) {
|
|
105
|
+
* console.error('Validation failed:', validation.issues);
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function validateMigration(): {
|
|
110
|
+
valid: boolean;
|
|
111
|
+
issues: string[];
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Complete migration workflow with validation
|
|
115
|
+
*
|
|
116
|
+
* Main entry point for the migration process. Orchestrates detection,
|
|
117
|
+
* migration, and validation with optional dry-run mode.
|
|
118
|
+
*
|
|
119
|
+
* @param options Configuration options for the migration:
|
|
120
|
+
* - dryRun: if true, only shows what would be changed without applying
|
|
121
|
+
*
|
|
122
|
+
* @returns MigrationResult object with complete operation status
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Preview changes without applying
|
|
127
|
+
* const preview = migrateUserConfig({ dryRun: true });
|
|
128
|
+
* console.log('Would apply:', preview.changesApplied);
|
|
129
|
+
*
|
|
130
|
+
* // Apply the migration
|
|
131
|
+
* const result = migrateUserConfig();
|
|
132
|
+
* if (result.success) {
|
|
133
|
+
* console.log('Migration completed successfully');
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function migrateUserConfig(options?: {
|
|
138
|
+
dryRun?: boolean;
|
|
139
|
+
}): MigrationResult;
|
|
140
|
+
//# sourceMappingURL=config-migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-migration.d.ts","sourceRoot":"","sources":["../../src/utils/config-migration.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AA0BD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,CA6CzD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,IAAI;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,IAAI,eAAe,CA6EhD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,IAAI;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmBxE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,eAAe,CAmDjB"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration migration utility for Attio MCP Server
|
|
3
|
+
* Handles migration of user.json files to fix outdated mappings
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import logger from './logger.js';
|
|
8
|
+
/**
|
|
9
|
+
* Known problematic mappings that need to be fixed
|
|
10
|
+
*/
|
|
11
|
+
const MAPPINGS_TO_FIX = {
|
|
12
|
+
ZIP: {
|
|
13
|
+
from: 'zip',
|
|
14
|
+
to: 'postal_code',
|
|
15
|
+
reason: 'zip attribute does not exist in Attio schema',
|
|
16
|
+
},
|
|
17
|
+
'Postal Code': {
|
|
18
|
+
from: 'zip',
|
|
19
|
+
to: 'postal_code',
|
|
20
|
+
reason: 'zip attribute does not exist in Attio schema',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Paths for configuration files
|
|
25
|
+
*/
|
|
26
|
+
const CONFIG_PATHS = {
|
|
27
|
+
user: path.resolve(process.cwd(), 'config/mappings/user.json'),
|
|
28
|
+
backup: path.resolve(process.cwd(), 'config/mappings/backup'),
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Detects if user.json needs migration for postal code mappings
|
|
32
|
+
*
|
|
33
|
+
* Scans the user configuration file for outdated postal code mappings
|
|
34
|
+
* that use "zip" instead of the correct "postal_code" attribute name.
|
|
35
|
+
*
|
|
36
|
+
* @returns MigrationDetection object containing:
|
|
37
|
+
* - needsMigration: whether migration is required
|
|
38
|
+
* - outdatedMappings: array of problematic mappings found
|
|
39
|
+
* - filePath: path to the user config file
|
|
40
|
+
* - exists: whether the config file exists
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const detection = detectMigrationNeeds();
|
|
45
|
+
* if (detection.needsMigration) {
|
|
46
|
+
* console.log('Found outdated mappings:', detection.outdatedMappings);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function detectMigrationNeeds() {
|
|
51
|
+
const result = {
|
|
52
|
+
needsMigration: false,
|
|
53
|
+
outdatedMappings: [],
|
|
54
|
+
filePath: CONFIG_PATHS.user,
|
|
55
|
+
exists: false,
|
|
56
|
+
};
|
|
57
|
+
// Check if user.json exists
|
|
58
|
+
if (!fs.existsSync(CONFIG_PATHS.user)) {
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
result.exists = true;
|
|
62
|
+
try {
|
|
63
|
+
const userConfig = JSON.parse(fs.readFileSync(CONFIG_PATHS.user, 'utf8'));
|
|
64
|
+
// Check common mappings for problematic postal code mappings
|
|
65
|
+
const commonMappings = userConfig.mappings?.attributes?.common || {};
|
|
66
|
+
for (const [displayName, expectedFix] of Object.entries(MAPPINGS_TO_FIX)) {
|
|
67
|
+
const currentMapping = commonMappings[displayName];
|
|
68
|
+
if (currentMapping === expectedFix.from) {
|
|
69
|
+
result.needsMigration = true;
|
|
70
|
+
result.outdatedMappings.push(`"${displayName}": "${currentMapping}" → should be "${expectedFix.to}"`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// If we can't parse the file, we can't migrate it
|
|
76
|
+
logger.warn('config-migration', 'Could not parse user configuration file for migration detection', {
|
|
77
|
+
filePath: CONFIG_PATHS.user,
|
|
78
|
+
error: error instanceof Error ? error.message : String(error),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a timestamped backup of the user.json file
|
|
85
|
+
*
|
|
86
|
+
* Creates a backup in config/mappings/backup/ directory with ISO timestamp.
|
|
87
|
+
* Ensures the backup directory exists before creating the backup file.
|
|
88
|
+
*
|
|
89
|
+
* @returns Object containing:
|
|
90
|
+
* - success: whether backup creation succeeded
|
|
91
|
+
* - backupPath: path to the created backup file (if successful)
|
|
92
|
+
* - error: error message (if failed)
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const backup = createBackup();
|
|
97
|
+
* if (backup.success) {
|
|
98
|
+
* console.log('Backup created at:', backup.backupPath);
|
|
99
|
+
* } else {
|
|
100
|
+
* console.error('Backup failed:', backup.error);
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export function createBackup() {
|
|
105
|
+
try {
|
|
106
|
+
// Ensure backup directory exists
|
|
107
|
+
if (!fs.existsSync(CONFIG_PATHS.backup)) {
|
|
108
|
+
fs.mkdirSync(CONFIG_PATHS.backup, { recursive: true });
|
|
109
|
+
}
|
|
110
|
+
// Create timestamped backup filename
|
|
111
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
112
|
+
const backupFileName = `user.json.backup.${timestamp}`;
|
|
113
|
+
const backupPath = path.join(CONFIG_PATHS.backup, backupFileName);
|
|
114
|
+
// Copy the current user.json to backup
|
|
115
|
+
fs.copyFileSync(CONFIG_PATHS.user, backupPath);
|
|
116
|
+
return { success: true, backupPath };
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: error instanceof Error ? error.message : String(error),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Applies the postal code mapping migration to user.json
|
|
127
|
+
*
|
|
128
|
+
* Performs the complete migration workflow:
|
|
129
|
+
* 1. Detects if migration is needed
|
|
130
|
+
* 2. Creates a backup of the current configuration
|
|
131
|
+
* 3. Applies the postal code mapping fixes
|
|
132
|
+
* 4. Updates metadata to track migration history
|
|
133
|
+
*
|
|
134
|
+
* @returns MigrationResult object containing:
|
|
135
|
+
* - success: whether the migration succeeded
|
|
136
|
+
* - message: descriptive message about the operation
|
|
137
|
+
* - backupPath: path to the backup file (if created)
|
|
138
|
+
* - changesApplied: array of changes that were made
|
|
139
|
+
* - errors: array of error messages (if any failures occurred)
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const result = applyMigration();
|
|
144
|
+
* if (result.success) {
|
|
145
|
+
* console.log('Migration completed:', result.message);
|
|
146
|
+
* console.log('Changes:', result.changesApplied);
|
|
147
|
+
* } else {
|
|
148
|
+
* console.error('Migration failed:', result.message);
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export function applyMigration() {
|
|
153
|
+
const detection = detectMigrationNeeds();
|
|
154
|
+
if (!detection.exists) {
|
|
155
|
+
return {
|
|
156
|
+
success: true,
|
|
157
|
+
message: 'No user.json file found - no migration needed',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (!detection.needsMigration) {
|
|
161
|
+
return {
|
|
162
|
+
success: true,
|
|
163
|
+
message: 'User configuration is already up to date - no migration needed',
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
// Create backup first
|
|
168
|
+
const backup = createBackup();
|
|
169
|
+
if (!backup.success) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
message: `Failed to create backup: ${backup.error}`,
|
|
173
|
+
errors: [backup.error || 'Unknown backup error'],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// Load and modify the user config
|
|
177
|
+
const userConfig = JSON.parse(fs.readFileSync(CONFIG_PATHS.user, 'utf8'));
|
|
178
|
+
const changesApplied = [];
|
|
179
|
+
// Apply postal code mapping fixes
|
|
180
|
+
if (userConfig.mappings?.attributes?.common) {
|
|
181
|
+
for (const [displayName, fix] of Object.entries(MAPPINGS_TO_FIX)) {
|
|
182
|
+
const currentMapping = userConfig.mappings.attributes.common[displayName];
|
|
183
|
+
if (currentMapping === fix.from) {
|
|
184
|
+
userConfig.mappings.attributes.common[displayName] = fix.to;
|
|
185
|
+
changesApplied.push(`Updated "${displayName}": "${fix.from}" → "${fix.to}"`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Update metadata to track migration
|
|
190
|
+
if (!userConfig.metadata) {
|
|
191
|
+
userConfig.metadata = {};
|
|
192
|
+
}
|
|
193
|
+
userConfig.metadata.lastMigration = new Date().toISOString();
|
|
194
|
+
userConfig.metadata.migratedMappings = changesApplied;
|
|
195
|
+
// Write the updated config back to file
|
|
196
|
+
fs.writeFileSync(CONFIG_PATHS.user, JSON.stringify(userConfig, null, 2), 'utf8');
|
|
197
|
+
return {
|
|
198
|
+
success: true,
|
|
199
|
+
message: `Migration completed successfully. Applied ${changesApplied.length} changes.`,
|
|
200
|
+
backupPath: backup.backupPath,
|
|
201
|
+
changesApplied,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
return {
|
|
206
|
+
success: false,
|
|
207
|
+
message: `Migration failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
208
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Validates that the migration was applied correctly
|
|
214
|
+
*
|
|
215
|
+
* Checks if the user configuration still contains any outdated postal
|
|
216
|
+
* code mappings after migration has been applied.
|
|
217
|
+
*
|
|
218
|
+
* @returns Object containing:
|
|
219
|
+
* - valid: whether the configuration passes validation
|
|
220
|
+
* - issues: array of validation issues found (if any)
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const validation = validateMigration();
|
|
225
|
+
* if (!validation.valid) {
|
|
226
|
+
* console.error('Validation failed:', validation.issues);
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export function validateMigration() {
|
|
231
|
+
const detection = detectMigrationNeeds();
|
|
232
|
+
if (!detection.exists) {
|
|
233
|
+
return { valid: true, issues: [] };
|
|
234
|
+
}
|
|
235
|
+
if (detection.needsMigration) {
|
|
236
|
+
return {
|
|
237
|
+
valid: false,
|
|
238
|
+
issues: [
|
|
239
|
+
`Migration incomplete. Still found outdated mappings: ${detection.outdatedMappings.join(', ')}`,
|
|
240
|
+
],
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return { valid: true, issues: [] };
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Complete migration workflow with validation
|
|
247
|
+
*
|
|
248
|
+
* Main entry point for the migration process. Orchestrates detection,
|
|
249
|
+
* migration, and validation with optional dry-run mode.
|
|
250
|
+
*
|
|
251
|
+
* @param options Configuration options for the migration:
|
|
252
|
+
* - dryRun: if true, only shows what would be changed without applying
|
|
253
|
+
*
|
|
254
|
+
* @returns MigrationResult object with complete operation status
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* // Preview changes without applying
|
|
259
|
+
* const preview = migrateUserConfig({ dryRun: true });
|
|
260
|
+
* console.log('Would apply:', preview.changesApplied);
|
|
261
|
+
*
|
|
262
|
+
* // Apply the migration
|
|
263
|
+
* const result = migrateUserConfig();
|
|
264
|
+
* if (result.success) {
|
|
265
|
+
* console.log('Migration completed successfully');
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
export function migrateUserConfig(options = {}) {
|
|
270
|
+
const detection = detectMigrationNeeds();
|
|
271
|
+
// Early return if no migration needed
|
|
272
|
+
if (!detection.exists) {
|
|
273
|
+
return {
|
|
274
|
+
success: true,
|
|
275
|
+
message: 'No user.json file found - no migration needed',
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (!detection.needsMigration) {
|
|
279
|
+
return {
|
|
280
|
+
success: true,
|
|
281
|
+
message: 'User configuration is already up to date - no migration needed',
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
// Dry run mode - just report what would be changed
|
|
285
|
+
if (options.dryRun) {
|
|
286
|
+
return {
|
|
287
|
+
success: true,
|
|
288
|
+
message: `Migration needed. Would fix: ${detection.outdatedMappings.join(', ')}`,
|
|
289
|
+
changesApplied: detection.outdatedMappings,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
// Apply the migration
|
|
293
|
+
const migrationResult = applyMigration();
|
|
294
|
+
if (!migrationResult.success) {
|
|
295
|
+
return migrationResult;
|
|
296
|
+
}
|
|
297
|
+
// Validate the migration worked
|
|
298
|
+
const validation = validateMigration();
|
|
299
|
+
if (!validation.valid) {
|
|
300
|
+
return {
|
|
301
|
+
success: false,
|
|
302
|
+
message: `Migration applied but validation failed: ${validation.issues.join(', ')}`,
|
|
303
|
+
errors: validation.issues,
|
|
304
|
+
backupPath: migrationResult.backupPath,
|
|
305
|
+
changesApplied: migrationResult.changesApplied,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return migrationResult;
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=config-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-migration.js","sourceRoot":"","sources":["../../src/utils/config-migration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAM,MAAM,aAAa,CAAC;AAoBjC;;GAEG;AACH,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,EAAE,EAAE,aAAa;QACjB,MAAM,EAAE,8CAA8C;KACvD;IACD,aAAa,EAAE;QACb,IAAI,EAAE,KAAK;QACX,EAAE,EAAE,aAAa;QACjB,MAAM,EAAE,8CAA8C;KACvD;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,2BAA2B,CAAC;IAC9D,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,wBAAwB,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,MAAM,GAAuB;QACjC,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,EAAE;QACpB,QAAQ,EAAE,YAAY,CAAC,IAAI;QAC3B,MAAM,EAAE,KAAK;KACd,CAAC;IAEF,4BAA4B;IAC5B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IAErB,IAAI,CAAC;QACH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