@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
|
@@ -38,6 +38,9 @@ export interface ModelSchema {
|
|
|
38
38
|
/**
|
|
39
39
|
* Default indexes for the DynamoDB GSI pattern.
|
|
40
40
|
* These are used when a model does not specify custom indexes.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Restored in 0.2.4 to unblock consumers. Will be removed in
|
|
43
|
+
* 0.3.0 — register model indexes explicitly with `registerModel()` instead.
|
|
41
44
|
*/
|
|
42
45
|
export declare const DEFAULT_INDEXES: IndexDefinition[];
|
|
43
46
|
/**
|
package/dist/esm/index.js
CHANGED
|
@@ -284,10 +284,10 @@ function tryParseJson(value) {
|
|
|
284
284
|
return value;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
287
|
-
* Unwrap arrays
|
|
287
|
+
* Unwrap arrays to get to the scalar value
|
|
288
288
|
* - Single-element arrays unwrap to their element
|
|
289
|
-
* - Objects
|
|
290
|
-
* - Recursively unwraps nested
|
|
289
|
+
* - Objects pass through as-is (handled by individual fabric functions)
|
|
290
|
+
* - Recursively unwraps nested arrays
|
|
291
291
|
*/
|
|
292
292
|
function unwrapToScalar(value) {
|
|
293
293
|
if (value === undefined || value === null) {
|
|
@@ -303,14 +303,6 @@ function unwrapToScalar(value) {
|
|
|
303
303
|
}
|
|
304
304
|
throw new BadRequestError("Cannot convert multi-value array to scalar");
|
|
305
305
|
}
|
|
306
|
-
// Unwrap objects with value property
|
|
307
|
-
if (typeof value === "object") {
|
|
308
|
-
const obj = value;
|
|
309
|
-
if ("value" in obj) {
|
|
310
|
-
return unwrapToScalar(obj.value);
|
|
311
|
-
}
|
|
312
|
-
throw new BadRequestError("Object must have a value attribute");
|
|
313
|
-
}
|
|
314
306
|
return value;
|
|
315
307
|
}
|
|
316
308
|
/**
|
|
@@ -453,6 +445,9 @@ function fabricString(value) {
|
|
|
453
445
|
}
|
|
454
446
|
return String(prepared);
|
|
455
447
|
}
|
|
448
|
+
if (typeof prepared === "object") {
|
|
449
|
+
return JSON.stringify(prepared);
|
|
450
|
+
}
|
|
456
451
|
throw new BadRequestError(`Cannot convert ${typeof prepared} to String`);
|
|
457
452
|
}
|
|
458
453
|
/**
|
|
@@ -495,11 +490,10 @@ function resolveFromArray(value) {
|
|
|
495
490
|
return value;
|
|
496
491
|
}
|
|
497
492
|
/**
|
|
498
|
-
* Convert a value to an object
|
|
493
|
+
* Convert a value to an object
|
|
499
494
|
* - Scalars become { value: scalar }
|
|
500
495
|
* - Arrays become { value: array }
|
|
501
|
-
* - Objects with
|
|
502
|
-
* - Objects without a value attribute throw BadRequestError
|
|
496
|
+
* - Objects pass through as-is (including those with or without value attribute)
|
|
503
497
|
* - undefined/null become undefined
|
|
504
498
|
*/
|
|
505
499
|
function fabricObject(value) {
|
|
@@ -508,11 +502,8 @@ function fabricObject(value) {
|
|
|
508
502
|
}
|
|
509
503
|
// Check if already an object (but not an array)
|
|
510
504
|
if (typeof value === "object" && !Array.isArray(value)) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return obj;
|
|
514
|
-
}
|
|
515
|
-
throw new BadRequestError("Object must have a value attribute");
|
|
505
|
+
// Pass through any object as-is
|
|
506
|
+
return value;
|
|
516
507
|
}
|
|
517
508
|
// Scalars and arrays become { value: ... }
|
|
518
509
|
return { value };
|
|
@@ -520,7 +511,7 @@ function fabricObject(value) {
|
|
|
520
511
|
/**
|
|
521
512
|
* Resolve a value from an object to its value property
|
|
522
513
|
* - Objects with a value property return that value
|
|
523
|
-
* - Objects without a value
|
|
514
|
+
* - Objects without a value property pass through as-is
|
|
524
515
|
* - Scalars pass through
|
|
525
516
|
*/
|
|
526
517
|
function resolveFromObject(value) {
|
|
@@ -532,7 +523,8 @@ function resolveFromObject(value) {
|
|
|
532
523
|
if ("value" in obj) {
|
|
533
524
|
return obj.value;
|
|
534
525
|
}
|
|
535
|
-
|
|
526
|
+
// Pass through objects without value property
|
|
527
|
+
return value;
|
|
536
528
|
}
|
|
537
529
|
return value;
|
|
538
530
|
}
|
|
@@ -787,6 +779,9 @@ function computeResolvedName(model) {
|
|
|
787
779
|
/**
|
|
788
780
|
* Default indexes for the DynamoDB GSI pattern.
|
|
789
781
|
* These are used when a model does not specify custom indexes.
|
|
782
|
+
*
|
|
783
|
+
* @deprecated Restored in 0.2.4 to unblock consumers. Will be removed in
|
|
784
|
+
* 0.3.0 — register model indexes explicitly with `registerModel()` instead.
|
|
790
785
|
*/
|
|
791
786
|
const DEFAULT_INDEXES = [
|
|
792
787
|
{ name: "indexScope", pk: ["scope", "model"], sk: ["sequence"] },
|
|
@@ -993,6 +988,9 @@ function getModelSchema(model) {
|
|
|
993
988
|
* Returns the model's custom indexes if registered,
|
|
994
989
|
* otherwise returns DEFAULT_INDEXES.
|
|
995
990
|
*
|
|
991
|
+
* @deprecated The fallback to DEFAULT_INDEXES will be removed in 0.3.0.
|
|
992
|
+
* Register model indexes explicitly with `registerModel()`.
|
|
993
|
+
*
|
|
996
994
|
* @param model - Model name to get indexes for
|
|
997
995
|
* @returns Array of index definitions
|
|
998
996
|
*/
|