@stackable-labs/cli-app-extension 1.94.0 → 1.96.0

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.
Files changed (2) hide show
  1. package/dist/index.js +88 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -98,7 +98,7 @@ var gradientColor = (row, col, rows, cols) => {
98
98
  const hi = Math.min(lo + 1, COLORS.length - 1);
99
99
  return lerp(COLORS[lo], COLORS[hi], idx - lo);
100
100
  };
101
- var Banner = ({ userId, orgId } = {}) => {
101
+ var Banner = ({ userId, orgId, appName, appId } = {}) => {
102
102
  const termWidth = process.stdout.columns ?? 80;
103
103
  const maxLen = Math.max(...WORDMARK.map((l) => l.length));
104
104
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
@@ -113,6 +113,15 @@ var Banner = ({ userId, orgId } = {}) => {
113
113
  /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
114
114
  /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Org:" }),
115
115
  /* @__PURE__ */ jsx(Text, { color: "cyan", children: orgId })
116
+ ] }),
117
+ appName && /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
118
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "App:" }),
119
+ /* @__PURE__ */ jsx(Text, { color: "cyan", children: appName }),
120
+ appId && /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
121
+ "(",
122
+ appId,
123
+ ")"
124
+ ] })
116
125
  ] })
117
126
  ] })
118
127
  ] })
@@ -605,6 +614,40 @@ var SettingsPrompt = ({ defaultDir, onSubmit, onBack }) => {
605
614
  );
606
615
  };
607
616
 
617
+ // ../../lib/contracts/src/base.ts
618
+ var asClerkUserId = (value) => value;
619
+ var asClerkOrgId = (value) => value;
620
+
621
+ // ../../lib/contracts/src/permissions.ts
622
+ var SUPER_ROLE = {
623
+ ADMIN: "org:super_admin"
624
+ };
625
+ var ORG_ROLE = {
626
+ ADMIN: "org:admin",
627
+ OWNER: "org:owner"};
628
+ var EDITOR_ROLES = [
629
+ SUPER_ROLE.ADMIN,
630
+ ORG_ROLE.ADMIN,
631
+ ORG_ROLE.OWNER
632
+ ];
633
+ [
634
+ ...Object.values(SUPER_ROLE),
635
+ ...Object.values(EDITOR_ROLES)
636
+ ];
637
+
638
+ // ../../lib/contracts/src/fields.ts
639
+ var FIELD_TYPE = {
640
+ TEXTAREA: "textarea",
641
+ TEXT: "text",
642
+ EMAIL: "email"};
643
+ var SECUREABLE_FIELD_TYPE = {
644
+ TEXT: FIELD_TYPE.TEXT,
645
+ TEXTAREA: FIELD_TYPE.TEXTAREA,
646
+ EMAIL: FIELD_TYPE.EMAIL
647
+ };
648
+ var typeAllowsSecret = (fieldType) => Object.values(SECUREABLE_FIELD_TYPE).includes(fieldType);
649
+ var allowsSecret = (field) => typeAllowsSecret(field.type);
650
+
608
651
  // src/lib/manifest-diff.ts
609
652
  var diffItems = (previous, next, getKey) => {
610
653
  const prevMap = new Map(previous.map((item) => [getKey(item), item]));
@@ -744,15 +787,17 @@ var ManifestReviewPrompt = ({
744
787
  const globalIndex = schemaSectionStart + index;
745
788
  const isCursor = globalIndex === cursor;
746
789
  const field = item.after ?? item.before;
747
- const detail = field ? `${field.type}${field.secret ? ", secret" : ""}` : "";
790
+ const detail = field ? `${field.type}${allowsSecret(field) && field.secret ? ", secret" : ""}` : "";
748
791
  let changeDetail;
749
792
  if (item.status === "changed" && item.before && item.after) {
750
793
  const parts = [];
751
794
  if (item.before.type !== item.after.type) {
752
795
  parts.push(`type ${item.before.type} \u2192 ${item.after.type}`);
753
796
  }
754
- if (item.before.secret !== item.after.secret) {
755
- parts.push(`secret ${!!item.before.secret} \u2192 ${!!item.after.secret}`);
797
+ const beforeSecret = allowsSecret(item.before) ? item.before.secret : void 0;
798
+ const afterSecret = allowsSecret(item.after) ? item.after.secret : void 0;
799
+ if (beforeSecret !== afterSecret) {
800
+ parts.push(`secret ${!!beforeSecret} \u2192 ${!!afterSecret}`);
756
801
  }
757
802
  if (item.before.label !== item.after.label) {
758
803
  parts.push(`label "${item.before.label}" \u2192 "${item.after.label}"`);
@@ -1167,27 +1212,6 @@ var TemplateSelect = ({ onSubmit, onBack }) => {
1167
1212
  );
1168
1213
  };
1169
1214
 
1170
- // ../../lib/contracts/src/base.ts
1171
- var asClerkUserId = (value) => value;
1172
- var asClerkOrgId = (value) => value;
1173
-
1174
- // ../../lib/contracts/src/permissions.ts
1175
- var SUPER_ROLE = {
1176
- ADMIN: "org:super_admin"
1177
- };
1178
- var ORG_ROLE = {
1179
- ADMIN: "org:admin",
1180
- OWNER: "org:owner"};
1181
- var EDITOR_ROLES = [
1182
- SUPER_ROLE.ADMIN,
1183
- ORG_ROLE.ADMIN,
1184
- ORG_ROLE.OWNER
1185
- ];
1186
- [
1187
- ...Object.values(SUPER_ROLE),
1188
- ...Object.values(EDITOR_ROLES)
1189
- ];
1190
-
1191
1215
  // ../../lib/utils-auth/src/constants.ts
1192
1216
  var STANDALONE_CLIENT_DATA = {
1193
1217
  CLI: { name: "@stackable-labs/cli-app-extension", authFile: "cli-auth.json" },
@@ -1383,16 +1407,26 @@ var updateExtension = async (token, appId, extensionId, payload) => {
1383
1407
  throw new Error(`Failed to update extension: ${res.status} ${body}`);
1384
1408
  }
1385
1409
  };
1410
+ var AUTO_SELECT_DELAY_MS = 600;
1386
1411
  var AppSelect = ({ token, userId, orgId, onSubmit }) => {
1387
1412
  const [apps, setApps] = useState([]);
1388
1413
  const [loading, setLoading] = useState(true);
1389
1414
  const [error, setError] = useState();
1390
1415
  const [cursor, setCursor] = useState(0);
1416
+ const autoSubmittedRef = useRef(false);
1391
1417
  useEffect(() => {
1392
1418
  fetchApps(token).then(setApps).catch((err) => setError(err instanceof Error ? err.message : String(err))).finally(() => setLoading(false));
1393
1419
  }, [token]);
1420
+ useEffect(() => {
1421
+ if (loading || error || autoSubmittedRef.current || apps.length !== 1) {
1422
+ return;
1423
+ }
1424
+ autoSubmittedRef.current = true;
1425
+ const timer = setTimeout(() => onSubmit(apps[0]), AUTO_SELECT_DELAY_MS);
1426
+ return () => clearTimeout(timer);
1427
+ }, [loading, error, apps, onSubmit]);
1394
1428
  useInput((_, key) => {
1395
- if (loading || error || apps.length === 0) {
1429
+ if (loading || error || apps.length <= 1) {
1396
1430
  return;
1397
1431
  }
1398
1432
  if (key.upArrow) {
@@ -1403,6 +1437,7 @@ var AppSelect = ({ token, userId, orgId, onSubmit }) => {
1403
1437
  onSubmit(apps[cursor]);
1404
1438
  }
1405
1439
  });
1440
+ const defaultApp = !loading && !error && apps.length === 1 ? apps[0] : void 0;
1406
1441
  const renderContent = () => {
1407
1442
  if (loading) {
1408
1443
  return /* @__PURE__ */ jsxs(Box, { gap: 2, children: [
@@ -1419,6 +1454,23 @@ var AppSelect = ({ token, userId, orgId, onSubmit }) => {
1419
1454
  if (apps.length === 0) {
1420
1455
  return /* @__PURE__ */ jsx(Text, { color: "yellow", children: "No Apps available. Contact your administrator." });
1421
1456
  }
1457
+ if (defaultApp) {
1458
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
1459
+ /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
1460
+ /* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
1461
+ /* @__PURE__ */ jsxs(Text, { children: [
1462
+ "Using ",
1463
+ /* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: defaultApp.name })
1464
+ ] }),
1465
+ /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
1466
+ "(",
1467
+ defaultApp.id,
1468
+ ")"
1469
+ ] })
1470
+ ] }),
1471
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Auto-selected \u2014 only one App available." })
1472
+ ] });
1473
+ }
1422
1474
  return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: apps.map((app, i) => {
1423
1475
  const isCursor = i === cursor;
1424
1476
  return /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
@@ -1433,7 +1485,7 @@ var AppSelect = ({ token, userId, orgId, onSubmit }) => {
1433
1485
  }) });
1434
1486
  };
1435
1487
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
1436
- /* @__PURE__ */ jsx(Banner, { userId, orgId }),
1488
+ /* @__PURE__ */ jsx(Banner, { userId, orgId, appName: defaultApp?.name, appId: defaultApp?.id }),
1437
1489
  /* @__PURE__ */ jsx(StepShell, { title: "Select the App you are building an Extension for:", children: renderContent() })
1438
1490
  ] });
1439
1491
  };
@@ -2601,7 +2653,15 @@ var App = ({ command, token, userId, orgId, initialName, initialExtensionId, opt
2601
2653
  case "app": {
2602
2654
  if (options?.appId || initialExtensionId && (command === "update" /* UPDATE */ || command === "scaffold" /* SCAFFOLD */)) {
2603
2655
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
2604
- /* @__PURE__ */ jsx(Banner, { userId, orgId }),
2656
+ /* @__PURE__ */ jsx(
2657
+ Banner,
2658
+ {
2659
+ userId,
2660
+ orgId,
2661
+ appId: selectedApp?.id,
2662
+ appName: selectedApp?.name
2663
+ }
2664
+ ),
2605
2665
  /* @__PURE__ */ jsx(StepShell, { title: "Loading App\u2026", children: /* @__PURE__ */ jsxs(Box, { gap: 2, children: [
2606
2666
  /* @__PURE__ */ jsx(Spinner5, { type: "dots" }),
2607
2667
  /* @__PURE__ */ jsx(Text, { children: options?.appId ? "Fetching app details\u2026" : "Resolving app from extension\u2026" })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/cli-app-extension",
3
- "version": "1.94.0",
3
+ "version": "1.96.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "bin": {