@aeriajs/entrypoint 0.0.41 → 0.0.43

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.d.ts CHANGED
@@ -5,3 +5,4 @@ export declare const getCollections: () => Promise<Record<string, Collection | (
5
5
  export declare const getCollection: (collectionName: string) => Promise<Collection | undefined>;
6
6
  export declare const getRouter: () => Promise<any>;
7
7
  export declare const getConfig: () => Promise<ApiConfig>;
8
+ export declare const getAvailableRoles: () => Promise<string[]>;
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConfig = exports.getRouter = exports.getCollection = exports.getCollections = exports.getEntrypoint = exports.getEntrypointPath = void 0;
3
+ exports.getAvailableRoles = exports.getConfig = exports.getRouter = exports.getCollection = exports.getCollections = exports.getEntrypoint = exports.getEntrypointPath = void 0;
4
4
  const path = require("path");
5
5
  const fs = require("fs/promises");
6
6
  const common_1 = require("@aeriajs/common");
7
7
  let collectionsMemo;
8
+ let availableRolesMemo;
8
9
  const collectionMemo = {};
9
10
  const getEntrypointPath = async () => {
10
11
  if (process.env.AERIA_MAIN) {
@@ -41,9 +42,6 @@ const getCollection = async (collectionName) => {
41
42
  }
42
43
  const collections = await (0, exports.getCollections)();
43
44
  const candidate = collections[collectionName];
44
- if (!candidate) {
45
- return;
46
- }
47
45
  const collection = typeof candidate === 'function'
48
46
  ? candidate()
49
47
  : candidate;
@@ -63,3 +61,28 @@ const getConfig = async () => {
63
61
  : {};
64
62
  };
65
63
  exports.getConfig = getConfig;
64
+ const getAvailableRoles = async () => {
65
+ if (availableRolesMemo) {
66
+ return availableRolesMemo;
67
+ }
68
+ const collections = await (0, exports.getCollections)();
69
+ const availableRoles = [];
70
+ for (const collectionName in collections) {
71
+ const candidate = collections[collectionName];
72
+ const collection = typeof candidate === 'function'
73
+ ? candidate()
74
+ : candidate;
75
+ if (!collection.exposedFunctions) {
76
+ continue;
77
+ }
78
+ for (const fnName in collection.exposedFunctions) {
79
+ const exposed = collection.exposedFunctions[fnName];
80
+ if (Array.isArray(exposed)) {
81
+ availableRoles.push(...exposed);
82
+ }
83
+ }
84
+ }
85
+ availableRolesMemo = Array.from(new Set(availableRoles));
86
+ return availableRolesMemo;
87
+ };
88
+ exports.getAvailableRoles = getAvailableRoles;
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import * as path from "path";
3
3
  import * as fs from "fs/promises";
4
4
  import { dynamicImport } from "@aeriajs/common";
5
5
  let collectionsMemo;
6
+ let availableRolesMemo;
6
7
  const collectionMemo = {};
7
8
  export const getEntrypointPath = async () => {
8
9
  if (process.env.AERIA_MAIN) {
@@ -34,9 +35,6 @@ export const getCollection = async (collectionName) => {
34
35
  }
35
36
  const collections = await getCollections();
36
37
  const candidate = collections[collectionName];
37
- if (!candidate) {
38
- return;
39
- }
40
38
  const collection = typeof candidate === "function" ? candidate() : candidate;
41
39
  collectionsMemo[collectionName] = candidate;
42
40
  return collection;
@@ -49,3 +47,25 @@ export const getConfig = async () => {
49
47
  const entrypoint = await getEntrypoint();
50
48
  return entrypoint.default ? entrypoint.default.options.config : {};
51
49
  };
50
+ export const getAvailableRoles = async () => {
51
+ if (availableRolesMemo) {
52
+ return availableRolesMemo;
53
+ }
54
+ const collections = await getCollections();
55
+ const availableRoles = [];
56
+ for (const collectionName in collections) {
57
+ const candidate = collections[collectionName];
58
+ const collection = typeof candidate === "function" ? candidate() : candidate;
59
+ if (!collection.exposedFunctions) {
60
+ continue;
61
+ }
62
+ for (const fnName in collection.exposedFunctions) {
63
+ const exposed = collection.exposedFunctions[fnName];
64
+ if (Array.isArray(exposed)) {
65
+ availableRoles.push(...exposed);
66
+ }
67
+ }
68
+ }
69
+ availableRolesMemo = Array.from(new Set(availableRoles));
70
+ return availableRolesMemo;
71
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/entrypoint",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,8 +26,8 @@
26
26
  "@aeriajs/types": "link:../types"
27
27
  },
28
28
  "peerDependencies": {
29
- "@aeriajs/common": "^0.0.41",
30
- "@aeriajs/types": "^0.0.38"
29
+ "@aeriajs/common": "^0.0.43",
30
+ "@aeriajs/types": "^0.0.40"
31
31
  },
32
32
  "scripts": {
33
33
  "test": "echo skipping",