@jacebenson/jsn 4.3.7-dev.38 → 4.3.7-dev.39

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": "@jacebenson/jsn",
3
- "version": "4.3.7-dev.38",
3
+ "version": "4.3.7-dev.39",
4
4
  "description": "A command-line interface for ServiceNow that follows the Unix philosophy: simple, composable, and scriptable.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -230,14 +230,20 @@ export async function readActionDefinition(sdk, instance, actionTypeId, scope, {
230
230
  return { definition, schema };
231
231
  }
232
232
 
233
- function buildTypedInputs(action, schema) {
233
+ export function buildTypedInputs(action, schema) {
234
234
  const supplied = action.inputs || {};
235
- const allowed = new Set(schema.map(field => field.name));
235
+ const allowed = new Set(schema.map(field => field?.name).filter(Boolean));
236
236
  for (const key of Object.keys(supplied)) if (!allowed.has(key)) throw new Error(`Unsupported input "${key}" for action ${action.type}`);
237
237
  return schema.map(field => {
238
- if (!field || typeof field !== 'object' || !field.id || !field.parameter || typeof field.parameter !== 'object') {
238
+ // The instance's own definition is the contract: identity is required,
239
+ // everything else (including an optional `parameter` block) is echoed back
240
+ // untouched. Demanding a key the provider omits breaks real actions.
241
+ if (!field || typeof field !== 'object' || !field.id || !field.name) {
239
242
  throw new Error(`Action ${action.type} returned an incomplete input schema; refusing to invent input metadata for "${field?.name || 'unknown'}"`);
240
243
  }
244
+ if (field.parameter !== undefined && (typeof field.parameter !== 'object' || field.parameter === null || Array.isArray(field.parameter))) {
245
+ throw new Error(`Action ${action.type} input "${field.name}" has a malformed parameter block; refusing to change it`);
246
+ }
241
247
  const suppliedValue = Object.prototype.hasOwnProperty.call(supplied, field.name) ? supplied[field.name] : field.default;
242
248
  if ((suppliedValue === undefined || suppliedValue === null) && (field.mandatory === true || field.required === true)) throw new Error(`Missing required input "${field.name}" for action ${action.type}`);
243
249
  const value = suppliedValue ?? null;
@@ -265,8 +265,8 @@ export async function guidedFlowCreate(argv, app) {
265
265
  const { schema } = await readActionDefinition(app.sdk, app.getEffectiveInstance(), id, manifest.scope, { requireTypes: true });
266
266
  const inputs = {};
267
267
  for (const field of schema) {
268
- if (!field.id || !field.parameter || typeof field.parameter !== 'object' || Array.isArray(field.parameter)) {
269
- throw errUsage(`Published action input ${field.name} lacks provider id/parameter metadata; no flow was allocated`);
268
+ if (!field.id || !field.name) {
269
+ throw errUsage(`Published action input ${field.name || 'unknown'} lacks the provider identity needed to bind a value; no flow was allocated`);
270
270
  }
271
271
  inputs[field.name] = await promptSchemaValue(app, field, field.default, 'Action input: ');
272
272
  }