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

@open-rpc/typings

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-rpc/typings - npm Package Compare versions

Comparing version 1.12.3 to 1.12.4

6

build/cli.js

@@ -18,3 +18,3 @@ #!/usr/bin/env node

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -86,7 +86,7 @@ if (y = 0, t) op = [op[0] & 2, t.value];

_a.trys.push([0, 3, , 4]);
return [4 /*yield*/, schema_utils_js_1.parseOpenRPCDocument(commander_1.default.document)];
return [4 /*yield*/, (0, schema_utils_js_1.parseOpenRPCDocument)(commander_1.default.document)];
case 1:
openrpcDocument = _a.sent();
typingsOptions = parseTypingsOptions(commander_1.default);
return [4 /*yield*/, generate_typings_file_1.generateTypingsFile(openrpcDocument, typingsOptions)];
return [4 /*yield*/, (0, generate_typings_file_1.generateTypingsFile)(openrpcDocument, typingsOptions)];
case 2:

@@ -93,0 +93,0 @@ _a.sent();

@@ -17,3 +17,3 @@ "use strict";

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -67,8 +67,8 @@ if (y = 0, t) op = [op[0] & 2, t.value];

switch (_a.label) {
case 0: return [4 /*yield*/, fs_extra_1.ensureDir(option.dirName)];
case 0: return [4 /*yield*/, (0, fs_extra_1.ensureDir)(option.dirName)];
case 1:
_a.sent();
typings = methodTypings.toString(option.lang);
typingsFileName = option.dirName + "/" + option.fileName + getExtension(option.lang);
return [4 /*yield*/, fs_extra_1.writeFile(typingsFileName, typings, "utf8")];
typingsFileName = "".concat(option.dirName, "/").concat(option.fileName).concat(getExtension(option.lang));
return [4 /*yield*/, (0, fs_extra_1.writeFile)(typingsFileName, typings, "utf8")];
case 2: return [2 /*return*/, _a.sent()];

@@ -75,0 +75,0 @@ }

import { OpenrpcDocument as OpenRPC, MethodObject } from "@open-rpc/meta-schema";
export declare type GetMethodTypings = (openrpcSchema: OpenRPC) => string;
export declare type GetParamsTypings = (openrpcSchema: OpenRPC) => string;
export declare type GetParamsTyping = (method: MethodObject, joinString?: string) => string;
export declare type GetMethodAliasName = (method: MethodObject) => string;
export type GetMethodTypings = (openrpcSchema: OpenRPC) => string;
export type GetParamsTypings = (openrpcSchema: OpenRPC) => string;
export type GetParamsTyping = (method: MethodObject, joinString?: string) => string;
export type GetMethodAliasName = (method: MethodObject) => string;
export interface Generator {

@@ -7,0 +7,0 @@ getMethodTypings: GetMethodTypings;

@@ -21,7 +21,7 @@ "use strict";

var getMethodAliasName = function (method) {
return utils_1.languageSafeName(method.name);
return (0, utils_1.languageSafeName)(method.name);
};
exports.getMethodAliasName = getMethodAliasName;
var getParamsTyping = function (method) {
var params = method.params.map(function (param) { return param.name + " " + utils_1.languageSafeName(utils_1.getTitle(titleizer_1.default(param.schema))); }).join(", ");
var params = method.params.map(function (param) { return "".concat(param.name, " ").concat((0, utils_1.languageSafeName)((0, utils_1.getTitle)((0, titleizer_1.default)(param.schema)))); }).join(", ");
return params;

@@ -32,6 +32,6 @@ };

var mutableSchema = (mResult.schema === true || mResult.schema === false) ? mResult.schema : __assign({}, mResult.schema);
var resultName = utils_1.languageSafeName(utils_1.getTitle(titleizer_1.default(mutableSchema)));
var methodAliasName = exports.getMethodAliasName(method);
var resultName = (0, utils_1.languageSafeName)((0, utils_1.getTitle)((0, titleizer_1.default)(mutableSchema)));
var methodAliasName = (0, exports.getMethodAliasName)(method);
var params = getParamsTyping(method);
return "\t" + methodAliasName + "(" + params + ") (" + resultName + ", error)";
return "\t".concat(methodAliasName, "(").concat(params, ") (").concat(resultName, ", error)");
};

@@ -41,3 +41,3 @@ var getMethodTypings = function (openrpcDocument) {

return [
"type " + utils_1.languageSafeName(openrpcDocument.info.title) + " interface {",
"type ".concat((0, utils_1.languageSafeName)(openrpcDocument.info.title), " interface {"),
fns.join("\n"),

@@ -44,0 +44,0 @@ "}",

import { OpenrpcDocument as OpenRPC, MethodObject } from "@open-rpc/meta-schema";
export declare type OpenRPCTypingsSupportedLanguages = "rust" | "rs" | "typescript" | "ts" | "go" | "golang" | "py" | "python";
export type OpenRPCTypingsSupportedLanguages = "rust" | "rs" | "typescript" | "ts" | "go" | "golang" | "py" | "python";
interface OpenRPCTypings {

@@ -4,0 +4,0 @@ schemas: string;

@@ -30,4 +30,4 @@ "use strict";

};
var schemas = utils_1.getSchemasForOpenRPCDocument(openrpcDocument);
this.transpiler = new transpiler_1.default(utils_1.deepClone(schemas));
var schemas = (0, utils_1.getSchemasForOpenRPCDocument)(openrpcDocument);
this.transpiler = new transpiler_1.default((0, utils_1.deepClone)(schemas));
}

@@ -75,5 +75,5 @@ /**

var schema = _a.schema;
return utils_2.languageSafeName(utils_2.getTitle(titleizer_1.default(schema)));
return (0, utils_2.languageSafeName)((0, utils_2.getTitle)((0, titleizer_1.default)(schema)));
}),
result: utils_2.languageSafeName(utils_2.getTitle(titleizer_1.default(methodResult.schema))),
result: (0, utils_2.languageSafeName)((0, utils_2.getTitle)((0, titleizer_1.default)(methodResult.schema))),
};

@@ -80,0 +80,0 @@ };

@@ -15,3 +15,3 @@ "use strict";

var getMethodAliasName = function (method) {
return utils_1.languageSafeName(method.name);
return (0, utils_1.languageSafeName)(method.name);
};

@@ -18,0 +18,0 @@ exports.getMethodAliasName = getMethodAliasName;

@@ -21,7 +21,7 @@ "use strict";

var getMethodAliasName = function (method) {
return utils_1.languageSafeName(method.name);
return (0, utils_1.languageSafeName)(method.name);
};
exports.getMethodAliasName = getMethodAliasName;
var getParamsTyping = function (method) {
var params = method.params.map(function (param) { return param.name + ": " + utils_1.languageSafeName(utils_1.getTitle(titleizer_1.default(param.schema))); }).join(", ");
var params = method.params.map(function (param) { return "".concat(param.name, ": ").concat((0, utils_1.languageSafeName)((0, utils_1.getTitle)((0, titleizer_1.default)(param.schema)))); }).join(", ");
return params;

@@ -32,8 +32,8 @@ };

var mutableSchema = (mResult.schema === true || mResult.schema === false) ? mResult.schema : __assign({}, mResult.schema);
var resultName = utils_1.getTitle(titleizer_1.default(mutableSchema));
var result = "RpcRequest<" + utils_1.languageSafeName(resultName) + ">";
var methodAliasName = exports.getMethodAliasName(method);
var resultName = (0, utils_1.getTitle)((0, titleizer_1.default)(mutableSchema));
var result = "RpcRequest<".concat((0, utils_1.languageSafeName)(resultName), ">");
var methodAliasName = (0, exports.getMethodAliasName)(method);
var params = getParamsTyping(method);
var paramString = (params.length > 0) ? ", " + params : "";
return "pub fn " + methodAliasName + "(&mut self" + paramString + ") -> " + result + ";";
var paramString = (params.length > 0) ? ", ".concat(params) : "";
return "pub fn ".concat(methodAliasName, "(&mut self").concat(paramString, ") -> ").concat(result, ";");
};

@@ -40,0 +40,0 @@ var getMethodTypings = function (openrpcDocument) {

@@ -21,3 +21,3 @@ "use strict";

var getMethodAliasName = function (method) {
return utils_1.languageSafeName(method.name);
return (0, utils_1.languageSafeName)(method.name);
};

@@ -27,4 +27,4 @@ exports.getMethodAliasName = getMethodAliasName;

var params = method.params.map(function (param) { return [
"" + param.name + (param.required === false ? "?" : "") + ": ",
"" + utils_1.languageSafeName(utils_1.getTitle(titleizer_1.default(param.schema))),
"".concat(param.name).concat(param.required === false ? "?" : "", ": "),
"".concat((0, utils_1.languageSafeName)((0, utils_1.getTitle)((0, titleizer_1.default)(param.schema)))),
].join(""); }).join(joinString || ", ");

@@ -36,7 +36,7 @@ return params;

var mutableSchema = (result.schema === true || result.schema === false) ? result.schema : __assign({}, result.schema);
var resultName = utils_1.getTitle(titleizer_1.default(mutableSchema));
var resultTypeName = "Promise<" + utils_1.languageSafeName(resultName) + ">";
var methodAliasName = exports.getMethodAliasName(method);
var resultName = (0, utils_1.getTitle)((0, titleizer_1.default)(mutableSchema));
var resultTypeName = "Promise<".concat((0, utils_1.languageSafeName)(resultName), ">");
var methodAliasName = (0, exports.getMethodAliasName)(method);
var params = getParamsTyping(method);
return "export type " + methodAliasName + " = (" + params + ") => " + resultTypeName + ";";
return "export type ".concat(methodAliasName, " = (").concat(params, ") => ").concat(resultTypeName, ";");
};

@@ -43,0 +43,0 @@ var getMethodTypings = function (openrpcDocument) {

@@ -13,6 +13,10 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -24,3 +28,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

if (val instanceof Array) {
return __spreadArray(__spreadArray([], memo), val);
return __spreadArray(__spreadArray([], memo, true), val, true);
}

@@ -36,3 +40,3 @@ else {

var methods = openrpcDocument.methods;
var params = exports.flatten(methods.map(function (method) { return method.params; }));
var params = (0, exports.flatten)(methods.map(function (method) { return method.params; }));
var result = methods.map(function (method) { return method.result; });

@@ -58,3 +62,3 @@ return params

if (obj instanceof Array) {
result = obj.map(function (o) { return exports.deepClone(o, hash); });
result = obj.map(function (o) { return (0, exports.deepClone)(o, hash); });
}

@@ -67,3 +71,3 @@ else if (obj instanceof Set) {

var key = _a[0], val = _a[1];
return [key, exports.deepClone(val, hash)];
return [key, (0, exports.deepClone)(val, hash)];
}));

@@ -83,5 +87,5 @@ }

var _a;
return (_a = {}, _a[key] = exports.deepClone(obj[key], hash), _a);
})));
return (_a = {}, _a[key] = (0, exports.deepClone)(obj[key], hash), _a);
}), false));
};
exports.deepClone = deepClone;
{
"name": "@open-rpc/typings",
"private": false,
"version": "1.12.3",
"version": "1.12.4",
"description": "",

@@ -32,5 +32,5 @@ "main": "build/index.js",

"dependencies": {
"@json-schema-tools/titleizer": "1.0.8",
"@json-schema-tools/transpiler": "^1.10.3",
"@open-rpc/schema-utils-js": "1.16.1",
"@json-schema-tools/titleizer": "1.0.9",
"@json-schema-tools/transpiler": "^1.10.5",
"@open-rpc/schema-utils-js": "2.0.2",
"commander": "^6.0.0",

@@ -40,12 +40,12 @@ "fs-extra": "^10.0.0"

"devDependencies": {
"@open-rpc/examples": "1.6.1",
"@open-rpc/meta-schema": "1.14.2",
"@open-rpc/examples": "1.7.2",
"@open-rpc/meta-schema": "1.14.9",
"@types/commander": "^2.12.2",
"@types/fs-extra": "^9.0.1",
"@types/jest": "^26.0.7",
"jest": "^26.1.0",
"ts-jest": "^26.1.4",
"typedoc": "0.21.5",
"typescript": "4.3.5"
"@types/jest": "^29.5.12",
"jest": "^29.1.2",
"ts-jest": "^29.1.2",
"typedoc": "0.25.13",
"typescript": "4.9.5"
}
}
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