@fougere/core 0.6.0-alpha.0 → 0.8.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 +1 -1
- package/dist/boot/AppLifecycle.d.ts +1 -1
- package/dist/boot/AppLifecycle.d.ts.map +1 -1
- package/dist/boot/AppLifecycle.js +13 -2
- package/dist/boot/AppLifecycle.js.map +1 -1
- package/dist/boot/Emissions.d.ts +13 -90
- package/dist/boot/Emissions.d.ts.map +1 -1
- package/dist/boot/Emissions.js +21 -118
- package/dist/boot/Emissions.js.map +1 -1
- package/dist/boot/ambient-port.d.ts +3 -24
- package/dist/boot/ambient-port.d.ts.map +1 -1
- package/dist/boot/ambient.als.d.ts.map +1 -1
- package/dist/boot/ambient.als.js +7 -12
- package/dist/boot/ambient.als.js.map +1 -1
- package/dist/boot/ambient.queue.d.ts +2 -5
- package/dist/boot/ambient.queue.d.ts.map +1 -1
- package/dist/boot/ambient.queue.js.map +1 -1
- package/dist/boot/apply.d.ts +1 -13
- package/dist/boot/apply.d.ts.map +1 -1
- package/dist/boot/apply.js +9 -16
- package/dist/boot/apply.js.map +1 -1
- package/dist/boot/auth.d.ts +2 -12
- package/dist/boot/auth.d.ts.map +1 -1
- package/dist/boot/boot.d.ts +3 -16
- package/dist/boot/boot.d.ts.map +1 -1
- package/dist/boot/boot.js +4 -11
- package/dist/boot/boot.js.map +1 -1
- package/dist/boot/bootstrap.d.ts.map +1 -1
- package/dist/boot/bootstrap.js +84 -130
- package/dist/boot/bootstrap.js.map +1 -1
- package/dist/boot/card.d.ts +1 -17
- package/dist/boot/card.d.ts.map +1 -1
- package/dist/boot/card.js +3 -32
- package/dist/boot/card.js.map +1 -1
- package/dist/boot/frame.d.ts +8 -32
- package/dist/boot/frame.d.ts.map +1 -1
- package/dist/boot/frame.js +17 -56
- package/dist/boot/frame.js.map +1 -1
- package/dist/boot/hosted.d.ts +2 -24
- package/dist/boot/hosted.d.ts.map +1 -1
- package/dist/boot/hosted.js +10 -15
- package/dist/boot/hosted.js.map +1 -1
- package/dist/boot/ownership.d.ts +3 -36
- package/dist/boot/ownership.d.ts.map +1 -1
- package/dist/boot/ownership.js +5 -40
- package/dist/boot/ownership.js.map +1 -1
- package/dist/boot/ports.d.ts +1 -14
- package/dist/boot/ports.d.ts.map +1 -1
- package/dist/boot/ports.js +1 -14
- package/dist/boot/ports.js.map +1 -1
- package/dist/boot/remote.d.ts +5 -38
- package/dist/boot/remote.d.ts.map +1 -1
- package/dist/boot/remote.js +8 -41
- package/dist/boot/remote.js.map +1 -1
- package/dist/boot/runner.d.ts +4 -21
- package/dist/boot/runner.d.ts.map +1 -1
- package/dist/boot/runner.js +4 -17
- package/dist/boot/runner.js.map +1 -1
- package/dist/boot/seed.d.ts +4 -31
- package/dist/boot/seed.d.ts.map +1 -1
- package/dist/boot/seed.js +6 -37
- package/dist/boot/seed.js.map +1 -1
- package/dist/boot/statement-drift.d.ts +2 -21
- package/dist/boot/statement-drift.d.ts.map +1 -1
- package/dist/boot/statement-drift.js +4 -9
- package/dist/boot/statement-drift.js.map +1 -1
- package/dist/boot/together.d.ts +4 -8
- package/dist/boot/together.d.ts.map +1 -1
- package/dist/boot/together.js +15 -50
- package/dist/boot/together.js.map +1 -1
- package/dist/boot/types.d.ts +31 -173
- package/dist/boot/types.d.ts.map +1 -1
- package/dist/builtin/config.d.ts +7 -0
- package/dist/builtin/config.d.ts.map +1 -0
- package/dist/builtin/config.js +15 -0
- package/dist/builtin/config.js.map +1 -0
- package/dist/{builtins → builtin}/logger.d.ts +4 -25
- package/dist/builtin/logger.d.ts.map +1 -0
- package/dist/{builtins → builtin}/logger.js +5 -32
- package/dist/builtin/logger.js.map +1 -0
- package/dist/config-loader.d.ts +9 -67
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +5 -18
- package/dist/config-loader.js.map +1 -1
- package/dist/contract.d.ts +15 -31
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +13 -26
- package/dist/contract.js.map +1 -1
- package/dist/criterion.d.ts +37 -0
- package/dist/criterion.d.ts.map +1 -0
- package/dist/criterion.js +28 -0
- package/dist/criterion.js.map +1 -0
- package/dist/crypto/encoding.d.ts +2 -15
- package/dist/crypto/encoding.d.ts.map +1 -1
- package/dist/crypto/encoding.js +2 -15
- package/dist/crypto/encoding.js.map +1 -1
- package/dist/crypto/node.d.ts.map +1 -1
- package/dist/crypto/node.js +1 -7
- package/dist/crypto/node.js.map +1 -1
- package/dist/crypto/port.d.ts +2 -18
- package/dist/crypto/port.d.ts.map +1 -1
- package/dist/crypto/port.js +1 -17
- package/dist/crypto/port.js.map +1 -1
- package/dist/crypto/webcrypto.d.ts.map +1 -1
- package/dist/crypto/webcrypto.js +1 -12
- package/dist/crypto/webcrypto.js.map +1 -1
- package/dist/declare.d.ts +19 -37
- package/dist/declare.d.ts.map +1 -1
- package/dist/declare.js +23 -30
- package/dist/declare.js.map +1 -1
- package/dist/define.d.ts +2 -3
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +2 -3
- package/dist/define.js.map +1 -1
- package/dist/descriptor/Fronds.d.ts +3 -28
- package/dist/descriptor/Fronds.d.ts.map +1 -1
- package/dist/descriptor/Fronds.js +6 -31
- package/dist/descriptor/Fronds.js.map +1 -1
- package/dist/descriptor/frond.d.ts +25 -60
- package/dist/descriptor/frond.d.ts.map +1 -1
- package/dist/descriptor/frond.js +5 -1
- package/dist/descriptor/frond.js.map +1 -1
- package/dist/dispatch/ArgumentResolver.d.ts +1 -1
- package/dist/dispatch/ArgumentResolver.d.ts.map +1 -1
- package/dist/dispatch/ArgumentResolver.js +5 -5
- package/dist/dispatch/ArgumentResolver.js.map +1 -1
- package/dist/dispatch/DispatchEvent.d.ts +2 -2
- package/dist/dispatch/DispatchEvent.d.ts.map +1 -1
- package/dist/dispatch/DispatchLifecycle.d.ts +1 -7
- package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -1
- package/dist/dispatch/DispatchLifecycle.js +1 -7
- package/dist/dispatch/DispatchLifecycle.js.map +1 -1
- package/dist/dispatch/DispatchPort.d.ts +1 -1
- package/dist/dispatch/DispatchPort.d.ts.map +1 -1
- package/dist/dispatch/Dispatcher.d.ts +1 -1
- package/dist/dispatch/Dispatcher.d.ts.map +1 -1
- package/dist/dispatch/Dispatcher.js +2 -2
- package/dist/dispatch/Dispatcher.js.map +1 -1
- package/dist/{boot → dispatch}/HandlerFacade.d.ts +25 -38
- package/dist/dispatch/HandlerFacade.d.ts.map +1 -0
- package/dist/{boot → dispatch}/HandlerFacade.js +65 -74
- package/dist/dispatch/HandlerFacade.js.map +1 -0
- package/dist/dispatch/LocalRoutePolicy.d.ts +1 -1
- package/dist/dispatch/LocalRoutePolicy.d.ts.map +1 -1
- package/dist/dispatch/LocalRoutePolicy.js +4 -4
- package/dist/dispatch/LocalRoutePolicy.js.map +1 -1
- package/dist/dispatch/OperationRoute.d.ts +2 -2
- package/dist/dispatch/OperationRoute.d.ts.map +1 -1
- package/dist/dispatch/OutputView.d.ts +3 -2
- package/dist/dispatch/OutputView.d.ts.map +1 -1
- package/dist/dispatch/OutputView.js +19 -1
- package/dist/dispatch/OutputView.js.map +1 -1
- package/dist/dispatch/Route.d.ts +2 -2
- package/dist/dispatch/Route.d.ts.map +1 -1
- package/dist/dispatch/RoutePolicy.d.ts +1 -1
- package/dist/dispatch/RoutePolicy.d.ts.map +1 -1
- package/dist/dispatch/RouteRegistry.d.ts +1 -1
- package/dist/dispatch/RouteRegistry.d.ts.map +1 -1
- package/dist/dispatch/RouteRegistry.js +2 -2
- package/dist/dispatch/RouteRegistry.js.map +1 -1
- package/dist/dispatch/RouteResolver.d.ts +2 -4
- package/dist/dispatch/RouteResolver.d.ts.map +1 -1
- package/dist/dispatch/StorageGuard.d.ts +40 -8
- package/dist/dispatch/StorageGuard.d.ts.map +1 -1
- package/dist/dispatch/StorageGuard.js +151 -20
- package/dist/dispatch/StorageGuard.js.map +1 -1
- package/dist/dispatch/presenterArguments.d.ts +7 -0
- package/dist/dispatch/presenterArguments.d.ts.map +1 -0
- package/dist/dispatch/presenterArguments.js +12 -0
- package/dist/dispatch/presenterArguments.js.map +1 -0
- package/dist/dispatch/remoteRoutes.d.ts +7 -0
- package/dist/dispatch/remoteRoutes.d.ts.map +1 -0
- package/dist/dispatch/{RemoteRouteResolver.js → remoteRoutes.js} +6 -10
- package/dist/dispatch/remoteRoutes.js.map +1 -0
- package/dist/dispatch/routeNotFound.d.ts +9 -0
- package/dist/dispatch/routeNotFound.d.ts.map +1 -0
- package/dist/dispatch/routeNotFound.js +21 -0
- package/dist/dispatch/routeNotFound.js.map +1 -0
- package/dist/dispatch/validateInput.d.ts +5 -0
- package/dist/dispatch/validateInput.d.ts.map +1 -0
- package/dist/dispatch/validateInput.js +20 -0
- package/dist/dispatch/validateInput.js.map +1 -0
- package/dist/effective-operation.d.ts +1 -24
- package/dist/effective-operation.d.ts.map +1 -1
- package/dist/effective-operation.js +21 -50
- package/dist/effective-operation.js.map +1 -1
- package/dist/emit.d.ts +4 -42
- package/dist/emit.d.ts.map +1 -1
- package/dist/emit.js +3 -39
- package/dist/emit.js.map +1 -1
- package/dist/entry/facade.d.ts +8 -0
- package/dist/entry/facade.d.ts.map +1 -0
- package/dist/entry/facade.js +28 -0
- package/dist/entry/facade.js.map +1 -0
- package/dist/entry/transport.d.ts +5 -0
- package/dist/entry/transport.d.ts.map +1 -0
- package/dist/entry/transport.js +11 -0
- package/dist/entry/transport.js.map +1 -0
- package/dist/frond-config.d.ts +7 -70
- package/dist/frond-config.d.ts.map +1 -1
- package/dist/frond-config.js +1 -9
- package/dist/frond-config.js.map +1 -1
- package/dist/identity-keys.d.ts +2 -5
- package/dist/identity-keys.d.ts.map +1 -1
- package/dist/identity-keys.js +3 -16
- package/dist/identity-keys.js.map +1 -1
- package/dist/identity.d.ts +4 -30
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +11 -73
- package/dist/identity.js.map +1 -1
- package/dist/imports.d.ts +1 -7
- package/dist/imports.d.ts.map +1 -1
- package/dist/imports.js +1 -7
- package/dist/imports.js.map +1 -1
- package/dist/index.d.ts +17 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -18
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -8
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +1 -8
- package/dist/loader.js.map +1 -1
- package/dist/node.d.ts +2 -11
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +2 -11
- package/dist/node.js.map +1 -1
- package/dist/prefab/collector.d.ts +1 -22
- package/dist/prefab/collector.d.ts.map +1 -1
- package/dist/prefab/collector.js +1 -22
- package/dist/prefab/collector.js.map +1 -1
- package/dist/prefab/crud.d.ts +16 -32
- package/dist/prefab/crud.d.ts.map +1 -1
- package/dist/prefab/crud.js +31 -58
- package/dist/prefab/crud.js.map +1 -1
- package/dist/prefab/mirror.d.ts +2 -24
- package/dist/prefab/mirror.d.ts.map +1 -1
- package/dist/prefab/mirror.js +2 -20
- package/dist/prefab/mirror.js.map +1 -1
- package/dist/prefab/prefab.d.ts +1 -7
- package/dist/prefab/prefab.d.ts.map +1 -1
- package/dist/prefab/prefab.js +1 -7
- package/dist/prefab/prefab.js.map +1 -1
- package/dist/prefab/presenter.d.ts +2 -36
- package/dist/prefab/presenter.d.ts.map +1 -1
- package/dist/prefab/presenter.js +2 -36
- package/dist/prefab/presenter.js.map +1 -1
- package/dist/prefab/repository.d.ts +5 -73
- package/dist/prefab/repository.d.ts.map +1 -1
- package/dist/prefab/repository.js +3 -16
- package/dist/prefab/repository.js.map +1 -1
- package/dist/scan/adapters.d.ts +3 -0
- package/dist/scan/adapters.d.ts.map +1 -0
- package/dist/scan/adapters.js +25 -0
- package/dist/scan/adapters.js.map +1 -0
- package/dist/scan/bundling.d.ts +1 -12
- package/dist/scan/bundling.d.ts.map +1 -1
- package/dist/scan/bundling.js +1 -12
- package/dist/scan/bundling.js.map +1 -1
- package/dist/scan/contract.d.ts +27 -0
- package/dist/scan/contract.d.ts.map +1 -0
- package/dist/scan/contract.js +46 -0
- package/dist/scan/contract.js.map +1 -0
- package/dist/scan/conventions.d.ts +6 -40
- package/dist/scan/conventions.d.ts.map +1 -1
- package/dist/scan/conventions.js +5 -34
- package/dist/scan/conventions.js.map +1 -1
- package/dist/scan/emit.d.ts +1 -5
- package/dist/scan/emit.d.ts.map +1 -1
- package/dist/scan/emit.js +10 -78
- package/dist/scan/emit.js.map +1 -1
- package/dist/scan/handler-parser.d.ts +4 -26
- package/dist/scan/handler-parser.d.ts.map +1 -1
- package/dist/scan/handler-parser.js +26 -83
- package/dist/scan/handler-parser.js.map +1 -1
- package/dist/scan/result.d.ts +3 -16
- package/dist/scan/result.d.ts.map +1 -1
- package/dist/scan/scanner.d.ts +2 -27
- package/dist/scan/scanner.d.ts.map +1 -1
- package/dist/scan/scanner.js +45 -133
- package/dist/scan/scanner.js.map +1 -1
- package/dist/scan/statement.d.ts.map +1 -1
- package/dist/scan/statement.js +60 -37
- package/dist/scan/statement.js.map +1 -1
- package/dist/source.d.ts +53 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +18 -0
- package/dist/source.js.map +1 -0
- package/dist/storage.d.ts +13 -210
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -68
- package/dist/storage.js.map +1 -1
- package/dist/store.d.ts +18 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +179 -0
- package/dist/store.js.map +1 -0
- package/dist/verify.d.ts +5 -38
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +17 -37
- package/dist/verify.js.map +1 -1
- package/dist/wire/CallLog.d.ts +32 -0
- package/dist/wire/CallLog.d.ts.map +1 -0
- package/dist/{contract → wire}/CallLog.js.map +1 -1
- package/dist/wire/Invocation.d.ts +32 -0
- package/dist/wire/Invocation.d.ts.map +1 -0
- package/dist/wire/Invocation.js +66 -0
- package/dist/wire/Invocation.js.map +1 -0
- package/dist/{contract → wire}/RouteAddress.d.ts +5 -0
- package/dist/wire/RouteAddress.d.ts.map +1 -0
- package/dist/{contract → wire}/RouteAddress.js +7 -0
- package/dist/wire/RouteAddress.js.map +1 -0
- package/dist/wire/binding.d.ts +5 -21
- package/dist/wire/binding.d.ts.map +1 -1
- package/dist/wire/binding.js +5 -10
- package/dist/wire/binding.js.map +1 -1
- package/dist/wire/call.d.ts +24 -133
- package/dist/wire/call.d.ts.map +1 -1
- package/dist/wire/call.js +15 -41
- package/dist/wire/call.js.map +1 -1
- package/dist/wire/drift.d.ts +3 -28
- package/dist/wire/drift.d.ts.map +1 -1
- package/dist/wire/drift.js +4 -23
- package/dist/wire/drift.js.map +1 -1
- package/dist/wire/errors.d.ts +4 -24
- package/dist/wire/errors.d.ts.map +1 -1
- package/dist/wire/errors.js +4 -24
- package/dist/wire/errors.js.map +1 -1
- package/dist/wire/http-error.d.ts +2 -13
- package/dist/wire/http-error.d.ts.map +1 -1
- package/dist/wire/http-error.js +5 -19
- package/dist/wire/http-error.js.map +1 -1
- package/dist/wire/loggerMiddleware.d.ts +2 -8
- package/dist/wire/loggerMiddleware.d.ts.map +1 -1
- package/dist/wire/loggerMiddleware.js +1 -7
- package/dist/wire/loggerMiddleware.js.map +1 -1
- package/dist/wire/middleware.d.ts +3 -7
- package/dist/wire/middleware.d.ts.map +1 -1
- package/dist/wire/middleware.js +1 -5
- package/dist/wire/middleware.js.map +1 -1
- package/dist/wire/operation.d.ts +7 -43
- package/dist/wire/operation.d.ts.map +1 -1
- package/dist/wire/operation.js +4 -15
- package/dist/wire/operation.js.map +1 -1
- package/dist/wire/signature.d.ts +4 -25
- package/dist/wire/signature.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/boot/AppLifecycle.ts +15 -2
- package/src/boot/Emissions.ts +21 -118
- package/src/boot/ambient-port.ts +3 -24
- package/src/boot/ambient.als.ts +7 -12
- package/src/boot/ambient.queue.ts +2 -5
- package/src/boot/apply.ts +9 -16
- package/src/boot/auth.ts +2 -12
- package/src/boot/boot.ts +6 -21
- package/src/boot/bootstrap.ts +95 -140
- package/src/boot/card.ts +4 -33
- package/src/boot/frame.ts +24 -64
- package/src/boot/hosted.ts +12 -34
- package/src/boot/ownership.ts +5 -39
- package/src/boot/ports.ts +1 -14
- package/src/boot/remote.ts +11 -58
- package/src/boot/runner.ts +5 -22
- package/src/boot/seed.ts +6 -37
- package/src/boot/statement-drift.ts +5 -24
- package/src/boot/together.ts +18 -51
- package/src/boot/types.ts +31 -173
- package/src/{builtins → builtin}/config.ts +1 -7
- package/src/{builtins → builtin}/logger.ts +6 -39
- package/src/config-loader.ts +12 -71
- package/src/contract.ts +19 -39
- package/src/criterion.ts +54 -0
- package/src/crypto/encoding.ts +2 -15
- package/src/crypto/node.ts +1 -7
- package/src/crypto/port.ts +2 -18
- package/src/crypto/webcrypto.ts +1 -12
- package/src/declare.ts +42 -41
- package/src/define.ts +2 -3
- package/src/descriptor/Fronds.ts +6 -31
- package/src/descriptor/frond.ts +26 -60
- package/src/dispatch/ArgumentResolver.ts +6 -6
- package/src/dispatch/DispatchEvent.ts +2 -2
- package/src/dispatch/DispatchLifecycle.ts +1 -7
- package/src/dispatch/DispatchPort.ts +1 -1
- package/src/dispatch/Dispatcher.ts +3 -3
- package/src/dispatch/HandlerFacade.ts +231 -0
- package/src/dispatch/LocalRoutePolicy.ts +4 -4
- package/src/dispatch/OperationRoute.ts +2 -2
- package/src/dispatch/OutputView.ts +24 -2
- package/src/dispatch/Route.ts +2 -2
- package/src/dispatch/RoutePolicy.ts +1 -1
- package/src/dispatch/RouteRegistry.ts +2 -2
- package/src/dispatch/RouteResolver.ts +2 -4
- package/src/dispatch/StorageGuard.ts +175 -19
- package/src/dispatch/presenterArguments.ts +25 -0
- package/src/dispatch/{RemoteRouteResolver.ts → remoteRoutes.ts} +7 -9
- package/src/dispatch/routeNotFound.ts +33 -0
- package/src/dispatch/validateInput.ts +28 -0
- package/src/effective-operation.ts +21 -50
- package/src/emit.ts +5 -63
- package/src/entry/facade.ts +44 -0
- package/src/entry/transport.ts +16 -0
- package/src/frond-config.ts +7 -70
- package/src/identity-keys.ts +3 -16
- package/src/identity.ts +12 -80
- package/src/imports.ts +2 -31
- package/src/index.ts +17 -24
- package/src/loader.ts +2 -16
- package/src/node.ts +2 -11
- package/src/prefab/collector.ts +1 -22
- package/src/prefab/crud.ts +37 -76
- package/src/prefab/mirror.ts +4 -44
- package/src/prefab/prefab.ts +2 -21
- package/src/prefab/presenter.ts +2 -36
- package/src/prefab/repository.ts +7 -83
- package/src/scan/adapters.ts +32 -0
- package/src/scan/bundling.ts +1 -12
- package/src/scan/contract.ts +80 -0
- package/src/scan/conventions.ts +6 -40
- package/src/scan/emit.ts +11 -80
- package/src/scan/handler-parser.ts +27 -96
- package/src/scan/result.ts +3 -16
- package/src/scan/scanner.ts +46 -132
- package/src/scan/statement.ts +73 -41
- package/src/source.ts +63 -0
- package/src/storage.ts +14 -234
- package/src/store.ts +191 -0
- package/src/verify.ts +16 -57
- package/src/wire/CallLog.ts +30 -0
- package/src/{contract → wire}/Invocation.ts +24 -17
- package/src/{contract → wire}/RouteAddress.ts +7 -0
- package/src/wire/binding.ts +9 -25
- package/src/wire/call.ts +30 -133
- package/src/wire/drift.ts +5 -30
- package/src/wire/errors.ts +4 -24
- package/src/wire/http-error.ts +5 -19
- package/src/wire/loggerMiddleware.ts +2 -8
- package/src/wire/middleware.ts +3 -7
- package/src/wire/operation.ts +8 -48
- package/src/wire/signature.ts +4 -25
- package/dist/boot/HandlerFacade.d.ts.map +0 -1
- package/dist/boot/HandlerFacade.js.map +0 -1
- package/dist/builtins/config.d.ts +0 -13
- package/dist/builtins/config.d.ts.map +0 -1
- package/dist/builtins/config.js +0 -21
- package/dist/builtins/config.js.map +0 -1
- package/dist/builtins/logger.d.ts.map +0 -1
- package/dist/builtins/logger.js.map +0 -1
- package/dist/contract/Call.d.ts +0 -10
- package/dist/contract/Call.d.ts.map +0 -1
- package/dist/contract/Call.js +0 -15
- package/dist/contract/Call.js.map +0 -1
- package/dist/contract/CallLog.d.ts +0 -57
- package/dist/contract/CallLog.d.ts.map +0 -1
- package/dist/contract/Invocation.d.ts +0 -27
- package/dist/contract/Invocation.d.ts.map +0 -1
- package/dist/contract/Invocation.js +0 -59
- package/dist/contract/Invocation.js.map +0 -1
- package/dist/contract/RouteAddress.d.ts.map +0 -1
- package/dist/contract/RouteAddress.js.map +0 -1
- package/dist/dispatch/InputValidator.d.ts +0 -7
- package/dist/dispatch/InputValidator.d.ts.map +0 -1
- package/dist/dispatch/InputValidator.js +0 -22
- package/dist/dispatch/InputValidator.js.map +0 -1
- package/dist/dispatch/OperationExecutor.d.ts +0 -25
- package/dist/dispatch/OperationExecutor.d.ts.map +0 -1
- package/dist/dispatch/OperationExecutor.js +0 -32
- package/dist/dispatch/OperationExecutor.js.map +0 -1
- package/dist/dispatch/OutputProjector.d.ts +0 -12
- package/dist/dispatch/OutputProjector.d.ts.map +0 -1
- package/dist/dispatch/OutputProjector.js +0 -30
- package/dist/dispatch/OutputProjector.js.map +0 -1
- package/dist/dispatch/PresenterArgumentResolver.d.ts +0 -12
- package/dist/dispatch/PresenterArgumentResolver.d.ts.map +0 -1
- package/dist/dispatch/PresenterArgumentResolver.js +0 -20
- package/dist/dispatch/PresenterArgumentResolver.js.map +0 -1
- package/dist/dispatch/RemoteRouteResolver.d.ts +0 -13
- package/dist/dispatch/RemoteRouteResolver.d.ts.map +0 -1
- package/dist/dispatch/RemoteRouteResolver.js.map +0 -1
- package/dist/dispatch/RouteNotFoundError.d.ts +0 -10
- package/dist/dispatch/RouteNotFoundError.d.ts.map +0 -1
- package/dist/dispatch/RouteNotFoundError.js +0 -24
- package/dist/dispatch/RouteNotFoundError.js.map +0 -1
- package/dist/entry/DynamicFacade.d.ts +0 -10
- package/dist/entry/DynamicFacade.d.ts.map +0 -1
- package/dist/entry/DynamicFacade.js +0 -27
- package/dist/entry/DynamicFacade.js.map +0 -1
- package/dist/entry/FacadeEntry.d.ts +0 -11
- package/dist/entry/FacadeEntry.d.ts.map +0 -1
- package/dist/entry/FacadeEntry.js +0 -26
- package/dist/entry/FacadeEntry.js.map +0 -1
- package/dist/entry/TransportEntry.d.ts +0 -13
- package/dist/entry/TransportEntry.d.ts.map +0 -1
- package/dist/entry/TransportEntry.js +0 -24
- package/dist/entry/TransportEntry.js.map +0 -1
- package/dist/rows.d.ts +0 -40
- package/dist/rows.d.ts.map +0 -1
- package/dist/rows.js +0 -146
- package/dist/rows.js.map +0 -1
- package/src/boot/HandlerFacade.ts +0 -242
- package/src/contract/Call.ts +0 -18
- package/src/contract/CallLog.ts +0 -55
- package/src/dispatch/InputValidator.ts +0 -28
- package/src/dispatch/OperationExecutor.ts +0 -60
- package/src/dispatch/OutputProjector.ts +0 -32
- package/src/dispatch/PresenterArgumentResolver.ts +0 -25
- package/src/dispatch/RouteNotFoundError.ts +0 -29
- package/src/entry/DynamicFacade.ts +0 -28
- package/src/entry/FacadeEntry.ts +0 -32
- package/src/entry/TransportEntry.ts +0 -30
- package/src/rows.ts +0 -155
- /package/dist/{contract → wire}/CallLog.js +0 -0
package/src/prefab/repository.ts
CHANGED
|
@@ -2,68 +2,11 @@ import { upperFirst, type EntityConstructor } from '@fougere/schema';
|
|
|
2
2
|
import type { Storage, ListOptions, ListResult, SelectOption } from '../storage.js';
|
|
3
3
|
import type { SchemaView } from '@fougere/schema';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Repository(…entities) — who owns an entity's storage, and where its questions are named.
|
|
7
|
-
*
|
|
8
|
-
* **The arity decides**, which is the second reading of what `storage.ts` already states for
|
|
9
|
-
* `Storage` against `Together`: the arity of the unit is the whole distinction.
|
|
10
|
-
*
|
|
11
|
-
* ONE entity — the repository IS that entity's storage, with your methods added. The port's
|
|
12
|
-
* thirteen gestures are forwarded, so a handler reads `this.posts.list()` whether or not
|
|
13
|
-
* anyone wrote the file, and a named question sits beside them:
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* // repositories/PostRepository.ts
|
|
17
|
-
* export default class PostRepository extends Repository(Post) {
|
|
18
|
-
* published() {
|
|
19
|
-
* return this.list({ where: { status: 'published' }, orderBy: 'publishedAt', order: 'desc' });
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* TWO OR MORE — an aggregate. It owns them: nothing else in the app is handed their
|
|
25
|
-
* storage, and no gesture is forwarded (which entity would `create` write to?), so the only
|
|
26
|
-
* way in is a method this class names. That is what lets a rule spanning two tables exist:
|
|
27
|
-
* it is ordinary TypeScript inside the method that does the writing.
|
|
28
|
-
*
|
|
29
|
-
* ```ts
|
|
30
|
-
* // repositories/CommandeRepository.ts
|
|
31
|
-
* export default class CommandeRepository extends Repository(Commande, Stock) {
|
|
32
|
-
* avecLignes(id: string) {
|
|
33
|
-
* const [commandes, stock] = this.storages;
|
|
34
|
-
* …
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* `this.storages` is protected, because the whole point is that the storage stops at this file.
|
|
40
|
-
* `protected` is erased at runtime, like `abstract` on a port: a compile-time guarantee, not
|
|
41
|
-
* a barrier. The same bargain, already accepted.
|
|
42
|
-
*
|
|
43
|
-
* **The boundary is not the unit of work.** An aggregate says the rules of these entities
|
|
44
|
-
* hold together; a frame says these writes land together, and the two lists coincide only
|
|
45
|
-
* often. Deriving the frame from the membership would make a read-only aggregate carry one
|
|
46
|
-
* — refusals included, and `registerFrames` refuses without storage or over `remotes:` —
|
|
47
|
-
* and would put `Together<[Commande, Stock], [StockMirror]>` out of reach forever. So a
|
|
48
|
-
* frame is ASKED FOR here as anywhere else, which is what makes it declared:
|
|
49
|
-
*
|
|
50
|
-
* ```ts
|
|
51
|
-
* constructor(commandes: CommandeStorage, stock: StockStorage, private frame: Together<[Commande, Stock]>) {
|
|
52
|
-
* super(commandes, stock);
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* The storage words come back in that line, and only there: this class IS the holder, which is
|
|
57
|
-
* the one case `boot/ownership.ts` lets name the storage it was built on.
|
|
58
|
-
*
|
|
59
|
-
* A repository is NOT a door: it has no façade, so nothing here is reachable from the wire.
|
|
60
|
-
*/
|
|
5
|
+
/** Repository(…entities) — who owns an entity's storage, and where its questions are named. */
|
|
61
6
|
|
|
62
7
|
/**
|
|
63
|
-
* The shape a repository of ONE entity has — the port itself, plus whatever the subclass
|
|
64
|
-
*
|
|
65
|
-
* to `PostRepository` what `Storage<Post>` is to `PostStorage`, one spelling of one key, and
|
|
66
|
-
* `depKeyOf` reads both.
|
|
8
|
+
* The shape a repository of ONE entity has — the port itself, plus whatever the subclass names on
|
|
9
|
+
* top.
|
|
67
10
|
*/
|
|
68
11
|
export type RepositoryOf<T> = Storage<T>;
|
|
69
12
|
|
|
@@ -73,13 +16,7 @@ export interface RepositoryConstructor<T> {
|
|
|
73
16
|
readonly __entity: unknown;
|
|
74
17
|
}
|
|
75
18
|
|
|
76
|
-
/**
|
|
77
|
-
* What an aggregate's subclass sees: the storage of the members it owns, in declared order,
|
|
78
|
-
* and `protected` — the storage stops at that file, which is the whole mechanism.
|
|
79
|
-
*
|
|
80
|
-
* A class and not an interface, because `protected` cannot be spelled in one. Ambient: the
|
|
81
|
-
* value it describes is fabricated by `many()` for an arity only known at the call.
|
|
82
|
-
*/
|
|
19
|
+
/** What an aggregate's subclass sees. */
|
|
83
20
|
declare abstract class AggregateShape<E extends readonly EntityConstructor[]> {
|
|
84
21
|
protected storages: { [K in keyof E]: Storage<InstanceType<E[K]>> };
|
|
85
22
|
}
|
|
@@ -103,11 +40,7 @@ export function Repository(...entities: EntityConstructor[]): unknown {
|
|
|
103
40
|
return entities.length === 1 ? one(entities[0]) : many(entities);
|
|
104
41
|
}
|
|
105
42
|
|
|
106
|
-
/**
|
|
107
|
-
* The port forwarded, member by member. Written out rather than proxied: a Proxy would
|
|
108
|
-
* answer every name including the ones the port does not have, and this file would then
|
|
109
|
-
* state the surface nowhere. Thirteen lines against one declaration that can be read.
|
|
110
|
-
*/
|
|
43
|
+
/** The port forwarded, member by member. */
|
|
111
44
|
function one<E extends EntityConstructor>(entity: E): RepositoryConstructor<InstanceType<E>> {
|
|
112
45
|
type T = InstanceType<E>;
|
|
113
46
|
|
|
@@ -134,11 +67,7 @@ function one<E extends EntityConstructor>(entity: E): RepositoryConstructor<Inst
|
|
|
134
67
|
return RepositoryBase as unknown as RepositoryConstructor<T>;
|
|
135
68
|
}
|
|
136
69
|
|
|
137
|
-
/**
|
|
138
|
-
* The aggregate. Its constructor takes the members' storage in the DECLARED order — the
|
|
139
|
-
* order `toProvider` fills its `deps` with, and the order a subclass hands back to `super()`
|
|
140
|
-
* when it declares a constructor of its own.
|
|
141
|
-
*/
|
|
70
|
+
/** The aggregate. */
|
|
142
71
|
function many<E extends readonly EntityConstructor[]>(entities: E): AggregateConstructor<E> {
|
|
143
72
|
class AggregateBase {
|
|
144
73
|
static readonly __entity = entities[0];
|
|
@@ -159,12 +88,7 @@ export function repositoryKeyOf(entity: string): string {
|
|
|
159
88
|
return `${upperFirst(entity)}Repository`;
|
|
160
89
|
}
|
|
161
90
|
|
|
162
|
-
/**
|
|
163
|
-
* The entities a class owns — empty for anything that is not an aggregate.
|
|
164
|
-
*
|
|
165
|
-
* Read from the mark rather than from the constructor, for the reason `Crud.__ops` exists:
|
|
166
|
-
* the AST scan is workspace-only, so an installed prefab resolves to nothing.
|
|
167
|
-
*/
|
|
91
|
+
/** The entities a class owns — empty for anything that is not an aggregate. */
|
|
168
92
|
export function ownedBy(ctor: unknown): readonly EntityConstructor[] {
|
|
169
93
|
return (ctor as { __owns?: readonly EntityConstructor[] } | undefined)?.__owns ?? [];
|
|
170
94
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** Which adapters a PROJECT could load, read off its dependencies. */
|
|
5
|
+
const ADAPTER_PACKAGE = /^@fougere\/adapter-(.+)$/;
|
|
6
|
+
|
|
7
|
+
/** The adapter names this project depends on — empty when it has no package.json to read. */
|
|
8
|
+
export async function adaptersOf(root: string): Promise<string[]> {
|
|
9
|
+
const manifest = await read(join(root, 'package.json'));
|
|
10
|
+
if (!manifest) return [];
|
|
11
|
+
|
|
12
|
+
const declared = { ...manifest.dependencies, ...manifest.devDependencies };
|
|
13
|
+
|
|
14
|
+
return Object.keys(declared)
|
|
15
|
+
.map((name) => ADAPTER_PACKAGE.exec(name)?.[1])
|
|
16
|
+
.filter((name): name is string => name !== undefined);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function read(path: string): Promise<Manifest | undefined> {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(await readFile(path, 'utf8')) as Manifest;
|
|
22
|
+
} catch {
|
|
23
|
+
// No manifest, or one that is not JSON. Either way this cannot validate a name, and
|
|
24
|
+
// reporting every `adapters:` key as unknown would be worse than saying nothing.
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Manifest {
|
|
30
|
+
dependencies?: Record<string, string>;
|
|
31
|
+
devDependencies?: Record<string, string>;
|
|
32
|
+
}
|
package/src/scan/bundling.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What a Fougere boot loads at RUNTIME, so a bundler must leave it alone.
|
|
3
|
-
*
|
|
4
|
-
* Stated once because it was stated twice and the two had already drifted: the Vite plugin
|
|
5
|
-
* listed `@fougere/schema`, `@fougere/adapter-graphql` and `@fougere/auth-better`, the Next
|
|
6
|
-
* one did not, and BOTH omitted the two packages `@fougere/app`'s boot actually imports
|
|
7
|
-
* dynamically — `@fougere/defaults` and `@fougere/transport-http`. A list a bundler reads
|
|
8
|
-
* has no way to notice it is wrong: nothing fails at build time, the app fails at boot.
|
|
9
|
-
*
|
|
10
|
-
* It sits here rather than beside the dynamic imports because both readers are BUILD-TIME
|
|
11
|
-
* plugins that already depend on core, and neither may pull the boot into a bundler config.
|
|
12
|
-
*/
|
|
1
|
+
/** What a Fougere boot loads at RUNTIME, so a bundler must leave it alone. */
|
|
13
2
|
export const RUNTIME_PACKAGES: readonly string[] = [
|
|
14
3
|
'@fougere/app',
|
|
15
4
|
'@fougere/core',
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** An operation contract, written down — the half two emitters say the same way. */
|
|
2
|
+
import { ANONYMOUS_SCHEMA_NAME, Card, type SchemaView } from '@fougere/schema';
|
|
3
|
+
|
|
4
|
+
import type { OperationContract } from '../wire/operation.js';
|
|
5
|
+
|
|
6
|
+
/** A value that ends up as an import in the module being written. */
|
|
7
|
+
export type Live = object;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* What the writer needs of an emitter's imports, and nothing more.
|
|
11
|
+
*
|
|
12
|
+
* The two emitters index theirs differently — one by value against a relative path, one
|
|
13
|
+
* by file against the package specifier a project already uses — and neither is wrong for
|
|
14
|
+
* the module it writes. What they agree on is this: a value already imported has an
|
|
15
|
+
* alias, a class can be imported by name, and an entity can be found by its class name.
|
|
16
|
+
*/
|
|
17
|
+
export interface Aliases {
|
|
18
|
+
aliasOf(value: Live): string | undefined;
|
|
19
|
+
named(value: Live, filePath: string, name: string): string;
|
|
20
|
+
/** The entity class this name belongs to — what a `Partial<X>` names as its source. */
|
|
21
|
+
classNamed(name: string): Live | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const lit = (value: unknown): string => JSON.stringify(value ?? null);
|
|
25
|
+
|
|
26
|
+
/** What a schema slot becomes in the generated module. */
|
|
27
|
+
export function schemaRef(
|
|
28
|
+
schema: SchemaView | undefined,
|
|
29
|
+
declaredIn: string,
|
|
30
|
+
imports: Aliases,
|
|
31
|
+
): string | undefined {
|
|
32
|
+
if (!schema) return undefined;
|
|
33
|
+
const known = imports.aliasOf(schema as Live);
|
|
34
|
+
if (known) return known;
|
|
35
|
+
|
|
36
|
+
const name = (schema as { name?: string }).name;
|
|
37
|
+
if (name && name !== ANONYMOUS_SCHEMA_NAME) return imports.named(schema as Live, declaredIn, name);
|
|
38
|
+
|
|
39
|
+
const card = Card.fromSchema(schema);
|
|
40
|
+
const source = card.origin?.from ?? card.descriptor.title;
|
|
41
|
+
const from = source ? imports.classNamed(source) : undefined;
|
|
42
|
+
if (from) return `${imports.aliasOf(from)}.partial()`;
|
|
43
|
+
|
|
44
|
+
throw new Error(
|
|
45
|
+
`A scan cannot be written down: an anonymous schema in ${declaredIn} names no source. `
|
|
46
|
+
+ 'Only `Partial<X>` is derivable here, and it says which X it came from.',
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** One entry of an operations Map, as its module spells it. */
|
|
51
|
+
export function contractOf(
|
|
52
|
+
op: string,
|
|
53
|
+
contract: OperationContract,
|
|
54
|
+
declaredIn: string,
|
|
55
|
+
imports: Aliases,
|
|
56
|
+
): string {
|
|
57
|
+
const parts: string[] = [];
|
|
58
|
+
const input = schemaRef(contract.input, declaredIn, imports);
|
|
59
|
+
const output = schemaRef(contract.output, declaredIn, imports);
|
|
60
|
+
if (input) parts.push(`input: ${input}`);
|
|
61
|
+
if (output) parts.push(`output: ${output}`);
|
|
62
|
+
if (contract.binding !== undefined) parts.push(`binding: ${lit(contract.binding)}`);
|
|
63
|
+
if (contract.description !== undefined) parts.push(`description: ${lit(contract.description)}`);
|
|
64
|
+
if (contract.cardinality !== undefined) parts.push(`cardinality: ${lit(contract.cardinality)}`);
|
|
65
|
+
if (contract.signature !== undefined) parts.push(`signature: ${lit(contract.signature)}`);
|
|
66
|
+
|
|
67
|
+
return `[${lit(op)}, { ${parts.join(', ')} }]`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The operations of one handler, as the Map its reader builds. */
|
|
71
|
+
export function operationsOf(
|
|
72
|
+
operations: ReadonlyMap<string, OperationContract>,
|
|
73
|
+
declaredIn: string,
|
|
74
|
+
imports: Aliases,
|
|
75
|
+
indent: string,
|
|
76
|
+
): string {
|
|
77
|
+
const ops = [...operations].map((entry) => contractOf(entry[0], entry[1], declaredIn, imports));
|
|
78
|
+
|
|
79
|
+
return `new Map([\n${indent} ${ops.join(`,\n${indent} `)}\n${indent}])`;
|
|
80
|
+
}
|
package/src/scan/conventions.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The names the scan READS instead of deriving them.
|
|
3
|
-
*
|
|
4
|
-
* Everything else a frond states, it states by its shape; these seven directories and the
|
|
5
|
-
* import prefix are the one place where a name is the declaration. They were spelled as
|
|
6
|
-
* literals in five packages, so a project could not move any of them and `frondsDir` was
|
|
7
|
-
* a declared key with no reader.
|
|
8
|
-
*/
|
|
1
|
+
/** The names the scan READS instead of deriving them. */
|
|
9
2
|
|
|
10
3
|
export interface Conventions {
|
|
11
|
-
/**
|
|
12
|
-
* The scope a frond's package name carries — `@fronds/blog`.
|
|
13
|
-
*
|
|
14
|
-
* A real package name, not only an alias: the CLI writes it as `name` in a scaffolded
|
|
15
|
-
* frond and as a `workspace:*` dependency in the app that consumes it.
|
|
16
|
-
*/
|
|
4
|
+
/** The scope a frond's package name carries — `@fronds/blog`. */
|
|
17
5
|
scope: string;
|
|
18
6
|
/** The directory holding fronds, below the project root. */
|
|
19
7
|
fronds: string;
|
|
@@ -31,12 +19,7 @@ export interface Conventions {
|
|
|
31
19
|
};
|
|
32
20
|
}
|
|
33
21
|
|
|
34
|
-
/**
|
|
35
|
-
* What a project means when it declares nothing — the convention itself.
|
|
36
|
-
*
|
|
37
|
-
* `@fronds` and not `@frond`: the npm org for the singular belongs to someone else, and a
|
|
38
|
-
* scope is a name that must be ownable.
|
|
39
|
-
*/
|
|
22
|
+
/** What a project means when it declares nothing — the convention itself. */
|
|
40
23
|
export const DEFAULT_CONVENTIONS: Conventions = {
|
|
41
24
|
scope: '@fronds',
|
|
42
25
|
fronds: 'fronds',
|
|
@@ -59,13 +42,7 @@ export type ConventionsInput = {
|
|
|
59
42
|
dirs?: Partial<Conventions['dirs']>;
|
|
60
43
|
};
|
|
61
44
|
|
|
62
|
-
/**
|
|
63
|
-
* The convention, with a project's exceptions folded in.
|
|
64
|
-
*
|
|
65
|
-
* Merged one level into `dirs` so renaming one directory does not require restating the
|
|
66
|
-
* other six — the same reading `sources:` and `ports:` get, where only the exception is
|
|
67
|
-
* declared.
|
|
68
|
-
*/
|
|
45
|
+
/** The convention, with a project's exceptions folded in. */
|
|
69
46
|
export function resolveConventions(input?: ConventionsInput): Conventions {
|
|
70
47
|
return {
|
|
71
48
|
scope: input?.scope ?? DEFAULT_CONVENTIONS.scope,
|
|
@@ -79,23 +56,12 @@ export function frondPackage(name: string, conventions: Conventions): string {
|
|
|
79
56
|
return `${conventions.scope}/${name}`;
|
|
80
57
|
}
|
|
81
58
|
|
|
82
|
-
/**
|
|
83
|
-
* Directories whose classes register as providers — two spellings, one behaviour.
|
|
84
|
-
*
|
|
85
|
-
* A project may point both roles at one directory; the scan must then read it once, or
|
|
86
|
-
* every provider would be registered twice.
|
|
87
|
-
*/
|
|
59
|
+
/** Directories whose classes register as providers — two spellings, one behaviour. */
|
|
88
60
|
export function providerDirsOf(conventions: Conventions): string[] {
|
|
89
61
|
return [...new Set([conventions.dirs.services, conventions.dirs.repositories])];
|
|
90
62
|
}
|
|
91
63
|
|
|
92
|
-
/**
|
|
93
|
-
* The frond vocabulary — every directory the scan reads.
|
|
94
|
-
*
|
|
95
|
-
* What a reader needs to bound a frond: the Nuxt module watches these for the root frond
|
|
96
|
-
* (watching the root itself would match every write), and a flat app's tsconfig lists
|
|
97
|
-
* them instead of `["."]`, which would swallow `app/` and `nuxt.config.ts`.
|
|
98
|
-
*/
|
|
64
|
+
/** The frond vocabulary — every directory the scan reads. */
|
|
99
65
|
export function frondDirsOf(conventions: Conventions): string[] {
|
|
100
66
|
const { entities, handlers, presenters, collectors, seeds, versions } = conventions.dirs;
|
|
101
67
|
return [...new Set([
|
package/src/scan/emit.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The scan, written down as a module — what `createApp` is handed where there is no disk.
|
|
3
|
-
*
|
|
4
|
-
* It RE-RESOLVES NOTHING. By the time this runs the scan has already decided what every
|
|
5
|
-
* slot holds, and `resolveSchema` put the entity's own class in `contract.output` — the
|
|
6
|
-
* very object `EntityEntry.entityClass` holds. So the emitter keeps a table from object
|
|
7
|
-
* to import alias and writes the alias. Identity is preserved because it is the same
|
|
8
|
-
* object that becomes the same import, which is what three call sites depend on
|
|
9
|
-
* (`adapter/graphql`'s `view === entity.entityClass` and its WeakMap, and `bootstrap`'s
|
|
10
|
-
* `outputSchema !== entity.entityClass`). An emitter that re-resolved instead would build
|
|
11
|
-
* a second class for `Post` and those three would silently take the other branch.
|
|
12
|
-
*
|
|
13
|
-
* Measured on three real projects: every live reference is either a class the descriptor
|
|
14
|
-
* already names by `filePath`, a named export of the file that declared the signature, or
|
|
15
|
-
* `Partial<X>` — the one derivation `resolveSchema` fabricates.
|
|
16
|
-
*/
|
|
1
|
+
/** The scan, written down as a module — what `createApp` is handed where there is no disk. */
|
|
17
2
|
import { dirname, relative } from 'node:path';
|
|
18
|
-
import {
|
|
3
|
+
import { nameOf } from '../descriptor/frond.js';
|
|
19
4
|
import type { FrondDescriptor, EntityEntry, HandlerEntry, PresenterEntry, CollectorEntry, ProviderEntry, SeedEntry } from '../descriptor/frond.js';
|
|
20
5
|
import type { ScanResult } from './result.js';
|
|
21
|
-
import type
|
|
6
|
+
import { type Aliases, type Live, lit, operationsOf, schemaRef } from './contract.js';
|
|
22
7
|
|
|
23
8
|
export interface EmitOptions {
|
|
24
9
|
/** Where the generated module will sit. Imports are written relative to it. */
|
|
@@ -27,28 +12,17 @@ export interface EmitOptions {
|
|
|
27
12
|
core?: string;
|
|
28
13
|
}
|
|
29
14
|
|
|
30
|
-
type Live = object;
|
|
31
|
-
|
|
32
15
|
/** Is a TypeScript compiler going to read this module? Its name is the only thing that says. */
|
|
33
16
|
const isTypeScript = (outFile: string): boolean => /\.tsx?$/.test(outFile);
|
|
34
17
|
|
|
35
|
-
/**
|
|
36
|
-
* A source file becomes a specifier its reader can follow — and the two readers differ.
|
|
37
|
-
*
|
|
38
|
-
* A `.ts` destination is compiled by tsc under Node16 resolution, which spells a
|
|
39
|
-
* TypeScript source with `.js`. A `.mjs` destination is read by a bundler, which resolves
|
|
40
|
-
* the path AS IT IS ON DISK — measured, Nitro's rollup refused `Post.seed.js` because no
|
|
41
|
-
* such file exists. One rule, read off the destination, exactly like the type annotation.
|
|
42
|
-
*/
|
|
18
|
+
/** A source file becomes a specifier its reader can follow — and the two readers differ. */
|
|
43
19
|
function specifierOf(filePath: string, outFile: string): string {
|
|
44
20
|
const path = relative(dirname(outFile), filePath);
|
|
45
21
|
const rel = isTypeScript(outFile) ? path.replace(/\.tsx?$/, '.js') : path;
|
|
46
22
|
return rel.startsWith('.') ? rel : `./${rel}`;
|
|
47
23
|
}
|
|
48
24
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class Imports {
|
|
25
|
+
class Imports implements Aliases {
|
|
52
26
|
private readonly byValue = new Map<Live, string>();
|
|
53
27
|
private readonly lines: string[] = [];
|
|
54
28
|
/** Entity classes by their class name — what a `Partial<X>` names as its source. */
|
|
@@ -78,63 +52,23 @@ class Imports {
|
|
|
78
52
|
|
|
79
53
|
has(value: Live): boolean { return this.byValue.has(value); }
|
|
80
54
|
aliasOf(value: Live): string | undefined { return this.byValue.get(value); }
|
|
55
|
+
classNamed(name: string): Live | undefined { return this.byClassName.get(name); }
|
|
81
56
|
render(): string { return this.lines.join('\n'); }
|
|
82
57
|
}
|
|
83
58
|
|
|
84
|
-
/**
|
|
85
|
-
* What a schema slot becomes in the generated module.
|
|
86
|
-
*
|
|
87
|
-
* Three answers, and the third is the only rule: a class already imported is its alias; a
|
|
88
|
-
* named export of the file that declared the signature is imported by its own name — it
|
|
89
|
-
* IS exported there, because that is where `resolveSchema` found it; and an anonymous
|
|
90
|
-
* schema is `Partial<X>`, the one derivation `resolveSchema` builds, so it is written as
|
|
91
|
-
* the derivation rather than as a value.
|
|
92
|
-
*/
|
|
93
|
-
function schemaRef(schema: SchemaView | undefined, declaredIn: string, imports: Imports): string | undefined {
|
|
94
|
-
if (!schema) return undefined;
|
|
95
|
-
const known = imports.aliasOf(schema as Live);
|
|
96
|
-
if (known) return known;
|
|
97
|
-
|
|
98
|
-
const name = (schema as { name?: string }).name;
|
|
99
|
-
if (name && name !== ANONYMOUS_SCHEMA_NAME) return imports.named(schema as Live, declaredIn, name);
|
|
100
|
-
|
|
101
|
-
const card = Card.fromSchema(schema);
|
|
102
|
-
const source = card.origin?.from ?? card.descriptor.title;
|
|
103
|
-
const from = source ? imports.byClassName.get(source) : undefined;
|
|
104
|
-
if (from) return `${imports.aliasOf(from)}.partial()`;
|
|
105
|
-
|
|
106
|
-
throw new Error(
|
|
107
|
-
`A scan cannot be written down: an anonymous schema in ${declaredIn} names no source. `
|
|
108
|
-
+ 'Only `Partial<X>` is derivable here, and it says which X it came from.',
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function contractOf(op: string, c: OperationContract, declaredIn: string, imports: Imports): string {
|
|
113
|
-
const parts: string[] = [];
|
|
114
|
-
const input = schemaRef(c.input, declaredIn, imports);
|
|
115
|
-
const output = schemaRef(c.output, declaredIn, imports);
|
|
116
|
-
if (input) parts.push(`input: ${input}`);
|
|
117
|
-
if (output) parts.push(`output: ${output}`);
|
|
118
|
-
if (c.binding !== undefined) parts.push(`binding: ${lit(c.binding)}`);
|
|
119
|
-
if (c.description !== undefined) parts.push(`description: ${lit(c.description)}`);
|
|
120
|
-
if (c.cardinality !== undefined) parts.push(`cardinality: ${lit(c.cardinality)}`);
|
|
121
|
-
if (c.signature !== undefined) parts.push(`signature: ${lit(c.signature)}`);
|
|
122
|
-
return `[${lit(op)}, { ${parts.join(', ')} }]`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
59
|
function entityOf(e: EntityEntry, imports: Imports): string {
|
|
126
60
|
return `{ name: ${lit(e.name)}, entityClass: ${imports.aliasOf(e.entityClass as Live)}, `
|
|
127
61
|
+ `filePath: ${lit(e.filePath)}, exposed: ${lit(e.exposed)} }`;
|
|
128
62
|
}
|
|
129
63
|
|
|
130
64
|
function handlerOf(h: HandlerEntry, imports: Imports): string {
|
|
131
|
-
const ops =
|
|
65
|
+
const ops = operationsOf(h.operations, h.filePath, imports, ' ');
|
|
132
66
|
const override = schemaRef(h.outputOverride, h.filePath, imports);
|
|
133
67
|
return `{ name: ${lit(h.name)}, address: ${lit(h.address)}, ctor: ${imports.aliasOf(h.ctor as Live)}, `
|
|
134
68
|
+ `deps: ${lit(h.deps)}, filePath: ${lit(h.filePath)}, exposed: ${lit(h.exposed)}, `
|
|
135
69
|
+ (h.surface ? `surface: ${lit(h.surface)}, ` : '')
|
|
136
70
|
+ (override ? `outputOverride: ${override}, ` : '')
|
|
137
|
-
+ `operations:
|
|
71
|
+
+ `operations: ${ops} }`;
|
|
138
72
|
}
|
|
139
73
|
|
|
140
74
|
function presenterOf(p: PresenterEntry, imports: Imports): string {
|
|
@@ -151,7 +85,8 @@ function collectorOf(c: CollectorEntry, imports: Imports): string {
|
|
|
151
85
|
}
|
|
152
86
|
|
|
153
87
|
function providerOf(p: ProviderEntry, imports: Imports): string {
|
|
154
|
-
return `{
|
|
88
|
+
return `{ name: ${lit(nameOf(p))}, ctor: ${imports.aliasOf(p.ctor as Live)}, `
|
|
89
|
+
+ `deps: ${lit(p.deps)}, filePath: ${lit(p.filePath)} }`;
|
|
155
90
|
}
|
|
156
91
|
|
|
157
92
|
function seedOf(s: SeedEntry, imports: Imports): string {
|
|
@@ -178,11 +113,7 @@ function frondOf(f: FrondDescriptor, imports: Imports): string {
|
|
|
178
113
|
].filter(Boolean).join('\n');
|
|
179
114
|
}
|
|
180
115
|
|
|
181
|
-
/**
|
|
182
|
-
* Write a scan down. The result is a TypeScript module whose only imports are the classes
|
|
183
|
-
* the scan found — static, so a bundler traces them — and whose only value is the
|
|
184
|
-
* descriptor `createApp` asks for.
|
|
185
|
-
*/
|
|
116
|
+
/** Write a scan down. */
|
|
186
117
|
export function emitScan(result: ScanResult, options: EmitOptions): string {
|
|
187
118
|
const imports = new Imports(options.outFile);
|
|
188
119
|
const core = options.core ?? '@fougere/core';
|