{"id":24755167,"url":"https://github.com/gravity-ui/unipika","last_synced_at":"2026-03-06T05:49:46.470Z","repository":{"id":74832595,"uuid":"603157870","full_name":"gravity-ui/unipika","owner":"gravity-ui","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-20T16:05:51.000Z","size":1275,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-16T04:43:39.693Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gravity-ui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-17T18:32:53.000Z","updated_at":"2024-08-20T16:05:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"655698e7-b09e-4c27-83bc-8da19ad79620","html_url":"https://github.com/gravity-ui/unipika","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity-ui%2Funipika","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity-ui%2Funipika/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity-ui%2Funipika/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity-ui%2Funipika/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gravity-ui","download_url":"https://codeload.github.com/gravity-ui/unipika/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236017826,"owners_count":19081984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T12:36:41.676Z","updated_at":"2025-10-11T01:31:30.321Z","avatar_url":"https://github.com/gravity-ui.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unipika\n\nCommon YT/YQL/QC data formatting library.\n\n## format(data[, settings[, converter]])\n\nFunction accepts data in Unipika-YSON format (hereinafter referred to as the - Unipika), or, if converter is presented, in any other format and formats data according to its type. Currently two built-in converters are presented:\n\n- YSON to Unipikа\n- YQL to Unipika\n\n### List of supported types:\n\n| Source format | Types                                                                                                                            |\n| ------------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| YSON          | `string`, `number`, `int64`, `uint64`, `double`, `map`, `list`, `null`                                                           |\n| YQL           | `yql.string`, `yql.int64`, `yql.uint64`, `yql.double`, `yql.struct`, `yql.dict`, `yql.list`, `yql.tuple`, `yql.null`, `yql.yson`, `yql.pg.*` - PostgreSQL Data Types in YQL are being formatted as string |\n\nSimilar in meaning types are displayed similarly. For example, `int64` and `yql.int64`, `map` and `yql.struct`, etc.\n\nIt is assumed that types can't be mixed in arbitrary way, that is, for example, `list` can't have elements of type `yql.string`, nevertheless, library doesn't attempt to fix invalid data in this case. When using built-in converter this situation shouldn't happen. Also, for example, only YSON types can have attributes, for the rest of types special field `$attributes` is pointless.\n\n### Formatter settings:\n\n| Name                      | Type                       | Default value                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| ------------------------- | -------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| normalizeUrl              | `(url: string) =\u003e string`  | `(url) =\u003e new URL(url).toString()` | Optional pararmeter that allows to override default behavior of `utils.normalizeUrl`. Default implementation uses `encodeURI(url)` and returns empty string if the call throws an exception. The result of call `settings.normalizeUrl(url)` injects to DOM tree \"as is\" as value of `href`-attributes, so you have to sanitize returned value to prevent XSS.                                                                                                                   |\n| validateSrcUrl            | `(url: string) =\u003e boolean` | `() =\u003e false`                      | Function, which accepts source url for `TaggedType` types and returns whether it is allowed to be downloaded. If settings in not defined, `TaggedType` types (images, audio, video) will be formatted as `StructType`                                                                                                                                                                                                                                                            |\n| format                    | String                     | `'json'`                           | `[YSON-specific]` Affects displaying YSON types. Serialization to text `yson` or `json` is supported. These ways of representation are described in YT documentation.                                                                                                                                                                                                                                                                                                            |\n| decodeUTF8                | Boolean                    | `true`                             | `[YSON-Converter][YSON-specific]` Setting is passed to the converter (YSON to Unipikа). Indicated whether to try decode the data. The data received from YT with the setting { encode_utf8 = false } should not be decoded (also is means that all strings are valid UTF-8 sequences, that is, they are not binary). By default the data from YT is received with the setting { encode_utf8 = true } and should be decoded; strings that cannot be decoded are marked as binary. |\n| showDecoded               | Boolean                    | `true`                             | `[NCP][YSON-specific]` Indicates whether the decoded data should be displayed or the data in the form in which it is received from YT.                                                                                                                                                                                                                                                                                                                                           |\n| binaryAsHex               | Boolean                    | `true`                             | `[NCP][YSON-specific]` Indicates whether binary strings should be displayed as a sequence of HEX-digits.                                                                                                                                                                                                                                                                                                                                                                         |\n| asHTML                    | Boolean                    | `true`                             | Return serialized data in `plain text` or `html`.                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| break                     | Boolean                    | `true`                             | Put hyphens and indents or return everything as a single line.                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| indent                    | Number                     | `4`                                | Indent size.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| compact                   | Boolean                    | `false`                            | The mode in which complex types like `map`, `list`, `yql.struct` and so on, are displayed more compact if contain only one element.                                                                                                                                                                                                                                                                                                                                              |\n| highlightControlCharacter | Boolean                    | `false`                            | Enables highlighting of special control characters in html strings.                                                                                                                                                                                                                                                                                                                                                                                                              |\n| escapeWhitespace          | Boolean                    | `true`                             | `[NCP]`The mode in which hyphens and tab characters are not escaped. With this option it is convenient to view formatted data like stack-traces.                                                                                                                                                                                                                                                                                                                                 |\n| escapeYQLStrings          | Boolean                    | `true`                             | `[NCP][YQL-Converter]`The mode in which no symbols are escaped at all, so that user can get \"raw\" data.                                                                                                                                                                                                                                                                                                                                                                          |\n| nonBreakingIndent         | Boolean                    | `true`                             | The mode in which indents, spaces in key-value separator, and spaces in string binary representation are nonbreaking ( `\u0026nbsp;` symbol).                                                                                                                                                                                                                                                                                                                                         |\n| omitStructNull            | Boolean                    | `false`                            | `[YQL-Converter]` Indicates whether to skip keys with `null` value in `yql.struct` type.                                                                                                                                                                                                                                                                                                                                                                                         |\n| maxListSize               | Number                     | `undefined`                        | `[YQL-Converter]` Maximum allowed size of list nodes (`yql.list`, `yql.dict`, `yql.struct`, `yql.tuple`, `yql.stream`). If value \u003e 0 is set, node will be truncated to this value.                                                                                                                                                                                                                                                                                               |\n| maxStringSize             | Number                     | `undefined`                        | `[YQL-Converter]` Maximum allowed size of strings (`yql.string`, `yql.utf8`). If value \u003e 0 is set, string will be truncated to this value.                                                                                                                                                                                                                                                                                                                                       |\n| limitMapLength            | Number                     | `undefined`                        | Maximum allowed size of all map nodes. If value \u003e 0 is set, node will be truncated to this (value - 1).                                                                                                                                                                                                                                                                                                                                                                          |\n| limitListLength           | Number                     | `undefined`                        | Maximum allowed size of all list nodes. If value \u003e 0 is set, node will be truncated to this (value - 1).                                                                                                                                                                                                                                                                                                                                                                         |\n| treatValAsData           | Boolean                     | `false`                        | If `val` is among data fields, it may be treated two ways: as normal object key (if `treatValAsData` is not set or is set to `false`) or it's value will be set as overall $value (if `treatValAsData` is set to `true`). In most cases this setting should not be set.                                                                                                                                                                                                                                                                                                                                                                          |\n\n`[YQL-Converter]` - Options affects only data conversion from YQL format.\n`[YSON-Converter]` - Options affects only data conversion from YSON format.\n`[YSON-Specific]` - Options affects only YSON types representation and should not affect other types representation.\n`[NCP]` - (Non copy-pastable) this representation is used to improve readability, but is not valid; copying and using such data may cause an error.\n\n## formatFromYSON(data[, settings])\n\nFormat function wrapper, data is passed in YSON format, YSON to Unipika converter is used.\n\n## formatFromYQL(data[, settings])\n\nFormat function wrapper, data is passed in YQL format (in the list `[data, dataType]`), YQL to Unipika converter is used.\n\n## Features of Working with Dates:\n1) All dates are converted to the Gregorian calendar.\n2) According to the Gregorian calendar, the first year AD is denoted as: 01-01-01T00:00:00.000000Z.\nIf you subtract 1 microsecond from this date, you get the date -01-12-31T23:59:59.999999Z (the first year BC).\n3) To determine if a negative year is a leap year in the Gregorian calendar, first add 1 to the year, and then apply the usual leap year rules. Thus, the year -1 is a leap year (since -1 + 1 = 0, and 0 % 4 = 0, so it is a leap year).\n4) Year -1 came after year -2, but at the same time, -1-01-20 was before -01-01-21 (similarly, -1-01-01 was before -1-02-01). Thus, the minus sign applies only to the value of the year.\n5) There is no year zero in the Gregorian calendar, but this does not prevent us from considering year -1 as a leap year.\n6) It is important to understand that as input, the plugins yql-date, yql-datetime, and yql-timestamp receive time relative to the Unix epoch (1970-01-01T00:00:00.000000Z). Thus, the date 1-01-02 was 719161 days ago relative to the Unix epoch, but one day ahead of the beginning of the era (1-01-01).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravity-ui%2Funipika","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgravity-ui%2Funipika","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravity-ui%2Funipika/lists"}