@etohq/framework 1.5.1-alpha.3 → 1.5.1-alpha.5
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/config/loader.d.ts +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +3 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/deps/awilix.d.ts +2 -0
- package/dist/deps/awilix.d.ts.map +1 -0
- package/dist/deps/awilix.js +18 -0
- package/dist/deps/awilix.js.map +1 -0
- package/dist/deps/mikro-orm-cli.d.ts +2 -0
- package/dist/deps/mikro-orm-cli.d.ts.map +1 -0
- package/dist/deps/mikro-orm-cli.js +18 -0
- package/dist/deps/mikro-orm-cli.js.map +1 -0
- package/dist/deps/mikro-orm-core.d.ts +2 -0
- package/dist/deps/mikro-orm-core.d.ts.map +1 -0
- package/dist/deps/mikro-orm-core.js +18 -0
- package/dist/deps/mikro-orm-core.js.map +1 -0
- package/dist/deps/mikro-orm-knex.d.ts +2 -0
- package/dist/deps/mikro-orm-knex.d.ts.map +1 -0
- package/dist/deps/mikro-orm-knex.js +18 -0
- package/dist/deps/mikro-orm-knex.js.map +1 -0
- package/dist/deps/mikro-orm-migrations.d.ts +2 -0
- package/dist/deps/mikro-orm-migrations.d.ts.map +1 -0
- package/dist/deps/mikro-orm-migrations.js +18 -0
- package/dist/deps/mikro-orm-migrations.js.map +1 -0
- package/dist/deps/mikro-orm-postgresql.d.ts +2 -0
- package/dist/deps/mikro-orm-postgresql.d.ts.map +1 -0
- package/dist/deps/mikro-orm-postgresql.js +18 -0
- package/dist/deps/mikro-orm-postgresql.js.map +1 -0
- package/dist/deps/opentelemetry-api.d.ts +2 -0
- package/dist/deps/opentelemetry-api.d.ts.map +1 -0
- package/dist/deps/opentelemetry-api.js +18 -0
- package/dist/deps/opentelemetry-api.js.map +1 -0
- package/dist/deps/opentelemetry-instrumentation-pg.d.ts +2 -0
- package/dist/deps/opentelemetry-instrumentation-pg.d.ts.map +1 -0
- package/dist/deps/opentelemetry-instrumentation-pg.js +18 -0
- package/dist/deps/opentelemetry-instrumentation-pg.js.map +1 -0
- package/dist/deps/opentelemetry-resources.d.ts +2 -0
- package/dist/deps/opentelemetry-resources.d.ts.map +1 -0
- package/dist/deps/opentelemetry-resources.js +18 -0
- package/dist/deps/opentelemetry-resources.js.map +1 -0
- package/dist/deps/opentelemetry-sdk-node.d.ts +2 -0
- package/dist/deps/opentelemetry-sdk-node.d.ts.map +1 -0
- package/dist/deps/opentelemetry-sdk-node.js +18 -0
- package/dist/deps/opentelemetry-sdk-node.js.map +1 -0
- package/dist/deps/opentelemetry-sdk-trace-node.d.ts +2 -0
- package/dist/deps/opentelemetry-sdk-trace-node.d.ts.map +1 -0
- package/dist/deps/opentelemetry-sdk-trace-node.js +18 -0
- package/dist/deps/opentelemetry-sdk-trace-node.js.map +1 -0
- package/dist/deps/pg.d.ts +2 -0
- package/dist/deps/pg.d.ts.map +1 -0
- package/dist/deps/pg.js +18 -0
- package/dist/deps/pg.js.map +1 -0
- package/dist/deps/zod.d.ts +2 -0
- package/dist/deps/zod.d.ts.map +1 -0
- package/dist/deps/zod.js +18 -0
- package/dist/deps/zod.js.map +1 -0
- package/dist/eto-app-loader.d.ts.map +1 -1
- package/dist/eto-app-loader.js +4 -2
- package/dist/eto-app-loader.js.map +1 -1
- package/dist/eto.d.ts +11 -2
- package/dist/eto.d.ts.map +1 -1
- package/dist/eto.js +29 -18
- package/dist/eto.js.map +1 -1
- package/dist/http/express-loader.d.ts +10 -0
- package/dist/http/express-loader.d.ts.map +1 -0
- package/dist/http/express-loader.js +130 -0
- package/dist/http/express-loader.js.map +1 -0
- package/dist/http/middleware-file-loader.d.ts +33 -0
- package/dist/http/middleware-file-loader.d.ts.map +1 -0
- package/dist/http/middleware-file-loader.js +186 -0
- package/dist/http/middleware-file-loader.js.map +1 -0
- package/dist/http/middlewares/apply-locale.d.ts +12 -0
- package/dist/http/middlewares/apply-locale.d.ts.map +1 -0
- package/dist/http/middlewares/apply-locale.js +31 -0
- package/dist/http/middlewares/apply-locale.js.map +1 -0
- package/dist/http/middlewares/check-permissions.d.ts +15 -0
- package/dist/http/middlewares/check-permissions.d.ts.map +1 -0
- package/dist/http/middlewares/check-permissions.js +54 -0
- package/dist/http/middlewares/check-permissions.js.map +1 -0
- package/dist/http/router.d.ts +36 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/router.js +317 -0
- package/dist/http/router.js.map +1 -0
- package/dist/http/routes-finder.d.ts +22 -0
- package/dist/http/routes-finder.d.ts.map +1 -0
- package/dist/http/routes-finder.js +68 -0
- package/dist/http/routes-finder.js.map +1 -0
- package/dist/http/routes-loader.d.ts +39 -0
- package/dist/http/routes-loader.d.ts.map +1 -0
- package/dist/http/routes-loader.js +232 -0
- package/dist/http/routes-loader.js.map +1 -0
- package/dist/http/routes-sorter.d.ts +105 -0
- package/dist/http/routes-sorter.d.ts.map +1 -0
- package/dist/http/routes-sorter.js +146 -0
- package/dist/http/routes-sorter.js.map +1 -0
- package/dist/http/utils/define-middlewares.d.ts +22 -0
- package/dist/http/utils/define-middlewares.d.ts.map +1 -0
- package/dist/http/utils/define-middlewares.js +27 -0
- package/dist/http/utils/define-middlewares.js.map +1 -0
- package/dist/http/utils/field-filtering/field-parser.d.ts +32 -0
- package/dist/http/utils/field-filtering/field-parser.d.ts.map +1 -0
- package/dist/http/utils/field-filtering/field-parser.js +87 -0
- package/dist/http/utils/field-filtering/field-parser.js.map +1 -0
- package/dist/http/utils/field-filtering/field-validator.d.ts +24 -0
- package/dist/http/utils/field-filtering/field-validator.d.ts.map +1 -0
- package/dist/http/utils/field-filtering/field-validator.js +67 -0
- package/dist/http/utils/field-filtering/field-validator.js.map +1 -0
- package/dist/http/utils/field-filtering/index.d.ts +33 -0
- package/dist/http/utils/field-filtering/index.d.ts.map +1 -0
- package/dist/http/utils/field-filtering/index.js +9 -0
- package/dist/http/utils/field-filtering/index.js.map +1 -0
- package/dist/http/utils/policies/rbac-field-filter.d.ts +19 -0
- package/dist/http/utils/policies/rbac-field-filter.d.ts.map +1 -0
- package/dist/http/utils/policies/rbac-field-filter.js +348 -0
- package/dist/http/utils/policies/rbac-field-filter.js.map +1 -0
- package/dist/links/link-loader.d.ts +2 -1
- package/dist/links/link-loader.d.ts.map +1 -1
- package/dist/links/link-loader.js +9 -7
- package/dist/links/link-loader.js.map +1 -1
- package/dist/policies/has-permission.d.ts +33 -0
- package/dist/policies/has-permission.d.ts.map +1 -0
- package/dist/policies/has-permission.js +110 -0
- package/dist/policies/has-permission.js.map +1 -0
- package/dist/policies/index.d.ts +3 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +19 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/policy-loader.d.ts +6 -0
- package/dist/policies/policy-loader.d.ts.map +1 -0
- package/dist/policies/policy-loader.js +17 -0
- package/dist/policies/policy-loader.js.map +1 -0
- package/dist/telemetry/index.d.ts +50 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +81 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/types/container.d.ts +5 -1
- package/dist/types/container.d.ts.map +1 -1
- package/dist/utils/resource-loader.d.ts +3 -1
- package/dist/utils/resource-loader.d.ts.map +1 -1
- package/dist/utils/resource-loader.js +18 -7
- package/dist/utils/resource-loader.js.map +1 -1
- package/dist/zod/index.d.ts +1 -0
- package/dist/zod/index.d.ts.map +1 -1
- package/dist/zod/index.js +1 -0
- package/dist/zod/index.js.map +1 -1
- package/package.json +21 -9
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldParser = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/utils");
|
|
5
|
+
/**
|
|
6
|
+
* Handles parsing of field strings into structured field sets
|
|
7
|
+
* Supports various field modifiers:
|
|
8
|
+
* - `+field` or ` field`: Add to defaults
|
|
9
|
+
* - `-field`: Remove from defaults
|
|
10
|
+
* - `*field` or `field.*`: Select all properties of a relation
|
|
11
|
+
*/
|
|
12
|
+
class FieldParser {
|
|
13
|
+
/**
|
|
14
|
+
* Parse field string and defaults into structured field sets
|
|
15
|
+
* @param fields - Comma-separated field string from query
|
|
16
|
+
* @param defaults - Default fields to include
|
|
17
|
+
* @returns ParsedFields with fields and starFields sets
|
|
18
|
+
*/
|
|
19
|
+
static parse(fields, defaults = []) {
|
|
20
|
+
const starFields = new Set();
|
|
21
|
+
let allFields = new Set(defaults);
|
|
22
|
+
if ((0, utils_1.isDefined)(fields)) {
|
|
23
|
+
const customFields = fields.split(",").filter(Boolean);
|
|
24
|
+
const shouldReplaceDefaultFields = this.shouldReplaceDefaults(customFields);
|
|
25
|
+
if (shouldReplaceDefaultFields) {
|
|
26
|
+
allFields = new Set(customFields.map((f) => f.replace(/^[+ -]/, "")));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.applyFieldModifiers(customFields, allFields);
|
|
30
|
+
}
|
|
31
|
+
allFields.add("id");
|
|
32
|
+
}
|
|
33
|
+
this.extractStarFields(allFields, starFields);
|
|
34
|
+
return { fields: allFields, starFields };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determines if custom fields should replace defaults
|
|
38
|
+
* Fields replace defaults when any field doesn't have a modifier prefix
|
|
39
|
+
*/
|
|
40
|
+
static shouldReplaceDefaults(customFields) {
|
|
41
|
+
return (!customFields.length ||
|
|
42
|
+
customFields.some((field) => {
|
|
43
|
+
return !(field.startsWith("-") ||
|
|
44
|
+
field.startsWith("+") ||
|
|
45
|
+
field.startsWith(" ") ||
|
|
46
|
+
field.startsWith("*") ||
|
|
47
|
+
field.endsWith(".*"));
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Apply field modifiers (+, -, etc) to the field set
|
|
52
|
+
*/
|
|
53
|
+
static applyFieldModifiers(customFields, allFields) {
|
|
54
|
+
customFields.forEach((field) => {
|
|
55
|
+
if (field.startsWith("+") || field.startsWith(" ")) {
|
|
56
|
+
allFields.add(field.trim().replace(/^\+/, ""));
|
|
57
|
+
}
|
|
58
|
+
else if (field.startsWith("-")) {
|
|
59
|
+
const fieldName = field.replace(/^-/, "");
|
|
60
|
+
for (const reqField of allFields) {
|
|
61
|
+
const reqFieldName = reqField.replace(/^\*/, "");
|
|
62
|
+
if (reqFieldName === fieldName ||
|
|
63
|
+
reqFieldName.startsWith(fieldName + ".")) {
|
|
64
|
+
allFields.delete(reqField);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
allFields.add(field);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Extract star fields (* prefix or .* suffix) from allFields into starFields set
|
|
75
|
+
* Star fields represent "select all properties" for a relation
|
|
76
|
+
*/
|
|
77
|
+
static extractStarFields(allFields, starFields) {
|
|
78
|
+
allFields.forEach((field) => {
|
|
79
|
+
if (field.startsWith("*") || field.endsWith(".*")) {
|
|
80
|
+
starFields.add(field.replace(/(^\*|\.\*$)/, ""));
|
|
81
|
+
allFields.delete(field);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.FieldParser = FieldParser;
|
|
87
|
+
//# sourceMappingURL=field-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-parser.js","sourceRoot":"","sources":["../../../../src/http/utils/field-filtering/field-parser.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AAGxC;;;;;;GAMG;AACH,MAAa,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CACV,MAA0B,EAC1B,WAAqB,EAAE;QAEvB,MAAM,UAAU,GAAgB,IAAI,GAAG,EAAE,CAAA;QACzC,IAAI,SAAS,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAgB,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ACJ,CAAC;CACF;AA7FD,kCA6FC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FieldFilterContext, IFieldFilter } from "./index";
|
|
2
|
+
/**
|
|
3
|
+
* Filter that only allows explicitly specified fields
|
|
4
|
+
* Fields not in the allowed list are returned as not allowed
|
|
5
|
+
*/
|
|
6
|
+
export declare class AllowedFieldFilter implements IFieldFilter {
|
|
7
|
+
private allowed;
|
|
8
|
+
constructor({ allowed }: {
|
|
9
|
+
allowed: string[];
|
|
10
|
+
});
|
|
11
|
+
getNotAllowedFields(context: FieldFilterContext): string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Filter that restricts specific fields
|
|
15
|
+
* Fields containing any restricted segment are returned as not allowed
|
|
16
|
+
*/
|
|
17
|
+
export declare class RestrictedFieldFilter implements IFieldFilter {
|
|
18
|
+
private restricted;
|
|
19
|
+
constructor({ restricted }: {
|
|
20
|
+
restricted: string[];
|
|
21
|
+
});
|
|
22
|
+
getNotAllowedFields(context: FieldFilterContext): string[];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=field-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-validator.d.ts","sourceRoot":"","sources":["../../../../src/http/utils/field-filtering/field-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE1D;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,OAAO,CAAU;gBAEb,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IAI9C,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE;CAmC3D;AAED;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,YAAY;IACxD,OAAO,CAAC,UAAU,CAAU;gBAEhB,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE;IAIpD,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE;CAqB3D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestrictedFieldFilter = exports.AllowedFieldFilter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Filter that only allows explicitly specified fields
|
|
6
|
+
* Fields not in the allowed list are returned as not allowed
|
|
7
|
+
*/
|
|
8
|
+
class AllowedFieldFilter {
|
|
9
|
+
constructor({ allowed }) {
|
|
10
|
+
this.allowed = allowed;
|
|
11
|
+
}
|
|
12
|
+
getNotAllowedFields(context) {
|
|
13
|
+
const { parsedFields } = context;
|
|
14
|
+
const { fields, starFields } = parsedFields;
|
|
15
|
+
const fieldsToCheck = [...fields, ...Array.from(starFields)];
|
|
16
|
+
const notAllowedFields = [];
|
|
17
|
+
fieldsToCheck.forEach((field) => {
|
|
18
|
+
const hasAllowedField = this.allowed.includes(field);
|
|
19
|
+
if (hasAllowedField) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// Select full relation - must match an allowed field fully
|
|
23
|
+
// e.g product.variants must have product.variants in allowedFields
|
|
24
|
+
if (starFields.has(field)) {
|
|
25
|
+
if (hasAllowedField) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
notAllowedFields.push(field);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const fieldStartsWithAllowedField = this.allowed.some((allowedField) => field.startsWith(allowedField));
|
|
32
|
+
if (!fieldStartsWithAllowedField) {
|
|
33
|
+
notAllowedFields.push(field);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return notAllowedFields;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.AllowedFieldFilter = AllowedFieldFilter;
|
|
41
|
+
/**
|
|
42
|
+
* Filter that restricts specific fields
|
|
43
|
+
* Fields containing any restricted segment are returned as not allowed
|
|
44
|
+
*/
|
|
45
|
+
class RestrictedFieldFilter {
|
|
46
|
+
constructor({ restricted }) {
|
|
47
|
+
this.restricted = restricted;
|
|
48
|
+
}
|
|
49
|
+
getNotAllowedFields(context) {
|
|
50
|
+
const { parsedFields } = context;
|
|
51
|
+
const { fields, starFields } = parsedFields;
|
|
52
|
+
const fieldsToCheck = [...fields, ...Array.from(starFields)];
|
|
53
|
+
const notAllowedFields = [];
|
|
54
|
+
fieldsToCheck.forEach((field) => {
|
|
55
|
+
const fieldSegments = field.split(".");
|
|
56
|
+
const hasRestrictedField = this.restricted.some((restrictedField) => fieldSegments.includes(restrictedField));
|
|
57
|
+
if (hasRestrictedField) {
|
|
58
|
+
notAllowedFields.push(field);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
});
|
|
63
|
+
return notAllowedFields;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.RestrictedFieldFilter = RestrictedFieldFilter;
|
|
67
|
+
//# sourceMappingURL=field-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-validator.js","sourceRoot":"","sources":["../../../../src/http/utils/field-filtering/field-validator.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,kBAAkB;IAG7B,YAAY,EAAE,OAAO,EAAyB;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,mBAAmB,CAAC,OAA2B;QAC7C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QAChC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,YAAY,CAAA;QAC3C,MAAM,aAAa,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;QAC5D,MAAM,gBAAgB,GAAa,EAAE,CAAA;QAErC,aAAa,CAAC,OAAO,C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,CAAC,CAAA;YACtC,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAClE,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CACxC,CAAA;YACD,IAAI,kBAAkB,EAAE,CAAC;gBACvB,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBAC5B,OAAM;YACR,CAAC;YAED,OAAM;QACR,CAAC,CAAC,CAAA;QAEF,OAAO,gBAAgB,CAAA;IACzB,CAAC;CACF;AA5BD,sDA4BC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed fields structure after processing field strings
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedFields {
|
|
5
|
+
/** Regular fields to select */
|
|
6
|
+
fields: Set<string>;
|
|
7
|
+
/** Star fields representing full relation selections (e.g., *product.variants) */
|
|
8
|
+
starFields: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Context passed to field filters for determining access
|
|
12
|
+
*/
|
|
13
|
+
export interface FieldFilterContext {
|
|
14
|
+
/** The main entity being queried (e.g., "product", "order") */
|
|
15
|
+
entity: string;
|
|
16
|
+
/** Parsed fields to filter */
|
|
17
|
+
parsedFields: ParsedFields;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for field filters following the Strategy pattern
|
|
21
|
+
* Allows adding new field filtering logic without modifying prepareListQuery
|
|
22
|
+
*/
|
|
23
|
+
export interface IFieldFilter {
|
|
24
|
+
/**
|
|
25
|
+
* Returns fields that should be excluded from the query
|
|
26
|
+
* @param context - The filter context containing entity and parsed fields
|
|
27
|
+
* @returns Array of field names that are not allowed
|
|
28
|
+
*/
|
|
29
|
+
getNotAllowedFields(context: FieldFilterContext): Promise<string[]> | string[];
|
|
30
|
+
}
|
|
31
|
+
export { FieldParser } from "./field-parser";
|
|
32
|
+
export { AllowedFieldFilter, RestrictedFieldFilter } from "./field-validator";
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/http/utils/field-filtering/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,kFAAkF;IAClF,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAA;CAC/E;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestrictedFieldFilter = exports.AllowedFieldFilter = exports.FieldParser = void 0;
|
|
4
|
+
var field_parser_1 = require("./field-parser");
|
|
5
|
+
Object.defineProperty(exports, "FieldParser", { enumerable: true, get: function () { return field_parser_1.FieldParser; } });
|
|
6
|
+
var field_validator_1 = require("./field-validator");
|
|
7
|
+
Object.defineProperty(exports, "AllowedFieldFilter", { enumerable: true, get: function () { return field_validator_1.AllowedFieldFilter; } });
|
|
8
|
+
Object.defineProperty(exports, "RestrictedFieldFilter", { enumerable: true, get: function () { return field_validator_1.RestrictedFieldFilter; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/http/utils/field-filtering/index.ts"],"names":[],"mappings":";;;AAiCA,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AACpB,qDAA6E;AAApE,qHAAA,kBAAkB,OAAA;AAAE,wHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PolicyDefinition } from "@etohq/framework/utils";
|
|
2
|
+
import type { EtoContainer } from "@etohq/types";
|
|
3
|
+
import { FieldFilterContext, IFieldFilter } from "../field-filtering/index";
|
|
4
|
+
/**
|
|
5
|
+
* RBAC Field Filter using the Strategy pattern
|
|
6
|
+
* Optimized for parallel permission checks
|
|
7
|
+
*/
|
|
8
|
+
export declare class RBACFieldFilter implements IFieldFilter {
|
|
9
|
+
private policies;
|
|
10
|
+
private userRoles;
|
|
11
|
+
private container;
|
|
12
|
+
constructor({ policies, userRoles, container, }: {
|
|
13
|
+
policies: PolicyDefinition[];
|
|
14
|
+
userRoles: string[];
|
|
15
|
+
container: EtoContainer;
|
|
16
|
+
});
|
|
17
|
+
getNotAllowedFields(context: FieldFilterContext): Promise<string[]>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=rbac-field-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rbac-field-filter.d.ts","sourceRoot":"","sources":["../../../../src/http/utils/policies/rbac-field-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAIjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAqY3E;;;GAGG;AACH,qBAAa,eAAgB,YAAW,YAAY;IAClD,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,SAAS,CAAc;gBAEnB,EACV,QAAQ,EACR,SAAS,EACT,SAAS,GACV,EAAE;QACD,QAAQ,EAAE,gBAAgB,EAAE,CAAA;QAC5B,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,SAAS,EAAE,YAAY,CAAA;KACxB;IAMK,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CA+D1E"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RBACFieldFilter = void 0;
|
|
4
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
5
|
+
const modules_sdk_1 = require("@etohq/modules-sdk");
|
|
6
|
+
const has_permission_1 = require("../../../policies/has-permission");
|
|
7
|
+
/**
|
|
8
|
+
* Base GraphQL schema with common scalars
|
|
9
|
+
*/
|
|
10
|
+
const baseGraphqlSchema = `
|
|
11
|
+
scalar DateTime
|
|
12
|
+
scalar Date
|
|
13
|
+
scalar Time
|
|
14
|
+
scalar JSON
|
|
15
|
+
`;
|
|
16
|
+
const primitiveTypes = new Set([
|
|
17
|
+
"String",
|
|
18
|
+
"Int",
|
|
19
|
+
"Float",
|
|
20
|
+
"Boolean",
|
|
21
|
+
"ID",
|
|
22
|
+
"DateTime",
|
|
23
|
+
"JSON",
|
|
24
|
+
]);
|
|
25
|
+
// Cache for the schema and entity mappings to avoid re-parsing the GraphQL
|
|
26
|
+
let cachedSchema = null;
|
|
27
|
+
let cachedEntityMap = null;
|
|
28
|
+
let cachedEntityAliasMap = null;
|
|
29
|
+
function isString(value) {
|
|
30
|
+
return typeof value === "string";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Makes a GraphQL schema executable
|
|
34
|
+
*/
|
|
35
|
+
function makeSchemaExecutable(inputSchema) {
|
|
36
|
+
const { schema: cleanedSchema } = utils_1.GraphQLUtils.cleanGraphQLSchema(inputSchema);
|
|
37
|
+
if (!cleanedSchema) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return utils_1.GraphQLUtils.makeExecutableSchema({
|
|
41
|
+
typeDefs: cleanedSchema,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function getExecutableSchema() {
|
|
45
|
+
if (cachedSchema) {
|
|
46
|
+
return cachedSchema;
|
|
47
|
+
}
|
|
48
|
+
cachedSchema = buildExecutableSchema();
|
|
49
|
+
return cachedSchema;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Builds entity alias map from joiner configs
|
|
53
|
+
* Maps all possible aliases (e.g., "variant", "variants") to canonical entity names (e.g., "ProductVariant")
|
|
54
|
+
*/
|
|
55
|
+
function buildEntityAliasMap() {
|
|
56
|
+
const moduleJoinerConfigs = modules_sdk_1.EtoModule.getAllJoinerConfigs();
|
|
57
|
+
const aliasMap = new Map();
|
|
58
|
+
for (const config of moduleJoinerConfigs) {
|
|
59
|
+
if (!config.alias) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const aliases = Array.isArray(config.alias) ? config.alias : [config.alias];
|
|
63
|
+
for (const alias of aliases) {
|
|
64
|
+
const aliasNames = Array.isArray(alias.name) ? alias.name : [alias.name];
|
|
65
|
+
if (!alias.entity) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const targetEntity = alias.entity;
|
|
69
|
+
for (const aliasName of aliasNames) {
|
|
70
|
+
aliasMap.set(aliasName, targetEntity);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return aliasMap;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the entity alias map, building it if necessary
|
|
78
|
+
*/
|
|
79
|
+
function getEntityAliasMap() {
|
|
80
|
+
if (!cachedEntityAliasMap) {
|
|
81
|
+
cachedEntityAliasMap = buildEntityAliasMap();
|
|
82
|
+
}
|
|
83
|
+
return cachedEntityAliasMap;
|
|
84
|
+
}
|
|
85
|
+
function getSchemaFromJoinerConfigs(moduleJoinerConfigs) {
|
|
86
|
+
const schemaParts = [];
|
|
87
|
+
for (const config of moduleJoinerConfigs) {
|
|
88
|
+
if (!config?.schema) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
schemaParts.push(config.schema);
|
|
92
|
+
}
|
|
93
|
+
return schemaParts.join("\n");
|
|
94
|
+
}
|
|
95
|
+
function buildCompleteEntityMap() {
|
|
96
|
+
const moduleJoinerConfigs = modules_sdk_1.EtoModule.getAllJoinerConfigs();
|
|
97
|
+
const entityMap = new Map();
|
|
98
|
+
// base GraphQL schema
|
|
99
|
+
const schema = buildExecutableSchema();
|
|
100
|
+
if (!schema) {
|
|
101
|
+
return entityMap;
|
|
102
|
+
}
|
|
103
|
+
const entitiesMap = schema.getTypeMap();
|
|
104
|
+
// Process each service configuration to build alias field mappings
|
|
105
|
+
for (const config of moduleJoinerConfigs) {
|
|
106
|
+
processServiceConfig(config, entitiesMap, entityMap);
|
|
107
|
+
}
|
|
108
|
+
return entityMap;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Processes a service configuration to extract field mappings
|
|
112
|
+
*/
|
|
113
|
+
function processServiceConfig(config, entitiesMap, entityMap) {
|
|
114
|
+
if (!config.extends) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
for (const extend of config.extends) {
|
|
118
|
+
if (!entitiesMap[extend?.entity]) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const extendedFieldAlias = extend.fieldAlias || {};
|
|
122
|
+
if (Object.keys(extendedFieldAlias).length > 0) {
|
|
123
|
+
processFieldAliases(extendedFieldAlias, extend.entity, entitiesMap, entityMap);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Processes field aliases to build entity mappings
|
|
129
|
+
*/
|
|
130
|
+
function processFieldAliases(fieldAlias, baseEntity, entitiesMap, entityMap) {
|
|
131
|
+
for (const [aliasName, aliasConfig] of Object.entries(fieldAlias)) {
|
|
132
|
+
const aliasPath = isString(aliasConfig) ? aliasConfig : aliasConfig.path;
|
|
133
|
+
if (!aliasPath) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
// Build the complete path from base entity through alias path
|
|
137
|
+
const pathSegments = aliasPath.split(".");
|
|
138
|
+
let currentEntity = baseEntity;
|
|
139
|
+
let finalEntity = baseEntity;
|
|
140
|
+
let isValidPath = true;
|
|
141
|
+
// Traverse the path to find the final entity
|
|
142
|
+
for (const segment of pathSegments) {
|
|
143
|
+
const entityMapping = findFieldInEntity(currentEntity, segment, entitiesMap);
|
|
144
|
+
if (!entityMapping) {
|
|
145
|
+
isValidPath = false;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
currentEntity = entityMapping.targetEntity;
|
|
149
|
+
finalEntity = entityMapping.targetEntity;
|
|
150
|
+
}
|
|
151
|
+
if (isValidPath) {
|
|
152
|
+
const fullPath = `${baseEntity}.${aliasName}`;
|
|
153
|
+
entityMap.set(fullPath, {
|
|
154
|
+
entityName: aliasName,
|
|
155
|
+
targetEntity: finalEntity,
|
|
156
|
+
path: pathSegments,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Finds a field in an entity and returns its target entity
|
|
163
|
+
*/
|
|
164
|
+
function findFieldInEntity(entityName, fieldName, entitiesMap) {
|
|
165
|
+
const entity = entitiesMap[entityName];
|
|
166
|
+
if (!entity?.astNode?.fields) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
for (const field of entity.astNode.fields) {
|
|
170
|
+
if (field.name?.value === fieldName) {
|
|
171
|
+
let type = field.type;
|
|
172
|
+
while (type.type) {
|
|
173
|
+
type = type.type;
|
|
174
|
+
}
|
|
175
|
+
const targetEntity = type.name?.value;
|
|
176
|
+
if (targetEntity && !primitiveTypes.has(targetEntity)) {
|
|
177
|
+
return { targetEntity };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Gets the complete entity map with all aliases resolved
|
|
185
|
+
*/
|
|
186
|
+
function getEntityMap() {
|
|
187
|
+
if (!cachedEntityMap) {
|
|
188
|
+
cachedEntityMap = buildCompleteEntityMap();
|
|
189
|
+
}
|
|
190
|
+
return cachedEntityMap;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Builds executable schema from all joiner configs
|
|
194
|
+
*/
|
|
195
|
+
function buildExecutableSchema() {
|
|
196
|
+
const moduleJoinerConfigs = modules_sdk_1.EtoModule.getAllJoinerConfigs();
|
|
197
|
+
const schemaFromJoinerConfigs = getSchemaFromJoinerConfigs(moduleJoinerConfigs);
|
|
198
|
+
const augmentedSchema = baseGraphqlSchema + "\n" + schemaFromJoinerConfigs;
|
|
199
|
+
const executableSchema = makeSchemaExecutable(augmentedSchema);
|
|
200
|
+
return executableSchema || null;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Gets the actual GraphQL entity name from a field path using the complete entity map
|
|
204
|
+
* This now uses the pre-built entity map with all aliases resolved
|
|
205
|
+
* e.g., "product.variants.prices" -> "Price" (from resolved alias path)
|
|
206
|
+
*/
|
|
207
|
+
function getActualEntityName(fieldPath) {
|
|
208
|
+
const schema = getExecutableSchema();
|
|
209
|
+
if (!schema) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const entitiesMap = schema.getTypeMap();
|
|
213
|
+
const entityMap = getEntityMap();
|
|
214
|
+
const entityAliasMap = getEntityAliasMap();
|
|
215
|
+
const parts = fieldPath.split(".");
|
|
216
|
+
const entryPoint = parts[0];
|
|
217
|
+
const resolvedEntityName = entityAliasMap.get(entryPoint);
|
|
218
|
+
if (!resolvedEntityName) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
let currentEntity = entitiesMap[resolvedEntityName];
|
|
222
|
+
let currentEntityName = resolvedEntityName;
|
|
223
|
+
if (!currentEntity) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
for (let i = 1; i < parts.length; i++) {
|
|
227
|
+
const fieldName = parts[i];
|
|
228
|
+
const mappingKey = `${currentEntityName}.${fieldName}`;
|
|
229
|
+
const entityMapping = entityMap.get(mappingKey);
|
|
230
|
+
if (entityMapping) {
|
|
231
|
+
// field alias paths
|
|
232
|
+
const targetEntityName = entityMapping.targetEntity;
|
|
233
|
+
currentEntityName = targetEntityName;
|
|
234
|
+
currentEntity = entitiesMap[currentEntityName];
|
|
235
|
+
if (!currentEntity) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const fieldResult = findFieldInEntity(currentEntityName, fieldName, entitiesMap);
|
|
241
|
+
if (!fieldResult) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
currentEntityName = fieldResult.targetEntity;
|
|
245
|
+
currentEntity = entitiesMap[currentEntityName];
|
|
246
|
+
if (!currentEntity) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return currentEntityName;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Gets the normalized snake_case entity name for policy comparison
|
|
255
|
+
* e.g., "product.variants" -> "product_variant", "Price" -> "price"
|
|
256
|
+
*/
|
|
257
|
+
function getNormalizedEntityName(fieldPath) {
|
|
258
|
+
const actualEntityName = getActualEntityName(fieldPath);
|
|
259
|
+
if (!actualEntityName) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
return (0, utils_1.toSnakeCase)(actualEntityName);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Collects all unique entity paths that need permission checks
|
|
266
|
+
* This avoids duplicate permission checks for shared path prefixes
|
|
267
|
+
*/
|
|
268
|
+
function collectUniqueEntityPaths(entity, fields) {
|
|
269
|
+
const uniquePaths = new Map();
|
|
270
|
+
for (const field of fields) {
|
|
271
|
+
const fullFieldPath = entity + "." + field;
|
|
272
|
+
const pathSegments = fullFieldPath.split(".");
|
|
273
|
+
// Build paths incrementally using string concatenation (more efficient than slice + join)
|
|
274
|
+
let currentPath = "";
|
|
275
|
+
for (let i = 0; i < pathSegments.length; i++) {
|
|
276
|
+
currentPath =
|
|
277
|
+
i === 0 ? pathSegments[i] : currentPath + "." + pathSegments[i];
|
|
278
|
+
if (!uniquePaths.has(currentPath)) {
|
|
279
|
+
const entityName = getNormalizedEntityName(currentPath);
|
|
280
|
+
uniquePaths.set(currentPath, { path: currentPath, entityName });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return uniquePaths;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* RBAC Field Filter using the Strategy pattern
|
|
288
|
+
* Optimized for parallel permission checks
|
|
289
|
+
*/
|
|
290
|
+
class RBACFieldFilter {
|
|
291
|
+
constructor({ policies, userRoles, container, }) {
|
|
292
|
+
this.policies = policies;
|
|
293
|
+
this.userRoles = userRoles;
|
|
294
|
+
this.container = container;
|
|
295
|
+
}
|
|
296
|
+
async getNotAllowedFields(context) {
|
|
297
|
+
const { entity, parsedFields } = context;
|
|
298
|
+
const { fields, starFields } = parsedFields;
|
|
299
|
+
const fieldsToCheck = [...fields, ...Array.from(starFields)];
|
|
300
|
+
if (!fieldsToCheck.length || !this.policies.length || !entity) {
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
const uniquePaths = collectUniqueEntityPaths(entity, fieldsToCheck);
|
|
304
|
+
const pathsNeedingCheck = [];
|
|
305
|
+
for (const [path, info] of uniquePaths) {
|
|
306
|
+
if (info.entityName && utils_1.PolicyResource[info.entityName]) {
|
|
307
|
+
pathsNeedingCheck.push({ path, entityName: info.entityName });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const permissionResults = await (0, utils_1.promiseAll)(pathsNeedingCheck.map(async ({ path, entityName }) => {
|
|
311
|
+
const hasAccess = await (0, has_permission_1.hasPermission)({
|
|
312
|
+
roles: this.userRoles,
|
|
313
|
+
actions: { resource: entityName, operation: "read" },
|
|
314
|
+
container: this.container,
|
|
315
|
+
});
|
|
316
|
+
return { path, hasAccess };
|
|
317
|
+
}));
|
|
318
|
+
const accessMap = new Map();
|
|
319
|
+
for (const result of permissionResults) {
|
|
320
|
+
accessMap.set(result.path, result.hasAccess);
|
|
321
|
+
}
|
|
322
|
+
const notAllowedFields = [];
|
|
323
|
+
for (const field of fieldsToCheck) {
|
|
324
|
+
const fullFieldPath = entity + "." + field;
|
|
325
|
+
const pathSegments = fullFieldPath.split(".");
|
|
326
|
+
let currentPath = "";
|
|
327
|
+
let fieldAllowed = true;
|
|
328
|
+
for (let i = 0; i < pathSegments.length; i++) {
|
|
329
|
+
currentPath =
|
|
330
|
+
i === 0 ? pathSegments[i] : currentPath + "." + pathSegments[i];
|
|
331
|
+
// Check if this path was in our permission check results
|
|
332
|
+
if (accessMap.has(currentPath)) {
|
|
333
|
+
const hasAccess = accessMap.get(currentPath);
|
|
334
|
+
if (!hasAccess) {
|
|
335
|
+
fieldAllowed = false;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (!fieldAllowed) {
|
|
341
|
+
notAllowedFields.push(field);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return notAllowedFields;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.RBACFieldFilter = RBACFieldFilter;
|
|
348
|
+
//# sourceMappingURL=rbac-field-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rbac-field-filter.js","sourceRoot":"","sources":["../../../../src/http/utils/policies/rbac-field-filter.ts"],"names":[],"mappings":";;;AAAA,kDAM+B;AAC/B,oDAA8C;AAE9C,qEAAgE;AAGhE;;GAEG;AACH,M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H,CAAC;QAED,OAAO,gBAAgB,CAAA;IACzB,CAAC;CACF;AAlFD,0CAkFC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Logger } from "@etohq/types";
|
|
1
2
|
export declare class LinkLoader {
|
|
2
3
|
#private;
|
|
3
|
-
constructor(sourceDir: string | string[]);
|
|
4
|
+
constructor(sourceDir: string | string[], logger?: Logger);
|
|
4
5
|
/**
|
|
5
6
|
* Load links from the source paths, links are registering themselves,
|
|
6
7
|
* therefore we only need to import them
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-loader.d.ts","sourceRoot":"","sources":["../../src/links/link-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link-loader.d.ts","sourceRoot":"","sources":["../../src/links/link-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AASrC,qBAAa,UAAU;;gBAqBT,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM;IAKzD;;;OAGG;IACG,IAAI;CAoCX"}
|