@docyrus/docyrus 0.0.8 → 0.0.11
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/main.js +57 -9
- package/main.js.map +2 -2
- package/package.json +1 -1
- package/tui.mjs +425 -43
- package/tui.mjs.map +3 -3
package/main.js
CHANGED
|
@@ -63633,7 +63633,7 @@ function buildInputSchema(args, env, options) {
|
|
|
63633
63633
|
// package.json
|
|
63634
63634
|
var package_default = {
|
|
63635
63635
|
name: "@docyrus/docyrus",
|
|
63636
|
-
version: "0.0.
|
|
63636
|
+
version: "0.0.11",
|
|
63637
63637
|
private: false,
|
|
63638
63638
|
description: "Docyrus API CLI",
|
|
63639
63639
|
main: "./main.js",
|
|
@@ -63854,10 +63854,11 @@ var DEFAULT_LOGIN_SCOPES = [
|
|
|
63854
63854
|
"Docs.ReadWrite.All",
|
|
63855
63855
|
"Architect.ReadWrite.All"
|
|
63856
63856
|
].join(" ");
|
|
63857
|
-
var
|
|
63857
|
+
var DOCYRUS_SETTINGS_DIR_NAME = ".docyrus";
|
|
63858
|
+
var AUTH_DIR_PATH = (0, import_node_path3.join)((0, import_node_os3.homedir)(), DOCYRUS_SETTINGS_DIR_NAME);
|
|
63858
63859
|
var AUTH_FILE_PATH = (0, import_node_path3.join)(AUTH_DIR_PATH, "auth.json");
|
|
63859
63860
|
var CONFIG_FILE_PATH = (0, import_node_path3.join)(AUTH_DIR_PATH, "config.json");
|
|
63860
|
-
var TENANT_OPENAPI_ROOT_PATH = (0, import_node_path3.join)(
|
|
63861
|
+
var TENANT_OPENAPI_ROOT_PATH = (0, import_node_path3.join)(AUTH_DIR_PATH, "tenans");
|
|
63861
63862
|
var TENANT_OPENAPI_PUBLIC_URL_TEMPLATE = "https://api.docyrus.app/storage/v1/object/public/tenant-public/{tenantId}/openapi.json";
|
|
63862
63863
|
var DEFAULT_ENVIRONMENT_ID = "live";
|
|
63863
63864
|
var DEFAULT_ENVIRONMENTS = [
|
|
@@ -63886,6 +63887,41 @@ var TOKEN_EXPIRY_SKEW_MS = 6e4;
|
|
|
63886
63887
|
var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
|
|
63887
63888
|
var DEVICE_POLL_SLOW_DOWN_SECONDS = 5;
|
|
63888
63889
|
var DEFAULT_DEVICE_CODE_EXPIRY_SECONDS = 600;
|
|
63890
|
+
function getLocalDocyrusSettingsRootPath(cwd = process.cwd()) {
|
|
63891
|
+
return (0, import_node_path3.join)(cwd, DOCYRUS_SETTINGS_DIR_NAME);
|
|
63892
|
+
}
|
|
63893
|
+
function toDocyrusSettingsPaths(rootPath, scope) {
|
|
63894
|
+
return {
|
|
63895
|
+
scope,
|
|
63896
|
+
rootPath,
|
|
63897
|
+
authFilePath: (0, import_node_path3.join)(rootPath, "auth.json"),
|
|
63898
|
+
configFilePath: (0, import_node_path3.join)(rootPath, "config.json"),
|
|
63899
|
+
tenantOpenApiRootPath: (0, import_node_path3.join)(rootPath, "tenans")
|
|
63900
|
+
};
|
|
63901
|
+
}
|
|
63902
|
+
function resolveDocyrusSettingsPaths(params) {
|
|
63903
|
+
const cwd = params?.cwd || process.cwd();
|
|
63904
|
+
const localRootPath = getLocalDocyrusSettingsRootPath(cwd);
|
|
63905
|
+
if (params?.forceGlobal) {
|
|
63906
|
+
return toDocyrusSettingsPaths(AUTH_DIR_PATH, "global");
|
|
63907
|
+
}
|
|
63908
|
+
return toDocyrusSettingsPaths(localRootPath, "local");
|
|
63909
|
+
}
|
|
63910
|
+
function extractGlobalFlagFromArgv(argv) {
|
|
63911
|
+
let forceGlobal = false;
|
|
63912
|
+
const sanitizedArgs = [];
|
|
63913
|
+
for (const value of argv) {
|
|
63914
|
+
if (value === "-g" || value === "--global") {
|
|
63915
|
+
forceGlobal = true;
|
|
63916
|
+
continue;
|
|
63917
|
+
}
|
|
63918
|
+
sanitizedArgs.push(value);
|
|
63919
|
+
}
|
|
63920
|
+
return {
|
|
63921
|
+
forceGlobal,
|
|
63922
|
+
argv: sanitizedArgs
|
|
63923
|
+
};
|
|
63924
|
+
}
|
|
63889
63925
|
function getContextEnvValue(contextEnv, key) {
|
|
63890
63926
|
if (typeof contextEnv === "object" && contextEnv !== null && key in contextEnv) {
|
|
63891
63927
|
const value = contextEnv[key];
|
|
@@ -63989,7 +64025,8 @@ function createAuthCli(dependencies) {
|
|
|
63989
64025
|
run: async (context) => {
|
|
63990
64026
|
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
63991
64027
|
const configuredClientId = await dependencies.environmentConfigService.getDefaultClientId();
|
|
63992
|
-
const
|
|
64028
|
+
const globalConfiguredClientId = configuredClientId ? void 0 : await dependencies.globalEnvironmentConfigService?.getDefaultClientId();
|
|
64029
|
+
const clientId = context.options.clientId || getOptionalEnvValue(context.env, "DOCYRUS_API_CLIENT_ID") || configuredClientId || globalConfiguredClientId;
|
|
63993
64030
|
if (!clientId) {
|
|
63994
64031
|
throw new UserInputError(
|
|
63995
64032
|
"Client ID is required. Pass --clientId, set DOCYRUS_API_CLIENT_ID, or login once with --clientId to save it."
|
|
@@ -67295,6 +67332,7 @@ var TenantOpenApiService = class {
|
|
|
67295
67332
|
|
|
67296
67333
|
// src/main.ts
|
|
67297
67334
|
var ROOT_HELP_COMMANDS = [
|
|
67335
|
+
{ command: "docyrus -g <command>", description: "Force use of global ~/.docyrus settings for this run" },
|
|
67298
67336
|
{ command: "env", description: "Show active environment and list environments" },
|
|
67299
67337
|
{ command: "env use <id|name>", description: "Switch active environment" },
|
|
67300
67338
|
{ command: "auth login", description: "Authenticate with OAuth2 device flow" },
|
|
@@ -67313,11 +67351,17 @@ var ROOT_HELP_COMMANDS = [
|
|
|
67313
67351
|
{ command: "curl <path>", description: "Send arbitrary API requests" }
|
|
67314
67352
|
];
|
|
67315
67353
|
function createDocyrusCli(params) {
|
|
67316
|
-
const
|
|
67317
|
-
|
|
67354
|
+
const settingsPaths = resolveDocyrusSettingsPaths({
|
|
67355
|
+
forceGlobal: params?.forceGlobalSettings,
|
|
67356
|
+
cwd: params?.cwd
|
|
67357
|
+
});
|
|
67358
|
+
const authStore = params?.authStore ?? new AuthStore(settingsPaths.authFilePath);
|
|
67359
|
+
const environmentConfigService = params?.environmentConfigService ?? new EnvironmentConfigService(settingsPaths.configFilePath);
|
|
67360
|
+
const globalEnvironmentConfigService = new EnvironmentConfigService(CONFIG_FILE_PATH);
|
|
67318
67361
|
const includeTui = params?.includeTui !== false;
|
|
67319
67362
|
const tenantOpenApiService = new TenantOpenApiService({
|
|
67320
|
-
fetchFn: params?.fetchFn
|
|
67363
|
+
fetchFn: params?.fetchFn,
|
|
67364
|
+
rootPath: settingsPaths.tenantOpenApiRootPath
|
|
67321
67365
|
});
|
|
67322
67366
|
const createAuthSessionService = (apiBaseUrl) => {
|
|
67323
67367
|
return new AuthSessionService({
|
|
@@ -67361,6 +67405,7 @@ function createDocyrusCli(params) {
|
|
|
67361
67405
|
createApiClient,
|
|
67362
67406
|
createAuthSessionService,
|
|
67363
67407
|
environmentConfigService,
|
|
67408
|
+
globalEnvironmentConfigService,
|
|
67364
67409
|
onMessage: params?.onAuthMessage,
|
|
67365
67410
|
authStore
|
|
67366
67411
|
}));
|
|
@@ -67396,8 +67441,11 @@ function createDocyrusCli(params) {
|
|
|
67396
67441
|
}));
|
|
67397
67442
|
return cli2;
|
|
67398
67443
|
}
|
|
67399
|
-
var
|
|
67400
|
-
cli
|
|
67444
|
+
var runtimeArgs = extractGlobalFlagFromArgv(process.argv.slice(2));
|
|
67445
|
+
var cli = createDocyrusCli({
|
|
67446
|
+
forceGlobalSettings: runtimeArgs.forceGlobal
|
|
67447
|
+
});
|
|
67448
|
+
cli.serve(runtimeArgs.argv);
|
|
67401
67449
|
var main_default = cli;
|
|
67402
67450
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67403
67451
|
0 && (module.exports = {
|