Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz committed Mar 18, 2024
1 parent 2128912 commit 77d50c2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
18 changes: 14 additions & 4 deletions etc/interfaces.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export namespace IBaseComponent {

// @public
export interface IBaseComponent {
[START_COMPONENT]?: (startOptions: IBaseComponent.ComponentStartOptions) => Promise<void>;
[STOP_COMPONENT]?: () => Promise<void>;
// @deprecated
start?: (startOptions: IBaseComponent.ComponentStartOptions) => Promise<void>;
// @deprecated
stop?: () => Promise<void>;
}

Expand Down Expand Up @@ -394,6 +398,12 @@ export type RequestOptions = fetch_2.RequestInit & {
type Response_2 = fetch_2.Response;
export { Response_2 as Response }

// @public
export const START_COMPONENT: unique symbol;

// @public
export const STOP_COMPONENT: unique symbol;

// @public (undocumented)
export type Trace = Pick<TraceContext, "traceId" | "version" | "parentId" | "traceFlags">;

Expand All @@ -414,10 +424,10 @@ export type TraceState = Required<Pick<TraceContext, "traceState">>["traceState"

// Warnings were encountered during analysis:
//
// src/components/fetcher.ts:27:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Request" which is marked as @alpha
// src/components/fetcher.ts:27:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Response" which is marked as @alpha
// src/components/fetcher.ts:28:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Request" which is marked as @alpha
// src/components/fetcher.ts:28:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Response" which is marked as @alpha
// src/components/fetcher.ts:27:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Request_2" which is marked as @alpha
// src/components/fetcher.ts:27:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Response_2" which is marked as @alpha
// src/components/fetcher.ts:28:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Request_2" which is marked as @alpha
// src/components/fetcher.ts:28:3 - (ae-incompatible-release-tags) The symbol "fetch" is marked as @public, but its signature references "Response_2" which is marked as @alpha

// (No @packageDocumentation comment for this package)

Expand Down
18 changes: 13 additions & 5 deletions src/components/base-component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
export const START_COMPONENT = Symbol.for("wkc:START_COMPONENT");
export const STOP_COMPONENT = Symbol.for("wkc:STOP_COMPONENT");
/**
* @public
* Symbol to start a component, used by Lifecycle
*/
export const START_COMPONENT = Symbol.for("wkc:START_COMPONENT")
/**
* @public
* Symbol to stop a component, used by Lifecycle
*/
export const STOP_COMPONENT = Symbol.for("wkc:STOP_COMPONENT")

/**
* @public
Expand Down Expand Up @@ -29,12 +37,12 @@ export namespace IBaseComponent {
export interface IBaseComponent {
/**
* starts the component, i.e. it connects the database or binds the port in a listener server
* @deprecated Use import { START_COMPONENT } from '@well-known-components/interfaces'
* @deprecated - Use import \{ START_COMPONENT \} from '\@well-known-components/interfaces'
*/
start?: (startOptions: IBaseComponent.ComponentStartOptions) => Promise<void>
/**
* finishes pending work and/or releases all the resources (connections, bound ports, open file descriptors)
* @deprecated Use import { STOP_COMPONENT } from '@well-known-components/interfaces'
* @deprecated - Use import \{ STOP_COMPONENT \} from '\@well-known-components/interfaces'
*/
stop?: () => Promise<void>

Expand All @@ -60,5 +68,5 @@ export type IAdapterHandler<Context, ReturnType> = (context: Context) => Promise
*/
export type IMiddlewareAdapterHandler<Context, ReturnType> = (
context: Context,
next: () => Promise<ReturnType>
next: () => Promise<ReturnType>,
) => Promise<ReturnType>
4 changes: 2 additions & 2 deletions src/utils/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IBaseComponent, STOP_COMPONENT } from "../components/base-component"
import { IBaseComponent, STOP_COMPONENT, START_COMPONENT } from "../components/base-component"

function stopAllComponents(components: Record<string, IBaseComponent>) {
const pending: PromiseLike<any>[] = []
Expand Down Expand Up @@ -70,7 +70,7 @@ async function startComponentsLifecycle(components: Record<string, IBaseComponen
)
}
if (!component) throw new Error("Null or empty components are not allowed: " + c)
var startFn: IBaseComponent[START_COMPONENT] = undefined
var startFn: IBaseComponent[typeof START_COMPONENT] = undefined

if (typeof component[START_COMPONENT] == "function") {
startFn = component[START_COMPONENT].bind(component)
Expand Down

0 comments on commit 77d50c2

Please sign in to comment.