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

conjure-typescript

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conjure-typescript - npm Package Compare versions

Comparing version 5.4.0 to 5.5.0

4

lib/commands/generate/errorGenerator.js

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

type: (0, utils_1.doubleQuote)(definition.code),
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -51,2 +52,3 @@ {

type: "string",
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -56,2 +58,3 @@ {

type: (0, utils_1.doubleQuote)(errorName),
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -61,2 +64,3 @@ {

type: "{\n" + properties + "}",
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -63,0 +67,0 @@ ],

@@ -34,2 +34,6 @@ /**

flavorizedAliases?: boolean;
/**
* Generated interfaces have readonly properties and collections
*/
readonlyInterfaces?: boolean;
}

@@ -36,0 +40,0 @@ export interface ITsConfig {

23

lib/commands/generate/generateCommand.js

@@ -80,4 +80,5 @@ "use strict";

var _a, output, rawSource, _b, conjureDefinition, packageJson, tsConfig, gitIgnore, generatePromise;
return __generator(this, function (_c) {
switch (_c.label) {
var _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:

@@ -88,5 +89,6 @@ _a = args._, output = _a[2];

case 1:
_b = _c.sent(), conjureDefinition = _b.conjureDefinition, packageJson = _b.packageJson, tsConfig = _b.tsConfig, gitIgnore = _b.gitIgnore;
_b = _e.sent(), conjureDefinition = _b.conjureDefinition, packageJson = _b.packageJson, tsConfig = _b.tsConfig, gitIgnore = _b.gitIgnore;
generatePromise = (0, generator_1.generate)(conjureDefinition, output, {
flavorizedAliases: !!args.flavorizedAliases,
flavorizedAliases: (_c = args.flavorizedAliases) !== null && _c !== void 0 ? _c : false,
readonlyInterfaces: (_d = args.readonlyInterfaces) !== null && _d !== void 0 ? _d : false,
});

@@ -139,2 +141,7 @@ if (rawSource) {

})
.option("readonlyInterfaces", {
default: false,
describe: "Generated interfaces have readonly properties and collections",
type: "boolean",
})
.option("productDependencies", {

@@ -162,3 +169,3 @@ default: undefined,

}
else if (!rawSource && !(0, sls_version_1.isValid)(packageVersion)) {
else if (!rawSource && !sls_version_1.SlsVersion.isValid(packageVersion)) {
throw new Error("Expected version to be valid SLS version but found \"" + packageVersion + ". " +

@@ -247,6 +254,7 @@ "Please see https://github.com/palantir/sls-version-js for more details on SLS version.");

var maxVersion = productDependency["maximum-version"];
var optional = productDependency.optional;
var recommendedVersion = productDependency["recommended-version"];
if (!(0, sls_version_1.isValid)(minVersion) ||
if (!sls_version_1.SlsVersion.isValid(minVersion) ||
sls_version_1.SlsVersionMatcher.safeValueOf(maxVersion) == null ||
(recommendedVersion && !(0, sls_version_1.isValid)(recommendedVersion))) {
(recommendedVersion && !sls_version_1.SlsVersion.isValid(recommendedVersion))) {
throw new Error("Encountered invalid product dependency");

@@ -257,2 +265,3 @@ }

maxVersion: maxVersion,
optional: optional,
recommendedVersion: recommendedVersion,

@@ -259,0 +268,0 @@ };

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

protected nestedVisitor: () => ITypeVisitor<string>;
protected getArrayType(itemType: string): string;
}

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

var valueTsType = conjure_api_1.IType.visit(obj.valueType, _this.nestedVisitor());
var maybeReadonly = _this.typeGenerationFlags.readonlyInterfaces ? 'readonly ' : '';
if (conjure_api_1.IType.isReference(obj.keyType)) {

@@ -60,19 +61,19 @@ var keyTypeDefinition = _this.knownTypes.get((0, utils_1.createHashableTypeName)(obj.keyType.reference));

if (conjure_api_1.ITypeDefinition.isEnum(keyTypeDefinition)) {
return "{ [key in " + obj.keyType.reference.name + "]?: " + valueTsType + " }";
return "{ " + maybeReadonly + "[key in " + obj.keyType.reference.name + "]?: " + valueTsType + " }";
}
else if (conjure_api_1.ITypeDefinition.isAlias(keyTypeDefinition) &&
(0, utils_1.isFlavorizable)(keyTypeDefinition.alias.alias, _this.typeGenerationFlags.flavorizedAliases)) {
return "{ [key: I" + obj.keyType.reference.name + "]: " + valueTsType + " }";
return "{ " + maybeReadonly + "[key: I" + obj.keyType.reference.name + "]: " + valueTsType + " }";
}
}
}
return "{ [key: string]: " + valueTsType + " }";
return "{ " + maybeReadonly + "[key: string]: " + valueTsType + " }";
};
this.list = function (obj) {
var itemType = conjure_api_1.IType.visit(obj.itemType, _this.nestedVisitor());
return "Array<" + itemType + ">";
return _this.getArrayType(itemType);
};
this.set = function (obj) {
var itemType = conjure_api_1.IType.visit(obj.itemType, _this.nestedVisitor());
return "Array<" + itemType + ">";
return _this.getArrayType(itemType);
};

@@ -114,2 +115,5 @@ this.optional = function (obj) {

}
TsReturnTypeVisitor.prototype.getArrayType = function (itemType) {
return this.typeGenerationFlags.readonlyInterfaces ? "ReadonlyArray<" + itemType + ">" : "Array<" + itemType + ">";
};
return TsReturnTypeVisitor;

@@ -116,0 +120,0 @@ }());

@@ -24,3 +24,7 @@ /**

*/
flavorizedAliases: boolean;
readonly flavorizedAliases: boolean;
/**
* Generated interfaces have readonly properties and use ReadonlyArray instead of Array.
*/
readonly readonlyInterfaces: boolean;
}

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

docs: (0, utils_1.addDeprecatedToDocs)(fieldDefinition),
isReadonly: typeGenerationFlags.readonlyInterfaces,
};

@@ -331,2 +332,3 @@ properties.push(property);

type: fieldType,
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -336,2 +338,3 @@ {

type: (0, utils_1.doubleQuote)(memberName),
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -373,2 +376,3 @@ ],

type: "(obj: " + fieldType + ") => T",
isReadonly: typeGenerationFlags.readonlyInterfaces,
});

@@ -380,2 +384,3 @@ visitorStatements.push("if (" + typeGuard.name + "(" + obj + ")) {\n return " + visitor + "." + memberName + "(" + obj + "." + memberName + ");\n }");

type: "(obj: " + unionTsType + ") => T",
isReadonly: typeGenerationFlags.readonlyInterfaces,
});

@@ -382,0 +387,0 @@ visitorStatements.push("return " + visitor + ".unknown(" + obj + ");");

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

"recommended-version"?: string;
"optional"?: boolean;
}

@@ -15,3 +16,4 @@ export interface IProductDependency {

maxVersion: string;
optional?: boolean;
recommendedVersion?: string;
}
{
"name": "conjure-typescript",
"version": "5.4.0",
"version": "5.5.0",
"description": "A conjure generator for Typescript",

@@ -31,8 +31,8 @@ "bin": {

"conjure-client": "^2.4.1",
"fs-extra": "^5.0.0",
"fs-extra": "^10.1.0",
"lodash": "^4.17.11",
"mkdirp": "^0.5.1",
"mkdirp": "^1.0.4",
"path": "^0.12.7",
"semver": "^5.6.0",
"sls-version": "^1.1.1",
"semver": "^7.3.7",
"sls-version": "^2.1.0",
"ts-simple-ast": "^11.3.0",

@@ -43,14 +43,12 @@ "tslib": "^1.9.3",

"devDependencies": {
"@blueprintjs/tslint-config": "^1.6.0",
"@blueprintjs/tslint-config": "^3.3.1",
"@types/chai": "^4.1.6",
"@types/commander": "2.12.2",
"@types/download": "^6.2.2",
"@types/fs-extra": "^5.0.4",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.0.3",
"@types/lodash": "^4.14.117",
"@types/mkdirp": "^0.5.2",
"@types/mkdirp": "^1.0.2",
"@types/nock": "^9.3.0",
"@types/node": "^16.11.7",
"@types/node-dir": "^0.0.30",
"@types/semver": "^5.5.0",
"@types/semver": "^7.3.10",
"@types/tempy": "^0.1.0",

@@ -60,8 +58,8 @@ "@types/yargs": "^11.1.2",

"jest": "^27.0.3",
"karma": "^2.0.5",
"karma": "^6.4.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-chrome-launcher": "^3.1.1",
"karma-mocha": "^2.0.1",
"karma-nodeunit": "^0.2.0",
"karma-typescript": "^3.0.13",
"karma-typescript": "^5.5.3",
"mocha": "^5.2.0",

@@ -73,7 +71,7 @@ "node-dir": "^0.1.17",

"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
"tslint": "^5.11.0",
"ts-loader": "^9.3.1",
"tslint": "^6.0.0",
"typescript": "~4.4.4",
"webpack": "^5.64.1",
"webpack-cli": "^4.9.1"
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},

@@ -80,0 +78,0 @@ "author": "Palantir Technologies, Inc.",

@@ -30,9 +30,11 @@ <p align="right">

Options:
--version Show version number [boolean]
--help Show help [boolean]
--packageVersion The version of the generated package [string]
--packageName The name of the generated package [string]
--nodeCompatibleModules Generate node compatible javascript [boolean] [default: false]
--rawSource Generate raw source without any package metadata [boolean] [default: false]
--productDependencies Path to a file containing a list of product dependencies [string]
--version Show version number [boolean]
--help Show help [boolean]
--packageVersion The version of the generated package [string]
--packageName The name of the generated package [string]
--flavorizedAliases Generates flavoured types for compatible aliases. [boolean] [default: false]
--nodeCompatibleModules Generate node compatible javascript [boolean] [default: false]
--rawSource Generate raw source without any package metadata [boolean] [default: false]
--readonlyInterfaces Generated interfaces have readonly properties and collections [boolean] [default: false]
--productDependencies Path to a file containing a list of product dependencies [string]
```

@@ -39,0 +41,0 @@

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

type: doubleQuote(definition.code),
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -61,2 +62,3 @@ {

type: "string",
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -66,2 +68,3 @@ {

type: doubleQuote(errorName),
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -71,2 +74,3 @@ {

type: `{\n${properties}}`,
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -73,0 +77,0 @@ ],

@@ -21,3 +21,3 @@ /**

import * as path from "path";
import { isValid, SlsVersionMatcher } from "sls-version";
import { SlsVersion, SlsVersionMatcher } from "sls-version";
import { Argv, CommandModule } from "yargs";

@@ -62,2 +62,7 @@ import { IPackageJson, IProductDependency, ISlsManifestDependency, writeJson } from "../../utils";

flavorizedAliases?: boolean;
/**
* Generated interfaces have readonly properties and collections
*/
readonlyInterfaces?: boolean;
}

@@ -118,2 +123,7 @@

})
.option("readonlyInterfaces", {
default: false,
describe: "Generated interfaces have readonly properties and collections",
type: "boolean",
})
.option("productDependencies", {

@@ -132,3 +142,4 @@ default: undefined,

const generatePromise = generate(conjureDefinition, output, {
flavorizedAliases: !!args.flavorizedAliases,
flavorizedAliases: args.flavorizedAliases ?? false,
readonlyInterfaces: args.readonlyInterfaces ?? false,
});

@@ -153,3 +164,3 @@ if (rawSource) {

throw new Error(`Directory "${output}" does not exist`);
} else if (!rawSource && !isValid(packageVersion!)) {
} else if (!rawSource && !SlsVersion.isValid(packageVersion!)) {
throw new Error(

@@ -219,7 +230,8 @@ `Expected version to be valid SLS version but found "${packageVersion}. ` +

const maxVersion = productDependency["maximum-version"];
const optional = productDependency.optional;
const recommendedVersion = productDependency["recommended-version"];
if (
!isValid(minVersion) ||
!SlsVersion.isValid(minVersion) ||
SlsVersionMatcher.safeValueOf(maxVersion) == null ||
(recommendedVersion && !isValid(recommendedVersion))
(recommendedVersion && !SlsVersion.isValid(recommendedVersion))
) {

@@ -231,2 +243,3 @@ throw new Error("Encountered invalid product dependency");

maxVersion,
optional,
recommendedVersion,

@@ -233,0 +246,0 @@ };

@@ -39,3 +39,4 @@ /**

protected typeGenerationFlags: ITypeGenerationFlags,
) {}
) {
}

@@ -68,2 +69,3 @@ public primitive = (obj: PrimitiveType): string => {

const valueTsType = IType.visit(obj.valueType, this.nestedVisitor());
const maybeReadonly = this.typeGenerationFlags.readonlyInterfaces ? 'readonly ' : '';
if (IType.isReference(obj.keyType)) {

@@ -73,3 +75,3 @@ const keyTypeDefinition = this.knownTypes.get(createHashableTypeName(obj.keyType.reference));

if (ITypeDefinition.isEnum(keyTypeDefinition)) {
return `{ [key in ${obj.keyType.reference.name}]?: ${valueTsType} }`;
return `{ ${maybeReadonly}[key in ${obj.keyType.reference.name}]?: ${valueTsType} }`;
} else if (

@@ -79,15 +81,15 @@ ITypeDefinition.isAlias(keyTypeDefinition) &&

) {
return `{ [key: I${obj.keyType.reference.name}]: ${valueTsType} }`;
return `{ ${maybeReadonly}[key: I${obj.keyType.reference.name}]: ${valueTsType} }`;
}
}
}
return `{ [key: string]: ${valueTsType} }`;
return `{ ${maybeReadonly}[key: string]: ${valueTsType} }`;
};
public list = (obj: IListType): string => {
const itemType = IType.visit(obj.itemType, this.nestedVisitor());
return `Array<${itemType}>`;
return this.getArrayType(itemType);
};
public set = (obj: ISetType): string => {
const itemType = IType.visit(obj.itemType, this.nestedVisitor());
return `Array<${itemType}>`;
return this.getArrayType(itemType);
};

@@ -128,2 +130,5 @@ public optional = (obj: IOptionalType): string => {

};
protected getArrayType(itemType: string) {
return this.typeGenerationFlags.readonlyInterfaces ? `ReadonlyArray<${itemType}>` : `Array<${itemType}>`;
}
}

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

*/
flavorizedAliases: boolean;
readonly flavorizedAliases: boolean;
/**
* Generated interfaces have readonly properties and use ReadonlyArray instead of Array.
*/
readonly readonlyInterfaces: boolean;
}

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

docs: addDeprecatedToDocs(fieldDefinition),
isReadonly: typeGenerationFlags.readonlyInterfaces,
};

@@ -329,2 +330,3 @@

type: fieldType,
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -334,2 +336,3 @@ {

type: doubleQuote(memberName),
isReadonly: typeGenerationFlags.readonlyInterfaces,
},

@@ -378,2 +381,3 @@ ],

type: `(obj: ${fieldType}) => T`,
isReadonly: typeGenerationFlags.readonlyInterfaces,
});

@@ -388,2 +392,3 @@ visitorStatements.push(`if (${typeGuard.name}(${obj})) {

type: `(obj: ${unionTsType}) => T`,
isReadonly: typeGenerationFlags.readonlyInterfaces,
});

@@ -390,0 +395,0 @@ visitorStatements.push(`return ${visitor}.unknown(${obj});`);

@@ -11,2 +11,4 @@ /**

"recommended-version"?: string;
// Optional for backcompat
"optional"?: boolean;
}

@@ -17,3 +19,5 @@

maxVersion: string;
// Optional for backcompat
optional?: boolean;
recommendedVersion?: string;
}

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

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