@aeriajs/core 0.0.248 → 0.0.249

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.
@@ -1,5 +1,4 @@
1
- import type { WithId } from 'mongodb';
2
- import type { Context, Description, Pagination, GetAllPayload, CountReturnType } from '@aeriajs/types';
3
- export declare const makePagination: <T>(payload: GetAllPayload<WithId<T>>, documents: unknown[], context: Context<Description, {
1
+ import type { Context, SchemaWithId, Description, Pagination, GetAllPayload, CountReturnType } from '@aeriajs/types';
2
+ export declare const makePagination: <TDescription extends Description>(payload: GetAllPayload<SchemaWithId<TDescription>>, documents: unknown[], context: Context<Description, {
4
3
  count?: (...args: unknown[]) => Promise<CountReturnType>;
5
4
  }>) => Promise<Pagination>;
package/dist/context.js CHANGED
@@ -65,6 +65,10 @@ const indepthCollection = (collectionName, collections, parentContext) => {
65
65
  });
66
66
  return {
67
67
  ...collection,
68
+ context: () => (0, exports.createContext)({
69
+ parentContext,
70
+ collectionName,
71
+ }),
68
72
  functions: proxiedFunctions,
69
73
  originalFunctions: collection.functions,
70
74
  model: (0, database_js_1.getDatabaseCollection)(collectionName),
package/dist/context.mjs CHANGED
@@ -28,6 +28,10 @@ const indepthCollection = (collectionName, collections, parentContext) => {
28
28
  });
29
29
  return {
30
30
  ...collection,
31
+ context: () => createContext({
32
+ parentContext,
33
+ collectionName
34
+ }),
31
35
  functions: proxiedFunctions,
32
36
  originalFunctions: collection.functions,
33
37
  model: getDatabaseCollection(collectionName)
@@ -2,6 +2,7 @@ export * from './count.js';
2
2
  export * from './get.js';
3
3
  export * from './getAll.js';
4
4
  export * from './insert.js';
5
+ export * from './paginatedGetAll.js';
5
6
  export * from './remove.js';
6
7
  export * from './removeAll.js';
7
8
  export * from './removeFile.js';
@@ -19,6 +19,7 @@ __exportStar(require("./count.js"), exports);
19
19
  __exportStar(require("./get.js"), exports);
20
20
  __exportStar(require("./getAll.js"), exports);
21
21
  __exportStar(require("./insert.js"), exports);
22
+ __exportStar(require("./paginatedGetAll.js"), exports);
22
23
  __exportStar(require("./remove.js"), exports);
23
24
  __exportStar(require("./removeAll.js"), exports);
24
25
  __exportStar(require("./removeFile.js"), exports);
@@ -3,6 +3,7 @@ export * from "./count.mjs";
3
3
  export * from "./get.mjs";
4
4
  export * from "./getAll.mjs";
5
5
  export * from "./insert.mjs";
6
+ export * from "./paginatedGetAll.mjs";
6
7
  export * from "./remove.mjs";
7
8
  export * from "./removeAll.mjs";
8
9
  export * from "./removeFile.mjs";
@@ -0,0 +1,53 @@
1
+ import { Description, GetAllPayload, SchemaWithId, Context, CountReturnType } from '@aeriajs/types';
2
+ export declare const paginatedGetAll: <TDescription extends Description, TFunctions>(payload: GetAllPayload<SchemaWithId<TDescription>>, context: Context<TDescription, TFunctions & {
3
+ count?: (...args: unknown[]) => Promise<CountReturnType>;
4
+ }>) => Promise<{
5
+ readonly _tag: "Error";
6
+ readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
7
+ readonly httpStatus: {
8
+ readonly enum: [403];
9
+ };
10
+ readonly code: {
11
+ readonly enum: ["OWNERSHIP_ERROR", "INSECURE_OPERATOR", "INVALID_LIMIT"];
12
+ };
13
+ readonly message: {
14
+ readonly type: "string";
15
+ };
16
+ readonly details: {
17
+ readonly type: "object";
18
+ readonly additionalProperties: true;
19
+ };
20
+ }>> & {
21
+ code: "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "INVALID_LIMIT";
22
+ httpStatus: 403;
23
+ message: string;
24
+ details: any;
25
+ }, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
26
+ readonly httpStatus: {
27
+ readonly enum: [403];
28
+ };
29
+ readonly code: {
30
+ readonly enum: ["OWNERSHIP_ERROR", "INSECURE_OPERATOR", "INVALID_LIMIT"];
31
+ };
32
+ readonly message: {
33
+ readonly type: "string";
34
+ };
35
+ readonly details: {
36
+ readonly type: "object";
37
+ readonly additionalProperties: true;
38
+ };
39
+ }>> & {
40
+ code: "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "INVALID_LIMIT";
41
+ httpStatus: 403;
42
+ message: string;
43
+ details: any;
44
+ }, never>>;
45
+ readonly result: undefined;
46
+ } | {
47
+ readonly _tag: "Result";
48
+ readonly error: undefined;
49
+ readonly result: {
50
+ readonly data: SchemaWithId<TDescription>[];
51
+ readonly pagination: import("@aeriajs/types").Pagination;
52
+ };
53
+ }>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paginatedGetAll = void 0;
4
+ const types_1 = require("@aeriajs/types");
5
+ const makePagination_js_1 = require("../collection/makePagination.js");
6
+ const getAll_js_1 = require("./getAll.js");
7
+ const paginatedGetAll = async (payload, context) => {
8
+ const { error, result } = await (0, getAll_js_1.getAll)(payload, context);
9
+ if (error) {
10
+ return types_1.Result.error(error);
11
+ }
12
+ return types_1.Result.result({
13
+ data: result,
14
+ pagination: await (0, makePagination_js_1.makePagination)(payload, result, context),
15
+ });
16
+ };
17
+ exports.paginatedGetAll = paginatedGetAll;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ import { Result } from "@aeriajs/types";
3
+ import { makePagination } from "../collection/makePagination.mjs";
4
+ import { getAll } from "./getAll.mjs";
5
+ export const paginatedGetAll = async (payload, context) => {
6
+ const { error, result } = await getAll(payload, context);
7
+ if (error) {
8
+ return Result.error(error);
9
+ }
10
+ return Result.result({
11
+ data: result,
12
+ pagination: await makePagination(payload, result, context)
13
+ });
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/core",
3
- "version": "0.0.248",
3
+ "version": "0.0.249",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "aeriaMain": "tests/fixtures/aeriaMain.js",
@@ -42,13 +42,13 @@
42
42
  "mongodb-memory-server": "^9.2.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@aeriajs/builtins": "^0.0.248",
46
- "@aeriajs/common": "^0.0.137",
47
- "@aeriajs/entrypoint": "^0.0.141",
48
- "@aeriajs/http": "^0.0.166",
49
- "@aeriajs/security": "^0.0.248",
50
- "@aeriajs/types": "^0.0.119",
51
- "@aeriajs/validation": "^0.0.153"
45
+ "@aeriajs/builtins": "^0.0.249",
46
+ "@aeriajs/common": "^0.0.138",
47
+ "@aeriajs/entrypoint": "^0.0.142",
48
+ "@aeriajs/http": "^0.0.167",
49
+ "@aeriajs/security": "^0.0.249",
50
+ "@aeriajs/types": "^0.0.120",
51
+ "@aeriajs/validation": "^0.0.154"
52
52
  },
53
53
  "dependencies": {
54
54
  "mongodb": "^6.5.0",