@bitblit/ratchet-common 4.0.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/2d/line-2d.d.ts +5 -0
- package/lib/2d/plane-2d.d.ts +6 -0
- package/lib/2d/point-2d.d.ts +4 -0
- package/lib/2d/poly-line-2d.d.ts +4 -0
- package/lib/2d/ratchet-2d.d.ts +37 -0
- package/lib/2d/ratchet-2d.spec.d.ts +1 -0
- package/lib/build/build-information.d.ts +8 -0
- package/lib/build/ratchet-common-info.d.ts +5 -0
- package/lib/histogram/histogram-entry.d.ts +4 -0
- package/lib/histogram/histogram.d.ts +12 -0
- package/lib/histogram/histogram.spec.d.ts +1 -0
- package/lib/index.d.ts +73 -0
- package/lib/index.mjs +4 -0
- package/lib/index.mjs.map +1 -0
- package/lib/jwt/common-jwt-token.d.ts +6 -0
- package/lib/jwt/expired-jwt-handling.d.ts +5 -0
- package/lib/jwt/jwt-ratchet-like.d.ts +15 -0
- package/lib/jwt/jwt-ratchet.d.ts +30 -0
- package/lib/jwt/jwt-ratchet.spec.d.ts +1 -0
- package/lib/jwt/jwt-token-base.d.ts +9 -0
- package/lib/lang/array-ratchet.d.ts +14 -0
- package/lib/lang/array-ratchet.spec.d.ts +1 -0
- package/lib/lang/base64-ratchet.d.ts +10 -0
- package/lib/lang/base64-ratchet.spec.d.ts +1 -0
- package/lib/lang/boolean-ratchet.d.ts +7 -0
- package/lib/lang/boolean-ratchet.spec.d.ts +1 -0
- package/lib/lang/composite-last-success-provider.d.ts +7 -0
- package/lib/lang/composite-last-success-provider.spec.d.ts +1 -0
- package/lib/lang/date-ratchet.d.ts +11 -0
- package/lib/lang/date-ratchet.spec.d.ts +1 -0
- package/lib/lang/duration-ratchet.d.ts +7 -0
- package/lib/lang/duration-ratchet.spec.d.ts +1 -0
- package/lib/lang/enum-ratchet.d.ts +5 -0
- package/lib/lang/enum-ratchet.spec.d.ts +5 -0
- package/lib/lang/error-ratchet.d.ts +6 -0
- package/lib/lang/error-ratchet.spec.d.ts +1 -0
- package/lib/lang/esm-ratchet.d.ts +4 -0
- package/lib/lang/expiring-object.d.ts +20 -0
- package/lib/lang/expiring-object.spec.d.ts +1 -0
- package/lib/lang/geolocation-ratchet.d.ts +40 -0
- package/lib/lang/geolocation-ratchet.spec.d.ts +1 -0
- package/lib/lang/global-ratchet.d.ts +6 -0
- package/lib/lang/global-ratchet.spec.d.ts +1 -0
- package/lib/lang/key-value.d.ts +4 -0
- package/lib/lang/last-success-provider.d.ts +3 -0
- package/lib/lang/map-ratchet.d.ts +15 -0
- package/lib/lang/map-ratchet.spec.d.ts +1 -0
- package/lib/lang/no.d.ts +3 -0
- package/lib/lang/no.spec.d.ts +1 -0
- package/lib/lang/number-ratchet.d.ts +20 -0
- package/lib/lang/number-ratchet.spec.d.ts +1 -0
- package/lib/lang/parsed-url.d.ts +10 -0
- package/lib/lang/promise-ratchet.d.ts +18 -0
- package/lib/lang/promise-ratchet.spec.d.ts +1 -0
- package/lib/lang/require-ratchet.d.ts +11 -0
- package/lib/lang/require-ratchet.spec.d.ts +3 -0
- package/lib/lang/stop-watch.d.ts +17 -0
- package/lib/lang/string-ratchet.d.ts +28 -0
- package/lib/lang/string-ratchet.spec.d.ts +1 -0
- package/lib/lang/time-zone-ratchet.d.ts +19 -0
- package/lib/lang/time-zone-ratchet.spec.d.ts +1 -0
- package/lib/lang/timeout-token.d.ts +9 -0
- package/lib/lang/timeout-token.spec.d.ts +1 -0
- package/lib/lang/transform-ratchet.d.ts +7 -0
- package/lib/lang/transform-ratchet.spec.d.ts +1 -0
- package/lib/logger/classic-single-line-log-message-formatter.d.ts +6 -0
- package/lib/logger/log-message-builder.d.ts +14 -0
- package/lib/logger/log-message-format-type.d.ts +5 -0
- package/lib/logger/log-message-formatter.d.ts +5 -0
- package/lib/logger/log-message-processor.d.ts +5 -0
- package/lib/logger/log-message.d.ts +8 -0
- package/lib/logger/log-snapshot.d.ts +5 -0
- package/lib/logger/logger-instance.d.ts +46 -0
- package/lib/logger/logger-level-name.d.ts +8 -0
- package/lib/logger/logger-meta.d.ts +6 -0
- package/lib/logger/logger-options.d.ts +13 -0
- package/lib/logger/logger-output-function.d.ts +5 -0
- package/lib/logger/logger-ring-buffer.d.ts +18 -0
- package/lib/logger/logger-util.d.ts +8 -0
- package/lib/logger/logger-util.spec.d.ts +1 -0
- package/lib/logger/logger.d.ts +43 -0
- package/lib/logger/logger.spec.d.ts +1 -0
- package/lib/logger/none-log-message-formatter.d.ts +6 -0
- package/lib/logger/structured-json-log-message-formatter.d.ts +6 -0
- package/lib/network/browser-local-ip-provider.d.ts +7 -0
- package/lib/network/browser-local-ip-provider.spec.d.ts +1 -0
- package/lib/network/fixed-local-ip-provider.d.ts +6 -0
- package/lib/network/local-ip-provider.d.ts +3 -0
- package/lib/network/network-ratchet.d.ts +9 -0
- package/lib/network/network-ratchet.spec.d.ts +1 -0
- package/lib/stream/buffer-writable.d.ts +9 -0
- package/lib/stream/multi-stream.d.ts +7 -0
- package/lib/stream/stream-ratchet.d.ts +12 -0
- package/lib/stream/stream-ratchet.spec.d.ts +1 -0
- package/lib/stream/string-writable.d.ts +8 -0
- package/lib/stream/string-writable.spec.d.ts +1 -0
- package/lib/third-party/google/google-recaptcha-ratchet.d.ts +4 -0
- package/lib/third-party/google/google-recaptcha-ratchet.spec.d.ts +1 -0
- package/lib/third-party/twilio/twilio-ratchet.d.ts +11 -0
- package/lib/transform/built-in-transforms.d.ts +18 -0
- package/lib/transform/transform-rule.d.ts +3 -0
- package/lib/tx/transaction-configuration.d.ts +7 -0
- package/lib/tx/transaction-final-state.d.ts +5 -0
- package/lib/tx/transaction-ratchet.d.ts +6 -0
- package/lib/tx/transaction-ratchet.spec.d.ts +1 -0
- package/lib/tx/transaction-result.d.ts +9 -0
- package/lib/tx/transaction-step.d.ts +5 -0
- package/package.json +71 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LogMessageFormatType } from './log-message-format-type.js';
|
|
2
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
3
|
+
import { LogMessageProcessor } from './log-message-processor.js';
|
|
4
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
5
|
+
export interface LoggerOptions {
|
|
6
|
+
initialLevel?: LoggerLevelName;
|
|
7
|
+
formatType?: LogMessageFormatType;
|
|
8
|
+
trace?: string;
|
|
9
|
+
globalVars?: Record<string, string | number | boolean>;
|
|
10
|
+
outputFunction?: LoggerOutputFunction;
|
|
11
|
+
ringBufferSize?: number;
|
|
12
|
+
preProcessors?: LogMessageProcessor[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogSnapshot } from './log-snapshot.js';
|
|
3
|
+
export declare class LoggerRingBuffer {
|
|
4
|
+
private _lastLogMessage;
|
|
5
|
+
private _buffer;
|
|
6
|
+
private _bufferIdx;
|
|
7
|
+
private _lastSnapshotIdx;
|
|
8
|
+
private _bufferSize;
|
|
9
|
+
constructor(size: number);
|
|
10
|
+
get currentIndex(): number;
|
|
11
|
+
get lastSnapshotIdx(): number;
|
|
12
|
+
set bufferSize(newSize: number);
|
|
13
|
+
getMessages(inStartFrom?: number, clear?: boolean, reverseSort?: boolean): LogMessage[];
|
|
14
|
+
takeSnapshot(): LogSnapshot;
|
|
15
|
+
getLastLogMessage(): LogMessage;
|
|
16
|
+
private clearRingBuffer;
|
|
17
|
+
addToRingBuffer(newMsg: LogMessage): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
2
|
+
import { LoggerOutputFunction } from './logger-output-function.js';
|
|
3
|
+
export declare class LoggerUtil {
|
|
4
|
+
private static LOG_LEVELS_IN_ORDER;
|
|
5
|
+
static handlerFunctionMap(outputFn?: LoggerOutputFunction): Map<LoggerLevelName, (...any: any[]) => void>;
|
|
6
|
+
static defaultHandlerFunction(): (...any: any[]) => void;
|
|
7
|
+
static levelIsEnabled(targetLevel: LoggerLevelName, currentEnabled: LoggerLevelName): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogSnapshot } from './log-snapshot.js';
|
|
3
|
+
import { LoggerOptions } from './logger-options.js';
|
|
4
|
+
import { LoggerInstance } from './logger-instance.js';
|
|
5
|
+
import { LoggerLevelName } from './logger-level-name.js';
|
|
6
|
+
import { LoggerRingBuffer } from './logger-ring-buffer.js';
|
|
7
|
+
import { LogMessageBuilder } from './log-message-builder.js';
|
|
8
|
+
export declare class Logger {
|
|
9
|
+
private static LOGGER_INSTANCES;
|
|
10
|
+
private static DEFAULT_OPTIONS;
|
|
11
|
+
static applyDefaultsToOptions(input?: LoggerOptions): LoggerOptions;
|
|
12
|
+
static changeDefaultOptions(input: LoggerOptions, retroactive?: boolean): void;
|
|
13
|
+
static getLogger(loggerName?: string, inOptions?: LoggerOptions): LoggerInstance;
|
|
14
|
+
static recordMessageBuilder(msgBuild: LogMessageBuilder): string;
|
|
15
|
+
static recordMessage(msg: LogMessage): string;
|
|
16
|
+
static formatMessages(msgs: LogMessage[]): string[];
|
|
17
|
+
static updateTracePrefix(newValue: string): void;
|
|
18
|
+
static changeRingBufferSize(newValue: number): void;
|
|
19
|
+
static getRingBuffer(): LoggerRingBuffer;
|
|
20
|
+
static dumpConfigurationIntoLog(): void;
|
|
21
|
+
static dumpOptionsIntoLog(): void;
|
|
22
|
+
static getLevel(): LoggerLevelName;
|
|
23
|
+
static setLevel(newLevel: LoggerLevelName): void;
|
|
24
|
+
static getOptions(): LoggerOptions;
|
|
25
|
+
static getMessages(inStartFrom?: number, clear?: boolean, reverseSort?: boolean): LogMessage[];
|
|
26
|
+
static consoleLogPassThru(level: LoggerLevelName, ...input: any[]): void;
|
|
27
|
+
static error(format: string, ...input: any[]): string;
|
|
28
|
+
static errorP(...input: any[]): void;
|
|
29
|
+
static warn(format: string, ...input: any[]): string;
|
|
30
|
+
static warnP(...input: any[]): void;
|
|
31
|
+
static info(format: string, ...input: any[]): string;
|
|
32
|
+
static infoP(...input: any[]): void;
|
|
33
|
+
static verbose(format: string, ...input: any[]): string;
|
|
34
|
+
static verboseP(...input: any[]): void;
|
|
35
|
+
static debug(format: string, ...input: any[]): string;
|
|
36
|
+
static debugP(...input: any[]): void;
|
|
37
|
+
static silly(format: string, ...input: any[]): string;
|
|
38
|
+
static sillyP(...input: any[]): void;
|
|
39
|
+
static takeSnapshot(): LogSnapshot;
|
|
40
|
+
static logByLevel(level: LoggerLevelName, format: string, ...input: any[]): void;
|
|
41
|
+
static importMessages(msgs: LogMessage[], prefixIn?: string, addTimestamp?: boolean): void;
|
|
42
|
+
static getLastLogMessage(): LogMessage;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogMessageFormatter } from './log-message-formatter.js';
|
|
3
|
+
import { LoggerMeta } from './logger-meta.js';
|
|
4
|
+
export declare class NoneLogMessageFormatter implements LogMessageFormatter {
|
|
5
|
+
formatMessage(msg: LogMessage, meta: LoggerMeta): string;
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LogMessage } from './log-message.js';
|
|
2
|
+
import { LogMessageFormatter } from './log-message-formatter.js';
|
|
3
|
+
import { LoggerMeta } from './logger-meta.js';
|
|
4
|
+
export declare class StructuredJsonLogMessageFormatter implements LogMessageFormatter {
|
|
5
|
+
formatMessage(msg: LogMessage, meta: LoggerMeta): string;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ParsedUrl } from '../lang/parsed-url.js';
|
|
2
|
+
export declare class NetworkRatchet {
|
|
3
|
+
private static LOCAL_IP;
|
|
4
|
+
static findLocalIp(useCache?: boolean): Promise<string>;
|
|
5
|
+
static parseUrl(href: string): ParsedUrl;
|
|
6
|
+
private static updateLocalIP;
|
|
7
|
+
private static grepSDP;
|
|
8
|
+
private static updateAddressList;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Writable } from 'stream';
|
|
4
|
+
export declare class BufferWritable extends Writable {
|
|
5
|
+
private _val;
|
|
6
|
+
constructor();
|
|
7
|
+
_write(chunk: any, encoding: string, callback: any): void;
|
|
8
|
+
get value(): Buffer;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
export declare class StreamRatchet {
|
|
5
|
+
private constructor();
|
|
6
|
+
static readableToBufferSync(stream: Readable): Buffer;
|
|
7
|
+
static webReadableStreamToBuffer(stream: ReadableStream): Promise<Buffer>;
|
|
8
|
+
static webReadableStreamToString(stream: ReadableStream): Promise<string>;
|
|
9
|
+
static stringToReadable(input: string): Readable;
|
|
10
|
+
static stringToWebReadableStream(input: string): ReadableStream;
|
|
11
|
+
static anyToStringReadable(input: any): Readable;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class TwilioRatchet {
|
|
2
|
+
private accountSid;
|
|
3
|
+
private authToken;
|
|
4
|
+
private outBoundNumber;
|
|
5
|
+
static readonly TWILLIO_BASE_API_URL: string;
|
|
6
|
+
constructor(accountSid: string, authToken: string, outBoundNumber: string);
|
|
7
|
+
static sendMessageDirect(accountSid: string, authToken: string, outBoundNumber: string, recipientPhoneNumbers: string[], message: string): Promise<any[]>;
|
|
8
|
+
static generateTwilioBasicAuth(sid: string, authToken: string): string;
|
|
9
|
+
sendMessage(recipientPhoneNumbers: string[], message: string): Promise<any[]>;
|
|
10
|
+
static isValidE164Number(num: string): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransformRule } from './transform-rule.js';
|
|
2
|
+
export declare class BuiltInTransforms {
|
|
3
|
+
static keysOnly(rule: TransformRule): TransformRule;
|
|
4
|
+
static valuesOnly(rule: TransformRule): TransformRule;
|
|
5
|
+
static stringReplaceTransform(input: string, output: string): TransformRule;
|
|
6
|
+
static stripStringTransform(input: string): TransformRule;
|
|
7
|
+
static retainAll(input: string[]): TransformRule;
|
|
8
|
+
static removeAll(input: string[]): TransformRule;
|
|
9
|
+
static snakeToCamelCase(): TransformRule;
|
|
10
|
+
static stringToNumber(): TransformRule;
|
|
11
|
+
static camelToSnakeCase(): TransformRule;
|
|
12
|
+
static concatenateToNewField(newFieldName: string, oldFieldNamesInOrder: string[], abortIfFieldMissing?: boolean): TransformRule;
|
|
13
|
+
static numberToBool(fieldNames: string[]): TransformRule;
|
|
14
|
+
static boolToNumber(fieldNames: string[]): TransformRule;
|
|
15
|
+
static makeDuplicateField(oldName: string, newName: string): TransformRule;
|
|
16
|
+
static addField(name: string, valueToAdd: string): TransformRule;
|
|
17
|
+
static reformatDateFields(fieldNames: string[], oldFormat: string, newFormat: string): TransformRule;
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TransactionResult } from './transaction-result.js';
|
|
2
|
+
import { LoggerLevelName } from '../logger/logger-level-name.js';
|
|
3
|
+
export interface TransactionConfiguration<T> {
|
|
4
|
+
stepLogLevel?: LoggerLevelName;
|
|
5
|
+
executeAfterRollback?(result: TransactionResult<T>): Promise<void>;
|
|
6
|
+
executeAfterRollbackFailure?(result: TransactionResult<T>): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TransactionStep } from './transaction-step.js';
|
|
2
|
+
import { TransactionResult } from './transaction-result.js';
|
|
3
|
+
import { TransactionConfiguration } from './transaction-configuration.js';
|
|
4
|
+
export declare class TransactionRatchet {
|
|
5
|
+
static execute<T>(steps: TransactionStep<T>[], initialContext: T, inConfiguration?: TransactionConfiguration<T>): Promise<TransactionResult<T>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bitblit/ratchet-common",
|
|
3
|
+
"version": "4.0.1-alpha",
|
|
4
|
+
"description": "Common tools for general use",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib/*",
|
|
8
|
+
"bin/*"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./lib/index.d.ts",
|
|
13
|
+
"import": "./lib/index.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"contributors": [
|
|
17
|
+
"Christopher Weiss <bitblit@gmail.com>",
|
|
18
|
+
"William Weiss <npm@codification.org>",
|
|
19
|
+
"Austin Grantham <agrantham@algidious.com>",
|
|
20
|
+
"Lucas Myers <veganbeef@protonmail.com>",
|
|
21
|
+
"Joel Flint <joel@stimulimedia.net>",
|
|
22
|
+
"Bilal Shahid <bshahid@adomni.com>"
|
|
23
|
+
],
|
|
24
|
+
"husky": {
|
|
25
|
+
"hooks": {
|
|
26
|
+
"pre-commit": "pretty-quick --staged"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"prettier": {
|
|
30
|
+
"printWidth": 140,
|
|
31
|
+
"singleQuote": true,
|
|
32
|
+
"arrowParens": "always"
|
|
33
|
+
},
|
|
34
|
+
"config": {},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"watch": "tsc-watch",
|
|
37
|
+
"clean": "shx rm -Rf lib",
|
|
38
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
39
|
+
"docs": "typedoc",
|
|
40
|
+
"lint": "eslint src/**/*.ts",
|
|
41
|
+
"lint-fix": "eslint --fix src/**/*.ts",
|
|
42
|
+
"generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts && sed -i 's/\\x27;/.js\\x27;/' src/index.ts",
|
|
43
|
+
"build": "yarn clean && yarn generate-barrels && rollup -c rollup.config.js",
|
|
44
|
+
"force-build": "tsc --build --force"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/bitblit/Ratchet"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"wrench",
|
|
52
|
+
"utility"
|
|
53
|
+
],
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/bitblit/Ratchet/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/bitblit/Ratchet#readme",
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=14.18"
|
|
60
|
+
},
|
|
61
|
+
"license": "Apache-2.0",
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"ts-enum-util": "4.0.2"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
},
|
|
67
|
+
"peerDependenciesMeta": {
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
}
|
|
71
|
+
}
|