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

@fernapi/ir-generation

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fernapi/ir-generation - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

14

lib/index.d.ts
export { IntermediateRepresentationGenerationStage } from "./stage";
export type { AliasTypeDefinition } from "./types/AliasTypeDefinition";
export { ContainerType } from "./types/ContainerType";
export type { EnumTypeDefinition } from "./types/EnumTypeDefinition";
export type { EnumValue } from "./types/EnumValue";
export { FernFilepath } from "./types/FernFilepath";
export type { IntermediateRepresentation } from "./types/IntermediateRepresentation";
export type { ObjectTypeDefinition } from "./types/ObjectTypeDefinition";
export { PrimitiveType } from "./types/PrimitiveType";
export type { SingleUnionType } from "./types/SingleUnionType";
export { Type } from "./types/Type";
export type { TypeDefinition } from "./types/TypeDefinition";
export type { TypeName } from "./types/TypeName";
export { TypeReference } from "./types/TypeReference";
export type { UnionTypeDefinition } from "./types/UnionTypeDefinition";

12

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeReference = exports.Type = exports.PrimitiveType = exports.FernFilepath = exports.ContainerType = exports.IntermediateRepresentationGenerationStage = void 0;
exports.IntermediateRepresentationGenerationStage = void 0;
var stage_1 = require("./stage");
Object.defineProperty(exports, "IntermediateRepresentationGenerationStage", { enumerable: true, get: function () { return stage_1.IntermediateRepresentationGenerationStage; } });
var ContainerType_1 = require("./types/ContainerType");
Object.defineProperty(exports, "ContainerType", { enumerable: true, get: function () { return ContainerType_1.ContainerType; } });
var FernFilepath_1 = require("./types/FernFilepath");
Object.defineProperty(exports, "FernFilepath", { enumerable: true, get: function () { return FernFilepath_1.FernFilepath; } });
var PrimitiveType_1 = require("./types/PrimitiveType");
Object.defineProperty(exports, "PrimitiveType", { enumerable: true, get: function () { return PrimitiveType_1.PrimitiveType; } });
var Type_1 = require("./types/Type");
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return Type_1.Type; } });
var TypeReference_1 = require("./types/TypeReference");
Object.defineProperty(exports, "TypeReference", { enumerable: true, get: function () { return TypeReference_1.TypeReference; } });
//# sourceMappingURL=index.js.map

2

lib/stage.d.ts

@@ -0,4 +1,4 @@

import { IntermediateRepresentation } from "@fernapi/api";
import { CompilerStage, RelativeFilePath } from "@fernapi/compiler-commons";
import { RawSchemas } from "@fernapi/syntax-analysis";
import { IntermediateRepresentation } from "./types/IntermediateRepresentation";
export declare const IntermediateRepresentationGenerationStage: CompilerStage<Record<RelativeFilePath, RawSchemas.FernSchema>, IntermediateRepresentation, void>;

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

exports.IntermediateRepresentationGenerationStage = void 0;
const api_1 = require("@fernapi/api");
const path_1 = __importDefault(require("path"));
const ContainerType_1 = require("./types/ContainerType");
const FernFilepath_1 = require("./types/FernFilepath");
const HttpMethod_1 = require("./types/HttpMethod");
const PrimitiveType_1 = require("./types/PrimitiveType");
const Type_1 = require("./types/Type");
const TypeReference_1 = require("./types/TypeReference");
const WebSocketMessageOrigin_1 = require("./types/WebSocketMessageOrigin");
const WebSocketMessageResponseBehavior_1 = require("./types/WebSocketMessageResponseBehavior");
exports.IntermediateRepresentationGenerationStage = {

@@ -31,3 +24,3 @@ run: (schemas) => {

if (typeAsString == null) {
return TypeReference_1.TypeReference.void();
return api_1.TypeReference.void();
}

@@ -50,5 +43,5 @@ return parseInlineType({ type: typeAsString, fernFilepath, imports });

},
shape: Type_1.Type.alias({
shape: api_1.Type.alias({
aliasOf: typeof id === "string" || id.type == null
? TypeReference_1.TypeReference.primitive(PrimitiveType_1.PrimitiveType.String)
? api_1.TypeReference.primitive(api_1.PrimitiveType.String)
: parseInlinableType(id.type),

@@ -72,3 +65,3 @@ isId: true,

},
shape: Type_1.Type.alias({
shape: api_1.Type.alias({
aliasOf: parseInlinableType(typeof typeDefinition === "string" ? typeDefinition : typeDefinition.alias),

@@ -86,3 +79,3 @@ isId: false,

},
shape: Type_1.Type.object({
shape: api_1.Type.object({
extends: typeDefinition.extends != null

@@ -114,3 +107,3 @@ ? typeof typeDefinition.extends === "string"

},
shape: Type_1.Type.union({
shape: api_1.Type.union({
types: Object.entries(typeDefinition.union).map(([discriminantValue, unionedType]) => ({

@@ -131,3 +124,3 @@ discriminantValue,

},
shape: Type_1.Type.enum({
shape: api_1.Type.enum({
values: typeDefinition.enum.map((value) => typeof value === "string"

@@ -145,2 +138,3 @@ ? { value, docs: undefined }

services: (services) => {
var _a, _b, _c, _d;
if (services == null) {

@@ -150,11 +144,11 @@ return;

if (services.http != null) {
for (const [serviceName, serviceDefinition] of Object.entries(services.http)) {
for (const [serviceId, serviceDefinition] of Object.entries(services.http)) {
intermediateRepresentation.services.http.push({
docs: serviceDefinition.docs,
name: {
name: serviceName,
name: serviceId,
fernFilepath,
},
displayName: serviceDefinition.name,
basePath: serviceDefinition["base-path"],
displayName: (_a = serviceDefinition.name) !== null && _a !== void 0 ? _a : serviceId,
basePath: (_b = serviceDefinition["base-path"]) !== null && _b !== void 0 ? _b : "/",
headers: serviceDefinition.headers != null

@@ -167,4 +161,4 @@ ? Object.entries(serviceDefinition.headers).map(([header, headerType]) => ({

: [],
endpoints: Object.entries(serviceDefinition.endpoints).map(([endpointName, endpoint]) => ({
name: endpointName,
endpoints: Object.entries(serviceDefinition.endpoints).map(([endpointId, endpoint]) => ({
endpointId,
docs: endpoint.docs,

@@ -227,3 +221,3 @@ method: convertHttpMethod(endpoint.method),

if (services.webSocket != null) {
for (const [serviceName, serviceDefinition] of Object.entries(services.webSocket)) {
for (const [serviceId, serviceDefinition] of Object.entries(services.webSocket)) {
intermediateRepresentation.services.webSocket.push({

@@ -233,6 +227,6 @@ docs: serviceDefinition.docs,

fernFilepath,
name: serviceName,
name: serviceId,
},
displayName: serviceDefinition.name,
basePath: serviceDefinition["base-path"],
displayName: (_c = serviceDefinition.name) !== null && _c !== void 0 ? _c : serviceId,
basePath: (_d = serviceDefinition["base-path"]) !== null && _d !== void 0 ? _d : "/",
messages: Object.entries(serviceDefinition.messages).map(([messageName, message]) => ({

@@ -256,3 +250,3 @@ name: messageName,

? convertWebSocketMessageResponseBehavior(message.response.behavior)
: WebSocketMessageResponseBehavior_1.WebSocketMessageResponseBehavior.ONGOING,
: api_1.WebSocketMessageResponseBehavior.ONGOING,
}

@@ -301,3 +295,3 @@ : undefined,

if (mapMatch != null && mapMatch[1] != null && mapMatch[2] != null) {
return TypeReference_1.TypeReference.container(ContainerType_1.ContainerType.map({
return api_1.TypeReference.container(api_1.ContainerType.map({
keyType: parseInlineTypeRecursive(mapMatch[1]),

@@ -309,25 +303,25 @@ valueType: parseInlineTypeRecursive(mapMatch[2]),

if (listMatch != null && listMatch[1] != null) {
return TypeReference_1.TypeReference.container(ContainerType_1.ContainerType.list(parseInlineTypeRecursive(listMatch[1])));
return api_1.TypeReference.container(api_1.ContainerType.list(parseInlineTypeRecursive(listMatch[1])));
}
const setMatch = type.match(SET_REGEX);
if (setMatch != null && setMatch[1] != null) {
return TypeReference_1.TypeReference.container(ContainerType_1.ContainerType.set(parseInlineTypeRecursive(setMatch[1])));
return api_1.TypeReference.container(api_1.ContainerType.set(parseInlineTypeRecursive(setMatch[1])));
}
const optionalMatch = type.match(OPTIONAL_REGEX);
if (optionalMatch != null && optionalMatch[1] != null) {
return TypeReference_1.TypeReference.container(ContainerType_1.ContainerType.optional(parseInlineTypeRecursive(optionalMatch[1])));
return api_1.TypeReference.container(api_1.ContainerType.optional(parseInlineTypeRecursive(optionalMatch[1])));
}
switch (type) {
case "integer":
return TypeReference_1.TypeReference.primitive(PrimitiveType_1.PrimitiveType.Integer);
return api_1.TypeReference.primitive(api_1.PrimitiveType.Integer);
case "double":
return TypeReference_1.TypeReference.primitive(PrimitiveType_1.PrimitiveType.Double);
return api_1.TypeReference.primitive(api_1.PrimitiveType.Double);
case "long":
return TypeReference_1.TypeReference.primitive(PrimitiveType_1.PrimitiveType.Long);
return api_1.TypeReference.primitive(api_1.PrimitiveType.Long);
case "string":
return TypeReference_1.TypeReference.primitive(PrimitiveType_1.PrimitiveType.String);
return api_1.TypeReference.primitive(api_1.PrimitiveType.String);
case "boolean":
return TypeReference_1.TypeReference.primitive(PrimitiveType_1.PrimitiveType.Boolean);
return api_1.TypeReference.primitive(api_1.PrimitiveType.Boolean);
}
return TypeReference_1.TypeReference.named(parseTypeName({
return api_1.TypeReference.named(parseTypeName({
typeName: type,

@@ -377,9 +371,9 @@ fernFilepath,

case "GET":
return HttpMethod_1.HttpMethod.GET;
return api_1.HttpMethod.GET;
case "POST":
return HttpMethod_1.HttpMethod.POST;
return api_1.HttpMethod.POST;
case "PUT":
return HttpMethod_1.HttpMethod.PUT;
return api_1.HttpMethod.PUT;
case "DELETE":
return HttpMethod_1.HttpMethod.DELETE;
return api_1.HttpMethod.DELETE;
}

@@ -390,5 +384,5 @@ }

case "client":
return WebSocketMessageOrigin_1.WebSocketMessageOrigin.CLIENT;
return api_1.WebSocketMessageOrigin.CLIENT;
case "server":
return WebSocketMessageOrigin_1.WebSocketMessageOrigin.SERVER;
return api_1.WebSocketMessageOrigin.SERVER;
}

@@ -398,9 +392,9 @@ }

if (behavior == null) {
return WebSocketMessageResponseBehavior_1.WebSocketMessageResponseBehavior.ONGOING;
return api_1.WebSocketMessageResponseBehavior.ONGOING;
}
switch (behavior) {
case "ongoing":
return WebSocketMessageResponseBehavior_1.WebSocketMessageResponseBehavior.ONGOING;
return api_1.WebSocketMessageResponseBehavior.ONGOING;
case "request-response":
return WebSocketMessageResponseBehavior_1.WebSocketMessageResponseBehavior.REQUEST_RESPONSE;
return api_1.WebSocketMessageResponseBehavior.REQUEST_RESPONSE;
}

@@ -410,4 +404,4 @@ }

const parsed = path_1.default.parse(relativeFilepath);
return FernFilepath_1.FernFilepath.of(path_1.default.join(parsed.dir, parsed.name));
return api_1.FernFilepath.of(path_1.default.join(parsed.dir, parsed.name));
}
//# sourceMappingURL=stage.js.map
{
"name": "@fernapi/ir-generation",
"version": "0.1.0",
"version": "0.1.2",
"main": "lib/index.js",

@@ -23,4 +23,5 @@ "types": "lib/index.d.ts",

"dependencies": {
"@fernapi/compiler-commons": "^0.1.0",
"@fernapi/syntax-analysis": "^0.1.0"
"@fernapi/api": "^0.1.2",
"@fernapi/compiler-commons": "^0.1.2",
"@fernapi/syntax-analysis": "^0.1.2"
},

@@ -27,0 +28,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc