@fougere/core 0.2.0-alpha.2 → 0.3.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/README.md +2 -1
- package/dist/boot/AppLifecycle.d.ts +18 -0
- package/dist/boot/AppLifecycle.d.ts.map +1 -0
- package/dist/boot/AppLifecycle.js +42 -0
- package/dist/boot/AppLifecycle.js.map +1 -0
- package/dist/boot/Emissions.d.ts +126 -0
- package/dist/boot/Emissions.d.ts.map +1 -0
- package/dist/boot/Emissions.js +233 -0
- package/dist/boot/Emissions.js.map +1 -0
- package/dist/boot/HandlerFacade.d.ts +72 -0
- package/dist/boot/HandlerFacade.d.ts.map +1 -0
- package/dist/boot/HandlerFacade.js +174 -0
- package/dist/boot/HandlerFacade.js.map +1 -0
- package/dist/boot/Lifecycle.d.ts +4 -0
- package/dist/boot/Lifecycle.d.ts.map +1 -0
- package/dist/boot/Lifecycle.js +3 -0
- package/dist/boot/Lifecycle.js.map +1 -0
- package/dist/boot/ambient-port.d.ts +38 -0
- package/dist/boot/ambient-port.d.ts.map +1 -0
- package/dist/boot/ambient-port.js +2 -0
- package/dist/boot/ambient-port.js.map +1 -0
- package/dist/boot/ambient.als.d.ts +3 -0
- package/dist/boot/ambient.als.d.ts.map +1 -0
- package/dist/boot/ambient.als.js +34 -0
- package/dist/boot/ambient.als.js.map +1 -0
- package/dist/boot/ambient.queue.d.ts +10 -0
- package/dist/boot/ambient.queue.d.ts.map +1 -0
- package/dist/boot/ambient.queue.js +60 -0
- package/dist/boot/ambient.queue.js.map +1 -0
- package/dist/boot/apply.d.ts +22 -0
- package/dist/boot/apply.d.ts.map +1 -0
- package/dist/boot/apply.js +48 -0
- package/dist/boot/apply.js.map +1 -0
- package/dist/boot/auth.d.ts +53 -0
- package/dist/boot/auth.d.ts.map +1 -0
- package/dist/boot/auth.js +2 -0
- package/dist/boot/auth.js.map +1 -0
- package/dist/{binding.d.ts → boot/binding.d.ts} +14 -17
- package/dist/boot/binding.d.ts.map +1 -0
- package/dist/{binding.js → boot/binding.js} +19 -10
- package/dist/boot/binding.js.map +1 -0
- package/dist/{boot.d.ts → boot/boot.d.ts} +25 -5
- package/dist/boot/boot.d.ts.map +1 -0
- package/dist/boot/boot.js +70 -0
- package/dist/boot/boot.js.map +1 -0
- package/dist/boot/bootstrap.d.ts.map +1 -0
- package/dist/boot/bootstrap.js +721 -0
- package/dist/boot/bootstrap.js.map +1 -0
- package/dist/boot/egress.d.ts +8 -0
- package/dist/boot/egress.d.ts.map +1 -0
- package/dist/boot/egress.js +11 -0
- package/dist/boot/egress.js.map +1 -0
- package/dist/boot/frame.d.ts +44 -0
- package/dist/boot/frame.d.ts.map +1 -0
- package/dist/boot/frame.js +181 -0
- package/dist/boot/frame.js.map +1 -0
- package/dist/boot/ownership.d.ts +42 -0
- package/dist/boot/ownership.d.ts.map +1 -0
- package/dist/boot/ownership.js +127 -0
- package/dist/boot/ownership.js.map +1 -0
- package/dist/boot/ports.d.ts +17 -0
- package/dist/boot/ports.d.ts.map +1 -0
- package/dist/boot/ports.js +57 -0
- package/dist/boot/ports.js.map +1 -0
- package/dist/{remote.d.ts → boot/remote.d.ts} +11 -3
- package/dist/boot/remote.d.ts.map +1 -0
- package/dist/{remote.js → boot/remote.js} +24 -26
- package/dist/boot/remote.js.map +1 -0
- package/dist/{seed.d.ts → boot/seed.d.ts} +13 -1
- package/dist/boot/seed.d.ts.map +1 -0
- package/dist/{seed.js → boot/seed.js} +24 -3
- package/dist/boot/seed.js.map +1 -0
- package/dist/boot/together.d.ts +26 -0
- package/dist/boot/together.d.ts.map +1 -0
- package/dist/boot/together.js +163 -0
- package/dist/boot/together.js.map +1 -0
- package/dist/boot/types.d.ts +260 -0
- package/dist/boot/types.d.ts.map +1 -0
- package/dist/boot/types.js.map +1 -0
- package/dist/builtins/config.d.ts +9 -0
- package/dist/builtins/config.d.ts.map +1 -1
- package/dist/builtins/config.js +16 -1
- package/dist/builtins/config.js.map +1 -1
- package/dist/builtins/logger.d.ts +37 -4
- package/dist/builtins/logger.d.ts.map +1 -1
- package/dist/builtins/logger.js +66 -7
- package/dist/builtins/logger.js.map +1 -1
- package/dist/config-loader.d.ts +39 -35
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +15 -54
- package/dist/config-loader.js.map +1 -1
- package/dist/contract/Call.d.ts +10 -0
- package/dist/contract/Call.d.ts.map +1 -0
- package/dist/contract/Call.js +15 -0
- package/dist/contract/Call.js.map +1 -0
- package/dist/contract/Invocation.d.ts +27 -0
- package/dist/contract/Invocation.d.ts.map +1 -0
- package/dist/contract/Invocation.js +59 -0
- package/dist/contract/Invocation.js.map +1 -0
- package/dist/contract/RouteAddress.d.ts +17 -0
- package/dist/contract/RouteAddress.d.ts.map +1 -0
- package/dist/contract/RouteAddress.js +38 -0
- package/dist/contract/RouteAddress.js.map +1 -0
- package/dist/contract.d.ts +25 -19
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +25 -10
- package/dist/contract.js.map +1 -1
- package/dist/crypto/encoding.d.ts +25 -0
- package/dist/crypto/encoding.d.ts.map +1 -0
- package/dist/crypto/encoding.js +58 -0
- package/dist/crypto/encoding.js.map +1 -0
- package/dist/crypto/node.d.ts +4 -0
- package/dist/crypto/node.d.ts.map +1 -0
- package/dist/crypto/node.js +25 -0
- package/dist/crypto/node.js.map +1 -0
- package/dist/crypto/port.d.ts +42 -0
- package/dist/crypto/port.d.ts.map +1 -0
- package/dist/crypto/port.js +19 -0
- package/dist/crypto/port.js.map +1 -0
- package/dist/crypto/webcrypto.d.ts +4 -0
- package/dist/crypto/webcrypto.d.ts.map +1 -0
- package/dist/crypto/webcrypto.js +34 -0
- package/dist/crypto/webcrypto.js.map +1 -0
- package/dist/dispatch/ArgumentResolver.d.ts +10 -0
- package/dist/dispatch/ArgumentResolver.d.ts.map +1 -0
- package/dist/dispatch/ArgumentResolver.js +12 -0
- package/dist/dispatch/ArgumentResolver.js.map +1 -0
- package/dist/dispatch/ArrayResult.d.ts +3 -0
- package/dist/dispatch/ArrayResult.d.ts.map +1 -0
- package/dist/dispatch/ArrayResult.js +11 -0
- package/dist/dispatch/ArrayResult.js.map +1 -0
- package/dist/dispatch/DispatchEvent.d.ts +18 -0
- package/dist/dispatch/DispatchEvent.d.ts.map +1 -0
- package/dist/dispatch/DispatchEvent.js +30 -0
- package/dist/dispatch/DispatchEvent.js.map +1 -0
- package/dist/dispatch/DispatchLifecycle.d.ts +9 -0
- package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -0
- package/dist/dispatch/DispatchLifecycle.js +25 -0
- package/dist/dispatch/DispatchLifecycle.js.map +1 -0
- package/dist/dispatch/DispatchPort.d.ts +6 -0
- package/dist/dispatch/DispatchPort.d.ts.map +1 -0
- package/dist/dispatch/DispatchPort.js +2 -0
- package/dist/dispatch/DispatchPort.js.map +1 -0
- package/dist/dispatch/Dispatcher.d.ts +16 -0
- package/dist/dispatch/Dispatcher.d.ts.map +1 -0
- package/dist/dispatch/Dispatcher.js +44 -0
- package/dist/dispatch/Dispatcher.js.map +1 -0
- package/dist/dispatch/InFlight.d.ts +12 -0
- package/dist/dispatch/InFlight.d.ts.map +1 -0
- package/dist/dispatch/InFlight.js +46 -0
- package/dist/dispatch/InFlight.js.map +1 -0
- package/dist/dispatch/InputValidator.d.ts +7 -0
- package/dist/dispatch/InputValidator.d.ts.map +1 -0
- package/dist/dispatch/InputValidator.js +21 -0
- package/dist/dispatch/InputValidator.js.map +1 -0
- package/dist/dispatch/LocalRoutePolicy.d.ts +11 -0
- package/dist/dispatch/LocalRoutePolicy.d.ts.map +1 -0
- package/dist/dispatch/LocalRoutePolicy.js +32 -0
- package/dist/dispatch/LocalRoutePolicy.js.map +1 -0
- package/dist/dispatch/OperationExecutor.d.ts +25 -0
- package/dist/dispatch/OperationExecutor.d.ts.map +1 -0
- package/dist/dispatch/OperationExecutor.js +32 -0
- package/dist/dispatch/OperationExecutor.js.map +1 -0
- package/dist/dispatch/OperationRoute.d.ts +13 -0
- package/dist/dispatch/OperationRoute.d.ts.map +1 -0
- package/dist/dispatch/OperationRoute.js +15 -0
- package/dist/dispatch/OperationRoute.js.map +1 -0
- package/dist/dispatch/OutputProjector.d.ts +12 -0
- package/dist/dispatch/OutputProjector.d.ts.map +1 -0
- package/dist/dispatch/OutputProjector.js +30 -0
- package/dist/dispatch/OutputProjector.js.map +1 -0
- package/dist/dispatch/OutputView.d.ts +8 -0
- package/dist/dispatch/OutputView.d.ts.map +1 -0
- package/dist/dispatch/OutputView.js +10 -0
- package/dist/dispatch/OutputView.js.map +1 -0
- package/dist/dispatch/PresenterArgumentResolver.d.ts +12 -0
- package/dist/dispatch/PresenterArgumentResolver.d.ts.map +1 -0
- package/dist/dispatch/PresenterArgumentResolver.js +20 -0
- package/dist/dispatch/PresenterArgumentResolver.js.map +1 -0
- package/dist/dispatch/PresenterExecutor.d.ts +11 -0
- package/dist/dispatch/PresenterExecutor.d.ts.map +1 -0
- package/dist/dispatch/PresenterExecutor.js +56 -0
- package/dist/dispatch/PresenterExecutor.js.map +1 -0
- package/dist/dispatch/RemoteRouteResolver.d.ts +13 -0
- package/dist/dispatch/RemoteRouteResolver.d.ts.map +1 -0
- package/dist/dispatch/RemoteRouteResolver.js +18 -0
- package/dist/dispatch/RemoteRouteResolver.js.map +1 -0
- package/dist/dispatch/Route.d.ts +10 -0
- package/dist/dispatch/Route.d.ts.map +1 -0
- package/dist/dispatch/Route.js +2 -0
- package/dist/dispatch/Route.js.map +1 -0
- package/dist/dispatch/RouteNotFoundError.d.ts +10 -0
- package/dist/dispatch/RouteNotFoundError.d.ts.map +1 -0
- package/dist/dispatch/RouteNotFoundError.js +24 -0
- package/dist/dispatch/RouteNotFoundError.js.map +1 -0
- package/dist/dispatch/RoutePolicy.d.ts +8 -0
- package/dist/dispatch/RoutePolicy.d.ts.map +1 -0
- package/dist/dispatch/RoutePolicy.js +2 -0
- package/dist/dispatch/RoutePolicy.js.map +1 -0
- package/dist/dispatch/RouteRegistry.d.ts +18 -0
- package/dist/dispatch/RouteRegistry.d.ts.map +1 -0
- package/dist/dispatch/RouteRegistry.js +62 -0
- package/dist/dispatch/RouteRegistry.js.map +1 -0
- package/dist/dispatch/RouteResolver.d.ts +7 -0
- package/dist/dispatch/RouteResolver.d.ts.map +1 -0
- package/dist/dispatch/RouteResolver.js +2 -0
- package/dist/dispatch/RouteResolver.js.map +1 -0
- package/dist/dispatch/StorageGuard.d.ts +15 -0
- package/dist/dispatch/StorageGuard.d.ts.map +1 -0
- package/dist/dispatch/StorageGuard.js +63 -0
- package/dist/dispatch/StorageGuard.js.map +1 -0
- package/dist/effective-operation.d.ts +90 -0
- package/dist/effective-operation.d.ts.map +1 -0
- package/dist/effective-operation.js +450 -0
- package/dist/effective-operation.js.map +1 -0
- package/dist/emit.js +2 -2
- package/dist/emit.js.map +1 -1
- package/dist/entry/DynamicFacade.d.ts +10 -0
- package/dist/entry/DynamicFacade.d.ts.map +1 -0
- package/dist/entry/DynamicFacade.js +27 -0
- package/dist/entry/DynamicFacade.js.map +1 -0
- package/dist/entry/FacadeEntry.d.ts +11 -0
- package/dist/entry/FacadeEntry.d.ts.map +1 -0
- package/dist/entry/FacadeEntry.js +26 -0
- package/dist/entry/FacadeEntry.js.map +1 -0
- package/dist/entry/TransportEntry.d.ts +13 -0
- package/dist/entry/TransportEntry.d.ts.map +1 -0
- package/dist/entry/TransportEntry.js +24 -0
- package/dist/entry/TransportEntry.js.map +1 -0
- package/dist/frond-config.d.ts +24 -7
- package/dist/frond-config.d.ts.map +1 -1
- package/dist/frond-config.js.map +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +3 -2
- package/dist/graph.js.map +1 -1
- package/dist/identity-keys.d.ts +14 -0
- package/dist/identity-keys.d.ts.map +1 -0
- package/dist/identity-keys.js +37 -0
- package/dist/identity-keys.js.map +1 -0
- package/dist/identity.d.ts +58 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +182 -0
- package/dist/identity.js.map +1 -0
- package/dist/imports.d.ts +1 -1
- package/dist/imports.d.ts.map +1 -1
- package/dist/imports.js +7 -3
- package/dist/imports.js.map +1 -1
- package/dist/index.d.ts +57 -38
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -32
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +16 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +25 -0
- package/dist/loader.js.map +1 -0
- package/dist/node.d.ts +21 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +24 -0
- package/dist/node.js.map +1 -0
- package/dist/orm.d.ts +69 -8
- package/dist/orm.d.ts.map +1 -1
- package/dist/orm.js +35 -2
- package/dist/orm.js.map +1 -1
- package/dist/prefab/collector.d.ts +29 -0
- package/dist/prefab/collector.d.ts.map +1 -0
- package/dist/prefab/collector.js +34 -0
- package/dist/prefab/collector.js.map +1 -0
- package/dist/{crud.d.ts → prefab/crud.d.ts} +7 -8
- package/dist/prefab/crud.d.ts.map +1 -0
- package/dist/{crud.js → prefab/crud.js} +39 -5
- package/dist/prefab/crud.js.map +1 -0
- package/dist/prefab/mirror.d.ts +52 -0
- package/dist/prefab/mirror.d.ts.map +1 -0
- package/dist/prefab/mirror.js +66 -0
- package/dist/prefab/mirror.js.map +1 -0
- package/dist/prefab/prefab.d.ts +15 -0
- package/dist/prefab/prefab.d.ts.map +1 -0
- package/dist/prefab/prefab.js +19 -0
- package/dist/prefab/prefab.js.map +1 -0
- package/dist/{presenter.d.ts → prefab/presenter.d.ts} +6 -17
- package/dist/prefab/presenter.d.ts.map +1 -0
- package/dist/{presenter.js → prefab/presenter.js} +5 -23
- package/dist/prefab/presenter.js.map +1 -0
- package/dist/prefab/repository.d.ts +104 -0
- package/dist/prefab/repository.d.ts.map +1 -0
- package/dist/prefab/repository.js +62 -0
- package/dist/prefab/repository.js.map +1 -0
- package/dist/scan/Fronds.d.ts +45 -0
- package/dist/scan/Fronds.d.ts.map +1 -0
- package/dist/scan/Fronds.js +66 -0
- package/dist/scan/Fronds.js.map +1 -0
- package/dist/scan/conventions.d.ts +74 -0
- package/dist/scan/conventions.d.ts.map +1 -0
- package/dist/scan/conventions.js +82 -0
- package/dist/scan/conventions.js.map +1 -0
- package/dist/scan/emit.d.ts +14 -0
- package/dist/scan/emit.d.ts.map +1 -0
- package/dist/scan/emit.js +211 -0
- package/dist/scan/emit.js.map +1 -0
- package/dist/scan/frond.d.ts +224 -0
- package/dist/scan/frond.d.ts.map +1 -0
- package/dist/scan/frond.js +2 -0
- package/dist/scan/frond.js.map +1 -0
- package/dist/{handler-parser.d.ts → scan/handler-parser.d.ts} +18 -9
- package/dist/scan/handler-parser.d.ts.map +1 -0
- package/dist/scan/handler-parser.js +625 -0
- package/dist/scan/handler-parser.js.map +1 -0
- package/dist/scan/scan-cache.d.ts +16 -0
- package/dist/scan/scan-cache.d.ts.map +1 -0
- package/dist/{scan-cache.js → scan/scan-cache.js} +27 -20
- package/dist/scan/scan-cache.js.map +1 -0
- package/dist/scan/scanner.d.ts +20 -0
- package/dist/scan/scanner.d.ts.map +1 -0
- package/dist/{scanner.js → scan/scanner.js} +185 -167
- package/dist/scan/scanner.js.map +1 -0
- package/dist/verify.d.ts +16 -3
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +21 -18
- package/dist/verify.js.map +1 -1
- package/dist/{call.d.ts → wire/call.d.ts} +70 -1
- package/dist/wire/call.d.ts.map +1 -0
- package/dist/{call.js → wire/call.js} +48 -75
- package/dist/wire/call.js.map +1 -0
- package/dist/{middleware.d.ts → wire/errors.d.ts} +18 -19
- package/dist/wire/errors.d.ts.map +1 -0
- package/dist/{middleware.js → wire/errors.js} +26 -14
- package/dist/wire/errors.js.map +1 -0
- package/dist/{errors.d.ts → wire/http-error.d.ts} +5 -6
- package/dist/wire/http-error.d.ts.map +1 -0
- package/dist/{errors.js → wire/http-error.js} +7 -6
- package/dist/wire/http-error.js.map +1 -0
- package/dist/wire/invocation.d.ts +4 -0
- package/dist/wire/invocation.d.ts.map +1 -0
- package/dist/wire/invocation.js +3 -0
- package/dist/wire/invocation.js.map +1 -0
- package/dist/{middleware/logger.d.ts → wire/loggerMiddleware.d.ts} +3 -3
- package/dist/wire/loggerMiddleware.d.ts.map +1 -0
- package/dist/{middleware/logger.js → wire/loggerMiddleware.js} +2 -2
- package/dist/wire/loggerMiddleware.js.map +1 -0
- package/dist/wire/middleware.d.ts +29 -0
- package/dist/wire/middleware.d.ts.map +1 -0
- package/dist/wire/middleware.js +20 -0
- package/dist/wire/middleware.js.map +1 -0
- package/dist/{operation.d.ts → wire/operation.d.ts} +39 -10
- package/dist/wire/operation.d.ts.map +1 -0
- package/dist/wire/operation.js +167 -0
- package/dist/wire/operation.js.map +1 -0
- package/package.json +24 -7
- package/dist/binding.d.ts.map +0 -1
- package/dist/binding.js.map +0 -1
- package/dist/boot.d.ts.map +0 -1
- package/dist/boot.js +0 -53
- package/dist/boot.js.map +0 -1
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -879
- package/dist/bootstrap.js.map +0 -1
- package/dist/call.d.ts.map +0 -1
- package/dist/call.js.map +0 -1
- package/dist/collector.d.ts +0 -28
- package/dist/collector.d.ts.map +0 -1
- package/dist/collector.js +0 -32
- package/dist/collector.js.map +0 -1
- package/dist/crud.d.ts.map +0 -1
- package/dist/crud.js.map +0 -1
- package/dist/egress.d.ts +0 -52
- package/dist/egress.d.ts.map +0 -1
- package/dist/egress.js +0 -186
- package/dist/egress.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/handler-parser.d.ts.map +0 -1
- package/dist/handler-parser.js +0 -505
- package/dist/handler-parser.js.map +0 -1
- package/dist/invocation.d.ts +0 -20
- package/dist/invocation.d.ts.map +0 -1
- package/dist/invocation.js +0 -15
- package/dist/invocation.js.map +0 -1
- package/dist/middleware/error-handler.d.ts +0 -15
- package/dist/middleware/error-handler.d.ts.map +0 -1
- package/dist/middleware/error-handler.js +0 -29
- package/dist/middleware/error-handler.js.map +0 -1
- package/dist/middleware/logger.d.ts.map +0 -1
- package/dist/middleware/logger.js.map +0 -1
- package/dist/middleware.d.ts.map +0 -1
- package/dist/middleware.js.map +0 -1
- package/dist/mirror.d.ts +0 -93
- package/dist/mirror.d.ts.map +0 -1
- package/dist/mirror.js +0 -96
- package/dist/mirror.js.map +0 -1
- package/dist/operation.d.ts.map +0 -1
- package/dist/operation.js +0 -95
- package/dist/operation.js.map +0 -1
- package/dist/presenter.d.ts.map +0 -1
- package/dist/presenter.js.map +0 -1
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js.map +0 -1
- package/dist/repository.d.ts +0 -55
- package/dist/repository.d.ts.map +0 -1
- package/dist/repository.js +0 -26
- package/dist/repository.js.map +0 -1
- package/dist/scan-cache.d.ts +0 -10
- package/dist/scan-cache.d.ts.map +0 -1
- package/dist/scan-cache.js.map +0 -1
- package/dist/scanner.d.ts +0 -34
- package/dist/scanner.d.ts.map +0 -1
- package/dist/scanner.js.map +0 -1
- package/dist/seed.d.ts.map +0 -1
- package/dist/seed.js.map +0 -1
- package/dist/types.d.ts +0 -421
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- /package/dist/{bootstrap.d.ts → boot/bootstrap.d.ts} +0 -0
- /package/dist/{types.js → boot/types.js} +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { registrationKeyOf } from '@fougere/schema';
|
|
2
|
+
import { collectorKeyOf } from '../prefab/collector.js';
|
|
3
|
+
import { presenterKeyOf } from '../prefab/presenter.js';
|
|
4
|
+
import { repositoryKeyOf } from '../prefab/repository.js';
|
|
5
|
+
import { targetOf } from '../prefab/prefab.js';
|
|
6
|
+
import { InputValidator } from '../dispatch/InputValidator.js';
|
|
7
|
+
import { ArgumentResolver } from '../dispatch/ArgumentResolver.js';
|
|
8
|
+
import { OperationExecutor } from '../dispatch/OperationExecutor.js';
|
|
9
|
+
import { OutputProjector } from '../dispatch/OutputProjector.js';
|
|
10
|
+
import { OutputView } from '../dispatch/OutputView.js';
|
|
11
|
+
import { PresenterExecutor } from '../dispatch/PresenterExecutor.js';
|
|
12
|
+
import { PresenterArgumentResolver } from '../dispatch/PresenterArgumentResolver.js';
|
|
13
|
+
/** Adapts one handler door to executable operations. */
|
|
14
|
+
export class HandlerFacade {
|
|
15
|
+
door;
|
|
16
|
+
wiring;
|
|
17
|
+
/** Rich operation facts shared with check, explain and adapters. */
|
|
18
|
+
effectiveOperations;
|
|
19
|
+
/** Contracts served by this door. */
|
|
20
|
+
contracts;
|
|
21
|
+
/** The callable surface: op name → the function a caller reaches. */
|
|
22
|
+
ops = {};
|
|
23
|
+
cachedViews = new Map();
|
|
24
|
+
instance;
|
|
25
|
+
implementationKeys = new Map();
|
|
26
|
+
implementationInstances = new Map();
|
|
27
|
+
inputValidator = new InputValidator();
|
|
28
|
+
argumentResolver = new ArgumentResolver((typeName) => this.collectorResolver(typeName));
|
|
29
|
+
presenterArguments;
|
|
30
|
+
constructor(door, wiring) {
|
|
31
|
+
this.door = door;
|
|
32
|
+
this.wiring = wiring;
|
|
33
|
+
const { handler, entity } = door;
|
|
34
|
+
this.presenterArguments = new PresenterArgumentResolver(this.argumentResolver, wiring.collectors);
|
|
35
|
+
this.refuseCrudWithoutRepository(handler);
|
|
36
|
+
door.scope.register(this.handlerKey, handler.ctor, { deps: this.depsOf(handler) });
|
|
37
|
+
this.effectiveOperations = door.operations;
|
|
38
|
+
this.contracts = new Map([...door.operations].map(([name, operation]) => [name, operation]));
|
|
39
|
+
handler.operations = this.contracts;
|
|
40
|
+
// Register model-selected implementations in the same execution scope.
|
|
41
|
+
for (const [name, operation] of door.operations) {
|
|
42
|
+
if (this.isBaseImplementation(operation))
|
|
43
|
+
continue;
|
|
44
|
+
const implementation = this.implementationHandler(name);
|
|
45
|
+
this.refuseCrudWithoutRepository(implementation);
|
|
46
|
+
const key = `${this.handlerKey}:implementation:${operation.implementation.className}`;
|
|
47
|
+
if (!this.implementationKeys.has(operation.implementation.className)) {
|
|
48
|
+
door.scope.register(key, implementation.ctor, { deps: this.depsOf(implementation) });
|
|
49
|
+
this.implementationKeys.set(operation.implementation.className, key);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Emissions use the same contracts and execution path as direct calls.
|
|
53
|
+
wiring.emissions.note(this.contracts, door.key);
|
|
54
|
+
// Only declared operations become callable façade members.
|
|
55
|
+
for (const op of this.contracts.keys())
|
|
56
|
+
this.ops[op] = this.wrap(op);
|
|
57
|
+
if (this.inheritsCrud(handler) && !entity) {
|
|
58
|
+
// An installed Crud subject may be absent from the local scan.
|
|
59
|
+
wiring.log.debug(`${handler.ctor.name} extends Crud() and no scanned entity is named `
|
|
60
|
+
+ `'${this.subjectOf(handler)}' — installed entity, or a missing one: no ORM will be injected`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Storage follows the Crud subject, which may differ from the door address. */
|
|
64
|
+
subjectOf(handler) {
|
|
65
|
+
const target = targetOf(handler.ctor);
|
|
66
|
+
return target?.name ? registrationKeyOf(target.name) : handler.address;
|
|
67
|
+
}
|
|
68
|
+
inheritsCrud(handler) {
|
|
69
|
+
const proto = handler.ctor.prototype;
|
|
70
|
+
return typeof proto?.list === 'function' && typeof proto?.findById === 'function';
|
|
71
|
+
}
|
|
72
|
+
get handlerKey() {
|
|
73
|
+
return `_handler:${this.door.key}`;
|
|
74
|
+
}
|
|
75
|
+
depsOf(handler) {
|
|
76
|
+
const { deps } = handler;
|
|
77
|
+
if (deps.length > 0)
|
|
78
|
+
return deps;
|
|
79
|
+
return this.inheritsCrud(handler) ? [repositoryKeyOf(this.subjectOf(handler))] : [];
|
|
80
|
+
}
|
|
81
|
+
/** A custom Crud constructor must explicitly receive its repository. */
|
|
82
|
+
refuseCrudWithoutRepository(handler) {
|
|
83
|
+
const repoTypeName = repositoryKeyOf(this.subjectOf(handler));
|
|
84
|
+
if (!this.inheritsCrud(handler) || handler.deps.length === 0 || handler.deps.includes(repoTypeName))
|
|
85
|
+
return;
|
|
86
|
+
throw new Error(`${handler.ctor.name} extends Crud() and declares a constructor, so its storage is no ` +
|
|
87
|
+
`longer injected for it — but it does not take any.\n` +
|
|
88
|
+
` Add it and hand it to super():\n` +
|
|
89
|
+
` constructor(repo: ${repoTypeName}, …) { super(repo); }`);
|
|
90
|
+
}
|
|
91
|
+
/** Resolve and cache the output view declared for one operation. */
|
|
92
|
+
viewOf(op) {
|
|
93
|
+
const known = this.cachedViews.get(op);
|
|
94
|
+
if (known)
|
|
95
|
+
return known;
|
|
96
|
+
const operation = this.effectiveOperations.get(op);
|
|
97
|
+
const schema = operation?.output;
|
|
98
|
+
const resolved = new OutputView(typeof schema?.getFields === 'function' ? schema.getFields() : {}, operation?.outputClosed ?? false);
|
|
99
|
+
this.cachedViews.set(op, resolved);
|
|
100
|
+
return resolved;
|
|
101
|
+
}
|
|
102
|
+
collectorResolver = (typeName) => {
|
|
103
|
+
try {
|
|
104
|
+
return this.door.scope.resolve(collectorKeyOf(typeName));
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
/** The handler itself, resolved on first call — never at boot. */
|
|
111
|
+
resolvedHandler() {
|
|
112
|
+
if (!this.instance)
|
|
113
|
+
this.instance = this.door.scope.resolve(this.handlerKey);
|
|
114
|
+
return this.instance;
|
|
115
|
+
}
|
|
116
|
+
isBaseImplementation(operation) {
|
|
117
|
+
return operation.implementation.className === this.door.handler.ctor.name
|
|
118
|
+
&& operation.implementation.address === this.door.handler.address
|
|
119
|
+
&& operation.implementation.filePath === this.door.handler.filePath;
|
|
120
|
+
}
|
|
121
|
+
/** The exact handler entry the pure model selected; no name-only retry or fallback. */
|
|
122
|
+
implementationHandler(operationName) {
|
|
123
|
+
const operation = this.effectiveOperations.get(operationName);
|
|
124
|
+
const matches = this.door.handlers.filter((handler) => handler.ctor.name === operation.implementation.className
|
|
125
|
+
&& handler.address === operation.implementation.address
|
|
126
|
+
&& handler.filePath === operation.implementation.filePath);
|
|
127
|
+
if (matches.length !== 1) {
|
|
128
|
+
throw new Error(`EffectiveOperation '${operation.id}' names ${operation.implementation.className}.`
|
|
129
|
+
+ `${operation.implementation.method}, but boot found ${matches.length} matching handlers.`);
|
|
130
|
+
}
|
|
131
|
+
return matches[0];
|
|
132
|
+
}
|
|
133
|
+
resolvedImplementation(operationName) {
|
|
134
|
+
const operation = this.effectiveOperations.get(operationName);
|
|
135
|
+
if (this.isBaseImplementation(operation)) {
|
|
136
|
+
return { instance: this.resolvedHandler(), method: operation.implementation.method };
|
|
137
|
+
}
|
|
138
|
+
const className = operation.implementation.className;
|
|
139
|
+
const key = this.implementationKeys.get(className);
|
|
140
|
+
if (!key)
|
|
141
|
+
throw new Error(`No registered implementation for EffectiveOperation '${operation.id}'.`);
|
|
142
|
+
let instance = this.implementationInstances.get(key);
|
|
143
|
+
if (!instance) {
|
|
144
|
+
instance = this.door.scope.resolve(key);
|
|
145
|
+
this.implementationInstances.set(key, instance);
|
|
146
|
+
}
|
|
147
|
+
return { instance, method: operation.implementation.method };
|
|
148
|
+
}
|
|
149
|
+
wrap(op) {
|
|
150
|
+
const address = this.door.handler.address;
|
|
151
|
+
const contract = this.contracts.get(op);
|
|
152
|
+
const view = this.viewOf(op);
|
|
153
|
+
const presenter = this.wiring.presenters.get(address);
|
|
154
|
+
const executor = new OperationExecutor({
|
|
155
|
+
entity: address,
|
|
156
|
+
frond: this.wiring.frond,
|
|
157
|
+
operation: op,
|
|
158
|
+
contract,
|
|
159
|
+
middlewares: () => this.wiring.middlewaresFor(address),
|
|
160
|
+
validator: this.inputValidator,
|
|
161
|
+
arguments: this.argumentResolver,
|
|
162
|
+
invoke: async (args) => {
|
|
163
|
+
const implementation = this.resolvedImplementation(op);
|
|
164
|
+
return implementation.instance[implementation.method](...args);
|
|
165
|
+
},
|
|
166
|
+
projector: new OutputProjector(view),
|
|
167
|
+
...(view.closed || !presenter ? {} : {
|
|
168
|
+
present: async (result, effective) => new PresenterExecutor(this.wiring.frondScope.resolve(presenterKeyOf(address)), presenter.fields, address, op).present(result, await this.presenterArguments.resolve(presenter, effective)),
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
return (invocation) => executor.execute(invocation);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=HandlerFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandlerFacade.js","sourceRoot":"","sources":["../../src/boot/HandlerFacade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,iBAAiB,CAAC;AAIjE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAgCrF,wDAAwD;AACxD,MAAM,OAAO,aAAa;IAmBK;IAAgC;IAlB7D,oEAAoE;IAC3D,mBAAmB,CAAyB;IACrD,qCAAqC;IAC5B,SAAS,CAAgB;IAElC,qEAAqE;IAC5D,GAAG,GAA6B,EAAE,CAAC;IAE3B,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IACrD,QAAQ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,gBAAgB;YAChC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACrB,MAAM,cAAc,GAAG,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;gBACvD,OAAO,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YACjE,CAAC;YACD,SAAS,EAAE,IAAI,eAAe,CAAC,IAAI,CAAC;YACpC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnC,OAAO,EAAE,KAAK,EAAE,MAAe,EAAE,SAA4B,EAAE,EAAE,CAC/D,IAAI,iBAAiB,CACnB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACvD,SAAS,CAAC,MAAM,EAChB,OAAO,EACP,EAAE,CACH,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;aACjF,CAAC;SACH,CAAC,CAAC;QAEH,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lifecycle.d.ts","sourceRoot":"","sources":["../../src/boot/Lifecycle.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,YAAY,EAAE,YAAY,IAAI,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvF,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lifecycle.js","sourceRoot":"","sources":["../../src/boot/Lifecycle.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,YAAY,EAAE,YAAY,IAAI,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a call needs to know about the call it is inside, and the two ways to answer it.
|
|
3
|
+
*
|
|
4
|
+
* One realization reads an async context (`ambient.als.ts`), the other cannot and waits
|
|
5
|
+
* its turn instead (`ambient.queue.ts`). `#ambient` in package.json picks one per runtime,
|
|
6
|
+
* so a bundle for a host without async context never names `node:async_hooks`.
|
|
7
|
+
*/
|
|
8
|
+
export interface Ambient {
|
|
9
|
+
/** True when this runtime has no async context, and the boot says so. */
|
|
10
|
+
readonly degraded: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Run `fn` as the frame `key`. A frame opened inside another must not proceed.
|
|
13
|
+
*
|
|
14
|
+
* Measured on SQLite: a second transaction on the same connection WAITS for the first,
|
|
15
|
+
* so a nested frame hangs on one engine and returns when split across two.
|
|
16
|
+
*/
|
|
17
|
+
enterFrame<R>(key: string, fn: () => Promise<R>): Promise<R>;
|
|
18
|
+
/**
|
|
19
|
+
* Settle before `fact` is dispatched: a fact announced inside a frame that then rolls
|
|
20
|
+
* back is a lie. Refuses when the caller's own frame can be told, waits when it cannot.
|
|
21
|
+
*/
|
|
22
|
+
beforeAnnounce(fact: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* The facts already being announced up the stack, so a fact cannot cause itself.
|
|
25
|
+
*
|
|
26
|
+
* A CHAIN and not a depth: `A → B → D` and `A → C → D` is a diamond, perfectly legal,
|
|
27
|
+
* while `A → … → A` never ends. Empty where it cannot be followed.
|
|
28
|
+
*
|
|
29
|
+
* Detecting this at boot was the first idea and it was wrong: `Emit<G>` is a CONSTRUCTOR
|
|
30
|
+
* dependency, so it belongs to the handler and not to one of its methods. A handler that
|
|
31
|
+
* subscribes to `A` in one method and emits `G` from another would have been refused for
|
|
32
|
+
* a cycle it never walks.
|
|
33
|
+
*/
|
|
34
|
+
currentChain(): readonly string[];
|
|
35
|
+
/** Run `fn` with `fact` appended to the emission chain. */
|
|
36
|
+
enterChain<R>(fact: string, fn: () => Promise<R>): Promise<R>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ambient-port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient-port.d.ts","sourceRoot":"","sources":["../../src/boot/ambient-port.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7D;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C;;;;;;;;;;OAUG;IACH,YAAY,IAAI,SAAS,MAAM,EAAE,CAAC;IAElC,2DAA2D;IAC3D,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient-port.js","sourceRoot":"","sources":["../../src/boot/ambient-port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient.als.d.ts","sourceRoot":"","sources":["../../src/boot/ambient.als.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAKjD,eAAO,MAAM,OAAO,EAAE,OA8BrB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The realization that can tell whose frame is open: an async context.
|
|
3
|
+
*
|
|
4
|
+
* Chosen by `#ambient` wherever `node:async_hooks` exists — Node, Deno, Bun, and workerd
|
|
5
|
+
* with `nodejs_als`. Every refusal here is immediate and names its cause.
|
|
6
|
+
*/
|
|
7
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
8
|
+
const frame = new AsyncLocalStorage();
|
|
9
|
+
const chain = new AsyncLocalStorage();
|
|
10
|
+
export const ambient = {
|
|
11
|
+
degraded: false,
|
|
12
|
+
enterFrame(key, fn) {
|
|
13
|
+
const held = frame.getStore();
|
|
14
|
+
if (held !== undefined) {
|
|
15
|
+
return Promise.reject(new Error(`Together<[…]> (${key}) cannot be opened inside ${held}: on one engine the second `
|
|
16
|
+
+ `transaction waits for the first and the call hangs. Two frames that must both hold `
|
|
17
|
+
+ `are ONE frame — declare a single Together naming every member.`));
|
|
18
|
+
}
|
|
19
|
+
return frame.run(key, fn);
|
|
20
|
+
},
|
|
21
|
+
beforeAnnounce(fact) {
|
|
22
|
+
const held = frame.getStore();
|
|
23
|
+
if (held === undefined)
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
return Promise.reject(new Error(`${fact} cannot be announced inside Together<[…]> (${held}): announcing is dispatch, `
|
|
26
|
+
+ `so subscribers and the carrier would have it while these writes can still be taken `
|
|
27
|
+
+ `back. Announce after run() returns, when it is true.`));
|
|
28
|
+
},
|
|
29
|
+
currentChain: () => chain.getStore() ?? [],
|
|
30
|
+
enterChain(fact, fn) {
|
|
31
|
+
return chain.run([...(chain.getStore() ?? []), fact], fn);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=ambient.als.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient.als.js","sourceRoot":"","sources":["../../src/boot/ambient.als.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,KAAK,GAAG,IAAI,iBAAiB,EAAU,CAAC;AAC9C,MAAM,KAAK,GAAG,IAAI,iBAAiB,EAAqB,CAAC;AAEzD,MAAM,CAAC,MAAM,OAAO,GAAY;IAC9B,QAAQ,EAAE,KAAK;IAEf,UAAU,CAAI,GAAW,EAAE,EAAoB;QAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAC7B,kBAAkB,GAAG,6BAA6B,IAAI,6BAA6B;kBACjF,qFAAqF;kBACrF,gEAAgE,CACnE,CAAC,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,cAAc,CAAC,IAAY;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QACjD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAC7B,GAAG,IAAI,8CAA8C,IAAI,6BAA6B;cACpF,qFAAqF;cACrF,sDAAsD,CACzD,CAAC,CAAC;IACL,CAAC;IAED,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE;IAE1C,UAAU,CAAI,IAAY,EAAE,EAAoB;QAC9C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The realization for a runtime with no async context: it cannot tell whose frame is
|
|
3
|
+
* open, so it never guesses — it waits its turn.
|
|
4
|
+
*
|
|
5
|
+
* Two consequences the boot reports rather than hides: frames run one at a time, and a
|
|
6
|
+
* frame opened inside another is not refused, it waits for itself and times out.
|
|
7
|
+
*/
|
|
8
|
+
import type { Ambient } from './ambient-port.js';
|
|
9
|
+
export declare const ambient: Ambient;
|
|
10
|
+
//# sourceMappingURL=ambient.queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient.queue.d.ts","sourceRoot":"","sources":["../../src/boot/ambient.queue.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAmBjD,eAAO,MAAM,OAAO,EAAE,OAgDrB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** What a nested frame waits before it is told what it did — the hang, measured, plus a name. */
|
|
2
|
+
const NESTED_TIMEOUT_MS = 5_000;
|
|
3
|
+
let busy;
|
|
4
|
+
let holder;
|
|
5
|
+
const settled = () => undefined;
|
|
6
|
+
/** Resolves when `p` settles or `ms` elapses, whichever comes first, holding no timer after. */
|
|
7
|
+
function raceWith(p, ms) {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
const timer = setTimeout(resolve, ms);
|
|
10
|
+
const clear = () => { clearTimeout(timer); resolve(); };
|
|
11
|
+
void p.then(clear, clear);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export const ambient = {
|
|
15
|
+
degraded: true,
|
|
16
|
+
async enterFrame(key, fn) {
|
|
17
|
+
const deadline = Date.now() + NESTED_TIMEOUT_MS;
|
|
18
|
+
for (;;) {
|
|
19
|
+
// Nothing may await between this test and the reservation below, or two waiters
|
|
20
|
+
// woken in the same tick would both take the frame.
|
|
21
|
+
if (busy === undefined)
|
|
22
|
+
break;
|
|
23
|
+
const left = deadline - Date.now();
|
|
24
|
+
if (left <= 0) {
|
|
25
|
+
throw new Error(`Together<[…]> (${key}) waited ${NESTED_TIMEOUT_MS}ms for ${holder} and gave up. `
|
|
26
|
+
+ `This runtime has no async context, so a frame opened inside another waits for `
|
|
27
|
+
+ `itself instead of being refused. Two frames that must both hold are ONE frame — `
|
|
28
|
+
+ `declare a single Together naming every member.`);
|
|
29
|
+
}
|
|
30
|
+
await raceWith(busy, left);
|
|
31
|
+
}
|
|
32
|
+
// Held BEFORE `fn` runs: the first thing a frame's body does may be to open another,
|
|
33
|
+
// and reserving on the returned promise would be one tick too late to see it.
|
|
34
|
+
let release = settled;
|
|
35
|
+
busy = new Promise((resolve) => { release = resolve; });
|
|
36
|
+
holder = key;
|
|
37
|
+
try {
|
|
38
|
+
return await fn();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
busy = undefined;
|
|
42
|
+
holder = undefined;
|
|
43
|
+
release();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Waits rather than refuses: whose frame is open cannot be told here, and refusing on
|
|
48
|
+
* that would refuse an announcement made by an unrelated call.
|
|
49
|
+
*/
|
|
50
|
+
async beforeAnnounce(_fact) {
|
|
51
|
+
while (busy)
|
|
52
|
+
await raceWith(busy, NESTED_TIMEOUT_MS);
|
|
53
|
+
},
|
|
54
|
+
/** No chain can be followed here — an emission ring is not detected. Said at boot. */
|
|
55
|
+
currentChain: () => [],
|
|
56
|
+
enterChain(_fact, fn) {
|
|
57
|
+
return fn();
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=ambient.queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient.queue.js","sourceRoot":"","sources":["../../src/boot/ambient.queue.ts"],"names":[],"mappings":"AASA,iGAAiG;AACjG,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,IAAI,IAA+B,CAAC;AACpC,IAAI,MAA0B,CAAC;AAE/B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAEhC,gGAAgG;AAChG,SAAS,QAAQ,CAAC,CAAgB,EAAE,EAA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IAAI,GAAG,SAAS,CAAC;YACjB,MAAM,GAAG,SAAS,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,KAAa;QAChC,OAAO,IAAI;YAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACvD,CAAC;IAED,sFAAsF;IACtF,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE;IAEtB,UAAU,CAAI,KAAa,EAAE,EAAoB;QAC/C,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FougereConfig } from '../config-loader.js';
|
|
2
|
+
export interface ConfigApplication {
|
|
3
|
+
/** What this call changed in the running process. */
|
|
4
|
+
applied: string[];
|
|
5
|
+
/** What differs from the config in force and did NOT take effect. */
|
|
6
|
+
pending: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* What a (re-)read config changes in a process that is already running.
|
|
10
|
+
*
|
|
11
|
+
* The rule it realizes, and the only one worth remembering: **a value that is
|
|
12
|
+
* CONSULTED can change under a running app; a value that was CONSUMED to build
|
|
13
|
+
* something cannot, without rebuilding what it built.** `logLevel` is consulted at
|
|
14
|
+
* every emission, so it moves. `db` opened a connection, `ports:` registered a class,
|
|
15
|
+
* the entities built façades — those are consumed, and this function reports them
|
|
16
|
+
* rather than pretending.
|
|
17
|
+
*
|
|
18
|
+
* The list of consulted keys is not declared anywhere: a key is consulted when this
|
|
19
|
+
* function does something with it, which is the only definition that cannot go stale.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyConfig(next: FougereConfig, inForce?: FougereConfig): ConfigApplication;
|
|
22
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/boot/apply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qEAAqE;IACrE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAsB3F"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { setLogLevel, logLevel, envLevel } from '../builtins/logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a (re-)read config changes in a process that is already running.
|
|
4
|
+
*
|
|
5
|
+
* The rule it realizes, and the only one worth remembering: **a value that is
|
|
6
|
+
* CONSULTED can change under a running app; a value that was CONSUMED to build
|
|
7
|
+
* something cannot, without rebuilding what it built.** `logLevel` is consulted at
|
|
8
|
+
* every emission, so it moves. `db` opened a connection, `ports:` registered a class,
|
|
9
|
+
* the entities built façades — those are consumed, and this function reports them
|
|
10
|
+
* rather than pretending.
|
|
11
|
+
*
|
|
12
|
+
* The list of consulted keys is not declared anywhere: a key is consulted when this
|
|
13
|
+
* function does something with it, which is the only definition that cannot go stale.
|
|
14
|
+
*/
|
|
15
|
+
export function applyConfig(next, inForce) {
|
|
16
|
+
const applied = [];
|
|
17
|
+
const pending = [];
|
|
18
|
+
// The CLI speaks through the environment, so it keeps winning over the file — read
|
|
19
|
+
// through `envLevel`, which is where the environment is already judged. Casting it
|
|
20
|
+
// here was a second reader that validated nothing: `FOUGERE_LOG_LEVEL=verbose` set
|
|
21
|
+
// the threshold to `undefined` and every log passed.
|
|
22
|
+
const wanted = envLevel() ?? next.logLevel ?? 'debug';
|
|
23
|
+
const before = logLevel();
|
|
24
|
+
if (wanted !== before) {
|
|
25
|
+
setLogLevel(wanted);
|
|
26
|
+
applied.push(`logLevel: ${before} → ${wanted}`);
|
|
27
|
+
}
|
|
28
|
+
for (const key of new Set([...Object.keys(next), ...Object.keys(inForce ?? {})])) {
|
|
29
|
+
if (key === 'logLevel' || !inForce)
|
|
30
|
+
continue;
|
|
31
|
+
if (!same(next[key], inForce[key])) {
|
|
32
|
+
pending.push(key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { applied, pending };
|
|
36
|
+
}
|
|
37
|
+
/** Equal enough to decide "nothing changed". Anything unserialisable counts as changed. */
|
|
38
|
+
function same(a, b) {
|
|
39
|
+
if (a === b)
|
|
40
|
+
return true;
|
|
41
|
+
try {
|
|
42
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/boot/apply.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AASxE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,IAAmB,EAAE,OAAuB;IACtE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,mFAAmF;IACnF,mFAAmF;IACnF,mFAAmF;IACnF,qDAAqD;IACrD,MAAM,MAAM,GAAG,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IACtD,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,aAAa,MAAM,MAAM,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,IAAI,GAAG,KAAK,UAAU,IAAI,CAAC,OAAO;YAAE,SAAS;QAC7C,IAAI,CAAC,IAAI,CAAE,IAAgC,CAAC,GAAG,CAAC,EAAG,OAAmC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7F,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,2FAA2F;AAC3F,SAAS,IAAI,CAAC,CAAU,EAAE,CAAU;IAClC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an auth provider promises the boot, and what the boot hands it — the whole of
|
|
3
|
+
* the contract between core and an `@fougere/auth-*` package.
|
|
4
|
+
*/
|
|
5
|
+
import type { SchemaView } from '@fougere/schema';
|
|
6
|
+
import type { EntityOrm, OrmFactory } from '../orm.js';
|
|
7
|
+
/**
|
|
8
|
+
* Lazy auth declaration written in fougere.config.ts.
|
|
9
|
+
*
|
|
10
|
+
* Each @fougere/auth-* package exports a factory (e.g. `betterAuth(opts)`) that
|
|
11
|
+
* returns this shape. The `create()` method is called once at boot with the
|
|
12
|
+
* resolved db + ormFactory, so the provider can wire its engine through Fougere.
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthConfig {
|
|
15
|
+
/** Build the runtime — invoked by createApp at boot with the resolved storage handles. */
|
|
16
|
+
create(ctx: AuthContext): AuthRuntime | Promise<AuthRuntime>;
|
|
17
|
+
/**
|
|
18
|
+
* Entities the provider will use. Optional metadata — useful for the core's
|
|
19
|
+
* future migration registry to know which tables auth needs.
|
|
20
|
+
*/
|
|
21
|
+
entities?: Record<string, SchemaView>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Context passed by the core to an auth provider's create() function.
|
|
25
|
+
* Provides the resources the provider needs to integrate with the app.
|
|
26
|
+
*/
|
|
27
|
+
export interface AuthContext {
|
|
28
|
+
/** Storage handle (Kysely DB instance, Prisma client, etc.) — opaque to core. */
|
|
29
|
+
db: unknown;
|
|
30
|
+
/** Per-entity ORM factory — auth provider uses this to back its adapter. */
|
|
31
|
+
ormFactory: OrmFactory;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runtime returned by an auth provider's create(config, ctx) function.
|
|
35
|
+
* The core mounts this on the App and the HTTP layer (Nuxt module / router) uses it.
|
|
36
|
+
*/
|
|
37
|
+
export interface AuthRuntime {
|
|
38
|
+
/** Entities used by the provider, including any defaults it filled in. */
|
|
39
|
+
entities: Record<string, SchemaView>;
|
|
40
|
+
/**
|
|
41
|
+
* Per-entity ORMs the provider built for itself. Exposed so app code can
|
|
42
|
+
* query auth tables (e.g. list active sessions for a user) without rebuilding
|
|
43
|
+
* the same EntityOrm.
|
|
44
|
+
*/
|
|
45
|
+
orms: Record<string, EntityOrm>;
|
|
46
|
+
/** Web Standard handler that processes /auth/* requests. */
|
|
47
|
+
handler: (request: Request) => Promise<Response>;
|
|
48
|
+
/** Programmatic API exposed by the provider (getSession, signOut, ...). */
|
|
49
|
+
api: Record<string, unknown>;
|
|
50
|
+
/** Effective mount path (echoes config.basePath or the provider's default). */
|
|
51
|
+
basePath: string;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/boot/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,0FAA0F;IAC1F,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7D;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,iFAAiF;IACjF,EAAE,EAAE,OAAO,CAAC;IACZ,4EAA4E;IAC5E,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACrC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChC,4DAA4D;IAC5D,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,2EAA2E;IAC3E,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/boot/auth.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Where each parameter of an operation gets its value — decided once at boot from the
|
|
3
|
+
* parsed signature, replayed per call by `resolveArgs`.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Algorithm (by param type):
|
|
8
|
-
* 1. Collector entity type → resolved via Collector.collect(ctx)
|
|
9
|
-
* 2. InvocationContext → the context itself
|
|
10
|
-
* 3. Primitive (string, number, boolean) → matched by name from params then query
|
|
11
|
-
* 4. Object/entity type → matched from body
|
|
5
|
+
* The branches are ORDERED and each states why it sits where it does; the list used to
|
|
6
|
+
* be repeated here too, and it had already lost `Fact` — the one whose position is
|
|
7
|
+
* load-bearing, since the fall-through would otherwise hand it the caller's body.
|
|
12
8
|
*/
|
|
13
|
-
import type { ParsedParam } from '
|
|
14
|
-
import type { InvocationContext } from '
|
|
15
|
-
|
|
9
|
+
import type { ParsedParam } from '../scan/handler-parser.js';
|
|
10
|
+
import type { InvocationContext } from '../wire/invocation.js';
|
|
11
|
+
type ParamSource = {
|
|
16
12
|
kind: 'collector';
|
|
17
|
-
|
|
13
|
+
typeName: string;
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
20
16
|
* `Fact<PostPublished>` — something that happened, not something a caller typed.
|
|
@@ -40,7 +36,7 @@ export type ParamSource = {
|
|
|
40
36
|
| {
|
|
41
37
|
kind: 'query';
|
|
42
38
|
};
|
|
43
|
-
|
|
39
|
+
interface ParamBinding {
|
|
44
40
|
name: string;
|
|
45
41
|
source: ParamSource;
|
|
46
42
|
optional: boolean;
|
|
@@ -50,14 +46,15 @@ export type BindingPlan = ParamBinding[];
|
|
|
50
46
|
* Build a BindingPlan from parsed method params.
|
|
51
47
|
*
|
|
52
48
|
* @param params - Parsed parameter list from AST
|
|
53
|
-
* @param
|
|
49
|
+
* @param collectorTypeNames - Registration keys of the types a Collector answers for
|
|
54
50
|
*/
|
|
55
|
-
export declare function computeBindingPlan(params: ParsedParam[],
|
|
51
|
+
export declare function computeBindingPlan(params: ParsedParam[], collectorTypeNames: Set<string>): BindingPlan;
|
|
56
52
|
export interface CollectorResolver {
|
|
57
53
|
collect(ctx: InvocationContext): Promise<unknown>;
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
60
56
|
* Resolve handler arguments from a BindingPlan + InvocationContext.
|
|
61
57
|
*/
|
|
62
|
-
export declare function resolveArgs(plan: BindingPlan, ctx: InvocationContext, resolveCollector?: (
|
|
58
|
+
export declare function resolveArgs(plan: BindingPlan, ctx: InvocationContext, resolveCollector?: (typeName: string) => CollectorResolver | undefined): Promise<unknown[]>;
|
|
59
|
+
export {};
|
|
63
60
|
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/boot/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/D,KAAK,WAAW,GACZ;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AACzC;;;;;;;GAOG;GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB,2EAA2E;GACzE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtB,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC;AAczC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,WAAW,EAAE,EACrB,kBA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