@estiva-app/interop 0.104.0 → 0.105.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/interop",
3
- "version": "0.104.0",
3
+ "version": "0.105.0",
4
4
  "description": "Render and act on another app's objects from its published NIP-89 manifest. The owner defines the projection; the consumer decides how it looks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -106,6 +106,7 @@ export {
106
106
  type FolderRecord,
107
107
  type ResolvedSlot,
108
108
  type ResolvedAction,
109
+ type ResolvedOption,
109
110
  type ActionFormField,
110
111
  type ProseFormat,
111
112
  type ManifestAction,
package/src/projection.ts CHANGED
@@ -890,7 +890,26 @@ export interface ActionFormField {
890
890
  */
891
891
  format?: ProseFormat
892
892
  /** When the property names a vocabulary, its entries, already looked up. */
893
- options?: { value: string; label: string; colour?: string }[]
893
+ options?: ResolvedOption[]
894
+ }
895
+
896
+ /**
897
+ * A vocabulary entry a consumer draws and writes from. `stage` is the entry's
898
+ * declared stage when it is one of the four (SPEC §7.3) — what an app that
899
+ * builds its own change passes to {@link stageTagFor}, so the change says what
900
+ * the choice means as a declared action's does (EAC-5).
901
+ */
902
+ export interface ResolvedOption {
903
+ value: string
904
+ label: string
905
+ colour?: string
906
+ stage?: Stage
907
+ }
908
+
909
+ /** A vocabulary entry as a consumer gets it: its stage only when it is one of the four. */
910
+ function resolvedOption(entry: { value: string; label: string; colour: string; stage?: string }): ResolvedOption {
911
+ const stage = asStage(entry.stage)
912
+ return { value: entry.value, label: entry.label, colour: entry.colour, ...(stage ? { stage } : {}) }
894
913
  }
895
914
 
896
915
  /**
@@ -923,8 +942,8 @@ export interface ResolvedAction {
923
942
  * it.
924
943
  */
925
944
  control: 'select' | 'pubkey' | 'text' | 'form' | 'confirm'
926
- /** For `select`: the declared vocabulary, already looked up. */
927
- options?: { value: string; label: string; colour?: string }[]
945
+ /** For `select`: the declared vocabulary, already looked up, each entry with its stage (see {@link ResolvedOption}). */
946
+ options?: ResolvedOption[]
928
947
  /**
929
948
  * For `form`: the fields to draw, in declaration order, with any vocabulary
930
949
  * already looked up — the same service `options` performs for a `select`.
@@ -1126,13 +1145,7 @@ function resolveActions(
1126
1145
  // Prose only where the value is `content` — a tag is a scalar (§7.3).
1127
1146
  ...(spec.target === 'content' && proseFormatOf(spec.format) ? { format: proseFormatOf(spec.format) } : {}),
1128
1147
  ...(spec.enum && manifest.vocabularies?.[spec.enum]
1129
- ? {
1130
- options: manifest.vocabularies[spec.enum].map((v) => ({
1131
- value: v.value,
1132
- label: v.label,
1133
- colour: v.colour,
1134
- })),
1135
- }
1148
+ ? { options: manifest.vocabularies[spec.enum].map(resolvedOption) }
1136
1149
  : {}),
1137
1150
  })),
1138
1151
  // The parent is not a property and never appears in `properties`; it
@@ -1156,7 +1169,7 @@ function resolveActions(
1156
1169
  ...(action.effect ? { effect: action.effect } : {}),
1157
1170
  control,
1158
1171
  ...(format ? { format } : {}),
1159
- options: vocab?.map((v) => ({ value: v.value, label: v.label, colour: v.colour })),
1172
+ options: vocab?.map(resolvedOption),
1160
1173
  current: action.emits.field ? folded[action.emits.field]?.value : undefined,
1161
1174
  field: action.emits.field,
1162
1175
  })