@navios/core 1.0.0 → 2.0.0-alpha.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/CHANGELOG.md +97 -11
- package/README.md +67 -220
- package/lib/async-context-6pdlnNLA.d.mts +237 -0
- package/lib/async-context-6pdlnNLA.d.mts.map +1 -0
- package/lib/async-context-Dqk7pE-D.d.cts +237 -0
- package/lib/async-context-Dqk7pE-D.d.cts.map +1 -0
- package/lib/attribute-factory-B3VuYnp7.d.cts +70 -0
- package/lib/attribute-factory-B3VuYnp7.d.cts.map +1 -0
- package/lib/attribute-factory-mKOXoVnV.d.mts +70 -0
- package/lib/attribute-factory-mKOXoVnV.d.mts.map +1 -0
- package/lib/attribute-value-CjX9ZkLq.cjs +172 -0
- package/lib/attribute-value-CjX9ZkLq.cjs.map +1 -0
- package/lib/attribute-value-DMEA255r.mjs +119 -0
- package/lib/attribute-value-DMEA255r.mjs.map +1 -0
- package/lib/basic-execution-context-CeGuhMOz.mjs +246 -0
- package/lib/basic-execution-context-CeGuhMOz.mjs.map +1 -0
- package/lib/basic-execution-context-DSk5MNtc.cjs +281 -0
- package/lib/basic-execution-context-DSk5MNtc.cjs.map +1 -0
- package/lib/execution-context-BPD3FeFb.d.mts +71 -0
- package/lib/execution-context-BPD3FeFb.d.mts.map +1 -0
- package/lib/execution-context-BTJdHhbf.d.cts +71 -0
- package/lib/execution-context-BTJdHhbf.d.cts.map +1 -0
- package/lib/execution-context-token-BXUKB2hf.cjs +112 -0
- package/lib/execution-context-token-BXUKB2hf.cjs.map +1 -0
- package/lib/execution-context-token-CrXmTvk2.mjs +77 -0
- package/lib/execution-context-token-CrXmTvk2.mjs.map +1 -0
- package/lib/index.cjs +1687 -4409
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +838 -3
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +838 -3
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +1573 -4219
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +72 -371
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +42 -382
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +41 -382
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +51 -345
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/module-Bha7GER_.mjs +135 -0
- package/lib/module-Bha7GER_.mjs.map +1 -0
- package/lib/module-DZewk_2r.cjs +164 -0
- package/lib/module-DZewk_2r.cjs.map +1 -0
- package/lib/module-graph-DCP9MHG0.cjs +147 -0
- package/lib/module-graph-DCP9MHG0.cjs.map +1 -0
- package/lib/module-graph-xvVEykFM.mjs +142 -0
- package/lib/module-graph-xvVEykFM.mjs.map +1 -0
- package/lib/module-metadata-C8S92seK.cjs +95 -0
- package/lib/module-metadata-C8S92seK.cjs.map +1 -0
- package/lib/module-metadata-k3RTt20x.mjs +66 -0
- package/lib/module-metadata-k3RTt20x.mjs.map +1 -0
- package/lib/module-options-Dmse0gii.d.mts +51 -0
- package/lib/module-options-Dmse0gii.d.mts.map +1 -0
- package/lib/module-options-IuDO-p8u.d.cts +51 -0
- package/lib/module-options-IuDO-p8u.d.cts.map +1 -0
- package/lib/testing/index.cjs +96 -414
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.d.cts +25 -385
- package/lib/testing/index.d.cts.map +1 -1
- package/lib/testing/index.d.mts +24 -385
- package/lib/testing/index.d.mts.map +1 -1
- package/lib/testing/index.mjs +94 -408
- package/lib/testing/index.mjs.map +1 -1
- package/lib/transport.cjs +25 -0
- package/lib/transport.d.cts +190 -0
- package/lib/transport.d.cts.map +1 -0
- package/lib/transport.d.mts +190 -0
- package/lib/transport.d.mts.map +1 -0
- package/lib/transport.mjs +7 -0
- package/package.json +37 -17
- package/docs/README.md +0 -316
- package/docs/adapters.md +0 -308
- package/docs/application-setup.md +0 -524
- package/docs/attributes.md +0 -689
- package/docs/controllers.md +0 -373
- package/docs/endpoints.md +0 -444
- package/docs/exceptions.md +0 -352
- package/docs/guards.md +0 -550
- package/docs/legacy-compat.md +0 -356
- package/docs/modules.md +0 -377
- package/docs/quick-start.md +0 -290
- package/docs/services.md +0 -427
- package/docs/testing.md +0 -827
- package/lib/index-C0Sg16Eb.d.cts +0 -3365
- package/lib/index-C0Sg16Eb.d.cts.map +0 -1
- package/lib/index-DySQ6Dpd.d.mts +0 -3365
- package/lib/index-DySQ6Dpd.d.mts.map +0 -1
- package/lib/navios.factory-CO5MB_OK.cjs +0 -4125
- package/lib/navios.factory-CO5MB_OK.cjs.map +0 -1
- package/lib/navios.factory-D6Y94P9B.mjs +0 -3828
- package/lib/navios.factory-D6Y94P9B.mjs.map +0 -1
- package/lib/tokens-4J9sredA.mjs +0 -100
- package/lib/tokens-4J9sredA.mjs.map +0 -1
- package/lib/tokens-CWw9kyeD.cjs +0 -196
- package/lib/tokens-CWw9kyeD.cjs.map +0 -1
- package/lib/use-guards.decorator-BecoQSmE.mjs +0 -339
- package/lib/use-guards.decorator-BecoQSmE.mjs.map +0 -1
- package/lib/use-guards.decorator-C4ml9XaT.cjs +0 -447
- package/lib/use-guards.decorator-C4ml9XaT.cjs.map +0 -1
- package/project.json +0 -66
- package/src/__tests__/attribute.factory.spec.mts +0 -300
- package/src/__tests__/config.service.spec.mts +0 -43
- package/src/__tests__/console-logger.service.spec.mts +0 -312
- package/src/__tests__/controller-resolver.spec.mts +0 -229
- package/src/__tests__/controller.spec.mts +0 -58
- package/src/__tests__/guard-runner.service.spec.mts +0 -399
- package/src/__tests__/logger.service.spec.mts +0 -147
- package/src/__tests__/responders.spec.mts +0 -340
- package/src/__tests__/testing-module.spec.mts +0 -459
- package/src/__tests__/unit-testing-module.spec.mts +0 -424
- package/src/attribute.factory.mts +0 -325
- package/src/config/config-service.interface.mts +0 -47
- package/src/config/config.provider.mts +0 -69
- package/src/config/config.service.mts +0 -176
- package/src/config/index.mts +0 -5
- package/src/config/types.mts +0 -58
- package/src/config/utils/helpers.mts +0 -23
- package/src/config/utils/index.mts +0 -1
- package/src/decorators/controller.decorator.mts +0 -81
- package/src/decorators/endpoint.decorator.mts +0 -181
- package/src/decorators/header.decorator.mts +0 -38
- package/src/decorators/http-code.decorator.mts +0 -38
- package/src/decorators/index.mts +0 -8
- package/src/decorators/module.decorator.mts +0 -106
- package/src/decorators/multipart.decorator.mts +0 -169
- package/src/decorators/stream.decorator.mts +0 -155
- package/src/decorators/use-guards.decorator.mts +0 -73
- package/src/exceptions/bad-request.exception.mts +0 -28
- package/src/exceptions/conflict.exception.mts +0 -31
- package/src/exceptions/forbidden.exception.mts +0 -30
- package/src/exceptions/http.exception.mts +0 -33
- package/src/exceptions/index.mts +0 -7
- package/src/exceptions/internal-server-error.exception.mts +0 -33
- package/src/exceptions/not-found.exception.mts +0 -33
- package/src/exceptions/unauthorized.exception.mts +0 -30
- package/src/factories/adapter.factory.mts +0 -20
- package/src/factories/endpoint-adapter.factory.mts +0 -21
- package/src/factories/http-adapter.factory.mts +0 -20
- package/src/factories/index.mts +0 -8
- package/src/factories/multipart-adapter.factory.mts +0 -21
- package/src/factories/reply.factory.mts +0 -21
- package/src/factories/request.factory.mts +0 -21
- package/src/factories/stream-adapter.factory.mts +0 -20
- package/src/factories/xml-stream-adapter.factory.mts +0 -20
- package/src/index.mts +0 -16
- package/src/interfaces/abstract-adapter.interface.mts +0 -32
- package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
- package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
- package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
- package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
- package/src/interfaces/adapter-environment.interface.mts +0 -74
- package/src/interfaces/can-activate.mts +0 -38
- package/src/interfaces/http-header.mts +0 -18
- package/src/interfaces/index.mts +0 -11
- package/src/interfaces/navios-module.mts +0 -28
- package/src/interfaces/plugin.interface.mts +0 -139
- package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
- package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
- package/src/legacy-compat/attribute.factory.mts +0 -351
- package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
- package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
- package/src/legacy-compat/decorators/header.decorator.mts +0 -43
- package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
- package/src/legacy-compat/decorators/index.mts +0 -11
- package/src/legacy-compat/decorators/module.decorator.mts +0 -37
- package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
- package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
- package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
- package/src/legacy-compat/index.mts +0 -57
- package/src/logger/README.md +0 -3
- package/src/logger/console-logger.service.mts +0 -714
- package/src/logger/index.mts +0 -6
- package/src/logger/log-levels.mts +0 -21
- package/src/logger/logger-service.interface.mts +0 -42
- package/src/logger/logger.service.mts +0 -113
- package/src/logger/logger.tokens.mts +0 -44
- package/src/logger/utils/cli-colors.util.mts +0 -17
- package/src/logger/utils/filter-log-levelts.util.mts +0 -29
- package/src/logger/utils/index.mts +0 -5
- package/src/logger/utils/is-log-level-enabled.mts +0 -33
- package/src/logger/utils/is-log-level.util.mts +0 -10
- package/src/logger/utils/shared.utils.mts +0 -51
- package/src/metadata/controller.metadata.mts +0 -72
- package/src/metadata/handler.metadata.mts +0 -80
- package/src/metadata/index.mts +0 -4
- package/src/metadata/module.metadata.mts +0 -108
- package/src/metadata/navios-managed.metadata.mts +0 -42
- package/src/navios.application.mts +0 -484
- package/src/navios.environment.mts +0 -42
- package/src/navios.factory.mts +0 -158
- package/src/responders/enums/framework-error.enum.mts +0 -38
- package/src/responders/enums/index.mts +0 -1
- package/src/responders/index.mts +0 -4
- package/src/responders/interfaces/error-responder.interface.mts +0 -42
- package/src/responders/interfaces/error-response.interface.mts +0 -22
- package/src/responders/interfaces/index.mts +0 -3
- package/src/responders/interfaces/problem-details.interface.mts +0 -34
- package/src/responders/services/error-response-producer.service.mts +0 -143
- package/src/responders/services/forbidden-responder.service.mts +0 -77
- package/src/responders/services/index.mts +0 -5
- package/src/responders/services/internal-server-error-responder.service.mts +0 -57
- package/src/responders/services/not-found-responder.service.mts +0 -76
- package/src/responders/services/validation-error-responder.service.mts +0 -78
- package/src/responders/tokens/index.mts +0 -1
- package/src/responders/tokens/responder.tokens.mts +0 -84
- package/src/services/abstract-handler-adapter.service.mts +0 -366
- package/src/services/guard-runner.service.mts +0 -152
- package/src/services/index.mts +0 -4
- package/src/services/instance-resolver.service.mts +0 -177
- package/src/services/module-loader.service.mts +0 -252
- package/src/stores/index.mts +0 -1
- package/src/stores/request-id.store.mts +0 -85
- package/src/testing/index.mts +0 -3
- package/src/testing/testing-module.mts +0 -393
- package/src/testing/unit-testing-module.mts +0 -298
- package/src/tokens/adapter.token.mts +0 -6
- package/src/tokens/endpoint-adapter.token.mts +0 -8
- package/src/tokens/execution-context.token.mts +0 -9
- package/src/tokens/http-adapter.token.mts +0 -8
- package/src/tokens/index.mts +0 -10
- package/src/tokens/multipart-adapter.token.mts +0 -8
- package/src/tokens/navios-options.token.mts +0 -6
- package/src/tokens/reply.token.mts +0 -3
- package/src/tokens/request.token.mts +0 -3
- package/src/tokens/stream-adapter.token.mts +0 -8
- package/src/tokens/xml-stream-adapter.token.mts +0 -8
- package/src/utils/adapter-supports.util.mts +0 -47
- package/src/utils/index.mts +0 -1
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -8
- package/tsconfig.spec.json +0 -15
- package/tsdown.config.mts +0 -35
- package/vitest.config.mts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-Bha7GER_.mjs","names":[],"sources":["../src/attributes/attribute-factory.mts","../src/metadata/attach-classes.mts","../src/guards/use-guards.mts","../src/interceptors/use-interceptors.mts","../src/modules/module.mts"],"sourcesContent":["import type { InferInput, InferOutput, StandardSchemaV1 } from '@navios/di'\n\nimport { classAttributes } from '../metadata/class-metadata.mjs'\nimport { memberMetadata } from '../metadata/member-metadata.mjs'\n\nimport type { HandlerInfo } from '../execution/execution-context.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AttributeContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The result of calling an attribute. It is a decorator for a module, a\n * controller, a handler method or a handler field, and it can also be passed\n * in `handler(endpoint, { attributes: [...] }, fn)`.\n */\nexport interface AttributeApplication {\n (target: any, context: AttributeContext): any\n readonly token: symbol\n readonly value: unknown\n}\n\nexport interface ClassAttribute {\n (): AttributeApplication\n readonly token: symbol\n}\n\nexport interface ClassSchemaAttribute<Schema extends StandardSchemaV1> {\n (value: InferInput<Schema>): AttributeApplication\n readonly token: symbol\n readonly schema: Schema\n}\n\nfunction apply(token: symbol, value: unknown): AttributeApplication {\n const decorator = (target: any, context: AttributeContext) => {\n if (context.kind === 'class') {\n classAttributes(context).set(token, value)\n } else if (context.kind === 'method' || context.kind === 'field') {\n if (typeof context.name !== 'string') {\n throw new Error('[Navios] Attributes cannot be applied to symbol-named members')\n }\n memberMetadata(context, context.name).attributes.set(token, value)\n } else {\n throw new Error('[Navios] Attributes can only be applied to classes, methods and fields')\n }\n return context.kind === 'field' ? undefined : target\n }\n return Object.assign(decorator, { token, value })\n}\n\n/**\n * What reading an attribute needs of it. An attribute of either factory, the\n * standard one or the one from `@navios/core/legacy-compat`, has this shape;\n * what calling it returns differs between the two and does not matter here.\n */\ninterface ReadableAttribute {\n readonly token: symbol\n readonly schema?: undefined\n}\n\ninterface ReadableSchemaAttribute<Schema extends StandardSchemaV1> {\n readonly token: symbol\n readonly schema: Schema\n}\n\ntype AttributeSource = HandlerInfo | { attributes: ReadonlyMap<symbol, unknown> }\n\nfunction layers(source: AttributeSource): ReadonlyMap<symbol, unknown>[] {\n const attributes = source.attributes\n if (attributes instanceof Map) {\n return [attributes]\n }\n const route = attributes as HandlerInfo['attributes']\n // Most specific first.\n return [route.handler, route.controller, route.module]\n}\n\n/**\n * Creates and reads attributes: typed metadata attached to modules,\n * controllers and handlers.\n *\n * ```ts\n * export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))\n * export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))\n *\n * if (AttributeFactory.has(Public, ctx.handler)) return true\n * const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null\n * ```\n */\nexport class AttributeFactory {\n static createAttribute(token: symbol): ClassAttribute\n static createAttribute<Schema extends StandardSchemaV1>(\n token: symbol,\n schema: Schema,\n ): ClassSchemaAttribute<Schema>\n static createAttribute(token: symbol, schema?: StandardSchemaV1): any {\n const attribute = (value?: unknown) => {\n if (!schema) {\n return apply(token, true)\n }\n const result = schema['~standard'].validate(value)\n if (result instanceof Promise) {\n result.catch(() => {})\n throw new Error(\n `[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`,\n )\n }\n if (result.issues) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${result.issues\n .map((issue) => issue.message)\n .join('; ')}`,\n )\n }\n return apply(token, result.value)\n }\n return Object.assign(attribute, schema ? { token, schema } : { token })\n }\n\n /**\n * The attribute's value for a handler: the handler's own, else the controller's,\n * else the module's. `null` when none has it.\n */\n static get(attribute: ReadableAttribute, source: AttributeSource): true | null\n static get<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema> | null\n static get(attribute: { token: symbol }, source: AttributeSource): unknown {\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n return layer.get(attribute.token)\n }\n }\n return null\n }\n\n /**\n * Every value of the attribute for a handler, most specific first.\n */\n static getAll(attribute: ReadableAttribute, source: AttributeSource): true[]\n static getAll<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema>[]\n static getAll(attribute: { token: symbol }, source: AttributeSource): unknown[] {\n const values: unknown[] = []\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n values.push(layer.get(attribute.token))\n }\n }\n return values\n }\n\n static has(attribute: { token: symbol }, source: AttributeSource): boolean {\n return layers(source).some((layer) => layer.has(attribute.token))\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport { classGuards, classInterceptors } from './class-metadata.mjs'\nimport { memberMetadata } from './member-metadata.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AnyMemberContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The decorator behind `@UseGuards` and `@UseInterceptors`: adds classes to\n * the list of a class or of one of its members.\n * @internal\n */\nexport function attachClasses(\n kind: 'guards' | 'interceptors',\n classes: ClassType[],\n name: string,\n): (target: any, context: AnyMemberContext) => any {\n return (target, context) => {\n if (context.kind === 'class') {\n const list = kind === 'guards' ? classGuards(context) : classInterceptors(context)\n for (const cls of classes) {\n if (!list.includes(cls)) {\n list.push(cls)\n }\n }\n return target\n }\n if (context.kind !== 'method' && context.kind !== 'field') {\n throw new Error(`[Navios] @${name} can only be used on classes, methods and fields.`)\n }\n if (typeof context.name !== 'string') {\n throw new Error(`[Navios] @${name} cannot be used on symbol-named members.`)\n }\n const list = memberMetadata(context, context.name)[kind]\n for (const cls of classes) {\n if (!list.includes(cls)) {\n list.push(cls)\n }\n }\n return context.kind === 'field' ? undefined : target\n }\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { GuardClass } from './guard.mjs'\n\n/**\n * Adds guards to a module, a controller or a handler. Guards run in the\n * order module, controller, handler, and within one level in the order given.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseGuards(...guards: GuardClass[]) {\n return attachClasses('guards', guards, 'UseGuards')\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { InterceptorClass } from './interceptor.mjs'\n\n/**\n * Adds interceptors to a module, a controller or a handler. The first one\n * given is the outermost. They run for what the guards let through, unlike the\n * interceptors of the application.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseInterceptors(...interceptors: InterceptorClass[]) {\n return attachClasses('interceptors', interceptors, 'UseInterceptors')\n}\n","import { InjectableScope, registerInjectable } from '@navios/di'\n\nimport type { ClassType } from '@navios/di'\n\nimport { applyAttributes } from '../attributes/attribute-value.mjs'\n\nimport { defineModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleOptions } from './module-options.mjs'\n\n/**\n * Marks a class as a module: a group of handlers with shared guards,\n * interceptors and attributes.\n */\nexport function Module(options: ModuleOptions = {}) {\n return <T extends ClassType>(target: T, context: ClassDecoratorContext): T => {\n if (context.kind !== 'class') {\n throw new Error('[Navios] @Module can only be used on classes.')\n }\n applyAttributes(defineModuleMetadata(target, context, options).attributes, options.attributes)\n registerInjectable(target, { scope: InjectableScope.Singleton })\n return target\n }\n}\n\n/**\n * Registers a class as a module without decorator syntax.\n */\nexport function registerModule<T extends ClassType>(target: T, options: ModuleOptions = {}): T {\n applyAttributes(\n defineModuleMetadata(target, { metadata: {} }, options).attributes,\n options.attributes,\n )\n registerInjectable(target, { scope: InjectableScope.Singleton })\n return target\n}\n"],"mappings":";;;;AAoCA,SAAS,MAAM,OAAe,OAAsC;CAClE,MAAM,aAAa,QAAa,YAA8B;EAC5D,IAAI,QAAQ,SAAS,SACnB,gBAAgB,OAAO,CAAC,CAAC,IAAI,OAAO,KAAK;OACpC,IAAI,QAAQ,SAAS,YAAY,QAAQ,SAAS,SAAS;GAChE,IAAI,OAAO,QAAQ,SAAS,UAC1B,MAAM,IAAI,MAAM,+DAA+D;GAEjF,eAAe,SAAS,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,OAAO,KAAK;EACnE,OACE,MAAM,IAAI,MAAM,wEAAwE;EAE1F,OAAO,QAAQ,SAAS,UAAU,KAAA,IAAY;CAChD;CACA,OAA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AU,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,YACxD,QAAQ,UACV;CACA,mBAAmB,QAAQ,EAAE,OAAO,gBAAgB,UAAU,CAAC;CAC/D,OAAO;AACT"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
const require_attribute_value = require("./attribute-value-CjX9ZkLq.cjs");
|
|
2
|
+
const require_module_metadata = require("./module-metadata-C8S92seK.cjs");
|
|
3
|
+
let _navios_di = require("@navios/di");
|
|
4
|
+
// src/attributes/attribute-factory.mts
|
|
5
|
+
function apply(token, value) {
|
|
6
|
+
const decorator = (target, context) => {
|
|
7
|
+
if (context.kind === "class") require_attribute_value.classAttributes(context).set(token, value);
|
|
8
|
+
else if (context.kind === "method" || context.kind === "field") {
|
|
9
|
+
if (typeof context.name !== "string") throw new Error("[Navios] Attributes cannot be applied to symbol-named members");
|
|
10
|
+
require_attribute_value.memberMetadata(context, context.name).attributes.set(token, value);
|
|
11
|
+
} else throw new Error("[Navios] Attributes can only be applied to classes, methods and fields");
|
|
12
|
+
return context.kind === "field" ? void 0 : target;
|
|
13
|
+
};
|
|
14
|
+
return Object.assign(decorator, {
|
|
15
|
+
token,
|
|
16
|
+
value
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function layers(source) {
|
|
20
|
+
const attributes = source.attributes;
|
|
21
|
+
if (attributes instanceof Map) return [attributes];
|
|
22
|
+
const route = attributes;
|
|
23
|
+
return [
|
|
24
|
+
route.handler,
|
|
25
|
+
route.controller,
|
|
26
|
+
route.module
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates and reads attributes: typed metadata attached to modules,
|
|
31
|
+
* controllers and handlers.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
|
|
35
|
+
* export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))
|
|
36
|
+
*
|
|
37
|
+
* if (AttributeFactory.has(Public, ctx.handler)) return true
|
|
38
|
+
* const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
var AttributeFactory = class {
|
|
42
|
+
static createAttribute(token, schema) {
|
|
43
|
+
const attribute = (value) => {
|
|
44
|
+
if (!schema) return apply(token, true);
|
|
45
|
+
const result = schema["~standard"].validate(value);
|
|
46
|
+
if (result instanceof Promise) {
|
|
47
|
+
result.catch(() => {});
|
|
48
|
+
throw new Error(`[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`);
|
|
49
|
+
}
|
|
50
|
+
if (result.issues) throw new Error(`[Navios] Invalid value for attribute ${token.toString()}: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
51
|
+
return apply(token, result.value);
|
|
52
|
+
};
|
|
53
|
+
return Object.assign(attribute, schema ? {
|
|
54
|
+
token,
|
|
55
|
+
schema
|
|
56
|
+
} : { token });
|
|
57
|
+
}
|
|
58
|
+
static get(attribute, source) {
|
|
59
|
+
for (const layer of layers(source)) if (layer.has(attribute.token)) return layer.get(attribute.token);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
static getAll(attribute, source) {
|
|
63
|
+
const values = [];
|
|
64
|
+
for (const layer of layers(source)) if (layer.has(attribute.token)) values.push(layer.get(attribute.token));
|
|
65
|
+
return values;
|
|
66
|
+
}
|
|
67
|
+
static has(attribute, source) {
|
|
68
|
+
return layers(source).some((layer) => layer.has(attribute.token));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
// src/metadata/attach-classes.mts
|
|
72
|
+
/**
|
|
73
|
+
* The decorator behind `@UseGuards` and `@UseInterceptors`: adds classes to
|
|
74
|
+
* the list of a class or of one of its members.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
function attachClasses(kind, classes, name) {
|
|
78
|
+
return (target, context) => {
|
|
79
|
+
if (context.kind === "class") {
|
|
80
|
+
const list = kind === "guards" ? require_attribute_value.classGuards(context) : require_attribute_value.classInterceptors(context);
|
|
81
|
+
for (const cls of classes) if (!list.includes(cls)) list.push(cls);
|
|
82
|
+
return target;
|
|
83
|
+
}
|
|
84
|
+
if (context.kind !== "method" && context.kind !== "field") throw new Error(`[Navios] @${name} can only be used on classes, methods and fields.`);
|
|
85
|
+
if (typeof context.name !== "string") throw new Error(`[Navios] @${name} cannot be used on symbol-named members.`);
|
|
86
|
+
const list = require_attribute_value.memberMetadata(context, context.name)[kind];
|
|
87
|
+
for (const cls of classes) if (!list.includes(cls)) list.push(cls);
|
|
88
|
+
return context.kind === "field" ? void 0 : target;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// src/guards/use-guards.mts
|
|
92
|
+
/**
|
|
93
|
+
* Adds guards to a module, a controller or a handler. Guards run in the
|
|
94
|
+
* order module, controller, handler, and within one level in the order given.
|
|
95
|
+
*
|
|
96
|
+
* On a class, place it above `@Controller` / `@Module`.
|
|
97
|
+
*/
|
|
98
|
+
function UseGuards(...guards) {
|
|
99
|
+
return attachClasses("guards", guards, "UseGuards");
|
|
100
|
+
}
|
|
101
|
+
// src/interceptors/use-interceptors.mts
|
|
102
|
+
/**
|
|
103
|
+
* Adds interceptors to a module, a controller or a handler. The first one
|
|
104
|
+
* given is the outermost. They run for what the guards let through, unlike the
|
|
105
|
+
* interceptors of the application.
|
|
106
|
+
*
|
|
107
|
+
* On a class, place it above `@Controller` / `@Module`.
|
|
108
|
+
*/
|
|
109
|
+
function UseInterceptors(...interceptors) {
|
|
110
|
+
return attachClasses("interceptors", interceptors, "UseInterceptors");
|
|
111
|
+
}
|
|
112
|
+
// src/modules/module.mts
|
|
113
|
+
/**
|
|
114
|
+
* Marks a class as a module: a group of handlers with shared guards,
|
|
115
|
+
* interceptors and attributes.
|
|
116
|
+
*/
|
|
117
|
+
function Module(options = {}) {
|
|
118
|
+
return (target, context) => {
|
|
119
|
+
if (context.kind !== "class") throw new Error("[Navios] @Module can only be used on classes.");
|
|
120
|
+
require_attribute_value.applyAttributes(require_module_metadata.defineModuleMetadata(target, context, options).attributes, options.attributes);
|
|
121
|
+
(0, _navios_di.registerInjectable)(target, { scope: _navios_di.InjectableScope.Singleton });
|
|
122
|
+
return target;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Registers a class as a module without decorator syntax.
|
|
127
|
+
*/
|
|
128
|
+
function registerModule(target, options = {}) {
|
|
129
|
+
require_attribute_value.applyAttributes(require_module_metadata.defineModuleMetadata(target, { metadata: {} }, options).attributes, options.attributes);
|
|
130
|
+
(0, _navios_di.registerInjectable)(target, { scope: _navios_di.InjectableScope.Singleton });
|
|
131
|
+
return target;
|
|
132
|
+
}
|
|
133
|
+
Object.defineProperty(exports, "AttributeFactory", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function() {
|
|
136
|
+
return AttributeFactory;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, "Module", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function() {
|
|
142
|
+
return Module;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, "UseGuards", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function() {
|
|
148
|
+
return UseGuards;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, "UseInterceptors", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function() {
|
|
154
|
+
return UseInterceptors;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, "registerModule", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function() {
|
|
160
|
+
return registerModule;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
//# sourceMappingURL=module-DZewk_2r.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-DZewk_2r.cjs","names":["classAttributes","memberMetadata","classGuards","classInterceptors","memberMetadata","applyAttributes","defineModuleMetadata","registerInjectable","InjectableScope"],"sources":["../src/attributes/attribute-factory.mts","../src/metadata/attach-classes.mts","../src/guards/use-guards.mts","../src/interceptors/use-interceptors.mts","../src/modules/module.mts"],"sourcesContent":["import type { InferInput, InferOutput, StandardSchemaV1 } from '@navios/di'\n\nimport { classAttributes } from '../metadata/class-metadata.mjs'\nimport { memberMetadata } from '../metadata/member-metadata.mjs'\n\nimport type { HandlerInfo } from '../execution/execution-context.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AttributeContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The result of calling an attribute. It is a decorator for a module, a\n * controller, a handler method or a handler field, and it can also be passed\n * in `handler(endpoint, { attributes: [...] }, fn)`.\n */\nexport interface AttributeApplication {\n (target: any, context: AttributeContext): any\n readonly token: symbol\n readonly value: unknown\n}\n\nexport interface ClassAttribute {\n (): AttributeApplication\n readonly token: symbol\n}\n\nexport interface ClassSchemaAttribute<Schema extends StandardSchemaV1> {\n (value: InferInput<Schema>): AttributeApplication\n readonly token: symbol\n readonly schema: Schema\n}\n\nfunction apply(token: symbol, value: unknown): AttributeApplication {\n const decorator = (target: any, context: AttributeContext) => {\n if (context.kind === 'class') {\n classAttributes(context).set(token, value)\n } else if (context.kind === 'method' || context.kind === 'field') {\n if (typeof context.name !== 'string') {\n throw new Error('[Navios] Attributes cannot be applied to symbol-named members')\n }\n memberMetadata(context, context.name).attributes.set(token, value)\n } else {\n throw new Error('[Navios] Attributes can only be applied to classes, methods and fields')\n }\n return context.kind === 'field' ? undefined : target\n }\n return Object.assign(decorator, { token, value })\n}\n\n/**\n * What reading an attribute needs of it. An attribute of either factory, the\n * standard one or the one from `@navios/core/legacy-compat`, has this shape;\n * what calling it returns differs between the two and does not matter here.\n */\ninterface ReadableAttribute {\n readonly token: symbol\n readonly schema?: undefined\n}\n\ninterface ReadableSchemaAttribute<Schema extends StandardSchemaV1> {\n readonly token: symbol\n readonly schema: Schema\n}\n\ntype AttributeSource = HandlerInfo | { attributes: ReadonlyMap<symbol, unknown> }\n\nfunction layers(source: AttributeSource): ReadonlyMap<symbol, unknown>[] {\n const attributes = source.attributes\n if (attributes instanceof Map) {\n return [attributes]\n }\n const route = attributes as HandlerInfo['attributes']\n // Most specific first.\n return [route.handler, route.controller, route.module]\n}\n\n/**\n * Creates and reads attributes: typed metadata attached to modules,\n * controllers and handlers.\n *\n * ```ts\n * export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))\n * export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))\n *\n * if (AttributeFactory.has(Public, ctx.handler)) return true\n * const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null\n * ```\n */\nexport class AttributeFactory {\n static createAttribute(token: symbol): ClassAttribute\n static createAttribute<Schema extends StandardSchemaV1>(\n token: symbol,\n schema: Schema,\n ): ClassSchemaAttribute<Schema>\n static createAttribute(token: symbol, schema?: StandardSchemaV1): any {\n const attribute = (value?: unknown) => {\n if (!schema) {\n return apply(token, true)\n }\n const result = schema['~standard'].validate(value)\n if (result instanceof Promise) {\n result.catch(() => {})\n throw new Error(\n `[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`,\n )\n }\n if (result.issues) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${result.issues\n .map((issue) => issue.message)\n .join('; ')}`,\n )\n }\n return apply(token, result.value)\n }\n return Object.assign(attribute, schema ? { token, schema } : { token })\n }\n\n /**\n * The attribute's value for a handler: the handler's own, else the controller's,\n * else the module's. `null` when none has it.\n */\n static get(attribute: ReadableAttribute, source: AttributeSource): true | null\n static get<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema> | null\n static get(attribute: { token: symbol }, source: AttributeSource): unknown {\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n return layer.get(attribute.token)\n }\n }\n return null\n }\n\n /**\n * Every value of the attribute for a handler, most specific first.\n */\n static getAll(attribute: ReadableAttribute, source: AttributeSource): true[]\n static getAll<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema>[]\n static getAll(attribute: { token: symbol }, source: AttributeSource): unknown[] {\n const values: unknown[] = []\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n values.push(layer.get(attribute.token))\n }\n }\n return values\n }\n\n static has(attribute: { token: symbol }, source: AttributeSource): boolean {\n return layers(source).some((layer) => layer.has(attribute.token))\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport { classGuards, classInterceptors } from './class-metadata.mjs'\nimport { memberMetadata } from './member-metadata.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AnyMemberContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The decorator behind `@UseGuards` and `@UseInterceptors`: adds classes to\n * the list of a class or of one of its members.\n * @internal\n */\nexport function attachClasses(\n kind: 'guards' | 'interceptors',\n classes: ClassType[],\n name: string,\n): (target: any, context: AnyMemberContext) => any {\n return (target, context) => {\n if (context.kind === 'class') {\n const list = kind === 'guards' ? classGuards(context) : classInterceptors(context)\n for (const cls of classes) {\n if (!list.includes(cls)) {\n list.push(cls)\n }\n }\n return target\n }\n if (context.kind !== 'method' && context.kind !== 'field') {\n throw new Error(`[Navios] @${name} can only be used on classes, methods and fields.`)\n }\n if (typeof context.name !== 'string') {\n throw new Error(`[Navios] @${name} cannot be used on symbol-named members.`)\n }\n const list = memberMetadata(context, context.name)[kind]\n for (const cls of classes) {\n if (!list.includes(cls)) {\n list.push(cls)\n }\n }\n return context.kind === 'field' ? undefined : target\n }\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { GuardClass } from './guard.mjs'\n\n/**\n * Adds guards to a module, a controller or a handler. Guards run in the\n * order module, controller, handler, and within one level in the order given.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseGuards(...guards: GuardClass[]) {\n return attachClasses('guards', guards, 'UseGuards')\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { InterceptorClass } from './interceptor.mjs'\n\n/**\n * Adds interceptors to a module, a controller or a handler. The first one\n * given is the outermost. They run for what the guards let through, unlike the\n * interceptors of the application.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseInterceptors(...interceptors: InterceptorClass[]) {\n return attachClasses('interceptors', interceptors, 'UseInterceptors')\n}\n","import { InjectableScope, registerInjectable } from '@navios/di'\n\nimport type { ClassType } from '@navios/di'\n\nimport { applyAttributes } from '../attributes/attribute-value.mjs'\n\nimport { defineModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleOptions } from './module-options.mjs'\n\n/**\n * Marks a class as a module: a group of handlers with shared guards,\n * interceptors and attributes.\n */\nexport function Module(options: ModuleOptions = {}) {\n return <T extends ClassType>(target: T, context: ClassDecoratorContext): T => {\n if (context.kind !== 'class') {\n throw new Error('[Navios] @Module can only be used on classes.')\n }\n applyAttributes(defineModuleMetadata(target, context, options).attributes, options.attributes)\n registerInjectable(target, { scope: InjectableScope.Singleton })\n return target\n }\n}\n\n/**\n * Registers a class as a module without decorator syntax.\n */\nexport function registerModule<T extends ClassType>(target: T, options: ModuleOptions = {}): T {\n applyAttributes(\n defineModuleMetadata(target, { metadata: {} }, options).attributes,\n options.attributes,\n )\n registerInjectable(target, { scope: InjectableScope.Singleton })\n return target\n}\n"],"mappings":";;;;AAoCA,SAAS,MAAM,OAAe,OAAsC;CAClE,MAAM,aAAa,QAAa,YAA8B;EAC5D,IAAI,QAAQ,SAAS,SACnBA,wBAAAA,gBAAgB,OAAO,CAAC,CAAC,IAAI,OAAO,KAAK;OACpC,IAAI,QAAQ,SAAS,YAAY,QAAQ,SAAS,SAAS;GAChE,IAAI,OAAO,QAAQ,SAAS,UAC1B,MAAM,IAAI,MAAM,+DAA+D;GA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AqB,QAAQ,SAAS,OAAO,CAAC,CAAC,YAAY,QAAQ,UAAU;EAC7FC,CAAAA,GAAAA,WAAAA,mBAAAA,CAAmB,QAAQ,EAAE,OAAOC,WAAAA,gBAAgB,UAAU,CAAC;EAC/D,OAAO;CACT;AACF;;;;AAKA,SAAgB,eAAoC,QAAW,UAAyB,CAAC,GAAM;CAC7FH,wBAAAA,gBACEC,wBAAAA,qBAAqB,QAAQ,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,YACxD,QAAQ,UACV;CACAC,CAAAA,GAAAA,WAAAA,mBAAAA,CAAmB,QAAQ,EAAE,OAAOC,WAAAA,gBAAgB,UAAU,CAAC;CAC/D,OAAO;AACT"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
let node_util = require("node:util");
|
|
2
|
+
const require_module_metadata = require("./module-metadata-C8S92seK.cjs");
|
|
3
|
+
// src/modules/module-graph.mts
|
|
4
|
+
function addAll(target, source) {
|
|
5
|
+
for (const item of source) if (!target.includes(item)) target.push(item);
|
|
6
|
+
}
|
|
7
|
+
function names(path) {
|
|
8
|
+
return path.map((module) => module.name).join(" -> ");
|
|
9
|
+
}
|
|
10
|
+
/** One way to a module from a root, the module included. */
|
|
11
|
+
function pathTo(node) {
|
|
12
|
+
const path = [node.module];
|
|
13
|
+
for (let at = node; !at.isRoot && at.importers.length > 0;) {
|
|
14
|
+
at = at.importers[0];
|
|
15
|
+
path.unshift(at.module);
|
|
16
|
+
}
|
|
17
|
+
return path;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gives a module the attributes it inherits. Guards add up over several import
|
|
21
|
+
* paths, which is safe; attributes cannot. One that opens a handler and one that
|
|
22
|
+
* restricts it would each be wrong if it applied because of one path alone, so
|
|
23
|
+
* the paths have to agree where a handler inherits it.
|
|
24
|
+
*/
|
|
25
|
+
function inheritAttributes(draft, importers) {
|
|
26
|
+
const { node, metadata, disagreements } = draft;
|
|
27
|
+
const keys = new Set(importers.flatMap((importer) => [...importer.node.attributes.keys(), ...importer.disagreements.keys()]));
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
if (metadata.attributes.has(key)) continue;
|
|
30
|
+
const inherited = importers.find((importer) => importer.disagreements.has(key));
|
|
31
|
+
if (inherited) {
|
|
32
|
+
const { one, other, otherHasValue } = inherited.disagreements.get(key);
|
|
33
|
+
disagreements.set(key, {
|
|
34
|
+
one: [...one, node.module],
|
|
35
|
+
other: [...other, node.module],
|
|
36
|
+
otherHasValue
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const source = importers.find((importer) => importer.node.attributes.has(key));
|
|
41
|
+
const value = source.node.attributes.get(key);
|
|
42
|
+
const disagrees = (importer) => !importer.node.attributes.has(key) || !(0, node_util.isDeepStrictEqual)(importer.node.attributes.get(key), value);
|
|
43
|
+
const other = importers.find(disagrees);
|
|
44
|
+
if (other === void 0 && !node.isRoot) node.attributes.set(key, value);
|
|
45
|
+
else disagreements.set(key, {
|
|
46
|
+
one: [...pathTo(source.node), node.module],
|
|
47
|
+
other: other === void 0 ? [node.module] : [...pathTo(other.node), node.module],
|
|
48
|
+
otherHasValue: other !== void 0 && other.node.attributes.has(key)
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
node.disputed = new Map(Array.from(disagreements, ([key, value]) => [key, described(value)]));
|
|
52
|
+
}
|
|
53
|
+
function described({ one, other, otherHasValue }) {
|
|
54
|
+
return `one over ${names(one)}, ${otherHasValue ? "another" : "none"} over ${names(other)}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Walks the import graph from the given roots and computes, for this
|
|
58
|
+
* application only, what applies to each module.
|
|
59
|
+
*
|
|
60
|
+
* - Guards and interceptors are the union over every path that reaches a
|
|
61
|
+
* module, outermost first: what the importers contribute, importers in
|
|
62
|
+
* import order, then the module's own. Nothing is written back to the
|
|
63
|
+
* classes, so two applications importing one module under different parents
|
|
64
|
+
* do not affect each other.
|
|
65
|
+
* - An attribute comes from the module itself or else from what imports it.
|
|
66
|
+
* One that the importers do not agree about is in `disputed` instead.
|
|
67
|
+
*
|
|
68
|
+
* Neither depends on the order in which a module happens to be reached.
|
|
69
|
+
* Modules are returned in dependency order: a module comes after everything
|
|
70
|
+
* it imports. That cannot be done for modules that import each other, which is
|
|
71
|
+
* an error as well.
|
|
72
|
+
*/
|
|
73
|
+
function buildModuleGraph(roots) {
|
|
74
|
+
const drafts = /* @__PURE__ */ new Map();
|
|
75
|
+
const order = [];
|
|
76
|
+
const path = [];
|
|
77
|
+
const visit = (module, importer) => {
|
|
78
|
+
const known = drafts.get(module);
|
|
79
|
+
if (known) {
|
|
80
|
+
if (known.open) throw new Error(`[Navios] Modules import each other in a cycle: ` + names([...path.slice(path.indexOf(module)), module]));
|
|
81
|
+
if (importer && !known.node.importers.includes(importer)) known.node.importers.push(importer);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const metadata = require_module_metadata.getModuleMetadata(module);
|
|
85
|
+
const imports = metadata.imports;
|
|
86
|
+
require_module_metadata.assertImportsDefined(module, imports);
|
|
87
|
+
const node = {
|
|
88
|
+
module,
|
|
89
|
+
providers: metadata.providers,
|
|
90
|
+
entries: metadata.entries,
|
|
91
|
+
guards: [],
|
|
92
|
+
interceptors: [],
|
|
93
|
+
attributes: /* @__PURE__ */ new Map(),
|
|
94
|
+
disputed: /* @__PURE__ */ new Map(),
|
|
95
|
+
importers: importer ? [importer] : [],
|
|
96
|
+
isRoot: false
|
|
97
|
+
};
|
|
98
|
+
const draft = {
|
|
99
|
+
node,
|
|
100
|
+
metadata,
|
|
101
|
+
disagreements: /* @__PURE__ */ new Map(),
|
|
102
|
+
open: true,
|
|
103
|
+
ranked: false
|
|
104
|
+
};
|
|
105
|
+
drafts.set(module, draft);
|
|
106
|
+
path.push(module);
|
|
107
|
+
for (const imported of imports) visit(imported, node);
|
|
108
|
+
path.pop();
|
|
109
|
+
draft.open = false;
|
|
110
|
+
order.push(node);
|
|
111
|
+
};
|
|
112
|
+
for (const root of roots) {
|
|
113
|
+
visit(root, null);
|
|
114
|
+
drafts.get(root).node.isRoot = true;
|
|
115
|
+
}
|
|
116
|
+
const outermostFirst = [];
|
|
117
|
+
const rank = (draft) => {
|
|
118
|
+
if (draft.ranked) return;
|
|
119
|
+
draft.ranked = true;
|
|
120
|
+
const imports = draft.metadata.imports;
|
|
121
|
+
for (let i = imports.length - 1; i >= 0; i--) rank(drafts.get(imports[i]));
|
|
122
|
+
outermostFirst.push(draft);
|
|
123
|
+
};
|
|
124
|
+
for (let i = roots.length - 1; i >= 0; i--) rank(drafts.get(roots[i]));
|
|
125
|
+
outermostFirst.reverse();
|
|
126
|
+
for (const draft of outermostFirst) {
|
|
127
|
+
const { node, metadata } = draft;
|
|
128
|
+
addAll(node.guards, metadata.guards);
|
|
129
|
+
addAll(node.interceptors, metadata.interceptors);
|
|
130
|
+
inheritAttributes(draft, node.importers.map((importer) => drafts.get(importer.module)));
|
|
131
|
+
for (const [key, value] of metadata.attributes) node.attributes.set(key, value);
|
|
132
|
+
for (const imported of metadata.imports) {
|
|
133
|
+
const child = drafts.get(imported);
|
|
134
|
+
addAll(child.node.guards, node.guards);
|
|
135
|
+
addAll(child.node.interceptors, node.interceptors);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return order;
|
|
139
|
+
}
|
|
140
|
+
Object.defineProperty(exports, "buildModuleGraph", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function() {
|
|
143
|
+
return buildModuleGraph;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=module-graph-DCP9MHG0.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-graph-DCP9MHG0.cjs","names":["isDeepStrictEqual","getModuleMetadata","assertImportsDefined"],"sources":["../src/modules/module-graph.mts"],"sourcesContent":["import { isDeepStrictEqual } from 'node:util'\n\nimport type { ClassType, Provider } from '@navios/di'\n\nimport { assertImportsDefined, getModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleMetadata } from './module-metadata.mjs'\n\n/**\n * A module as it applies to one application: its guards, interceptors and\n * attributes together with those it inherits, and the modules that import it.\n */\nexport interface ModuleNode {\n module: ClassType\n providers: Provider[]\n /** The module's transport-specific options, by option name. */\n entries: ReadonlyMap<string, unknown>\n guards: ClassType[]\n interceptors: ClassType[]\n attributes: Map<symbol, unknown>\n /**\n * The attributes that the importers of the module do not agree about, and what\n * each of two import paths gives it. They are not among `attributes`;\n * `handlerChain` refuses a handler that would inherit one.\n */\n disputed: ReadonlyMap<symbol, string>\n /** The modules that import this one, in the order they were reached. */\n importers: ModuleNode[]\n /** Whether the module was given to the application directly. */\n isRoot: boolean\n}\n\n/** Two import paths that give a module different values of one attribute. */\ninterface Disagreement {\n one: ClassType[]\n other: ClassType[]\n /** Whether the other path gives a value at all. */\n otherHasValue: boolean\n}\n\n/** What a module has while the graph is being computed. */\ninterface Draft {\n node: ModuleNode\n metadata: ModuleMetadata\n /** The attributes the importers do not agree about. */\n disagreements: Map<symbol, Disagreement>\n /** Whether the walk is at what it imports. */\n open: boolean\n ranked: boolean\n}\n\nfunction addAll<T>(target: T[], source: Iterable<T>): void {\n for (const item of source) {\n if (!target.includes(item)) {\n target.push(item)\n }\n }\n}\n\nfunction names(path: readonly ClassType[]): string {\n return path.map((module) => module.name).join(' -> ')\n}\n\n/** One way to a module from a root, the module included. */\nfunction pathTo(node: ModuleNode): ClassType[] {\n const path = [node.module]\n for (let at = node; !at.isRoot && at.importers.length > 0;) {\n at = at.importers[0]\n path.unshift(at.module)\n }\n return path\n}\n\n/**\n * Gives a module the attributes it inherits. Guards add up over several import\n * paths, which is safe; attributes cannot. One that opens a handler and one that\n * restricts it would each be wrong if it applied because of one path alone, so\n * the paths have to agree where a handler inherits it.\n */\nfunction inheritAttributes(draft: Draft, importers: readonly Draft[]): void {\n const { node, metadata, disagreements } = draft\n const keys = new Set(\n importers.flatMap((importer) => [\n ...importer.node.attributes.keys(),\n ...importer.disagreements.keys(),\n ]),\n )\n for (const key of keys) {\n if (metadata.attributes.has(key)) {\n continue\n }\n const inherited = importers.find((importer) => importer.disagreements.has(key))\n if (inherited) {\n const { one, other, otherHasValue } = inherited.disagreements.get(key)!\n disagreements.set(key, {\n one: [...one, node.module],\n other: [...other, node.module],\n otherHasValue,\n })\n continue\n }\n const source = importers.find((importer) => importer.node.attributes.has(key))!\n const value = source.node.attributes.get(key)\n const disagrees = (importer: Draft) =>\n !importer.node.attributes.has(key) ||\n !isDeepStrictEqual(importer.node.attributes.get(key), value)\n const other = importers.find(disagrees)\n if (other === undefined && !node.isRoot) {\n node.attributes.set(key, value)\n } else {\n disagreements.set(key, {\n one: [...pathTo(source.node), node.module],\n other: other === undefined ? [node.module] : [...pathTo(other.node), node.module],\n otherHasValue: other !== undefined && other.node.attributes.has(key),\n })\n }\n }\n node.disputed = new Map(Array.from(disagreements, ([key, value]) => [key, described(value)]))\n}\n\nfunction described({ one, other, otherHasValue }: Disagreement): string {\n return `one over ${names(one)}, ${otherHasValue ? 'another' : 'none'} over ${names(other)}`\n}\n\n/**\n * Walks the import graph from the given roots and computes, for this\n * application only, what applies to each module.\n *\n * - Guards and interceptors are the union over every path that reaches a\n * module, outermost first: what the importers contribute, importers in\n * import order, then the module's own. Nothing is written back to the\n * classes, so two applications importing one module under different parents\n * do not affect each other.\n * - An attribute comes from the module itself or else from what imports it.\n * One that the importers do not agree about is in `disputed` instead.\n *\n * Neither depends on the order in which a module happens to be reached.\n * Modules are returned in dependency order: a module comes after everything\n * it imports. That cannot be done for modules that import each other, which is\n * an error as well.\n */\nexport function buildModuleGraph(roots: ClassType[]): ModuleNode[] {\n const drafts = new Map<ClassType, Draft>()\n const order: ModuleNode[] = []\n\n // First walk: every module once, in dependency order, with its importers.\n const path: ClassType[] = []\n const visit = (module: ClassType, importer: ModuleNode | null): void => {\n const known = drafts.get(module)\n if (known) {\n if (known.open) {\n throw new Error(\n `[Navios] Modules import each other in a cycle: ` +\n names([...path.slice(path.indexOf(module)), module]),\n )\n }\n if (importer && !known.node.importers.includes(importer)) {\n known.node.importers.push(importer)\n }\n return\n }\n const metadata = getModuleMetadata(module)\n const imports = metadata.imports\n assertImportsDefined(module, imports)\n const node: ModuleNode = {\n module,\n providers: metadata.providers,\n entries: metadata.entries,\n guards: [],\n interceptors: [],\n attributes: new Map(),\n disputed: new Map(),\n importers: importer ? [importer] : [],\n isRoot: false,\n }\n const draft: Draft = {\n node,\n metadata,\n disagreements: new Map(),\n open: true,\n ranked: false,\n }\n drafts.set(module, draft)\n path.push(module)\n for (const imported of imports) {\n visit(imported, node)\n }\n path.pop()\n draft.open = false\n order.push(node)\n }\n for (const root of roots) {\n visit(root, null)\n drafts.get(root)!.node.isRoot = true\n }\n\n // Second walk: importers before what they import, siblings in import\n // order. That is the reverse of a post-order that takes the imports last\n // to first.\n const outermostFirst: Draft[] = []\n const rank = (draft: Draft): void => {\n if (draft.ranked) {\n return\n }\n draft.ranked = true\n const imports = draft.metadata.imports\n for (let i = imports.length - 1; i >= 0; i--) {\n rank(drafts.get(imports[i])!)\n }\n outermostFirst.push(draft)\n }\n for (let i = roots.length - 1; i >= 0; i--) {\n rank(drafts.get(roots[i])!)\n }\n outermostFirst.reverse()\n\n // Each module is complete when its turn comes, because everything that\n // imports it came before; it then hands what it has to its imports.\n for (const draft of outermostFirst) {\n const { node, metadata } = draft\n addAll(node.guards, metadata.guards)\n addAll(node.interceptors, metadata.interceptors)\n inheritAttributes(\n draft,\n node.importers.map((importer) => drafts.get(importer.module)!),\n )\n for (const [key, value] of metadata.attributes) {\n node.attributes.set(key, value)\n }\n for (const imported of metadata.imports) {\n const child = drafts.get(imported)!\n addAll(child.node.guards, node.guards)\n addAll(child.node.interceptors, node.interceptors)\n }\n }\n return order\n}\n"],"mappings":";;;AAmDA,SAAS,OAAU,QAAa,QAA2B;CACzD,KAAK,MAAM,QAAQ,QACjB,IAAI,CAAC,OAAO,SAA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,KAAK,QAAQ,KAAK,MAAM;GACrC,OAAO,MAAM,KAAK,cAAc,KAAK,YAAY;EACnD;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { i as getModuleMetadata, t as assertImportsDefined } from "./module-metadata-k3RTt20x.mjs";
|
|
3
|
+
// src/modules/module-graph.mts
|
|
4
|
+
function addAll(target, source) {
|
|
5
|
+
for (const item of source) if (!target.includes(item)) target.push(item);
|
|
6
|
+
}
|
|
7
|
+
function names(path) {
|
|
8
|
+
return path.map((module) => module.name).join(" -> ");
|
|
9
|
+
}
|
|
10
|
+
/** One way to a module from a root, the module included. */
|
|
11
|
+
function pathTo(node) {
|
|
12
|
+
const path = [node.module];
|
|
13
|
+
for (let at = node; !at.isRoot && at.importers.length > 0;) {
|
|
14
|
+
at = at.importers[0];
|
|
15
|
+
path.unshift(at.module);
|
|
16
|
+
}
|
|
17
|
+
return path;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gives a module the attributes it inherits. Guards add up over several import
|
|
21
|
+
* paths, which is safe; attributes cannot. One that opens a handler and one that
|
|
22
|
+
* restricts it would each be wrong if it applied because of one path alone, so
|
|
23
|
+
* the paths have to agree where a handler inherits it.
|
|
24
|
+
*/
|
|
25
|
+
function inheritAttributes(draft, importers) {
|
|
26
|
+
const { node, metadata, disagreements } = draft;
|
|
27
|
+
const keys = new Set(importers.flatMap((importer) => [...importer.node.attributes.keys(), ...importer.disagreements.keys()]));
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
if (metadata.attributes.has(key)) continue;
|
|
30
|
+
const inherited = importers.find((importer) => importer.disagreements.has(key));
|
|
31
|
+
if (inherited) {
|
|
32
|
+
const { one, other, otherHasValue } = inherited.disagreements.get(key);
|
|
33
|
+
disagreements.set(key, {
|
|
34
|
+
one: [...one, node.module],
|
|
35
|
+
other: [...other, node.module],
|
|
36
|
+
otherHasValue
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const source = importers.find((importer) => importer.node.attributes.has(key));
|
|
41
|
+
const value = source.node.attributes.get(key);
|
|
42
|
+
const disagrees = (importer) => !importer.node.attributes.has(key) || !isDeepStrictEqual(importer.node.attributes.get(key), value);
|
|
43
|
+
const other = importers.find(disagrees);
|
|
44
|
+
if (other === void 0 && !node.isRoot) node.attributes.set(key, value);
|
|
45
|
+
else disagreements.set(key, {
|
|
46
|
+
one: [...pathTo(source.node), node.module],
|
|
47
|
+
other: other === void 0 ? [node.module] : [...pathTo(other.node), node.module],
|
|
48
|
+
otherHasValue: other !== void 0 && other.node.attributes.has(key)
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
node.disputed = new Map(Array.from(disagreements, ([key, value]) => [key, described(value)]));
|
|
52
|
+
}
|
|
53
|
+
function described({ one, other, otherHasValue }) {
|
|
54
|
+
return `one over ${names(one)}, ${otherHasValue ? "another" : "none"} over ${names(other)}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Walks the import graph from the given roots and computes, for this
|
|
58
|
+
* application only, what applies to each module.
|
|
59
|
+
*
|
|
60
|
+
* - Guards and interceptors are the union over every path that reaches a
|
|
61
|
+
* module, outermost first: what the importers contribute, importers in
|
|
62
|
+
* import order, then the module's own. Nothing is written back to the
|
|
63
|
+
* classes, so two applications importing one module under different parents
|
|
64
|
+
* do not affect each other.
|
|
65
|
+
* - An attribute comes from the module itself or else from what imports it.
|
|
66
|
+
* One that the importers do not agree about is in `disputed` instead.
|
|
67
|
+
*
|
|
68
|
+
* Neither depends on the order in which a module happens to be reached.
|
|
69
|
+
* Modules are returned in dependency order: a module comes after everything
|
|
70
|
+
* it imports. That cannot be done for modules that import each other, which is
|
|
71
|
+
* an error as well.
|
|
72
|
+
*/
|
|
73
|
+
function buildModuleGraph(roots) {
|
|
74
|
+
const drafts = /* @__PURE__ */ new Map();
|
|
75
|
+
const order = [];
|
|
76
|
+
const path = [];
|
|
77
|
+
const visit = (module, importer) => {
|
|
78
|
+
const known = drafts.get(module);
|
|
79
|
+
if (known) {
|
|
80
|
+
if (known.open) throw new Error(`[Navios] Modules import each other in a cycle: ` + names([...path.slice(path.indexOf(module)), module]));
|
|
81
|
+
if (importer && !known.node.importers.includes(importer)) known.node.importers.push(importer);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const metadata = getModuleMetadata(module);
|
|
85
|
+
const imports = metadata.imports;
|
|
86
|
+
assertImportsDefined(module, imports);
|
|
87
|
+
const node = {
|
|
88
|
+
module,
|
|
89
|
+
providers: metadata.providers,
|
|
90
|
+
entries: metadata.entries,
|
|
91
|
+
guards: [],
|
|
92
|
+
interceptors: [],
|
|
93
|
+
attributes: /* @__PURE__ */ new Map(),
|
|
94
|
+
disputed: /* @__PURE__ */ new Map(),
|
|
95
|
+
importers: importer ? [importer] : [],
|
|
96
|
+
isRoot: false
|
|
97
|
+
};
|
|
98
|
+
const draft = {
|
|
99
|
+
node,
|
|
100
|
+
metadata,
|
|
101
|
+
disagreements: /* @__PURE__ */ new Map(),
|
|
102
|
+
open: true,
|
|
103
|
+
ranked: false
|
|
104
|
+
};
|
|
105
|
+
drafts.set(module, draft);
|
|
106
|
+
path.push(module);
|
|
107
|
+
for (const imported of imports) visit(imported, node);
|
|
108
|
+
path.pop();
|
|
109
|
+
draft.open = false;
|
|
110
|
+
order.push(node);
|
|
111
|
+
};
|
|
112
|
+
for (const root of roots) {
|
|
113
|
+
visit(root, null);
|
|
114
|
+
drafts.get(root).node.isRoot = true;
|
|
115
|
+
}
|
|
116
|
+
const outermostFirst = [];
|
|
117
|
+
const rank = (draft) => {
|
|
118
|
+
if (draft.ranked) return;
|
|
119
|
+
draft.ranked = true;
|
|
120
|
+
const imports = draft.metadata.imports;
|
|
121
|
+
for (let i = imports.length - 1; i >= 0; i--) rank(drafts.get(imports[i]));
|
|
122
|
+
outermostFirst.push(draft);
|
|
123
|
+
};
|
|
124
|
+
for (let i = roots.length - 1; i >= 0; i--) rank(drafts.get(roots[i]));
|
|
125
|
+
outermostFirst.reverse();
|
|
126
|
+
for (const draft of outermostFirst) {
|
|
127
|
+
const { node, metadata } = draft;
|
|
128
|
+
addAll(node.guards, metadata.guards);
|
|
129
|
+
addAll(node.interceptors, metadata.interceptors);
|
|
130
|
+
inheritAttributes(draft, node.importers.map((importer) => drafts.get(importer.module)));
|
|
131
|
+
for (const [key, value] of metadata.attributes) node.attributes.set(key, value);
|
|
132
|
+
for (const imported of metadata.imports) {
|
|
133
|
+
const child = drafts.get(imported);
|
|
134
|
+
addAll(child.node.guards, node.guards);
|
|
135
|
+
addAll(child.node.interceptors, node.interceptors);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return order;
|
|
139
|
+
}
|
|
140
|
+
export { buildModuleGraph as t };
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=module-graph-xvVEykFM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-graph-xvVEykFM.mjs","names":[],"sources":["../src/modules/module-graph.mts"],"sourcesContent":["import { isDeepStrictEqual } from 'node:util'\n\nimport type { ClassType, Provider } from '@navios/di'\n\nimport { assertImportsDefined, getModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleMetadata } from './module-metadata.mjs'\n\n/**\n * A module as it applies to one application: its guards, interceptors and\n * attributes together with those it inherits, and the modules that import it.\n */\nexport interface ModuleNode {\n module: ClassType\n providers: Provider[]\n /** The module's transport-specific options, by option name. */\n entries: ReadonlyMap<string, unknown>\n guards: ClassType[]\n interceptors: ClassType[]\n attributes: Map<symbol, unknown>\n /**\n * The attributes that the importers of the module do not agree about, and what\n * each of two import paths gives it. They are not among `attributes`;\n * `handlerChain` refuses a handler that would inherit one.\n */\n disputed: ReadonlyMap<symbol, string>\n /** The modules that import this one, in the order they were reached. */\n importers: ModuleNode[]\n /** Whether the module was given to the application directly. */\n isRoot: boolean\n}\n\n/** Two import paths that give a module different values of one attribute. */\ninterface Disagreement {\n one: ClassType[]\n other: ClassType[]\n /** Whether the other path gives a value at all. */\n otherHasValue: boolean\n}\n\n/** What a module has while the graph is being computed. */\ninterface Draft {\n node: ModuleNode\n metadata: ModuleMetadata\n /** The attributes the importers do not agree about. */\n disagreements: Map<symbol, Disagreement>\n /** Whether the walk is at what it imports. */\n open: boolean\n ranked: boolean\n}\n\nfunction addAll<T>(target: T[], source: Iterable<T>): void {\n for (const item of source) {\n if (!target.includes(item)) {\n target.push(item)\n }\n }\n}\n\nfunction names(path: readonly ClassType[]): string {\n return path.map((module) => module.name).join(' -> ')\n}\n\n/** One way to a module from a root, the module included. */\nfunction pathTo(node: ModuleNode): ClassType[] {\n const path = [node.module]\n for (let at = node; !at.isRoot && at.importers.length > 0;) {\n at = at.importers[0]\n path.unshift(at.module)\n }\n return path\n}\n\n/**\n * Gives a module the attributes it inherits. Guards add up over several import\n * paths, which is safe; attributes cannot. One that opens a handler and one that\n * restricts it would each be wrong if it applied because of one path alone, so\n * the paths have to agree where a handler inherits it.\n */\nfunction inheritAttributes(draft: Draft, importers: readonly Draft[]): void {\n const { node, metadata, disagreements } = draft\n const keys = new Set(\n importers.flatMap((importer) => [\n ...importer.node.attributes.keys(),\n ...importer.disagreements.keys(),\n ]),\n )\n for (const key of keys) {\n if (metadata.attributes.has(key)) {\n continue\n }\n const inherited = importers.find((importer) => importer.disagreements.has(key))\n if (inherited) {\n const { one, other, otherHasValue } = inherited.disagreements.get(key)!\n disagreements.set(key, {\n one: [...one, node.module],\n other: [...other, node.module],\n otherHasValue,\n })\n continue\n }\n const source = importers.find((importer) => importer.node.attributes.has(key))!\n const value = source.node.attributes.get(key)\n const disagrees = (importer: Draft) =>\n !importer.node.attributes.has(key) ||\n !isDeepStrictEqual(importer.node.attributes.get(key), value)\n const other = importers.find(disagrees)\n if (other === undefined && !node.isRoot) {\n node.attributes.set(key, value)\n } else {\n disagreements.set(key, {\n one: [...pathTo(source.node), node.module],\n other: other === undefined ? [node.module] : [...pathTo(other.node), node.module],\n otherHasValue: other !== undefined && other.node.attributes.has(key),\n })\n }\n }\n node.disputed = new Map(Array.from(disagreements, ([key, value]) => [key, described(value)]))\n}\n\nfunction described({ one, other, otherHasValue }: Disagreement): string {\n return `one over ${names(one)}, ${otherHasValue ? 'another' : 'none'} over ${names(other)}`\n}\n\n/**\n * Walks the import graph from the given roots and computes, for this\n * application only, what applies to each module.\n *\n * - Guards and interceptors are the union over every path that reaches a\n * module, outermost first: what the importers contribute, importers in\n * import order, then the module's own. Nothing is written back to the\n * classes, so two applications importing one module under different parents\n * do not affect each other.\n * - An attribute comes from the module itself or else from what imports it.\n * One that the importers do not agree about is in `disputed` instead.\n *\n * Neither depends on the order in which a module happens to be reached.\n * Modules are returned in dependency order: a module comes after everything\n * it imports. That cannot be done for modules that import each other, which is\n * an error as well.\n */\nexport function buildModuleGraph(roots: ClassType[]): ModuleNode[] {\n const drafts = new Map<ClassType, Draft>()\n const order: ModuleNode[] = []\n\n // First walk: every module once, in dependency order, with its importers.\n const path: ClassType[] = []\n const visit = (module: ClassType, importer: ModuleNode | null): void => {\n const known = drafts.get(module)\n if (known) {\n if (known.open) {\n throw new Error(\n `[Navios] Modules import each other in a cycle: ` +\n names([...path.slice(path.indexOf(module)), module]),\n )\n }\n if (importer && !known.node.importers.includes(importer)) {\n known.node.importers.push(importer)\n }\n return\n }\n const metadata = getModuleMetadata(module)\n const imports = metadata.imports\n assertImportsDefined(module, imports)\n const node: ModuleNode = {\n module,\n providers: metadata.providers,\n entries: metadata.entries,\n guards: [],\n interceptors: [],\n attributes: new Map(),\n disputed: new Map(),\n importers: importer ? [importer] : [],\n isRoot: false,\n }\n const draft: Draft = {\n node,\n metadata,\n disagreements: new Map(),\n open: true,\n ranked: false,\n }\n drafts.set(module, draft)\n path.push(module)\n for (const imported of imports) {\n visit(imported, node)\n }\n path.pop()\n draft.open = false\n order.push(node)\n }\n for (const root of roots) {\n visit(root, null)\n drafts.get(root)!.node.isRoot = true\n }\n\n // Second walk: importers before what they import, siblings in import\n // order. That is the reverse of a post-order that takes the imports last\n // to first.\n const outermostFirst: Draft[] = []\n const rank = (draft: Draft): void => {\n if (draft.ranked) {\n return\n }\n draft.ranked = true\n const imports = draft.metadata.imports\n for (let i = imports.length - 1; i >= 0; i--) {\n rank(drafts.get(imports[i])!)\n }\n outermostFirst.push(draft)\n }\n for (let i = roots.length - 1; i >= 0; i--) {\n rank(drafts.get(roots[i])!)\n }\n outermostFirst.reverse()\n\n // Each module is complete when its turn comes, because everything that\n // imports it came before; it then hands what it has to its imports.\n for (const draft of outermostFirst) {\n const { node, metadata } = draft\n addAll(node.guards, metadata.guards)\n addAll(node.interceptors, metadata.interceptors)\n inheritAttributes(\n draft,\n node.importers.map((importer) => drafts.get(importer.module)!),\n )\n for (const [key, value] of metadata.attributes) {\n node.attributes.set(key, value)\n }\n for (const imported of metadata.imports) {\n const child = drafts.get(imported)!\n addAll(child.node.guards, node.guards)\n addAll(child.node.interceptors, node.interceptors)\n }\n }\n return order\n}\n"],"mappings":";;;AAmDA,SAAS,OAAU,QAAa,QAA2B;CACzD,KAAK,MAAM,QAAQ,QACjB,IAAI,CAAC,OAAO,SAAS,IAAI,GACvB,OAAO,KAAK,IAAI;AAGtB;AAEA,SAAS,MAAM,MAAoC;CACjD,OAAO,KAAK,KAAK,WAAW,OAAO,IAAI,CAAC,CAAC,KAAK,MAAM;AACtD;;AAGA,SAAS,OAAO,MAA+B;CAC7C,MAAM,OAAO,CAAC,KAAK,MAAM;CACzB,KAAK,IAAI,KAAK,MAAM,CAAC,GAAG,UAAU,GAAG,UAAU,SAAS,IAAI;EAC1D,KAAK,GAAG,UAAU;EAClB,KAAK,QAAQ,GAAG,MAAM;CACxB;CACA,OAAO;AACT;;;;;;;AAQA,SAAS,kBAAkB,OAAc,WAAmC;CAC1E,MAAM,EAAE,MAAM,UAAU,kBAAkB;CAC1C,MAAM,OAAO,IAAI,IACf,UAAU,SAAS,aAAa,CAC9B,GAAG,S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