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

@ifit/json-schema-tools

Package Overview
Dependencies
Maintainers
63
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ifit/json-schema-tools - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [1.2.0](https://github.com/ifit/schema-tools/compare/@ifit/json-schema-tools@1.1.0...@ifit/json-schema-tools@1.2.0) (2024-03-12)
### Bug Fixes
* lint fix for unused variable in getTypes function ([712c095](https://github.com/ifit/schema-tools/commit/712c095362f4712ec555d49f5d0ecce239c01039))
### Features
* created npm package and using it in chainsaw code ([1e5f4cc](https://github.com/ifit/schema-tools/commit/1e5f4cc64fa0f615106d8c86ff64ce11dc44678e))
# 1.1.0 (2024-03-11)

@@ -8,0 +24,0 @@

3

lib/index.d.ts

@@ -1,1 +0,2 @@

export declare function someFunction(): void;
export declare function generateTypescript(schema: object): Promise<string>;
export declare function getTypes(typescript: string): string[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.someFunction = void 0;
function someFunction() {
console.log("hit in json schema tools");
exports.getTypes = exports.generateTypescript = void 0;
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
function annotateProperties(schema) {
var _a;
if (Array.isArray(schema.enum)) {
schema.tsEnumNames = schema.enum.map((val) => {
return val
.split("_")
.map((word) => `${word[0].toUpperCase()}${word.slice(1).toLowerCase()}`)
.join("");
});
}
switch (schema.format) {
case "date-time":
schema.tsType = "DateTime";
break;
case "duration":
schema.tsType = "Duration";
break;
}
if (schema.type === "object") {
for (const value of Object.values((_a = schema.properties) !== null && _a !== void 0 ? _a : {})) {
annotateProperties(value);
}
}
const arrayTypes = schema.oneOf || schema.anyOf || schema.allOf;
if (Array.isArray(arrayTypes)) {
for (const value of arrayTypes) {
annotateProperties(value);
}
}
}
exports.someFunction = someFunction;
async function generateTypescript(schema) {
var _a;
const schemaCopy = JSON.parse(JSON.stringify(schema));
for (const value of Object.values((_a = schemaCopy.definitions) !== null && _a !== void 0 ? _a : {})) {
annotateProperties(value);
}
const ts = await (0, json_schema_to_typescript_1.compile)(schemaCopy, "#", {
bannerComment: "",
enableConstEnums: false,
});
return ts;
}
exports.generateTypescript = generateTypescript;
function getTypes(typescript) {
const match = typescript.matchAll(/ (type|interface|enum) (\w+) /g);
return Array.from(match).map(([_all, _type, name]) => name);
}
exports.getTypes = getTypes;
//# sourceMappingURL=index.js.map
{
"name": "@ifit/json-schema-tools",
"version": "1.1.0",
"version": "1.2.0",
"description": "> TODO: description",

@@ -35,3 +35,6 @@ "author": "ericventor <Eric.Ventor@iFit.com>",

},
"gitHead": "cc58676391bd95e0f528c876ba5467e3a8425e4e"
"dependencies": {
"json-schema-to-typescript": "^13.1.2"
},
"gitHead": "3e042f3a0f0cddf126efa637cabaff69e5fc6d90"
}

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