Socket
Socket
Sign inDemoInstall

@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.2.4 to 3.3.0

generator/errors.ts

18

generator/factories.ts

@@ -171,3 +171,3 @@ import type {

export type StringUnionOptions = {
export type PrimitiveUnionOptions = {
exported?: boolean;

@@ -177,3 +177,3 @@ };

/**
* @summary creates a string union node
* @summary creates a union node with primitive members
* @param f compiler factory to use

@@ -183,7 +183,7 @@ * @param name identifier of the enum

*/
export const createStringUnion = (
export const createUnionOfPrimitives = (
f: NodeFactory,
name: string | Identifier,
members: string[],
{ exported = false }: StringUnionOptions = {}
members: (string | number | boolean | bigint)[],
{ exported = false }: PrimitiveUnionOptions = {}
) => {

@@ -193,5 +193,11 @@ const modifiers: Modifier[] = [];

const hs = new Map();
hs.set("string", (v: string) => f.createStringLiteral(v));
hs.set("number", (v: number) => f.createNumericLiteral(v));
hs.set("boolean", (v: boolean) => (v ? f.createTrue() : f.createFalse()));
hs.set("bigint", (v: ts.PseudoBigInt) => f.createBigIntLiteral(v));
const union = f.createUnionTypeNode(
members.map((type) =>
f.createLiteralTypeNode(f.createStringLiteral(type))
f.createLiteralTypeNode(hs.get(typeof type)(type))
)

@@ -198,0 +204,0 @@ );

@@ -6,3 +6,3 @@ import type { NodeFactory } from "typescript";

createNamespace,
createStringUnion,
createUnionOfPrimitives,
} from "./factories.js";

@@ -17,3 +17,3 @@ import { printNodesToFile } from "./printer.js";

) => {
const union = createStringUnion(factory, "BuiltIn", filters);
const union = createUnionOfPrimitives(factory, "BuiltIn", filters);
const ns = createNamespace(factory, namespaceName, [union]);

@@ -61,3 +61,3 @@ const commonNS = createNamespace(factory, "StackExchangeAPI", [ns]);

const union = createStringUnion(factory, "BuiltIn", filters, {
const union = createUnionOfPrimitives(factory, "BuiltIn", filters, {
exported: true,

@@ -64,0 +64,0 @@ });

import got from "got";
import { generateErrors } from "./errors.js";
import { generateBuiltInFilters } from "./filters.js";

@@ -50,2 +51,10 @@ import { generateTypes } from "./types.js";

await generateErrors(
factory,
DOCS_BASE,
"/docs/error-handling",
`${TYPES_PATH}/errors.d.ts`,
nsName
);
await generateTypes(factory, DOCS_BASE, `${TYPES_PATH}/types.d.ts`, nsName);

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

import "./lib/errors";
import "./lib/filters";

@@ -2,0 +3,0 @@ import "./lib/types";

{
"name": "@userscripters/stackexchange-api-types",
"description": "Stack Exchange API types generator",
"version": "3.2.4",
"version": "3.3.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.2.4 |
| Version | 3.3.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