Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#180 Updating BE packages #181

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/backend-express-io-ts-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ty-ras/backend-express-io-ts-openapi",
"version": "2.1.0",
"version": "2.2.0",
"author": {
"name": "Stanislav Muhametsin",
"email": "[email protected]",
Expand Down Expand Up @@ -45,9 +45,9 @@
}
},
"dependencies": {
"@ty-ras/server-express": "^2.1.0",
"@ty-ras/server-express": "^2.2.0",
"@ty-ras/data-backend-io-ts": "^2.0.2",
"@ty-ras/endpoint-spec": "^2.1.1",
"@ty-ras/endpoint-spec": "^2.2.0",
"@ty-ras/metadata-jsonschema-io-ts": "^2.0.1",
"@ty-ras/metadata-openapi": "^2.0.2",
"@ty-ras/state-io-ts": "^2.0.1",
Expand Down
38 changes: 38 additions & 0 deletions code/backend-express-io-ts-openapi/src/endpoint-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function newBuilder<
TDefaultResponseBodyContentType
>,
): ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand Down Expand Up @@ -80,6 +81,7 @@ export function newBuilder<
TDefaultResponseBodyContentType
>,
): ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand Down Expand Up @@ -136,6 +138,7 @@ export function newBuilder<
* This type specializes generic {@link epSpec.ApplicationBuilder} type to use `io-ts` and OpenAPI -specific type parameters where possible.
*/
export type ApplicationBuilder<
TServerContext = never,
TAuthenticatedState extends TStateSpecBase = typeof DEFAULT_AUTHENTICATED_STATE,
TOtherState extends TStateSpecBase = typeof DEFAULT_NOT_AUTHENTICATED_STATE,
TAllRequestBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
Expand All @@ -150,13 +153,48 @@ export type ApplicationBuilder<
DefaultStateHKT<TAuthenticatedState, TOtherState>,
MetadataProviders,
server.ServerContext,
TServerContext,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>;

/**
* This is helper type to have both {@link server.ServerContext} and `never` as context types of {@link ApplicationBuilder}.
*/
export type ApplicationBuilderAny<
TAuthenticatedState extends TStateSpecBase = typeof DEFAULT_AUTHENTICATED_STATE,
TOtherState extends TStateSpecBase = typeof DEFAULT_NOT_AUTHENTICATED_STATE,
TAllRequestBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
TAllResponseBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
TDefaultRequestBodyContentType extends TAllRequestBodyContentTypes = TAllRequestBodyContentTypes,
TDefaultResponseBodyContentType extends TAllResponseBodyContentTypes = TAllResponseBodyContentTypes,
// TMetadataProviders extends epSpec.TMetadataProvidersBase = MetadataProviders,
TAdditionalDataSpecHKT extends epSpec.EndpointSpecAdditionalDataHKTBase = epSpec.NoAdditionalSpecDataHKT,
> =
| ApplicationBuilder<
server.ServerContext,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>
| ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>;

/**
* This is the {@link dataBE.MaterializeStateInfo} type for {@link DefaultStateHKT}.
*/
Expand Down
39 changes: 21 additions & 18 deletions code/backend-express-io-ts-openapi/src/md-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type * as protocol from "@ty-ras/protocol"; // Imported only for JSDoc
import * as dataIO from "@ty-ras/data-backend-io-ts";
import type * as ep from "@ty-ras/endpoint";
import type * as serverGeneric from "@ty-ras/server";
import type * as server from "@ty-ras/server-express";
import type * as epSpecBase from "@ty-ras/endpoint-spec";
import * as md from "@ty-ras/metadata-openapi";
Expand All @@ -23,14 +23,14 @@ import * as epSpec from "./endpoint-spec";
* @returns All of the endpoints of `creationResult` along with endpoints to serve the OpenAPI document.
*/
export function endpointsWithOpenAPI(
builder: epSpec.ApplicationBuilder,
builder: epSpec.ApplicationBuilderAny,
creationResult: epSpecBase.EndpointsCreationResult<
epSpec.MetadataProviders,
server.ServerContext,
epSpec.DefaultStateInfo
>,
openAPIPath?: string,
): Array<ep.AppEndpoint<server.ServerContext, epSpec.DefaultStateInfo>>;
): MutableServerEndpoints;

/**
* Given the builder and the {@link epSpecBase.EndpointsCreationResult} from the builder, returns the endpoints of given {@link epSpecBase.EndpointsCreationResult}, along with endpoint(s) to serve OpenAPI document built from the endpoints.
Expand Down Expand Up @@ -58,7 +58,7 @@ export function endpointsWithOpenAPI<
...Array<keyof TAuthenticatedState>,
],
>(
builder: epSpec.ApplicationBuilder<
builder: epSpec.ApplicationBuilderAny<
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand All @@ -81,12 +81,7 @@ export function endpointsWithOpenAPI<
{ [P in TStateKeys[number]]: false }
>,
openAPIPath?: string,
): Array<
ep.AppEndpoint<
server.ServerContext,
epSpec.DefaultStateInfo<TAuthenticatedState, TOtherState>
>
>;
): MutableServerEndpoints<TAuthenticatedState, TOtherState>;

/**
* Given the builder and the {@link epSpecBase.EndpointsCreationResult} from the builder, returns the endpoints of given {@link epSpecBase.EndpointsCreationResult}, along with endpoint(s) to serve OpenAPI document built from the endpoints.
Expand Down Expand Up @@ -116,7 +111,7 @@ export function endpointsWithOpenAPI<
...Array<keyof TAuthenticatedState>,
],
>(
builder: epSpec.ApplicationBuilder<
builder: epSpec.ApplicationBuilderAny<
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand All @@ -142,13 +137,8 @@ export function endpointsWithOpenAPI<
{ [P in TStateKeys[number]]: false }
>,
openAPIPath?: string,
): Array<
ep.AppEndpoint<
server.ServerContext,
epSpec.DefaultStateInfo<TAuthenticatedState, TOtherState>
>
> {
const noMD = builder.resetMetadataProviders();
): MutableServerEndpoints<TAuthenticatedState, TOtherState> {
const noMD = builder.showContextToEndpoints().resetMetadataProviders();
const noURLParameters = noMD.url``({});
const params: ParametersValidation<
TAuthenticatedState,
Expand Down Expand Up @@ -226,6 +216,19 @@ export function endpointsWithOpenAPI<
];
}

/**
* Helper type to specify return type of {@link endpointsWithOpenAPI}.
*/
export type MutableServerEndpoints<
TAuthenticatedState extends epSpec.TStateSpecBase = epSpec.TStateSpecBase,
TOtherState extends epSpec.TStateSpecBase = epSpec.TStateSpecBase,
> = Array<
serverGeneric.ServerEndpoints<
server.ServerContext,
epSpec.DefaultStateInfo<TAuthenticatedState, TOtherState>
>[number]
>;

/**
* This is the protocol interface for OpenAPI endpoint.
* @see protocol.ProtocolSpecCore
Expand Down
26 changes: 13 additions & 13 deletions code/backend-express-io-ts-openapi/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@
dependencies:
"@ty-ras/protocol" "^2.0.0"

"@ty-ras/endpoint-spec@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@ty-ras/endpoint-spec/-/endpoint-spec-2.1.1.tgz#bef7c85a39c0777c9bdce8eea46e9f9ecb881d12"
integrity sha512-M3pXOyJA8FWVSBvSPCkDXZS0O8bUlt8k9YOm7vsK2VNA00a5pmRuKU17atxT1FiS6TbhRtch704m2MgNMNr9kA==
"@ty-ras/endpoint-spec@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ty-ras/endpoint-spec/-/endpoint-spec-2.2.0.tgz#be4975fe00dec66c10ba86486aba639b5a7c4f88"
integrity sha512-T1LnSduUR/+c7XsQ1YSrxOtjU5mTvCtVyRwgcRFuR+crHz7Y7c6a13ie1MZ/khUnRhPvSsjOda8NRdZKk2KR8A==
dependencies:
"@ty-ras/endpoint" "^2.0.0"
"@ty-ras/metadata" "^2.0.0"
Expand Down Expand Up @@ -539,17 +539,17 @@
resolved "https://registry.yarnpkg.com/@ty-ras/protocol/-/protocol-2.0.0.tgz#2cba0ceb6f891228bed881eadb3e17812152c632"
integrity sha512-4ZGXghpSu8pdNz8oG8t36QAcYOugZ7FcfzsnGUIdK4VXIAwm5dW8d3y2JNv8w4hpa/QT6/oFUngK1H+ARrBc/Q==

"@ty-ras/server-express@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@ty-ras/server-express/-/server-express-2.1.0.tgz#5179b75850f8a178d37b2d0c622be476ddffd540"
integrity sha512-0Z+GrVA8wdnv6sp55n5AAmPFBV68/jItYYvL5WqKffaR09JN9fYDl3mqfoaX1bBlGObMRqwf4oK68Sh9rJ9hoQ==
"@ty-ras/server-express@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ty-ras/server-express/-/server-express-2.2.0.tgz#33d25e7ebadb6edba36ff027fcdf73f61c980465"
integrity sha512-s9B5SyH1om51oL6WF3vl4aVR/xnP1r3ppxRY5MMg2+6tqJtVXQmskEaAfrgapPD8xMEQm/XPHRiBviMh6WAxxw==
dependencies:
"@ty-ras/server" "^2.2.0"
"@ty-ras/server" "^2.3.0"

"@ty-ras/server@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@ty-ras/server/-/server-2.2.0.tgz#6a1dc54767241355be5202006127afea3a2ff602"
integrity sha512-rJwZj20uiO2tcS9Ln+5TfapdILDPcWxYbeyIDUjmbOmkv+FvMma+pVgKhozNP3iQj1mnKN2CmqgIhaxKw+bRBg==
"@ty-ras/server@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@ty-ras/server/-/server-2.3.0.tgz#f168669b29f777130823bf583341f83f0ade8ec0"
integrity sha512-0DhQqHHwyfDP2YJQhbxl+TAs4yDXKaBAVgs53+nCS0lr0M7Surc1MZ9AUeDQtcZJKc8FkWhUhUpt9aOQjZ89EA==
dependencies:
"@ty-ras/endpoint" "^2.0.0"

Expand Down
6 changes: 3 additions & 3 deletions code/backend-express-runtypes-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ty-ras/backend-express-runtypes-openapi",
"version": "2.1.0",
"version": "2.2.0",
"author": {
"name": "Stanislav Muhametsin",
"email": "[email protected]",
Expand Down Expand Up @@ -45,9 +45,9 @@
}
},
"dependencies": {
"@ty-ras/server-express": "^2.1.0",
"@ty-ras/server-express": "^2.2.0",
"@ty-ras/data-backend-runtypes": "^2.0.0",
"@ty-ras/endpoint-spec": "^2.1.1",
"@ty-ras/endpoint-spec": "^2.2.0",
"@ty-ras/metadata-jsonschema-runtypes": "^2.0.0",
"@ty-ras/metadata-openapi": "^2.0.2",
"@ty-ras/state-runtypes": "^2.0.0",
Expand Down
42 changes: 42 additions & 0 deletions code/backend-express-runtypes-openapi/src/endpoint-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function newBuilder<
TDefaultResponseBodyContentType
>,
): ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand Down Expand Up @@ -86,6 +87,7 @@ export function newBuilder<
TDefaultResponseBodyContentType
>,
): ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand Down Expand Up @@ -142,6 +144,7 @@ export function newBuilder<
* This type specializes generic {@link epSpec.ApplicationBuilder} type to use `runtypes` and OpenAPI -specific type parameters where possible.
*/
export type ApplicationBuilder<
TServerContext = never,
TAuthenticatedState extends
TStateSpecBase = typeof DEFAULT_AUTHENTICATED_STATE,
TOtherState extends TStateSpecBase = typeof DEFAULT_NOT_AUTHENTICATED_STATE,
Expand All @@ -160,13 +163,52 @@ export type ApplicationBuilder<
DefaultStateHKT<TAuthenticatedState, TOtherState>,
MetadataProviders,
server.ServerContext,
TServerContext,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>;

/**
* This is helper type to have both {@link server.ServerContext} and `never` as context types of {@link ApplicationBuilder}.
*/
export type ApplicationBuilderAny<
TAuthenticatedState extends
TStateSpecBase = typeof DEFAULT_AUTHENTICATED_STATE,
TOtherState extends TStateSpecBase = typeof DEFAULT_NOT_AUTHENTICATED_STATE,
TAllRequestBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
TAllResponseBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
TDefaultRequestBodyContentType extends
TAllRequestBodyContentTypes = TAllRequestBodyContentTypes,
TDefaultResponseBodyContentType extends
TAllResponseBodyContentTypes = TAllResponseBodyContentTypes,
// TMetadataProviders extends epSpec.TMetadataProvidersBase = MetadataProviders,
TAdditionalDataSpecHKT extends
epSpec.EndpointSpecAdditionalDataHKTBase = epSpec.NoAdditionalSpecDataHKT,
> =
| ApplicationBuilder<
server.ServerContext,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>
| ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>;

/**
* This is the {@link dataBE.MaterializeStateInfo} type for {@link DefaultStateHKT}.
*/
Expand Down
Loading
Loading