@budibase/backend-core 2.21.8 → 2.22.0
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/index.js +28 -40
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.map +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/context/mainContext.d.ts +1 -0
- package/dist/src/context/mainContext.js +23 -3
- package/dist/src/context/mainContext.js.map +1 -1
- package/dist/src/context/types.d.ts +3 -3
- package/dist/src/events/publishers/app.d.ts +2 -0
- package/dist/src/events/publishers/app.js +13 -0
- package/dist/src/events/publishers/app.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/timers/timers.d.ts +0 -12
- package/dist/src/timers/timers.js +1 -38
- package/dist/src/timers/timers.js.map +1 -1
- package/dist/tests/core/utilities/mocks/events.js +1 -0
- package/dist/tests/core/utilities/mocks/events.js.map +1 -1
- package/package.json +4 -4
- package/src/cache/tests/docWritethrough.spec.ts +1 -1
- package/src/context/mainContext.ts +24 -3
- package/src/context/types.ts +3 -3
- package/src/events/publishers/app.ts +13 -0
- package/src/timers/timers.ts +0 -38
- package/tests/core/utilities/mocks/events.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -54263,6 +54263,7 @@ var AuditedEventFriendlyName = {
|
|
|
54263
54263
|
["app:created" /* APP_CREATED */]: `App "{{ name }}" created`,
|
|
54264
54264
|
["app:updated" /* APP_UPDATED */]: `App "{{ name }}" updated`,
|
|
54265
54265
|
["app:deleted" /* APP_DELETED */]: `App "{{ name }}" deleted`,
|
|
54266
|
+
["app:duplicated" /* APP_DUPLICATED */]: `App "{{ name }}" duplicated`,
|
|
54266
54267
|
["app:published" /* APP_PUBLISHED */]: `App "{{ name }}" published`,
|
|
54267
54268
|
["app:unpublished" /* APP_UNPUBLISHED */]: `App "{{ name }}" unpublished`,
|
|
54268
54269
|
["app:template:imported" /* APP_TEMPLATE_IMPORTED */]: `App "{{ name }}" template imported`,
|
|
@@ -55104,6 +55105,7 @@ __export(context_exports, {
|
|
|
55104
55105
|
doInIdentityContext: () => doInIdentityContext,
|
|
55105
55106
|
doInScimContext: () => doInScimContext,
|
|
55106
55107
|
doInTenant: () => doInTenant,
|
|
55108
|
+
ensureSnippetContext: () => ensureSnippetContext,
|
|
55107
55109
|
getAppDB: () => getAppDB,
|
|
55108
55110
|
getAppId: () => getAppId,
|
|
55109
55111
|
getAuditLogDBName: () => getAuditLogDBName,
|
|
@@ -56037,10 +56039,10 @@ async function newContext(updates, task) {
|
|
|
56037
56039
|
return Context.run(context, task);
|
|
56038
56040
|
}
|
|
56039
56041
|
async function doInAutomationContext(params2) {
|
|
56040
|
-
|
|
56042
|
+
await ensureSnippetContext();
|
|
56041
56043
|
return newContext(
|
|
56042
56044
|
{
|
|
56043
|
-
tenantId,
|
|
56045
|
+
tenantId: getTenantIDFromAppID(params2.appId),
|
|
56044
56046
|
appId: params2.appId,
|
|
56045
56047
|
automationId: params2.automationId
|
|
56046
56048
|
},
|
|
@@ -56156,6 +56158,19 @@ function doInScimContext(task) {
|
|
|
56156
56158
|
};
|
|
56157
56159
|
return newContext(updates, task);
|
|
56158
56160
|
}
|
|
56161
|
+
async function ensureSnippetContext() {
|
|
56162
|
+
const ctx = getCurrentContext();
|
|
56163
|
+
if (!ctx || ctx.snippets) {
|
|
56164
|
+
return;
|
|
56165
|
+
}
|
|
56166
|
+
let snippets;
|
|
56167
|
+
const db = getAppDB();
|
|
56168
|
+
if (db && !environment_default.isTest()) {
|
|
56169
|
+
const app = await db.get("app_metadata" /* APP_METADATA */);
|
|
56170
|
+
snippets = app.snippets;
|
|
56171
|
+
}
|
|
56172
|
+
ctx.snippets = snippets || [];
|
|
56173
|
+
}
|
|
56159
56174
|
function getEnvironmentVariables() {
|
|
56160
56175
|
const context = Context.get();
|
|
56161
56176
|
if (!context.environmentVariables) {
|
|
@@ -58481,8 +58496,6 @@ function logWarn(message, e) {
|
|
|
58481
58496
|
// src/timers/index.ts
|
|
58482
58497
|
var timers_exports = {};
|
|
58483
58498
|
__export(timers_exports, {
|
|
58484
|
-
ExecutionTimeTracker: () => ExecutionTimeTracker,
|
|
58485
|
-
ExecutionTimeoutError: () => ExecutionTimeoutError,
|
|
58486
58499
|
cleanup: () => cleanup,
|
|
58487
58500
|
clear: () => clear,
|
|
58488
58501
|
set: () => set
|
|
@@ -58508,42 +58521,6 @@ function cleanup() {
|
|
|
58508
58521
|
}
|
|
58509
58522
|
intervals = [];
|
|
58510
58523
|
}
|
|
58511
|
-
var ExecutionTimeoutError = class extends Error {
|
|
58512
|
-
constructor() {
|
|
58513
|
-
super(...arguments);
|
|
58514
|
-
this.name = "ExecutionTimeoutError";
|
|
58515
|
-
}
|
|
58516
|
-
};
|
|
58517
|
-
var ExecutionTimeTracker = class _ExecutionTimeTracker {
|
|
58518
|
-
constructor(limitMs) {
|
|
58519
|
-
this.limitMs = limitMs;
|
|
58520
|
-
this.totalTimeMs = 0;
|
|
58521
|
-
}
|
|
58522
|
-
static withLimit(limitMs) {
|
|
58523
|
-
return new _ExecutionTimeTracker(limitMs);
|
|
58524
|
-
}
|
|
58525
|
-
track(f) {
|
|
58526
|
-
this.checkLimit();
|
|
58527
|
-
const start2 = process.hrtime.bigint();
|
|
58528
|
-
try {
|
|
58529
|
-
return f();
|
|
58530
|
-
} finally {
|
|
58531
|
-
const end2 = process.hrtime.bigint();
|
|
58532
|
-
this.totalTimeMs += Number(end2 - start2) / 1e6;
|
|
58533
|
-
this.checkLimit();
|
|
58534
|
-
}
|
|
58535
|
-
}
|
|
58536
|
-
get elapsedMS() {
|
|
58537
|
-
return this.totalTimeMs;
|
|
58538
|
-
}
|
|
58539
|
-
checkLimit() {
|
|
58540
|
-
if (this.totalTimeMs > this.limitMs) {
|
|
58541
|
-
throw new ExecutionTimeoutError(
|
|
58542
|
-
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
|
58543
|
-
);
|
|
58544
|
-
}
|
|
58545
|
-
}
|
|
58546
|
-
};
|
|
58547
58524
|
|
|
58548
58525
|
// src/redis/redis.ts
|
|
58549
58526
|
var MockRedis;
|
|
@@ -61934,6 +61911,16 @@ async function fileImported(app) {
|
|
|
61934
61911
|
};
|
|
61935
61912
|
await publishEvent("app:file:imported" /* APP_FILE_IMPORTED */, properties);
|
|
61936
61913
|
}
|
|
61914
|
+
async function duplicated(app, duplicateAppId) {
|
|
61915
|
+
const properties = {
|
|
61916
|
+
duplicateAppId,
|
|
61917
|
+
appId: app.appId,
|
|
61918
|
+
audited: {
|
|
61919
|
+
name: app.name
|
|
61920
|
+
}
|
|
61921
|
+
};
|
|
61922
|
+
await publishEvent("app:duplicated" /* APP_DUPLICATED */, properties);
|
|
61923
|
+
}
|
|
61937
61924
|
async function templateImported(app, templateKey) {
|
|
61938
61925
|
const properties = {
|
|
61939
61926
|
appId: app.appId,
|
|
@@ -61991,6 +61978,7 @@ var app_default = {
|
|
|
61991
61978
|
published,
|
|
61992
61979
|
unpublished,
|
|
61993
61980
|
fileImported,
|
|
61981
|
+
duplicated,
|
|
61994
61982
|
templateImported,
|
|
61995
61983
|
versionUpdated,
|
|
61996
61984
|
versionReverted,
|