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