Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace separation #751

Merged
merged 471 commits into from
Aug 8, 2023
Merged

Namespace separation #751

merged 471 commits into from
Aug 8, 2023

Conversation

samchon
Copy link
Owner

@samchon samchon commented Aug 8, 2023

Separated some functions under json and misc for protobuf.

When protobuf features come into typia, name of JSON related functions would be similar with protobuf. Also, when more features like cbor, messagePack and gql come, naming global functions of the root scope would be much different. typia is not a library for only runtime validation and JSON serialization more.

Therefore, decided to separate namespaces like below.

```typescript
// RUNTIME VALIDATORS
export function is<T>(input: unknown): input is T; // returns boolean
export function assert<T>(input: unknown): T; // throws TypeGuardError
export function validate<T>(input: unknown): IValidation<T>; // detailed
export const customValidators: CustomValidatorMap; // for customization

// JSON FUNCTIONS
export namespace json {
    export function application<T>(): IJsonApplication; // JSON schema
    export function assertParse<T>(input: string): T; // type safe parser
    export function assertStringify<T>(input: T): string; // safe and faster
}

// PROTOCOL BUFFER
export namespace protobuf {
    export function message<T>(): string; // Protocol Buffer message
    export function assertDecode<T>(buffer: Buffer): T; // safe decoder
    export function assertEncode<T>(input: T): Uint8Array; // safe encoder
}

// RANDOM GENERATOR
export function random<T>(g?: Partial<IRandomGenerator>): T;

samchon and others added 30 commits April 3, 2023 03:27
Benchmark stringify functions, especially vs `class-transformer`
Close #570 - support custom random generation
Close #575 - new function `literals()`
Fix #573 - exact import path generation
Prepare #574 - benchmark in each process
 Develop #578 - utilize `is()` in `assert()` and `validate()`
Complement #574 and #578 - new benchmark program
Fix #573 - unable to run setup on Macbook + `pnpm`
samchon and others added 23 commits June 29, 2023 14:29
…pt-tw-5.1.6

Update typescript requirement from ^5.1.5 to ^5.1.6
Add generation mode on playground website
`typia` could not validate recursive intersection type like below. Of course, below type is an extremely crazy case, but as goal of `typia` is to supporting every TypeScript types, I've fixed it.

```typescript
export type ISetupConfig =
  | ({
      type: 'Main';
    } & ISetupConfigMain)
  | ({
      type: 'Before';
    } & ISetupConfigBefore)
  | ({
      type: 'After';
    } & ISetupConfigAfter);

export type ISetupConfigMain = {
  content: ISetupConfig;
};

export type ISetupConfigBefore = {
  content: ISetupConfig;
};

export type ISetupConfigAfter = {
  content: ISetupConfig;
};
```
Fix #695 - support recursive intersection type
When repeated type comes recurrying both Array and Object types at the same time, comment tags could not be parsed.

Fixed such bug since 4.1.3 update.
Fix #704 - comment tags when repeated type comes
Fix #706 - support `exactOptionalPropertyTypes` option
In TypeScript, the word `package` was one of reserved keywords that could not declare as a variable. Have not known it for a long time \o/.
Add `package` word on reserved keywords.
Separated some functions under `json` and `misc` for `protobuf`.
@samchon samchon added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 8, 2023
@samchon samchon self-assigned this Aug 8, 2023
@samchon samchon merged commit e8a3053 into v5.0 Aug 8, 2023
2 checks passed
@samchon samchon deleted the features/namespace branch August 10, 2023 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants