|
| 1 | +type ArgsParserOptions = { |
| 2 | + string: string[]; |
| 3 | + number: string[]; |
| 4 | + boolean: string[]; |
| 5 | + array: string[]; |
| 6 | + alias: Record<string, string>; |
| 7 | + configuration: Record<string, boolean>; |
| 8 | +}; |
| 9 | + |
| 10 | +// TODO: Export this from arg-parser or find a better way to do this |
| 11 | +// From: https://github.com/mongodb-js/mongosh/blob/main/packages/cli-repl/src/arg-parser.ts |
| 12 | +export const OPTIONS = { |
| 13 | + number: ["maxDocumentsPerQuery", "maxBytesPerQuery"], |
| 14 | + string: [ |
| 15 | + "apiBaseUrl", |
| 16 | + "apiClientId", |
| 17 | + "apiClientSecret", |
| 18 | + "connectionString", |
| 19 | + "httpHost", |
| 20 | + "httpPort", |
| 21 | + "idleTimeoutMs", |
| 22 | + "logPath", |
| 23 | + "notificationTimeoutMs", |
| 24 | + "telemetry", |
| 25 | + "transport", |
| 26 | + "apiVersion", |
| 27 | + "authenticationDatabase", |
| 28 | + "authenticationMechanism", |
| 29 | + "browser", |
| 30 | + "db", |
| 31 | + "gssapiHostName", |
| 32 | + "gssapiServiceName", |
| 33 | + "host", |
| 34 | + "oidcFlows", |
| 35 | + "oidcRedirectUri", |
| 36 | + "password", |
| 37 | + "port", |
| 38 | + "sslCAFile", |
| 39 | + "sslCRLFile", |
| 40 | + "sslCertificateSelector", |
| 41 | + "sslDisabledProtocols", |
| 42 | + "sslPEMKeyFile", |
| 43 | + "sslPEMKeyPassword", |
| 44 | + "sspiHostnameCanonicalization", |
| 45 | + "sspiRealmOverride", |
| 46 | + "tlsCAFile", |
| 47 | + "tlsCRLFile", |
| 48 | + "tlsCertificateKeyFile", |
| 49 | + "tlsCertificateKeyFilePassword", |
| 50 | + "tlsCertificateSelector", |
| 51 | + "tlsDisabledProtocols", |
| 52 | + "username", |
| 53 | + "atlasTemporaryDatabaseUserLifetimeMs", |
| 54 | + "exportsPath", |
| 55 | + "exportTimeoutMs", |
| 56 | + "exportCleanupIntervalMs", |
| 57 | + "voyageApiKey", |
| 58 | + ], |
| 59 | + boolean: [ |
| 60 | + "apiDeprecationErrors", |
| 61 | + "apiStrict", |
| 62 | + "disableEmbeddingsValidation", |
| 63 | + "help", |
| 64 | + "indexCheck", |
| 65 | + "ipv6", |
| 66 | + "nodb", |
| 67 | + "oidcIdTokenAsAccessToken", |
| 68 | + "oidcNoNonce", |
| 69 | + "oidcTrustedEndpoint", |
| 70 | + "readOnly", |
| 71 | + "retryWrites", |
| 72 | + "ssl", |
| 73 | + "sslAllowInvalidCertificates", |
| 74 | + "sslAllowInvalidHostnames", |
| 75 | + "sslFIPSMode", |
| 76 | + "tls", |
| 77 | + "tlsAllowInvalidCertificates", |
| 78 | + "tlsAllowInvalidHostnames", |
| 79 | + "tlsFIPSMode", |
| 80 | + "version", |
| 81 | + ], |
| 82 | + array: ["disabledTools", "loggers", "confirmationRequiredTools", "previewFeatures"], |
| 83 | + alias: { |
| 84 | + h: "help", |
| 85 | + p: "password", |
| 86 | + u: "username", |
| 87 | + "build-info": "buildInfo", |
| 88 | + browser: "browser", |
| 89 | + oidcDumpTokens: "oidcDumpTokens", |
| 90 | + oidcRedirectUrl: "oidcRedirectUri", |
| 91 | + oidcIDTokenAsAccessToken: "oidcIdTokenAsAccessToken", |
| 92 | + }, |
| 93 | + configuration: { |
| 94 | + "camel-case-expansion": false, |
| 95 | + "unknown-options-as-args": true, |
| 96 | + "parse-positional-numbers": false, |
| 97 | + "parse-numbers": false, |
| 98 | + "greedy-arrays": true, |
| 99 | + "short-option-groups": false, |
| 100 | + }, |
| 101 | +} as Readonly<ArgsParserOptions>; |
| 102 | + |
| 103 | +export const ALL_CONFIG_KEYS = new Set( |
| 104 | + (OPTIONS.string as readonly string[]) |
| 105 | + .concat(OPTIONS.number) |
| 106 | + .concat(OPTIONS.array) |
| 107 | + .concat(OPTIONS.boolean) |
| 108 | + .concat(Object.keys(OPTIONS.alias)) |
| 109 | +); |
0 commit comments