@budibase/backend-core 2.13.4 → 2.13.6

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.
Files changed (42) hide show
  1. package/dist/index.js +39 -23
  2. package/dist/index.js.map +4 -4
  3. package/dist/index.js.meta.json +1 -1
  4. package/dist/package.json +4 -4
  5. package/dist/plugins.js.meta.json +1 -1
  6. package/dist/src/cache/appMetadata.js.map +1 -1
  7. package/dist/src/constants/db.d.ts +1 -3
  8. package/dist/src/constants/db.js.map +1 -1
  9. package/dist/src/context/Context.d.ts +1 -1
  10. package/dist/src/context/Context.js.map +1 -1
  11. package/dist/src/context/identity.d.ts +3 -3
  12. package/dist/src/context/mainContext.d.ts +7 -7
  13. package/dist/src/context/mainContext.js +3 -0
  14. package/dist/src/context/mainContext.js.map +1 -1
  15. package/dist/src/db/couch/DatabaseImpl.d.ts +3 -3
  16. package/dist/src/db/couch/DatabaseImpl.js +0 -3
  17. package/dist/src/db/couch/DatabaseImpl.js.map +1 -1
  18. package/dist/src/db/db.d.ts +3 -4
  19. package/dist/src/db/db.js +2 -14
  20. package/dist/src/db/db.js.map +1 -1
  21. package/dist/src/db/views.d.ts +7 -7
  22. package/dist/src/db/views.js +4 -5
  23. package/dist/src/db/views.js.map +1 -1
  24. package/dist/src/index.d.ts +8 -8
  25. package/dist/src/users/db.js +1 -1
  26. package/dist/src/users/db.js.map +1 -1
  27. package/dist/src/users/users.js.map +1 -1
  28. package/dist/src/utils/utils.d.ts +1 -0
  29. package/dist/src/utils/utils.js +16 -1
  30. package/dist/src/utils/utils.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/cache/appMetadata.ts +1 -1
  33. package/src/constants/db.ts +1 -1
  34. package/src/context/Context.ts +1 -1
  35. package/src/context/mainContext.ts +13 -10
  36. package/src/db/couch/DatabaseImpl.ts +5 -6
  37. package/src/db/db.ts +3 -13
  38. package/src/db/views.ts +22 -23
  39. package/src/users/db.ts +4 -6
  40. package/src/users/users.ts +1 -1
  41. package/src/utils/tests/utils.spec.ts +13 -0
  42. package/src/utils/utils.ts +14 -0
@@ -151,7 +151,7 @@ export const searchGlobalUsersByApp = async (
151
151
  include_docs: true,
152
152
  })
153
153
  params.startkey = opts && opts.startkey ? opts.startkey : params.startkey
154
- let response = await queryGlobalView(ViewName.USER_BY_APP, params)
154
+ let response = await queryGlobalView<User>(ViewName.USER_BY_APP, params)
155
155
 
156
156
  if (!response) {
157
157
  response = []
@@ -188,4 +188,17 @@ describe("utils", () => {
188
188
  expectResult(false)
189
189
  })
190
190
  })
191
+
192
+ describe("hasCircularStructure", () => {
193
+ it("should detect a circular structure", () => {
194
+ const a: any = { b: "b" }
195
+ const b = { a }
196
+ a.b = b
197
+ expect(utils.hasCircularStructure(b)).toBe(true)
198
+ })
199
+
200
+ it("should allow none circular structures", () => {
201
+ expect(utils.hasCircularStructure({ a: "b" })).toBe(false)
202
+ })
203
+ })
191
204
  })
@@ -237,3 +237,17 @@ export function timeout(timeMs: number) {
237
237
  export function isAudited(event: Event) {
238
238
  return !!AuditedEventFriendlyName[event]
239
239
  }
240
+
241
+ export function hasCircularStructure(json: any) {
242
+ if (typeof json !== "object") {
243
+ return false
244
+ }
245
+ try {
246
+ JSON.stringify(json)
247
+ } catch (err) {
248
+ if (err instanceof Error && err?.message.includes("circular structure")) {
249
+ return true
250
+ }
251
+ }
252
+ return false
253
+ }