@docyrus/docyrus 0.0.14 → 0.0.15
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 +184 -20
- package/main.js.map +3 -3
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -124678,7 +124678,7 @@ function buildInputSchema(args, env2, options2) {
|
|
|
124678
124678
|
// package.json
|
|
124679
124679
|
var package_default = {
|
|
124680
124680
|
name: "@docyrus/docyrus",
|
|
124681
|
-
version: "0.0.
|
|
124681
|
+
version: "0.0.15",
|
|
124682
124682
|
private: false,
|
|
124683
124683
|
description: "Docyrus API CLI",
|
|
124684
124684
|
main: "./main.js",
|
|
@@ -125009,6 +125009,54 @@ function createAiCli(dependencies) {
|
|
|
125009
125009
|
}
|
|
125010
125010
|
|
|
125011
125011
|
// src/commands/appsCommands.ts
|
|
125012
|
+
function normalizeOptional(value) {
|
|
125013
|
+
const trimmed = value?.trim();
|
|
125014
|
+
return trimmed && trimmed.length > 0 ? trimmed : void 0;
|
|
125015
|
+
}
|
|
125016
|
+
function extractAppRecords(payload) {
|
|
125017
|
+
if (Array.isArray(payload)) {
|
|
125018
|
+
return payload.filter((item) => typeof item === "object" && item !== null);
|
|
125019
|
+
}
|
|
125020
|
+
if (typeof payload === "object" && payload !== null && Array.isArray(payload.data)) {
|
|
125021
|
+
return payload.data.filter((item) => typeof item === "object" && item !== null);
|
|
125022
|
+
}
|
|
125023
|
+
return [];
|
|
125024
|
+
}
|
|
125025
|
+
function extractString(record2, key) {
|
|
125026
|
+
const value = record2[key];
|
|
125027
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
125028
|
+
}
|
|
125029
|
+
async function resolveAppId(params) {
|
|
125030
|
+
const appId = normalizeOptional(params.appId);
|
|
125031
|
+
const appSlug = normalizeOptional(params.appSlug);
|
|
125032
|
+
if (appId && appSlug) {
|
|
125033
|
+
throw new UserInputError("Provide either --appId or --appSlug, not both.");
|
|
125034
|
+
}
|
|
125035
|
+
if (!appId && !appSlug) {
|
|
125036
|
+
throw new UserInputError("Provide --appId or --appSlug.");
|
|
125037
|
+
}
|
|
125038
|
+
if (appId) {
|
|
125039
|
+
return appId;
|
|
125040
|
+
}
|
|
125041
|
+
const response = await params.apiClient.request({
|
|
125042
|
+
method: "GET",
|
|
125043
|
+
path: "/apps"
|
|
125044
|
+
});
|
|
125045
|
+
const apps = extractAppRecords(response.data);
|
|
125046
|
+
const matches = apps.filter((item) => extractString(item, "slug") === appSlug);
|
|
125047
|
+
if (matches.length === 0) {
|
|
125048
|
+
throw new UserInputError(`App slug '${appSlug}' was not found.`);
|
|
125049
|
+
}
|
|
125050
|
+
if (matches.length > 1) {
|
|
125051
|
+
const matchingIds = matches.map((item) => extractString(item, "id")).filter((value) => Boolean(value));
|
|
125052
|
+
throw new UserInputError(`App slug '${appSlug}' is ambiguous. Matching IDs: ${matchingIds.join(", ")}`);
|
|
125053
|
+
}
|
|
125054
|
+
const resolvedId = extractString(matches[0], "id");
|
|
125055
|
+
if (!resolvedId) {
|
|
125056
|
+
throw new UserInputError(`App slug '${appSlug}' resolved to an invalid item without id.`);
|
|
125057
|
+
}
|
|
125058
|
+
return resolvedId;
|
|
125059
|
+
}
|
|
125012
125060
|
function createAppsCli(dependencies) {
|
|
125013
125061
|
const appsCli = Cli_exports.create("apps", {
|
|
125014
125062
|
description: "App commands",
|
|
@@ -125036,6 +125084,81 @@ function createAppsCli(dependencies) {
|
|
|
125036
125084
|
});
|
|
125037
125085
|
}
|
|
125038
125086
|
});
|
|
125087
|
+
appsCli.command("delete", {
|
|
125088
|
+
description: "Archive an app",
|
|
125089
|
+
options: external_exports.object({
|
|
125090
|
+
appId: external_exports.string().optional().describe("App ID"),
|
|
125091
|
+
appSlug: external_exports.string().optional().describe("App slug")
|
|
125092
|
+
}),
|
|
125093
|
+
run: async (context) => {
|
|
125094
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
125095
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
125096
|
+
const appId = await resolveAppId({
|
|
125097
|
+
apiClient,
|
|
125098
|
+
appId: context.options.appId,
|
|
125099
|
+
appSlug: context.options.appSlug
|
|
125100
|
+
});
|
|
125101
|
+
const response = await apiClient.request({
|
|
125102
|
+
method: "DELETE",
|
|
125103
|
+
path: `/dev/apps/${appId}`
|
|
125104
|
+
});
|
|
125105
|
+
return await injectContext({
|
|
125106
|
+
apiBaseUrl,
|
|
125107
|
+
authStore: dependencies.authStore,
|
|
125108
|
+
payload: response.data
|
|
125109
|
+
});
|
|
125110
|
+
}
|
|
125111
|
+
});
|
|
125112
|
+
appsCli.command("restore", {
|
|
125113
|
+
description: "Restore an archived app",
|
|
125114
|
+
options: external_exports.object({
|
|
125115
|
+
appId: external_exports.string().optional().describe("App ID"),
|
|
125116
|
+
appSlug: external_exports.string().optional().describe("App slug")
|
|
125117
|
+
}),
|
|
125118
|
+
run: async (context) => {
|
|
125119
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
125120
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
125121
|
+
const appId = await resolveAppId({
|
|
125122
|
+
apiClient,
|
|
125123
|
+
appId: context.options.appId,
|
|
125124
|
+
appSlug: context.options.appSlug
|
|
125125
|
+
});
|
|
125126
|
+
const response = await apiClient.request({
|
|
125127
|
+
method: "POST",
|
|
125128
|
+
path: `/dev/apps/${appId}/restore`
|
|
125129
|
+
});
|
|
125130
|
+
return await injectContext({
|
|
125131
|
+
apiBaseUrl,
|
|
125132
|
+
authStore: dependencies.authStore,
|
|
125133
|
+
payload: response.data
|
|
125134
|
+
});
|
|
125135
|
+
}
|
|
125136
|
+
});
|
|
125137
|
+
appsCli.command("permanent-delete", {
|
|
125138
|
+
description: "Permanently delete an app",
|
|
125139
|
+
options: external_exports.object({
|
|
125140
|
+
appId: external_exports.string().optional().describe("App ID"),
|
|
125141
|
+
appSlug: external_exports.string().optional().describe("App slug")
|
|
125142
|
+
}),
|
|
125143
|
+
run: async (context) => {
|
|
125144
|
+
const apiBaseUrl = await dependencies.environmentConfigService.getActiveApiBaseUrl();
|
|
125145
|
+
const apiClient = dependencies.createApiClient(apiBaseUrl);
|
|
125146
|
+
const appId = await resolveAppId({
|
|
125147
|
+
apiClient,
|
|
125148
|
+
appId: context.options.appId,
|
|
125149
|
+
appSlug: context.options.appSlug
|
|
125150
|
+
});
|
|
125151
|
+
const response = await apiClient.request({
|
|
125152
|
+
method: "DELETE",
|
|
125153
|
+
path: `/dev/apps/${appId}/permanent`
|
|
125154
|
+
});
|
|
125155
|
+
return await injectContext({
|
|
125156
|
+
apiBaseUrl,
|
|
125157
|
+
authStore: dependencies.authStore,
|
|
125158
|
+
payload: response.data
|
|
125159
|
+
});
|
|
125160
|
+
}
|
|
125161
|
+
});
|
|
125039
125162
|
return appsCli;
|
|
125040
125163
|
}
|
|
125041
125164
|
|
|
@@ -126454,7 +126577,7 @@ function normalizeBatchPayload(payload, key) {
|
|
|
126454
126577
|
function isRecord4(value) {
|
|
126455
126578
|
return typeof value === "object" && value !== null;
|
|
126456
126579
|
}
|
|
126457
|
-
function
|
|
126580
|
+
function extractString2(record2, key) {
|
|
126458
126581
|
const value = record2[key];
|
|
126459
126582
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
126460
126583
|
}
|
|
@@ -126475,20 +126598,20 @@ function ensureExclusiveSelector(label, idValue, slugValue) {
|
|
|
126475
126598
|
throw new UserInputError(`Provide --${label}Id or --${label}Slug.`);
|
|
126476
126599
|
}
|
|
126477
126600
|
}
|
|
126478
|
-
function
|
|
126601
|
+
function normalizeOptional2(value) {
|
|
126479
126602
|
const trimmed = value?.trim();
|
|
126480
126603
|
return trimmed && trimmed.length > 0 ? trimmed : void 0;
|
|
126481
126604
|
}
|
|
126482
126605
|
function resolveBySlug(label, items, slug) {
|
|
126483
|
-
const matches = items.filter((item) =>
|
|
126606
|
+
const matches = items.filter((item) => extractString2(item, "slug") === slug);
|
|
126484
126607
|
if (matches.length === 0) {
|
|
126485
126608
|
throw new UserInputError(`${label} slug '${slug}' was not found.`);
|
|
126486
126609
|
}
|
|
126487
126610
|
if (matches.length > 1) {
|
|
126488
|
-
const matchingIds = matches.map((item) =>
|
|
126611
|
+
const matchingIds = matches.map((item) => extractString2(item, "id")).filter((id) => Boolean(id));
|
|
126489
126612
|
throw new UserInputError(`${label} slug '${slug}' is ambiguous. Matching IDs: ${matchingIds.join(", ")}`);
|
|
126490
126613
|
}
|
|
126491
|
-
const matchId =
|
|
126614
|
+
const matchId = extractString2(matches[0], "id");
|
|
126492
126615
|
if (!matchId) {
|
|
126493
126616
|
throw new UserInputError(`${label} slug '${slug}' resolved to an invalid item without id.`);
|
|
126494
126617
|
}
|
|
@@ -126502,8 +126625,8 @@ var StudioResolver = class {
|
|
|
126502
126625
|
#dataSourcesByAppId = /* @__PURE__ */ new Map();
|
|
126503
126626
|
#fieldsByAppAndDataSource = /* @__PURE__ */ new Map();
|
|
126504
126627
|
async resolveAppId(options2) {
|
|
126505
|
-
const appId =
|
|
126506
|
-
const appSlug =
|
|
126628
|
+
const appId = normalizeOptional2(options2.appId);
|
|
126629
|
+
const appSlug = normalizeOptional2(options2.appSlug);
|
|
126507
126630
|
ensureExclusiveSelector("app", appId, appSlug);
|
|
126508
126631
|
if (appId) {
|
|
126509
126632
|
return appId;
|
|
@@ -126512,8 +126635,8 @@ var StudioResolver = class {
|
|
|
126512
126635
|
return resolveBySlug("App", apps, appSlug);
|
|
126513
126636
|
}
|
|
126514
126637
|
async resolveDataSourceId(options2) {
|
|
126515
|
-
const dataSourceId =
|
|
126516
|
-
const dataSourceSlug =
|
|
126638
|
+
const dataSourceId = normalizeOptional2(options2.dataSourceId);
|
|
126639
|
+
const dataSourceSlug = normalizeOptional2(options2.dataSourceSlug);
|
|
126517
126640
|
ensureExclusiveSelector("dataSource", dataSourceId, dataSourceSlug);
|
|
126518
126641
|
if (dataSourceId) {
|
|
126519
126642
|
return dataSourceId;
|
|
@@ -126522,8 +126645,8 @@ var StudioResolver = class {
|
|
|
126522
126645
|
return resolveBySlug("Data source", dataSources, dataSourceSlug);
|
|
126523
126646
|
}
|
|
126524
126647
|
async resolveFieldId(options2) {
|
|
126525
|
-
const fieldId =
|
|
126526
|
-
const fieldSlug =
|
|
126648
|
+
const fieldId = normalizeOptional2(options2.fieldId);
|
|
126649
|
+
const fieldSlug = normalizeOptional2(options2.fieldSlug);
|
|
126527
126650
|
ensureExclusiveSelector("field", fieldId, fieldSlug);
|
|
126528
126651
|
if (fieldId) {
|
|
126529
126652
|
return fieldId;
|
|
@@ -126768,7 +126891,7 @@ function createStudioCli(dependencies) {
|
|
|
126768
126891
|
}
|
|
126769
126892
|
});
|
|
126770
126893
|
studioCli.command("delete-data-source", {
|
|
126771
|
-
description: "
|
|
126894
|
+
description: "Archive a data source",
|
|
126772
126895
|
options: external_exports.object({
|
|
126773
126896
|
appId: external_exports.string().optional().describe("App ID"),
|
|
126774
126897
|
appSlug: external_exports.string().optional().describe("App slug"),
|
|
@@ -126793,6 +126916,46 @@ function createStudioCli(dependencies) {
|
|
|
126793
126916
|
return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
|
|
126794
126917
|
}
|
|
126795
126918
|
});
|
|
126919
|
+
studioCli.command("restore-data-source", {
|
|
126920
|
+
description: "Restore an archived data source",
|
|
126921
|
+
options: external_exports.object({
|
|
126922
|
+
appId: external_exports.string().optional().describe("App ID"),
|
|
126923
|
+
appSlug: external_exports.string().optional().describe("App slug"),
|
|
126924
|
+
dataSourceId: external_exports.string().min(1).describe("Data source ID")
|
|
126925
|
+
}),
|
|
126926
|
+
run: async (context) => {
|
|
126927
|
+
const studio = await getStudioRunContext(dependencies);
|
|
126928
|
+
const appId = await studio.resolver.resolveAppId({
|
|
126929
|
+
appId: context.options.appId,
|
|
126930
|
+
appSlug: context.options.appSlug
|
|
126931
|
+
});
|
|
126932
|
+
const response = await studio.apiClient.request({
|
|
126933
|
+
method: "POST",
|
|
126934
|
+
path: `/dev/apps/${appId}/data-sources/${context.options.dataSourceId}/restore`
|
|
126935
|
+
});
|
|
126936
|
+
return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
|
|
126937
|
+
}
|
|
126938
|
+
});
|
|
126939
|
+
studioCli.command("permanent-delete-data-source", {
|
|
126940
|
+
description: "Permanently delete a data source",
|
|
126941
|
+
options: external_exports.object({
|
|
126942
|
+
appId: external_exports.string().optional().describe("App ID"),
|
|
126943
|
+
appSlug: external_exports.string().optional().describe("App slug"),
|
|
126944
|
+
dataSourceId: external_exports.string().min(1).describe("Data source ID")
|
|
126945
|
+
}),
|
|
126946
|
+
run: async (context) => {
|
|
126947
|
+
const studio = await getStudioRunContext(dependencies);
|
|
126948
|
+
const appId = await studio.resolver.resolveAppId({
|
|
126949
|
+
appId: context.options.appId,
|
|
126950
|
+
appSlug: context.options.appSlug
|
|
126951
|
+
});
|
|
126952
|
+
const response = await studio.apiClient.request({
|
|
126953
|
+
method: "DELETE",
|
|
126954
|
+
path: `/dev/apps/${appId}/data-sources/${context.options.dataSourceId}/permanent`
|
|
126955
|
+
});
|
|
126956
|
+
return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
|
|
126957
|
+
}
|
|
126958
|
+
});
|
|
126796
126959
|
studioCli.command("bulk-create-data-sources", {
|
|
126797
126960
|
description: "Bulk create data sources",
|
|
126798
126961
|
options: external_exports.object({
|
|
@@ -127598,7 +127761,7 @@ function extractRecordValue(record2, keys) {
|
|
|
127598
127761
|
}
|
|
127599
127762
|
return void 0;
|
|
127600
127763
|
}
|
|
127601
|
-
function
|
|
127764
|
+
function extractString3(record2, keys) {
|
|
127602
127765
|
const value = extractRecordValue(record2, keys);
|
|
127603
127766
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
127604
127767
|
}
|
|
@@ -127905,10 +128068,10 @@ var AuthSessionService = class {
|
|
|
127905
128068
|
throw new AuthSessionError("Unable to parse /users/me response.");
|
|
127906
128069
|
}
|
|
127907
128070
|
const tenantCandidate = isRecord5(dataCandidate.tenant) ? dataCandidate.tenant : void 0;
|
|
127908
|
-
const userId =
|
|
127909
|
-
const email3 =
|
|
127910
|
-
const tenantId = tenantCandidate ?
|
|
127911
|
-
const tenantName = tenantCandidate ?
|
|
128071
|
+
const userId = extractString3(dataCandidate, ["id", "user_id"]);
|
|
128072
|
+
const email3 = extractString3(dataCandidate, ["email"]);
|
|
128073
|
+
const tenantId = tenantCandidate ? extractString3(tenantCandidate, ["id"]) : extractString3(dataCandidate, ["tenant_id", "tenantId"]);
|
|
128074
|
+
const tenantName = tenantCandidate ? extractString3(tenantCandidate, ["name"]) : extractString3(dataCandidate, ["tenant_name", "tenantName"]);
|
|
127912
128075
|
const tenantNo = tenantCandidate ? extractNumber(tenantCandidate, ["no", "tenant_no"]) : extractNumber(dataCandidate, ["tenant_no", "tenantNo"]);
|
|
127913
128076
|
if (!userId || !email3 || !tenantId || !tenantName || !tenantNo) {
|
|
127914
128077
|
throw new AuthSessionError("Incomplete identity data returned from /users/me.");
|
|
@@ -127939,8 +128102,8 @@ var AuthSessionService = class {
|
|
|
127939
128102
|
if (!isRecord5(item)) {
|
|
127940
128103
|
continue;
|
|
127941
128104
|
}
|
|
127942
|
-
const tenantId =
|
|
127943
|
-
const tenantName =
|
|
128105
|
+
const tenantId = extractString3(item, ["id", "tenant_id"]);
|
|
128106
|
+
const tenantName = extractString3(item, ["name"]);
|
|
127944
128107
|
const tenantNo = extractNumber(item, ["tenant_no", "tenantNo", "no"]);
|
|
127945
128108
|
const logoValue = extractRecordValue(item, ["logo"]);
|
|
127946
128109
|
const logo = typeof logoValue === "string" || logoValue === null ? logoValue : void 0;
|
|
@@ -128698,6 +128861,7 @@ var ROOT_HELP_COMMANDS = [
|
|
|
128698
128861
|
{ command: "discover search <terms>", description: "Search in endpoint paths and entity names" },
|
|
128699
128862
|
{ command: "ds list <appSlug> <dataSourceSlug>", description: "List data source items" },
|
|
128700
128863
|
{ command: "apps list", description: "List apps" },
|
|
128864
|
+
{ command: "apps delete --appId <id>", description: "Archive an app" },
|
|
128701
128865
|
{ command: "studio list-data-sources --appSlug <slug>", description: "List studio data sources" },
|
|
128702
128866
|
{ command: "tui", description: "Launch terminal UI (OpenTUI, requires Bun)" },
|
|
128703
128867
|
{ command: "curl <path>", description: "Send arbitrary API requests" }
|