@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.
@@ -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 and objects to get to the scalar value
287
+ * Unwrap arrays to get to the scalar value
288
288
  * - Single-element arrays unwrap to their element
289
- * - Objects with value property unwrap to that value
290
- * - Recursively unwraps nested structures
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 with a value property
493
+ * Convert a value to an object
499
494
  * - Scalars become { value: scalar }
500
495
  * - Arrays become { value: array }
501
- * - Objects with a value attribute pass through
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
- const obj = value;
512
- if ("value" in obj) {
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 throw BadRequestError
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
- throw new BadRequestError("Object must have a value attribute");
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
  */