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

@autoplay/utils

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autoplay/utils - npm Package Compare versions

Comparing version 0.0.18 to 0.0.21

esm/index.d.ts

26

package.json
{
"name": "@autoplay/utils",
"version": "0.0.18",
"version": "0.0.21",
"description": "Utilities designed for error management, parsing, and TypeScript domain modeling.",
"keywords": [],
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"types": "esm/index.d.ts",
"exports": {
".": {
"import": {
"types": "./cjs/index.d.ts",
"default": "./cjs/index.js"
},
"require": {
"types": "./esm/index.d.ts",
"default": "./esm/index.js"
}
}
},
"scripts": {
"build": "tsc --build .",
"clean": "tsc --build . --clean && rimraf dist",
"build": "tsc --build . && tsc --build tsconfig.cjs.json",
"clean": "tsc --build . --clean && rimraf cjs esm",
"test": "jest",

@@ -17,3 +28,4 @@ "prepare": "npm run clean && npm run build",

"files": [
"dist/*",
"esm/*",
"cjs/*",
"src/*"

@@ -29,3 +41,3 @@ ],

"tslib": "^2.4",
"zod": "^3.17.3"
"zod": "^3"
},

@@ -32,0 +44,0 @@ "devDependencies": {

// Invariant errors with stack trace fixing
export * from "./internal/invariant";
export * from "./internal/DevError";
export * from "./internal/devStringify";
export * from "./internal/DevString";
export * from "./internal/match";
export * from "./internal/parseJSON";
export * from "./internal/createErrorObj";
export * from "./internal/staticCheck";
export * from "./internal/tightJsonStringify";
export * from "./internal/tightObjectDebug";
export * from "./internal/UsrString";
export * from "./internal/invariant.js";
export * from "./internal/DevError.js";
export * from "./internal/devStringify.js";
export * from "./internal/DevString.js";
export * from "./internal/match.js";
export * from "./internal/parseJSON.js";
export * from "./internal/createErrorObj.js";
export * from "./internal/staticCheck.js";
export * from "./internal/tightJsonStringify.js";
export * from "./internal/tightObjectDebug.js";
export * from "./internal/UsrString.js";
// functional pipe used for many sdk builders
export * from "./internal/pipe";
export * from "./internal/pipe.js";
// zod for runtime parsing for type validators (accepted and output cannot be different types)
// This also includes ZodChoice type
export * from "./internal/z/index";
export * from "./internal/z/index.js";

@@ -1,3 +0,3 @@

import type { DevString } from "./DevString";
import { dev } from "./DevString";
import type { DevString } from "./DevString.js";
import { dev } from "./DevString.js";

@@ -4,0 +4,0 @@ /**

@@ -1,3 +0,3 @@

import { DevError } from "./DevError";
import { devStringify } from "./devStringify";
import { DevError } from "./DevError.js";
import { devStringify } from "./devStringify.js";

@@ -59,3 +59,3 @@ /**

asError(): DevError {
const err = new DevError(this._templateDisplay());
const err = new DevError(this.toDisplay());
if (this._values) {

@@ -62,0 +62,0 @@ err.cause = this._values.cause

@@ -1,4 +0,5 @@

import { dev } from "./DevString";
import { devStringify } from "./devStringify";
import { describe, expect, it, jest } from "@jest/globals";
import { dev } from "./DevString.js";
import { devStringify } from "./devStringify.js";
import { tightJsonStringify } from "./tightJsonStringify.js";
import { describe, expect, it } from "@jest/globals";

@@ -22,8 +23,7 @@ describe("tightJsonStringify", () => {

expectStringWithPaths(devStringify(reason)).toMatchInlineSnapshot(`
"[ "Error resulting from ",
{ error: "TypeError: Unknown type\\"
\\"",
stack: "TypeError: Unknown type\\"
"Error resulting from { error: "TypeError: Unknown type\\"
\\"",
stack: "TypeError: Unknown type\\"
\\"
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:17:45)
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:18:47)
at Promise.then.completed (node_modules/jest-circus/build/utils.js:333:28)

@@ -37,27 +37,33 @@ at new Promise (<anonymous>)

at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:91:9)
at run (node_modules/jest-circus/build/run.js:31:3)" },
". This might have been caused by ",
"https://example.com/" ]"
at run (node_modules/jest-circus/build/run.js:31:3)" }. This might have been caused by "https://example.com/""
`);
expectStringWithPaths(devStringify(reason.causedA`failed to log in`)).toMatchInlineSnapshot(`
const input = dev`the user saw an error`.because(reason);
expectStringWithPaths(
tightJsonStringify(input, (key, err) => (err instanceof Error ? { error: err.message, stack: err.stack } : err)),
).toMatchInlineSnapshot(`
"[ "the user saw an error",
{ cause: [
{ "cause": [
"Error resulting from ",
{ error: "TypeError: Unknown type\\"
\\"",
stack: "TypeError: Unknown type\\"
\\"
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:17:45)
at Promise.then.completed (node_modules/jest-circus/build/utils.js:333:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (node_modules/jest-circus/build/utils.js:259:10)
at _callCircusTest (node_modules/jest-circus/build/run.js:277:40)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at _runTest (node_modules/jest-circus/build/run.js:209:3)
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:97:9)
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:91:9)
at run (node_modules/jest-circus/build/run.js:31:3)" },
{ "error": "Unknown type\\"\\n\\"",
"stack": "TypeError: Unknown type\\"\\n\\"\\n at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:18:47)\\n at Promise.then.completed (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/utils.js:333:28)\\n at new Promise (<anonymous>)\\n at callAsyncCircusFn (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/utils.js:259:10)\\n at _callCircusTest (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:277:40)\\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\\n at _runTest (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:209:3)\\n at _runTestsForDescribeBlock (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:97:9)\\n at _runTestsForDescribeBlock (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:91:9)\\n at run (/Users/cole/autoplay/artprompt-app/node_modules/.pnpm/jest-circus@28.1.3/node_modules/jest-circus/build/run.js:31:3)" },
". This might have been caused by ",
"https://example.com/" ] } ]"
`);
expectStringWithPaths(input.toDisplay()).toMatchInlineSnapshot(`
"the user saw an error
because: Error resulting from { error: "TypeError: Unknown type\\"
\\"",
stack: "TypeError: Unknown type\\"
\\"
at Object.<anonymous> (🙈/src/internal/devStringify.test.ts:18:47)
at Promise.then.completed (node_modules/jest-circus/build/utils.js:333:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (node_modules/jest-circus/build/utils.js:259:10)
at _callCircusTest (node_modules/jest-circus/build/run.js:277:40)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at _runTest (node_modules/jest-circus/build/run.js:209:3)
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:97:9)
at _runTestsForDescribeBlock (node_modules/jest-circus/build/run.js:91:9)
at run (node_modules/jest-circus/build/run.js:31:3)" }. This might have been caused by "https://example.com/""
`);
// expect(devStringify(dev1)).toMatchInlineSnapshot();

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

@@ -1,3 +0,3 @@

import { DevString } from "./DevString";
import { tightJsonStringify } from "./tightJsonStringify";
import { DevString } from "./DevString.js";
import { tightJsonStringify } from "./tightJsonStringify.js";

@@ -39,3 +39,3 @@ /**

});
return display ? cleanNewlinesAndStacks(json.replace(/\\?"([^"]+)\\?":/g, "$1:")) : json;
return display ? cleanNewlinesAndStacks(json.replace(/(\\?")([^"]+)\1:/g, "$2:")) : json;
}

@@ -54,6 +54,15 @@ } catch (err) {

// replace escaped newlines in strings
.replace(/(.+?)"(.*\\n(.(?!\\"))+|\\")*"/gm, (_fullMatch, beforeQuote, inside) => {
return beforeQuote + (inside ? `"${inside.split(/\\n/g).join("\n" + " ".repeat(beforeQuote.length))}"` : '""');
// .replace(/^(.+?)"(.*\\n(.(?!\\"))+|\\")*"$/gm, (_fullMatch, beforeQuote, inside) => {
.replace(/([^"]+?)"((?:\\.|[^\"])*)"/g, (_fullMatch, beforeQuote, inside: string | undefined) => {
return (
beforeQuote +
(inside
? `"${inside
.split(/\\n/g)
// .map((line) => line.replace(/\\"/g, '"'))
.join("\n" + " ".repeat(beforeQuote.length))}"`
: '""')
);
})
);
}

@@ -1,4 +0,4 @@

import { DevError } from "./DevError";
import type { DevString } from "./DevString";
import { devStringify } from "./devStringify";
import { DevError } from "./DevError.js";
import type { DevString } from "./DevString.js";
import { devStringify } from "./devStringify.js";

@@ -5,0 +5,0 @@ type AllowedMessageTypes = DevString | string | number | object;

@@ -72,3 +72,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

if (p === OTH) return found === empty ? (cb: (val: unknown) => unknown) => cb(value) : () => found;
if (found === empty && value && p in value) {
if (found === empty && value && p in (value as object)) {
const inner = (value as $IntentionalAny)[p];

@@ -75,0 +75,0 @@ return (cb: (inner: unknown) => unknown) => {

@@ -1,4 +0,4 @@

import type { DevString } from "./DevString";
import { dev } from "./DevString";
import type { ZodLikeParser } from "./ZodLikeParser";
import type { DevString } from "./DevString.js";
import { dev } from "./DevString.js";
import type { ZodLikeParser } from "./ZodLikeParser.js";

@@ -5,0 +5,0 @@ /**

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

import { tightJsonStringify } from "./tightJsonStringify";
import { tightJsonStringify } from "./tightJsonStringify.js";
import { describe, expect, it } from "@jest/globals";

@@ -3,0 +3,0 @@

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

import { tightJsonStringify } from "./tightJsonStringify";
import { tightJsonStringify } from "./tightJsonStringify.js";

@@ -3,0 +3,0 @@ export function tightObjectDebug(obj: any) {

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

import { z } from "./index";
import { z } from "./index.js";

@@ -3,0 +3,0 @@ export function errorToString(err: z.ZodError | any) {

@@ -1,5 +0,5 @@

export * as z from "./z";
export * as z from "./z.js";
// Extra invariant assertion
export * from "./invariantChoiceIs";
export * from "./invariantChoiceIs.js";
// Error stringification including Zod types
export * from "./errorToString";
export * from "./errorToString.js";

@@ -1,3 +0,3 @@

import type { z } from ".";
import { identity, invariantThrow } from "../invariant";
import type { z } from "./index.js";
import { identity, invariantThrow } from "../invariant.js";

@@ -4,0 +4,0 @@ /** Used with our (Autoplay) custom ZodChoice */

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

import { staticCheck } from "../staticCheck";
import { staticCheck } from "../staticCheck.js";
import * as z from "zod";

@@ -7,5 +7,5 @@

// Custom Zod types
export { ZodChoice, choiceType as choice } from "./zchoice";
export { ZodChoiceContainer, ZodChoiceVariantsToValue, ZodChoiceFactory, inferChoiceContainer } from "./zchoice";
export { optionType as option, ZodOption } from "./zoption";
export { ZodChoice, choiceType as choice } from "./zchoice.js";
export { ZodChoiceContainer, ZodChoiceVariantsToValue, ZodChoiceFactory, inferChoiceContainer } from "./zchoice.js";
export { optionType as option, ZodOption } from "./zoption.js";

@@ -12,0 +12,0 @@ export const obj: typeof z.object = z.object.bind(z);

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

import { choiceType, ZodChoice } from "./zchoice";
import { choiceType, ZodChoice } from "./zchoice.js";
import * as z from "zod";

@@ -3,0 +3,0 @@

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