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

@logto/shared

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logto/shared - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

lib/node/env/ConsoleLog.test.d.ts

4

lib/database/types.d.ts

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

import type { IdentifierSqlToken } from 'slonik';
export type SchemaValuePrimitive = string | number | boolean | undefined;

@@ -11,5 +10,2 @@ export type SchemaValue = SchemaValuePrimitive | Record<string, unknown> | unknown[] | null;

};
export type FieldIdentifiers<Key extends string> = {
[key in Key]: IdentifierSqlToken;
};
export type OrderDirection = 'asc' | 'desc';

@@ -16,0 +12,0 @@ export type UpdateWhereData<SetKey extends string, WhereKey extends string> = {

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

/**
* @fileoverview This file is used for jest only. This package does not need jest for testing.
*/
declare const proxy: ProxyConstructor;
export default proxy;

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

/**
* @fileoverview This file is used for jest only. This package does not need jest for testing.
*/
const { jest } = import.meta;

@@ -2,0 +5,0 @@ // For testing

export * from './universal.js';
export * from './node/index.js';
export * from './database/sql.js';
export * from './universal.js';
export * from './node/index.js';
export * from './database/sql.js';
export default class ConsoleLog {
/** A prefix to prepend to all log messages. */
readonly prefix?: string | undefined;
/**
* The number of spaces to pad the prefix. For example, if the prefix is `custom` and the
* padding is 8, the output will be `custom `.
*
* @default 8
*/
readonly padding: number;
static prefixes: Readonly<{

@@ -8,6 +17,13 @@ info: string;

}>;
plain: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
constructor(
/** A prefix to prepend to all log messages. */
prefix?: string | undefined,
/**
* The number of spaces to pad the prefix. For example, if the prefix is `custom` and the
* padding is 8, the output will be `custom `.
*
* @default 8
*/
padding?: number);
plain: typeof console.log;
info: typeof console.log;

@@ -18,2 +34,3 @@ succeed: typeof console.log;

fatal: (...args: Parameters<typeof console.log>) => never;
protected getArgs(args: Parameters<typeof console.log>): [message?: any, ...optionalParams: any[]];
}
import chalk from 'chalk';
export default class ConsoleLog {
constructor() {
this.plain = console.log;
static { this.prefixes = Object.freeze({
info: chalk.bold(chalk.blue('info')),
warn: chalk.bold(chalk.yellow('warn')),
error: chalk.bold(chalk.red('error')),
fatal: chalk.bold(chalk.red('fatal')),
}); }
constructor(
/** A prefix to prepend to all log messages. */
prefix,
/**
* The number of spaces to pad the prefix. For example, if the prefix is `custom` and the
* padding is 8, the output will be `custom `.
*
* @default 8
*/
padding = 8) {
this.prefix = prefix;
this.padding = padding;
this.plain = (...args) => {
console.log(...this.getArgs(args));
};
this.info = (...args) => {
console.log(ConsoleLog.prefixes.info, ...args);
this.plain(ConsoleLog.prefixes.info, ...args);
};

@@ -12,9 +31,9 @@ this.succeed = (...args) => {

this.warn = (...args) => {
console.warn(ConsoleLog.prefixes.warn, ...args);
console.warn(...this.getArgs([ConsoleLog.prefixes.warn, ...args]));
};
this.error = (...args) => {
console.error(ConsoleLog.prefixes.error, ...args);
console.error(...this.getArgs([ConsoleLog.prefixes.error, ...args]));
};
this.fatal = (...args) => {
console.error(ConsoleLog.prefixes.fatal, ...args);
console.error(...this.getArgs([ConsoleLog.prefixes.fatal, ...args]));
// eslint-disable-next-line unicorn/no-process-exit

@@ -24,8 +43,9 @@ process.exit(1);

}
static { this.prefixes = Object.freeze({
info: chalk.bold(chalk.blue('info')),
warn: chalk.bold(chalk.yellow('warn')),
error: chalk.bold(chalk.red('error')),
fatal: chalk.bold(chalk.red('fatal')),
}); }
getArgs(args) {
if (this.prefix) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return [this.prefix.padEnd(this.padding), ...args];
}
return args;
}
}

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

import { afterEach, describe, expect, it } from 'vitest';
import UrlSet from './UrlSet.js';

@@ -2,0 +3,0 @@ describe('UrlSet', () => {

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

import { describe, expect, it } from 'vitest';
import { generateStandardId, generateStandardSecret, generateStandardShortId } from './id.js';

@@ -2,0 +3,0 @@ describe('standard id generator', () => {

@@ -0,6 +1,8 @@

export * from './fetch.js';
export * from './id.js';
export * from './normalize-error.js';
export * from './object.js';
export * from './phone.js';
export * from './sub-domain.js';
export * from './ttl-cache.js';
export * from './id.js';
export * from './user-display-name.js';
export * from './phone.js';
export * from './sub-domain.js';

@@ -0,6 +1,8 @@

export * from './fetch.js';
export * from './id.js';
export * from './normalize-error.js';
export * from './object.js';
export * from './phone.js';
export * from './sub-domain.js';
export * from './ttl-cache.js';
export * from './id.js';
export * from './user-display-name.js';
export * from './phone.js';
export * from './sub-domain.js';

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

import { describe, expect, it } from 'vitest';
import { isValidSubdomain } from './sub-domain.js';

@@ -2,0 +3,0 @@ describe('isValidSubdomain()', () => {

@@ -0,16 +1,16 @@

import { afterEach, describe, expect, it, beforeEach, vi } from 'vitest';
import { TtlCache } from './ttl-cache.js';
const { jest } = import.meta;
describe('TtlCache', () => {
beforeEach(() => {
jest.useFakeTimers();
vi.useFakeTimers();
});
afterEach(() => {
jest.useRealTimers();
vi.useRealTimers();
});
it('should return cached value after a long time if ttl is not set', () => {
jest.setSystemTime(0);
vi.setSystemTime(0);
const cache = new TtlCache();
const someObject = Object.freeze({ foo: 'bar', baz: 123 });
cache.set('foo', someObject);
jest.setSystemTime(100_000_000);
vi.setSystemTime(100_000_000);
expect(cache.get('foo')).toBe(someObject);

@@ -20,3 +20,3 @@ expect(cache.has('foo')).toBe(true);

it('should return cached value and honor ttl', () => {
jest.setSystemTime(0);
vi.setSystemTime(0);
const cache = new TtlCache(100);

@@ -26,3 +26,3 @@ const someObject = Object.freeze({ foo: 'bar', baz: 123 });

cache.set('foo', someObject, 99);
jest.setSystemTime(100);
vi.setSystemTime(100);
expect(cache.get(123)).toBe(someObject);

@@ -34,3 +34,3 @@ expect(cache.has(123)).toBe(true);

expect(cache.has('foo')).toBe(false);
jest.setSystemTime(101);
vi.setSystemTime(101);
expect(cache.get(123)).toBe(undefined);

@@ -37,0 +37,0 @@ expect(cache.has(123)).toBe(false);

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

import { describe, expect, it } from 'vitest';
import { getUserDisplayName } from './user-display-name.js';

@@ -2,0 +3,0 @@ describe('getUserDisplayName', () => {

{
"name": "@logto/shared",
"version": "3.1.0",
"version": "3.1.1",
"main": "lib/index.js",

@@ -29,12 +29,12 @@ "author": "Silverhand Inc. <contact@silverhand.io>",

"devDependencies": {
"@logto/connector-kit": "^2.1.0",
"@silverhand/eslint-config": "5.0.0",
"@silverhand/ts-config": "5.0.0",
"@types/jest": "^29.4.0",
"@jest/globals": "^29.7.0",
"@silverhand/eslint-config": "6.0.1",
"@silverhand/ts-config": "6.0.0",
"@types/node": "^20.9.5",
"eslint": "^8.44.0",
"jest": "^29.7.0",
"@vitest/coverage-v8": "^1.4.0",
"eslint": "^8.56.0",
"lint-staged": "^15.0.0",
"prettier": "^3.0.0",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^1.4.0"
},

@@ -56,4 +56,3 @@ "engines": {

"libphonenumber-js": "^1.9.49",
"nanoid": "^5.0.1",
"slonik": "^30.0.0"
"nanoid": "^5.0.1"
},

@@ -63,10 +62,9 @@ "scripts": {

"build": "rm -rf lib/ && tsc -p tsconfig.build.json",
"build:test": "rm -rf lib/ && tsc -p tsconfig.test.json --sourcemap",
"build:test": "pnpm build",
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm test:only"
"test": "vitest src",
"test:ci": "pnpm run test --silent --coverage"
}
}
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