@vortexm/vjt 0.1.11 → 0.1.12

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.js CHANGED
@@ -3900,7 +3900,7 @@ var NetworkRuntime = class {
3900
3900
  }
3901
3901
  }
3902
3902
  async executeRequest(requestName, currentValue) {
3903
- const definition = this.requestsMap[requestName];
3903
+ const definition = resolveRequestDefinition(this.requestsMap, requestName);
3904
3904
  if (!definition) {
3905
3905
  return null;
3906
3906
  }
@@ -4125,6 +4125,24 @@ var NetworkRuntime = class {
4125
4125
  await this.rerenderRoot();
4126
4126
  }
4127
4127
  };
4128
+ function isRequestDefinitionLike(value) {
4129
+ return typeof value === "object" && value !== null && "request" in value && "name" in value;
4130
+ }
4131
+ function resolveRequestDefinition(requestsMap, requestName) {
4132
+ const directMatch = requestsMap[requestName];
4133
+ if (isRequestDefinitionLike(directMatch)) {
4134
+ return directMatch;
4135
+ }
4136
+ const segments = requestName.split(".").filter(Boolean);
4137
+ let current = requestsMap;
4138
+ for (const segment of segments) {
4139
+ if (typeof current !== "object" || current === null || !(segment in current)) {
4140
+ return void 0;
4141
+ }
4142
+ current = current[segment];
4143
+ }
4144
+ return isRequestDefinitionLike(current) ? current : void 0;
4145
+ }
4128
4146
 
4129
4147
  // src/lib/references.ts
4130
4148
  function isPlainObject2(value) {
@@ -4256,13 +4274,16 @@ var ReferenceRuntime = class {
4256
4274
  constructor(host) {
4257
4275
  this.host = host;
4258
4276
  }
4259
- isEmptyReference(reference, currentValue, responseValue) {
4260
- return isReferenceValueEmpty(this.resolveReference(reference, currentValue, responseValue));
4277
+ isEmptyReference(reference, currentValue, responseValue, inputValue) {
4278
+ return isReferenceValueEmpty(this.resolveReference(reference, currentValue, responseValue, inputValue));
4261
4279
  }
4262
- resolveReference(reference, currentValue, responseValue) {
4280
+ resolveReference(reference, currentValue, responseValue, inputValue = currentValue) {
4263
4281
  if (reference === "current") {
4264
4282
  return currentValue;
4265
4283
  }
4284
+ if (reference === "input") {
4285
+ return inputValue;
4286
+ }
4266
4287
  if (reference === "message") {
4267
4288
  return responseValue;
4268
4289
  }
@@ -4275,6 +4296,9 @@ var ReferenceRuntime = class {
4275
4296
  if (reference.startsWith("current.")) {
4276
4297
  return this.resolveCurrentReference(reference.slice(8), currentValue);
4277
4298
  }
4299
+ if (reference.startsWith("input.")) {
4300
+ return readPath(inputValue, reference.slice(6).split("."));
4301
+ }
4278
4302
  if (reference.startsWith("cookies.")) {
4279
4303
  return getCookieValue(reference.slice(8));
4280
4304
  }
@@ -4513,20 +4537,20 @@ var ReferenceRuntime = class {
4513
4537
  }
4514
4538
  }
4515
4539
  }
4516
- resolveMappedValue(template, currentValue, responseValue) {
4540
+ resolveMappedValue(template, currentValue, responseValue, inputValue = currentValue) {
4517
4541
  if (typeof template === "string") {
4518
4542
  if (template.startsWith("$ref:")) {
4519
- return this.resolveReference(template.slice(5), currentValue, responseValue);
4543
+ return this.resolveReference(template.slice(5), currentValue, responseValue, inputValue);
4520
4544
  }
4521
4545
  if (template.includes("$ref:")) {
4522
4546
  return template.replaceAll(/\$ref:([A-Za-z0-9_.]+)/g, (_match, ref) => {
4523
- const resolved = this.resolveReference(ref, currentValue, responseValue);
4547
+ const resolved = this.resolveReference(ref, currentValue, responseValue, inputValue);
4524
4548
  return stringifyReferenceValue(resolved);
4525
4549
  });
4526
4550
  }
4527
4551
  }
4528
4552
  if (Array.isArray(template)) {
4529
- return template.map((entry) => this.resolveMappedValue(entry, currentValue, responseValue));
4553
+ return template.map((entry) => this.resolveMappedValue(entry, currentValue, responseValue, inputValue));
4530
4554
  }
4531
4555
  if (isPlainObject2(template)) {
4532
4556
  const result = {};
@@ -4537,7 +4561,7 @@ var ReferenceRuntime = class {
4537
4561
  if (isTrustedConfigOnlyKey(key) && templateValueUsesReference(value)) {
4538
4562
  continue;
4539
4563
  }
4540
- result[key] = this.resolveMappedValue(value, currentValue, responseValue);
4564
+ result[key] = this.resolveMappedValue(value, currentValue, responseValue, inputValue);
4541
4565
  }
4542
4566
  return result;
4543
4567
  }
@@ -4794,8 +4818,9 @@ var ActionRuntime = class {
4794
4818
  responseValue: context.responseValue,
4795
4819
  pointer: context.pointer ?? null
4796
4820
  });
4797
- if (this.actionsMap[name]) {
4798
- return this.runActions(this.actionsMap[name], inputValue, context);
4821
+ const customAction = resolveActionDefinition(this.actionsMap, name);
4822
+ if (customAction) {
4823
+ return this.runActions(customAction, inputValue, context);
4799
4824
  }
4800
4825
  if (name.startsWith("refresh ")) {
4801
4826
  await this.refreshWidgetTree(name.slice(8));
@@ -4822,7 +4847,7 @@ var ActionRuntime = class {
4822
4847
  return null;
4823
4848
  }
4824
4849
  if (name.startsWith("play ")) {
4825
- await this.playAudio(this.resolveReference(name.slice(5), context.currentValue, context.responseValue));
4850
+ await this.playAudio(this.resolveReference(name.slice(5), context.currentValue, context.responseValue, inputValue));
4826
4851
  return null;
4827
4852
  }
4828
4853
  if (name === "copyToClipboard") {
@@ -4935,18 +4960,18 @@ var ActionRuntime = class {
4935
4960
  if (name.startsWith("get ")) {
4936
4961
  const reference = name.slice(4);
4937
4962
  if (Array.isArray(inputValue) && this.isCurrentScopedReference(reference)) {
4938
- return inputValue.map((entry) => this.resolveReference(reference, entry, context.responseValue)).filter((entry) => entry !== null && entry !== void 0);
4963
+ return inputValue.map((entry) => this.resolveReference(reference, entry, context.responseValue, entry)).filter((entry) => entry !== null && entry !== void 0);
4939
4964
  }
4940
- return this.resolveReference(reference, context.currentValue, context.responseValue);
4965
+ return this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
4941
4966
  }
4942
4967
  if (name.startsWith("getFirst ")) {
4943
- return this.getCollectionBoundary(name.slice(9), "first");
4968
+ return this.getCollectionBoundaryByReference(name.slice(9), inputValue, context, "first");
4944
4969
  }
4945
4970
  if (name.startsWith("getLast ")) {
4946
- return this.getCollectionBoundary(name.slice(8), "last");
4971
+ return this.getCollectionBoundaryByReference(name.slice(8), inputValue, context, "last");
4947
4972
  }
4948
4973
  if (name.startsWith("count ")) {
4949
- return this.countValue(this.resolveReference(name.slice(6), context.currentValue, context.responseValue));
4974
+ return this.countValue(this.resolveReference(name.slice(6), context.currentValue, context.responseValue, inputValue));
4950
4975
  }
4951
4976
  if (name === "indexOf") {
4952
4977
  if (isListElementLike(context.currentValue)) {
@@ -4985,25 +5010,25 @@ var ActionRuntime = class {
4985
5010
  return this.stringifyValue(inputValue).replaceAll(/\r\n/g, "\n").replaceAll(/\n{3,}/g, "\n\n");
4986
5011
  }
4987
5012
  if (name.startsWith("equals ")) {
4988
- return this.resolveReference(name.slice(7), context.currentValue, context.responseValue) === action.args;
5013
+ return this.resolveReference(name.slice(7), context.currentValue, context.responseValue, inputValue) === action.args;
4989
5014
  }
4990
5015
  if (name.startsWith("greaterThan ")) {
4991
- return this.toNumber(inputValue) > this.toNumber(this.resolveReference(name.slice(12), context.currentValue, context.responseValue));
5016
+ return this.toNumber(inputValue) > this.toNumber(this.resolveReference(name.slice(12), context.currentValue, context.responseValue, inputValue));
4992
5017
  }
4993
5018
  if (name.startsWith("greaterThanOrEquals ")) {
4994
- return this.toNumber(inputValue) >= this.toNumber(this.resolveReference(name.slice(20), context.currentValue, context.responseValue));
5019
+ return this.toNumber(inputValue) >= this.toNumber(this.resolveReference(name.slice(20), context.currentValue, context.responseValue, inputValue));
4995
5020
  }
4996
5021
  if (name.startsWith("lessThan ")) {
4997
- return this.toNumber(inputValue) < this.toNumber(this.resolveReference(name.slice(9), context.currentValue, context.responseValue));
5022
+ return this.toNumber(inputValue) < this.toNumber(this.resolveReference(name.slice(9), context.currentValue, context.responseValue, inputValue));
4998
5023
  }
4999
5024
  if (name.startsWith("lessThanOrEquals ")) {
5000
- return this.toNumber(inputValue) <= this.toNumber(this.resolveReference(name.slice(17), context.currentValue, context.responseValue));
5025
+ return this.toNumber(inputValue) <= this.toNumber(this.resolveReference(name.slice(17), context.currentValue, context.responseValue, inputValue));
5001
5026
  }
5002
5027
  if (name.startsWith("and ")) {
5003
- return Boolean(inputValue) && Boolean(this.resolveReference(name.slice(4), context.currentValue, context.responseValue));
5028
+ return Boolean(inputValue) && Boolean(this.resolveReference(name.slice(4), context.currentValue, context.responseValue, inputValue));
5004
5029
  }
5005
5030
  if (name.startsWith("isEmpty ")) {
5006
- return this.isEmptyReference(name.slice(8), context.currentValue, context.responseValue);
5031
+ return this.isEmptyReference(name.slice(8), context.currentValue, context.responseValue, inputValue);
5007
5032
  }
5008
5033
  if (name.startsWith("set ")) {
5009
5034
  const args = typeof action.args === "object" && action.args !== null && !Array.isArray(action.args) ? action.args : void 0;
@@ -5011,14 +5036,14 @@ var ActionRuntime = class {
5011
5036
  return inputValue;
5012
5037
  }
5013
5038
  if (name.startsWith("setFirst ")) {
5014
- return this.setCollectionBoundary(name.slice(9), inputValue, "first");
5039
+ return this.setCollectionBoundaryByReference(name.slice(9), inputValue, context, "first");
5015
5040
  }
5016
5041
  if (name.startsWith("setLast ")) {
5017
- return this.setCollectionBoundary(name.slice(8), inputValue, "last");
5042
+ return this.setCollectionBoundaryByReference(name.slice(8), inputValue, context, "last");
5018
5043
  }
5019
5044
  if (name.startsWith("append ")) {
5020
5045
  const reference = name.slice(7);
5021
- const currentText = this.resolveReference(reference, context.currentValue, context.responseValue);
5046
+ const currentText = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5022
5047
  const nextValue = `${this.stringifyValue(currentText)}${this.stringifyValue(action.args)}`;
5023
5048
  this.assignReference(reference, nextValue, context.currentValue);
5024
5049
  return nextValue;
@@ -5026,9 +5051,9 @@ var ActionRuntime = class {
5026
5051
  if (name.startsWith("filter ")) {
5027
5052
  const reference = name.slice(7);
5028
5053
  if (Array.isArray(inputValue) && this.isCurrentScopedReference(reference)) {
5029
- return inputValue.filter((entry) => this.resolveReference(reference, entry, context.responseValue));
5054
+ return inputValue.filter((entry) => this.resolveReference(reference, entry, context.responseValue, entry));
5030
5055
  }
5031
- const value = this.resolveReference(reference, context.currentValue, context.responseValue);
5056
+ const value = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5032
5057
  return value ? inputValue : null;
5033
5058
  }
5034
5059
  if (name === "remove") {
@@ -5044,7 +5069,7 @@ var ActionRuntime = class {
5044
5069
  return null;
5045
5070
  }
5046
5071
  if (name.startsWith("add ")) {
5047
- const valueToAdd = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(4), context.currentValue, context.responseValue)));
5072
+ const valueToAdd = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(4), context.currentValue, context.responseValue, inputValue)));
5048
5073
  const listState = this.getCurrentListState(context.currentValue);
5049
5074
  if (listState && Array.isArray(listState.elements)) {
5050
5075
  listState.elements.push(valueToAdd);
@@ -5071,7 +5096,7 @@ var ActionRuntime = class {
5071
5096
  return inputValue;
5072
5097
  }
5073
5098
  if (name.startsWith("insert ")) {
5074
- const valueToInsert = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(7), context.currentValue, context.responseValue)));
5099
+ const valueToInsert = this.cloneValue(this.unwrapListValue(this.resolveReference(name.slice(7), context.currentValue, context.responseValue, inputValue)));
5075
5100
  const listState = this.getCurrentListState(context.currentValue);
5076
5101
  if (listState && Array.isArray(listState.elements) && typeof context.currentValue === "object" && context.currentValue !== null && "index" in context.currentValue) {
5077
5102
  const index = context.currentValue.index;
@@ -5102,9 +5127,12 @@ var ActionRuntime = class {
5102
5127
  }
5103
5128
  if (name === "map") {
5104
5129
  if (Array.isArray(inputValue)) {
5105
- return inputValue.map((entry) => this.resolveMappedValue(action.args, entry, context.responseValue));
5130
+ return inputValue.map((entry) => this.resolveMappedValue(action.args, entry, context.responseValue, entry));
5106
5131
  }
5107
- return this.resolveMappedValue(action.args, inputValue, context.responseValue);
5132
+ return this.resolveMappedValue(action.args, inputValue, context.responseValue, inputValue);
5133
+ }
5134
+ if (name === "setInput") {
5135
+ return this.resolveMappedValue(action.args, context.currentValue, context.responseValue, inputValue);
5108
5136
  }
5109
5137
  if (name === "ifelse") {
5110
5138
  const branches = isIfElseArgs(action.args) ? action.args : null;
@@ -5146,32 +5174,42 @@ var ActionRuntime = class {
5146
5174
  }
5147
5175
  return JSON.stringify(value);
5148
5176
  }
5149
- getCollectionBoundary(widgetId, boundary) {
5150
- const state = this.stateById.get(widgetId) ?? this.stateByKey.get(widgetId);
5151
- const collection = this.getWidgetCollection(state);
5177
+ getCollectionBoundaryByReference(reference, inputValue, context, boundary) {
5178
+ const collection = this.resolveCollectionReference(reference, inputValue, context);
5152
5179
  if (!collection || collection.length === 0) {
5153
5180
  return null;
5154
5181
  }
5155
- const index = boundary === "first" ? 0 : collection.length - 1;
5156
- const value = collection[index];
5157
- return isListElementLike(value) ? this.unwrapListValue(value) : value;
5182
+ return collection[boundary === "first" ? 0 : collection.length - 1];
5158
5183
  }
5159
- setCollectionBoundary(widgetId, inputValue, boundary) {
5160
- const state = this.stateById.get(widgetId) ?? this.stateByKey.get(widgetId);
5161
- if (!state) {
5184
+ setCollectionBoundaryByReference(reference, inputValue, context, boundary) {
5185
+ const state = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5186
+ const directCollection = this.getWidgetCollection(this.asWidgetState(state));
5187
+ if (directCollection && directCollection.length > 0) {
5188
+ directCollection[boundary === "first" ? 0 : directCollection.length - 1] = this.cloneValue(this.unwrapListValue(inputValue));
5189
+ const widgetState = this.asWidgetState(state);
5190
+ if (widgetState && (widgetState.widget === "list" || widgetState.widget === "grid-view")) {
5191
+ this.clearListElementState(widgetState.key);
5192
+ }
5162
5193
  return inputValue;
5163
5194
  }
5164
- const collection = this.getWidgetCollection(state);
5195
+ const collection = this.resolveCollectionReference(reference, inputValue, context);
5165
5196
  if (!collection || collection.length === 0) {
5166
5197
  return inputValue;
5167
5198
  }
5168
- const index = boundary === "first" ? 0 : collection.length - 1;
5169
- collection[index] = this.cloneValue(this.unwrapListValue(inputValue));
5170
- if (state.widget === "list" || state.widget === "grid-view") {
5171
- this.clearListElementState(state.key);
5172
- }
5199
+ const nextCollection = collection.map((entry) => this.cloneValue(this.unwrapListValue(entry)));
5200
+ nextCollection[boundary === "first" ? 0 : nextCollection.length - 1] = this.cloneValue(this.unwrapListValue(inputValue));
5201
+ this.assignReference(reference, nextCollection, context.currentValue);
5173
5202
  return inputValue;
5174
5203
  }
5204
+ resolveCollectionReference(reference, inputValue, context) {
5205
+ const resolved = this.resolveReference(reference, context.currentValue, context.responseValue, inputValue);
5206
+ const widgetCollection = this.getWidgetCollection(this.asWidgetState(resolved));
5207
+ const collection = Array.isArray(resolved) ? resolved : widgetCollection;
5208
+ if (!collection) {
5209
+ return null;
5210
+ }
5211
+ return collection.map((entry) => this.unwrapListValue(entry));
5212
+ }
5175
5213
  getWidgetCollection(state) {
5176
5214
  if (!state) {
5177
5215
  return null;
@@ -5187,6 +5225,12 @@ var ActionRuntime = class {
5187
5225
  }
5188
5226
  return null;
5189
5227
  }
5228
+ asWidgetState(value) {
5229
+ if (!value || typeof value !== "object") {
5230
+ return null;
5231
+ }
5232
+ return value;
5233
+ }
5190
5234
  isCurrentScopedReference(reference) {
5191
5235
  return reference === "current" || reference.startsWith("current.") || reference.startsWith("this.") || reference === "this";
5192
5236
  }
@@ -5234,6 +5278,21 @@ var ActionRuntime = class {
5234
5278
  function isIfElseArgs(value) {
5235
5279
  return typeof value === "object" && value !== null && !Array.isArray(value);
5236
5280
  }
5281
+ function resolveActionDefinition(actionsMap, actionName) {
5282
+ const directMatch = actionsMap[actionName];
5283
+ if (Array.isArray(directMatch)) {
5284
+ return directMatch;
5285
+ }
5286
+ const segments = actionName.split(".").filter(Boolean);
5287
+ let current = actionsMap;
5288
+ for (const segment of segments) {
5289
+ if (typeof current !== "object" || current === null || !(segment in current)) {
5290
+ return void 0;
5291
+ }
5292
+ current = current[segment];
5293
+ }
5294
+ return Array.isArray(current) ? current : void 0;
5295
+ }
5237
5296
  function isListElementLike(value) {
5238
5297
  return typeof value === "object" && value !== null && "kind" in value && value.kind === "list-element" && "listId" in value && typeof value.listId === "string" && "index" in value && typeof value.index === "number" && "descriptor" in value;
5239
5298
  }
@@ -7446,10 +7505,10 @@ var RuntimeRenderer = class {
7446
7505
  rerenderRoot: () => this.rerenderRoot(),
7447
7506
  dispatchWidgetEvent: (node, eventName, key, inputValue, pointer) => this.actionRuntime.dispatchWidgetEvent(node, eventName, key, inputValue, pointer),
7448
7507
  executeRequest: (requestName, currentValue) => this.networkRuntime.executeRequest(requestName, currentValue),
7449
- resolveReference: (reference, currentValue, responseValue) => this.referenceRuntime.resolveReference(reference, currentValue, responseValue),
7450
- isEmptyReference: (reference, currentValue, responseValue) => this.referenceRuntime.isEmptyReference(reference, currentValue, responseValue),
7508
+ resolveReference: (reference, currentValue, responseValue, inputValue) => this.referenceRuntime.resolveReference(reference, currentValue, responseValue, inputValue),
7509
+ isEmptyReference: (reference, currentValue, responseValue, inputValue) => this.referenceRuntime.isEmptyReference(reference, currentValue, responseValue, inputValue),
7451
7510
  assignReference: (reference, inputValue, currentValue, options2) => this.referenceRuntime.assignReference(reference, inputValue, currentValue, options2),
7452
- resolveMappedValue: (template, currentValue, responseValue) => this.referenceRuntime.resolveMappedValue(template, currentValue, responseValue),
7511
+ resolveMappedValue: (template, currentValue, responseValue, inputValue) => this.referenceRuntime.resolveMappedValue(template, currentValue, responseValue, inputValue),
7453
7512
  setWidgetEnabled: (widgetId, enabled) => this.setWidgetEnabled(widgetId, enabled),
7454
7513
  setWidgetVisible: (widgetId, visible) => this.setWidgetVisible(widgetId, visible),
7455
7514
  clearWidget: (widgetId) => this.clearWidget(widgetId),
@@ -9144,6 +9203,39 @@ function renderApp(root, description, options = {}) {
9144
9203
  }
9145
9204
 
9146
9205
  // src/lib/resource-manager.ts
9206
+ function isRequestDefinitionLike2(value) {
9207
+ return typeof value === "object" && value !== null && "request" in value && "name" in value;
9208
+ }
9209
+ function flattenActionMap(input, prefix = "") {
9210
+ const result = {};
9211
+ if (!input) {
9212
+ return result;
9213
+ }
9214
+ for (const [key, value] of Object.entries(input)) {
9215
+ const qualifiedName = prefix ? `${prefix}.${key}` : key;
9216
+ if (Array.isArray(value)) {
9217
+ result[qualifiedName] = value;
9218
+ continue;
9219
+ }
9220
+ Object.assign(result, flattenActionMap(value, qualifiedName));
9221
+ }
9222
+ return result;
9223
+ }
9224
+ function flattenRequestMap(input, prefix = "") {
9225
+ const result = {};
9226
+ if (!input) {
9227
+ return result;
9228
+ }
9229
+ for (const [key, value] of Object.entries(input)) {
9230
+ const qualifiedName = prefix ? `${prefix}.${key}` : key;
9231
+ if (isRequestDefinitionLike2(value)) {
9232
+ result[qualifiedName] = value;
9233
+ continue;
9234
+ }
9235
+ Object.assign(result, flattenRequestMap(value, qualifiedName));
9236
+ }
9237
+ return result;
9238
+ }
9147
9239
  var ResourceManager = class {
9148
9240
  ui = /* @__PURE__ */ new Map();
9149
9241
  actions = {};
@@ -9157,8 +9249,8 @@ var ResourceManager = class {
9157
9249
  for (const [key, value] of Object.entries(input.ui ?? {})) {
9158
9250
  this.ui.set(key, value);
9159
9251
  }
9160
- this.actions = { ...input.actions ?? {} };
9161
- this.requests = { ...input.requests ?? {} };
9252
+ this.actions = flattenActionMap(input.actions);
9253
+ this.requests = flattenRequestMap(input.requests);
9162
9254
  this.routes = Array.isArray(input.routes) ? input.routes.map((route) => ({ ...route })) : Array.isArray(input.routes?.routes) ? input.routes.routes.map((route) => ({ ...route })) : [];
9163
9255
  this.sse = { ...input.sse ?? {} };
9164
9256
  this.systemEvents = { ...input.systemEvents ?? {} };
@@ -1,4 +1,4 @@
1
- import type { ActionDefinition, ActionMap, DescriptionNode, WidgetEventName, WidgetState } from './types.js';
1
+ import type { ActionDefinition, ActionMapInput, DescriptionNode, WidgetEventName, WidgetState } from './types.js';
2
2
  export type ActionExecutionContext = {
3
3
  currentValue: unknown;
4
4
  responseValue?: unknown;
@@ -11,7 +11,7 @@ export type ActionExecutionContext = {
11
11
  };
12
12
  type ActionRuntimeOptions = {
13
13
  debugLogging: boolean;
14
- actionsMap: ActionMap;
14
+ actionsMap: ActionMapInput;
15
15
  actionFunctions: Record<string, () => unknown>;
16
16
  nodeById: Map<string, DescriptionNode>;
17
17
  stateById: Map<string, WidgetState>;
@@ -22,12 +22,12 @@ type ActionRuntimeOptions = {
22
22
  y: number;
23
23
  } | null) => Promise<void>;
24
24
  executeRequest: (requestName: string, currentValue: unknown) => Promise<unknown>;
25
- resolveReference: (reference: string, currentValue: unknown, responseValue: unknown) => unknown;
26
- isEmptyReference: (reference: string, currentValue: unknown, responseValue: unknown) => boolean;
25
+ resolveReference: (reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown) => unknown;
26
+ isEmptyReference: (reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown) => boolean;
27
27
  assignReference: (reference: string, inputValue: unknown, currentValue: unknown, options?: {
28
28
  cookieTtl?: unknown;
29
29
  }) => void;
30
- resolveMappedValue: (template: unknown, currentValue: unknown, responseValue: unknown) => unknown;
30
+ resolveMappedValue: (template: unknown, currentValue: unknown, responseValue: unknown, inputValue?: unknown) => unknown;
31
31
  setWidgetEnabled: (widgetId: string, enabled: boolean) => void;
32
32
  setWidgetVisible: (widgetId: string, visible: boolean) => void;
33
33
  clearWidget: (widgetId: string) => void;
@@ -124,9 +124,11 @@ export declare class ActionRuntime {
124
124
  private getCurrentListState;
125
125
  private cloneValue;
126
126
  private stringifyValue;
127
- private getCollectionBoundary;
128
- private setCollectionBoundary;
127
+ private getCollectionBoundaryByReference;
128
+ private setCollectionBoundaryByReference;
129
+ private resolveCollectionReference;
129
130
  private getWidgetCollection;
131
+ private asWidgetState;
130
132
  private isCurrentScopedReference;
131
133
  private countValue;
132
134
  private toNumber;
@@ -1,11 +1,11 @@
1
- import type { ActionDefinition, PrimitiveRequestType, RequestMap, RequestSchema, SseConfig } from './types.js';
1
+ import type { ActionDefinition, PrimitiveRequestType, RequestMapInput, RequestSchema, SseConfig } from './types.js';
2
2
  type ActionRunner = (actions: ActionDefinition[], inputValue: unknown, context: {
3
3
  currentValue: unknown;
4
4
  responseValue?: unknown;
5
5
  }) => Promise<unknown>;
6
6
  type NetworkRuntimeOptions = {
7
7
  debugLogging: boolean;
8
- requestsMap: RequestMap;
8
+ requestsMap: RequestMapInput;
9
9
  sseConfigs: SseConfig[];
10
10
  backendUrl?: string;
11
11
  eventSources: EventSource[];
@@ -16,8 +16,8 @@ type ReferenceRuntimeHost = {
16
16
  export declare class ReferenceRuntime {
17
17
  private readonly host;
18
18
  constructor(host: ReferenceRuntimeHost);
19
- isEmptyReference(reference: string, currentValue: unknown, responseValue: unknown): boolean;
20
- resolveReference(reference: string, currentValue: unknown, responseValue: unknown): unknown;
19
+ isEmptyReference(reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown): boolean;
20
+ resolveReference(reference: string, currentValue: unknown, responseValue: unknown, inputValue?: unknown): unknown;
21
21
  resolveCurrentReference(reference: string, currentValue: unknown): unknown;
22
22
  readWidgetField(state: WidgetState, field: string): unknown;
23
23
  assignReference(reference: string, inputValue: unknown, currentValue: unknown, options?: {
@@ -25,7 +25,7 @@ export declare class ReferenceRuntime {
25
25
  }): void;
26
26
  private assignCurrentReference;
27
27
  clearListElementState(listKey: string): void;
28
- resolveMappedValue(template: unknown, currentValue: unknown, responseValue: unknown): unknown;
28
+ resolveMappedValue(template: unknown, currentValue: unknown, responseValue: unknown, inputValue?: unknown): unknown;
29
29
  isListElementContext(value: unknown): value is ListElementContext;
30
30
  findNamedWidget(node: DescriptionNode | undefined, name: string, currentValue?: unknown): DescriptionNode | null;
31
31
  private resolveListDescriptorNode;
@@ -1,8 +1,8 @@
1
- import type { ActionMap, DescriptionNode, I18nMap, RequestMap, RouteDefinition, RoutesConfigInput, SseConfig, SystemEventsMap, StyleMap } from './types.js';
1
+ import type { ActionMap, ActionMapInput, DescriptionNode, I18nMap, RequestMap, RequestMapInput, RouteDefinition, RoutesConfigInput, SseConfig, SystemEventsMap, StyleMap } from './types.js';
2
2
  export type ResourceManagerInput = {
3
3
  ui?: Record<string, DescriptionNode>;
4
- actions?: ActionMap;
5
- requests?: RequestMap;
4
+ actions?: ActionMapInput;
5
+ requests?: RequestMapInput;
6
6
  routes?: RoutesConfigInput;
7
7
  sse?: Record<string, SseConfig>;
8
8
  systemEvents?: SystemEventsMap;
@@ -93,6 +93,12 @@ export type StyleMap = Record<string, string>;
93
93
  export type I18nMap = Record<string, Record<string, string>>;
94
94
  export type ActionMap = Record<string, ActionDefinition[]>;
95
95
  export type RequestMap = Record<string, RequestDefinition>;
96
+ export type ActionMapInput = {
97
+ [key: string]: ActionDefinition[] | ActionMapInput;
98
+ };
99
+ export type RequestMapInput = {
100
+ [key: string]: RequestDefinition | RequestMapInput;
101
+ };
96
102
  export type SseConfigInput = SseConfig | SseConfig[];
97
103
  export type SystemEventsMap = Partial<Record<SystemEventName, ActionDefinition[]>>;
98
104
  export type WidgetState = {
@@ -145,8 +151,8 @@ export type RenderJsonOptions = {
145
151
  language?: string;
146
152
  theme?: Theme;
147
153
  debugLogging?: boolean;
148
- actionsMap?: ActionMap;
149
- requestsMap?: RequestMap;
154
+ actionsMap?: ActionMapInput;
155
+ requestsMap?: RequestMapInput;
150
156
  sseConfigs?: SseConfigInput;
151
157
  systemEvents?: SystemEventsMap;
152
158
  routes?: RoutesConfigInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vortexm/vjt",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",