@etohq/framework 1.0.0 → 1.2.0
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/build-tools/compiler.d.ts.map +1 -1
- package/dist/build-tools/compiler.js +38 -32
- package/dist/build-tools/compiler.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +1 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/loader.d.ts +7 -2
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +28 -6
- package/dist/config/loader.js.map +1 -1
- package/dist/config/types.d.ts +4 -166
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/index.d.ts +6 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +50 -0
- package/dist/context/index.js.map +1 -0
- package/dist/error/index.d.ts +205 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/index.js +273 -0
- package/dist/error/index.js.map +1 -0
- package/dist/eto-app-loader.d.ts +6 -4
- package/dist/eto-app-loader.d.ts.map +1 -1
- package/dist/eto-app-loader.js +53 -11
- package/dist/eto-app-loader.js.map +1 -1
- package/dist/eto.d.ts +39 -0
- package/dist/eto.d.ts.map +1 -0
- package/dist/eto.js +148 -0
- package/dist/eto.js.map +1 -0
- package/dist/feature-flags/feature-flag-loader.d.ts +4 -3
- package/dist/feature-flags/feature-flag-loader.d.ts.map +1 -1
- package/dist/feature-flags/feature-flag-loader.js +36 -25
- package/dist/feature-flags/feature-flag-loader.js.map +1 -1
- package/dist/http/encore.d.ts +191 -0
- package/dist/http/encore.d.ts.map +1 -0
- package/dist/http/encore.js +3 -0
- package/dist/http/encore.js.map +1 -0
- package/dist/http/index.d.ts +1 -3
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +1 -3
- package/dist/http/index.js.map +1 -1
- package/dist/http/middlewares/apply-default-filters.d.ts +2 -2
- package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-default-filters.js +8 -6
- package/dist/http/middlewares/apply-default-filters.js.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.d.ts +2 -2
- package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -1
- package/dist/http/middlewares/apply-params-as-filters.js +7 -4
- package/dist/http/middlewares/apply-params-as-filters.js.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.d.ts +2 -2
- package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -1
- package/dist/http/middlewares/authenticate-middleware.js +25 -22
- package/dist/http/middlewares/authenticate-middleware.js.map +1 -1
- package/dist/http/middlewares/clear-filters-by-key.d.ts +2 -2
- package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -1
- package/dist/http/middlewares/clear-filters-by-key.js +2 -2
- package/dist/http/middlewares/clear-filters-by-key.js.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts +2 -2
- package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -1
- package/dist/http/middlewares/ensure-publishable-api-key.js +7 -5
- package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -1
- package/dist/http/middlewares/error-handler.d.ts +2 -3
- package/dist/http/middlewares/error-handler.d.ts.map +1 -1
- package/dist/http/middlewares/error-handler.js +6 -3
- package/dist/http/middlewares/error-handler.js.map +1 -1
- package/dist/http/middlewares/set-context.d.ts +2 -2
- package/dist/http/middlewares/set-context.d.ts.map +1 -1
- package/dist/http/middlewares/set-context.js +4 -4
- package/dist/http/middlewares/set-context.js.map +1 -1
- package/dist/http/types.d.ts +41 -31
- package/dist/http/types.d.ts.map +1 -1
- package/dist/http/types.js.map +1 -1
- package/dist/http/utils/http-compression.d.ts +1 -4
- package/dist/http/utils/http-compression.d.ts.map +1 -1
- package/dist/http/utils/http-compression.js +35 -30
- package/dist/http/utils/http-compression.js.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.d.ts +2 -2
- package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -1
- package/dist/http/utils/maybe-apply-link-filter.js +7 -6
- package/dist/http/utils/maybe-apply-link-filter.js.map +1 -1
- package/dist/http/utils/refetch-entities.d.ts +2 -2
- package/dist/http/utils/refetch-entities.d.ts.map +1 -1
- package/dist/http/utils/refetch-entities.js.map +1 -1
- package/dist/http/utils/unless-path.d.ts +4 -4
- package/dist/http/utils/unless-path.d.ts.map +1 -1
- package/dist/http/utils/unless-path.js +20 -11
- package/dist/http/utils/unless-path.js.map +1 -1
- package/dist/http/utils/validate-body.d.ts +1 -4
- package/dist/http/utils/validate-body.d.ts.map +1 -1
- package/dist/http/utils/validate-body.js +31 -20
- package/dist/http/utils/validate-body.js.map +1 -1
- package/dist/http/utils/validate-query.d.ts +9 -4
- package/dist/http/utils/validate-query.d.ts.map +1 -1
- package/dist/http/utils/validate-query.js +63 -20
- package/dist/http/utils/validate-query.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs/job-loader.d.ts +12 -4
- package/dist/jobs/job-loader.d.ts.map +1 -1
- package/dist/jobs/job-loader.js +56 -38
- package/dist/jobs/job-loader.js.map +1 -1
- package/dist/link-modules-sdk/index.d.ts +2 -0
- package/dist/link-modules-sdk/index.d.ts.map +1 -0
- package/dist/link-modules-sdk/index.js +18 -0
- package/dist/link-modules-sdk/index.js.map +1 -0
- package/dist/loader.d.ts +24 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +104 -0
- package/dist/loader.js.map +1 -0
- package/dist/mikro-orm-cli/bin.js +0 -0
- package/dist/subscribers/subscriber-loader.d.ts +15 -1
- package/dist/subscribers/subscriber-loader.d.ts.map +1 -1
- package/dist/subscribers/subscriber-loader.js +44 -17
- package/dist/subscribers/subscriber-loader.js.map +1 -1
- package/dist/types/container.d.ts +2 -23
- package/dist/types/container.d.ts.map +1 -1
- package/dist/zod/zod-helpers.js +1 -1
- package/dist/zod/zod-helpers.js.map +1 -1
- package/package.json +12 -9
- package/dist/http/express-loader.d.ts +0 -8
- package/dist/http/express-loader.d.ts.map +0 -1
- package/dist/http/express-loader.js +0 -85
- package/dist/http/express-loader.js.map +0 -1
- package/dist/http/router.d.ts +0 -100
- package/dist/http/router.d.ts.map +0 -1
- package/dist/http/router.js +0 -764
- package/dist/http/router.js.map +0 -1
- package/dist/http/utils/define-middlewares.d.ts +0 -18
- package/dist/http/utils/define-middlewares.d.ts.map +0 -1
- package/dist/http/utils/define-middlewares.js +0 -40
- package/dist/http/utils/define-middlewares.js.map +0 -1
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
// import compression from "compression"
|
|
3
|
+
// import type { ConfigModule } from "@etohq/types"
|
|
4
|
+
// import { ContainerRegistrationKeys } from "@etohq/utils"
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
6
|
+
// import { HttpCompressionOptions, ProjectConfigOptions } from "../../config"
|
|
7
|
+
// import type { EtoRequest, EtoResponse } from "../types"
|
|
8
|
+
// export function shouldCompressResponse(
|
|
9
|
+
// req: EtoRequest,
|
|
10
|
+
// res: EtoResponse
|
|
11
|
+
// ) {
|
|
12
|
+
// const { projectConfig } = req.scope.resolve<ConfigModule>(
|
|
13
|
+
// ContainerRegistrationKeys.CONFIG_MODULE
|
|
14
|
+
// )
|
|
15
|
+
// const { enabled } = compressionOptions(projectConfig)
|
|
16
|
+
// if (!enabled) {
|
|
17
|
+
// return false
|
|
18
|
+
// }
|
|
19
|
+
// if (req.headers["x-no-compression"]) {
|
|
20
|
+
// // don't compress responses with this request header
|
|
21
|
+
// return false
|
|
22
|
+
// }
|
|
23
|
+
// // fallback to standard filter function
|
|
24
|
+
// return compression.filter(req, res)
|
|
25
|
+
// }
|
|
26
|
+
// export function compressionOptions(
|
|
27
|
+
// config: ProjectConfigOptions
|
|
28
|
+
// ): HttpCompressionOptions {
|
|
29
|
+
// const responseCompressionOptions = config.http.compression ?? {}
|
|
30
|
+
// responseCompressionOptions.enabled =
|
|
31
|
+
// responseCompressionOptions.enabled ?? false
|
|
32
|
+
// responseCompressionOptions.level = responseCompressionOptions.level ?? 6
|
|
33
|
+
// responseCompressionOptions.memLevel = responseCompressionOptions.memLevel ?? 8
|
|
34
|
+
// responseCompressionOptions.threshold =
|
|
35
|
+
// responseCompressionOptions.threshold ?? 1024
|
|
36
|
+
// return responseCompressionOptions
|
|
37
|
+
// }
|
|
33
38
|
//# sourceMappingURL=http-compression.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-compression.js","sourceRoot":"","sources":["../../../src/http/utils/http-compression.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-compression.js","sourceRoot":"","sources":["../../../src/http/utils/http-compression.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,mDAAmD;AACnD,2DAA2D;;AAE3D,8EAA8E;AAC9E,0DAA0D;AAE1D,0CAA0C;AAC1C,qBAAqB;AACrB,qBAAqB;AACrB,MAAM;AACN,+DAA+D;AAC/D,8CAA8C;AAC9C,MAAM;AACN,0DAA0D;AAE1D,oBAAoB;AACpB,mBAAmB;AACnB,MAAM;AAEN,2CAA2C;AAC3C,2DAA2D;AAC3D,mBAAmB;AACnB,MAAM;AAEN,4CAA4C;AAC5C,wCAAwC;AACxC,IAAI;AAEJ,sCAAsC;AACtC,iCAAiC;AACjC,8BAA8B;AAC9B,qEAAqE;AAErE,yCAAyC;AACzC,kDAAkD;AAClD,6EAA6E;AAC7E,mFAAmF;AACnF,2CAA2C;AAC3C,mDAAmD;AAEnD,sCAAsC;AACtC,IAAI"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EtoMiddlewareNext, EtoMiddlewareRequest } from "../types";
|
|
2
2
|
export declare function maybeApplyLinkFilter({ entryPoint, resourceId, filterableField, filterByField, }: {
|
|
3
3
|
entryPoint: any;
|
|
4
4
|
resourceId: any;
|
|
5
5
|
filterableField: any;
|
|
6
6
|
filterByField?: string | undefined;
|
|
7
|
-
}): (req:
|
|
7
|
+
}): (req: EtoMiddlewareRequest, next: EtoMiddlewareNext) => Promise<import("..").HandlerResponse>;
|
|
8
8
|
//# sourceMappingURL=maybe-apply-link-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe-apply-link-filter.d.ts","sourceRoot":"","sources":["../../../src/http/utils/maybe-apply-link-filter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"maybe-apply-link-filter.d.ts","sourceRoot":"","sources":["../../../src/http/utils/maybe-apply-link-filter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAGlE,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAoB,GACrB;;;;;CAAA,SAEQ,oBAAoB,QACnB,iBAAiB,2CAiD1B"}
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.maybeApplyLinkFilter = maybeApplyLinkFilter;
|
|
4
4
|
const utils_1 = require("@etohq/utils");
|
|
5
|
+
const context_1 = require("../../context");
|
|
5
6
|
function maybeApplyLinkFilter({ entryPoint, resourceId, filterableField, filterByField = "id", }) {
|
|
6
|
-
return async function linkFilter(req,
|
|
7
|
-
const filterableFields = req.filterableFields;
|
|
7
|
+
return async function linkFilter(req, next) {
|
|
8
|
+
const filterableFields = req.data.filterableFields;
|
|
8
9
|
if (!filterableFields?.[filterableField]) {
|
|
9
|
-
return next();
|
|
10
|
+
return next(req);
|
|
10
11
|
}
|
|
11
12
|
const filterFields = filterableFields[filterableField];
|
|
12
13
|
const idsToFilterBy = Array.isArray(filterFields)
|
|
13
14
|
? filterFields
|
|
14
15
|
: [filterFields];
|
|
15
16
|
delete filterableFields[filterableField];
|
|
16
|
-
const remoteQuery = req.scope.resolve(utils_1.ContainerRegistrationKeys.REMOTE_QUERY);
|
|
17
|
+
const remoteQuery = (0, context_1.reqContext)(req.requestMeta).scope.resolve(utils_1.ContainerRegistrationKeys.REMOTE_QUERY);
|
|
17
18
|
const queryObject = (0, utils_1.remoteQueryObjectFromString)({
|
|
18
19
|
entryPoint,
|
|
19
20
|
fields: [resourceId],
|
|
@@ -30,8 +31,8 @@ function maybeApplyLinkFilter({ entryPoint, resourceId, filterableField, filterB
|
|
|
30
31
|
else {
|
|
31
32
|
filterableFields[filterByField] = resources.map((p) => p[resourceId]);
|
|
32
33
|
}
|
|
33
|
-
req.filterableFields = transformFilterableFields(filterableFields);
|
|
34
|
-
return next();
|
|
34
|
+
req.data.filterableFields = transformFilterableFields(filterableFields);
|
|
35
|
+
return next(req);
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe-apply-link-filter.js","sourceRoot":"","sources":["../../../src/http/utils/maybe-apply-link-filter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"maybe-apply-link-filter.js","sourceRoot":"","sources":["../../../src/http/utils/maybe-apply-link-filter.ts"],"names":[],"mappings":";;AAQA,oDAyDC;AAjED,wCAIqB;AAErB,2CAA0C;AAE1C,SAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,UAAU,EACV,eA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-
export declare const refetchEntities: (entryPoint: string, idOrFilter: string | object, scope: EtoContainer, fields: string[], pagination?:
|
|
2
|
+
import { EtoRequestContext } from "../types";
|
|
3
|
+
export declare const refetchEntities: (entryPoint: string, idOrFilter: string | object, scope: EtoContainer, fields: string[], pagination?: EtoRequestContext["queryConfig"]["pagination"]) => Promise<any>;
|
|
4
4
|
export declare const refetchEntity: (entryPoint: string, idOrFilter: string | object, scope: EtoContainer, fields: string[]) => Promise<any>;
|
|
5
5
|
//# sourceMappingURL=refetch-entities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refetch-entities.d.ts","sourceRoot":"","sources":["../../../src/http/utils/refetch-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAM3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"refetch-entities.d.ts","sourceRoot":"","sources":["../../../src/http/utils/refetch-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAM3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C,eAAO,MAAM,eAAe,eACd,MAAM,cACN,MAAM,GAAG,MAAM,SACpB,YAAY,UACX,MAAM,EAAE,eACH,iBAAiB,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,iBAuB5D,CAAA;AAED,eAAO,MAAM,aAAa,eACZ,MAAM,cACN,MAAM,GAAG,MAAM,SACpB,YAAY,UACX,MAAM,EAAE,iBAKjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refetch-entities.js","sourceRoot":"","sources":["../../../src/http/utils/refetch-entities.ts"],"names":[],"mappings":";;;AACA,wCAIqB;AAGd,MAAM,eAAe,GAAG,KAAK,EAClC,UAAkB,EAClB,UAA2B,EAC3B,KAAmB,EACnB,MAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"refetch-entities.js","sourceRoot":"","sources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toMiddlewareFn, EtoMiddlewareOptions } from "../types";
|
|
2
2
|
/**
|
|
3
|
-
* Due to how our route loader works, where
|
|
3
|
+
* Due to how our encore route loader works, we are using targeting and path where possible, encore load all middlewares group by targets before routes, and unless will enable skip based on paths when path specified.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* This function allows us to skip middlewares for particular routes
|
|
6
|
+
* This function allows us to skip middlewares for particular routes in a target.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const etoMiddleware: (options: EtoMiddlewareOptions, middleware: EtoMiddlewareFn) => EtoEncoreMiddleware;
|
|
9
9
|
//# sourceMappingURL=unless-path.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unless-path.d.ts","sourceRoot":"","sources":["../../../src/http/utils/unless-path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unless-path.d.ts","sourceRoot":"","sources":["../../../src/http/utils/unless-path.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAEf,oBAAoB,EAErB,MAAM,UAAU,CAAA;AAIjB;;GAEG;AACH;;GAEG;AAEH,eAAO,MAAM,aAAa,YACf,oBAAoB,cACjB,eAAe,KAC1B,mBAyBF,CAAA"}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.etoMiddleware = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Due to how our route loader works, where
|
|
5
|
+
* Due to how our encore route loader works, we are using targeting and path where possible, encore load all middlewares group by targets before routes, and unless will enable skip based on paths when path specified.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* This function allows us to skip middlewares for particular routes
|
|
8
|
+
* This function allows us to skip middlewares for particular routes in a target.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const etoMiddleware = (options, middleware) => {
|
|
11
|
+
// Create the middleware function that will be returned
|
|
12
|
+
const etoMiddleware = async (req, next) => {
|
|
13
|
+
const requestMeta = req.requestMeta;
|
|
14
|
+
// Check path condition
|
|
15
|
+
if (options.onPath &&
|
|
16
|
+
requestMeta &&
|
|
17
|
+
options.onPath.test(requestMeta.path)) {
|
|
18
|
+
return next(req);
|
|
19
|
+
}
|
|
20
|
+
// Execute the original middleware
|
|
21
|
+
return middleware(req, next);
|
|
22
|
+
};
|
|
23
|
+
// Attach options to the middleware function
|
|
24
|
+
etoMiddleware.options = options;
|
|
25
|
+
return etoMiddleware;
|
|
17
26
|
};
|
|
18
|
-
exports.
|
|
27
|
+
exports.etoMiddleware = etoMiddleware;
|
|
19
28
|
//# sourceMappingURL=unless-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unless-path.js","sourceRoot":"","sources":["../../../src/http/utils/unless-path.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"unless-path.js","sourceRoot":"","sources":["../../../src/http/utils/unless-path.ts"],"names":[],"mappings":";;;AAWA;;GAEG;AACH;;GAEG;AAEI,MAAM,aAAa,GAAG,CAC3B,OAA6B,EAC7B,UAA2B,EACN,EAAE;IACvB,uDAAuD;IACvD,MAAM,aAAa,GAAwB,KAAK,EAC9C,GAAyB,EACzB,IAAuB,EACvB,EAAE;QAEF,MAAM,WAAW,GAAG,GAAG,CAAC,WAA0B,CAAA;QAClD,uBAAuB;QACvB,IACE,OAAO,CAAC,MAAM;YACd,WAAW;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EACrC,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;QAED,kCAAkC;QAClC,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC,CAAA;IAED,4CAA4C;IAC5C,aAAa,CAAC,OAAO,GAAG,OAAO,CAAA;IAE/B,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AA5BY,QAAA,aAAa,iBA4BzB"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { NextFunction } from "express";
|
|
3
|
-
import { EtoRequest, EtoResponse } from "../types";
|
|
4
|
-
export declare function validateAndTransformBody(zodSchema: z.ZodObject<any, any> | ((customSchema?: z.ZodOptional<z.ZodNullable<z.ZodObject<any, any>>>) => z.ZodObject<any, any> | z.ZodEffects<any, any>)): (req: EtoRequest, res: EtoResponse, next: NextFunction) => Promise<void>;
|
|
1
|
+
export {};
|
|
5
2
|
//# sourceMappingURL=validate-body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-body.d.ts","sourceRoot":"","sources":["../../../src/http/utils/validate-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-body.d.ts","sourceRoot":"","sources":["../../../src/http/utils/validate-body.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// there is no need for this anymore encore does this alreaady automatically.
|
|
3
|
+
// export function validateAndTransformBody(
|
|
4
|
+
// zodSchema:
|
|
5
|
+
// | z.ZodObject<any, any>
|
|
6
|
+
// | ((
|
|
7
|
+
// customSchema?: z.ZodOptional<z.ZodNullable<z.ZodObject<any, any>>>
|
|
8
|
+
// ) => z.ZodObject<any, any> | z.ZodEffects<any, any>)
|
|
9
|
+
// ): (
|
|
10
|
+
// req: EtoRequest,
|
|
11
|
+
// res: EtoResponse,
|
|
12
|
+
// next: NextFunction
|
|
13
|
+
// ) => Promise<void> {
|
|
14
|
+
// return async function validateBody(
|
|
15
|
+
// req: EtoRequest,
|
|
16
|
+
// _: EtoResponse,
|
|
17
|
+
// next: NextFunction
|
|
18
|
+
// ) {
|
|
19
|
+
// try {
|
|
20
|
+
// let schema: z.ZodObject<any, any> | z.ZodEffects<any, any>
|
|
21
|
+
// if (typeof zodSchema === "function") {
|
|
22
|
+
// schema = zodSchema(req.additionalDataValidator)
|
|
23
|
+
// } else {
|
|
24
|
+
// schema = zodSchema
|
|
25
|
+
// }
|
|
2
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
schema = zodSchema(req.additionalDataValidator);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
schema = zodSchema;
|
|
14
|
-
}
|
|
15
|
-
req.validatedBody = await (0, zod_helpers_1.zodValidator)(schema, req.body);
|
|
16
|
-
next();
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
next(e);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
27
|
+
// req.validatedBody = await zodValidator(schema, req.body)
|
|
28
|
+
// next()
|
|
29
|
+
// } catch (e) {
|
|
30
|
+
// next(e)
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
23
34
|
//# sourceMappingURL=validate-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-body.js","sourceRoot":"","sources":["../../../src/http/utils/validate-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-body.js","sourceRoot":"","sources":["../../../src/http/utils/validate-body.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,4CAA4C;AAC5C,eAAe;AACf,8BAA8B;AAC9B,WAAW;AACX,6EAA6E;AAC7E,6DAA6D;AAC7D,OAAO;AACP,qBAAqB;AACrB,sBAAsB;AACtB,uBAAuB;AACvB,uBAAuB;AACvB,wCAAwC;AACxC,uBAAuB;AACvB,sBAAsB;AACtB,yBAAyB;AACzB,QAAQ;AACR,YAAY;AACZ,mEAAmE;AACnE,+CAA+C;AAC/C,0DAA0D;AAC1D,iBAAiB;AACjB,6BAA6B;AAC7B,UAAU;;AAEV,iEAAiE;AACjE,eAAe;AACf,oBAAoB;AACpB,gBAAgB;AAChB,QAAQ;AACR,MAAM;AACN,IAAI"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { BaseEntity, QueryConfig } from "@etohq/types";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { EtoEncoreMiddleware } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Normalize an input query, especially from array like query params to an array type
|
|
5
|
+
* e.g: /admin/orders/?fields[]=id,status,cart_id becomes { fields: ["id", "status", "cart_id"] }
|
|
6
|
+
*
|
|
7
|
+
* We only support up to 2 levels of depth for query params in order to have a somewhat readable query param, and limit possible performance issues
|
|
8
|
+
*/
|
|
9
|
+
export declare const normalizeQuery: (query: any) => {};
|
|
10
|
+
export declare function transformQuery<TEntity extends BaseEntity>(queryConfig: QueryConfig<TEntity>): EtoEncoreMiddleware;
|
|
6
11
|
//# sourceMappingURL=validate-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-query.d.ts","sourceRoot":"","sources":["../../../src/http/utils/validate-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"validate-query.d.ts","sourceRoot":"","sources":["../../../src/http/utils/validate-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAA;AAS1E,OAAO,EACL,mBAAmB,EAIpB,MAAM,UAAU,CAAA;AAGjB;;;;;GAKG;AAIH,eAAO,MAAM,cAAc,UAAW,GAAG,OA6BxC,CAAA;AAwDD,wBAAgB,cAAc,CAAC,OAAO,SAAS,UAAU,EACvD,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,GAChC,mBAAmB,CAwCrB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.normalizeQuery = void 0;
|
|
4
|
+
exports.transformQuery = transformQuery;
|
|
4
5
|
const utils_1 = require("@etohq/utils");
|
|
5
6
|
const lodash_1 = require("lodash");
|
|
6
|
-
const
|
|
7
|
+
const error_1 = require("../../error");
|
|
7
8
|
const get_query_config_1 = require("./get-query-config");
|
|
8
9
|
/**
|
|
9
10
|
* Normalize an input query, especially from array like query params to an array type
|
|
@@ -11,8 +12,9 @@ const get_query_config_1 = require("./get-query-config");
|
|
|
11
12
|
*
|
|
12
13
|
* We only support up to 2 levels of depth for query params in order to have a somewhat readable query param, and limit possible performance issues
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
// todo see if we still need this, the goal is to dispose this... moving normalization to app layer (which might also means moving moving transform logic to a function generator waiting for props or moove it to app layer) because we need to use encore first class.
|
|
16
|
+
const normalizeQuery = (query) => {
|
|
17
|
+
return Object.entries(query).reduce((acc, [key, val]) => {
|
|
16
18
|
let normalizedValue = val;
|
|
17
19
|
if (Array.isArray(val) && val.length === 1 && typeof val[0] === "string") {
|
|
18
20
|
normalizedValue = val[0].split(",");
|
|
@@ -36,6 +38,7 @@ const normalizeQuery = (req) => {
|
|
|
36
38
|
return acc;
|
|
37
39
|
}, {});
|
|
38
40
|
};
|
|
41
|
+
exports.normalizeQuery = normalizeQuery;
|
|
39
42
|
/**
|
|
40
43
|
* Omit the non filterable config from the validated object
|
|
41
44
|
* @param obj
|
|
@@ -44,18 +47,59 @@ const getFilterableFields = (obj) => {
|
|
|
44
47
|
const result = (0, lodash_1.omit)(obj, ["limit", "offset", "fields", "order"]);
|
|
45
48
|
return (0, utils_1.removeUndefinedProperties)(result);
|
|
46
49
|
};
|
|
47
|
-
function
|
|
48
|
-
|
|
50
|
+
// export function transformQuery<TEntity extends BaseEntity>(
|
|
51
|
+
// zodSchema: z.ZodObject<any, any> | z.ZodEffects<any, any>,
|
|
52
|
+
// queryConfig: QueryConfig<TEntity>
|
|
53
|
+
// ): (req: EtoRequest, res: EtoResponse, next: Next) => Promise<void> {
|
|
54
|
+
// return async function validateQuery(
|
|
55
|
+
// req: EtoRequest,
|
|
56
|
+
// _: EtoResponse,
|
|
57
|
+
// next: Next
|
|
58
|
+
// ) {
|
|
59
|
+
// try {
|
|
60
|
+
// const restricted = req.restrictedFields?.list()
|
|
61
|
+
// const allowed = queryConfig.allowed ?? []
|
|
62
|
+
// // If any custom allowed fields are set, we add them to the allowed list along side the one configured in the query config if any
|
|
63
|
+
// if (req.allowed?.length) {
|
|
64
|
+
// allowed.push(...req.allowed)
|
|
65
|
+
// }
|
|
66
|
+
// delete req.allowed
|
|
67
|
+
// const query = normalizeQuery(req)
|
|
68
|
+
// const validated = await zodValidator(zodSchema, query)
|
|
69
|
+
// const cnf = queryConfig.isList
|
|
70
|
+
// ? prepareListQuery(validated, { ...queryConfig, allowed, restricted })
|
|
71
|
+
// : prepareRetrieveQuery(validated, {
|
|
72
|
+
// ...queryConfig,
|
|
73
|
+
// allowed,
|
|
74
|
+
// restricted,
|
|
75
|
+
// })
|
|
76
|
+
// req.validatedQuery = validated
|
|
77
|
+
// req.filterableFields = getFilterableFields(req.validatedQuery)
|
|
78
|
+
// req.queryConfig = cnf.remoteQueryConfig as any
|
|
79
|
+
// req.remoteQueryConfig = req.queryConfig
|
|
80
|
+
// req.listConfig = (cnf as any).listConfig
|
|
81
|
+
// req.retrieveConfig = (cnf as any).retrieveConfig
|
|
82
|
+
// next(req)
|
|
83
|
+
// } catch (e) {
|
|
84
|
+
// next(e)
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
88
|
+
function transformQuery(queryConfig) {
|
|
89
|
+
return async function validateQuery(req, next) {
|
|
90
|
+
// currentData
|
|
49
91
|
try {
|
|
50
|
-
const restricted = req.restrictedFields?.list();
|
|
92
|
+
const restricted = req.data.restrictedFields?.list();
|
|
51
93
|
const allowed = queryConfig.allowed ?? [];
|
|
52
94
|
// If any custom allowed fields are set, we add them to the allowed list along side the one configured in the query config if any
|
|
53
|
-
if (req.allowed?.length) {
|
|
54
|
-
allowed.push(...req.allowed);
|
|
95
|
+
if (req.data.allowed?.length) {
|
|
96
|
+
allowed.push(...req.data.allowed);
|
|
55
97
|
}
|
|
56
|
-
delete req.allowed;
|
|
57
|
-
const
|
|
58
|
-
const validated =
|
|
98
|
+
delete req.data.allowed;
|
|
99
|
+
const currentRequest = req?.requestMeta || {};
|
|
100
|
+
const validated = currentRequest.parsedPayload;
|
|
101
|
+
// const query = normalizeQuery(currentRequest.parsedPayload)
|
|
102
|
+
// const validated = await zodValidator(zodSchema, query)
|
|
59
103
|
const cnf = queryConfig.isList
|
|
60
104
|
? (0, get_query_config_1.prepareListQuery)(validated, { ...queryConfig, allowed, restricted })
|
|
61
105
|
: (0, get_query_config_1.prepareRetrieveQuery)(validated, {
|
|
@@ -63,16 +107,15 @@ function validateAndTransformQuery(zodSchema, queryConfig) {
|
|
|
63
107
|
allowed,
|
|
64
108
|
restricted,
|
|
65
109
|
});
|
|
66
|
-
req.validatedQuery = validated;
|
|
67
|
-
req.filterableFields = getFilterableFields(req.validatedQuery);
|
|
68
|
-
req.queryConfig = cnf.remoteQueryConfig;
|
|
69
|
-
req.
|
|
70
|
-
req.
|
|
71
|
-
req
|
|
72
|
-
next();
|
|
110
|
+
req.data.validatedQuery = validated;
|
|
111
|
+
req.data.filterableFields = getFilterableFields(req.data.validatedQuery);
|
|
112
|
+
req.data.queryConfig = cnf.remoteQueryConfig;
|
|
113
|
+
req.data.listConfig = cnf.listConfig;
|
|
114
|
+
req.data.retrieveConfig = cnf.retrieveConfig;
|
|
115
|
+
return next(req);
|
|
73
116
|
}
|
|
74
117
|
catch (e) {
|
|
75
|
-
|
|
118
|
+
throw error_1.APIError.invalidArgument(`bad request`);
|
|
76
119
|
}
|
|
77
120
|
};
|
|
78
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-query.js","sourceRoot":"","sources":["../../../src/http/utils/validate-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-query.js","sourceRoot":"","sources":["../../../src/http/utils/validate-query.ts"],"names":[],"mappings":";;;AA+GA,wCA0CC;AAxJD,wCAAkE;AAClE,mCAA6B;AAK7B,uCAAsC;AAQtC,yDAA2E;AAE3E;;;;;GAKG;AAEH,wQAAwQ;AAEjQ,MAAM,cAAc,GAAG,CAAC,KAAU,EAAE,EAAE;IAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QACtD,IAAI,eAAe,GAAG,GAAG,CAAA;QACzB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACzE,eAAe,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACrC,CAAC;QAED,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACjD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,gBAAQ,CAChB,gBAAQ,CAAC,KAAK,CAAC,gBAAgB,EAC/B,yCAAyC,GAAG,EAAE,CAC/C,CAAA;YACH,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjB,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;YAClB,CAAC;YACD,GAAG,C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aAAa,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export * from "./subscribers";
|
|
|
11
11
|
export * from "./workflows";
|
|
12
12
|
export * from "./telemetry";
|
|
13
13
|
export * from "./zod";
|
|
14
|
+
export * from "./eto";
|
|
15
|
+
export * from "./loader";
|
|
16
|
+
export * from "./context";
|
|
17
|
+
export * from "./error";
|
|
14
18
|
export declare const ETO_CLI_PATH: string;
|
|
15
19
|
export { Query } from "@etohq/modules-sdk";
|
|
16
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AAEvB,eAAO,MAAM,YAAY,QAAgC,CAAA;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,10 @@ __exportStar(require("./subscribers"), exports);
|
|
|
28
28
|
__exportStar(require("./workflows"), exports);
|
|
29
29
|
__exportStar(require("./telemetry"), exports);
|
|
30
30
|
__exportStar(require("./zod"), exports);
|
|
31
|
+
__exportStar(require("./eto"), exports);
|
|
32
|
+
__exportStar(require("./loader"), exports);
|
|
33
|
+
__exportStar(require("./context"), exports);
|
|
34
|
+
__exportStar(require("./error"), exports);
|
|
31
35
|
exports.ETO_CLI_PATH = require.resolve("@etohq/cli");
|
|
32
36
|
var modules_sdk_1 = require("@etohq/modules-sdk");
|
|
33
37
|
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return modules_sdk_1.Query; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,8CAA2B;AAC3B,6CAA0B;AAC1B,kDAA+B;AAC/B,yCAAsB;AACtB,yCAAsB;AACtB,0CAAuB;AACvB,2CAAwB;AACxB,mDAAgC;AAChC,gDAA6B;AAC7B,8CAA2B;AAC3B,8CAA2B;AAC3B,wCAAqB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,8CAA2B;AAC3B,6CAA0B;AAC1B,kDAA+B;AAC/B,yCAAsB;AACtB,yCAAsB;AACtB,0CAAuB;AACvB,2CAAwB;AACxB,mDAAgC;AAChC,gDAA6B;AAC7B,8CAA2B;AAC3B,8CAA2B;AAC3B,wCAAqB;AACrB,wCAAqB;AACrB,2CAAwB;AACxB,4CAAyB;AACzB,0CAAuB;AAEV,QAAA,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;AAEzD,kDAA0C;AAAjC,oGAAA,KAAK,OAAA"}
|
|
@@ -6,9 +6,19 @@ type CronJobConfig = {
|
|
|
6
6
|
numberOfExecutions?: SchedulerOptions["numberOfExecutions"];
|
|
7
7
|
};
|
|
8
8
|
type CronJobHandler = (container: EtoContainer) => Promise<any>;
|
|
9
|
+
type LoaderInput = {
|
|
10
|
+
sourceDir?: string | string[];
|
|
11
|
+
jobs?: Array<{
|
|
12
|
+
path: string;
|
|
13
|
+
module: {
|
|
14
|
+
default: CronJobHandler;
|
|
15
|
+
config: CronJobConfig;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
9
19
|
export declare class JobLoader {
|
|
10
20
|
#private;
|
|
11
|
-
constructor(sourceDir
|
|
21
|
+
constructor({ sourceDir, jobs }: LoaderInput);
|
|
12
22
|
/**
|
|
13
23
|
* Validate cron job configuration
|
|
14
24
|
* @param config
|
|
@@ -28,9 +38,7 @@ export declare class JobLoader {
|
|
|
28
38
|
config: CronJobConfig;
|
|
29
39
|
handler: CronJobHandler;
|
|
30
40
|
}): void;
|
|
31
|
-
|
|
32
|
-
* Load cron jobs from one or multiple source paths
|
|
33
|
-
*/
|
|
41
|
+
private loadFromDirectory;
|
|
34
42
|
load(): Promise<void>;
|
|
35
43
|
}
|
|
36
44
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job-loader.d.ts","sourceRoot":"","sources":["../../src/jobs/job-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAkB3C,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,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