@prosopo/user-access-policy 3.12.8 → 3.12.9

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 (84) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +45 -41
  2. package/.turbo/turbo-build$colon$tsc.log +14 -14
  3. package/.turbo/turbo-build.log +46 -42
  4. package/CHANGELOG.md +18 -0
  5. package/dist/.export.js +7 -21
  6. package/dist/_virtual/_rolldown/runtime.js +3 -0
  7. package/dist/api/.export.js +2 -9
  8. package/dist/api/accessRulesApiClient.js +1 -1
  9. package/dist/api/delete/.export.js +2 -1
  10. package/dist/api/delete/deleteAllRules.js +22 -24
  11. package/dist/api/delete/deleteRuleGroups.js +39 -51
  12. package/dist/api/delete/deleteRules.js +37 -41
  13. package/dist/api/read/.export.js +2 -1
  14. package/dist/api/read/fetchRules.js +34 -42
  15. package/dist/api/read/findRuleIds.js +35 -48
  16. package/dist/api/read/getMissingIds.js +36 -40
  17. package/dist/api/ruleApiRoutes.js +62 -120
  18. package/dist/api/rulesApiClient.js +51 -87
  19. package/dist/api/write/.export.js +2 -1
  20. package/dist/api/write/insertRules.js +84 -102
  21. package/dist/api/write/rehashRules.js +48 -56
  22. package/dist/cjs/.export.cjs +21 -23
  23. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  24. package/dist/cjs/api/.export.cjs +6 -10
  25. package/dist/cjs/api/accessRulesApiClient.cjs +0 -0
  26. package/dist/cjs/api/delete/.export.cjs +0 -1
  27. package/dist/cjs/api/delete/deleteAllRules.cjs +22 -24
  28. package/dist/cjs/api/delete/deleteRuleGroups.cjs +39 -51
  29. package/dist/cjs/api/delete/deleteRules.cjs +41 -42
  30. package/dist/cjs/api/read/.export.cjs +0 -1
  31. package/dist/cjs/api/read/fetchRules.cjs +34 -41
  32. package/dist/cjs/api/read/findRuleIds.cjs +37 -48
  33. package/dist/cjs/api/read/getMissingIds.cjs +36 -39
  34. package/dist/cjs/api/ruleApiRoutes.cjs +69 -125
  35. package/dist/cjs/api/rulesApiClient.cjs +54 -90
  36. package/dist/cjs/api/write/.export.cjs +0 -1
  37. package/dist/cjs/api/write/insertRules.cjs +85 -103
  38. package/dist/cjs/api/write/rehashRules.cjs +48 -56
  39. package/dist/cjs/classifyOs.cjs +46 -26
  40. package/dist/cjs/mongoose/.export.cjs +2 -3
  41. package/dist/cjs/mongoose/mongooseRuleSchema.cjs +97 -36
  42. package/dist/cjs/redis/.export.cjs +4 -5
  43. package/dist/cjs/redis/reader/redisAggregate.cjs +59 -84
  44. package/dist/cjs/redis/reader/redisRulesQuery.cjs +74 -116
  45. package/dist/cjs/redis/reader/redisRulesReader.cjs +322 -503
  46. package/dist/cjs/redis/reader/redisRulesSplitQuery.cjs +94 -72
  47. package/dist/cjs/redis/redisClient.cjs +53 -58
  48. package/dist/cjs/redis/redisRuleIndex.cjs +93 -49
  49. package/dist/cjs/redis/redisRulesStorage.cjs +21 -30
  50. package/dist/cjs/redis/redisRulesWriter.cjs +86 -112
  51. package/dist/cjs/rule.cjs +8 -7
  52. package/dist/cjs/ruleInput/.export.cjs +7 -8
  53. package/dist/cjs/ruleInput/policyInput.cjs +35 -58
  54. package/dist/cjs/ruleInput/ruleInput.cjs +37 -42
  55. package/dist/cjs/ruleInput/userScopeInput.cjs +47 -55
  56. package/dist/cjs/ruleRecord.cjs +15 -22
  57. package/dist/cjs/rulesStorage.cjs +7 -6
  58. package/dist/cjs/transformRule.cjs +36 -70
  59. package/dist/classifyOs.js +48 -29
  60. package/dist/mongoose/.export.js +2 -3
  61. package/dist/mongoose/mongooseRuleSchema.js +99 -38
  62. package/dist/redis/.export.js +3 -5
  63. package/dist/redis/reader/redisAggregate.js +60 -86
  64. package/dist/redis/reader/redisRulesQuery.js +75 -118
  65. package/dist/redis/reader/redisRulesReader.js +312 -487
  66. package/dist/redis/reader/redisRulesSplitQuery.js +96 -75
  67. package/dist/redis/redisClient.js +54 -62
  68. package/dist/redis/redisRuleIndex.js +93 -58
  69. package/dist/redis/redisRulesStorage.js +21 -30
  70. package/dist/redis/redisRulesWriter.js +82 -113
  71. package/dist/rule.js +10 -10
  72. package/dist/ruleInput/.export.js +3 -7
  73. package/dist/ruleInput/policyInput.js +35 -61
  74. package/dist/ruleInput/ruleInput.js +36 -44
  75. package/dist/ruleInput/userScopeInput.js +44 -55
  76. package/dist/ruleRecord.js +17 -27
  77. package/dist/rulesStorage.js +9 -8
  78. package/dist/tests/redis/redisRulesStorage.integration.test.js +1 -3
  79. package/dist/tests/redis/redisRulesStorage.integration.test.js.map +1 -1
  80. package/dist/transformRule.js +34 -73
  81. package/entries.ts +25 -6
  82. package/package.json +13 -12
  83. package/src/tests/redis/redisRulesStorage.integration.test.ts +191 -195
  84. package/tsconfig.tsbuildinfo +1 -1
@@ -1,44 +1,36 @@
1
- import { ApiEndpointResponseStatus } from "@prosopo/api-route";
2
- import { z } from "zod";
1
+ import "../../_virtual/_rolldown/runtime.js";
3
2
  import { ruleEntryInput } from "../../ruleInput/ruleInput.js";
4
- const fetchRulesResponse = z.object({
5
- ruleEntries: ruleEntryInput.array()
6
- });
7
- class FetchRulesEndpoint {
8
- constructor(accessRulesStorage, logger) {
9
- this.accessRulesStorage = accessRulesStorage;
10
- this.logger = logger;
11
- }
12
- getRequestArgsSchema() {
13
- return z.object({
14
- ids: z.string().array()
15
- });
16
- }
17
- async processRequest(args, logger) {
18
- const log = logger ?? this.logger;
19
- const ruleEntries = await this.accessRulesStorage.fetchRules(args.ids);
20
- log.info(() => ({
21
- msg: "Endpoint fetched rules",
22
- data: {
23
- requestedCount: args.ids.length,
24
- foundCount: ruleEntries.length
25
- }
26
- }));
27
- log.debug(() => ({
28
- msg: "Fetched rule details",
29
- data: {
30
- ruleEntries
31
- }
32
- }));
33
- return {
34
- status: ApiEndpointResponseStatus.SUCCESS,
35
- data: {
36
- ruleEntries
37
- }
38
- };
39
- }
40
- }
41
- export {
42
- FetchRulesEndpoint,
43
- fetchRulesResponse
3
+ import { z } from "zod";
4
+ import { ApiEndpointResponseStatus } from "@prosopo/api-route";
5
+ //#region src/api/read/fetchRules.ts
6
+ var fetchRulesResponse = z.object({ ruleEntries: ruleEntryInput.array() });
7
+ var FetchRulesEndpoint = class {
8
+ constructor(accessRulesStorage, logger) {
9
+ this.accessRulesStorage = accessRulesStorage;
10
+ this.logger = logger;
11
+ }
12
+ getRequestArgsSchema() {
13
+ return z.object({ ids: z.string().array() });
14
+ }
15
+ async processRequest(args, logger) {
16
+ const log = logger ?? this.logger;
17
+ const ruleEntries = await this.accessRulesStorage.fetchRules(args.ids);
18
+ log.info(() => ({
19
+ msg: "Endpoint fetched rules",
20
+ data: {
21
+ requestedCount: args.ids.length,
22
+ foundCount: ruleEntries.length
23
+ }
24
+ }));
25
+ log.debug(() => ({
26
+ msg: "Fetched rule details",
27
+ data: { ruleEntries }
28
+ }));
29
+ return {
30
+ status: ApiEndpointResponseStatus.SUCCESS,
31
+ data: { ruleEntries }
32
+ };
33
+ }
44
34
  };
35
+ //#endregion
36
+ export { FetchRulesEndpoint, fetchRulesResponse };
@@ -1,51 +1,38 @@
1
+ import "../../_virtual/_rolldown/runtime.js";
2
+ import { accessRulesFilterInput, getAccessRuleFiltersFromInput } from "../../ruleInput/ruleInput.js";
3
+ import { z } from "zod";
1
4
  import { ApiEndpointResponseStatus } from "@prosopo/api-route";
2
5
  import { executeBatchesSequentially } from "@prosopo/common";
3
- import { z } from "zod";
4
- import { accessRulesFilterInput, getAccessRuleFiltersFromInput } from "../../ruleInput/ruleInput.js";
5
- const ruleIdsResponse = z.object({
6
- ruleIds: z.string().array()
7
- });
8
- class FindRuleIdsEndpoint {
9
- constructor(accessRulesStorage, logger) {
10
- this.accessRulesStorage = accessRulesStorage;
11
- this.logger = logger;
12
- }
13
- getRequestArgsSchema() {
14
- return z.array(accessRulesFilterInput);
15
- }
16
- async processRequest(args, logger) {
17
- const log = logger ?? this.logger;
18
- const ruleIdBatches = await executeBatchesSequentially(
19
- args,
20
- async (rulesFilterInput) => {
21
- const ruleFilters = getAccessRuleFiltersFromInput(rulesFilterInput);
22
- const ruleIds2 = await executeBatchesSequentially(
23
- ruleFilters,
24
- (ruleFilter) => this.accessRulesStorage.findRuleIds(ruleFilter)
25
- );
26
- return ruleIds2.flat();
27
- }
28
- );
29
- const ruleIds = ruleIdBatches.flat();
30
- const uniqueRuleIds = [...new Set(ruleIds)];
31
- log.info(() => ({
32
- msg: "Endpoint found rules",
33
- data: {
34
- totalFoundCount: ruleIds.length,
35
- uniqueFoundCount: uniqueRuleIds.length,
36
- searchFilters: args,
37
- foundIds: uniqueRuleIds
38
- }
39
- }));
40
- return {
41
- status: ApiEndpointResponseStatus.SUCCESS,
42
- data: {
43
- ruleIds: uniqueRuleIds
44
- }
45
- };
46
- }
47
- }
48
- export {
49
- FindRuleIdsEndpoint,
50
- ruleIdsResponse
6
+ //#region src/api/read/findRuleIds.ts
7
+ var ruleIdsResponse = z.object({ ruleIds: z.string().array() });
8
+ var FindRuleIdsEndpoint = class {
9
+ constructor(accessRulesStorage, logger) {
10
+ this.accessRulesStorage = accessRulesStorage;
11
+ this.logger = logger;
12
+ }
13
+ getRequestArgsSchema() {
14
+ return z.array(accessRulesFilterInput);
15
+ }
16
+ async processRequest(args, logger) {
17
+ const log = logger ?? this.logger;
18
+ const ruleIds = (await executeBatchesSequentially(args, async (rulesFilterInput) => {
19
+ return (await executeBatchesSequentially(getAccessRuleFiltersFromInput(rulesFilterInput), (ruleFilter) => this.accessRulesStorage.findRuleIds(ruleFilter))).flat();
20
+ })).flat();
21
+ const uniqueRuleIds = [...new Set(ruleIds)];
22
+ log.info(() => ({
23
+ msg: "Endpoint found rules",
24
+ data: {
25
+ totalFoundCount: ruleIds.length,
26
+ uniqueFoundCount: uniqueRuleIds.length,
27
+ searchFilters: args,
28
+ foundIds: uniqueRuleIds
29
+ }
30
+ }));
31
+ return {
32
+ status: ApiEndpointResponseStatus.SUCCESS,
33
+ data: { ruleIds: uniqueRuleIds }
34
+ };
35
+ }
51
36
  };
37
+ //#endregion
38
+ export { FindRuleIdsEndpoint, ruleIdsResponse };
@@ -1,42 +1,38 @@
1
- import { ApiEndpointResponseStatus } from "@prosopo/api-route";
1
+ import "../../_virtual/_rolldown/runtime.js";
2
2
  import { z } from "zod";
3
- const missingIdsResponse = z.object({
4
- ids: z.string().array()
5
- });
6
- class GetMissingIdsEndpoint {
7
- constructor(accessRulesStorage, logger) {
8
- this.accessRulesStorage = accessRulesStorage;
9
- this.logger = logger;
10
- }
11
- getRequestArgsSchema() {
12
- return z.string().array();
13
- }
14
- async processRequest(args, logger) {
15
- const log = logger ?? this.logger;
16
- const missingIds = await this.accessRulesStorage.getMissingRuleIds(args);
17
- log.info(() => ({
18
- msg: "Endpoint checked missing ids",
19
- data: {
20
- idsToCheck: args.length,
21
- missingIds: missingIds.length
22
- }
23
- }));
24
- log.debug(() => ({
25
- msg: "Missing id details",
26
- data: {
27
- idsToCheck: args,
28
- missingIds
29
- }
30
- }));
31
- return {
32
- status: ApiEndpointResponseStatus.SUCCESS,
33
- data: {
34
- ids: missingIds
35
- }
36
- };
37
- }
38
- }
39
- export {
40
- GetMissingIdsEndpoint,
41
- missingIdsResponse
3
+ import { ApiEndpointResponseStatus } from "@prosopo/api-route";
4
+ //#region src/api/read/getMissingIds.ts
5
+ var missingIdsResponse = z.object({ ids: z.string().array() });
6
+ var GetMissingIdsEndpoint = class {
7
+ constructor(accessRulesStorage, logger) {
8
+ this.accessRulesStorage = accessRulesStorage;
9
+ this.logger = logger;
10
+ }
11
+ getRequestArgsSchema() {
12
+ return z.string().array();
13
+ }
14
+ async processRequest(args, logger) {
15
+ const log = logger ?? this.logger;
16
+ const missingIds = await this.accessRulesStorage.getMissingRuleIds(args);
17
+ log.info(() => ({
18
+ msg: "Endpoint checked missing ids",
19
+ data: {
20
+ idsToCheck: args.length,
21
+ missingIds: missingIds.length
22
+ }
23
+ }));
24
+ log.debug(() => ({
25
+ msg: "Missing id details",
26
+ data: {
27
+ idsToCheck: args,
28
+ missingIds
29
+ }
30
+ }));
31
+ return {
32
+ status: ApiEndpointResponseStatus.SUCCESS,
33
+ data: { ids: missingIds }
34
+ };
35
+ }
42
36
  };
37
+ //#endregion
38
+ export { GetMissingIdsEndpoint, missingIdsResponse };
@@ -1,3 +1,4 @@
1
+ import "../_virtual/_rolldown/runtime.js";
1
2
  import { FetchRulesEndpoint } from "./read/fetchRules.js";
2
3
  import { FindRuleIdsEndpoint } from "./read/findRuleIds.js";
3
4
  import { GetMissingIdsEndpoint } from "./read/getMissingIds.js";
@@ -6,126 +7,67 @@ import { DeleteAllRulesEndpoint } from "./delete/deleteAllRules.js";
6
7
  import { DeleteRuleGroupsEndpoint } from "./delete/deleteRuleGroups.js";
7
8
  import { DeleteRulesEndpoint } from "./delete/deleteRules.js";
8
9
  import { InsertRulesEndpoint } from "./write/insertRules.js";
9
- var accessRuleApiPaths = /* @__PURE__ */ ((accessRuleApiPaths2) => {
10
- accessRuleApiPaths2["DELETE_ALL"] = "/v1/prosopo/user-access-policy/rules/delete-all";
11
- accessRuleApiPaths2["DELETE_GROUPS"] = "/v1/prosopo/user-access-policy/rules/delete-groups";
12
- accessRuleApiPaths2["DELETE_MANY"] = "/v1/prosopo/user-access-policy/rules/delete-many";
13
- accessRuleApiPaths2["FETCH_MANY"] = "/v1/prosopo/user-access-policy/rules/fetch-many";
14
- accessRuleApiPaths2["FIND_IDS"] = "/v1/prosopo/user-access-policy/rules/find-ids";
15
- accessRuleApiPaths2["GET_MISSING_IDS"] = "/v1/prosopo/user-access-policy/rules/get-missing-ids";
16
- accessRuleApiPaths2["INSERT_MANY"] = "/v1/prosopo/user-access-policy/rules/insert-many";
17
- accessRuleApiPaths2["REHASH_ALL"] = "/v1/prosopo/user-access-policy/rules/rehash-all";
18
- return accessRuleApiPaths2;
19
- })(accessRuleApiPaths || {});
20
- class AccessRuleApiRoutes {
21
- constructor(accessRulesStorage, logger) {
22
- this.accessRulesStorage = accessRulesStorage;
23
- this.logger = logger;
24
- }
25
- getRoutes() {
26
- return {
27
- ...this.makeDeleteEndpoints(),
28
- ...this.makeReadEndpoints(),
29
- ...this.makeWriteEndpoints()
30
- };
31
- }
32
- makeDeleteEndpoints() {
33
- return {
34
- [
35
- "/v1/prosopo/user-access-policy/rules/delete-all"
36
- /* DELETE_ALL */
37
- ]: new DeleteAllRulesEndpoint(
38
- this.accessRulesStorage,
39
- this.logger
40
- ),
41
- [
42
- "/v1/prosopo/user-access-policy/rules/delete-groups"
43
- /* DELETE_GROUPS */
44
- ]: new DeleteRuleGroupsEndpoint(
45
- this.accessRulesStorage,
46
- this.logger
47
- ),
48
- [
49
- "/v1/prosopo/user-access-policy/rules/delete-many"
50
- /* DELETE_MANY */
51
- ]: new DeleteRulesEndpoint(
52
- this.accessRulesStorage,
53
- this.logger
54
- )
55
- };
56
- }
57
- makeReadEndpoints() {
58
- return {
59
- [
60
- "/v1/prosopo/user-access-policy/rules/fetch-many"
61
- /* FETCH_MANY */
62
- ]: new FetchRulesEndpoint(
63
- this.accessRulesStorage,
64
- this.logger
65
- ),
66
- [
67
- "/v1/prosopo/user-access-policy/rules/find-ids"
68
- /* FIND_IDS */
69
- ]: new FindRuleIdsEndpoint(
70
- this.accessRulesStorage,
71
- this.logger
72
- ),
73
- [
74
- "/v1/prosopo/user-access-policy/rules/get-missing-ids"
75
- /* GET_MISSING_IDS */
76
- ]: new GetMissingIdsEndpoint(
77
- this.accessRulesStorage,
78
- this.logger
79
- )
80
- };
81
- }
82
- makeWriteEndpoints() {
83
- return {
84
- [
85
- "/v1/prosopo/user-access-policy/rules/insert-many"
86
- /* INSERT_MANY */
87
- ]: new InsertRulesEndpoint(
88
- this.accessRulesStorage,
89
- this.logger
90
- ),
91
- [
92
- "/v1/prosopo/user-access-policy/rules/rehash-all"
93
- /* REHASH_ALL */
94
- ]: new RehashRulesEndpoint(
95
- this.accessRulesStorage,
96
- this.logger
97
- )
98
- };
99
- }
100
- }
101
- const getExpressApiRuleRateLimits = () => {
102
- const defaults = {
103
- limit: 5,
104
- windowSeconds: 10
105
- };
106
- const defaultWindowMs = defaults.windowSeconds * 1e3;
107
- const rateLimitEntries = Object.entries(accessRuleApiPaths).map(
108
- ([endpointName, endpointPath]) => [
109
- endpointPath,
110
- {
111
- windowMs: getIntEnvironmentVariable(
112
- `PROSOPO_USER_ACCESS_POLICY_RULE_${endpointName}_WINDOW`
113
- ) || defaultWindowMs,
114
- limit: getIntEnvironmentVariable(
115
- `PROSOPO_USER_ACCESS_POLICY_RULE_${endpointName}_LIMIT`
116
- ) || defaults.limit
117
- }
118
- ]
119
- );
120
- return Object.fromEntries(rateLimitEntries);
10
+ //#region src/api/ruleApiRoutes.ts
11
+ var accessRuleApiPaths = /* @__PURE__ */ function(accessRuleApiPaths) {
12
+ accessRuleApiPaths["DELETE_ALL"] = "/v1/prosopo/user-access-policy/rules/delete-all";
13
+ accessRuleApiPaths["DELETE_GROUPS"] = "/v1/prosopo/user-access-policy/rules/delete-groups";
14
+ accessRuleApiPaths["DELETE_MANY"] = "/v1/prosopo/user-access-policy/rules/delete-many";
15
+ accessRuleApiPaths["FETCH_MANY"] = "/v1/prosopo/user-access-policy/rules/fetch-many";
16
+ accessRuleApiPaths["FIND_IDS"] = "/v1/prosopo/user-access-policy/rules/find-ids";
17
+ accessRuleApiPaths["GET_MISSING_IDS"] = "/v1/prosopo/user-access-policy/rules/get-missing-ids";
18
+ accessRuleApiPaths["INSERT_MANY"] = "/v1/prosopo/user-access-policy/rules/insert-many";
19
+ accessRuleApiPaths["REHASH_ALL"] = "/v1/prosopo/user-access-policy/rules/rehash-all";
20
+ return accessRuleApiPaths;
21
+ }({});
22
+ var AccessRuleApiRoutes = class {
23
+ constructor(accessRulesStorage, logger) {
24
+ this.accessRulesStorage = accessRulesStorage;
25
+ this.logger = logger;
26
+ }
27
+ getRoutes() {
28
+ return {
29
+ ...this.makeDeleteEndpoints(),
30
+ ...this.makeReadEndpoints(),
31
+ ...this.makeWriteEndpoints()
32
+ };
33
+ }
34
+ makeDeleteEndpoints() {
35
+ return {
36
+ ["/v1/prosopo/user-access-policy/rules/delete-all"]: new DeleteAllRulesEndpoint(this.accessRulesStorage, this.logger),
37
+ ["/v1/prosopo/user-access-policy/rules/delete-groups"]: new DeleteRuleGroupsEndpoint(this.accessRulesStorage, this.logger),
38
+ ["/v1/prosopo/user-access-policy/rules/delete-many"]: new DeleteRulesEndpoint(this.accessRulesStorage, this.logger)
39
+ };
40
+ }
41
+ makeReadEndpoints() {
42
+ return {
43
+ ["/v1/prosopo/user-access-policy/rules/fetch-many"]: new FetchRulesEndpoint(this.accessRulesStorage, this.logger),
44
+ ["/v1/prosopo/user-access-policy/rules/find-ids"]: new FindRuleIdsEndpoint(this.accessRulesStorage, this.logger),
45
+ ["/v1/prosopo/user-access-policy/rules/get-missing-ids"]: new GetMissingIdsEndpoint(this.accessRulesStorage, this.logger)
46
+ };
47
+ }
48
+ makeWriteEndpoints() {
49
+ return {
50
+ ["/v1/prosopo/user-access-policy/rules/insert-many"]: new InsertRulesEndpoint(this.accessRulesStorage, this.logger),
51
+ ["/v1/prosopo/user-access-policy/rules/rehash-all"]: new RehashRulesEndpoint(this.accessRulesStorage, this.logger)
52
+ };
53
+ }
121
54
  };
122
- const getIntEnvironmentVariable = (variableName) => {
123
- const variableValue = process.env[variableName];
124
- const numericValue = variableValue ? Number.parseInt(variableValue) : Number.NaN;
125
- return Number.isInteger(numericValue) ? numericValue : void 0;
55
+ var getExpressApiRuleRateLimits = () => {
56
+ const defaults = {
57
+ limit: 5,
58
+ windowSeconds: 10
59
+ };
60
+ const defaultWindowMs = defaults.windowSeconds * 1e3;
61
+ const rateLimitEntries = Object.entries(accessRuleApiPaths).map(([endpointName, endpointPath]) => [endpointPath, {
62
+ windowMs: getIntEnvironmentVariable(`PROSOPO_USER_ACCESS_POLICY_RULE_${endpointName}_WINDOW`) || defaultWindowMs,
63
+ limit: getIntEnvironmentVariable(`PROSOPO_USER_ACCESS_POLICY_RULE_${endpointName}_LIMIT`) || defaults.limit
64
+ }]);
65
+ return Object.fromEntries(rateLimitEntries);
126
66
  };
127
- export {
128
- AccessRuleApiRoutes,
129
- accessRuleApiPaths,
130
- getExpressApiRuleRateLimits
67
+ var getIntEnvironmentVariable = (variableName) => {
68
+ const variableValue = process.env[variableName];
69
+ const numericValue = variableValue ? Number.parseInt(variableValue) : NaN;
70
+ return Number.isInteger(numericValue) ? numericValue : void 0;
131
71
  };
72
+ //#endregion
73
+ export { AccessRuleApiRoutes, accessRuleApiPaths, getExpressApiRuleRateLimits };
@@ -1,92 +1,56 @@
1
- import { ApiClient } from "@prosopo/api";
1
+ import "../_virtual/_rolldown/runtime.js";
2
2
  import { fetchRulesResponse } from "./read/fetchRules.js";
3
3
  import { ruleIdsResponse } from "./read/findRuleIds.js";
4
4
  import { missingIdsResponse } from "./read/getMissingIds.js";
5
5
  import { accessRuleApiPaths } from "./ruleApiRoutes.js";
6
- class AccessRulesApiClient extends ApiClient {
7
- //// delete
8
- deleteMany(filters, jwt) {
9
- return this.post(
10
- accessRuleApiPaths.DELETE_MANY,
11
- filters,
12
- this.getAuthHeaders(jwt)
13
- );
14
- }
15
- deleteGroups(siteGroups, jwt) {
16
- return this.post(
17
- accessRuleApiPaths.DELETE_GROUPS,
18
- siteGroups,
19
- this.getAuthHeaders(jwt)
20
- );
21
- }
22
- deleteAll(jwt) {
23
- return this.post(
24
- accessRuleApiPaths.DELETE_ALL,
25
- {},
26
- this.getAuthHeaders(jwt)
27
- );
28
- }
29
- //// read
30
- async getMissingIds(idsToCheck, jwt) {
31
- const endpointResponse = await this.post(
32
- accessRuleApiPaths.GET_MISSING_IDS,
33
- idsToCheck,
34
- this.getAuthHeaders(jwt)
35
- );
36
- const parsedData = missingIdsResponse.safeParse(endpointResponse.data);
37
- return {
38
- ...endpointResponse,
39
- data: parsedData.success ? parsedData.data : void 0
40
- };
41
- }
42
- async fetchMany(fetchOptions, jwt) {
43
- const endpointResponse = await this.post(
44
- accessRuleApiPaths.FETCH_MANY,
45
- fetchOptions,
46
- this.getAuthHeaders(jwt)
47
- );
48
- const parsedData = fetchRulesResponse.safeParse(endpointResponse.data);
49
- return {
50
- ...endpointResponse,
51
- data: parsedData.success ? parsedData.data : void 0
52
- };
53
- }
54
- async findIds(filters, jwt) {
55
- const endpointResponse = await this.post(
56
- accessRuleApiPaths.FIND_IDS,
57
- filters,
58
- this.getAuthHeaders(jwt)
59
- );
60
- const parsedData = ruleIdsResponse.safeParse(endpointResponse.data);
61
- return {
62
- ...endpointResponse,
63
- data: parsedData.success ? parsedData.data : void 0
64
- };
65
- }
66
- //// write
67
- async rehashAll(jwt) {
68
- return this.post(
69
- accessRuleApiPaths.REHASH_ALL,
70
- {},
71
- this.getAuthHeaders(jwt)
72
- );
73
- }
74
- insertMany(ruleGroups, jwt) {
75
- return this.post(
76
- accessRuleApiPaths.INSERT_MANY,
77
- ruleGroups,
78
- this.getAuthHeaders(jwt)
79
- );
80
- }
81
- getAuthHeaders(jwt) {
82
- return {
83
- headers: {
84
- "Prosopo-Site-Key": this.account,
85
- Authorization: `Bearer ${jwt}`
86
- }
87
- };
88
- }
89
- }
90
- export {
91
- AccessRulesApiClient
6
+ import { ApiClient } from "@prosopo/api";
7
+ //#region src/api/rulesApiClient.ts
8
+ var AccessRulesApiClient = class extends ApiClient {
9
+ deleteMany(filters, jwt) {
10
+ return this.post(accessRuleApiPaths.DELETE_MANY, filters, this.getAuthHeaders(jwt));
11
+ }
12
+ deleteGroups(siteGroups, jwt) {
13
+ return this.post(accessRuleApiPaths.DELETE_GROUPS, siteGroups, this.getAuthHeaders(jwt));
14
+ }
15
+ deleteAll(jwt) {
16
+ return this.post(accessRuleApiPaths.DELETE_ALL, {}, this.getAuthHeaders(jwt));
17
+ }
18
+ async getMissingIds(idsToCheck, jwt) {
19
+ const endpointResponse = await this.post(accessRuleApiPaths.GET_MISSING_IDS, idsToCheck, this.getAuthHeaders(jwt));
20
+ const parsedData = missingIdsResponse.safeParse(endpointResponse.data);
21
+ return {
22
+ ...endpointResponse,
23
+ data: parsedData.success ? parsedData.data : void 0
24
+ };
25
+ }
26
+ async fetchMany(fetchOptions, jwt) {
27
+ const endpointResponse = await this.post(accessRuleApiPaths.FETCH_MANY, fetchOptions, this.getAuthHeaders(jwt));
28
+ const parsedData = fetchRulesResponse.safeParse(endpointResponse.data);
29
+ return {
30
+ ...endpointResponse,
31
+ data: parsedData.success ? parsedData.data : void 0
32
+ };
33
+ }
34
+ async findIds(filters, jwt) {
35
+ const endpointResponse = await this.post(accessRuleApiPaths.FIND_IDS, filters, this.getAuthHeaders(jwt));
36
+ const parsedData = ruleIdsResponse.safeParse(endpointResponse.data);
37
+ return {
38
+ ...endpointResponse,
39
+ data: parsedData.success ? parsedData.data : void 0
40
+ };
41
+ }
42
+ async rehashAll(jwt) {
43
+ return this.post(accessRuleApiPaths.REHASH_ALL, {}, this.getAuthHeaders(jwt));
44
+ }
45
+ insertMany(ruleGroups, jwt) {
46
+ return this.post(accessRuleApiPaths.INSERT_MANY, ruleGroups, this.getAuthHeaders(jwt));
47
+ }
48
+ getAuthHeaders(jwt) {
49
+ return { headers: {
50
+ "Prosopo-Site-Key": this.account,
51
+ Authorization: `Bearer ${jwt}`
52
+ } };
53
+ }
92
54
  };
55
+ //#endregion
56
+ export { AccessRulesApiClient };
@@ -1 +1,2 @@
1
-
1
+ import "../../_virtual/_rolldown/runtime.js";
2
+ export {};