@aeriajs/core 0.0.136 → 0.0.138

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 (43) hide show
  1. package/dist/collection/reference.js +20 -8
  2. package/dist/collection/reference.mjs +20 -10
  3. package/dist/collection/traverseDocument.js +1 -1
  4. package/dist/collection/traverseDocument.mjs +1 -1
  5. package/dist/functions/{builtin/count.d.ts → count.d.ts} +8 -1
  6. package/dist/functions/{builtin/count.js → count.js} +26 -13
  7. package/dist/functions/count.mjs +44 -0
  8. package/dist/functions/{builtin/get.js → get.js} +19 -7
  9. package/dist/functions/{builtin/get.mjs → get.mjs} +18 -5
  10. package/dist/functions/getAll.d.ts +13 -0
  11. package/dist/functions/{builtin/getAll.js → getAll.js} +29 -11
  12. package/dist/functions/{builtin/getAll.mjs → getAll.mjs} +25 -10
  13. package/dist/functions/index.d.ts +8 -1
  14. package/dist/functions/index.js +8 -1
  15. package/dist/functions/index.mjs +8 -1
  16. package/dist/functions/{builtin/insert.d.ts → insert.d.ts} +5 -1
  17. package/dist/functions/{builtin/insert.js → insert.js} +14 -7
  18. package/dist/functions/{builtin/insert.mjs → insert.mjs} +14 -5
  19. package/dist/functions/{builtin/remove.d.ts → remove.d.ts} +9 -6
  20. package/dist/functions/{builtin/remove.js → remove.js} +16 -2
  21. package/dist/functions/{builtin/remove.mjs → remove.mjs} +17 -2
  22. package/dist/functions/{builtin/removeAll.d.ts → removeAll.d.ts} +4 -1
  23. package/dist/functions/{builtin/removeAll.js → removeAll.js} +16 -2
  24. package/dist/functions/removeAll.mjs +36 -0
  25. package/dist/functions/{builtin/removeFile.d.ts → removeFile.d.ts} +4 -1
  26. package/dist/functions/removeFile.js +24 -0
  27. package/dist/functions/removeFile.mjs +26 -0
  28. package/dist/functions/{builtin/upload.js → upload.js} +1 -2
  29. package/dist/functions/{builtin/upload.mjs → upload.mjs} +1 -2
  30. package/dist/index.d.ts +1 -2
  31. package/dist/index.js +1 -2
  32. package/dist/index.mjs +1 -2
  33. package/package.json +8 -8
  34. package/dist/functions/builtin/count.mjs +0 -33
  35. package/dist/functions/builtin/getAll.d.ts +0 -9
  36. package/dist/functions/builtin/index.d.ts +0 -8
  37. package/dist/functions/builtin/index.js +0 -24
  38. package/dist/functions/builtin/index.mjs +0 -9
  39. package/dist/functions/builtin/removeAll.mjs +0 -21
  40. package/dist/functions/builtin/removeFile.js +0 -17
  41. package/dist/functions/builtin/removeFile.mjs +0 -18
  42. /package/dist/functions/{builtin/get.d.ts → get.d.ts} +0 -0
  43. /package/dist/functions/{builtin/upload.d.ts → upload.d.ts} +0 -0
@@ -91,7 +91,6 @@ const getReferences = async (properties, options) => {
91
91
  // }
92
92
  if ('properties' in entrypoint) {
93
93
  const deepReferences = await (0, exports.getReferences)(entrypoint.properties, {
94
- depth: depth + 1,
95
94
  memoize: `${memoize}.${propName}`,
96
95
  });
97
96
  if (Object.keys(deepReferences).length > 0) {
@@ -237,15 +236,28 @@ const buildLookupStages = async (reference, propName, options) => {
237
236
  continue;
238
237
  }
239
238
  const refProperties = properties[propName];
240
- if (!('properties' in refProperties)) {
239
+ if ('properties' in refProperties) {
240
+ const { stages: refStages } = await buildLookupStages(refMap, refName, {
241
+ depth: depth + 1,
242
+ parent: withParent(propName),
243
+ properties: refProperties.properties,
244
+ });
245
+ stages.push(...refStages);
246
+ }
247
+ else if ('items' in refProperties) {
248
+ if (!('properties' in refProperties.items)) {
249
+ throw new Error();
250
+ }
251
+ const { stages: refStages } = await buildLookupStages(refMap, refName, {
252
+ depth: depth + 1,
253
+ parent: withParent(propName),
254
+ properties: refProperties.items.properties,
255
+ });
256
+ stages.push(...refStages);
257
+ }
258
+ else {
241
259
  throw new Error();
242
260
  }
243
- const { stages: result } = await buildLookupStages(refMap, refName, {
244
- depth: depth + 1,
245
- parent: withParent(propName),
246
- properties: refProperties.properties,
247
- });
248
- stages.push(...result);
249
261
  }
250
262
  }
251
263
  return {
@@ -81,7 +81,6 @@ export const getReferences = async (properties, options) => {
81
81
  const entrypoint = "items" in property ? property.items : property;
82
82
  if ("properties" in entrypoint) {
83
83
  const deepReferences = await getReferences(entrypoint.properties, {
84
- depth: depth + 1,
85
84
  memoize: `${memoize}.${propName}`
86
85
  });
87
86
  if (Object.keys(deepReferences).length > 0) {
@@ -211,24 +210,35 @@ const buildLookupStages = async (reference, propName, options) => {
211
210
  }
212
211
  if (refMap.referencedCollection) {
213
212
  const description = throwIfError(await getCollectionAsset(refMap.referencedCollection, "description"));
214
- const { stages: result2 } = await buildLookupStages(refMap, refName, {
213
+ const { stages: result } = await buildLookupStages(refMap, refName, {
215
214
  depth: depth + 1,
216
215
  parent: withParent(propName),
217
216
  properties: description.properties
218
217
  });
219
- stages.push(...result2);
218
+ stages.push(...result);
220
219
  continue;
221
220
  }
222
221
  const refProperties = properties[propName];
223
- if (!("properties" in refProperties)) {
222
+ if ("properties" in refProperties) {
223
+ const { stages: refStages } = await buildLookupStages(refMap, refName, {
224
+ depth: depth + 1,
225
+ parent: withParent(propName),
226
+ properties: refProperties.properties
227
+ });
228
+ stages.push(...refStages);
229
+ } else if ("items" in refProperties) {
230
+ if (!("properties" in refProperties.items)) {
231
+ throw new Error();
232
+ }
233
+ const { stages: refStages } = await buildLookupStages(refMap, refName, {
234
+ depth: depth + 1,
235
+ parent: withParent(propName),
236
+ properties: refProperties.items.properties
237
+ });
238
+ stages.push(...refStages);
239
+ } else {
224
240
  throw new Error();
225
241
  }
226
- const { stages: result } = await buildLookupStages(refMap, refName, {
227
- depth: depth + 1,
228
- parent: withParent(propName),
229
- properties: refProperties.properties
230
- });
231
- stages.push(...result);
232
242
  }
233
243
  }
234
244
  return {
@@ -40,7 +40,7 @@ const getProperty = (propertyName, parentProperty) => {
40
40
  if ('items' in parentProperty && 'properties' in parentProperty.items && propertyName in parentProperty.items.properties) {
41
41
  return parentProperty.items.properties[propertyName];
42
42
  }
43
- if ('additionalProperties' in parentProperty) {
43
+ if ('additionalProperties' in parentProperty && typeof parentProperty.additionalProperties === 'object') {
44
44
  return parentProperty.additionalProperties;
45
45
  }
46
46
  if ('properties' in parentProperty) {
@@ -15,7 +15,7 @@ const getProperty = (propertyName, parentProperty) => {
15
15
  if ("items" in parentProperty && "properties" in parentProperty.items && propertyName in parentProperty.items.properties) {
16
16
  return parentProperty.items.properties[propertyName];
17
17
  }
18
- if ("additionalProperties" in parentProperty) {
18
+ if ("additionalProperties" in parentProperty && typeof parentProperty.additionalProperties === "object") {
19
19
  return parentProperty.additionalProperties;
20
20
  }
21
21
  if ("properties" in parentProperty) {
@@ -1,6 +1,13 @@
1
1
  import type { Context, SchemaWithId, CountPayload } from '@aeriajs/types';
2
- export declare const count: <TContext extends Context>(payload: CountPayload<SchemaWithId<TContext["description"]>>, context: TContext extends Context<any> ? TContext : never) => Promise<{
2
+ export type CountOptions = {
3
+ bypassSecurity?: boolean;
4
+ };
5
+ export declare const count: <TContext extends Context>(payload: CountPayload<SchemaWithId<TContext["description"]>>, context: TContext extends Context<any> ? TContext : never, options?: CountOptions) => Promise<{
3
6
  readonly _tag: "Result";
4
7
  readonly error: undefined;
5
8
  readonly result: any;
9
+ } | {
10
+ readonly _tag: "Error";
11
+ readonly error: import("@aeriajs/types").ACError.InvalidLimit;
12
+ readonly result: undefined;
6
13
  }>;
@@ -4,24 +4,26 @@ exports.count = void 0;
4
4
  const security_1 = require("@aeriajs/security");
5
5
  const types_1 = require("@aeriajs/types");
6
6
  const common_1 = require("@aeriajs/common");
7
- const index_js_1 = require("../../collection/index.js");
8
- const count = async (payload, context) => {
9
- const security = (0, security_1.useSecurity)(context);
10
- const { filters } = (0, common_1.throwIfError)(await security.beforeRead(payload));
11
- const { $text, ...filtersRest } = filters;
12
- const traversedFilters = (0, common_1.throwIfError)(await (0, index_js_1.traverseDocument)(filtersRest, context.description, {
7
+ const index_js_1 = require("../collection/index.js");
8
+ const internalCount = async (payload, context) => {
9
+ const { filters = {} } = payload;
10
+ const $text = '$text' in filters
11
+ ? filters.$text
12
+ : undefined;
13
+ if ('$text' in filters) {
14
+ delete filters.$text;
15
+ }
16
+ const traversedFilters = (0, common_1.throwIfError)(await (0, index_js_1.traverseDocument)(filters, context.description, {
13
17
  autoCast: true,
14
18
  allowOperators: true,
15
19
  }));
16
20
  if ($text) {
17
21
  const pipeline = [];
18
- if ($text) {
19
- pipeline.push({
20
- $match: {
21
- $text,
22
- },
23
- });
24
- }
22
+ pipeline.push({
23
+ $match: {
24
+ $text,
25
+ },
26
+ });
25
27
  pipeline.push({
26
28
  $match: traversedFilters,
27
29
  });
@@ -35,4 +37,15 @@ const count = async (payload, context) => {
35
37
  }
36
38
  return types_1.Result.result(await context.collection.model.countDocuments(traversedFilters));
37
39
  };
40
+ const count = async (payload, context, options = {}) => {
41
+ if (options.bypassSecurity) {
42
+ return internalCount(payload, context);
43
+ }
44
+ const security = (0, security_1.useSecurity)(context);
45
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
46
+ if (error) {
47
+ return types_1.Result.error(error);
48
+ }
49
+ return internalCount(securedPayload, context);
50
+ };
38
51
  exports.count = count;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ import { useSecurity } from "@aeriajs/security";
3
+ import { Result } from "@aeriajs/types";
4
+ import { throwIfError } from "@aeriajs/common";
5
+ import { traverseDocument } from "../collection/index.mjs";
6
+ const internalCount = async (payload, context) => {
7
+ const { filters = {} } = payload;
8
+ const $text = "$text" in filters ? filters.$text : void 0;
9
+ if ("$text" in filters) {
10
+ delete filters.$text;
11
+ }
12
+ const traversedFilters = throwIfError(await traverseDocument(filters, context.description, {
13
+ autoCast: true,
14
+ allowOperators: true
15
+ }));
16
+ if ($text) {
17
+ const pipeline = [];
18
+ pipeline.push({
19
+ $match: {
20
+ $text
21
+ }
22
+ });
23
+ pipeline.push({
24
+ $match: traversedFilters
25
+ });
26
+ pipeline.push({
27
+ $count: "total"
28
+ });
29
+ const result = await context.collection.model.aggregate(pipeline).next();
30
+ return Result.result(result ? result.total : 0);
31
+ }
32
+ return Result.result(await context.collection.model.countDocuments(traversedFilters));
33
+ };
34
+ export const count = async (payload, context, options = {}) => {
35
+ if (options.bypassSecurity) {
36
+ return internalCount(payload, context);
37
+ }
38
+ const security = useSecurity(context);
39
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
40
+ if (error) {
41
+ return Result.error(error);
42
+ }
43
+ return internalCount(securedPayload, context);
44
+ };
@@ -4,12 +4,9 @@ exports.get = void 0;
4
4
  const security_1 = require("@aeriajs/security");
5
5
  const types_1 = require("@aeriajs/types");
6
6
  const common_1 = require("@aeriajs/common");
7
- const index_js_1 = require("../../collection/index.js");
8
- const get = async (payload, context, options) => {
9
- const security = (0, security_1.useSecurity)(context);
10
- const { filters = {}, project = [], } = !options?.bypassSecurity
11
- ? (0, common_1.throwIfError)(await security.beforeRead(payload))
12
- : payload;
7
+ const index_js_1 = require("../collection/index.js");
8
+ const internalGet = async (payload, context) => {
9
+ const { filters = {}, project = [], } = payload;
13
10
  if (Object.keys(filters).length === 0) {
14
11
  return context.error(types_1.HTTPStatus.BadRequest, {
15
12
  code: types_1.ACError.MalformedInput,
@@ -33,7 +30,9 @@ const get = async (payload, context, options) => {
33
30
  }
34
31
  pipeline.push(...await (0, index_js_1.buildLookupPipeline)(references, {
35
32
  memoize: context.description.$id,
36
- project: payload.populate || project,
33
+ project: payload.populate
34
+ ? payload.populate
35
+ : project,
37
36
  properties: context.description.properties,
38
37
  }));
39
38
  const doc = await context.collection.model.aggregate(pipeline).next();
@@ -50,4 +49,17 @@ const get = async (payload, context, options) => {
50
49
  })), context.description);
51
50
  return types_1.Result.result(result);
52
51
  };
52
+ const get = async (payload, context, options = {}) => {
53
+ if (options.bypassSecurity) {
54
+ return internalGet(payload, context);
55
+ }
56
+ const security = (0, security_1.useSecurity)(context);
57
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
58
+ if (error) {
59
+ switch (error) {
60
+ case types_1.ACError.InvalidLimit: throw new Error;
61
+ }
62
+ }
63
+ return internalGet(securedPayload, context);
64
+ };
53
65
  exports.get = get;
@@ -8,13 +8,12 @@ import {
8
8
  getReferences,
9
9
  buildLookupPipeline,
10
10
  fill
11
- } from "../../collection/index.mjs";
12
- export const get = async (payload, context, options) => {
13
- const security = useSecurity(context);
11
+ } from "../collection/index.mjs";
12
+ const internalGet = async (payload, context) => {
14
13
  const {
15
14
  filters = {},
16
15
  project = []
17
- } = !options?.bypassSecurity ? throwIfError(await security.beforeRead(payload)) : payload;
16
+ } = payload;
18
17
  if (Object.keys(filters).length === 0) {
19
18
  return context.error(HTTPStatus.BadRequest, {
20
19
  code: ACError.MalformedInput
@@ -38,7 +37,7 @@ export const get = async (payload, context, options) => {
38
37
  }
39
38
  pipeline.push(...await buildLookupPipeline(references, {
40
39
  memoize: context.description.$id,
41
- project: payload.populate || project,
40
+ project: payload.populate ? payload.populate : project,
42
41
  properties: context.description.properties
43
42
  }));
44
43
  const doc = await context.collection.model.aggregate(pipeline).next();
@@ -55,3 +54,17 @@ export const get = async (payload, context, options) => {
55
54
  })), context.description);
56
55
  return Result.result(result);
57
56
  };
57
+ export const get = async (payload, context, options = {}) => {
58
+ if (options.bypassSecurity) {
59
+ return internalGet(payload, context);
60
+ }
61
+ const security = useSecurity(context);
62
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
63
+ if (error) {
64
+ switch (error) {
65
+ case ACError.InvalidLimit:
66
+ throw new Error();
67
+ }
68
+ }
69
+ return internalGet(securedPayload, context);
70
+ };
@@ -0,0 +1,13 @@
1
+ import type { Context, SchemaWithId, GetAllPayload } from '@aeriajs/types';
2
+ export type GetAllOptions = {
3
+ bypassSecurity?: boolean;
4
+ };
5
+ export declare const getAll: <TContext extends Context>(payload: GetAllPayload<SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: GetAllOptions) => Promise<{
6
+ readonly _tag: "Error";
7
+ readonly error: import("@aeriajs/types").ACError.InvalidLimit;
8
+ readonly result: undefined;
9
+ } | {
10
+ readonly _tag: "Result";
11
+ readonly error: undefined;
12
+ readonly result: SchemaWithId<TContext["description"]>[];
13
+ }>;
@@ -4,14 +4,16 @@ exports.getAll = void 0;
4
4
  const security_1 = require("@aeriajs/security");
5
5
  const types_1 = require("@aeriajs/types");
6
6
  const common_1 = require("@aeriajs/common");
7
- const index_js_1 = require("../../collection/index.js");
8
- const getAll = async (_payload, context, options = {}) => {
9
- const security = (0, security_1.useSecurity)(context);
10
- const payload = _payload || {};
11
- const { filters = {}, limit = context.config.paginationLimit, sort, project = [], offset = 0, } = !options.bypassSecurity
12
- ? (0, common_1.throwIfError)(await security.beforeRead(payload))
13
- : payload;
14
- const { $text, ...filtersRest } = filters;
7
+ const index_js_1 = require("../collection/index.js");
8
+ const internalGetAll = async (payload, context) => {
9
+ const { limit = context.config.paginationLimit, sort, project = [], offset = 0, } = payload;
10
+ const filters = payload.filters || {};
11
+ const $text = payload.filters && '$text' in payload.filters
12
+ ? payload.filters.$text
13
+ : undefined;
14
+ if ('$text' in filters) {
15
+ delete filters.$text;
16
+ }
15
17
  const pipeline = [];
16
18
  const references = await (0, index_js_1.getReferences)(context.description.properties, {
17
19
  memoize: context.description.$id,
@@ -35,9 +37,9 @@ const getAll = async (_payload, context, options = {}) => {
35
37
  $sort: preferredSort,
36
38
  });
37
39
  }
38
- if (Object.keys(filtersRest).length > 0) {
40
+ if (Object.keys(filters).length > 0) {
39
41
  pipeline.push({
40
- $match: (0, common_1.throwIfError)(await (0, index_js_1.traverseDocument)(filtersRest, context.description, {
42
+ $match: (0, common_1.throwIfError)(await (0, index_js_1.traverseDocument)(filters, context.description, {
41
43
  autoCast: true,
42
44
  allowOperators: true,
43
45
  })),
@@ -59,7 +61,9 @@ const getAll = async (_payload, context, options = {}) => {
59
61
  }
60
62
  pipeline.push(...await (0, index_js_1.buildLookupPipeline)(references, {
61
63
  memoize: context.description.$id,
62
- project: payload.populate || project,
64
+ project: payload.populate
65
+ ? payload.populate
66
+ : project,
63
67
  properties: context.description.properties,
64
68
  }));
65
69
  if (Object.keys(references).length > 0 && preferredSort) {
@@ -79,4 +83,18 @@ const getAll = async (_payload, context, options = {}) => {
79
83
  }
80
84
  return types_1.Result.result(documents);
81
85
  };
86
+ const getAll = async (payload, context, options = {}) => {
87
+ if (!payload) {
88
+ return internalGetAll({}, context);
89
+ }
90
+ if (options.bypassSecurity) {
91
+ return internalGetAll(payload, context);
92
+ }
93
+ const security = (0, security_1.useSecurity)(context);
94
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
95
+ if (error) {
96
+ return types_1.Result.error(error);
97
+ }
98
+ return internalGetAll(securedPayload, context);
99
+ };
82
100
  exports.getAll = getAll;
@@ -8,18 +8,19 @@ import {
8
8
  getReferences,
9
9
  buildLookupPipeline,
10
10
  fill
11
- } from "../../collection/index.mjs";
12
- export const getAll = async (_payload, context, options = {}) => {
13
- const security = useSecurity(context);
14
- const payload = _payload || {};
11
+ } from "../collection/index.mjs";
12
+ const internalGetAll = async (payload, context) => {
15
13
  const {
16
- filters = {},
17
14
  limit = context.config.paginationLimit,
18
15
  sort,
19
16
  project = [],
20
17
  offset = 0
21
- } = !options.bypassSecurity ? throwIfError(await security.beforeRead(payload)) : payload;
22
- const { $text, ...filtersRest } = filters;
18
+ } = payload;
19
+ const filters = payload.filters || {};
20
+ const $text = payload.filters && "$text" in payload.filters ? payload.filters.$text : void 0;
21
+ if ("$text" in filters) {
22
+ delete filters.$text;
23
+ }
23
24
  const pipeline = [];
24
25
  const references = await getReferences(context.description.properties, {
25
26
  memoize: context.description.$id
@@ -39,9 +40,9 @@ export const getAll = async (_payload, context, options = {}) => {
39
40
  $sort: preferredSort
40
41
  });
41
42
  }
42
- if (Object.keys(filtersRest).length > 0) {
43
+ if (Object.keys(filters).length > 0) {
43
44
  pipeline.push({
44
- $match: throwIfError(await traverseDocument(filtersRest, context.description, {
45
+ $match: throwIfError(await traverseDocument(filters, context.description, {
45
46
  autoCast: true,
46
47
  allowOperators: true
47
48
  }))
@@ -63,7 +64,7 @@ export const getAll = async (_payload, context, options = {}) => {
63
64
  }
64
65
  pipeline.push(...await buildLookupPipeline(references, {
65
66
  memoize: context.description.$id,
66
- project: payload.populate || project,
67
+ project: payload.populate ? payload.populate : project,
67
68
  properties: context.description.properties
68
69
  }));
69
70
  if (Object.keys(references).length > 0 && preferredSort) {
@@ -83,3 +84,17 @@ export const getAll = async (_payload, context, options = {}) => {
83
84
  }
84
85
  return Result.result(documents);
85
86
  };
87
+ export const getAll = async (payload, context, options = {}) => {
88
+ if (!payload) {
89
+ return internalGetAll({}, context);
90
+ }
91
+ if (options.bypassSecurity) {
92
+ return internalGetAll(payload, context);
93
+ }
94
+ const security = useSecurity(context);
95
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
96
+ if (error) {
97
+ return Result.error(error);
98
+ }
99
+ return internalGetAll(securedPayload, context);
100
+ };
@@ -1 +1,8 @@
1
- export * from './builtin/index.js';
1
+ export * from './count.js';
2
+ export * from './get.js';
3
+ export * from './getAll.js';
4
+ export * from './insert.js';
5
+ export * from './remove.js';
6
+ export * from './removeAll.js';
7
+ export * from './removeFile.js';
8
+ export * from './upload.js';
@@ -14,4 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./builtin/index.js"), exports);
17
+ __exportStar(require("./count.js"), exports);
18
+ __exportStar(require("./get.js"), exports);
19
+ __exportStar(require("./getAll.js"), exports);
20
+ __exportStar(require("./insert.js"), exports);
21
+ __exportStar(require("./remove.js"), exports);
22
+ __exportStar(require("./removeAll.js"), exports);
23
+ __exportStar(require("./removeFile.js"), exports);
24
+ __exportStar(require("./upload.js"), exports);
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
- export * from "./builtin/index.mjs";
2
+ export * from "./count.mjs";
3
+ export * from "./get.mjs";
4
+ export * from "./getAll.mjs";
5
+ export * from "./insert.mjs";
6
+ export * from "./remove.mjs";
7
+ export * from "./removeAll.mjs";
8
+ export * from "./removeFile.mjs";
9
+ export * from "./upload.mjs";
@@ -33,4 +33,8 @@ export declare const insertErrorSchema: () => {
33
33
  };
34
34
  };
35
35
  };
36
- export declare const insert: <TContext extends Context>(payload: InsertPayload<SchemaWithId<TContext["description"]>>, context: TContext, options?: InsertOptions) => Promise<InsertReturnType<SchemaWithId<TContext["description"]>>>;
36
+ export declare const insert: <TContext extends Context>(payload: InsertPayload<SchemaWithId<TContext["description"]>>, context: TContext extends Context<any> ? TContext : never, options?: InsertOptions) => Promise<InsertReturnType<SchemaWithId<TContext["description"]>> | {
37
+ readonly _tag: "Error";
38
+ readonly error: ACError;
39
+ readonly result: undefined;
40
+ }>;
@@ -4,7 +4,7 @@ exports.insert = exports.insertErrorSchema = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
5
  const security_1 = require("@aeriajs/security");
6
6
  const common_1 = require("@aeriajs/common");
7
- const index_js_1 = require("../../collection/index.js");
7
+ const index_js_1 = require("../collection/index.js");
8
8
  const insertErrorSchema = () => (0, common_1.endpointErrorSchema)({
9
9
  httpStatus: [
10
10
  types_1.HTTPStatus.UnprocessableContent,
@@ -23,12 +23,8 @@ const insertErrorSchema = () => (0, common_1.endpointErrorSchema)({
23
23
  ],
24
24
  });
25
25
  exports.insertErrorSchema = insertErrorSchema;
26
- const insert = async (payload, context, options) => {
27
- const security = (0, security_1.useSecurity)(context);
28
- const query = !options?.bypassSecurity
29
- ? (0, common_1.throwIfError)(await security.beforeWrite(payload))
30
- : payload;
31
- const { error, result: what } = await (0, index_js_1.traverseDocument)(query.what, context.description, {
26
+ const internalInsert = async (payload, context) => {
27
+ const { error, result: what } = await (0, index_js_1.traverseDocument)(payload.what, context.description, {
32
28
  recurseDeep: true,
33
29
  autoCast: true,
34
30
  validate: true,
@@ -104,4 +100,15 @@ const insert = async (payload, context, options) => {
104
100
  })), context.description);
105
101
  return types_1.Result.result(result);
106
102
  };
103
+ const insert = async (payload, context, options = {}) => {
104
+ if (options.bypassSecurity) {
105
+ return internalInsert(payload, context);
106
+ }
107
+ const security = (0, security_1.useSecurity)(context);
108
+ const { error, result: securedPayload } = await security.secureWritePayload(payload);
109
+ if (error) {
110
+ return types_1.Result.error(error);
111
+ }
112
+ return internalInsert(securedPayload, context);
113
+ };
107
114
  exports.insert = insert;
@@ -2,7 +2,7 @@
2
2
  import { Result, HTTPStatus, ACError, ValidationErrorCode, TraverseError } from "@aeriajs/types";
3
3
  import { useSecurity } from "@aeriajs/security";
4
4
  import { throwIfError, endpointErrorSchema } from "@aeriajs/common";
5
- import { traverseDocument, normalizeProjection, prepareInsert, fill } from "../../collection/index.mjs";
5
+ import { traverseDocument, normalizeProjection, prepareInsert, fill } from "../collection/index.mjs";
6
6
  export const insertErrorSchema = () => endpointErrorSchema({
7
7
  httpStatus: [
8
8
  HTTPStatus.UnprocessableContent,
@@ -20,10 +20,8 @@ export const insertErrorSchema = () => endpointErrorSchema({
20
20
  TraverseError.InvalidTempfile
21
21
  ]
22
22
  });
23
- export const insert = async (payload, context, options) => {
24
- const security = useSecurity(context);
25
- const query = !options?.bypassSecurity ? throwIfError(await security.beforeWrite(payload)) : payload;
26
- const { error, result: what } = await traverseDocument(query.what, context.description, {
23
+ const internalInsert = async (payload, context) => {
24
+ const { error, result: what } = await traverseDocument(payload.what, context.description, {
27
25
  recurseDeep: true,
28
26
  autoCast: true,
29
27
  validate: true,
@@ -91,3 +89,14 @@ export const insert = async (payload, context, options) => {
91
89
  })), context.description);
92
90
  return Result.result(result);
93
91
  };
92
+ export const insert = async (payload, context, options = {}) => {
93
+ if (options.bypassSecurity) {
94
+ return internalInsert(payload, context);
95
+ }
96
+ const security = useSecurity(context);
97
+ const { error, result: securedPayload } = await security.secureWritePayload(payload);
98
+ if (error) {
99
+ return Result.error(error);
100
+ }
101
+ return internalInsert(securedPayload, context);
102
+ };
@@ -1,11 +1,14 @@
1
1
  import type { Context, SchemaWithId, RemovePayload } from '@aeriajs/types';
2
2
  import { Result, HTTPStatus, ACError } from '@aeriajs/types';
3
- export declare const remove: <TContext extends Context>(payload: RemovePayload<SchemaWithId<TContext["description"]>>, context: TContext) => Promise<Result.Error<{
4
- readonly code: ACError.ResourceNotFound;
5
- } & {
6
- httpStatus: HTTPStatus.NotFound;
7
- }> | {
3
+ export type RemoveOptions = {
4
+ bypassSecurity?: boolean;
5
+ };
6
+ export declare const remove: <TContext extends Context>(payload: RemovePayload<SchemaWithId<TContext["description"]>>, context: TContext, options?: RemoveOptions) => Promise<{
8
7
  readonly _tag: "Result";
9
8
  readonly error: undefined;
10
9
  readonly result: import("mongodb").WithId<Omit<import("@aeriajs/types").PackReferences<SchemaWithId<import("@aeriajs/types").Description>>, "_id">> | null;
11
- }>;
10
+ } | Result.Error<{
11
+ readonly code: ACError.ResourceNotFound;
12
+ } & {
13
+ httpStatus: HTTPStatus.NotFound;
14
+ }>>;
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.remove = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
5
  const common_1 = require("@aeriajs/common");
6
- const index_js_1 = require("../../collection/index.js");
7
- const remove = async (payload, context) => {
6
+ const security_1 = require("@aeriajs/security");
7
+ const index_js_1 = require("../collection/index.js");
8
+ const internalRemove = async (payload, context) => {
8
9
  if (!payload.filters._id) {
9
10
  return context.error(types_1.HTTPStatus.NotFound, {
10
11
  code: types_1.ACError.ResourceNotFound,
@@ -22,4 +23,17 @@ const remove = async (payload, context) => {
22
23
  await (0, index_js_1.cascadingRemove)(target, context);
23
24
  return types_1.Result.result(await context.collection.model.findOneAndDelete(filters));
24
25
  };
26
+ const remove = async (payload, context, options = {}) => {
27
+ if (options.bypassSecurity) {
28
+ return internalRemove(payload, context);
29
+ }
30
+ const security = (0, security_1.useSecurity)(context);
31
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
32
+ if (error) {
33
+ switch (error) {
34
+ case types_1.ACError.InvalidLimit: throw new Error;
35
+ }
36
+ }
37
+ return internalRemove(securedPayload, context);
38
+ };
25
39
  exports.remove = remove;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  import { Result, HTTPStatus, ACError } from "@aeriajs/types";
3
3
  import { throwIfError } from "@aeriajs/common";
4
- import { traverseDocument, cascadingRemove } from "../../collection/index.mjs";
5
- export const remove = async (payload, context) => {
4
+ import { useSecurity } from "@aeriajs/security";
5
+ import { traverseDocument, cascadingRemove } from "../collection/index.mjs";
6
+ const internalRemove = async (payload, context) => {
6
7
  if (!payload.filters._id) {
7
8
  return context.error(HTTPStatus.NotFound, {
8
9
  code: ACError.ResourceNotFound
@@ -20,3 +21,17 @@ export const remove = async (payload, context) => {
20
21
  await cascadingRemove(target, context);
21
22
  return Result.result(await context.collection.model.findOneAndDelete(filters));
22
23
  };
24
+ export const remove = async (payload, context, options = {}) => {
25
+ if (options.bypassSecurity) {
26
+ return internalRemove(payload, context);
27
+ }
28
+ const security = useSecurity(context);
29
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
30
+ if (error) {
31
+ switch (error) {
32
+ case ACError.InvalidLimit:
33
+ throw new Error();
34
+ }
35
+ }
36
+ return internalRemove(securedPayload, context);
37
+ };
@@ -1,5 +1,8 @@
1
1
  import type { Context, RemoveAllPayload } from '@aeriajs/types';
2
- export declare const removeAll: <TContext extends Context>(payload: RemoveAllPayload, context: TContext) => Promise<{
2
+ export type RemoveAllOptions = {
3
+ bypassSecurity?: boolean;
4
+ };
5
+ export declare const removeAll: <TContext extends Context>(payload: RemoveAllPayload, context: TContext, options?: RemoveAllOptions) => Promise<{
3
6
  readonly _tag: "Result";
4
7
  readonly error: undefined;
5
8
  readonly result: import("mongodb").DeleteResult;
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeAll = void 0;
4
4
  const types_1 = require("@aeriajs/types");
5
5
  const common_1 = require("@aeriajs/common");
6
- const index_js_1 = require("../../collection/index.js");
7
- const removeAll = async (payload, context) => {
6
+ const security_1 = require("@aeriajs/security");
7
+ const index_js_1 = require("../collection/index.js");
8
+ const internalRemoveAll = async (payload, context) => {
8
9
  const filtersWithId = {
9
10
  ...payload.filters,
10
11
  _id: {
@@ -21,4 +22,17 @@ const removeAll = async (payload, context) => {
21
22
  }
22
23
  return types_1.Result.result(await context.collection.model.deleteMany(filters));
23
24
  };
25
+ const removeAll = async (payload, context, options = {}) => {
26
+ if (options.bypassSecurity) {
27
+ return internalRemoveAll(payload, context);
28
+ }
29
+ const security = (0, security_1.useSecurity)(context);
30
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
31
+ if (error) {
32
+ switch (error) {
33
+ case types_1.ACError.InvalidLimit: throw new Error;
34
+ }
35
+ }
36
+ return internalRemoveAll(securedPayload, context);
37
+ };
24
38
  exports.removeAll = removeAll;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ import { Result, ACError } from "@aeriajs/types";
3
+ import { throwIfError } from "@aeriajs/common";
4
+ import { useSecurity } from "@aeriajs/security";
5
+ import { traverseDocument, cascadingRemove } from "../collection/index.mjs";
6
+ const internalRemoveAll = async (payload, context) => {
7
+ const filtersWithId = {
8
+ ...payload.filters,
9
+ _id: {
10
+ $in: payload.filters
11
+ }
12
+ };
13
+ const filters = throwIfError(await traverseDocument(filtersWithId, context.description, {
14
+ autoCast: true
15
+ }));
16
+ const it = context.collection.model.find(filters);
17
+ let doc;
18
+ while (doc = await it.next()) {
19
+ await cascadingRemove(doc, context);
20
+ }
21
+ return Result.result(await context.collection.model.deleteMany(filters));
22
+ };
23
+ export const removeAll = async (payload, context, options = {}) => {
24
+ if (options.bypassSecurity) {
25
+ return internalRemoveAll(payload, context);
26
+ }
27
+ const security = useSecurity(context);
28
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
29
+ if (error) {
30
+ switch (error) {
31
+ case ACError.InvalidLimit:
32
+ throw new Error();
33
+ }
34
+ }
35
+ return internalRemoveAll(securedPayload, context);
36
+ };
@@ -1,5 +1,8 @@
1
1
  import type { Context, RemoveFilePayload } from '@aeriajs/types';
2
- export declare const removeFile: <TContext extends Context>(payload: RemoveFilePayload, context: TContext) => Promise<{
2
+ export type RemoveFileOptions = {
3
+ bypassSecurity?: boolean;
4
+ };
5
+ export declare const removeFile: <TContext extends Context>(payload: RemoveFilePayload, context: TContext, options?: RemoveFileOptions) => Promise<{
3
6
  readonly _tag: "Result";
4
7
  readonly error: undefined;
5
8
  readonly result: any;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeFile = void 0;
4
+ const types_1 = require("@aeriajs/types");
5
+ const security_1 = require("@aeriajs/security");
6
+ const internalRemoveFile = async (payload, context) => {
7
+ const { propertyName, parentId, ...props } = payload;
8
+ const doc = await context.collections.file.functions.remove(props);
9
+ return types_1.Result.result(doc);
10
+ };
11
+ const removeFile = async (payload, context, options = {}) => {
12
+ if (options.bypassSecurity) {
13
+ return internalRemoveFile(payload, context);
14
+ }
15
+ const security = (0, security_1.useSecurity)(context);
16
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
17
+ if (error) {
18
+ switch (error) {
19
+ case types_1.ACError.InvalidLimit: throw new Error;
20
+ }
21
+ }
22
+ return internalRemoveFile(securedPayload, context);
23
+ };
24
+ exports.removeFile = removeFile;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ import { Result, ACError } from "@aeriajs/types";
3
+ import { useSecurity } from "@aeriajs/security";
4
+ const internalRemoveFile = async (payload, context) => {
5
+ const {
6
+ propertyName,
7
+ parentId,
8
+ ...props
9
+ } = payload;
10
+ const doc = await context.collections.file.functions.remove(props);
11
+ return Result.result(doc);
12
+ };
13
+ export const removeFile = async (payload, context, options = {}) => {
14
+ if (options.bypassSecurity) {
15
+ return internalRemoveFile(payload, context);
16
+ }
17
+ const security = useSecurity(context);
18
+ const { error, result: securedPayload } = await security.secureReadPayload(payload);
19
+ if (error) {
20
+ switch (error) {
21
+ case ACError.InvalidLimit:
22
+ throw new Error();
23
+ }
24
+ }
25
+ return internalRemoveFile(securedPayload, context);
26
+ };
@@ -66,6 +66,7 @@ const upload = async (_props, context) => {
66
66
  }
67
67
  const { error: headersError } = (0, validation_1.validate)(context.request.headers, {
68
68
  type: 'object',
69
+ additionalProperties: true,
69
70
  properties: {
70
71
  'x-stream-request': {
71
72
  const: '1',
@@ -74,8 +75,6 @@ const upload = async (_props, context) => {
74
75
  type: 'string',
75
76
  },
76
77
  },
77
- }, {
78
- extraneous: true,
79
78
  });
80
79
  if (headersError) {
81
80
  return context.error(types_1.HTTPStatus.BadRequest, {
@@ -35,6 +35,7 @@ export const upload = async (_props, context) => {
35
35
  }
36
36
  const { error: headersError } = validate(context.request.headers, {
37
37
  type: "object",
38
+ additionalProperties: true,
38
39
  properties: {
39
40
  "x-stream-request": {
40
41
  const: "1"
@@ -43,8 +44,6 @@ export const upload = async (_props, context) => {
43
44
  type: "string"
44
45
  }
45
46
  }
46
- }, {
47
- extraneous: true
48
47
  });
49
48
  if (headersError) {
50
49
  return context.error(HTTPStatus.BadRequest, {
package/dist/index.d.ts CHANGED
@@ -8,6 +8,5 @@ export * from './endpoints.js';
8
8
  export * from './token.js';
9
9
  export * from './use.js';
10
10
  export * from './functions/index.js';
11
- export * from './functions/builtin/index.js';
12
- export * as functions from './functions/builtin/index.js';
11
+ export * as functions from './functions/index.js';
13
12
  export { ObjectId, } from 'mongodb';
package/dist/index.js CHANGED
@@ -37,7 +37,6 @@ __exportStar(require("./endpoints.js"), exports);
37
37
  __exportStar(require("./token.js"), exports);
38
38
  __exportStar(require("./use.js"), exports);
39
39
  __exportStar(require("./functions/index.js"), exports);
40
- __exportStar(require("./functions/builtin/index.js"), exports);
41
- exports.functions = __importStar(require("./functions/builtin/index.js"));
40
+ exports.functions = __importStar(require("./functions/index.js"));
42
41
  var mongodb_1 = require("mongodb");
43
42
  Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return mongodb_1.ObjectId; } });
package/dist/index.mjs CHANGED
@@ -9,8 +9,7 @@ export * from "./endpoints.mjs";
9
9
  export * from "./token.mjs";
10
10
  export * from "./use.mjs";
11
11
  export * from "./functions/index.mjs";
12
- export * from "./functions/builtin/index.mjs";
13
- export * as functions from "./functions/builtin/index.mjs";
12
+ export * as functions from "./functions/index.mjs";
14
13
  export {
15
14
  ObjectId
16
15
  } from "mongodb";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/core",
3
- "version": "0.0.136",
3
+ "version": "0.0.138",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -41,13 +41,13 @@
41
41
  "mongodb-memory-server": "^9.2.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@aeriajs/builtins": "^0.0.136",
45
- "@aeriajs/common": "^0.0.85",
46
- "@aeriajs/entrypoint": "^0.0.87",
47
- "@aeriajs/http": "^0.0.96",
48
- "@aeriajs/security": "^0.0.136",
49
- "@aeriajs/types": "^0.0.73",
50
- "@aeriajs/validation": "^0.0.88"
44
+ "@aeriajs/builtins": "^0.0.138",
45
+ "@aeriajs/common": "^0.0.87",
46
+ "@aeriajs/entrypoint": "^0.0.89",
47
+ "@aeriajs/http": "^0.0.98",
48
+ "@aeriajs/security": "^0.0.138",
49
+ "@aeriajs/types": "^0.0.75",
50
+ "@aeriajs/validation": "^0.0.90"
51
51
  },
52
52
  "dependencies": {
53
53
  "mongodb": "^6.5.0",
@@ -1,33 +0,0 @@
1
- "use strict";
2
- import { useSecurity } from "@aeriajs/security";
3
- import { Result } from "@aeriajs/types";
4
- import { throwIfError } from "@aeriajs/common";
5
- import { traverseDocument } from "../../collection/index.mjs";
6
- export const count = async (payload, context) => {
7
- const security = useSecurity(context);
8
- const { filters } = throwIfError(await security.beforeRead(payload));
9
- const { $text, ...filtersRest } = filters;
10
- const traversedFilters = throwIfError(await traverseDocument(filtersRest, context.description, {
11
- autoCast: true,
12
- allowOperators: true
13
- }));
14
- if ($text) {
15
- const pipeline = [];
16
- if ($text) {
17
- pipeline.push({
18
- $match: {
19
- $text
20
- }
21
- });
22
- }
23
- pipeline.push({
24
- $match: traversedFilters
25
- });
26
- pipeline.push({
27
- $count: "total"
28
- });
29
- const result = await context.collection.model.aggregate(pipeline).next();
30
- return Result.result(result ? result.total : 0);
31
- }
32
- return Result.result(await context.collection.model.countDocuments(traversedFilters));
33
- };
@@ -1,9 +0,0 @@
1
- import type { Context, SchemaWithId, GetAllPayload } from '@aeriajs/types';
2
- export type GetAllOptions = {
3
- bypassSecurity?: boolean;
4
- };
5
- export declare const getAll: <TContext extends Context>(_payload: GetAllPayload<SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: GetAllOptions) => Promise<{
6
- readonly _tag: "Result";
7
- readonly error: undefined;
8
- readonly result: SchemaWithId<TContext["description"]>[];
9
- }>;
@@ -1,8 +0,0 @@
1
- export * from './count.js';
2
- export * from './get.js';
3
- export * from './getAll.js';
4
- export * from './insert.js';
5
- export * from './remove.js';
6
- export * from './removeAll.js';
7
- export * from './removeFile.js';
8
- export * from './upload.js';
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./count.js"), exports);
18
- __exportStar(require("./get.js"), exports);
19
- __exportStar(require("./getAll.js"), exports);
20
- __exportStar(require("./insert.js"), exports);
21
- __exportStar(require("./remove.js"), exports);
22
- __exportStar(require("./removeAll.js"), exports);
23
- __exportStar(require("./removeFile.js"), exports);
24
- __exportStar(require("./upload.js"), exports);
@@ -1,9 +0,0 @@
1
- "use strict";
2
- export * from "./count.mjs";
3
- export * from "./get.mjs";
4
- export * from "./getAll.mjs";
5
- export * from "./insert.mjs";
6
- export * from "./remove.mjs";
7
- export * from "./removeAll.mjs";
8
- export * from "./removeFile.mjs";
9
- export * from "./upload.mjs";
@@ -1,21 +0,0 @@
1
- "use strict";
2
- import { Result } from "@aeriajs/types";
3
- import { throwIfError } from "@aeriajs/common";
4
- import { traverseDocument, cascadingRemove } from "../../collection/index.mjs";
5
- export const removeAll = async (payload, context) => {
6
- const filtersWithId = {
7
- ...payload.filters,
8
- _id: {
9
- $in: payload.filters
10
- }
11
- };
12
- const filters = throwIfError(await traverseDocument(filtersWithId, context.description, {
13
- autoCast: true
14
- }));
15
- const it = context.collection.model.find(filters);
16
- let doc;
17
- while (doc = await it.next()) {
18
- await cascadingRemove(doc, context);
19
- }
20
- return Result.result(await context.collection.model.deleteMany(filters));
21
- };
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeFile = void 0;
4
- const security_1 = require("@aeriajs/security");
5
- const types_1 = require("@aeriajs/types");
6
- const removeFile = async (payload, context) => {
7
- const { propertyName, parentId, ...props } = payload;
8
- await (0, security_1.checkImmutability)({
9
- propertyName,
10
- parentId,
11
- childId: props.filters._id,
12
- payload: props,
13
- }, context);
14
- const doc = await context.collections.file.functions.remove(props);
15
- return types_1.Result.result(doc);
16
- };
17
- exports.removeFile = removeFile;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- import { checkImmutability } from "@aeriajs/security";
3
- import { Result } from "@aeriajs/types";
4
- export const removeFile = async (payload, context) => {
5
- const {
6
- propertyName,
7
- parentId,
8
- ...props
9
- } = payload;
10
- await checkImmutability({
11
- propertyName,
12
- parentId,
13
- childId: props.filters._id,
14
- payload: props
15
- }, context);
16
- const doc = await context.collections.file.functions.remove(props);
17
- return Result.result(doc);
18
- };
File without changes