@mastra/core 0.1.2 → 0.1.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/dist/core.cjs.development.js +37 -42
- 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 +37 -42
- package/dist/core.esm.js.map +1 -1
- package/dist/prisma/migrations/20241008024219_initial_migration/migration.sql +69 -0
- package/dist/types.d.ts +14 -1
- package/package.json +2 -3
|
@@ -1379,7 +1379,7 @@ var DataLayer = /*#__PURE__*/function () {
|
|
|
1379
1379
|
}
|
|
1380
1380
|
uniqueRecords = Array.from(uniqueRecordsMap.values());
|
|
1381
1381
|
externalIds = uniqueRecords.map(function (record) {
|
|
1382
|
-
return record.externalId;
|
|
1382
|
+
return String(record.externalId);
|
|
1383
1383
|
});
|
|
1384
1384
|
_context16.next = 9;
|
|
1385
1385
|
return this.db.record.findMany({
|
|
@@ -1401,7 +1401,7 @@ var DataLayer = /*#__PURE__*/function () {
|
|
|
1401
1401
|
toUpdate = [];
|
|
1402
1402
|
uniqueRecords.forEach(function (record) {
|
|
1403
1403
|
var existing = existingRecords.find(function (existingRecord) {
|
|
1404
|
-
return existingRecord.externalId === record.externalId;
|
|
1404
|
+
return existingRecord.externalId === String(record.externalId);
|
|
1405
1405
|
});
|
|
1406
1406
|
if (existing) {
|
|
1407
1407
|
toUpdate.push(_extends({}, record, {
|
|
@@ -1409,6 +1409,7 @@ var DataLayer = /*#__PURE__*/function () {
|
|
|
1409
1409
|
}));
|
|
1410
1410
|
} else {
|
|
1411
1411
|
toCreate.push(_extends({}, record, {
|
|
1412
|
+
externalId: String(record.externalId),
|
|
1412
1413
|
entityId: entityId
|
|
1413
1414
|
}));
|
|
1414
1415
|
}
|
|
@@ -1416,6 +1417,7 @@ var DataLayer = /*#__PURE__*/function () {
|
|
|
1416
1417
|
createPromise = toCreate.length ? this.db.record.createMany({
|
|
1417
1418
|
data: toCreate.map(function (record) {
|
|
1418
1419
|
return _extends({}, record, {
|
|
1420
|
+
externalId: String(record.externalId),
|
|
1419
1421
|
data: record.data
|
|
1420
1422
|
});
|
|
1421
1423
|
})
|
|
@@ -3228,19 +3230,6 @@ function allowedKey(key) {
|
|
|
3228
3230
|
}
|
|
3229
3231
|
return false;
|
|
3230
3232
|
}
|
|
3231
|
-
function transformKey(input) {
|
|
3232
|
-
// Use a regular expression to match 'get', followed by any characters and then the first uppercase letter
|
|
3233
|
-
return input.replace(/^(get|Get)([A-Z][a-z]*)/, function (_, __, firstPart) {
|
|
3234
|
-
// Convert the first meaningful part to lowercase
|
|
3235
|
-
return firstPart.toLowerCase();
|
|
3236
|
-
}).replace(/^([a-z]+)([A-Z].*)?$/, function (_, firstPart) {
|
|
3237
|
-
// Return the first part in lowercase
|
|
3238
|
-
return firstPart.toLowerCase();
|
|
3239
|
-
}).replace(/^([a-z]+)([A-Z].*)?$/, function (_, firstPart) {
|
|
3240
|
-
// Return the first part in lowercase
|
|
3241
|
-
return firstPart.toLowerCase();
|
|
3242
|
-
});
|
|
3243
|
-
}
|
|
3244
3233
|
function extractPlural(input) {
|
|
3245
3234
|
// Use a regular expression to match the pattern
|
|
3246
3235
|
var regex = /^get([A-Z][a-z]*(?:[A-Z][a-z]*)*)(?:([A-Z][a-z]+))?$/;
|
|
@@ -3278,7 +3267,8 @@ function getEntityKey(key) {
|
|
|
3278
3267
|
}
|
|
3279
3268
|
return removeDuplicateWord(pluralS.toLowerCase());
|
|
3280
3269
|
}
|
|
3281
|
-
return
|
|
3270
|
+
return key;
|
|
3271
|
+
// return transformKey(key);
|
|
3282
3272
|
}
|
|
3283
3273
|
function generateSyncs(_ref4) {
|
|
3284
3274
|
var client = _ref4.client,
|
|
@@ -3313,7 +3303,7 @@ function generateSyncs(_ref4) {
|
|
|
3313
3303
|
event: eventKey,
|
|
3314
3304
|
executor: function () {
|
|
3315
3305
|
var _executor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref6) {
|
|
3316
|
-
var event, connectionId, options, api, result, resultData, records;
|
|
3306
|
+
var event, connectionId, options, api, result, resultData, fallbackIDKey, records;
|
|
3317
3307
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3318
3308
|
while (1) switch (_context.prev = _context.next) {
|
|
3319
3309
|
case 0:
|
|
@@ -3338,14 +3328,17 @@ function generateSyncs(_ref4) {
|
|
|
3338
3328
|
result = _context.sent;
|
|
3339
3329
|
// First see if we are getting the list data
|
|
3340
3330
|
resultData = (result == null ? void 0 : result[listDataKey]) || [result];
|
|
3331
|
+
fallbackIDKey = Object.keys(resultData[0]).find(function (k) {
|
|
3332
|
+
return k.includes('id');
|
|
3333
|
+
}) || 'id';
|
|
3341
3334
|
records = resultData == null ? void 0 : resultData.map(function (d) {
|
|
3342
3335
|
return {
|
|
3343
|
-
externalId: d[idKey],
|
|
3336
|
+
externalId: d[idKey] || d[fallbackIDKey],
|
|
3344
3337
|
data: d,
|
|
3345
3338
|
entityType: entityKey.toUpperCase()
|
|
3346
3339
|
};
|
|
3347
3340
|
});
|
|
3348
|
-
_context.next =
|
|
3341
|
+
_context.next = 15;
|
|
3349
3342
|
return dataLayer == null ? void 0 : dataLayer.syncData({
|
|
3350
3343
|
name: name,
|
|
3351
3344
|
connectionId: connectionId,
|
|
@@ -3354,7 +3347,7 @@ function generateSyncs(_ref4) {
|
|
|
3354
3347
|
type: entityKey.toUpperCase(),
|
|
3355
3348
|
lastSyncId: event == null ? void 0 : event.id
|
|
3356
3349
|
});
|
|
3357
|
-
case
|
|
3350
|
+
case 15:
|
|
3358
3351
|
case "end":
|
|
3359
3352
|
return _context.stop();
|
|
3360
3353
|
}
|
|
@@ -3369,7 +3362,9 @@ function generateSyncs(_ref4) {
|
|
|
3369
3362
|
};
|
|
3370
3363
|
events[name + "." + entityKey + "/sync"] = {
|
|
3371
3364
|
schema: inputSchema,
|
|
3372
|
-
handler: handler
|
|
3365
|
+
handler: handler,
|
|
3366
|
+
fields: properties,
|
|
3367
|
+
entityType: entityKey
|
|
3373
3368
|
};
|
|
3374
3369
|
}
|
|
3375
3370
|
});
|
|
@@ -4653,17 +4648,17 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4653
4648
|
}();
|
|
4654
4649
|
_proto.subscribeEvent = /*#__PURE__*/function () {
|
|
4655
4650
|
var _subscribeEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref19) {
|
|
4656
|
-
var
|
|
4651
|
+
var _this$config$runner$u, _this$config$runner, _ref20, _this$config$runner$s, _this$config$runner2;
|
|
4657
4652
|
var id, _ref19$interval, interval, _ref19$timeout, timeout, inngestApiUrl, inngestApiToken, startTime, _poll;
|
|
4658
4653
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
4659
4654
|
while (1) switch (_context8.prev = _context8.next) {
|
|
4660
4655
|
case 0:
|
|
4661
4656
|
id = _ref19.id, _ref19$interval = _ref19.interval, interval = _ref19$interval === void 0 ? 5000 : _ref19$interval, _ref19$timeout = _ref19.timeout, timeout = _ref19$timeout === void 0 ? 60000 : _ref19$timeout;
|
|
4662
|
-
inngestApiUrl = process.env.INNGEST_URL;
|
|
4663
|
-
inngestApiToken = (
|
|
4657
|
+
inngestApiUrl = (_this$config$runner$u = (_this$config$runner = this.config.runner) == null ? void 0 : _this$config$runner.uri) != null ? _this$config$runner$u : process.env.INNGEST_URL;
|
|
4658
|
+
inngestApiToken = (_ref20 = (_this$config$runner$s = (_this$config$runner2 = this.config.runner) == null ? void 0 : _this$config$runner2.signingKey) != null ? _this$config$runner$s : process.env.INNGEST_SIGNING_KEY) != null ? _ref20 : '123';
|
|
4664
4659
|
startTime = Date.now();
|
|
4665
4660
|
_poll = /*#__PURE__*/function () {
|
|
4666
|
-
var
|
|
4661
|
+
var _ref21 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
4667
4662
|
var response, _yield$response$json, data, error, lastRun, elapsedTime;
|
|
4668
4663
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
4669
4664
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -4737,7 +4732,7 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4737
4732
|
}, _callee7, null, [[0, 18]]);
|
|
4738
4733
|
}));
|
|
4739
4734
|
return function poll() {
|
|
4740
|
-
return
|
|
4735
|
+
return _ref21.apply(this, arguments);
|
|
4741
4736
|
};
|
|
4742
4737
|
}();
|
|
4743
4738
|
return _context8.abrupt("return", _poll());
|
|
@@ -4745,7 +4740,7 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4745
4740
|
case "end":
|
|
4746
4741
|
return _context8.stop();
|
|
4747
4742
|
}
|
|
4748
|
-
}, _callee8);
|
|
4743
|
+
}, _callee8, this);
|
|
4749
4744
|
}));
|
|
4750
4745
|
function subscribeEvent(_x7) {
|
|
4751
4746
|
return _subscribeEvent.apply(this, arguments);
|
|
@@ -4753,13 +4748,13 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4753
4748
|
return subscribeEvent;
|
|
4754
4749
|
}();
|
|
4755
4750
|
_proto.triggerEvent = /*#__PURE__*/function () {
|
|
4756
|
-
var _triggerEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(
|
|
4751
|
+
var _triggerEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref22) {
|
|
4757
4752
|
var _this3 = this;
|
|
4758
|
-
var key, data, user,
|
|
4753
|
+
var key, data, user, _ref22$integrationNam, integrationName, returnObj, integrationEvents, integrationEvent, event, workflowEvent;
|
|
4759
4754
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
4760
4755
|
while (1) switch (_context11.prev = _context11.next) {
|
|
4761
4756
|
case 0:
|
|
4762
|
-
key =
|
|
4757
|
+
key = _ref22.key, data = _ref22.data, user = _ref22.user, _ref22$integrationNam = _ref22.integrationName, integrationName = _ref22$integrationNam === void 0 ? this.config.name : _ref22$integrationNam;
|
|
4763
4758
|
_context11.prev = 1;
|
|
4764
4759
|
returnObj = {
|
|
4765
4760
|
event: {}
|
|
@@ -4790,11 +4785,11 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4790
4785
|
subscribe: function () {
|
|
4791
4786
|
var _subscribe = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_temp) {
|
|
4792
4787
|
var _event$ids;
|
|
4793
|
-
var
|
|
4788
|
+
var _ref23, interval, timeout;
|
|
4794
4789
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
4795
4790
|
while (1) switch (_context9.prev = _context9.next) {
|
|
4796
4791
|
case 0:
|
|
4797
|
-
|
|
4792
|
+
_ref23 = _temp === void 0 ? {} : _temp, interval = _ref23.interval, timeout = _ref23.timeout;
|
|
4798
4793
|
return _context9.abrupt("return", _this3.subscribeEvent({
|
|
4799
4794
|
id: (_event$ids = event.ids) == null ? void 0 : _event$ids[0],
|
|
4800
4795
|
interval: interval,
|
|
@@ -4827,11 +4822,11 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4827
4822
|
subscribe: function () {
|
|
4828
4823
|
var _subscribe2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_temp2) {
|
|
4829
4824
|
var _workflowEvent$ids;
|
|
4830
|
-
var
|
|
4825
|
+
var _ref24, interval, timeout;
|
|
4831
4826
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
4832
4827
|
while (1) switch (_context10.prev = _context10.next) {
|
|
4833
4828
|
case 0:
|
|
4834
|
-
|
|
4829
|
+
_ref24 = _temp2 === void 0 ? {} : _temp2, interval = _ref24.interval, timeout = _ref24.timeout;
|
|
4835
4830
|
return _context10.abrupt("return", _this3.subscribeEvent({
|
|
4836
4831
|
id: (_workflowEvent$ids = workflowEvent.ids) == null ? void 0 : _workflowEvent$ids[0],
|
|
4837
4832
|
interval: interval,
|
|
@@ -4869,12 +4864,12 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4869
4864
|
_proto.triggerSystemEvent =
|
|
4870
4865
|
/*#__PURE__*/
|
|
4871
4866
|
function () {
|
|
4872
|
-
var _triggerSystemEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(
|
|
4867
|
+
var _triggerSystemEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref25) {
|
|
4873
4868
|
var key, data, user, event, systemEvent;
|
|
4874
4869
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
4875
4870
|
while (1) switch (_context12.prev = _context12.next) {
|
|
4876
4871
|
case 0:
|
|
4877
|
-
key =
|
|
4872
|
+
key = _ref25.key, data = _ref25.data, user = _ref25.user;
|
|
4878
4873
|
_context12.next = 3;
|
|
4879
4874
|
return client.send({
|
|
4880
4875
|
name: key,
|
|
@@ -4912,10 +4907,10 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4912
4907
|
}();
|
|
4913
4908
|
_proto.createRouter = function createRouter() {
|
|
4914
4909
|
var self = this;
|
|
4915
|
-
var makeWebhookUrl = function makeWebhookUrl(
|
|
4910
|
+
var makeWebhookUrl = function makeWebhookUrl(_ref26) {
|
|
4916
4911
|
var _self$config;
|
|
4917
|
-
var event =
|
|
4918
|
-
name =
|
|
4912
|
+
var event = _ref26.event,
|
|
4913
|
+
name = _ref26.name;
|
|
4919
4914
|
return encodeURI("" + (self == null || (_self$config = self.config) == null ? void 0 : _self$config.systemHostURL) + self.routes.webhook + "?name=" + name + "&event=" + event);
|
|
4920
4915
|
};
|
|
4921
4916
|
var makeRedirectURI = function makeRedirectURI() {
|
|
@@ -4955,10 +4950,10 @@ var Framework = /*#__PURE__*/function () {
|
|
|
4955
4950
|
inngest: '/inngest',
|
|
4956
4951
|
webhook: '/webhook'
|
|
4957
4952
|
};
|
|
4958
|
-
return Object.entries(registry).reduce(function (acc,
|
|
4953
|
+
return Object.entries(registry).reduce(function (acc, _ref27) {
|
|
4959
4954
|
var _extends3;
|
|
4960
|
-
var key =
|
|
4961
|
-
value =
|
|
4955
|
+
var key = _ref27[0],
|
|
4956
|
+
value = _ref27[1];
|
|
4962
4957
|
return _extends({}, acc, (_extends3 = {}, _extends3[key] = "" + _this4.config.routeRegistrationPath + value, _extends3));
|
|
4963
4958
|
}, {});
|
|
4964
4959
|
}
|