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

@userscripters/stackexchange-api-types

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@userscripters/stackexchange-api-types - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

generator/filters.ts

71

generator/factories.ts
import type {
EnumMember,
Expression,
Identifier,

@@ -93,1 +95,70 @@ KeywordTypeSyntaxKind,

};
export type EnumOptions = {
exported?: boolean;
constant?: boolean;
};
/**
* @summary creates a enum declaration
* @param f compiler factory to use
* @param name identifier of the enum
* @param expressions members of the enum
* @param options configuration
*/
export const createEnum = (
f: NodeFactory,
name: string | Identifier,
expressions: Map<string | Identifier, Expression>,
{ exported = false, constant = false }: EnumOptions = {}
) => {
const modifiers: Modifier[] = [];
if (exported) modifiers.push(f.createModifier(ts.SyntaxKind.ExportKeyword));
if (constant) modifiers.push(f.createModifier(ts.SyntaxKind.ConstKeyword));
const members: EnumMember[] = [];
expressions.forEach((expression, name) => {
members.push(f.createEnumMember(name, expression));
});
return f.createEnumDeclaration(
undefined,
modifiers,
typeof name === "string" ? f.createIdentifier(name) : name,
members
);
};
export type StringUnionOptions = {
exported?: boolean;
};
/**
* @summary creates a string union node
* @param f compiler factory to use
* @param name identifier of the enum
* @param members list of union members
*/
export const createStringUnion = (
f: NodeFactory,
name: string | Identifier,
members: string[],
{ exported = false }: StringUnionOptions = {}
) => {
const modifiers: Modifier[] = [];
if (exported) modifiers.push(f.createModifier(ts.SyntaxKind.ExportKeyword));
const union = f.createUnionTypeNode(
members.map((type) =>
f.createLiteralTypeNode(f.createStringLiteral(type))
)
);
return f.createTypeAliasDeclaration(
undefined,
modifiers,
typeof name === "string" ? f.createIdentifier(name) : name,
undefined,
union
);
};

@@ -5,2 +5,3 @@ import got from "got";

import { URL } from "url";
import { generateBuiltInFilters } from "./filters.js";
import { InterfaceOptions, parseInterface } from "./parsers.js";

@@ -136,2 +137,10 @@ import { printNodesToFile } from "./printer.js";

);
await generateBuiltInFilters(
factory,
DOCS_BASE,
"/docs/filters",
`${TYPES_PATH}/filters.d.ts`,
"Filters"
);
}

@@ -36,2 +36,13 @@ import got from "got";

/**
* @summary capitalizes the filter name, as well as trims, and removes leading and trailing dots
* @param name non-normalized type name (i.e. just parsed from docs)
*/
export const normalizeFilterName = (name: string) => {
return name
.trim()
.replace(/^[.]|[.]$/g, "")
.toLowerCase();
};
/**
* @summary fetches a JSDOM document from a URL

@@ -38,0 +49,0 @@ */

1

index.d.ts

@@ -9,4 +9,5 @@ import {Wrappers} from "./lib/wrapper";

export * from "./lib/filters";
export * from "./lib/types";
export * from "./lib/wrapper";
export as namespace StackExchangeAPI;

2

package.json
{
"name": "@userscripters/stackexchange-api-types",
"description": "Stack Exchange API types generator",
"version": "3.1.1",
"version": "3.2.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Oleg Valter",

@@ -9,3 +9,3 @@

| License | [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later) |
| Version | 3.1.1 |
| Version | 3.2.0 |

@@ -12,0 +12,0 @@ # Support

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