Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@effect/platform

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/platform - npm Package Compare versions

Comparing version 0.70.1 to 0.70.2

@@ -190,4 +190,7 @@ "use strict";

const emptyDecodeable = HttpApiSchema.getEmptyDecodeable(ast);
const current = members.get(status) ?? Option.none();
members.set(status, current.pipe(Option.map(current => AST.Union.make(current._tag === "Union" ? [...current.types, ast] : [current, ast])), Option.orElse(() => !emptyDecodeable && AST.encodedAST(ast)._tag === "VoidKeyword" ? Option.none() : Option.some(ast))));
const current = members.get(status);
members.set(status, {
description: (current ? current.description : Option.none()).pipe(Option.orElse(() => getDescriptionOrIdentifier(ast))),
ast: (current ? current.ast : Option.none()).pipe(Option.map(current => AST.Union.make(current._tag === "Union" ? [...current.types, ast] : [current, ast])), Option.orElse(() => !emptyDecodeable && AST.encodedAST(ast)._tag === "VoidKeyword" ? Option.none() : Option.some(ast)))
});
}

@@ -234,2 +237,9 @@ if (topAst._tag === "Union") {

};
const getDescriptionOrIdentifier = ast => {
const annotations = "to" in ast ? {
...ast.to.annotations,
...ast.annotations
} : ast.annotations;
return Option.fromNullable(annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId]);
};
/**

@@ -236,0 +246,0 @@ * @since 1.0.0

@@ -51,3 +51,5 @@ "use strict";

const decodeResponse = HttpClientResponse.matchStatus(decodeMap);
errors.forEach((ast, status) => {
errors.forEach(({
ast
}, status) => {
if (ast._tag === "None") {

@@ -60,3 +62,5 @@ decodeMap[status] = statusCodeError;

});
successes.forEach((ast, status) => {
successes.forEach(({
ast
}, status) => {
decodeMap[status] = ast._tag === "None" ? responseAsVoid : schemaToResponse(ast.value);

@@ -168,3 +172,3 @@ });

exports.endpoint = endpoint;
const paramsRegex = /:(\w+)[^/]*/g;
const paramsRegex = /:([^/:.]+)/g;
const compilePath = path => {

@@ -171,0 +175,0 @@ const segments = path.split(paramsRegex);

@@ -11,3 +11,2 @@ "use strict";

var Schema = _interopRequireWildcard(require("effect/Schema"));
var AST = _interopRequireWildcard(require("effect/SchemaAST"));
var HttpApi = _interopRequireWildcard(require("./HttpApi.js"));

@@ -197,3 +196,3 @@ var HttpApiMiddleware = _interopRequireWildcard(require("./HttpApiMiddleware.js"));

}) {
const tag = {
let tag = {
name: Context.getOrElse(group.annotations, Title, () => group.identifier)

@@ -210,2 +209,5 @@ };

});
Option.map(Context.getOption(group.annotations, Transform), fn => {
tag = fn(tag);
});
spec.tags.push(tag);

@@ -223,3 +225,3 @@ },

const method = endpoint.method.toLowerCase();
const op = {
let op = {
tags: [Context.getOrElse(group.annotations, Title, () => group.identifier)],

@@ -268,6 +270,9 @@ operationId: Context.getOrElse(endpoint.annotations, Identifier, () => group.topLevel ? endpoint.name : `${group.identifier}.${endpoint.name}`),

}
for (const [status, ast] of successes) {
for (const [status, {
ast,
description
}] of successes) {
if (op.responses[status]) continue;
op.responses[status] = {
description: Option.getOrElse(getDescriptionOrIdentifier(ast), () => "Success")
description: Option.getOrElse(description, () => "Success")
};

@@ -334,6 +339,9 @@ ast.pipe(Option.filter(ast => !HttpApiSchema.getEmptyDecodeable(ast)), Option.map(ast => {

}
for (const [status, ast] of errors) {
for (const [status, {
ast,
description
}] of errors) {
if (op.responses[status]) continue;
op.responses[status] = {
description: Option.getOrElse(getDescriptionOrIdentifier(ast), () => "Error")
description: Option.getOrElse(description, () => "Error")
};

@@ -354,2 +362,5 @@ ast.pipe(Option.filter(ast => !HttpApiSchema.getEmptyDecodeable(ast)), Option.map(ast => {

});
Option.map(Context.getOption(endpoint.annotations, Transform), transformFn => {
op = transformFn(op);
});
spec.paths[path][method] = op;

@@ -402,6 +413,2 @@ }

};
const getDescriptionOrIdentifier = ast => ast.pipe(Option.map(ast => "to" in ast ? {
...ast.to.annotations,
...ast.annotations
} : ast.annotations), Option.flatMapNullable(annotations => annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId]));
//# sourceMappingURL=OpenApi.js.map

@@ -146,4 +146,10 @@ /**

}>;
readonly successes: ReadonlyMap<number, Option.Option<AST.AST>>;
readonly errors: ReadonlyMap<number, Option.Option<AST.AST>>;
readonly successes: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>;
readonly description: Option.Option<string>;
}>;
readonly errors: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>;
readonly description: Option.Option<string>;
}>;
}) => void;

@@ -150,0 +156,0 @@ }) => void;

@@ -260,3 +260,3 @@ /**

*/
export declare const makeRoute: <E, R>(method: Method.HttpMethod, path: PathInput, handler: Route.Handler<E, R>, options?: {
export declare const makeRoute: <E, R>(method: Method.HttpMethod | "*", path: PathInput, handler: Route.Handler<E, R>, options?: {
readonly prefix?: string | undefined;

@@ -263,0 +263,0 @@ readonly uninterruptible?: boolean | undefined;

@@ -85,3 +85,3 @@ /**

}
declare const Transform_base: Context.TagClass<Transform, "@effect/platform/OpenApi/Transform", (openApiSpec: OpenAPISpec) => OpenAPISpec>;
declare const Transform_base: Context.TagClass<Transform, "@effect/platform/OpenApi/Transform", (openApiSpec: Record<string, any>) => Record<string, any>>;
/**

@@ -101,6 +101,6 @@ * Transforms the generated OpenAPI specification

readonly title?: string | undefined;
readonly summary?: string | undefined;
readonly version?: string | undefined;
readonly description?: string | undefined;
readonly license?: OpenAPISpecLicense | undefined;
readonly summary?: string | undefined;
readonly externalDocs?: OpenAPISpecExternalDocs | undefined;

@@ -110,6 +110,3 @@ readonly servers?: ReadonlyArray<OpenAPISpecServer> | undefined;

readonly override?: Record<string, unknown> | undefined;
/**
* Transforms the generated OpenAPI specification
*/
readonly transform?: ((openApiSpec: OpenAPISpec) => OpenAPISpec) | undefined;
readonly transform?: ((openApiSpec: Record<string, any>) => Record<string, any>) | undefined;
}) => Context.Context<never>;

@@ -116,0 +113,0 @@ /**

@@ -178,4 +178,7 @@ /**

const emptyDecodeable = HttpApiSchema.getEmptyDecodeable(ast);
const current = members.get(status) ?? Option.none();
members.set(status, current.pipe(Option.map(current => AST.Union.make(current._tag === "Union" ? [...current.types, ast] : [current, ast])), Option.orElse(() => !emptyDecodeable && AST.encodedAST(ast)._tag === "VoidKeyword" ? Option.none() : Option.some(ast))));
const current = members.get(status);
members.set(status, {
description: (current ? current.description : Option.none()).pipe(Option.orElse(() => getDescriptionOrIdentifier(ast))),
ast: (current ? current.ast : Option.none()).pipe(Option.map(current => AST.Union.make(current._tag === "Union" ? [...current.types, ast] : [current, ast])), Option.orElse(() => !emptyDecodeable && AST.encodedAST(ast)._tag === "VoidKeyword" ? Option.none() : Option.some(ast)))
});
}

@@ -222,2 +225,9 @@ if (topAst._tag === "Union") {

};
const getDescriptionOrIdentifier = ast => {
const annotations = "to" in ast ? {
...ast.to.annotations,
...ast.annotations
} : ast.annotations;
return Option.fromNullable(annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId]);
};
/**

@@ -224,0 +234,0 @@ * @since 1.0.0

@@ -42,3 +42,5 @@ /**

const decodeResponse = HttpClientResponse.matchStatus(decodeMap);
errors.forEach((ast, status) => {
errors.forEach(({
ast
}, status) => {
if (ast._tag === "None") {

@@ -51,3 +53,5 @@ decodeMap[status] = statusCodeError;

});
successes.forEach((ast, status) => {
successes.forEach(({
ast
}, status) => {
decodeMap[status] = ast._tag === "None" ? responseAsVoid : schemaToResponse(ast.value);

@@ -156,3 +160,3 @@ });

// ----------------------------------------------------------------------------
const paramsRegex = /:(\w+)[^/]*/g;
const paramsRegex = /:([^/:.]+)/g;
const compilePath = path => {

@@ -159,0 +163,0 @@ const segments = path.split(paramsRegex);

@@ -8,3 +8,2 @@ /**

import * as Schema from "effect/Schema";
import * as AST from "effect/SchemaAST";
import * as HttpApi from "./HttpApi.js";

@@ -176,3 +175,3 @@ import * as HttpApiMiddleware from "./HttpApiMiddleware.js";

}) {
const tag = {
let tag = {
name: Context.getOrElse(group.annotations, Title, () => group.identifier)

@@ -189,2 +188,5 @@ };

});
Option.map(Context.getOption(group.annotations, Transform), fn => {
tag = fn(tag);
});
spec.tags.push(tag);

@@ -202,3 +204,3 @@ },

const method = endpoint.method.toLowerCase();
const op = {
let op = {
tags: [Context.getOrElse(group.annotations, Title, () => group.identifier)],

@@ -247,6 +249,9 @@ operationId: Context.getOrElse(endpoint.annotations, Identifier, () => group.topLevel ? endpoint.name : `${group.identifier}.${endpoint.name}`),

}
for (const [status, ast] of successes) {
for (const [status, {
ast,
description
}] of successes) {
if (op.responses[status]) continue;
op.responses[status] = {
description: Option.getOrElse(getDescriptionOrIdentifier(ast), () => "Success")
description: Option.getOrElse(description, () => "Success")
};

@@ -313,6 +318,9 @@ ast.pipe(Option.filter(ast => !HttpApiSchema.getEmptyDecodeable(ast)), Option.map(ast => {

}
for (const [status, ast] of errors) {
for (const [status, {
ast,
description
}] of errors) {
if (op.responses[status]) continue;
op.responses[status] = {
description: Option.getOrElse(getDescriptionOrIdentifier(ast), () => "Error")
description: Option.getOrElse(description, () => "Error")
};

@@ -333,2 +341,5 @@ ast.pipe(Option.filter(ast => !HttpApiSchema.getEmptyDecodeable(ast)), Option.map(ast => {

});
Option.map(Context.getOption(endpoint.annotations, Transform), transformFn => {
op = transformFn(op);
});
spec.paths[path][method] = op;

@@ -380,6 +391,2 @@ }

};
const getDescriptionOrIdentifier = ast => ast.pipe(Option.map(ast => "to" in ast ? {
...ast.to.annotations,
...ast.annotations
} : ast.annotations), Option.flatMapNullable(annotations => annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId]));
//# sourceMappingURL=OpenApi.js.map
{
"name": "@effect/platform",
"version": "0.70.1",
"version": "0.70.2",
"description": "Unified interfaces for common platform-specific services",

@@ -17,3 +17,3 @@ "license": "MIT",

"peerDependencies": {
"effect": "^3.11.1"
"effect": "^3.11.2"
},

@@ -20,0 +20,0 @@ "publishConfig": {

@@ -289,4 +289,10 @@ /**

}>
readonly successes: ReadonlyMap<number, Option.Option<AST.AST>>
readonly errors: ReadonlyMap<number, Option.Option<AST.AST>>
readonly successes: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>
readonly errors: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>
}) => void

@@ -333,5 +339,11 @@ }

topAst: AST.AST,
inherited: ReadonlyMap<number, Option.Option<AST.AST>>,
inherited: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>,
getStatus: (ast: AST.AST) => number
): ReadonlyMap<number, Option.Option<AST.AST>> => {
): ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}> => {
const members = new Map(inherited)

@@ -348,15 +360,20 @@ function process(ast: AST.AST) {

const emptyDecodeable = HttpApiSchema.getEmptyDecodeable(ast)
const current = members.get(status) ?? Option.none()
const current = members.get(status)
members.set(
status,
current.pipe(
Option.map((current) =>
AST.Union.make(
current._tag === "Union" ? [...current.types, ast] : [current, ast]
{
description: (current ? current.description : Option.none()).pipe(
Option.orElse(() => getDescriptionOrIdentifier(ast))
),
ast: (current ? current.ast : Option.none()).pipe(
Option.map((current) =>
AST.Union.make(
current._tag === "Union" ? [...current.types, ast] : [current, ast]
)
),
Option.orElse(() =>
!emptyDecodeable && AST.encodedAST(ast)._tag === "VoidKeyword" ? Option.none() : Option.some(ast)
)
),
Option.orElse(() =>
!emptyDecodeable && AST.encodedAST(ast)._tag === "VoidKeyword" ? Option.none() : Option.some(ast)
)
)
}
)

@@ -412,2 +429,12 @@ }

const getDescriptionOrIdentifier = (ast: AST.PropertySignature | AST.AST): Option.Option<string> => {
const annotations = "to" in ast ?
{
...ast.to.annotations,
...ast.annotations
} :
ast.annotations
return Option.fromNullable(annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId] as any)
}
/**

@@ -414,0 +441,0 @@ * @since 1.0.0

@@ -121,4 +121,10 @@ /**

readonly middleware: ReadonlySet<HttpApiMiddleware.TagClassAny>
readonly successes: ReadonlyMap<number, Option.Option<AST.AST>>
readonly errors: ReadonlyMap<number, Option.Option<AST.AST>>
readonly successes: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>
readonly errors: ReadonlyMap<number, {
readonly ast: Option.Option<AST.AST>
readonly description: Option.Option<string>
}>
readonly endpointFn: Function

@@ -156,3 +162,3 @@ }) => void

const decodeResponse = HttpClientResponse.matchStatus(decodeMap)
errors.forEach((ast, status) => {
errors.forEach(({ ast }, status) => {
if (ast._tag === "None") {

@@ -165,3 +171,3 @@ decodeMap[status] = statusCodeError

})
successes.forEach((ast, status) => {
successes.forEach(({ ast }, status) => {
decodeMap[status] = ast._tag === "None" ? responseAsVoid : schemaToResponse(ast.value)

@@ -354,3 +360,3 @@ })

const paramsRegex = /:(\w+)[^/]*/g
const paramsRegex = /:([^/:.]+)/g

@@ -357,0 +363,0 @@ const compilePath = (path: string) => {

@@ -362,3 +362,3 @@ /**

export const makeRoute: <E, R>(
method: Method.HttpMethod,
method: Method.HttpMethod | "*",
path: PathInput,

@@ -365,0 +365,0 @@ handler: Route.Handler<E, R>,

@@ -345,3 +345,3 @@ import type * as Cause from "effect/Cause"

export const makeRoute = <E, R>(
method: Method.HttpMethod,
method: Method.HttpMethod | "*",
path: Router.PathInput,

@@ -348,0 +348,0 @@ handler: Router.Route.Handler<E, R>,

@@ -9,3 +9,2 @@ /**

import * as Schema from "effect/Schema"
import * as AST from "effect/SchemaAST"
import type { DeepMutable, Mutable } from "effect/Types"

@@ -94,5 +93,6 @@ import * as HttpApi from "./HttpApi.js"

*/
export class Transform
extends Context.Tag("@effect/platform/OpenApi/Transform")<Transform, (openApiSpec: OpenAPISpec) => OpenAPISpec>()
{}
export class Transform extends Context.Tag("@effect/platform/OpenApi/Transform")<
Transform,
(openApiSpec: Record<string, any>) => Record<string, any>
>() {}

@@ -124,6 +124,6 @@ const contextPartial = <Tags extends Record<string, Context.Tag<any, any>>>(tags: Tags): (

readonly title?: string | undefined
readonly summary?: string | undefined
readonly version?: string | undefined
readonly description?: string | undefined
readonly license?: OpenAPISpecLicense | undefined
readonly summary?: string | undefined
readonly externalDocs?: OpenAPISpecExternalDocs | undefined

@@ -133,6 +133,3 @@ readonly servers?: ReadonlyArray<OpenAPISpecServer> | undefined

readonly override?: Record<string, unknown> | undefined
/**
* Transforms the generated OpenAPI specification
*/
readonly transform?: ((openApiSpec: OpenAPISpec) => OpenAPISpec) | undefined
readonly transform?: ((openApiSpec: Record<string, any>) => Record<string, any>) | undefined
}

@@ -224,3 +221,3 @@ ) => Context.Context<never> = contextPartial({

onGroup({ group }) {
const tag: Mutable<OpenAPISpecTag> = {
let tag: Mutable<OpenAPISpecTag> = {
name: Context.getOrElse(group.annotations, Title, () => group.identifier)

@@ -237,2 +234,5 @@ }

})
Option.map(Context.getOption(group.annotations, Transform), (fn) => {
tag = fn(tag) as OpenAPISpecTag
})
spec.tags!.push(tag)

@@ -243,3 +243,3 @@ },

const method = endpoint.method.toLowerCase() as OpenAPISpecMethodName
const op: DeepMutable<OpenAPISpecOperation> = {
let op: DeepMutable<OpenAPISpecOperation> = {
tags: [Context.getOrElse(group.annotations, Title, () => group.identifier)],

@@ -285,6 +285,6 @@ operationId: Context.getOrElse(

}
for (const [status, ast] of successes) {
for (const [status, { ast, description }] of successes) {
if (op.responses![status]) continue
op.responses![status] = {
description: Option.getOrElse(getDescriptionOrIdentifier(ast), () => "Success")
description: Option.getOrElse(description, () => "Success")
}

@@ -354,6 +354,6 @@ ast.pipe(

}
for (const [status, ast] of errors) {
for (const [status, { ast, description }] of errors) {
if (op.responses![status]) continue
op.responses![status] = {
description: Option.getOrElse(getDescriptionOrIdentifier(ast), () => "Error")
description: Option.getOrElse(description, () => "Error")
}

@@ -377,2 +377,5 @@ ast.pipe(

})
Option.map(Context.getOption(endpoint.annotations, Transform), (transformFn) => {
op = transformFn(op)
})
spec.paths[path][method] = op

@@ -383,3 +386,3 @@ }

Option.map(Context.getOption(api.annotations, Transform), (transformFn) => {
spec = transformFn(spec)
spec = transformFn(spec) as OpenAPISpec
})

@@ -428,17 +431,2 @@

const getDescriptionOrIdentifier = (ast: Option.Option<AST.PropertySignature | AST.AST>): Option.Option<string> =>
ast.pipe(
Option.map((ast) =>
"to" in ast ?
{
...ast.to.annotations,
...ast.annotations
} :
ast.annotations
),
Option.flatMapNullable((annotations) =>
annotations[AST.DescriptionAnnotationId] ?? annotations[AST.IdentifierAnnotationId] as any
)
)
/**

@@ -445,0 +433,0 @@ * @category models

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet