@orioro/util 0.13.0 → 0.13.1

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 (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/strExpr/syntheticJson.d.ts +1 -1
  3. package/package.json +9 -3
  4. package/dist/array/join.d.ts +0 -9
  5. package/dist/debug/debugFn.d.ts +0 -15
  6. package/dist/normalizeString/index.d.ts +0 -1
  7. package/dist/pathResolve/index.d.ts +0 -7
  8. package/dist/resolvePaths/index.d.ts +0 -4
  9. package/dist/strAutoCast/index.d.ts +0 -1
  10. package/dist/strAutoCast/strAutoCast.d.ts +0 -1
  11. package/dist/validate/async/index.d.ts +0 -18
  12. package/dist/validate/async/validateAsyncFn.d.ts +0 -2
  13. package/dist/validate/async/validators/index.d.ts +0 -2
  14. package/dist/validate/async/validators/logical.d.ts +0 -4
  15. package/dist/validate/async/validators/shape.d.ts +0 -7
  16. package/dist/validate/async/validators/tmpand.d.ts +0 -2
  17. package/dist/validate/async/validators/tmpor.d.ts +0 -2
  18. package/dist/validate/common/ValidationError.d.ts +0 -11
  19. package/dist/validate/common/util/defaultErrorMessage.d.ts +0 -2
  20. package/dist/validate/common/util/index.d.ts +0 -3
  21. package/dist/validate/common/util/parseValidatorInput.d.ts +0 -5
  22. package/dist/validate/common/util/resolveValidationResult.d.ts +0 -6
  23. package/dist/validate/common/validators/index.d.ts +0 -1
  24. package/dist/validate/common/validators/type.d.ts +0 -9
  25. package/dist/validate/index.d.ts +0 -3
  26. package/dist/validate/sync/index.d.ts +0 -18
  27. package/dist/validate/sync/validateSyncFn.d.ts +0 -2
  28. package/dist/validate/sync/validators/index.d.ts +0 -2
  29. package/dist/validate/sync/validators/logical.d.ts +0 -4
  30. package/dist/validate/sync/validators/shape.d.ts +0 -7
  31. package/dist/validate/types/async.d.ts +0 -5
  32. package/dist/validate/types/common.d.ts +0 -27
  33. package/dist/validate/types/index.d.ts +0 -3
  34. package/dist/validate/types/sync.d.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @orioro/util
2
2
 
3
+ ## 0.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix exports to support import (mjs) and require (js)
8
+
3
9
  ## 0.13.0
4
10
 
5
11
  ### Minor Changes
@@ -1 +1 @@
1
- export declare function syntheticJson(str: string, maxLength?: number): unknown;
1
+ export declare function syntheticJson<T = unknown>(str: string, maxLength?: number): T;
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "@orioro/util",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "packageManager": "yarn@4.0.2",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
- ".": "./dist/index.mjs",
10
- "./*": "./dist/*"
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "./*": {
14
+ "import": "./dist/*.mjs",
15
+ "require": "./dist/*.js"
16
+ }
11
17
  },
12
18
  "files": [
13
19
  "dist"
@@ -1,9 +0,0 @@
1
- type Entry = Record<string, any>;
2
- type Dataset = Entry[];
3
- type OnKey = string;
4
- type DatasetInput = Dataset | [OnKey, Dataset, string?];
5
- export declare function join(datasets: DatasetInput[], { key: defaultOnKey, mode, }?: {
6
- key?: string;
7
- mode?: 'left' | 'inner';
8
- }): Entry[];
9
- export {};
@@ -1,15 +0,0 @@
1
- import { Merge } from 'type-fest';
2
- type AnyFn = (...args: any[]) => any;
3
- export type FnCallLog<FnType extends AnyFn = AnyFn> = {
4
- type: 'call';
5
- callId: string;
6
- fnName: string;
7
- args: Parameters<FnType>;
8
- };
9
- export type FnResultLog<FnType extends AnyFn = AnyFn> = Merge<FnCallLog<FnType>, {
10
- type: 'result';
11
- result: ReturnType<FnType>;
12
- }>;
13
- export type FnDebugLog<FnType extends AnyFn = AnyFn> = FnCallLog<FnType> | FnResultLog<FnType>;
14
- export declare function debugFn<FnType extends AnyFn = AnyFn>(fnName: string, fn: FnType, logCall?: (log: FnCallLog<FnType>) => void, logResult?: (log: FnResultLog<FnType>) => void): (...args: Parameters<FnType>) => ReturnType<FnType>;
15
- export {};
@@ -1 +0,0 @@
1
- export declare function normalizeString(str: string): string;
@@ -1,7 +0,0 @@
1
- type PathSpec = {
2
- path: string;
3
- defaultValue?: any;
4
- };
5
- type PathSpecInput = PathSpec | PathSpec['path'];
6
- export declare function pathResolve(obj: any, pathSpecInput: PathSpecInput): any;
7
- export {};
@@ -1,4 +0,0 @@
1
- type Resolver = string | ((sourceObj: Record<string, any>) => any);
2
- type PathSpec = string | [string, Resolver];
3
- export declare function resolvePaths(sourceObj: Record<string, any>, paths: PathSpec[]): Record<string, any>;
4
- export {};
@@ -1 +0,0 @@
1
- export * from './strAutoCast';
@@ -1 +0,0 @@
1
- export declare function strAutoCast(str: string): string | boolean | number | JSON | null | undefined;
@@ -1,18 +0,0 @@
1
- import * as common from '../common/validators';
2
- import * as asyncValidators from './validators';
3
- import { DetailedInvalid, AsyncValidatorSystem, Valid } from '../types';
4
- declare function assertValidAsync<InputT = any>(validator: AsyncValidatorSystem['ValidatorInput'], input: InputT): Promise<InputT>;
5
- interface ValidateAsync {
6
- (validatorInput: AsyncValidatorSystem['ValidatorInput'], input: any): Promise<Valid | DetailedInvalid>;
7
- type: typeof common.typeValidator;
8
- obj: typeof asyncValidators.obj;
9
- objOf: typeof asyncValidators.objOf;
10
- tuple: typeof asyncValidators.tuple;
11
- arrayOf: typeof asyncValidators.arrayOf;
12
- and: typeof asyncValidators.and;
13
- or: typeof asyncValidators.or;
14
- not: typeof asyncValidators.not;
15
- assertValid: typeof assertValidAsync;
16
- }
17
- export declare const validateAsync: ValidateAsync;
18
- export {};
@@ -1,2 +0,0 @@
1
- import { DetailedInvalid, Valid, AsyncValidatorSystem } from '../types';
2
- export declare function validateAsyncFn(validatorInput: AsyncValidatorSystem['ValidatorInput'], input: any): Promise<Valid | DetailedInvalid>;
@@ -1,2 +0,0 @@
1
- export * from './shape';
2
- export * from './logical';
@@ -1,4 +0,0 @@
1
- import { AsyncValidatorSystem } from '../../types';
2
- export declare function and(validators: AsyncValidatorSystem['ValidatorInput'][]): AsyncValidatorSystem['ValidatorFn'];
3
- export declare function or(validators: AsyncValidatorSystem['ValidatorInput'][]): AsyncValidatorSystem['ValidatorFn'];
4
- export declare function not(validator: AsyncValidatorSystem['ValidatorInput']): AsyncValidatorSystem['ValidatorFn'];
@@ -1,7 +0,0 @@
1
- import { AsyncValidatorSystem } from '../../types';
2
- export declare function obj(objShape: {
3
- [key: string]: AsyncValidatorSystem['ValidatorInput'];
4
- }): AsyncValidatorSystem['ValidatorFn'];
5
- export declare function objOf(ofType: AsyncValidatorSystem['ValidatorInput']): AsyncValidatorSystem['ValidatorFn'];
6
- export declare function tuple(tupleShape: AsyncValidatorSystem['ValidatorInput'][]): AsyncValidatorSystem['ValidatorFn'];
7
- export declare function arrayOf(ofType: AsyncValidatorSystem['ValidatorInput']): AsyncValidatorSystem['ValidatorFn'];
@@ -1,2 +0,0 @@
1
- import { AsyncValidatorSystem } from '../../types';
2
- export declare function and(validators: AsyncValidatorSystem['ValidatorInput'][]): AsyncValidatorSystem['ValidatorFn'];
@@ -1,2 +0,0 @@
1
- import { AsyncValidatorSystem } from '../../types';
2
- export declare function or(validators: AsyncValidatorSystem['ValidatorInput'][]): AsyncValidatorSystem['ValidatorFn'];
@@ -1,11 +0,0 @@
1
- import { DetailedInvalid } from '../types';
2
- export declare class ValidationError extends Error {
3
- input: any;
4
- code?: string;
5
- error?: Error;
6
- path?: string;
7
- nestedErrors?: DetailedInvalid[];
8
- name: string;
9
- constructor({ message, ...details }: DetailedInvalid);
10
- toJSON(): DetailedInvalid;
11
- }
@@ -1,2 +0,0 @@
1
- import { DetailedInvalid } from '../../types';
2
- export declare function defaultErrorMessage({ input, message, nestedErrors, expectedTypes, }: DetailedInvalid): string;
@@ -1,3 +0,0 @@
1
- export * from './defaultErrorMessage';
2
- export * from './resolveValidationResult';
3
- export * from './parseValidatorInput';
@@ -1,5 +0,0 @@
1
- export declare function parseValidatorInput<ValidatorInputT, ValidatorFnT, ValidatorT>({ objValidator, }: {
2
- objValidator: (objShape: {
3
- [key: string]: ValidatorInputT;
4
- }) => ValidatorFnT;
5
- }, validatorInput: ValidatorInputT): ValidatorT;
@@ -1,6 +0,0 @@
1
- import { DetailedInvalid, Valid, ValidatorErrorMessageFn, ValidatorResult } from '../../types';
2
- export declare function resolveValidationResult({ input, result, errorMessage, }: {
3
- input: any;
4
- result: ValidatorResult;
5
- errorMessage: ValidatorErrorMessageFn;
6
- }): Valid | DetailedInvalid;
@@ -1 +0,0 @@
1
- export * from './type';
@@ -1,9 +0,0 @@
1
- import { TypeOfType } from '../../../typeOf';
2
- import { CommonValidatorFn } from '../../types';
3
- type ParsedExpectedType = {
4
- type: TypeOfType;
5
- required: boolean;
6
- };
7
- type ExpectedTypesInput = (string | ParsedExpectedType)[] | string | ParsedExpectedType;
8
- export declare function typeValidator(expectedTypesInput: ExpectedTypesInput): CommonValidatorFn;
9
- export {};
@@ -1,3 +0,0 @@
1
- export * from './sync';
2
- export * from './async';
3
- export * from './common/ValidationError';
@@ -1,18 +0,0 @@
1
- import * as common from '../common/validators';
2
- import * as sync from './validators';
3
- import { DetailedInvalid, SyncValidatorSystem, Valid } from '../types';
4
- declare function assertValidSync<InputT = any>(validator: SyncValidatorSystem['ValidatorInput'], input: InputT): InputT;
5
- interface Validate {
6
- (validatorInput: SyncValidatorSystem['ValidatorInput'], input: any): Valid | DetailedInvalid;
7
- type: typeof common.typeValidator;
8
- obj: typeof sync.obj;
9
- objOf: typeof sync.objOf;
10
- tuple: typeof sync.tuple;
11
- arrayOf: typeof sync.arrayOf;
12
- and: typeof sync.and;
13
- or: typeof sync.or;
14
- not: typeof sync.not;
15
- assertValid: typeof assertValidSync;
16
- }
17
- export declare const validate: Validate;
18
- export {};
@@ -1,2 +0,0 @@
1
- import { DetailedInvalid, Valid, SyncValidatorSystem } from '../types';
2
- export declare function validateSyncFn(validatorInput: SyncValidatorSystem['ValidatorInput'], input: any): Valid | DetailedInvalid;
@@ -1,2 +0,0 @@
1
- export * from './logical';
2
- export * from './shape';
@@ -1,4 +0,0 @@
1
- import { SyncValidatorSystem } from '../../types';
2
- export declare function and(validators: SyncValidatorSystem['ValidatorInput'][]): SyncValidatorSystem['ValidatorFn'];
3
- export declare function or(validators: SyncValidatorSystem['ValidatorInput'][]): SyncValidatorSystem['ValidatorFn'];
4
- export declare function not(validator: SyncValidatorSystem['ValidatorInput']): SyncValidatorSystem['ValidatorFn'];
@@ -1,7 +0,0 @@
1
- import { SyncValidatorSystem } from '../../types';
2
- export declare function obj(objShape: {
3
- [key: string]: SyncValidatorSystem['ValidatorInput'];
4
- }): SyncValidatorSystem['ValidatorFn'];
5
- export declare function objOf(ofType: SyncValidatorSystem['ValidatorInput']): SyncValidatorSystem['ValidatorFn'];
6
- export declare function tuple(tupleShape: SyncValidatorSystem['ValidatorInput'][]): SyncValidatorSystem['ValidatorFn'];
7
- export declare function arrayOf(ofType: SyncValidatorSystem['ValidatorInput']): SyncValidatorSystem['ValidatorFn'];
@@ -1,5 +0,0 @@
1
- import { DetailedInvalid, Valid, ValidatorResult, ValidatorSystem } from './common';
2
- export type AsyncValidatorSystem = ValidatorSystem<(input: any, context: {
3
- validateAsync: AsyncValidateFn;
4
- }) => ValidatorResult | Promise<ValidatorResult>>;
5
- export type AsyncValidateFn = (validatorInput: AsyncValidatorSystem['ValidatorInput'], input: any) => Promise<Valid | DetailedInvalid>;
@@ -1,27 +0,0 @@
1
- export type Valid = true;
2
- export type SimpleInvalid = false | undefined | null;
3
- export type ErrorMessageInvalid = string;
4
- export type ErrorInvalid = Error;
5
- export type DetailedInvalid = {
6
- input: any;
7
- message?: string;
8
- code?: string;
9
- error?: Error;
10
- path?: string;
11
- nestedErrors?: DetailedInvalid[];
12
- expectedTypes?: string;
13
- };
14
- export type ValidatorResult = Valid | SimpleInvalid | ErrorMessageInvalid | ErrorInvalid | DetailedInvalid;
15
- export type ValidatorErrorMessageFn = (props: DetailedInvalid) => string;
16
- export type ValidatorErrorMessageInput = string | ValidatorErrorMessageFn;
17
- export type CommonValidatorFn = (input: any) => ValidatorResult;
18
- type _ValidatorFnInput<ValidatorFn> = string | {
19
- [key: string]: _ValidatorFnInput<ValidatorFn> | [_ValidatorFnInput<ValidatorFn>, ValidatorErrorMessageInput];
20
- } | ValidatorFn;
21
- export type ValidatorSystem<ValidatorFn> = {
22
- ValidatorFn: ValidatorFn;
23
- ValidatorFnInput: _ValidatorFnInput<ValidatorFn>;
24
- Validator: [ValidatorFn, ValidatorErrorMessageFn];
25
- ValidatorInput: _ValidatorFnInput<ValidatorFn> | [_ValidatorFnInput<ValidatorFn>, ValidatorErrorMessageInput];
26
- };
27
- export {};
@@ -1,3 +0,0 @@
1
- export * from './common';
2
- export * from './sync';
3
- export * from './async';
@@ -1,5 +0,0 @@
1
- import { DetailedInvalid, Valid, ValidatorResult, ValidatorSystem } from './common';
2
- export type SyncValidatorSystem = ValidatorSystem<(input: any, context: {
3
- validateSync: SyncValidateFn;
4
- }) => ValidatorResult>;
5
- export type SyncValidateFn = (validatorInput: SyncValidatorSystem['ValidatorInput'], input: any) => Valid | DetailedInvalid;