@mastra/core 0.1.27-alpha.50 → 0.1.27-alpha.52
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/dist/core.cjs.development.js +341 -1
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +341 -2
- package/dist/core.esm.js.map +1 -1
- package/dist/engine/engine.d.ts +61 -0
- package/dist/engine/engine.d.ts.map +1 -0
- package/dist/engine/engine.mock.d.ts +1 -1
- package/dist/engine/engine.mock.d.ts.map +1 -1
- package/dist/engine/index.d.ts +2 -60
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +5 -5
- package/dist/workflows/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3560,6 +3560,345 @@ var MastraEngine = /*#__PURE__*/function () {
|
|
|
3560
3560
|
return MastraEngine;
|
|
3561
3561
|
}();
|
|
3562
3562
|
|
|
3563
|
+
var MockMastraEngine = /*#__PURE__*/function (_MastraEngine) {
|
|
3564
|
+
function MockMastraEngine(config) {
|
|
3565
|
+
var _this;
|
|
3566
|
+
_this = _MastraEngine.call(this, config) || this;
|
|
3567
|
+
_this.entities = [];
|
|
3568
|
+
_this.records = [];
|
|
3569
|
+
return _this;
|
|
3570
|
+
}
|
|
3571
|
+
_inheritsLoose(MockMastraEngine, _MastraEngine);
|
|
3572
|
+
var _proto = MockMastraEngine.prototype;
|
|
3573
|
+
_proto.createEntity = /*#__PURE__*/function () {
|
|
3574
|
+
var _createEntity = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
3575
|
+
var entity;
|
|
3576
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3577
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3578
|
+
case 0:
|
|
3579
|
+
entity = {
|
|
3580
|
+
id: "entity_" + Date.now(),
|
|
3581
|
+
name: params.name,
|
|
3582
|
+
connectionId: params.connectionId,
|
|
3583
|
+
createdAt: new Date(),
|
|
3584
|
+
updatedAt: new Date(),
|
|
3585
|
+
lastSyncId: null
|
|
3586
|
+
};
|
|
3587
|
+
this.entities.push(entity);
|
|
3588
|
+
return _context.abrupt("return", entity);
|
|
3589
|
+
case 3:
|
|
3590
|
+
case "end":
|
|
3591
|
+
return _context.stop();
|
|
3592
|
+
}
|
|
3593
|
+
}, _callee, this);
|
|
3594
|
+
}));
|
|
3595
|
+
function createEntity(_x) {
|
|
3596
|
+
return _createEntity.apply(this, arguments);
|
|
3597
|
+
}
|
|
3598
|
+
return createEntity;
|
|
3599
|
+
}();
|
|
3600
|
+
_proto.getEntityById = /*#__PURE__*/function () {
|
|
3601
|
+
var _getEntityById = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
3602
|
+
var entity;
|
|
3603
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3604
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3605
|
+
case 0:
|
|
3606
|
+
entity = this.entities.find(function (e) {
|
|
3607
|
+
return e.id === params.id;
|
|
3608
|
+
});
|
|
3609
|
+
if (entity) {
|
|
3610
|
+
_context2.next = 3;
|
|
3611
|
+
break;
|
|
3612
|
+
}
|
|
3613
|
+
throw new Error("Entity with id " + params.id + " not found");
|
|
3614
|
+
case 3:
|
|
3615
|
+
return _context2.abrupt("return", entity);
|
|
3616
|
+
case 4:
|
|
3617
|
+
case "end":
|
|
3618
|
+
return _context2.stop();
|
|
3619
|
+
}
|
|
3620
|
+
}, _callee2, this);
|
|
3621
|
+
}));
|
|
3622
|
+
function getEntityById(_x2) {
|
|
3623
|
+
return _getEntityById.apply(this, arguments);
|
|
3624
|
+
}
|
|
3625
|
+
return getEntityById;
|
|
3626
|
+
}();
|
|
3627
|
+
_proto.getEntity = /*#__PURE__*/function () {
|
|
3628
|
+
var _getEntity = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
3629
|
+
var connectionId, name;
|
|
3630
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3631
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
3632
|
+
case 0:
|
|
3633
|
+
connectionId = _ref.connectionId, name = _ref.name;
|
|
3634
|
+
return _context3.abrupt("return", this.entities.find(function (e) {
|
|
3635
|
+
return (name ? e.name === name : true) && (connectionId ? e.connectionId === connectionId : true);
|
|
3636
|
+
}));
|
|
3637
|
+
case 2:
|
|
3638
|
+
case "end":
|
|
3639
|
+
return _context3.stop();
|
|
3640
|
+
}
|
|
3641
|
+
}, _callee3, this);
|
|
3642
|
+
}));
|
|
3643
|
+
function getEntity(_x3) {
|
|
3644
|
+
return _getEntity.apply(this, arguments);
|
|
3645
|
+
}
|
|
3646
|
+
return getEntity;
|
|
3647
|
+
}();
|
|
3648
|
+
_proto.deleteEntityById = /*#__PURE__*/function () {
|
|
3649
|
+
var _deleteEntityById = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref2) {
|
|
3650
|
+
var id, entityIndex, _this$entities$splice, deletedEntity;
|
|
3651
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
3652
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
3653
|
+
case 0:
|
|
3654
|
+
id = _ref2.id;
|
|
3655
|
+
entityIndex = this.entities.findIndex(function (e) {
|
|
3656
|
+
return e.id === id;
|
|
3657
|
+
});
|
|
3658
|
+
if (!(entityIndex === -1)) {
|
|
3659
|
+
_context4.next = 4;
|
|
3660
|
+
break;
|
|
3661
|
+
}
|
|
3662
|
+
throw new Error("Entity with id " + id + " not found");
|
|
3663
|
+
case 4:
|
|
3664
|
+
_this$entities$splice = this.entities.splice(entityIndex, 1), deletedEntity = _this$entities$splice[0]; // Also delete associated records
|
|
3665
|
+
this.records = this.records.filter(function (r) {
|
|
3666
|
+
return r.entityId !== id;
|
|
3667
|
+
});
|
|
3668
|
+
return _context4.abrupt("return", deletedEntity);
|
|
3669
|
+
case 7:
|
|
3670
|
+
case "end":
|
|
3671
|
+
return _context4.stop();
|
|
3672
|
+
}
|
|
3673
|
+
}, _callee4, this);
|
|
3674
|
+
}));
|
|
3675
|
+
function deleteEntityById(_x4) {
|
|
3676
|
+
return _deleteEntityById.apply(this, arguments);
|
|
3677
|
+
}
|
|
3678
|
+
return deleteEntityById;
|
|
3679
|
+
}();
|
|
3680
|
+
_proto.upsertRecords = /*#__PURE__*/function () {
|
|
3681
|
+
var _upsertRecords = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
3682
|
+
var _this2 = this;
|
|
3683
|
+
var _loop, _iterator, _step;
|
|
3684
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context6) {
|
|
3685
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
3686
|
+
case 0:
|
|
3687
|
+
_context6.next = 2;
|
|
3688
|
+
return this.getEntityById({
|
|
3689
|
+
id: params.entityId
|
|
3690
|
+
});
|
|
3691
|
+
case 2:
|
|
3692
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
3693
|
+
var record, existingRecordIndex, fullRecord;
|
|
3694
|
+
return _regeneratorRuntime().wrap(function _loop$(_context5) {
|
|
3695
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
3696
|
+
case 0:
|
|
3697
|
+
record = _step.value;
|
|
3698
|
+
existingRecordIndex = _this2.records.findIndex(function (r) {
|
|
3699
|
+
return r.entityId === params.entityId && r.externalId === record.externalId;
|
|
3700
|
+
});
|
|
3701
|
+
fullRecord = {
|
|
3702
|
+
id: "record_" + Date.now() + "_" + Math.random(),
|
|
3703
|
+
entityId: params.entityId,
|
|
3704
|
+
externalId: record.externalId,
|
|
3705
|
+
data: record.data,
|
|
3706
|
+
entityType: record.entityType,
|
|
3707
|
+
createdAt: new Date(),
|
|
3708
|
+
updatedAt: new Date()
|
|
3709
|
+
};
|
|
3710
|
+
if (existingRecordIndex !== -1) {
|
|
3711
|
+
_this2.records[existingRecordIndex] = fullRecord;
|
|
3712
|
+
} else {
|
|
3713
|
+
_this2.records.push(fullRecord);
|
|
3714
|
+
}
|
|
3715
|
+
case 4:
|
|
3716
|
+
case "end":
|
|
3717
|
+
return _context5.stop();
|
|
3718
|
+
}
|
|
3719
|
+
}, _loop);
|
|
3720
|
+
});
|
|
3721
|
+
_iterator = _createForOfIteratorHelperLoose(params.records);
|
|
3722
|
+
case 4:
|
|
3723
|
+
if ((_step = _iterator()).done) {
|
|
3724
|
+
_context6.next = 8;
|
|
3725
|
+
break;
|
|
3726
|
+
}
|
|
3727
|
+
return _context6.delegateYield(_loop(), "t0", 6);
|
|
3728
|
+
case 6:
|
|
3729
|
+
_context6.next = 4;
|
|
3730
|
+
break;
|
|
3731
|
+
case 8:
|
|
3732
|
+
case "end":
|
|
3733
|
+
return _context6.stop();
|
|
3734
|
+
}
|
|
3735
|
+
}, _callee5, this);
|
|
3736
|
+
}));
|
|
3737
|
+
function upsertRecords(_x5) {
|
|
3738
|
+
return _upsertRecords.apply(this, arguments);
|
|
3739
|
+
}
|
|
3740
|
+
return upsertRecords;
|
|
3741
|
+
}();
|
|
3742
|
+
_proto.getRecordsByEntityId = /*#__PURE__*/function () {
|
|
3743
|
+
var _getRecordsByEntityId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
3744
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
|
3745
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3746
|
+
case 0:
|
|
3747
|
+
return _context7.abrupt("return", this.records.filter(function (r) {
|
|
3748
|
+
return r.entityId === params.entityId;
|
|
3749
|
+
}));
|
|
3750
|
+
case 1:
|
|
3751
|
+
case "end":
|
|
3752
|
+
return _context7.stop();
|
|
3753
|
+
}
|
|
3754
|
+
}, _callee6, this);
|
|
3755
|
+
}));
|
|
3756
|
+
function getRecordsByEntityId(_x6) {
|
|
3757
|
+
return _getRecordsByEntityId.apply(this, arguments);
|
|
3758
|
+
}
|
|
3759
|
+
return getRecordsByEntityId;
|
|
3760
|
+
}();
|
|
3761
|
+
_proto.getRecordsByEntityName = /*#__PURE__*/function () {
|
|
3762
|
+
var _getRecordsByEntityName = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref3) {
|
|
3763
|
+
var name, connectionId, entity;
|
|
3764
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
3765
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3766
|
+
case 0:
|
|
3767
|
+
name = _ref3.name, connectionId = _ref3.connectionId;
|
|
3768
|
+
_context8.next = 3;
|
|
3769
|
+
return this.getEntity({
|
|
3770
|
+
name: name,
|
|
3771
|
+
connectionId: connectionId
|
|
3772
|
+
});
|
|
3773
|
+
case 3:
|
|
3774
|
+
entity = _context8.sent;
|
|
3775
|
+
if (entity) {
|
|
3776
|
+
_context8.next = 6;
|
|
3777
|
+
break;
|
|
3778
|
+
}
|
|
3779
|
+
return _context8.abrupt("return", []);
|
|
3780
|
+
case 6:
|
|
3781
|
+
return _context8.abrupt("return", this.getRecordsByEntityId({
|
|
3782
|
+
entityId: entity.id
|
|
3783
|
+
}));
|
|
3784
|
+
case 7:
|
|
3785
|
+
case "end":
|
|
3786
|
+
return _context8.stop();
|
|
3787
|
+
}
|
|
3788
|
+
}, _callee7, this);
|
|
3789
|
+
}));
|
|
3790
|
+
function getRecordsByEntityName(_x7) {
|
|
3791
|
+
return _getRecordsByEntityName.apply(this, arguments);
|
|
3792
|
+
}
|
|
3793
|
+
return getRecordsByEntityName;
|
|
3794
|
+
}();
|
|
3795
|
+
_proto.getRecords = /*#__PURE__*/function () {
|
|
3796
|
+
var _getRecords = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref4) {
|
|
3797
|
+
var entityName, connectionId, options, entity, records, start;
|
|
3798
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context9) {
|
|
3799
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3800
|
+
case 0:
|
|
3801
|
+
entityName = _ref4.entityName, connectionId = _ref4.connectionId, options = _ref4.options;
|
|
3802
|
+
_context9.next = 3;
|
|
3803
|
+
return this.getEntity({
|
|
3804
|
+
name: entityName,
|
|
3805
|
+
connectionId: connectionId
|
|
3806
|
+
});
|
|
3807
|
+
case 3:
|
|
3808
|
+
entity = _context9.sent;
|
|
3809
|
+
if (entity) {
|
|
3810
|
+
_context9.next = 6;
|
|
3811
|
+
break;
|
|
3812
|
+
}
|
|
3813
|
+
return _context9.abrupt("return", []);
|
|
3814
|
+
case 6:
|
|
3815
|
+
_context9.next = 8;
|
|
3816
|
+
return this.getRecordsByEntityId({
|
|
3817
|
+
entityId: entity.id
|
|
3818
|
+
});
|
|
3819
|
+
case 8:
|
|
3820
|
+
records = _context9.sent;
|
|
3821
|
+
// Apply basic filtering based on options
|
|
3822
|
+
if (options.filters) {
|
|
3823
|
+
records = records.filter(function () {
|
|
3824
|
+
// Implement your filtering logic here
|
|
3825
|
+
return true; // Placeholder
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
// Apply sorting
|
|
3829
|
+
if (options.sort) {
|
|
3830
|
+
records = records.sort(function () {
|
|
3831
|
+
// Implement your sorting logic here
|
|
3832
|
+
return 0; // Placeholder
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
// Apply pagination
|
|
3836
|
+
if (options.limit) {
|
|
3837
|
+
start = options.offset || 0;
|
|
3838
|
+
records = records.slice(start, start + options.limit);
|
|
3839
|
+
}
|
|
3840
|
+
return _context9.abrupt("return", records);
|
|
3841
|
+
case 13:
|
|
3842
|
+
case "end":
|
|
3843
|
+
return _context9.stop();
|
|
3844
|
+
}
|
|
3845
|
+
}, _callee8, this);
|
|
3846
|
+
}));
|
|
3847
|
+
function getRecords(_x8) {
|
|
3848
|
+
return _getRecords.apply(this, arguments);
|
|
3849
|
+
}
|
|
3850
|
+
return getRecords;
|
|
3851
|
+
}();
|
|
3852
|
+
_proto.syncRecords = /*#__PURE__*/function () {
|
|
3853
|
+
var _syncRecords = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref5) {
|
|
3854
|
+
var connectionId, name, records, lastSyncId, entity;
|
|
3855
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context10) {
|
|
3856
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3857
|
+
case 0:
|
|
3858
|
+
connectionId = _ref5.connectionId, name = _ref5.name, records = _ref5.records, lastSyncId = _ref5.lastSyncId;
|
|
3859
|
+
_context10.next = 3;
|
|
3860
|
+
return this.getEntity({
|
|
3861
|
+
name: name,
|
|
3862
|
+
connectionId: connectionId
|
|
3863
|
+
});
|
|
3864
|
+
case 3:
|
|
3865
|
+
entity = _context10.sent;
|
|
3866
|
+
if (entity) {
|
|
3867
|
+
_context10.next = 8;
|
|
3868
|
+
break;
|
|
3869
|
+
}
|
|
3870
|
+
_context10.next = 7;
|
|
3871
|
+
return this.createEntity({
|
|
3872
|
+
name: name,
|
|
3873
|
+
connectionId: connectionId
|
|
3874
|
+
});
|
|
3875
|
+
case 7:
|
|
3876
|
+
entity = _context10.sent;
|
|
3877
|
+
case 8:
|
|
3878
|
+
_context10.next = 10;
|
|
3879
|
+
return this.upsertRecords({
|
|
3880
|
+
entityId: entity.id,
|
|
3881
|
+
records: records.map(function (record) {
|
|
3882
|
+
return _extends({}, record, {
|
|
3883
|
+
lastSyncId: lastSyncId,
|
|
3884
|
+
entityType: name // Using name as entityType for simplicity
|
|
3885
|
+
});
|
|
3886
|
+
})
|
|
3887
|
+
});
|
|
3888
|
+
case 10:
|
|
3889
|
+
case "end":
|
|
3890
|
+
return _context10.stop();
|
|
3891
|
+
}
|
|
3892
|
+
}, _callee9, this);
|
|
3893
|
+
}));
|
|
3894
|
+
function syncRecords(_x9) {
|
|
3895
|
+
return _syncRecords.apply(this, arguments);
|
|
3896
|
+
}
|
|
3897
|
+
return syncRecords;
|
|
3898
|
+
}();
|
|
3899
|
+
return MockMastraEngine;
|
|
3900
|
+
}(MastraEngine);
|
|
3901
|
+
|
|
3563
3902
|
var _telemetry = /*#__PURE__*/_classPrivateFieldLooseKey("telemetry");
|
|
3564
3903
|
var MastraVector = /*#__PURE__*/function () {
|
|
3565
3904
|
function MastraVector() {
|
|
@@ -4964,7 +5303,7 @@ function _resolveVariables2(_ref30) {
|
|
|
4964
5303
|
continue;
|
|
4965
5304
|
}
|
|
4966
5305
|
// If path is empty or '.', return the entire source data
|
|
4967
|
-
var value = variable.path === '' || variable.path === '.' ? sourceData
|
|
5306
|
+
var value = variable.path === '' || variable.path === '.' ? sourceData : radash.get(sourceData, variable.path);
|
|
4968
5307
|
this.log(LogLevel.DEBUG, "Resolved variable " + key, {
|
|
4969
5308
|
value: value,
|
|
4970
5309
|
runId: _classPrivateFieldLooseBase(this, _runId)[_runId]
|
|
@@ -5481,6 +5820,7 @@ exports.LogLevel = LogLevel;
|
|
|
5481
5820
|
exports.MastraEngine = MastraEngine;
|
|
5482
5821
|
exports.MastraMemory = MastraMemory;
|
|
5483
5822
|
exports.MastraVector = MastraVector;
|
|
5823
|
+
exports.MockMastraEngine = MockMastraEngine;
|
|
5484
5824
|
exports.MultiLogger = MultiLogger;
|
|
5485
5825
|
exports.OpenAPIToolset = OpenAPIToolset;
|
|
5486
5826
|
exports.RegisteredLogger = RegisteredLogger;
|