@jaypie/fabric 0.2.2 → 0.2.3

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 (40) hide show
  1. package/README.md +16 -4
  2. package/dist/cjs/commander/index.cjs +10 -19
  3. package/dist/cjs/commander/index.cjs.map +1 -1
  4. package/dist/cjs/data/index.cjs +10 -19
  5. package/dist/cjs/data/index.cjs.map +1 -1
  6. package/dist/cjs/http/index.cjs +10 -19
  7. package/dist/cjs/http/index.cjs.map +1 -1
  8. package/dist/cjs/index/index.d.ts +1 -1
  9. package/dist/cjs/index/registry.d.ts +1 -1
  10. package/dist/cjs/index/types.d.ts +1 -6
  11. package/dist/cjs/index.cjs +15 -58
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/index.d.ts +1 -1
  14. package/dist/cjs/lambda/index.cjs +10 -19
  15. package/dist/cjs/lambda/index.cjs.map +1 -1
  16. package/dist/cjs/llm/index.cjs +10 -19
  17. package/dist/cjs/llm/index.cjs.map +1 -1
  18. package/dist/cjs/mcp/index.cjs +10 -19
  19. package/dist/cjs/mcp/index.cjs.map +1 -1
  20. package/dist/cjs/resolve.d.ts +4 -7
  21. package/dist/esm/commander/index.js +10 -19
  22. package/dist/esm/commander/index.js.map +1 -1
  23. package/dist/esm/data/index.js +10 -19
  24. package/dist/esm/data/index.js.map +1 -1
  25. package/dist/esm/http/index.js +10 -19
  26. package/dist/esm/http/index.js.map +1 -1
  27. package/dist/esm/index/index.d.ts +1 -1
  28. package/dist/esm/index/registry.d.ts +1 -1
  29. package/dist/esm/index/types.d.ts +1 -6
  30. package/dist/esm/index.d.ts +1 -1
  31. package/dist/esm/index.js +16 -58
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/lambda/index.js +10 -19
  34. package/dist/esm/lambda/index.js.map +1 -1
  35. package/dist/esm/llm/index.js +10 -19
  36. package/dist/esm/llm/index.js.map +1 -1
  37. package/dist/esm/mcp/index.js +10 -19
  38. package/dist/esm/mcp/index.js.map +1 -1
  39. package/dist/esm/resolve.d.ts +4 -7
  40. package/package.json +2 -2
@@ -108,10 +108,10 @@ function tryParseJson(value) {
108
108
  return value;
109
109
  }
110
110
  /**
111
- * Unwrap arrays and objects to get to the scalar value
111
+ * Unwrap arrays to get to the scalar value
112
112
  * - Single-element arrays unwrap to their element
113
- * - Objects with value property unwrap to that value
114
- * - Recursively unwraps nested structures
113
+ * - Objects pass through as-is (handled by individual fabric functions)
114
+ * - Recursively unwraps nested arrays
115
115
  */
116
116
  function unwrapToScalar(value) {
117
117
  if (value === undefined || value === null) {
@@ -127,14 +127,6 @@ function unwrapToScalar(value) {
127
127
  }
128
128
  throw new errors.BadRequestError("Cannot convert multi-value array to scalar");
129
129
  }
130
- // Unwrap objects with value property
131
- if (typeof value === "object") {
132
- const obj = value;
133
- if ("value" in obj) {
134
- return unwrapToScalar(obj.value);
135
- }
136
- throw new errors.BadRequestError("Object must have a value attribute");
137
- }
138
130
  return value;
139
131
  }
140
132
  /**
@@ -277,6 +269,9 @@ function fabricString(value) {
277
269
  }
278
270
  return String(prepared);
279
271
  }
272
+ if (typeof prepared === "object") {
273
+ return JSON.stringify(prepared);
274
+ }
280
275
  throw new errors.BadRequestError(`Cannot convert ${typeof prepared} to String`);
281
276
  }
282
277
  /**
@@ -298,11 +293,10 @@ function fabricArray(value) {
298
293
  return [value];
299
294
  }
300
295
  /**
301
- * Convert a value to an object with a value property
296
+ * Convert a value to an object
302
297
  * - Scalars become { value: scalar }
303
298
  * - Arrays become { value: array }
304
- * - Objects with a value attribute pass through
305
- * - Objects without a value attribute throw BadRequestError
299
+ * - Objects pass through as-is (including those with or without value attribute)
306
300
  * - undefined/null become undefined
307
301
  */
308
302
  function fabricObject(value) {
@@ -311,11 +305,8 @@ function fabricObject(value) {
311
305
  }
312
306
  // Check if already an object (but not an array)
313
307
  if (typeof value === "object" && !Array.isArray(value)) {
314
- const obj = value;
315
- if ("value" in obj) {
316
- return obj;
317
- }
318
- throw new errors.BadRequestError("Object must have a value attribute");
308
+ // Pass through any object as-is
309
+ return value;
319
310
  }
320
311
  // Scalars and arrays become { value: ... }
321
312
  return { value };