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