@jaypie/fabric 0.2.2 → 0.2.4
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 +15 -2
- 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/registry.d.ts +3 -0
- package/dist/cjs/index/types.d.ts +3 -0
- package/dist/cjs/index.cjs +19 -21
- package/dist/cjs/index.cjs.map +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/registry.d.ts +3 -0
- package/dist/esm/index/types.d.ts +3 -0
- package/dist/esm/index.js +19 -21
- 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/cjs/http/index.cjs
CHANGED
|
@@ -108,10 +108,10 @@ function tryParseJson(value) {
|
|
|
108
108
|
return value;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
* Unwrap arrays
|
|
111
|
+
* Unwrap arrays to get to the scalar value
|
|
112
112
|
* - Single-element arrays unwrap to their element
|
|
113
|
-
* - Objects
|
|
114
|
-
* - Recursively unwraps nested
|
|
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
|
|
296
|
+
* Convert a value to an object
|
|
302
297
|
* - Scalars become { value: scalar }
|
|
303
298
|
* - Arrays become { value: array }
|
|
304
|
-
* - Objects with
|
|
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
|
-
|
|
315
|
-
|
|
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 };
|