New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

martok

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

martok - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

17

dist/index.js

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

const Martok_1 = require("./martok/Martok");
const Patterns_1 = require("./typescript/Patterns");
const args = yargs_1.default

@@ -57,7 +56,2 @@ .scriptName("martok")

})
.option("datePattern", {
alias: "d",
type: "string",
describe: "regexp for any field that should be a date (requires kotlinx.datetime, use 'standard' for sensible default')",
})
.option("dedupeTaggedUnions", {

@@ -93,3 +87,2 @@ alias: "t",

function transpile(args) {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -103,11 +96,2 @@ console.log(`Transpile: `, args);

const rootDir = path.resolve(isDir ? args.path : path.dirname(args.path));
let dates;
if ((_a = args.datePattern) === null || _a === void 0 ? void 0 : _a.length) {
dates = {
framework: "kotlinx.datetime",
namePattern: args.datePattern === "standard"
? Patterns_1.StandardDatePattern
: RegExp(args.datePattern),
};
}
const { dedupeTaggedUnions, snakeToCamelCase, annotationNewLines, importStar, } = args;

@@ -119,3 +103,2 @@ const config = {

options: {
dates,
dedupeTaggedUnions,

@@ -122,0 +105,0 @@ snakeToCamelCase,

19

dist/martok/declarations/KlassGenerator.js

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

generateMemberOrCtorArg(node, options) {
var _a, _b, _c, _d, _e;
var _a;
const name = node.name.getText();

@@ -129,8 +129,13 @@ const annotations = [];

const doc = (0, typescript_1.getJSDocTags)(node);
const forceDateTime = type === "String" &&
doc.find((value) => value.tagName.text.toLowerCase() === "datetime");
if (forceDateTime ||
((_e = (_d = (_c = (_b = this.martok.config.options) === null || _b === void 0 ? void 0 : _b.dates) === null || _c === void 0 ? void 0 : _c.namePattern) === null || _d === void 0 ? void 0 : _d.exec(name)) === null || _e === void 0 ? void 0 : _e.length)) {
type = "kotlinx.datetime.Instant";
annotations.push("@Serializable(with = kotlinx.datetime.serializers.InstantIso8601Serializer::class)");
if (type === "String") {
const forceDateTime = doc.find((value) => value.tagName.text.toLowerCase() === "datetime");
const forceDate = doc.find((value) => value.tagName.text.toLowerCase() === "date");
if (forceDateTime) {
type = "kotlinx.datetime.Instant";
annotations.push("@Serializable(with = kotlinx.datetime.serializers.InstantIso8601Serializer::class)");
}
else if (forceDate) {
type = "kotlinx.datetime.LocalDate";
annotations.push("@Serializable(with = kotlinx.datetime.serializers.LocalDateIso8601Serializer::class)");
}
}

@@ -137,0 +142,0 @@ const nullable = (options === null || options === void 0 ? void 0 : options.optional) || !!node.questionToken;

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

const util = __importStar(require("util"));
const Patterns_1 = require("../typescript/Patterns");
const PACKAGE = "net.sarazan.martok";

@@ -105,6 +104,2 @@ const ROOT = path.resolve("./tests/comparisons");

options: {
dates: {
framework: "kotlinx.datetime",
namePattern: Patterns_1.StandardDatePattern,
},
dedupeTaggedUnions: true,

@@ -111,0 +106,0 @@ snakeToCamelCase: true,

{
"name": "martok",
"version": "1.5.1",
"version": "1.6.0",
"description": "",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"test": "jest",
"special": "ts-node src/index.ts tests/comparisons/single/types.d.ts -i -a -s -t -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"special": "ts-node src/index.ts tests/comparisons/special/DateTime.d.ts -i -a -s -t -o ./schema/martok --package net.sarazan.martok --datePattern standard",
"lint": "eslint . --ext .ts"

@@ -15,0 +15,0 @@ },

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

import { MartokOptions } from "./martok/MartokOptions";
import { StandardDatePattern } from "./typescript/Patterns";

@@ -28,8 +27,2 @@ const args = yargs

})
.option("datePattern", {
alias: "d",
type: "string",
describe:
"regexp for any field that should be a date (requires kotlinx.datetime, use 'standard' for sensible default')",
})
.option("dedupeTaggedUnions", {

@@ -86,12 +79,2 @@ alias: "t",

const rootDir = path.resolve(isDir ? args.path : path.dirname(args.path));
let dates: MartokOptions["dates"] | undefined;
if (args.datePattern?.length) {
dates = {
framework: "kotlinx.datetime",
namePattern:
args.datePattern === "standard"
? StandardDatePattern
: RegExp(args.datePattern),
};
}
const {

@@ -108,3 +91,2 @@ dedupeTaggedUnions,

options: {
dates,
dedupeTaggedUnions,

@@ -111,0 +93,0 @@ snakeToCamelCase,

@@ -199,13 +199,20 @@ import { Martok } from "../Martok";

const doc = getJSDocTags(node);
const forceDateTime =
type === "String" &&
doc.find((value) => value.tagName.text.toLowerCase() === "datetime");
if (
forceDateTime ||
this.martok.config.options?.dates?.namePattern?.exec(name)?.length
) {
type = "kotlinx.datetime.Instant";
annotations.push(
"@Serializable(with = kotlinx.datetime.serializers.InstantIso8601Serializer::class)"
if (type === "String") {
const forceDateTime = doc.find(
(value) => value.tagName.text.toLowerCase() === "datetime"
);
const forceDate = doc.find(
(value) => value.tagName.text.toLowerCase() === "date"
);
if (forceDateTime) {
type = "kotlinx.datetime.Instant";
annotations.push(
"@Serializable(with = kotlinx.datetime.serializers.InstantIso8601Serializer::class)"
);
} else if (forceDate) {
type = "kotlinx.datetime.LocalDate";
annotations.push(
"@Serializable(with = kotlinx.datetime.serializers.LocalDateIso8601Serializer::class)"
);
}
}

@@ -212,0 +219,0 @@ const nullable = options?.optional || !!node.questionToken;

export type MartokOptions = {
dates?: {
framework: "kotlinx.datetime";
namePattern: RegExp;
};
dedupeTaggedUnions?: boolean;

@@ -7,0 +3,0 @@ snakeToCamelCase?: boolean;

@@ -9,3 +9,2 @@ import { glob } from "glob";

import * as util from "util";
import { StandardDatePattern } from "../typescript/Patterns";

@@ -84,6 +83,2 @@ const PACKAGE = "net.sarazan.martok";

options: {
dates: {
framework: "kotlinx.datetime",
namePattern: StandardDatePattern,
},
dedupeTaggedUnions: true,

@@ -90,0 +85,0 @@ snakeToCamelCase: true,

@@ -7,6 +7,8 @@ export type WithDates = {

utcDate1: string;
isoDate2: string;
fooDate: string;
/**
* @Date
*/
just_date: string;
justAString: 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