@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.
- package/README.md +16 -4
- 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/index.d.ts +1 -1
- package/dist/cjs/index/registry.d.ts +1 -1
- package/dist/cjs/index/types.d.ts +1 -6
- package/dist/cjs/index.cjs +15 -58
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +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/index.d.ts +1 -1
- package/dist/esm/index/registry.d.ts +1 -1
- package/dist/esm/index/types.d.ts +1 -6
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +16 -58
- 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
|
@@ -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
|
|
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 (
|
|
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
|
*/
|
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
|
}
|
|
@@ -784,40 +776,6 @@ function computeResolvedName(model) {
|
|
|
784
776
|
* GSIs and auto-detect which index to use for queries.
|
|
785
777
|
*/
|
|
786
778
|
// =============================================================================
|
|
787
|
-
// Default Indexes
|
|
788
|
-
// =============================================================================
|
|
789
|
-
/**
|
|
790
|
-
* Default indexes for the DynamoDB GSI pattern.
|
|
791
|
-
* These are used when a model does not specify custom indexes.
|
|
792
|
-
*/
|
|
793
|
-
const DEFAULT_INDEXES = [
|
|
794
|
-
{ name: "indexScope", pk: ["scope", "model"], sk: ["sequence"] },
|
|
795
|
-
{
|
|
796
|
-
name: "indexAlias",
|
|
797
|
-
pk: ["scope", "model", "alias"],
|
|
798
|
-
sk: ["sequence"],
|
|
799
|
-
sparse: true,
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
name: "indexCategory",
|
|
803
|
-
pk: ["scope", "model", "category"],
|
|
804
|
-
sk: ["sequence"],
|
|
805
|
-
sparse: true,
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
name: "indexType",
|
|
809
|
-
pk: ["scope", "model", "type"],
|
|
810
|
-
sk: ["sequence"],
|
|
811
|
-
sparse: true,
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
name: "indexXid",
|
|
815
|
-
pk: ["scope", "model", "xid"],
|
|
816
|
-
sk: ["sequence"],
|
|
817
|
-
sparse: true,
|
|
818
|
-
},
|
|
819
|
-
];
|
|
820
|
-
// =============================================================================
|
|
821
779
|
// Constants
|
|
822
780
|
// =============================================================================
|
|
823
781
|
/**
|
|
@@ -993,14 +951,14 @@ function getModelSchema(model) {
|
|
|
993
951
|
* Get index definitions for a model
|
|
994
952
|
*
|
|
995
953
|
* Returns the model's custom indexes if registered,
|
|
996
|
-
* otherwise returns
|
|
954
|
+
* otherwise returns an empty array.
|
|
997
955
|
*
|
|
998
956
|
* @param model - Model name to get indexes for
|
|
999
957
|
* @returns Array of index definitions
|
|
1000
958
|
*/
|
|
1001
959
|
function getModelIndexes(model) {
|
|
1002
960
|
const schema = MODEL_REGISTRY.get(model);
|
|
1003
|
-
return schema?.indexes ??
|
|
961
|
+
return schema?.indexes ?? [];
|
|
1004
962
|
}
|
|
1005
963
|
/**
|
|
1006
964
|
* Get all registered models
|
|
@@ -1796,7 +1754,6 @@ exports.ARCHIVED_SUFFIX = ARCHIVED_SUFFIX;
|
|
|
1796
1754
|
exports.BOOLEAN_TYPE = BOOLEAN_TYPE;
|
|
1797
1755
|
exports.DATETIME_TYPE = DATETIME_TYPE;
|
|
1798
1756
|
exports.DATE_TYPE = DATE_TYPE;
|
|
1799
|
-
exports.DEFAULT_INDEXES = DEFAULT_INDEXES;
|
|
1800
1757
|
exports.DEFAULT_SORT_KEY = DEFAULT_SORT_KEY;
|
|
1801
1758
|
exports.DELETED_SUFFIX = DELETED_SUFFIX;
|
|
1802
1759
|
exports.DOLLARS_TYPE = DOLLARS_TYPE;
|