@budibase/backend-core 2.21.9 → 2.22.1

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 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
- const tenantId = getTenantIDFromAppID(params2.appId);
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) {
@@ -61896,6 +61911,16 @@ async function fileImported(app) {
61896
61911
  };
61897
61912
  await publishEvent("app:file:imported" /* APP_FILE_IMPORTED */, properties);
61898
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
+ }
61899
61924
  async function templateImported(app, templateKey) {
61900
61925
  const properties = {
61901
61926
  appId: app.appId,
@@ -61953,6 +61978,7 @@ var app_default = {
61953
61978
  published,
61954
61979
  unpublished,
61955
61980
  fileImported,
61981
+ duplicated,
61956
61982
  templateImported,
61957
61983
  versionUpdated,
61958
61984
  versionReverted,