@fluid-app/fluid-cli-portal 0.1.43 → 0.1.45
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/dist/index.d.mts +430 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +51 -32
- package/dist/index.mjs.map +1 -1
- package/dist/{pull-Cl7omGLf.mjs → pull-CG5dELOX.mjs} +537 -10
- package/dist/pull-CG5dELOX.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/pull-Cl7omGLf.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as writeMappings, S as updateMapping, _ as deriveSlug, a as buildThemeIdToSlugMap, b as resolveIdToSlug, c as transformNavigationItems, d as transformTheme, f as buildSnapshot, g as writeSnapshot, h as readSnapshot, i as buildNavigationIdToSlugMap, l as transformProfile, m as diffAgainstSnapshot, o as deriveScreenSlug, p as computeFileHash, r as buildIdToSlugMap, s as transformNavigation, t as pullCommand, u as transformScreen, v as readMappings, x as resolveSlugToId, y as removeMapping } from "./pull-
|
|
1
|
+
import { A as fluid_os_v0_create_fluid_osversion, B as fluid_os_v0_update_fluid_osnavigation, C as writeMappings, D as fluid_os_v0_create_fluid_osprofile, E as fluid_os_v0_create_fluid_osnavigation_item, F as fluid_os_v0_delete_fluid_osscreen, G as fluid_os_v0_update_fluid_osversion, H as fluid_os_v0_update_fluid_osprofile, I as fluid_os_v0_delete_fluid_ostheme, K as createFetchClient, L as fluid_os_v0_list_fluid_osdefinitions, M as fluid_os_v0_delete_fluid_osnavigation, N as fluid_os_v0_delete_fluid_osnavigation_item, O as fluid_os_v0_create_fluid_osscreen, P as fluid_os_v0_delete_fluid_osprofile, R as fluid_os_v0_list_fluid_osnavigation_items, S as updateMapping, T as fluid_os_v0_create_fluid_osnavigation, U as fluid_os_v0_update_fluid_osscreen, V as fluid_os_v0_update_fluid_osnavigation_item, W as fluid_os_v0_update_fluid_ostheme, _ as deriveSlug, a as buildThemeIdToSlugMap, b as resolveIdToSlug, c as transformNavigationItems, d as transformTheme, f as buildSnapshot, g as writeSnapshot, h as readSnapshot, i as buildNavigationIdToSlugMap, j as fluid_os_v0_create_widget_package_version, k as fluid_os_v0_create_fluid_ostheme, l as transformProfile, m as diffAgainstSnapshot, o as deriveScreenSlug, p as computeFileHash, r as buildIdToSlugMap, s as transformNavigation, t as pullCommand, u as transformScreen, v as readMappings, w as fluid_os_v0_complete_widget_package_version_upload, x as resolveSlugToId, y as removeMapping, z as fluid_os_v0_list_fluid_osversions } from "./pull-CG5dELOX.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import chalk from "chalk";
|
|
@@ -12,10 +12,8 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileS
|
|
|
12
12
|
import Handlebars from "handlebars";
|
|
13
13
|
import { execa } from "execa";
|
|
14
14
|
import os from "node:os";
|
|
15
|
-
import { createFetchClient, fluidOs } from "@fluid-app/fluidos-api-client";
|
|
16
15
|
import { createHash } from "node:crypto";
|
|
17
16
|
import fs from "fs-extra";
|
|
18
|
-
import { isJsonValue } from "@fluid-app/portal-core/remote-dom-widget-package";
|
|
19
17
|
//#region src/types.ts
|
|
20
18
|
/**
|
|
21
19
|
* Available project templates
|
|
@@ -1160,7 +1158,7 @@ async function autoPull(cwd) {
|
|
|
1160
1158
|
console.log(chalk.yellow("No portal/ directory found.") + " Attempting to pull content...");
|
|
1161
1159
|
console.log();
|
|
1162
1160
|
try {
|
|
1163
|
-
const { pullCommand } = await import("./pull-
|
|
1161
|
+
const { pullCommand } = await import("./pull-CG5dELOX.mjs").then((n) => n.n);
|
|
1164
1162
|
await pullCommand.parseAsync([], { from: "user" });
|
|
1165
1163
|
return hasPortalContent(cwd);
|
|
1166
1164
|
} catch (err) {
|
|
@@ -1663,7 +1661,7 @@ async function pushScreens(client, defId, portalDir, changes, mappings) {
|
|
|
1663
1661
|
const slug = slugFromPath(file);
|
|
1664
1662
|
try {
|
|
1665
1663
|
const local = await readPortalFile(portalDir, file);
|
|
1666
|
-
const newId = (await
|
|
1664
|
+
const newId = (await fluid_os_v0_create_fluid_osscreen(client, defId, { screen: {
|
|
1667
1665
|
name: local.name,
|
|
1668
1666
|
slug,
|
|
1669
1667
|
component_tree: toApiComponentTree(local.component_tree)
|
|
@@ -1704,7 +1702,7 @@ async function pushScreens(client, defId, portalDir, changes, mappings) {
|
|
|
1704
1702
|
}
|
|
1705
1703
|
try {
|
|
1706
1704
|
const local = await readPortalFile(portalDir, file);
|
|
1707
|
-
await
|
|
1705
|
+
await fluid_os_v0_update_fluid_osscreen(client, defId, screenId, { screen: {
|
|
1708
1706
|
name: local.name,
|
|
1709
1707
|
slug,
|
|
1710
1708
|
component_tree: toApiComponentTree(local.component_tree)
|
|
@@ -1743,7 +1741,7 @@ async function pushScreens(client, defId, portalDir, changes, mappings) {
|
|
|
1743
1741
|
};
|
|
1744
1742
|
}
|
|
1745
1743
|
try {
|
|
1746
|
-
await
|
|
1744
|
+
await fluid_os_v0_delete_fluid_osscreen(client, defId, screenId);
|
|
1747
1745
|
currentMappings = removeMapping(currentMappings, "screens", slug);
|
|
1748
1746
|
results.push({
|
|
1749
1747
|
file,
|
|
@@ -1778,7 +1776,7 @@ async function pushThemes(client, defId, portalDir, changes, mappings) {
|
|
|
1778
1776
|
const slug = slugFromPath(file);
|
|
1779
1777
|
try {
|
|
1780
1778
|
const local = await readPortalFile(portalDir, file);
|
|
1781
|
-
const newId = (await
|
|
1779
|
+
const newId = (await fluid_os_v0_create_fluid_ostheme(client, defId, { theme: {
|
|
1782
1780
|
name: local.name,
|
|
1783
1781
|
active: local.active,
|
|
1784
1782
|
config: local.config
|
|
@@ -1819,7 +1817,7 @@ async function pushThemes(client, defId, portalDir, changes, mappings) {
|
|
|
1819
1817
|
}
|
|
1820
1818
|
try {
|
|
1821
1819
|
const local = await readPortalFile(portalDir, file);
|
|
1822
|
-
await
|
|
1820
|
+
await fluid_os_v0_update_fluid_ostheme(client, defId, themeId, { theme: {
|
|
1823
1821
|
name: local.name,
|
|
1824
1822
|
active: local.active,
|
|
1825
1823
|
config: local.config
|
|
@@ -1858,7 +1856,7 @@ async function pushThemes(client, defId, portalDir, changes, mappings) {
|
|
|
1858
1856
|
};
|
|
1859
1857
|
}
|
|
1860
1858
|
try {
|
|
1861
|
-
await
|
|
1859
|
+
await fluid_os_v0_delete_fluid_ostheme(client, defId, themeId);
|
|
1862
1860
|
currentMappings = removeMapping(currentMappings, "themes", slug);
|
|
1863
1861
|
results.push({
|
|
1864
1862
|
file,
|
|
@@ -1928,7 +1926,7 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
|
|
|
1928
1926
|
const slug = slugFromPath(file);
|
|
1929
1927
|
try {
|
|
1930
1928
|
const local = await readPortalFile(portalDir, file);
|
|
1931
|
-
const newId = (await
|
|
1929
|
+
const newId = (await fluid_os_v0_create_fluid_osnavigation(client, defId, { navigation: {
|
|
1932
1930
|
name: local.name,
|
|
1933
1931
|
platform: local.platform
|
|
1934
1932
|
} })).navigation?.id;
|
|
@@ -1938,7 +1936,7 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
|
|
|
1938
1936
|
const localToServerId = /* @__PURE__ */ new Map();
|
|
1939
1937
|
for (const item of resolvedItems) {
|
|
1940
1938
|
const resolvedParentId = item.parent_id != null ? localToServerId.get(item.parent_id) ?? item.parent_id : void 0;
|
|
1941
|
-
const created = await
|
|
1939
|
+
const created = await fluid_os_v0_create_fluid_osnavigation_item(client, defId, newId, { navigation_item: {
|
|
1942
1940
|
label: item.label ?? "",
|
|
1943
1941
|
position: item.position ?? 0,
|
|
1944
1942
|
icon: item.icon ?? void 0,
|
|
@@ -1985,15 +1983,15 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
|
|
|
1985
1983
|
}
|
|
1986
1984
|
try {
|
|
1987
1985
|
const local = await readPortalFile(portalDir, file);
|
|
1988
|
-
await
|
|
1986
|
+
await fluid_os_v0_update_fluid_osnavigation(client, defId, navId, { navigation: {
|
|
1989
1987
|
name: local.name,
|
|
1990
1988
|
platform: local.platform
|
|
1991
1989
|
} });
|
|
1992
1990
|
const resolvedItems = flattenNavigationItems(resolveNavigationItemScreenIds(local.navigation_items, currentMappings));
|
|
1993
|
-
const serverItems = (await
|
|
1991
|
+
const serverItems = (await fluid_os_v0_list_fluid_osnavigation_items(client, defId, navId)).navigation_items ?? [];
|
|
1994
1992
|
const serverById = new Map(serverItems.map((s) => [s.id, s]));
|
|
1995
1993
|
const localIds = new Set(resolvedItems.filter((i) => i.id).map((i) => i.id));
|
|
1996
|
-
for (const serverItem of serverItems) if (!localIds.has(serverItem.id)) await
|
|
1994
|
+
for (const serverItem of serverItems) if (!localIds.has(serverItem.id)) await fluid_os_v0_delete_fluid_osnavigation_item(client, defId, navId, serverItem.id);
|
|
1997
1995
|
const localToServerId = /* @__PURE__ */ new Map();
|
|
1998
1996
|
for (const item of resolvedItems) {
|
|
1999
1997
|
const resolvedParentId = item.parent_id != null ? localToServerId.get(item.parent_id) ?? item.parent_id : void 0;
|
|
@@ -2006,9 +2004,9 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
|
|
|
2006
2004
|
source: item.source ?? void 0,
|
|
2007
2005
|
parent_id: resolvedParentId
|
|
2008
2006
|
};
|
|
2009
|
-
if (item.id && serverById.has(item.id)) await
|
|
2007
|
+
if (item.id && serverById.has(item.id)) await fluid_os_v0_update_fluid_osnavigation_item(client, defId, navId, item.id, { navigation_item: body });
|
|
2010
2008
|
else {
|
|
2011
|
-
const created = await
|
|
2009
|
+
const created = await fluid_os_v0_create_fluid_osnavigation_item(client, defId, navId, { navigation_item: {
|
|
2012
2010
|
...body,
|
|
2013
2011
|
label: body.label ?? "",
|
|
2014
2012
|
position: body.position ?? 0
|
|
@@ -2050,7 +2048,7 @@ async function pushNavigations(client, defId, portalDir, changes, mappings) {
|
|
|
2050
2048
|
};
|
|
2051
2049
|
}
|
|
2052
2050
|
try {
|
|
2053
|
-
await
|
|
2051
|
+
await fluid_os_v0_delete_fluid_osnavigation(client, defId, navId);
|
|
2054
2052
|
currentMappings = removeMapping(currentMappings, "navigations", slug);
|
|
2055
2053
|
results.push({
|
|
2056
2054
|
file,
|
|
@@ -2084,8 +2082,7 @@ async function pushProfiles(client, defId, portalDir, changes, mappings) {
|
|
|
2084
2082
|
for (const file of changes.new) {
|
|
2085
2083
|
const slug = slugFromPath(file);
|
|
2086
2084
|
try {
|
|
2087
|
-
const
|
|
2088
|
-
const newId = (await fluidOs.fluid_os_v0_create_fluid_osprofile(client, defId, { profile: body })).profile?.id;
|
|
2085
|
+
const newId = (await fluid_os_v0_create_fluid_osprofile(client, defId, { profile: resolveProfileBody(await readPortalFile(portalDir, file), currentMappings) })).profile?.id;
|
|
2089
2086
|
if (newId != null) currentMappings = updateMapping(currentMappings, "profiles", slug, newId);
|
|
2090
2087
|
results.push({
|
|
2091
2088
|
file,
|
|
@@ -2121,8 +2118,7 @@ async function pushProfiles(client, defId, portalDir, changes, mappings) {
|
|
|
2121
2118
|
};
|
|
2122
2119
|
}
|
|
2123
2120
|
try {
|
|
2124
|
-
|
|
2125
|
-
await fluidOs.fluid_os_v0_update_fluid_osprofile(client, defId, profileId, { profile: body });
|
|
2121
|
+
await fluid_os_v0_update_fluid_osprofile(client, defId, profileId, { profile: resolveProfileBody(await readPortalFile(portalDir, file), currentMappings) });
|
|
2126
2122
|
results.push({
|
|
2127
2123
|
file,
|
|
2128
2124
|
action: "updated",
|
|
@@ -2157,7 +2153,7 @@ async function pushProfiles(client, defId, portalDir, changes, mappings) {
|
|
|
2157
2153
|
};
|
|
2158
2154
|
}
|
|
2159
2155
|
try {
|
|
2160
|
-
await
|
|
2156
|
+
await fluid_os_v0_delete_fluid_osprofile(client, defId, profileId);
|
|
2161
2157
|
currentMappings = removeMapping(currentMappings, "profiles", slug);
|
|
2162
2158
|
results.push({
|
|
2163
2159
|
file,
|
|
@@ -2414,7 +2410,7 @@ async function selectDefinition(client, appName) {
|
|
|
2414
2410
|
const definitions = [];
|
|
2415
2411
|
let page = 1;
|
|
2416
2412
|
while (true) {
|
|
2417
|
-
const response = await
|
|
2413
|
+
const response = await fluid_os_v0_list_fluid_osdefinitions(client, {
|
|
2418
2414
|
page,
|
|
2419
2415
|
per_page: 500
|
|
2420
2416
|
});
|
|
@@ -2783,7 +2779,7 @@ async function readSourcePackageExtractorOutput(outputFile) {
|
|
|
2783
2779
|
details: `Output was: ${output.slice(0, 200)}`
|
|
2784
2780
|
});
|
|
2785
2781
|
}
|
|
2786
|
-
if (!isRecord$
|
|
2782
|
+
if (!isRecord$5(parsed) || parsed.sentinel !== SOURCE_PACKAGE_OUTPUT_SENTINEL) return failure({
|
|
2787
2783
|
code: "INVALID_FORMAT",
|
|
2788
2784
|
message: "Widget package extractor output file had an invalid sentinel"
|
|
2789
2785
|
});
|
|
@@ -2890,7 +2886,7 @@ try {
|
|
|
2890
2886
|
}
|
|
2891
2887
|
`;
|
|
2892
2888
|
}
|
|
2893
|
-
function isRecord$
|
|
2889
|
+
function isRecord$5(value) {
|
|
2894
2890
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2895
2891
|
}
|
|
2896
2892
|
//#endregion
|
|
@@ -2998,6 +2994,29 @@ function toPosixPath$1(value) {
|
|
|
2998
2994
|
return value.split(path.sep).join("/");
|
|
2999
2995
|
}
|
|
3000
2996
|
//#endregion
|
|
2997
|
+
//#region ../../portal/core/src/remote-dom-widget-package.ts
|
|
2998
|
+
const UNSAFE_JSON_KEYS = new Set([
|
|
2999
|
+
"__proto__",
|
|
3000
|
+
"constructor",
|
|
3001
|
+
"prototype"
|
|
3002
|
+
]);
|
|
3003
|
+
function isJsonValue(value) {
|
|
3004
|
+
return isJsonValueAtDepth(value, /* @__PURE__ */ new WeakSet(), 0);
|
|
3005
|
+
}
|
|
3006
|
+
function isJsonValueAtDepth(value, ancestors, depth) {
|
|
3007
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
3008
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
3009
|
+
if (typeof value !== "object" || depth > 50 || ancestors.has(value)) return false;
|
|
3010
|
+
ancestors.add(value);
|
|
3011
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3012
|
+
const isJson = Array.isArray(value) ? value.every((item) => isJsonValueAtDepth(item, ancestors, depth + 1)) : (prototype === Object.prototype || prototype === null) && isRecord$4(value) && Object.entries(value).every(([key, item]) => !UNSAFE_JSON_KEYS.has(key) && isJsonValueAtDepth(item, ancestors, depth + 1));
|
|
3013
|
+
ancestors.delete(value);
|
|
3014
|
+
return isJson;
|
|
3015
|
+
}
|
|
3016
|
+
function isRecord$4(value) {
|
|
3017
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3018
|
+
}
|
|
3019
|
+
//#endregion
|
|
3001
3020
|
//#region src/utils/widget-package-validation.ts
|
|
3002
3021
|
const URL_SAFE_SEGMENT_SOURCE = "[A-Za-z0-9][A-Za-z0-9_~-]*";
|
|
3003
3022
|
const URL_SAFE_WIDGET_NAME_PATTERN = new RegExp(`^${URL_SAFE_SEGMENT_SOURCE}$`);
|
|
@@ -3881,7 +3900,7 @@ function getWidgetPackageCompleteUploadRoute(owner, version) {
|
|
|
3881
3900
|
async function requestWidgetPackageUploadSession(client, owner, request) {
|
|
3882
3901
|
const payload = buildWidgetPackageUploadSessionPayload(request);
|
|
3883
3902
|
try {
|
|
3884
|
-
return normalizeWidgetPackageUploadSession(owner.kind === "company" ? await
|
|
3903
|
+
return normalizeWidgetPackageUploadSession(owner.kind === "company" ? await fluid_os_v0_create_widget_package_version(client, payload) : await client.post(getWidgetPackageUploadSessionRoute(owner), payload), request.version, request.artifacts);
|
|
3885
3904
|
} catch (err) {
|
|
3886
3905
|
if (err instanceof WidgetPackageUploadError) throw err;
|
|
3887
3906
|
throw new WidgetPackageUploadError("SESSION_REQUEST_FAILED", `Failed to create widget package upload session: ${formatUnknownError(err)}`);
|
|
@@ -3920,7 +3939,7 @@ async function uploadWidgetPackageArtifacts(session, artifacts, fetchImpl = fetc
|
|
|
3920
3939
|
async function completeWidgetPackageUpload(client, owner, version, packageKey, artifacts) {
|
|
3921
3940
|
const payload = buildWidgetPackageCompleteUploadPayload(packageKey, artifacts);
|
|
3922
3941
|
try {
|
|
3923
|
-
return normalizeWidgetPackageCompleteResponse(owner.kind === "company" ? await
|
|
3942
|
+
return normalizeWidgetPackageCompleteResponse(owner.kind === "company" ? await fluid_os_v0_complete_widget_package_version_upload(client, version, payload) : await client.post(getWidgetPackageCompleteUploadRoute(owner, version), payload), version);
|
|
3924
3943
|
} catch (err) {
|
|
3925
3944
|
if (err instanceof WidgetPackageUploadError) throw err;
|
|
3926
3945
|
throw new WidgetPackageUploadError("COMPLETE_UPLOAD_FAILED", `Failed to complete widget package upload: ${formatUnknownError(err)}`);
|
|
@@ -4537,7 +4556,7 @@ const createVersionCommand = new Command("create").description("Create a new ver
|
|
|
4537
4556
|
console.log(chalk.bold("Creating version..."));
|
|
4538
4557
|
let result;
|
|
4539
4558
|
try {
|
|
4540
|
-
result = await
|
|
4559
|
+
result = await fluid_os_v0_create_fluid_osversion(client, definitionId);
|
|
4541
4560
|
} catch (err) {
|
|
4542
4561
|
console.error(chalk.red("Error:") + " Failed to create version — " + (err instanceof Error ? err.message : String(err)));
|
|
4543
4562
|
process.exit(1);
|
|
@@ -4555,7 +4574,7 @@ const createVersionCommand = new Command("create").description("Create a new ver
|
|
|
4555
4574
|
if (options.activate) {
|
|
4556
4575
|
console.log("Activating version...");
|
|
4557
4576
|
try {
|
|
4558
|
-
await
|
|
4577
|
+
await fluid_os_v0_update_fluid_osversion(client, definitionId, version.id, { version: { active: true } });
|
|
4559
4578
|
} catch (err) {
|
|
4560
4579
|
console.error(chalk.red("Error:") + " Failed to activate version — " + (err instanceof Error ? err.message : String(err)));
|
|
4561
4580
|
process.exit(1);
|
|
@@ -4570,7 +4589,7 @@ const listVersionCommand = new Command("list").description("List all versions of
|
|
|
4570
4589
|
const definitionId = await requireDefinitionId();
|
|
4571
4590
|
let result;
|
|
4572
4591
|
try {
|
|
4573
|
-
result = await
|
|
4592
|
+
result = await fluid_os_v0_list_fluid_osversions(client, definitionId);
|
|
4574
4593
|
} catch (err) {
|
|
4575
4594
|
console.error(chalk.red("Error:") + " Failed to list versions — " + (err instanceof Error ? err.message : String(err)));
|
|
4576
4595
|
process.exit(1);
|
|
@@ -4613,7 +4632,7 @@ const activateVersionCommand = new Command("activate").description("Activate a s
|
|
|
4613
4632
|
console.log();
|
|
4614
4633
|
console.log(chalk.bold("Activating version..."));
|
|
4615
4634
|
try {
|
|
4616
|
-
await
|
|
4635
|
+
await fluid_os_v0_update_fluid_osversion(client, definitionId, versionId, { version: { active: true } });
|
|
4617
4636
|
} catch (err) {
|
|
4618
4637
|
console.error(chalk.red("Error:") + " Failed to activate version — " + (err instanceof Error ? err.message : String(err)));
|
|
4619
4638
|
process.exit(1);
|