@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.
Files changed (108) hide show
  1. package/lib/2d/line-2d.d.ts +5 -0
  2. package/lib/2d/plane-2d.d.ts +6 -0
  3. package/lib/2d/point-2d.d.ts +4 -0
  4. package/lib/2d/poly-line-2d.d.ts +4 -0
  5. package/lib/2d/ratchet-2d.d.ts +37 -0
  6. package/lib/2d/ratchet-2d.spec.d.ts +1 -0
  7. package/lib/build/build-information.d.ts +8 -0
  8. package/lib/build/ratchet-common-info.d.ts +5 -0
  9. package/lib/histogram/histogram-entry.d.ts +4 -0
  10. package/lib/histogram/histogram.d.ts +12 -0
  11. package/lib/histogram/histogram.spec.d.ts +1 -0
  12. package/lib/index.d.ts +73 -0
  13. package/lib/index.mjs +4 -0
  14. package/lib/index.mjs.map +1 -0
  15. package/lib/jwt/common-jwt-token.d.ts +6 -0
  16. package/lib/jwt/expired-jwt-handling.d.ts +5 -0
  17. package/lib/jwt/jwt-ratchet-like.d.ts +15 -0
  18. package/lib/jwt/jwt-ratchet.d.ts +30 -0
  19. package/lib/jwt/jwt-ratchet.spec.d.ts +1 -0
  20. package/lib/jwt/jwt-token-base.d.ts +9 -0
  21. package/lib/lang/array-ratchet.d.ts +14 -0
  22. package/lib/lang/array-ratchet.spec.d.ts +1 -0
  23. package/lib/lang/base64-ratchet.d.ts +10 -0
  24. package/lib/lang/base64-ratchet.spec.d.ts +1 -0
  25. package/lib/lang/boolean-ratchet.d.ts +7 -0
  26. package/lib/lang/boolean-ratchet.spec.d.ts +1 -0
  27. package/lib/lang/composite-last-success-provider.d.ts +7 -0
  28. package/lib/lang/composite-last-success-provider.spec.d.ts +1 -0
  29. package/lib/lang/date-ratchet.d.ts +11 -0
  30. package/lib/lang/date-ratchet.spec.d.ts +1 -0
  31. package/lib/lang/duration-ratchet.d.ts +7 -0
  32. package/lib/lang/duration-ratchet.spec.d.ts +1 -0
  33. package/lib/lang/enum-ratchet.d.ts +5 -0
  34. package/lib/lang/enum-ratchet.spec.d.ts +5 -0
  35. package/lib/lang/error-ratchet.d.ts +6 -0
  36. package/lib/lang/error-ratchet.spec.d.ts +1 -0
  37. package/lib/lang/esm-ratchet.d.ts +4 -0
  38. package/lib/lang/expiring-object.d.ts +20 -0
  39. package/lib/lang/expiring-object.spec.d.ts +1 -0
  40. package/lib/lang/geolocation-ratchet.d.ts +40 -0
  41. package/lib/lang/geolocation-ratchet.spec.d.ts +1 -0
  42. package/lib/lang/global-ratchet.d.ts +6 -0
  43. package/lib/lang/global-ratchet.spec.d.ts +1 -0
  44. package/lib/lang/key-value.d.ts +4 -0
  45. package/lib/lang/last-success-provider.d.ts +3 -0
  46. package/lib/lang/map-ratchet.d.ts +15 -0
  47. package/lib/lang/map-ratchet.spec.d.ts +1 -0
  48. package/lib/lang/no.d.ts +3 -0
  49. package/lib/lang/no.spec.d.ts +1 -0
  50. package/lib/lang/number-ratchet.d.ts +20 -0
  51. package/lib/lang/number-ratchet.spec.d.ts +1 -0
  52. package/lib/lang/parsed-url.d.ts +10 -0
  53. package/lib/lang/promise-ratchet.d.ts +18 -0
  54. package/lib/lang/promise-ratchet.spec.d.ts +1 -0
  55. package/lib/lang/require-ratchet.d.ts +11 -0
  56. package/lib/lang/require-ratchet.spec.d.ts +3 -0
  57. package/lib/lang/stop-watch.d.ts +17 -0
  58. package/lib/lang/string-ratchet.d.ts +28 -0
  59. package/lib/lang/string-ratchet.spec.d.ts +1 -0
  60. package/lib/lang/time-zone-ratchet.d.ts +19 -0
  61. package/lib/lang/time-zone-ratchet.spec.d.ts +1 -0
  62. package/lib/lang/timeout-token.d.ts +9 -0
  63. package/lib/lang/timeout-token.spec.d.ts +1 -0
  64. package/lib/lang/transform-ratchet.d.ts +7 -0
  65. package/lib/lang/transform-ratchet.spec.d.ts +1 -0
  66. package/lib/logger/classic-single-line-log-message-formatter.d.ts +6 -0
  67. package/lib/logger/log-message-builder.d.ts +14 -0
  68. package/lib/logger/log-message-format-type.d.ts +5 -0
  69. package/lib/logger/log-message-formatter.d.ts +5 -0
  70. package/lib/logger/log-message-processor.d.ts +5 -0
  71. package/lib/logger/log-message.d.ts +8 -0
  72. package/lib/logger/log-snapshot.d.ts +5 -0
  73. package/lib/logger/logger-instance.d.ts +46 -0
  74. package/lib/logger/logger-level-name.d.ts +8 -0
  75. package/lib/logger/logger-meta.d.ts +6 -0
  76. package/lib/logger/logger-options.d.ts +13 -0
  77. package/lib/logger/logger-output-function.d.ts +5 -0
  78. package/lib/logger/logger-ring-buffer.d.ts +18 -0
  79. package/lib/logger/logger-util.d.ts +8 -0
  80. package/lib/logger/logger-util.spec.d.ts +1 -0
  81. package/lib/logger/logger.d.ts +43 -0
  82. package/lib/logger/logger.spec.d.ts +1 -0
  83. package/lib/logger/none-log-message-formatter.d.ts +6 -0
  84. package/lib/logger/structured-json-log-message-formatter.d.ts +6 -0
  85. package/lib/network/browser-local-ip-provider.d.ts +7 -0
  86. package/lib/network/browser-local-ip-provider.spec.d.ts +1 -0
  87. package/lib/network/fixed-local-ip-provider.d.ts +6 -0
  88. package/lib/network/local-ip-provider.d.ts +3 -0
  89. package/lib/network/network-ratchet.d.ts +9 -0
  90. package/lib/network/network-ratchet.spec.d.ts +1 -0
  91. package/lib/stream/buffer-writable.d.ts +9 -0
  92. package/lib/stream/multi-stream.d.ts +7 -0
  93. package/lib/stream/stream-ratchet.d.ts +12 -0
  94. package/lib/stream/stream-ratchet.spec.d.ts +1 -0
  95. package/lib/stream/string-writable.d.ts +8 -0
  96. package/lib/stream/string-writable.spec.d.ts +1 -0
  97. package/lib/third-party/google/google-recaptcha-ratchet.d.ts +4 -0
  98. package/lib/third-party/google/google-recaptcha-ratchet.spec.d.ts +1 -0
  99. package/lib/third-party/twilio/twilio-ratchet.d.ts +11 -0
  100. package/lib/transform/built-in-transforms.d.ts +18 -0
  101. package/lib/transform/transform-rule.d.ts +3 -0
  102. package/lib/tx/transaction-configuration.d.ts +7 -0
  103. package/lib/tx/transaction-final-state.d.ts +5 -0
  104. package/lib/tx/transaction-ratchet.d.ts +6 -0
  105. package/lib/tx/transaction-ratchet.spec.d.ts +1 -0
  106. package/lib/tx/transaction-result.d.ts +9 -0
  107. package/lib/tx/transaction-step.d.ts +5 -0
  108. 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,5 @@
1
+ export declare enum LoggerOutputFunction {
2
+ Console = "Console",
3
+ ConsoleNoDebug = "ConsoleNoDebug",
4
+ StdOut = "StdOut"
5
+ }
@@ -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,7 @@
1
+ import { LocalIpProvider } from './local-ip-provider.js';
2
+ export declare class BrowserLocalIpProvider implements LocalIpProvider {
3
+ private currentIp;
4
+ constructor();
5
+ ready(): boolean;
6
+ currentLocalIpAddress(): string;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { LocalIpProvider } from './local-ip-provider.js';
2
+ export declare class FixedLocalIpProvider implements LocalIpProvider {
3
+ private fixed;
4
+ constructor(fixed: string);
5
+ currentLocalIpAddress(): string;
6
+ }
@@ -0,0 +1,3 @@
1
+ export interface LocalIpProvider {
2
+ currentLocalIpAddress(): string;
3
+ }
@@ -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,7 @@
1
+ /// <reference types="node" />
2
+ import { Readable, ReadableOptions } from 'stream';
3
+ export declare class MultiStream extends Readable {
4
+ _object: any;
5
+ constructor(object: any, options?: ReadableOptions);
6
+ _read(): void;
7
+ }
@@ -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,8 @@
1
+ /// <reference types="node" />
2
+ import { Writable } from 'stream';
3
+ export declare class StringWritable extends Writable {
4
+ private _val;
5
+ constructor();
6
+ _write(chunk: any, encoding: string, callback: any): void;
7
+ get value(): string;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare class GoogleRecaptchaRatchet {
2
+ private static readonly GOOGLE_VERIFY_URL;
3
+ static verifyRecaptchaToken(keySecret: string, token: string, fetchFn?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>): Promise<boolean>;
4
+ }
@@ -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,3 @@
1
+ export interface TransformRule {
2
+ transform(value: any, isKey: boolean, context: any): any;
3
+ }
@@ -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,5 @@
1
+ export declare enum TransactionFinalState {
2
+ Success = "Success",
3
+ RolledBack = "RolledBack",
4
+ RollbackFailed = "RollbackFailed"
5
+ }
@@ -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 {};
@@ -0,0 +1,9 @@
1
+ import { TransactionFinalState } from './transaction-final-state.js';
2
+ export interface TransactionResult<T> {
3
+ finalContext: T;
4
+ finalState: TransactionFinalState;
5
+ error?: any;
6
+ rollbackError?: any;
7
+ errorStep?: number;
8
+ rollbackErrorStep?: number;
9
+ }
@@ -0,0 +1,5 @@
1
+ export interface TransactionStep<T> {
2
+ execute(context: T, stepNumber?: number): Promise<void>;
3
+ rollback?(context: T, stepNumber?: number): Promise<void>;
4
+ name?: string;
5
+ }
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
+ }