@credibledata/cred-cli 0.0.103 → 0.0.105
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/README.md +106 -1
- package/dist/agent-contract.spec.js +548 -0
- package/dist/agent-contract.spec.js.map +1 -0
- package/dist/browser.js +72 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.spec.js +125 -0
- package/dist/browser.spec.js.map +1 -0
- package/dist/client/api.js +4137 -1159
- package/dist/client/api.js.map +1 -1
- package/dist/client-codeassist/api.js +476 -0
- package/dist/client-codeassist/api.js.map +1 -0
- package/dist/client-codeassist/base.js +69 -0
- package/dist/client-codeassist/base.js.map +1 -0
- package/dist/client-codeassist/common.js +162 -0
- package/dist/client-codeassist/common.js.map +1 -0
- package/dist/client-codeassist/configuration.js +44 -0
- package/dist/client-codeassist/configuration.js.map +1 -0
- package/dist/client-codeassist/index.js +32 -0
- package/dist/client-codeassist/index.js.map +1 -0
- package/dist/clientconfiguration.js +17 -289
- package/dist/clientconfiguration.js.map +1 -1
- package/dist/clientconfiguration.spec.js +35 -96
- package/dist/clientconfiguration.spec.js.map +1 -1
- package/dist/commands/add.js +103 -3
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/add.spec.js +113 -0
- package/dist/commands/add.spec.js.map +1 -0
- package/dist/commands/connection/createconnections.js +104 -7
- package/dist/commands/connection/createconnections.js.map +1 -1
- package/dist/commands/connection/createconnections.spec.js +35 -1
- package/dist/commands/connection/createconnections.spec.js.map +1 -1
- package/dist/commands/connection/deleteconnection.js +4 -2
- package/dist/commands/connection/deleteconnection.js.map +1 -1
- package/dist/commands/connection/deleteconnection.spec.js +6 -1
- package/dist/commands/connection/deleteconnection.spec.js.map +1 -1
- package/dist/commands/connection/listconnections.js +2 -0
- package/dist/commands/connection/listconnections.js.map +1 -1
- package/dist/commands/connection/updateconnection.js +365 -0
- package/dist/commands/connection/updateconnection.js.map +1 -0
- package/dist/commands/connection/updateconnection.spec.js +625 -0
- package/dist/commands/connection/updateconnection.spec.js.map +1 -0
- package/dist/commands/database/createdatabase.js +52 -0
- package/dist/commands/database/createdatabase.js.map +1 -0
- package/dist/commands/database/database.spec.js +267 -0
- package/dist/commands/database/database.spec.js.map +1 -0
- package/dist/commands/database/deletedatabase.js +91 -0
- package/dist/commands/database/deletedatabase.js.map +1 -0
- package/dist/commands/database/getdatabase.js +97 -0
- package/dist/commands/database/getdatabase.js.map +1 -0
- package/dist/commands/database/listdatabases.js +36 -0
- package/dist/commands/database/listdatabases.js.map +1 -0
- package/dist/commands/database/shared.js +125 -0
- package/dist/commands/database/shared.js.map +1 -0
- package/dist/commands/database/shared.spec.js +109 -0
- package/dist/commands/database/shared.spec.js.map +1 -0
- package/dist/commands/database/updatedatabase.js +39 -0
- package/dist/commands/database/updatedatabase.js.map +1 -0
- package/dist/commands/environment/createenvironment.js +59 -28
- package/dist/commands/environment/createenvironment.js.map +1 -1
- package/dist/commands/environment/createenvironment.spec.js +29 -0
- package/dist/commands/environment/createenvironment.spec.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.js +3 -2
- package/dist/commands/environment/deleteenvironment.js.map +1 -1
- package/dist/commands/environment/deleteenvironment.spec.js +5 -1
- package/dist/commands/environment/deleteenvironment.spec.js.map +1 -1
- package/dist/commands/environment/getenvironment.js +1 -0
- package/dist/commands/environment/getenvironment.js.map +1 -1
- package/dist/commands/environment/listenvironments.js +40 -8
- package/dist/commands/environment/listenvironments.js.map +1 -1
- package/dist/commands/environment/listenvironments.spec.js +41 -2
- package/dist/commands/environment/listenvironments.spec.js.map +1 -1
- package/dist/commands/environment/setenvironment.js +145 -6
- package/dist/commands/environment/setenvironment.js.map +1 -1
- package/dist/commands/environment/setenvironment.spec.js +256 -8
- package/dist/commands/environment/setenvironment.spec.js.map +1 -1
- package/dist/commands/environment/updateenvironment.js +12 -8
- package/dist/commands/environment/updateenvironment.js.map +1 -1
- package/dist/commands/environment/updateenvironment.spec.js +36 -2
- package/dist/commands/environment/updateenvironment.spec.js.map +1 -1
- package/dist/commands/get.js +64 -1
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/group/addmember.js +3 -1
- package/dist/commands/group/addmember.js.map +1 -1
- package/dist/commands/group/addmember.spec.js +7 -2
- package/dist/commands/group/addmember.spec.js.map +1 -1
- package/dist/commands/group/creategroup.js +2 -0
- package/dist/commands/group/creategroup.js.map +1 -1
- package/dist/commands/group/deletegroup.js +3 -1
- package/dist/commands/group/deletegroup.js.map +1 -1
- package/dist/commands/group/deletegroup.spec.js +7 -1
- package/dist/commands/group/deletegroup.spec.js.map +1 -1
- package/dist/commands/group/getgroup.js +2 -0
- package/dist/commands/group/getgroup.js.map +1 -1
- package/dist/commands/group/listgroups.js +2 -0
- package/dist/commands/group/listgroups.js.map +1 -1
- package/dist/commands/group/removemember.js +3 -1
- package/dist/commands/group/removemember.js.map +1 -1
- package/dist/commands/group/removemember.spec.js +7 -2
- package/dist/commands/group/removemember.spec.js.map +1 -1
- package/dist/commands/groupaccesstoken/deleteToken.js +2 -1
- package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -1
- package/dist/commands/groupaccesstoken/groupContainer.js +2 -0
- package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -1
- package/dist/commands/list.js +24 -4
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/materialization/cancelrun.js +3 -1
- package/dist/commands/materialization/cancelrun.js.map +1 -1
- package/dist/commands/materialization/getindex.js +2 -0
- package/dist/commands/materialization/getindex.js.map +1 -1
- package/dist/commands/materialization/getmaterialization.js +2 -0
- package/dist/commands/materialization/getmaterialization.js.map +1 -1
- package/dist/commands/materialization/getpreaggregate.js +2 -0
- package/dist/commands/materialization/getpreaggregate.js.map +1 -1
- package/dist/commands/materialization/getrun.js +2 -0
- package/dist/commands/materialization/getrun.js.map +1 -1
- package/dist/commands/materialization/listindexes.js +2 -0
- package/dist/commands/materialization/listindexes.js.map +1 -1
- package/dist/commands/materialization/listmaterializations.js +2 -0
- package/dist/commands/materialization/listmaterializations.js.map +1 -1
- package/dist/commands/materialization/listpreaggregates.js +2 -0
- package/dist/commands/materialization/listpreaggregates.js.map +1 -1
- package/dist/commands/materialization/listruns.js +3 -1
- package/dist/commands/materialization/listruns.js.map +1 -1
- package/dist/commands/materialization/rerun.js +3 -1
- package/dist/commands/materialization/rerun.js.map +1 -1
- package/dist/commands/misc/inquirerHost.js +87 -0
- package/dist/commands/misc/inquirerHost.js.map +1 -0
- package/dist/commands/misc/inquirerHost.spec.js +91 -0
- package/dist/commands/misc/inquirerHost.spec.js.map +1 -0
- package/dist/commands/misc/login.js +348 -58
- package/dist/commands/misc/login.js.map +1 -1
- package/dist/commands/misc/login.spec.js +525 -7
- package/dist/commands/misc/login.spec.js.map +1 -1
- package/dist/commands/misc/logout.js +26 -3
- package/dist/commands/misc/logout.js.map +1 -1
- package/dist/commands/misc/logout.spec.js +52 -12
- package/dist/commands/misc/logout.spec.js.map +1 -1
- package/dist/commands/misc/resolveLoginTarget.spec.js +90 -0
- package/dist/commands/misc/resolveLoginTarget.spec.js.map +1 -0
- package/dist/commands/misc/scope.spec.js +108 -0
- package/dist/commands/misc/scope.spec.js.map +1 -0
- package/dist/commands/misc/set-access-token.js +1 -1
- package/dist/commands/misc/set-access-token.js.map +1 -1
- package/dist/commands/misc/set-access-token.spec.js +13 -2
- package/dist/commands/misc/set-access-token.spec.js.map +1 -1
- package/dist/commands/misc/setup.js +819 -0
- package/dist/commands/misc/setup.js.map +1 -0
- package/dist/commands/misc/setup.spec.js +783 -0
- package/dist/commands/misc/setup.spec.js.map +1 -0
- package/dist/commands/misc/status.js +168 -0
- package/dist/commands/misc/status.js.map +1 -0
- package/dist/commands/misc/status.spec.js +301 -0
- package/dist/commands/misc/status.spec.js.map +1 -0
- package/dist/commands/misc/token.js +57 -0
- package/dist/commands/misc/token.js.map +1 -0
- package/dist/commands/misc/token.spec.js +92 -0
- package/dist/commands/misc/token.spec.js.map +1 -0
- package/dist/commands/package/deletepackage.js +4 -2
- package/dist/commands/package/deletepackage.js.map +1 -1
- package/dist/commands/package/deletepackage.spec.js +7 -1
- package/dist/commands/package/deletepackage.spec.js.map +1 -1
- package/dist/commands/package/getpackage.js +142 -0
- package/dist/commands/package/getpackage.js.map +1 -0
- package/dist/commands/package/getpackage.spec.js +246 -0
- package/dist/commands/package/getpackage.spec.js.map +1 -0
- package/dist/commands/package/listpackages.js +2 -0
- package/dist/commands/package/listpackages.js.map +1 -1
- package/dist/commands/package/publish.archive.spec.js +570 -0
- package/dist/commands/package/publish.archive.spec.js.map +1 -0
- package/dist/commands/package/publish.js +780 -49
- package/dist/commands/package/publish.js.map +1 -1
- package/dist/commands/package/publish.spec.js +451 -8
- package/dist/commands/package/publish.spec.js.map +1 -1
- package/dist/commands/package/updatepackage.js +22 -19
- package/dist/commands/package/updatepackage.js.map +1 -1
- package/dist/commands/package/updatepackage.spec.js +36 -1
- package/dist/commands/package/updatepackage.spec.js.map +1 -1
- package/dist/commands/permission/createpermission.js +3 -1
- package/dist/commands/permission/createpermission.js.map +1 -1
- package/dist/commands/permission/deletepermission.js +6 -3
- package/dist/commands/permission/deletepermission.js.map +1 -1
- package/dist/commands/permission/getpermission.js +2 -0
- package/dist/commands/permission/getpermission.js.map +1 -1
- package/dist/commands/permission/listpermissions.js +2 -0
- package/dist/commands/permission/listpermissions.js.map +1 -1
- package/dist/commands/rm.js +21 -0
- package/dist/commands/rm.js.map +1 -1
- package/dist/commands/set.js +40 -6
- package/dist/commands/set.js.map +1 -1
- package/dist/commands/set.spec.js +123 -0
- package/dist/commands/set.spec.js.map +1 -0
- package/dist/commands/table/addtable.js +155 -0
- package/dist/commands/table/addtable.js.map +1 -0
- package/dist/commands/table/deletetable.js +45 -0
- package/dist/commands/table/deletetable.js.map +1 -0
- package/dist/commands/table/gettable.js +32 -0
- package/dist/commands/table/gettable.js.map +1 -0
- package/dist/commands/table/listtables.js +36 -0
- package/dist/commands/table/listtables.js.map +1 -0
- package/dist/commands/table/table.spec.js +304 -0
- package/dist/commands/table/table.spec.js.map +1 -0
- package/dist/commands/table/tablefile.js +195 -0
- package/dist/commands/table/tablefile.js.map +1 -0
- package/dist/commands/table/tablefile.spec.js +158 -0
- package/dist/commands/table/tablefile.spec.js.map +1 -0
- package/dist/commands/update.js +21 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.js +4 -2
- package/dist/commands/version/archive-unarchive-version.js.map +1 -1
- package/dist/commands/version/archive-unarchive-version.spec.js +6 -1
- package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -1
- package/dist/commands/version/listversions.js +2 -0
- package/dist/commands/version/listversions.js.map +1 -1
- package/dist/common/UserGroupId.js +9 -4
- package/dist/common/UserGroupId.js.map +1 -1
- package/dist/common/UserGroupId.spec.js +5 -0
- package/dist/common/UserGroupId.spec.js.map +1 -1
- package/dist/constants.js +37 -143
- package/dist/constants.js.map +1 -1
- package/dist/index.js +487 -90
- package/dist/index.js.map +1 -1
- package/dist/logger.js +42 -9
- package/dist/logger.js.map +1 -1
- package/dist/session.js +56 -0
- package/dist/session.js.map +1 -0
- package/dist/session.spec.js +103 -0
- package/dist/session.spec.js.map +1 -0
- package/dist/setup-core/briefing.js +176 -0
- package/dist/setup-core/briefing.js.map +1 -0
- package/dist/setup-core/credstore.js +415 -0
- package/dist/setup-core/credstore.js.map +1 -0
- package/dist/setup-core/credstore.spec.js +238 -0
- package/dist/setup-core/credstore.spec.js.map +1 -0
- package/dist/setup-core/environments.js +267 -0
- package/dist/setup-core/environments.js.map +1 -0
- package/dist/setup-core/flow.e2e.js +165 -0
- package/dist/setup-core/flow.e2e.js.map +1 -0
- package/dist/setup-core/flow.js +765 -0
- package/dist/setup-core/flow.js.map +1 -0
- package/dist/setup-core/flow.spec.js +1348 -0
- package/dist/setup-core/flow.spec.js.map +1 -0
- package/dist/setup-core/folderconfig.js +283 -0
- package/dist/setup-core/folderconfig.js.map +1 -0
- package/dist/setup-core/git.js +97 -0
- package/dist/setup-core/git.js.map +1 -0
- package/dist/setup-core/host.js +77 -0
- package/dist/setup-core/host.js.map +1 -0
- package/dist/setup-core/importconnections.js +470 -0
- package/dist/setup-core/importconnections.js.map +1 -0
- package/dist/setup-core/importconnections.spec.js +594 -0
- package/dist/setup-core/importconnections.spec.js.map +1 -0
- package/dist/setup-core/liveness.js +94 -0
- package/dist/setup-core/liveness.js.map +1 -0
- package/dist/setup-core/liveness.spec.js +59 -0
- package/dist/setup-core/liveness.spec.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.js +26 -0
- package/dist/setup-core/localpublisherconfig.js.map +1 -0
- package/dist/setup-core/localpublisherconfig.spec.js +29 -0
- package/dist/setup-core/localpublisherconfig.spec.js.map +1 -0
- package/dist/setup-core/mcpconfig.js +198 -0
- package/dist/setup-core/mcpconfig.js.map +1 -0
- package/dist/setup-core/mcpconfig.spec.js +205 -0
- package/dist/setup-core/mcpconfig.spec.js.map +1 -0
- package/dist/setup-core/packagemanifest.js +55 -0
- package/dist/setup-core/packagemanifest.js.map +1 -0
- package/dist/setup-core/ports.js +182 -0
- package/dist/setup-core/ports.js.map +1 -0
- package/dist/setup-core/ports.spec.js +173 -0
- package/dist/setup-core/ports.spec.js.map +1 -0
- package/dist/setup-core/publisherconfig.js +268 -0
- package/dist/setup-core/publisherconfig.js.map +1 -0
- package/dist/setup-core/publisherconfig.oracle.js +166 -0
- package/dist/setup-core/publisherconfig.oracle.js.map +1 -0
- package/dist/setup-core/publisherconfig.spec.js +277 -0
- package/dist/setup-core/publisherconfig.spec.js.map +1 -0
- package/dist/setup-core/publisherversion.js +26 -0
- package/dist/setup-core/publisherversion.js.map +1 -0
- package/dist/setup-core/readiness.spec.js +161 -0
- package/dist/setup-core/readiness.spec.js.map +1 -0
- package/dist/setup-core/readylines.js +169 -0
- package/dist/setup-core/readylines.js.map +1 -0
- package/dist/setup-core/readylines.spec.js +70 -0
- package/dist/setup-core/readylines.spec.js.map +1 -0
- package/dist/setup-core/refresh.js +348 -0
- package/dist/setup-core/refresh.js.map +1 -0
- package/dist/setup-core/refresh.spec.js +501 -0
- package/dist/setup-core/refresh.spec.js.map +1 -0
- package/dist/setup-core/skills.js +279 -0
- package/dist/setup-core/skills.js.map +1 -0
- package/dist/setup-core/skills.spec.js +334 -0
- package/dist/setup-core/skills.spec.js.map +1 -0
- package/dist/setup-core/supervisor.js +879 -0
- package/dist/setup-core/supervisor.js.map +1 -0
- package/dist/setup-core/supervisor.spec.js +833 -0
- package/dist/setup-core/supervisor.spec.js.map +1 -0
- package/dist/setup-core/writefile.js +61 -0
- package/dist/setup-core/writefile.js.map +1 -0
- package/dist/setup-core/writefile.spec.js +68 -0
- package/dist/setup-core/writefile.spec.js.map +1 -0
- package/dist/utils.js +409 -3
- package/dist/utils.js.map +1 -1
- package/dist/utils.spec.js +373 -2
- package/dist/utils.spec.js.map +1 -1
- package/dist/versioncheck-refresh.js +18 -0
- package/dist/versioncheck-refresh.js.map +1 -0
- package/dist/versioncheck.js +324 -0
- package/dist/versioncheck.js.map +1 -0
- package/dist/versioncheck.spec.js +587 -0
- package/dist/versioncheck.spec.js.map +1 -0
- package/node_modules/@credibledata/cli-auth/dist/index.d.ts +86 -0
- package/node_modules/@credibledata/cli-auth/dist/index.js +102 -0
- package/node_modules/@credibledata/cli-auth/package.json +19 -0
- package/package.json +18 -6
- package/.github/workflows/build.yml +0 -23
- package/.mocharc.json +0 -10
- package/.prettierignore +0 -2
- package/.prettierrc +0 -4
- package/README-DEV.md +0 -40
- package/coverage/coverage-summary.json +0 -40
- package/coverage/tmp/coverage-2152-1789496974457-0.json +0 -1
- package/coverage/tmp/coverage-2153-1789496954404-0.json +0 -1
- package/docker/Dockerfile.ci +0 -18
- package/docker-compose.yml +0 -18
- package/eslint.config.mjs +0 -45
- package/generate-client.sh +0 -27
- package/mocha.setup.ts +0 -4
- package/openapitools.json +0 -10
- package/src/client/.openapi-generator/FILES +0 -9
- package/src/client/.openapi-generator/VERSION +0 -1
- package/src/client/.openapi-generator-ignore +0 -23
- package/src/client/api.ts +0 -15999
- package/src/client/base.ts +0 -86
- package/src/client/common.ts +0 -150
- package/src/client/configuration.ts +0 -110
- package/src/client/git_push.sh +0 -57
- package/src/client/index.ts +0 -18
- package/src/clientconfiguration.spec.ts +0 -615
- package/src/clientconfiguration.ts +0 -364
- package/src/commands/add.ts +0 -191
- package/src/commands/connection/createconnections.spec.ts +0 -413
- package/src/commands/connection/createconnections.ts +0 -109
- package/src/commands/connection/deleteconnection.spec.ts +0 -189
- package/src/commands/connection/deleteconnection.ts +0 -57
- package/src/commands/connection/listconnections.spec.ts +0 -132
- package/src/commands/connection/listconnections.ts +0 -58
- package/src/commands/environment/createenvironment.spec.ts +0 -249
- package/src/commands/environment/createenvironment.ts +0 -73
- package/src/commands/environment/deleteenvironment.spec.ts +0 -152
- package/src/commands/environment/deleteenvironment.ts +0 -48
- package/src/commands/environment/getenvironment.spec.ts +0 -110
- package/src/commands/environment/getenvironment.ts +0 -43
- package/src/commands/environment/listenvironments.spec.ts +0 -123
- package/src/commands/environment/listenvironments.ts +0 -67
- package/src/commands/environment/setenvironment.spec.ts +0 -63
- package/src/commands/environment/setenvironment.ts +0 -14
- package/src/commands/environment/updateenvironment.spec.ts +0 -386
- package/src/commands/environment/updateenvironment.ts +0 -168
- package/src/commands/get.ts +0 -153
- package/src/commands/group/addmember.spec.ts +0 -257
- package/src/commands/group/addmember.ts +0 -85
- package/src/commands/group/creategroup.spec.ts +0 -146
- package/src/commands/group/creategroup.ts +0 -54
- package/src/commands/group/deletegroup.spec.ts +0 -120
- package/src/commands/group/deletegroup.ts +0 -45
- package/src/commands/group/getgroup.spec.ts +0 -129
- package/src/commands/group/getgroup.ts +0 -47
- package/src/commands/group/listgroups.spec.ts +0 -137
- package/src/commands/group/listgroups.ts +0 -45
- package/src/commands/group/removemember.spec.ts +0 -224
- package/src/commands/group/removemember.ts +0 -75
- package/src/commands/groupaccesstoken/createToken.spec.ts +0 -211
- package/src/commands/groupaccesstoken/createToken.ts +0 -72
- package/src/commands/groupaccesstoken/deleteToken.spec.ts +0 -147
- package/src/commands/groupaccesstoken/deleteToken.ts +0 -29
- package/src/commands/groupaccesstoken/groupContainer.ts +0 -83
- package/src/commands/groupaccesstoken/listTokens.spec.ts +0 -147
- package/src/commands/groupaccesstoken/listTokens.ts +0 -29
- package/src/commands/legacy.ts +0 -5
- package/src/commands/list.ts +0 -326
- package/src/commands/materialization/cancelrun.ts +0 -70
- package/src/commands/materialization/getindex.ts +0 -55
- package/src/commands/materialization/getmaterialization.ts +0 -57
- package/src/commands/materialization/getpreaggregate.ts +0 -58
- package/src/commands/materialization/getrun.ts +0 -55
- package/src/commands/materialization/listindexes.ts +0 -69
- package/src/commands/materialization/listmaterializations.ts +0 -53
- package/src/commands/materialization/listpreaggregates.ts +0 -74
- package/src/commands/materialization/listruns.ts +0 -77
- package/src/commands/materialization/rerun.ts +0 -123
- package/src/commands/misc/login.spec.ts +0 -371
- package/src/commands/misc/login.ts +0 -343
- package/src/commands/misc/logout.spec.ts +0 -32
- package/src/commands/misc/logout.ts +0 -9
- package/src/commands/misc/loopbackOAuth.ts +0 -127
- package/src/commands/misc/set-access-token.spec.ts +0 -95
- package/src/commands/misc/set-access-token.ts +0 -32
- package/src/commands/package/deletepackage.spec.ts +0 -164
- package/src/commands/package/deletepackage.ts +0 -58
- package/src/commands/package/listpackages.spec.ts +0 -163
- package/src/commands/package/listpackages.ts +0 -74
- package/src/commands/package/publish.spec.ts +0 -642
- package/src/commands/package/publish.ts +0 -236
- package/src/commands/package/updatepackage.spec.ts +0 -319
- package/src/commands/package/updatepackage.ts +0 -95
- package/src/commands/permission/createpermission.spec.ts +0 -507
- package/src/commands/permission/createpermission.ts +0 -181
- package/src/commands/permission/deletepermission.ts +0 -117
- package/src/commands/permission/getpermission.ts +0 -115
- package/src/commands/permission/listpermissions.ts +0 -101
- package/src/commands/permission/scope.ts +0 -180
- package/src/commands/rm.ts +0 -146
- package/src/commands/set.ts +0 -25
- package/src/commands/update.ts +0 -107
- package/src/commands/version/archive-unarchive-version.spec.ts +0 -456
- package/src/commands/version/archive-unarchive-version.ts +0 -108
- package/src/commands/version/listversions.spec.ts +0 -138
- package/src/commands/version/listversions.ts +0 -45
- package/src/common/UserGroupId.spec.ts +0 -115
- package/src/common/UserGroupId.ts +0 -137
- package/src/constants.spec.ts +0 -111
- package/src/constants.ts +0 -228
- package/src/index.ts +0 -378
- package/src/logger.spec.ts +0 -158
- package/src/logger.ts +0 -90
- package/src/polyfills/file.polyfill.ts +0 -6
- package/src/utils.spec.ts +0 -135
- package/src/utils.ts +0 -115
- package/src/validator.spec.ts +0 -51
- package/src/validator.ts +0 -44
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.isPublisherServing = isPublisherServing;
|
|
16
|
+
exports.countServedPackages = countServedPackages;
|
|
17
|
+
const http_1 = __importDefault(require("http"));
|
|
18
|
+
/**
|
|
19
|
+
* Is a local Publisher answering on this port?
|
|
20
|
+
*
|
|
21
|
+
* The question `cred status` answers for an agent that started `cred dev` in
|
|
22
|
+
* the background and needs to know when to start calling tools. A bound port
|
|
23
|
+
* is not the signal (see `readylines.ts`): the REST API answering is. One GET
|
|
24
|
+
* with a short deadline, because the caller is polling.
|
|
25
|
+
*/
|
|
26
|
+
function isPublisherServing(uiPort_1) {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (uiPort, timeoutMs = 1000) {
|
|
28
|
+
// A JSON array, not just a 200: a dev server with an SPA fallback answers
|
|
29
|
+
// every path with 200 and would read as a publisher.
|
|
30
|
+
return Array.isArray(yield getJson(uiPort, "/api/v0/environments", timeoutMs));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* How many packages the local Publisher is serving, or null when it does not
|
|
35
|
+
* answer. Distinct from {@link isPublisherServing}: a server whose only package
|
|
36
|
+
* failed to compile answers every request and serves nothing — the
|
|
37
|
+
* `PUBLISHER_READY … packages=0 load_errors=1` case — and an agent that starts
|
|
38
|
+
* calling tools on `running` alone gets "no such package" for every one.
|
|
39
|
+
*/
|
|
40
|
+
function countServedPackages(uiPort_1) {
|
|
41
|
+
return __awaiter(this, arguments, void 0, function* (uiPort, environment = "default", timeoutMs = 1000) {
|
|
42
|
+
// Name comes from .credible/config.json: compare it, never put it in the
|
|
43
|
+
// path (CodeQL js/file-access-to-http). The listing carries each
|
|
44
|
+
// environment's packages, so one fixed request answers it.
|
|
45
|
+
const environments = yield getJson(uiPort, "/api/v0/environments", timeoutMs);
|
|
46
|
+
if (!Array.isArray(environments))
|
|
47
|
+
return null;
|
|
48
|
+
const match = environments.find((entry) => (entry === null || entry === void 0 ? void 0 : entry.name) === environment);
|
|
49
|
+
return Array.isArray(match === null || match === void 0 ? void 0 : match.packages) ? match.packages.length : null;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** GET a path on the local publisher as JSON, or null for any failure. */
|
|
53
|
+
function getJson(uiPort, requestPath, timeoutMs) {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
let request;
|
|
56
|
+
try {
|
|
57
|
+
request = http_1.default.get({
|
|
58
|
+
host: "127.0.0.1",
|
|
59
|
+
port: uiPort,
|
|
60
|
+
path: requestPath,
|
|
61
|
+
timeout: timeoutMs,
|
|
62
|
+
}, (response) => {
|
|
63
|
+
if (response.statusCode !== 200) {
|
|
64
|
+
response.resume();
|
|
65
|
+
resolve(null);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let body = "";
|
|
69
|
+
response.setEncoding("utf-8");
|
|
70
|
+
response.on("data", (chunk) => (body += chunk));
|
|
71
|
+
response.on("end", () => {
|
|
72
|
+
try {
|
|
73
|
+
resolve(JSON.parse(body));
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
resolve(null);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (_a) {
|
|
82
|
+
// `http.get` throws synchronously on a path it will not send, such as
|
|
83
|
+
// one with a space; "null for any failure" covers that too.
|
|
84
|
+
resolve(null);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
request.on("timeout", () => {
|
|
88
|
+
request.destroy();
|
|
89
|
+
resolve(null);
|
|
90
|
+
});
|
|
91
|
+
request.on("error", () => resolve(null));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=liveness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveness.js","sourceRoot":"","sources":["../../src/setup-core/liveness.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAUA,gDASC;AASD,kDAgBC;AA5CD,gDAAwB;AAExB;;;;;;;GAOG;AACH,SAAsB,kBAAkB;yDACrC,MAAc,EACd,SAAS,GAAG,IAAI;QAEhB,0EAA0E;QAC1E,qDAAqD;QACrD,OAAO,KAAK,CAAC,OAAO,CACjB,MAAM,OAAO,CAAC,MAAM,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAC1D,CAAC;IACL,CAAC;CAAA;AAED;;;;;;GAMG;AACH,S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,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC;gBAChD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;oBACrB,IAAI,CAAC;wBACF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC7B,CAAC;oBAAC,WAAM,CAAC;wBACN,OAAO,CAAC,IAAI,CAAC,CAAC;oBACjB,CAAC;gBACJ,CAAC,CAAC,CAAC;YACN,CAAC,CACH,CAAC;QACL,CAAC;QAAC,WAAM,CAAC;YACN,sEAAsE;YACtE,4DAA4D;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;QACV,CAAC;QACD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACxB,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const chai_1 = require("chai");
|
|
16
|
+
const http_1 = __importDefault(require("http"));
|
|
17
|
+
const liveness_1 = require("./liveness");
|
|
18
|
+
describe("countServedPackages", () => {
|
|
19
|
+
let server;
|
|
20
|
+
let port;
|
|
21
|
+
const requested = [];
|
|
22
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
server = http_1.default.createServer((request, response) => {
|
|
24
|
+
requested.push(String(request.url));
|
|
25
|
+
response.setHeader("content-type", "application/json");
|
|
26
|
+
if (request.url === "/api/v0/environments") {
|
|
27
|
+
response.end(JSON.stringify([
|
|
28
|
+
{
|
|
29
|
+
name: "analytics-local",
|
|
30
|
+
resource: "/api/v0/environments/analytics-local",
|
|
31
|
+
packages: [{ name: "a" }, { name: "b" }],
|
|
32
|
+
},
|
|
33
|
+
]));
|
|
34
|
+
}
|
|
35
|
+
else if (request.url === "/api/v0/environments/analytics-local/packages") {
|
|
36
|
+
response.end(JSON.stringify([{ name: "a" }, { name: "b" }]));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
response.statusCode = 404;
|
|
40
|
+
response.end("[]");
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
yield new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
44
|
+
port = server.address().port;
|
|
45
|
+
}));
|
|
46
|
+
after(() => server.close());
|
|
47
|
+
beforeEach(() => (requested.length = 0));
|
|
48
|
+
it("counts the named environment's packages from the one listing", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
(0, chai_1.expect)(yield (0, liveness_1.countServedPackages)(port, "analytics-local")).to.equal(2);
|
|
50
|
+
(0, chai_1.expect)(requested).to.eql(["/api/v0/environments"]);
|
|
51
|
+
}));
|
|
52
|
+
// The name is read from `.credible/config.json`. It is only compared with
|
|
53
|
+
// the server's listing, never spliced into a request path.
|
|
54
|
+
it("never puts the given name in a request path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
(0, chai_1.expect)(yield (0, liveness_1.countServedPackages)(port, "../../etc")).to.equal(null);
|
|
56
|
+
(0, chai_1.expect)(requested).to.eql(["/api/v0/environments"]);
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=liveness.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveness.spec.js","sourceRoot":"","sources":["../../src/setup-core/liveness.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,gDAAwB;AAExB,yCAAiD;AAEjD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAClC,IAAI,MAAmB,CAAC;IACxB,IAAI,IAAY,CAAC;IACjB,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,MAAM,CAAC,GAAS,EAAE;QACf,MAAM,GAAG,cAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YAC9C,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YACpC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;YACvD,IAAI,OAAO,CAAC,GAAG,KAAK,sBAAsB,EAAE,CAAC;gBAC1C,QAAQ,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CAAC;oBACZ;wBACG,IAAI,EAAE,iBAAiB;wBACvB,QAAQ,EAAE,sCAAsC;wBAChD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;qBAC1C;iBACH,CAAC,CACJ,CAAC;YACL,CAAC;iBAAM,IACJ,OAAO,CAAC,GAAG,KAAK,+CAA+C,EAChE,CAAC;gBACA,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C,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;IACtD,CAAC,CAAA,CAAC,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readLocalPublisherConfig = readLocalPublisherConfig;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* The parsed `<directory>/publisher.config.json` the user keeps there, or
|
|
11
|
+
* undefined when it is absent or not JSON.
|
|
12
|
+
*
|
|
13
|
+
* One reader for every place that looks at this file (the connections setup
|
|
14
|
+
* can import, the packages it lists, the retrieval block `cred dev` carries),
|
|
15
|
+
* so they agree on what "unreadable" means: nothing to read, and not an error.
|
|
16
|
+
* A caller that must say why asks for the reason itself.
|
|
17
|
+
*/
|
|
18
|
+
function readLocalPublisherConfig(directory) {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(fs_1.default.readFileSync(path_1.default.join(directory, "publisher.config.json"), "utf-8"));
|
|
21
|
+
}
|
|
22
|
+
catch (_a) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=localpublisherconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localpublisherconfig.js","sourceRoot":"","sources":["../../src/setup-core/localpublisherconfig.ts"],"names":[],"mappings":";;;;;AAYA,4DAWC;AAvBD,4CAAoB;AACpB,gDAAwB;AAExB;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,SAAiB;IACvD,IAAI,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CACd,YAAE,CAAC,YAAY,CACZ,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,uBAAuB,CAAC,EAC7C,OAAO,CACT,CACH,CAAC;IACL,CAAC;IAAC,WAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const chai_1 = require("chai");
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const localpublisherconfig_1 = require("./localpublisherconfig");
|
|
11
|
+
describe("readLocalPublisherConfig", () => {
|
|
12
|
+
let dir;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
dir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "local-config-"));
|
|
15
|
+
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
fs_1.default.rmSync(dir, { recursive: true, force: true });
|
|
18
|
+
});
|
|
19
|
+
it("returns the parsed file", () => {
|
|
20
|
+
fs_1.default.writeFileSync(path_1.default.join(dir, "publisher.config.json"), JSON.stringify({ environments: [] }));
|
|
21
|
+
(0, chai_1.expect)((0, localpublisherconfig_1.readLocalPublisherConfig)(dir)).to.eql({ environments: [] });
|
|
22
|
+
});
|
|
23
|
+
it("returns undefined for a missing file and for one that is not JSON", () => {
|
|
24
|
+
(0, chai_1.expect)((0, localpublisherconfig_1.readLocalPublisherConfig)(dir)).to.equal(undefined);
|
|
25
|
+
fs_1.default.writeFileSync(path_1.default.join(dir, "publisher.config.json"), "{ nope");
|
|
26
|
+
(0, chai_1.expect)((0, localpublisherconfig_1.readLocalPublisherConfig)(dir)).to.equal(undefined);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=localpublisherconfig.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localpublisherconfig.spec.js","sourceRoot":"","sources":["../../src/setup-core/localpublisherconfig.spec.ts"],"names":[],"mappings":";;;;;AAAA,+BAA8B;AAC9B,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,iEAAkE;AAElE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACvC,IAAI,GAAW,CAAC;IAChB,UAAU,CAAC,GAAG,EAAE;QACb,GAAG,GAAG,YAAE,CAAC,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACZ,YAAE,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QAChC,YAAE,CAAC,aAAa,CACb,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,EACvC,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CACtC,CAAC;QACF,IAAA,aAAM,EAAC,IAAA,+CAAwB,EAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC1E,IAAA,aAAM,EAAC,IAAA,+CAAwB,EAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,EAAE,QAAQ,CAAC,CAAC;QACpE,IAAA,aAAM,EAAC,IAAA,+CAAwB,EAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RETIRED_SERVER_NAMES = exports.OWNED_SERVER_NAMES = exports.REMOTE_SERVER_NAME = exports.LOCAL_SERVER_NAME = exports.MCP_CONFIG_FILENAME = void 0;
|
|
7
|
+
exports.localPublisherUrl = localPublisherUrl;
|
|
8
|
+
exports.remoteCredibleUrl = remoteCredibleUrl;
|
|
9
|
+
exports.writeMcpConfig = writeMcpConfig;
|
|
10
|
+
exports.detectIndent = detectIndent;
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const writefile_1 = require("./writefile");
|
|
14
|
+
/**
|
|
15
|
+
* Writing `.mcp.json` — the file that points an agent at both the local
|
|
16
|
+
* Publisher and the Credible cloud tools.
|
|
17
|
+
*
|
|
18
|
+
* ## Why we write it and the server does not
|
|
19
|
+
*
|
|
20
|
+
* The Publisher server writes `.mcp.json` itself on boot, but deliberately skips
|
|
21
|
+
* when the working directory is inside a git working tree — which describes
|
|
22
|
+
* essentially every real modeling directory, since model code that matters to
|
|
23
|
+
* anyone is under version control. So the skip is the normal case, not the edge
|
|
24
|
+
* case, and setup owns the file.
|
|
25
|
+
*
|
|
26
|
+
* ## Why the local URL is an IP literal and the browser URL is not
|
|
27
|
+
*
|
|
28
|
+
* `127.0.0.1`, never `localhost`, for the MCP entry. `localhost` resolves to both
|
|
29
|
+
* loopback families while the server binds only one, so another local process can
|
|
30
|
+
* hold the same port on the other family and receive the agent's traffic instead.
|
|
31
|
+
* Upstream reproduced this 3/3 and its own config writer uses the literal.
|
|
32
|
+
*
|
|
33
|
+
* The browser URL stays `localhost` because that is what a human recognises,
|
|
34
|
+
* copies, and bookmarks, and browsers already fall back across families.
|
|
35
|
+
*/
|
|
36
|
+
exports.MCP_CONFIG_FILENAME = ".mcp.json";
|
|
37
|
+
/** The name of the local Publisher entry. Matches what upstream writes. */
|
|
38
|
+
exports.LOCAL_SERVER_NAME = "malloy";
|
|
39
|
+
/** The name of the Credible cloud entry: the analysis tools over the published model. */
|
|
40
|
+
exports.REMOTE_SERVER_NAME = "credible";
|
|
41
|
+
/** Every key this writer owns, and therefore overwrites. */
|
|
42
|
+
exports.OWNED_SERVER_NAMES = [exports.LOCAL_SERVER_NAME, exports.REMOTE_SERVER_NAME];
|
|
43
|
+
/**
|
|
44
|
+
* Entries setup used to write and now removes.
|
|
45
|
+
*
|
|
46
|
+
* `credible-modeling` pointed at `/mcp/modeling` for `search_database_schema`
|
|
47
|
+
* over the indexed warehouse schema. Two reasons it is gone: the local
|
|
48
|
+
* publisher serves `search_database_schema` itself, walking the live schema
|
|
49
|
+
* through the proxy, so a modeling directory already has schema search; and the
|
|
50
|
+
* other tool on that mount, `search_modeling_suggestions`, has nothing useful
|
|
51
|
+
* to return today. What it cost was real — a third server whose tool names
|
|
52
|
+
* collide with both of the others, so every schema lookup became a choice the
|
|
53
|
+
* agent had to get right.
|
|
54
|
+
*
|
|
55
|
+
* Listed rather than simply deleted because a directory wired by an earlier
|
|
56
|
+
* build already carries the entry, and a name this writer no longer owns would
|
|
57
|
+
* be *preserved* forever. Removing it here means the next `cred init` or
|
|
58
|
+
* `cred dev` cleans it up. Only when its URL is the one we wrote (a path
|
|
59
|
+
* ending `/mcp/modeling`): a server of the user's own under the same name is
|
|
60
|
+
* theirs, and is kept.
|
|
61
|
+
*/
|
|
62
|
+
exports.RETIRED_SERVER_NAMES = ["credible-modeling"];
|
|
63
|
+
/** Is this entry the one an earlier `cred init` wrote under a retired name? */
|
|
64
|
+
function isRetiredEntry(entry) {
|
|
65
|
+
const url = entry === null || entry === void 0 ? void 0 : entry.url;
|
|
66
|
+
if (typeof url !== "string")
|
|
67
|
+
return false;
|
|
68
|
+
try {
|
|
69
|
+
return new URL(url).pathname.replace(/\/$/, "").endsWith("/mcp/modeling");
|
|
70
|
+
}
|
|
71
|
+
catch (_a) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** MCP host per deployment env, for the org-scoped remote endpoint. */
|
|
76
|
+
const MCP_HOSTS = {
|
|
77
|
+
production: (org) => `https://${org}.mcp.credibledata.com`,
|
|
78
|
+
// The AWS cell composes every public hostname onto its own delegated domain
|
|
79
|
+
// (`legacy_domain_base` in `infrastructure/environments/aws/videoamp/prod/
|
|
80
|
+
// env.hcl`, which `legacy_is_canonical` makes canonical), so this is NOT the
|
|
81
|
+
// production host with a different org in front. Copying production's line
|
|
82
|
+
// here is the omission the data-plane map below already carries a warning
|
|
83
|
+
// about, and it points a videoamp user's `.mcp.json` at the GCP cell.
|
|
84
|
+
videoamp: (org) => `https://${org}.mcp.videoamp-aws-us-east-1.credibledata.com`,
|
|
85
|
+
staging: (org) => `https://${org}.staging-mcp.credibledata.com`,
|
|
86
|
+
dev: (org) => `https://${org}.dev-mcp.credibledata.com`,
|
|
87
|
+
localhost: (org) => `http://${org}.mcp.credibledata.localhost:8000`,
|
|
88
|
+
"aws-dev": (org) => `https://${org}.aws-dev-mcp.credibledata.com`,
|
|
89
|
+
"aws-dev-2": (org) => `https://${org}.aws-dev-2-mcp.credibledata.com`,
|
|
90
|
+
"aws-affinity": (org) => `https://${org}.aws-affinity-mcp.credibledata.com`,
|
|
91
|
+
"e2e-test": (org) => `http://${org}.mcp.credibledata.localhost:8000`,
|
|
92
|
+
};
|
|
93
|
+
function localPublisherUrl(mcpPort) {
|
|
94
|
+
return `http://127.0.0.1:${mcpPort}/mcp`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The org-scoped remote MCP URL.
|
|
98
|
+
*
|
|
99
|
+
* `docs/mcp-global-endpoint-and-install-design.md` makes
|
|
100
|
+
* `https://mcp.credibledata.com/mcp` the canonical URL that docs lead with, and
|
|
101
|
+
* reframes the org-scoped host as a deliberate scope-down. Setup uses the
|
|
102
|
+
* scoped one *because* it already knows the organization: scoping down here
|
|
103
|
+
* removes the orientation tax that doc names as problem #1, where the agent
|
|
104
|
+
* burns two or three discovery calls before its first useful one.
|
|
105
|
+
*/
|
|
106
|
+
function remoteCredibleUrl(deployment, organization) {
|
|
107
|
+
return `${MCP_HOSTS[deployment](organization)}/mcp`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Merge our two entries into `<directory>/.mcp.json`, preserving everything else.
|
|
111
|
+
*
|
|
112
|
+
* Merge rather than create-or-replace, for two reasons that pull in opposite
|
|
113
|
+
* directions and both matter:
|
|
114
|
+
*
|
|
115
|
+
* - a user's own MCP servers in this file must survive `cred init`, so we only
|
|
116
|
+
* ever touch the keys we own, plus the ones we used to own and now remove;
|
|
117
|
+
* - our own entries must be *overwritten*, not preserved, because the port
|
|
118
|
+
* can legitimately change between runs and a stale local URL is the silent
|
|
119
|
+
* failure this whole file exists to avoid.
|
|
120
|
+
*
|
|
121
|
+
* No token is ever written. The local server needs none, and the remote one is
|
|
122
|
+
* reached with the client's own OAuth.
|
|
123
|
+
*/
|
|
124
|
+
function writeMcpConfig(options) {
|
|
125
|
+
var _a;
|
|
126
|
+
const filePath = path_1.default.join(options.directory, exports.MCP_CONFIG_FILENAME);
|
|
127
|
+
let existing = {};
|
|
128
|
+
let existingRaw;
|
|
129
|
+
let unmergeable = false;
|
|
130
|
+
try {
|
|
131
|
+
existingRaw = fs_1.default.readFileSync(filePath, "utf-8");
|
|
132
|
+
// Strip a leading byte-order mark before parsing. `JSON.parse` rejects
|
|
133
|
+
// one, but it is what Windows editors and PowerShell's `Out-File` write
|
|
134
|
+
// by default, and the agents that read this file accept it — so without
|
|
135
|
+
// this the file is valid to its actual consumer and unparseable to us.
|
|
136
|
+
const parsed = JSON.parse(existingRaw.replace(/^\uFEFF/, ""));
|
|
137
|
+
// A file whose top level is not an object (an array, a bare string)
|
|
138
|
+
// cannot be merged into.
|
|
139
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
140
|
+
existing = parsed;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
unmergeable = true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (_b) {
|
|
147
|
+
// Missing, or present and unparseable. Only the second is a problem: the
|
|
148
|
+
// merge below is `{...existing, mcpServers}`, so proceeding with an empty
|
|
149
|
+
// `existing` does not just skip the file, it overwrites it — dropping
|
|
150
|
+
// every server the user configured themselves.
|
|
151
|
+
unmergeable = existingRaw !== undefined && existingRaw.trim() !== "";
|
|
152
|
+
}
|
|
153
|
+
// Keep a copy of anything we are about to replace but could not read. The
|
|
154
|
+
// rewrite still happens — setup's job is to leave a working `.mcp.json`
|
|
155
|
+
// behind — but the user's own entries remain recoverable, and the caller
|
|
156
|
+
// says where they went.
|
|
157
|
+
// A fresh name each time: an earlier run's `.bak` is the only copy of
|
|
158
|
+
// whatever that run could not read, and overwriting it lost that silently.
|
|
159
|
+
let displaced;
|
|
160
|
+
if (unmergeable && existingRaw !== undefined) {
|
|
161
|
+
displaced = `${filePath}.bak`;
|
|
162
|
+
for (let n = 1; fs_1.default.existsSync(displaced); n += 1) {
|
|
163
|
+
displaced = `${filePath}.bak.${n}`;
|
|
164
|
+
}
|
|
165
|
+
(0, writefile_1.writeFileAtomic)(displaced, existingRaw);
|
|
166
|
+
}
|
|
167
|
+
const servers = Object.assign({}, ((_a = existing.mcpServers) !== null && _a !== void 0 ? _a : {}));
|
|
168
|
+
// Ours to remove, not to preserve: see RETIRED_SERVER_NAMES.
|
|
169
|
+
const retired = exports.RETIRED_SERVER_NAMES.filter((name) => name in servers && isRetiredEntry(servers[name]));
|
|
170
|
+
const preserved = Object.keys(servers).filter((name) => !exports.OWNED_SERVER_NAMES.includes(name) && !retired.includes(name));
|
|
171
|
+
for (const name of retired) {
|
|
172
|
+
delete servers[name];
|
|
173
|
+
}
|
|
174
|
+
servers[exports.LOCAL_SERVER_NAME] = {
|
|
175
|
+
type: "http",
|
|
176
|
+
url: localPublisherUrl(options.mcpPort),
|
|
177
|
+
};
|
|
178
|
+
servers[exports.REMOTE_SERVER_NAME] = {
|
|
179
|
+
type: "http",
|
|
180
|
+
url: remoteCredibleUrl(options.deployment, options.organization),
|
|
181
|
+
};
|
|
182
|
+
const merged = Object.assign(Object.assign({}, existing), { mcpServers: servers });
|
|
183
|
+
// The file's own indentation, so merging into a committed `.mcp.json`
|
|
184
|
+
// changes the lines that changed rather than every line. Two spaces for a
|
|
185
|
+
// new file, as Claude Code writes it.
|
|
186
|
+
const content = `${JSON.stringify(merged, null, detectIndent(existingRaw))}\n`;
|
|
187
|
+
if (existingRaw === content) {
|
|
188
|
+
return { filePath, changed: false, preserved, retired, displaced };
|
|
189
|
+
}
|
|
190
|
+
(0, writefile_1.writeFileAtomic)(filePath, content);
|
|
191
|
+
return { filePath, changed: true, preserved, retired, displaced };
|
|
192
|
+
}
|
|
193
|
+
/** The indentation of the first indented line, or two spaces. */
|
|
194
|
+
function detectIndent(text) {
|
|
195
|
+
const match = /^([ \t]+)\S/m.exec(text !== null && text !== void 0 ? text : "");
|
|
196
|
+
return match ? match[1] : " ";
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=mcpconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpconfig.js","sourceRoot":"","sources":["../../src/setup-core/mcpconfig.ts"],"names":[],"mappings":";;;;;;AAmGA,8CAEC;AAYD,8CAKC;AAwCD,wCAkFC;AAGD,oCAGC;AAtPD,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
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const chai_1 = require("chai");
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const mcpconfig_1 = require("./mcpconfig");
|
|
11
|
+
describe("writeMcpConfig", () => {
|
|
12
|
+
let directory;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
directory = fs_1.default.mkdtempSync((0, path_1.join)(os_1.default.tmpdir(), "mcpconfig-"));
|
|
15
|
+
});
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
fs_1.default.rmSync(directory, { recursive: true, force: true });
|
|
18
|
+
});
|
|
19
|
+
const options = {
|
|
20
|
+
mcpPort: 4040,
|
|
21
|
+
deployment: "production",
|
|
22
|
+
organization: "acme",
|
|
23
|
+
};
|
|
24
|
+
function read() {
|
|
25
|
+
return JSON.parse(fs_1.default.readFileSync((0, path_1.join)(directory, ".mcp.json"), "utf-8"));
|
|
26
|
+
}
|
|
27
|
+
// A committed `.mcp.json` re-indented on merge showed every line as
|
|
28
|
+
// changed in the user's diff.
|
|
29
|
+
it("keeps the file's own indentation, and uses two spaces for a new file", () => {
|
|
30
|
+
const file = (0, path_1.join)(directory, ".mcp.json");
|
|
31
|
+
fs_1.default.writeFileSync(file, '{\n "mcpServers": {\n "mine": { "type": "http", "url": "http://x" }\n }\n}\n');
|
|
32
|
+
(0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
33
|
+
(0, chai_1.expect)(fs_1.default.readFileSync(file, "utf-8")).to.match(/^\{\n {4}"mcpServers"/);
|
|
34
|
+
fs_1.default.rmSync(file);
|
|
35
|
+
(0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
36
|
+
(0, chai_1.expect)(fs_1.default.readFileSync(file, "utf-8")).to.match(/^\{\n {2}"mcpServers"/);
|
|
37
|
+
});
|
|
38
|
+
it("writes the two entries with no token anywhere", () => {
|
|
39
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
40
|
+
(0, chai_1.expect)(result.changed).to.equal(true);
|
|
41
|
+
const config = read();
|
|
42
|
+
(0, chai_1.expect)(config.mcpServers).to.eql({
|
|
43
|
+
malloy: { type: "http", url: "http://127.0.0.1:4040/mcp" },
|
|
44
|
+
credible: {
|
|
45
|
+
type: "http",
|
|
46
|
+
url: "https://acme.mcp.credibledata.com/mcp",
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
// The local server needs no auth; the remote one uses the client's own
|
|
50
|
+
// OAuth. A token in this file would be the invariant this design keeps.
|
|
51
|
+
(0, chai_1.expect)(fs_1.default.readFileSync((0, path_1.join)(directory, ".mcp.json"), "utf-8")).to.not.match(/token/i);
|
|
52
|
+
});
|
|
53
|
+
it("uses the IP literal for the local server, never localhost", () => {
|
|
54
|
+
// `localhost` resolves to both loopback families while the server binds
|
|
55
|
+
// one, so another process can hold the same port on the other family and
|
|
56
|
+
// receive the agent's traffic.
|
|
57
|
+
(0, chai_1.expect)((0, mcpconfig_1.localPublisherUrl)(4040)).to.equal("http://127.0.0.1:4040/mcp");
|
|
58
|
+
(0, chai_1.expect)((0, mcpconfig_1.localPublisherUrl)(4040)).to.not.contain("localhost");
|
|
59
|
+
});
|
|
60
|
+
// The whole reason `credible-modeling` is listed rather than deleted from
|
|
61
|
+
// the source: a name this writer no longer owns would otherwise be
|
|
62
|
+
// *preserved*, so the first users would carry the retired entry forever —
|
|
63
|
+
// and an agent would keep choosing between two `search_database_schema`s.
|
|
64
|
+
it("removes the retired credible-modeling entry instead of preserving it", () => {
|
|
65
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), JSON.stringify({
|
|
66
|
+
mcpServers: {
|
|
67
|
+
"credible-modeling": {
|
|
68
|
+
type: "http",
|
|
69
|
+
url: "https://acme.mcp.credibledata.com/mcp/modeling",
|
|
70
|
+
},
|
|
71
|
+
mine: { type: "http", url: "http://example" },
|
|
72
|
+
},
|
|
73
|
+
}));
|
|
74
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
75
|
+
(0, chai_1.expect)(result.retired).to.eql(["credible-modeling"]);
|
|
76
|
+
(0, chai_1.expect)(result.preserved).to.eql(["mine"]);
|
|
77
|
+
(0, chai_1.expect)(Object.keys(read().mcpServers).sort()).to.eql([
|
|
78
|
+
"credible",
|
|
79
|
+
"malloy",
|
|
80
|
+
"mine",
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
83
|
+
// Retired by name alone, a user's own server called credible-modeling was
|
|
84
|
+
// deleted.
|
|
85
|
+
it("keeps a credible-modeling entry that is not the one setup wrote", () => {
|
|
86
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), JSON.stringify({
|
|
87
|
+
mcpServers: {
|
|
88
|
+
"credible-modeling": { type: "http", url: "http://mine/mcp" },
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
92
|
+
(0, chai_1.expect)(result.retired).to.eql([]);
|
|
93
|
+
(0, chai_1.expect)(result.preserved).to.eql(["credible-modeling"]);
|
|
94
|
+
(0, chai_1.expect)(read().mcpServers["credible-modeling"].url).to.equal("http://mine/mcp");
|
|
95
|
+
});
|
|
96
|
+
it("reports nothing retired when the file never had it", () => {
|
|
97
|
+
(0, chai_1.expect)((0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options)).retired).to.eql([]);
|
|
98
|
+
});
|
|
99
|
+
it("preserves MCP servers it does not own", () => {
|
|
100
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), JSON.stringify({
|
|
101
|
+
mcpServers: {
|
|
102
|
+
"my-own-thing": { type: "http", url: "http://example.com/mcp" },
|
|
103
|
+
},
|
|
104
|
+
}));
|
|
105
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
106
|
+
(0, chai_1.expect)(result.preserved).to.eql(["my-own-thing"]);
|
|
107
|
+
(0, chai_1.expect)(read().mcpServers["my-own-thing"]).to.eql({
|
|
108
|
+
type: "http",
|
|
109
|
+
url: "http://example.com/mcp",
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
it("preserves unrelated top-level keys", () => {
|
|
113
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), JSON.stringify({ someOtherSetting: true }));
|
|
114
|
+
(0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
115
|
+
(0, chai_1.expect)(read().someOtherSetting).to.equal(true);
|
|
116
|
+
});
|
|
117
|
+
it("OVERWRITES its own stale local entry when the port changed", () => {
|
|
118
|
+
// The opposite of preserving: a stale local URL is the silent failure this
|
|
119
|
+
// file exists to prevent, so our own entries are always rewritten.
|
|
120
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), JSON.stringify({
|
|
121
|
+
mcpServers: {
|
|
122
|
+
malloy: { type: "http", url: "http://127.0.0.1:9999/mcp" },
|
|
123
|
+
},
|
|
124
|
+
}));
|
|
125
|
+
(0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
126
|
+
(0, chai_1.expect)(read().mcpServers.malloy.url).to.equal("http://127.0.0.1:4040/mcp");
|
|
127
|
+
});
|
|
128
|
+
it("reports no change when the file already says exactly this", () => {
|
|
129
|
+
(0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
130
|
+
const second = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
131
|
+
(0, chai_1.expect)(second.changed).to.equal(false);
|
|
132
|
+
});
|
|
133
|
+
it("recovers from an unparseable file rather than failing setup", () => {
|
|
134
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), "{ not json");
|
|
135
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
136
|
+
(0, chai_1.expect)(result.changed).to.equal(true);
|
|
137
|
+
(0, chai_1.expect)(read().mcpServers.malloy).to.exist;
|
|
138
|
+
});
|
|
139
|
+
it("treats a top-level array as absent rather than crashing", () => {
|
|
140
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), "[1,2,3]");
|
|
141
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
142
|
+
(0, chai_1.expect)(result.changed).to.equal(true);
|
|
143
|
+
(0, chai_1.expect)(read().mcpServers.credible).to.exist;
|
|
144
|
+
});
|
|
145
|
+
// A byte-order mark is what Windows editors and PowerShell's `Out-File`
|
|
146
|
+
// write, and the agents that read `.mcp.json` accept one. `JSON.parse` does
|
|
147
|
+
// not — so without stripping it, a file that works perfectly for its actual
|
|
148
|
+
// consumer parses as absent and the merge below overwrites it.
|
|
149
|
+
it("merges into a file that carries a byte-order mark", () => {
|
|
150
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), `\uFEFF${JSON.stringify({
|
|
151
|
+
mcpServers: { mine: { type: "http", url: "http://example" } },
|
|
152
|
+
})}`);
|
|
153
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
154
|
+
(0, chai_1.expect)(result.preserved).to.eql(["mine"]);
|
|
155
|
+
(0, chai_1.expect)(result.displaced).to.equal(undefined);
|
|
156
|
+
(0, chai_1.expect)(read().mcpServers.mine.url).to.equal("http://example");
|
|
157
|
+
(0, chai_1.expect)(read().mcpServers.malloy).to.exist;
|
|
158
|
+
});
|
|
159
|
+
// The rewrite still happens — setup's job is to leave a working file — but
|
|
160
|
+
// the user's own servers have to remain recoverable, and the caller has to
|
|
161
|
+
// be told. `preserved` cannot carry this: it is empty precisely because
|
|
162
|
+
// nothing parsed, so on its own the user gets the generic "wrote .mcp.json"
|
|
163
|
+
// line and no hint that anything was lost.
|
|
164
|
+
it("keeps a copy of a file it could not read, and says so", () => {
|
|
165
|
+
const original = '{ "mcpServers": { "mine": {} } ';
|
|
166
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), original);
|
|
167
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
168
|
+
(0, chai_1.expect)(result.displaced).to.equal((0, path_1.join)(directory, ".mcp.json.bak"));
|
|
169
|
+
(0, chai_1.expect)(fs_1.default.readFileSync(result.displaced, "utf-8")).to.equal(original);
|
|
170
|
+
(0, chai_1.expect)(read().mcpServers.malloy).to.exist;
|
|
171
|
+
});
|
|
172
|
+
// An earlier run's `.bak` is the only copy of what that run could not read.
|
|
173
|
+
it("does not overwrite an earlier copy", () => {
|
|
174
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json.bak"), "earlier");
|
|
175
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), "{ broken");
|
|
176
|
+
const result = (0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options));
|
|
177
|
+
(0, chai_1.expect)(result.displaced).to.equal((0, path_1.join)(directory, ".mcp.json.bak.1"));
|
|
178
|
+
(0, chai_1.expect)(fs_1.default.readFileSync((0, path_1.join)(directory, ".mcp.json.bak"), "utf-8")).to.equal("earlier");
|
|
179
|
+
(0, chai_1.expect)(fs_1.default.readFileSync(result.displaced, "utf-8")).to.equal("{ broken");
|
|
180
|
+
});
|
|
181
|
+
it("displaces nothing when there was no file to begin with", () => {
|
|
182
|
+
(0, chai_1.expect)((0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options)).displaced).to.equal(undefined);
|
|
183
|
+
});
|
|
184
|
+
it("displaces nothing for an empty file, which held nothing to lose", () => {
|
|
185
|
+
fs_1.default.writeFileSync((0, path_1.join)(directory, ".mcp.json"), " \n");
|
|
186
|
+
(0, chai_1.expect)((0, mcpconfig_1.writeMcpConfig)(Object.assign({ directory }, options)).displaced).to.equal(undefined);
|
|
187
|
+
(0, chai_1.expect)(fs_1.default.existsSync((0, path_1.join)(directory, ".mcp.json.bak"))).to.equal(false);
|
|
188
|
+
});
|
|
189
|
+
describe("remoteCredibleUrl", () => {
|
|
190
|
+
it("scopes to the organization on each deployment env", () => {
|
|
191
|
+
(0, chai_1.expect)((0, mcpconfig_1.remoteCredibleUrl)("production", "acme")).to.equal("https://acme.mcp.credibledata.com/mcp");
|
|
192
|
+
(0, chai_1.expect)((0, mcpconfig_1.remoteCredibleUrl)("staging", "acme")).to.equal("https://acme.staging-mcp.credibledata.com/mcp");
|
|
193
|
+
(0, chai_1.expect)((0, mcpconfig_1.remoteCredibleUrl)("dev", "acme")).to.equal("https://acme.dev-mcp.credibledata.com/mcp");
|
|
194
|
+
});
|
|
195
|
+
it("puts videoamp on the AWS cell's own domain, not production's", () => {
|
|
196
|
+
// The cell composes every public hostname onto `videoamp-aws-us-east-1`
|
|
197
|
+
// (see its env.hcl). A copy of production's line here is legal, plausible
|
|
198
|
+
// and points a videoamp user's agent at the GCP cell — which is the same
|
|
199
|
+
// omission `publisherconfig.ts`'s data-plane map already guards against.
|
|
200
|
+
(0, chai_1.expect)((0, mcpconfig_1.remoteCredibleUrl)("videoamp", "acme")).to.equal("https://acme.mcp.videoamp-aws-us-east-1.credibledata.com/mcp");
|
|
201
|
+
(0, chai_1.expect)((0, mcpconfig_1.remoteCredibleUrl)("videoamp", "acme")).to.not.equal((0, mcpconfig_1.remoteCredibleUrl)("production", "acme"));
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
//# sourceMappingURL=mcpconfig.spec.js.map
|