@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.
Files changed (40) hide show
  1. package/README.md +16 -4
  2. package/dist/cjs/commander/index.cjs +10 -19
  3. package/dist/cjs/commander/index.cjs.map +1 -1
  4. package/dist/cjs/data/index.cjs +10 -19
  5. package/dist/cjs/data/index.cjs.map +1 -1
  6. package/dist/cjs/http/index.cjs +10 -19
  7. package/dist/cjs/http/index.cjs.map +1 -1
  8. package/dist/cjs/index/index.d.ts +1 -1
  9. package/dist/cjs/index/registry.d.ts +1 -1
  10. package/dist/cjs/index/types.d.ts +1 -6
  11. package/dist/cjs/index.cjs +15 -58
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/index.d.ts +1 -1
  14. package/dist/cjs/lambda/index.cjs +10 -19
  15. package/dist/cjs/lambda/index.cjs.map +1 -1
  16. package/dist/cjs/llm/index.cjs +10 -19
  17. package/dist/cjs/llm/index.cjs.map +1 -1
  18. package/dist/cjs/mcp/index.cjs +10 -19
  19. package/dist/cjs/mcp/index.cjs.map +1 -1
  20. package/dist/cjs/resolve.d.ts +4 -7
  21. package/dist/esm/commander/index.js +10 -19
  22. package/dist/esm/commander/index.js.map +1 -1
  23. package/dist/esm/data/index.js +10 -19
  24. package/dist/esm/data/index.js.map +1 -1
  25. package/dist/esm/http/index.js +10 -19
  26. package/dist/esm/http/index.js.map +1 -1
  27. package/dist/esm/index/index.d.ts +1 -1
  28. package/dist/esm/index/registry.d.ts +1 -1
  29. package/dist/esm/index/types.d.ts +1 -6
  30. package/dist/esm/index.d.ts +1 -1
  31. package/dist/esm/index.js +16 -58
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/lambda/index.js +10 -19
  34. package/dist/esm/lambda/index.js.map +1 -1
  35. package/dist/esm/llm/index.js +10 -19
  36. package/dist/esm/llm/index.js.map +1 -1
  37. package/dist/esm/mcp/index.js +10 -19
  38. package/dist/esm/mcp/index.js.map +1 -1
  39. package/dist/esm/resolve.d.ts +4 -7
  40. package/package.json +2 -2
@@ -22,7 +22,7 @@ export declare function getModelSchema(model: string): ModelSchema | undefined;
22
22
  * Get index definitions for a model
23
23
  *
24
24
  * Returns the model's custom indexes if registered,
25
- * otherwise returns DEFAULT_INDEXES.
25
+ * otherwise returns an empty array.
26
26
  *
27
27
  * @param model - Model name to get indexes for
28
28
  * @returns Array of index definitions
@@ -32,14 +32,9 @@ export interface IndexDefinition {
32
32
  export interface ModelSchema {
33
33
  /** The model name (e.g., "record", "message", "chat") */
34
34
  model: string;
35
- /** Custom indexes for this model (uses DEFAULT_INDEXES if not specified) */
35
+ /** Custom indexes for this model (empty array if not specified) */
36
36
  indexes?: IndexDefinition[];
37
37
  }
38
- /**
39
- * Default indexes for the DynamoDB GSI pattern.
40
- * These are used when a model does not specify custom indexes.
41
- */
42
- export declare const DEFAULT_INDEXES: IndexDefinition[];
43
38
  /**
44
39
  * Default sort key fields when sk is not specified
45
40
  */
@@ -6,7 +6,7 @@ export { fabric, fabricArray, fabricBoolean, fabricNumber, fabricObject, fabricS
6
6
  export { DateType, fabricDate, isDateType, isValidDate, resolveFromDate, } from "./resolve-date.js";
7
7
  export { computeResolvedName, resolveWithFallback } from "./helpers/index.js";
8
8
  export type { ResolvedNameModel } from "./helpers/index.js";
9
- export { ARCHIVED_SUFFIX, buildCompositeKey, calculateIndexSuffix, calculateScope, clearRegistry, DEFAULT_INDEXES, DEFAULT_SORT_KEY, DELETED_SUFFIX, generateIndexName, getAllRegisteredIndexes, getModelIndexes, getModelSchema, getRegisteredModels, isModelRegistered, populateIndexKeys, registerModel, tryBuildCompositeKey, } from "./index/index.js";
9
+ export { ARCHIVED_SUFFIX, buildCompositeKey, calculateIndexSuffix, calculateScope, clearRegistry, DEFAULT_SORT_KEY, DELETED_SUFFIX, generateIndexName, getAllRegisteredIndexes, getModelIndexes, getModelSchema, getRegisteredModels, isModelRegistered, populateIndexKeys, registerModel, tryBuildCompositeKey, } from "./index/index.js";
10
10
  export type { IndexableModel, IndexDefinition, IndexField, ModelSchema, } from "./index/index.js";
11
11
  export { BOOLEAN_TYPE, DATE_TYPE, DATETIME_TYPE, DOLLARS_TYPE, ELEMENTARY_TYPE_REGISTRY, ELEMENTARY_TYPES, getAllElementaryTypes, getElementaryType, isElementaryType, isFieldDefinition, MULTISELECT_TYPE, NUMBER_TYPE, REFERENCE_TYPE, SELECT_TYPE, TEXT_TYPE, TEXTAREA_TYPE, } from "./types/index.js";
12
12
  export type { ElementaryType, ElementaryTypeDefinition, FieldDefinition, FieldRef, ValidationRule, } from "./types/index.js";
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
  }
@@ -782,40 +774,6 @@ function computeResolvedName(model) {
782
774
  * GSIs and auto-detect which index to use for queries.
783
775
  */
784
776
  // =============================================================================
785
- // Default Indexes
786
- // =============================================================================
787
- /**
788
- * Default indexes for the DynamoDB GSI pattern.
789
- * These are used when a model does not specify custom indexes.
790
- */
791
- const DEFAULT_INDEXES = [
792
- { name: "indexScope", pk: ["scope", "model"], sk: ["sequence"] },
793
- {
794
- name: "indexAlias",
795
- pk: ["scope", "model", "alias"],
796
- sk: ["sequence"],
797
- sparse: true,
798
- },
799
- {
800
- name: "indexCategory",
801
- pk: ["scope", "model", "category"],
802
- sk: ["sequence"],
803
- sparse: true,
804
- },
805
- {
806
- name: "indexType",
807
- pk: ["scope", "model", "type"],
808
- sk: ["sequence"],
809
- sparse: true,
810
- },
811
- {
812
- name: "indexXid",
813
- pk: ["scope", "model", "xid"],
814
- sk: ["sequence"],
815
- sparse: true,
816
- },
817
- ];
818
- // =============================================================================
819
777
  // Constants
820
778
  // =============================================================================
821
779
  /**
@@ -991,14 +949,14 @@ function getModelSchema(model) {
991
949
  * Get index definitions for a model
992
950
  *
993
951
  * Returns the model's custom indexes if registered,
994
- * otherwise returns DEFAULT_INDEXES.
952
+ * otherwise returns an empty array.
995
953
  *
996
954
  * @param model - Model name to get indexes for
997
955
  * @returns Array of index definitions
998
956
  */
999
957
  function getModelIndexes(model) {
1000
958
  const schema = MODEL_REGISTRY.get(model);
1001
- return schema?.indexes ?? DEFAULT_INDEXES;
959
+ return schema?.indexes ?? [];
1002
960
  }
1003
961
  /**
1004
962
  * Get all registered models
@@ -1789,5 +1747,5 @@ function isStatus(value) {
1789
1747
  STATUS_VALUES.includes(value));
1790
1748
  }
1791
1749
 
1792
- export { APEX, ARCHIVED_SUFFIX, BOOLEAN_TYPE, DATETIME_TYPE, DATE_TYPE, DEFAULT_INDEXES, DEFAULT_SORT_KEY, DELETED_SUFFIX, DOLLARS_TYPE, DateType, ELEMENTARY_TYPES, ELEMENTARY_TYPE_REGISTRY, FABRIC_MODEL_AUTO_FIELDS, FABRIC_MODEL_FIELDS, FABRIC_MODEL_REQUIRED_FIELDS, FABRIC_MODEL_TIMESTAMP_FIELDS, FABRIC_VERSION, MULTISELECT_TYPE, NUMBER_TYPE, REFERENCE_TYPE, SELECT_TYPE, SEPARATOR, STATUS_VALUES, SYSTEM_MODELS, StatusType, TEXTAREA_TYPE, TEXT_TYPE, buildCompositeKey, calculateIndexSuffix, calculateScope, clearRegistry, computeResolvedName, createFabricModelInput, createServiceSuite, fabric, fabricArray, fabricBoolean, fabricDate, fabricNumber, fabricObject, fabricService, fabricString, generateIndexName, getAllElementaryTypes, getAllRegisteredIndexes, getElementaryType, getModelIndexes, getModelSchema, getRegisteredModels, hasFabricModelShape, isAutoField, isDateType, isElementaryType, isFabricModel, isFieldDefinition, isModelRegistered, isService, isStatus, isTimestampField, isValidDate, pickFabricModelFields, populateIndexKeys, registerModel, resolveFromArray, resolveFromDate, resolveFromObject, resolveService, resolveWithFallback, tryBuildCompositeKey };
1750
+ export { APEX, ARCHIVED_SUFFIX, BOOLEAN_TYPE, DATETIME_TYPE, DATE_TYPE, DEFAULT_SORT_KEY, DELETED_SUFFIX, DOLLARS_TYPE, DateType, ELEMENTARY_TYPES, ELEMENTARY_TYPE_REGISTRY, FABRIC_MODEL_AUTO_FIELDS, FABRIC_MODEL_FIELDS, FABRIC_MODEL_REQUIRED_FIELDS, FABRIC_MODEL_TIMESTAMP_FIELDS, FABRIC_VERSION, MULTISELECT_TYPE, NUMBER_TYPE, REFERENCE_TYPE, SELECT_TYPE, SEPARATOR, STATUS_VALUES, SYSTEM_MODELS, StatusType, TEXTAREA_TYPE, TEXT_TYPE, buildCompositeKey, calculateIndexSuffix, calculateScope, clearRegistry, computeResolvedName, createFabricModelInput, createServiceSuite, fabric, fabricArray, fabricBoolean, fabricDate, fabricNumber, fabricObject, fabricService, fabricString, generateIndexName, getAllElementaryTypes, getAllRegisteredIndexes, getElementaryType, getModelIndexes, getModelSchema, getRegisteredModels, hasFabricModelShape, isAutoField, isDateType, isElementaryType, isFabricModel, isFieldDefinition, isModelRegistered, isService, isStatus, isTimestampField, isValidDate, pickFabricModelFields, populateIndexKeys, registerModel, resolveFromArray, resolveFromDate, resolveFromObject, resolveService, resolveWithFallback, tryBuildCompositeKey };
1793
1751
  //# sourceMappingURL=index.js.map