fix: make application port contracts checkJs-safe
This commit is contained in:
@@ -12,10 +12,26 @@
|
|||||||
* }} ports
|
* }} ports
|
||||||
*/
|
*/
|
||||||
export function createApplication(ports) {
|
export function createApplication(ports) {
|
||||||
|
/**
|
||||||
|
* @param {unknown} query
|
||||||
|
* @param {import("./ports/resource-ports.js").RequestContext} [context]
|
||||||
|
*/
|
||||||
|
function queryResources(query, context) {
|
||||||
|
return ports.resources.query.execute(query, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {unknown} command
|
||||||
|
* @param {import("./ports/resource-ports.js").RequestContext} [context]
|
||||||
|
*/
|
||||||
|
function commandResources(command, context) {
|
||||||
|
return ports.resources.command.execute(command, context);
|
||||||
|
}
|
||||||
|
|
||||||
return Object.freeze({
|
return Object.freeze({
|
||||||
resources: Object.freeze({
|
resources: Object.freeze({
|
||||||
query: (query, context) => ports.resources.query.execute(query, context),
|
query: queryResources,
|
||||||
command: (command, context) => ports.resources.command.execute(command, context),
|
command: commandResources,
|
||||||
}),
|
}),
|
||||||
cache: ports.cache,
|
cache: ports.cache,
|
||||||
storage: ports.storage,
|
storage: ports.storage,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* }} ClockPort
|
* }} ClockPort
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @type {ClockPort} */
|
||||||
export const systemClock = Object.freeze({
|
export const systemClock = Object.freeze({
|
||||||
now: () => Date.now(),
|
now: () => Date.now(),
|
||||||
sleep(milliseconds, signal) {
|
sleep(milliseconds, signal) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* @template Value
|
* @template Value
|
||||||
* @typedef {{ ok: true, value: Value, meta?: Record<string, unknown> } |
|
* @typedef {{ ok: true, value: Value, meta?: Record<string, unknown> } |
|
||||||
* { ok: false, error: import("../../contracts/errors.js").ApiFailure }} Result
|
* { ok: false, error: unknown }} Result
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
Reference in New Issue
Block a user