@fungi.computer/oyster 0.19.26 → 0.19.28

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/host.js CHANGED
@@ -692,11 +692,24 @@ export function oysterRouteTable(host) {
692
692
  const verified = await releaseOf(current.release);
693
693
  const declaration = verified.declaration ?? emptyAppDeclaration;
694
694
  const declared = await deriveDeclaredOperations(current.release, declaration, operationDescriptors);
695
+ const directory = host.workbench
696
+ ? await host.workbench.directory()
697
+ : null;
698
+ const appCalls = (declaration.calls ?? []).flatMap((call) => {
699
+ const targetName = directory?.apps.find((app) => app.appId === call.appId)
700
+ ?.displayName ?? `App ${call.appId}`;
701
+ return call.methods.map((method) => ({
702
+ operation: appCallOperation(call.appId, method),
703
+ method,
704
+ targetName,
705
+ }));
706
+ });
695
707
  const config = appPermissionPageSchema.parse({
696
708
  storeGeneration: generation,
697
709
  installationId: current.installationId,
698
710
  appId: current.appId,
699
711
  appName: declaration.displayName ?? current.installationId,
712
+ appCalls,
700
713
  artifactDigest: current.release.artifact.artifactDigest,
701
714
  canEdit: oysterPrincipalIsOwner(principal),
702
715
  resources: host.permissionResources === undefined
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { appCallMethodLabel } from "@fungi.computer/nacre/app-directory";
2
3
  import { useCallback, useEffect, useId, useRef, useState } from "react";
3
4
  import { Disclosure } from "@fungi.computer/caps/components/disclosure";
4
5
  import { Alert } from "@fungi.computer/caps/components/alert";
@@ -33,15 +34,6 @@ const gridHeadings = {
33
34
  scope: "Applies to",
34
35
  control: "Change",
35
36
  };
36
- /** "publishDraft" and "publish_draft" read as "Publish draft". */
37
- function methodLabel(operation) {
38
- const words = operation
39
- .replace(/([a-z0-9])([A-Z])/gu, "$1 $2")
40
- .replace(/[._-]+/gu, " ")
41
- .trim()
42
- .toLowerCase();
43
- return words.charAt(0).toUpperCase() + words.slice(1);
44
- }
45
37
  /** One grid row per grant: a label, its state in words and a labelled switch. */
46
38
  function grantRow(context, input) {
47
39
  return {
@@ -112,25 +104,31 @@ function appRows(context, group) {
112
104
  },
113
105
  });
114
106
  }),
115
- ...group.operations.map((operation) => grantRow(context, {
116
- id: `${operation.capability}:${operation.operation}`,
117
- capability: operation.capability,
118
- sigil: permissionCatalog["apps.call"].sigil,
119
- label: methodLabel(operation.operation),
120
- chip: groupLabels[group.id],
121
- scopeName: "Other Apps",
122
- pending: false,
123
- on: operation.on,
124
- locked: false,
125
- onChange: (on) => {
126
- context.edit({
127
- kind: "operation",
128
- capability: operation.capability,
129
- operation: operation.operation,
130
- on,
131
- });
132
- },
133
- })),
107
+ ...group.operations.map((operation) => {
108
+ const call = context.appCalls.find((call) => call.operation === operation.operation);
109
+ const words = call === undefined
110
+ ? "Use another App"
111
+ : appCallMethodLabel(call.method);
112
+ return grantRow(context, {
113
+ id: `${operation.capability}:${operation.operation}`,
114
+ capability: operation.capability,
115
+ sigil: permissionCatalog["apps.call"].sigil,
116
+ label: words.charAt(0).toUpperCase() + words.slice(1),
117
+ chip: groupLabels[group.id],
118
+ scopeName: call?.targetName ?? operation.operation,
119
+ pending: false,
120
+ on: operation.on,
121
+ locked: false,
122
+ onChange: (on) => {
123
+ context.edit({
124
+ kind: "operation",
125
+ capability: operation.capability,
126
+ operation: operation.operation,
127
+ on,
128
+ });
129
+ },
130
+ });
131
+ }),
134
132
  ];
135
133
  }
136
134
  /** Every row of a group: its resources' grants, then the App's own switches. */
@@ -334,6 +332,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
334
332
  const pending = baseline.pending.filter((capability) => capability !== "team.workbenchHost");
335
333
  const context = {
336
334
  disabled,
335
+ appCalls: view.appCalls,
337
336
  describedBy: (capability) => `${describeId}-${capability}`,
338
337
  edit,
339
338
  };
@@ -345,7 +344,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
345
344
  const first = rowsOf(askedIds.size > 0 ? groups.filter((g) => askedIds.has(g.id)) : groups);
346
345
  const later = askedIds.size > 0 ? rowsOf(groups.filter((g) => !askedIds.has(g.id))) : [];
347
346
  const showFooter = (groups.length > 0 && !shellChanged) || uncertain || refreshNeeded;
348
- return (_jsxs(Form, { style: { maxWidth: "var(--container-2xl)", marginInline: "auto" }, onSubmit: (event) => {
347
+ return (_jsxs(Form, { onSubmit: (event) => {
349
348
  event.preventDefault();
350
349
  void save();
351
350
  }, children: [_jsx(Toaster, { id: describeId }), !screen.canEdit && _jsx("p", { children: "Only an owner can change these permissions." }), pending.length > 0 && (_jsx(Alert, { tone: "warning", title: `${String(pending.length)} ${pending.length === 1 ? "permission needs" : "permissions need"} your OK`, action: screen.canEdit ? (_jsxs(Button, { type: "button", size: "xs", variant: "primary", disabled: disabled || shellChanged, onClick: () => {