@antelopejs/interface-dms 0.17.4 → 0.17.5-next.1111.gaba637e
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/CHANGELOG.md +0 -37
- package/dist/auth/index.d.ts +0 -42
- package/dist/auth/index.js +0 -40
- package/dist/auth/index.js.map +1 -1
- package/dist/base/data-types/default/options.d.ts +0 -30
- package/dist/base/data-types/default-types.d.ts +0 -10
- package/dist/base/data-types/default-types.js +0 -5
- package/dist/base/data-types/default-types.js.map +1 -1
- package/dist/base/form-schema.d.ts +0 -32
- package/dist/base/form-schema.js +0 -9
- package/dist/base/form-schema.js.map +1 -1
- package/dist/base/internal/column-badges.d.ts +2 -3
- package/dist/base/internal/column-badges.js +3 -4
- package/dist/base/internal/column-badges.js.map +1 -1
- package/dist/base/layouts.d.ts +1 -1
- package/dist/base/layouts.js.map +1 -1
- package/dist/base/table-view/internal/option-contract.d.ts +3 -3
- package/dist/base/table-view/internal/option-displays.d.ts +0 -30
- package/dist/base/table-view/internal/option-expandable.d.ts +0 -12
- package/dist/base/table-view/internal/validation.d.ts +4 -22
- package/dist/base/table-view/internal/validation.js +8 -29
- package/dist/base/table-view/internal/validation.js.map +1 -1
- package/dist/base/table-view/options.d.ts +0 -1
- package/dist/base/table-view/schema.d.ts +0 -2
- package/dist/base/table-view/schema.js +0 -8
- package/dist/base/table-view/schema.js.map +1 -1
- package/dist/base/table-view.d.ts +1 -1
- package/dist/base/table-view.js.map +1 -1
- package/dist/component-options/data-type.js +3 -3
- package/dist/component-options/data-type.js.map +1 -1
- package/dist/component-options/page-layout.d.ts +1 -29
- package/dist/component-options/page-layout.js +2 -8
- package/dist/component-options/page-layout.js.map +1 -1
- package/dist/page/internal/layout-filter.js +1 -1
- package/dist/page/internal/layout-filter.js.map +1 -1
- package/dist/request-tenant.d.ts +1 -2
- package/dist/request-tenant.js +1 -2
- package/dist/request-tenant.js.map +1 -1
- package/docs/1.core/12.frontend-modules-and-request-helpers.md +1 -21
- package/docs/1.core/5.tenancy.md +1 -1
- package/docs/2.auth/1.introduction.md +1 -1
- package/docs/2.auth/2.authentication.md +0 -68
- package/docs/3.base/11.page-layouts.md +1 -18
- package/docs/3.base/4.tables.md +3 -3
- package/docs/3.base/8.data-types.md +0 -7
- package/docs/5.html-render/2.built-in-emails.md +0 -2
- package/package.json +2 -2
- package/dist/base/data-types/default/identifiers.d.ts +0 -62
- package/dist/base/data-types/default/identifiers.js +0 -183
- package/dist/base/data-types/default/identifiers.js.map +0 -1
- package/dist/base/data-types/internal/legal-identifiers.d.ts +0 -36
- package/dist/base/data-types/internal/legal-identifiers.js +0 -191
- package/dist/base/data-types/internal/legal-identifiers.js.map +0 -1
- package/dist/base/table-view/internal/group-order.d.ts +0 -26
- package/dist/base/table-view/internal/group-order.js +0 -50
- package/dist/base/table-view/internal/group-order.js.map +0 -1
- package/dist/base/table-view/internal/grouped-pinned.d.ts +0 -6
- package/dist/base/table-view/internal/grouped-pinned.js +0 -19
- package/dist/base/table-view/internal/grouped-pinned.js.map +0 -1
- package/dist/component-options/internal/data-type-registry.d.ts +0 -14
- package/dist/component-options/internal/data-type-registry.js +0 -19
- package/dist/component-options/internal/data-type-registry.js.map +0 -1
- package/dist/period-request.d.ts +0 -66
- package/dist/period-request.js +0 -149
- package/dist/period-request.js.map +0 -1
- package/docs/3.base/16.identifier-types.md +0 -27
package/docs/3.base/4.tables.md
CHANGED
|
@@ -247,7 +247,7 @@ Typing `TableViewOptions` by `InstanceType<T>` is what makes row-action rules fi
|
|
|
247
247
|
| `pagination` | `TableViewPaginationMode` | `"pages"` (default): a pager; `"loadMore"`: a "Load more" button; `"infinite"`: the next page loads as the footer scrolls into view. The last two ask for every page loaded so far, from the first row, so a refresh re-reads them. |
|
|
248
248
|
| `footer` | `TableViewFooterOptions` | `{ countLabel?, hint?, summary?, legend? }`: the footer's row count (`$` key pluralized on `{ count }`) and hint; `summary` figures (`TableViewFooterSummary`: `label`, `field?`, `op: "sum" \| "count"`, `where?` row rule, `format?` `TableViewSummaryFormat`) computed by the `Summary` route over every listed row; `legend`, a `SelectType` column. Serialized as `TableViewFooterSerialized`: each summary gets an `id`, its `where` stays server-side (`TableViewMeta.footerSummary(id)`). A sum without `field`, an unknown column or a legend that is no select column throws. |
|
|
249
249
|
| `emptyStates` | `TableViewEmptyStates` | `{ firstRun?, filtered?, error? }`, each a `TableViewEmptyState` (`title`, `description?`, `icon?`, `actions?: BlockLinkAction[]`, `component?`) the empty body of the grid and the `cards` display shows instead of the built-in words, its texts (keys and literals alike) receiving `{ search }`. A `component` receives `state`, `search`, `refresh()`, and `clearSearch()` / `clearFilters()` while there is a search or a filter chip to clear. |
|
|
250
|
-
| `expandable` | `TableViewExpandableOptions` | Expandable rows, a union: `{ fields, fieldsLabel? }` (column keys or `{ key, label
|
|
250
|
+
| `expandable` | `TableViewExpandableOptions` | Expandable rows, a union: `{ fields, fieldsLabel? }` (column keys or `{ key, label? }`, each rendered by its column's data type) **or** `{ component }` (receives `TableViewExpandedRowProps`: `row`, `rowId`, `columns`, `labelKey`, `actions`, `open` and `refresh`, and draws the whole band), plus `defaultExpanded` (`"none"` \| `"first"` \| `"all"`), `single` and `lazyLoad` (read the row from `get` when it opens). Fields must name declared columns; both or neither throws. Serialized as `TableViewExpandableSerialized`. |
|
|
251
251
|
| `rowIdKey` | `string` | Field holding the row id. Defaults to `DEFAULT_ROW_ID_FIELD`. |
|
|
252
252
|
| `labelKey` | `string` | Field naming a row: it follows the drawer or modal title ("Edit task · Write the docs") and ends the breadcrumb of the edit and details pages (set on their forms as `labelKey`). |
|
|
253
253
|
| `rowActions` | `TableViewRowActionOptions<T>` | Built-in and custom row actions. |
|
|
@@ -259,7 +259,7 @@ Typing `TableViewOptions` by `InstanceType<T>` is what makes row-action rules fi
|
|
|
259
259
|
| `archivedCountLabel` | `string` | How the footer counts the archived rows: an i18n key with `$` receiving `{ count }` and pluralized on it, or a text with `{count}`. Defaults to "Archived: {count}", which agrees with no noun. |
|
|
260
260
|
| `defaultFilters` | `Array<{ accessorKey: string; value?: string; mode: string }>` | Filters applied when the table opens. |
|
|
261
261
|
| `defaultSort` | `{ field: string; desc?: boolean }` | Sort applied when the viewer has no stored preference, and the one a cleared sort goes back to. |
|
|
262
|
-
| `pinnedRows` | `RowActionRule<T>` | Rows listed first whatever the sort, in the sort's order among themselves: within the list the route answers (a source without `paginate` answers every row, so its pinned rows open the first page; a paging route's open their page). The `grouped` display pins
|
|
262
|
+
| `pinnedRows` | `RowActionRule<T>` | Rows listed first whatever the sort, in the sort's order among themselves: within the list the route answers (a source without `paginate` answers every row, so its pinned rows open the first page; a paging route's open their page). The `grouped` display pins nothing; registration throws beside `reorder`. |
|
|
263
263
|
| `queryParamFilters` | `QueryParamFilters` | Maps URL query parameters onto hidden filters. |
|
|
264
264
|
| `routeParamFilters` | `RouteParamFilters` | Maps DMS route parameters onto hidden filters. |
|
|
265
265
|
| `strictRuleValidation` | `boolean` | Reject the whole request when any row fails rule validation, instead of processing only the eligible rows. |
|
|
@@ -269,7 +269,7 @@ Typing `TableViewOptions` by `InstanceType<T>` is what makes row-action rules fi
|
|
|
269
269
|
| `liveHold` | `TableViewLiveHoldOptions` | On a page declared with `live`, keeps the rows while the page is paused, and shows a "N new · Show" pill over the rows, which moves nothing, counting the rows its tab, search and filters match now beyond those it holds (asked of its count route), not the events; Show reads them once without leaving the pause. `whileOnScreen` is required: `true` also holds the rows in Direct while they are on screen or scrolled past (a new row at the top would push them down), `false` lets them follow the feed. `whileRowOpen?`, `whileScrolled?`, `whileSearching?` and `whileSorted?` (all default `false`) also hold the table alone, the page staying live, while a row is open in a row action's side panel or drawer, its first row is scrolled out of view, the user's search narrows the rows or they are sorted otherwise than by `defaultSort`; the strip then names the reason ("Table on hold · search active"). `missedLabel` words the strip's count, given `{count}` ("12 new requests"); while the page is paused the strip adds the page's `setMissedDetail` breakdown. A `TableView.fromSource` route receives `liveHeldAt` (ISO 8601) on every request made while held. Also offered by `TableView.fromSource`. |
|
|
270
270
|
| `reorder` | `TableViewReorderOptions` | `{ field }`: rows ordered by hand with a drag handle, on the grid and on the `cards` display. `field` must be a `@Sortable()`, writable `NumberType` column, and the edit action on: registration throws otherwise. The rows are listed sorted on it, and a move saves only the rows whose value changed. |
|
|
271
271
|
| `kanban` | `KanbanOptions` | Enable the kanban display. |
|
|
272
|
-
| `grouped` | `GroupedOptions` | `{ groupByField, by?: "value" \| "day" \| "week",
|
|
272
|
+
| `grouped` | `GroupedOptions` | `{ groupByField, by?: "value" \| "day" \| "week", collapsible?, count? }`: offer the `grouped` display, the grid's columns under a header row per group. `groupByField` must be a `@Sortable()` column, a `DateType` one to group by day or week. |
|
|
273
273
|
| `views` | `TableViewViewsOptions` | `{ items: TableViewView[], layout?: "tabs" \| "strip" \| "menu", defaultView?, userViews? }`. A `TableViewView` is a `TableViewViewState` (`filters`, `search`, `sort`, `columns: { visible?, hidden?, order? }`, `display`, `density`) with `id`, `label`, `icon`, `tone`, `dot`, `count`, `permission` (an action of the table by name, or an `Action`) and `permissionId` (an absolute permission id, which wins); a view the caller fails it for is left out when the layout is served. Filter values may hold `{{user.id}}`, `{{now}}` and `{{now±Nd}}`, resolved by the server. Serialized as `TableViewViewsSerialized` (no `permission` nor `permissionId`). |
|
|
274
274
|
| `card` | `TableViewCardOptions` | The card the `kanban` and `cards` displays draw: `fields` it shows, or a `component` drawing it whole; `minWidth` (a CSS length, `"230px"` by default) is the narrowest a card of the `cards` grid gets. |
|
|
275
275
|
| `displays` | `TableViewDisplayOption[]` | The displays offered, in order: a built-in id (`"table"`, `"cards"`) without a component, or a module display named `<module>:<id>`; registration throws otherwise. Left out, the built-in `table` alone; listed, exactly these, so the grid is kept by listing `{ id: "table" }`. |
|
|
@@ -253,10 +253,6 @@ The ordering modes and `is_between` send a date value to the value proxy as epoc
|
|
|
253
253
|
| `EmailType` | `email` | `contains`, `is`, `is_not`, `not_contains`, `is_empty`, `is_not_empty` | email |
|
|
254
254
|
| `UrlType` | `url` | `is`, `is_not`, `is_empty`, `is_not_empty` | text |
|
|
255
255
|
| `PhoneType` | `phone` | `contains`, `is`, `is_not`, `not_contains`, `is_empty`, `is_not_empty` | phone |
|
|
256
|
-
| `IbanType` | `iban` | `contains`, `is`, `is_not`, `not_contains`, `is_empty`, `is_not_empty` | identifier |
|
|
257
|
-
| `BicType` | `bic` | as `IbanType` | identifier |
|
|
258
|
-
| `VatNumberType` | `vat_number` | as `IbanType` | identifier |
|
|
259
|
-
| `CompanyNumberType` | `company_number` | as `IbanType` | identifier |
|
|
260
256
|
| `ColorType` | `color` | `is`, `is_not`, `is_empty`, `is_not_empty` | colour |
|
|
261
257
|
| `PasswordType` | `password` | none | password |
|
|
262
258
|
| `RichTextType` | `rich_text` | none | rich text |
|
|
@@ -282,8 +278,6 @@ The ordering modes and `is_between` send a date value to the value proxy as epoc
|
|
|
282
278
|
| `PhoneTypeOptions` | `placeholder?`, `requiredPrefix?`, `defaultCountry?`, `fallback?` |
|
|
283
279
|
| `StringTimeTypeOptions` | `placeholder?`, `min?`, `max?`, `fallback?` |
|
|
284
280
|
|
|
285
|
-
The options and the rules of `IbanType`, `BicType`, `VatNumberType` and `CompanyNumberType` are in [Identifier data types](/docs/interfaces/base/identifier-types).
|
|
286
|
-
|
|
287
281
|
Notes on the ones whose behaviour is not obvious from the options:
|
|
288
282
|
|
|
289
283
|
- `StringType` renders a textarea instead of a single-line input when `textarea` is set, and passes `rows` to it.
|
|
@@ -376,5 +370,4 @@ Both types enable the table view's native file handling: authorized saves promot
|
|
|
376
370
|
|
|
377
371
|
## Next steps
|
|
378
372
|
|
|
379
|
-
- [Identifier data types](/docs/interfaces/base/identifier-types): IBAN, BIC, VAT number and company number.
|
|
380
373
|
- [Helpers](/docs/interfaces/base/helpers): Search, export jobs, file references and the archive-mode defaults.
|
|
@@ -22,8 +22,6 @@ An account created through an invitation link starts validated, so it receives n
|
|
|
22
22
|
|
|
23
23
|
Each email, subject included, is written in the recipient's language, English or French. See [Language](#language).
|
|
24
24
|
|
|
25
|
-
Each email leaves with two alternatives: the rendered HTML and a plain-text reading of it. In the plain text, each block of the HTML is a paragraph and a link's address follows its label, so a mail client that shows no HTML still shows the code or the link. A template that replaces a built-in one gets its plain text the same way.
|
|
26
|
-
|
|
27
25
|
These names are taken. Give your own emails other names. To change what a built-in email looks like, see [Replacing a built-in email](#replacing-a-built-in-email).
|
|
28
26
|
|
|
29
27
|
## Props
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-dms",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.5-next.1111.gaba637e",
|
|
4
4
|
"description": "Public AntelopeJS interfaces of the DMS: pages, components, permissions, tenancy, auth, notifications and HTML rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"provenance": true,
|
|
132
132
|
"registry": "https://registry.npmjs.org/"
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "aba637e95a981ee2a810ae2ba7849bad68a0f813",
|
|
135
135
|
"scripts": {
|
|
136
136
|
"build": "rimraf dist && antelopejs-tsc",
|
|
137
137
|
"typecheck": "antelopejs-tsc --noEmit",
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/** Stable legal and bank identifier data types. @packageDocumentation */
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { FormComponents } from "../../form-schema";
|
|
4
|
-
import { DataType } from "../core";
|
|
5
|
-
import type { ValueProxyOrValue } from "@antelopejs/interface-database";
|
|
6
|
-
import { BicTypeOptions, CompanyNumberTypeOptions, IbanTypeOptions, VatNumberTypeOptions } from "./options";
|
|
7
|
-
type FilterArguments = Parameters<DataType["filter"]>;
|
|
8
|
-
/**
|
|
9
|
-
* The `iban` data type: an IBAN, checked against its check digits (ISO
|
|
10
|
-
* 13616, modulo 97) and stored without spaces in upper case
|
|
11
|
-
* (`BE68539007547034`).
|
|
12
|
-
*
|
|
13
|
-
* @docsApi
|
|
14
|
-
*/
|
|
15
|
-
export declare class IbanType extends DataType {
|
|
16
|
-
readonly options: IbanTypeOptions;
|
|
17
|
-
constructor(options?: IbanTypeOptions);
|
|
18
|
-
protected defaultInputComponent(): import("../../..").ComponentInfoSerialized<FormComponents.InputIdentifierOptions>;
|
|
19
|
-
filter(...args: FilterArguments): ValueProxyOrValue<boolean>;
|
|
20
|
-
getValidation(): z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The `bic` data type: a BIC of 8 or 11 characters (ISO 9362), stored
|
|
24
|
-
* without spaces in upper case.
|
|
25
|
-
*
|
|
26
|
-
* @docsApi
|
|
27
|
-
*/
|
|
28
|
-
export declare class BicType extends DataType {
|
|
29
|
-
readonly options: BicTypeOptions;
|
|
30
|
-
constructor(options?: BicTypeOptions);
|
|
31
|
-
protected defaultInputComponent(): import("../../..").ComponentInfoSerialized<FormComponents.InputIdentifierOptions>;
|
|
32
|
-
filter(...args: FilterArguments): ValueProxyOrValue<boolean>;
|
|
33
|
-
getValidation(): z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The `vat_number` data type: a VAT number of the EU, Northern Ireland or
|
|
37
|
-
* Great Britain, stored as VIES writes it (`BE0123456749`).
|
|
38
|
-
*
|
|
39
|
-
* @docsApi
|
|
40
|
-
*/
|
|
41
|
-
export declare class VatNumberType extends DataType {
|
|
42
|
-
readonly options: VatNumberTypeOptions;
|
|
43
|
-
constructor(options?: VatNumberTypeOptions);
|
|
44
|
-
protected defaultInputComponent(): import("../../..").ComponentInfoSerialized<FormComponents.InputIdentifierOptions>;
|
|
45
|
-
filter(...args: FilterArguments): ValueProxyOrValue<boolean>;
|
|
46
|
-
getValidation(): z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The `company_number` data type: the registration number of a company in
|
|
50
|
-
* its country's register, stored as digits only.
|
|
51
|
-
*
|
|
52
|
-
* @docsApi
|
|
53
|
-
*/
|
|
54
|
-
export declare class CompanyNumberType extends DataType {
|
|
55
|
-
readonly options: CompanyNumberTypeOptions;
|
|
56
|
-
/** @throws When `options.country` is not a country it reads. */
|
|
57
|
-
constructor(options: CompanyNumberTypeOptions);
|
|
58
|
-
protected defaultInputComponent(): import("../../..").ComponentInfoSerialized<FormComponents.InputIdentifierOptions>;
|
|
59
|
-
filter(...args: FilterArguments): ValueProxyOrValue<boolean>;
|
|
60
|
-
getValidation(): z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CompanyNumberType = exports.VatNumberType = exports.BicType = exports.IbanType = void 0;
|
|
13
|
-
/** Stable legal and bank identifier data types. @packageDocumentation */
|
|
14
|
-
const zod_1 = require("zod");
|
|
15
|
-
const form_schema_1 = require("../../form-schema");
|
|
16
|
-
const core_1 = require("../core");
|
|
17
|
-
const compare_types_1 = require("../compare-types");
|
|
18
|
-
const legal_identifiers_1 = require("../internal/legal-identifiers");
|
|
19
|
-
const IDENTIFIER_COMPARE_TYPES = [
|
|
20
|
-
compare_types_1.DefaultDataCompareTypes.Is,
|
|
21
|
-
compare_types_1.DefaultDataCompareTypes.IsNot,
|
|
22
|
-
compare_types_1.DefaultDataCompareTypes.Contains,
|
|
23
|
-
compare_types_1.DefaultDataCompareTypes.NotContains,
|
|
24
|
-
compare_types_1.DefaultDataCompareTypes.IsEmpty,
|
|
25
|
-
compare_types_1.DefaultDataCompareTypes.IsNotEmpty,
|
|
26
|
-
];
|
|
27
|
-
/**
|
|
28
|
-
* Filters an identifier column on the text `read` makes of the typed value,
|
|
29
|
-
* so `is` and `contains` find the stored compact identifier. `is` and
|
|
30
|
-
* `is_not` compare that text as text: a company number's digits are not a
|
|
31
|
-
* number.
|
|
32
|
-
*/
|
|
33
|
-
function filterIdentifier(type, read, [context, proxy, key, value, mode, row]) {
|
|
34
|
-
const text = (0, legal_identifiers_1.identifierFilterText)(String(value), read);
|
|
35
|
-
if (mode === "is")
|
|
36
|
-
return proxy.eq(text);
|
|
37
|
-
if (mode === "is_not")
|
|
38
|
-
return proxy.ne(text);
|
|
39
|
-
return core_1.DataType.prototype.filter.call(type, context, proxy, key, text, mode, row);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* A string schema that stores what `read` returns and refuses, with
|
|
43
|
-
* `message`, a value it cannot read.
|
|
44
|
-
*/
|
|
45
|
-
function identifierSchema(read, message) {
|
|
46
|
-
return zod_1.z.string().transform((value, context) => {
|
|
47
|
-
const canonical = read(value);
|
|
48
|
-
if (canonical !== undefined)
|
|
49
|
-
return canonical;
|
|
50
|
-
context.addIssue({ code: zod_1.z.ZodIssueCode.custom, message });
|
|
51
|
-
return zod_1.z.NEVER;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The `iban` data type: an IBAN, checked against its check digits (ISO
|
|
56
|
-
* 13616, modulo 97) and stored without spaces in upper case
|
|
57
|
-
* (`BE68539007547034`).
|
|
58
|
-
*
|
|
59
|
-
* @docsApi
|
|
60
|
-
*/
|
|
61
|
-
let IbanType = class IbanType extends core_1.DataType {
|
|
62
|
-
options;
|
|
63
|
-
constructor(options = {}) {
|
|
64
|
-
super(IDENTIFIER_COMPARE_TYPES, compare_types_1.DefaultDataCompareTypes.Contains, options);
|
|
65
|
-
this.options = options;
|
|
66
|
-
}
|
|
67
|
-
defaultInputComponent() {
|
|
68
|
-
return form_schema_1.FormComponents.InputIdentifier({
|
|
69
|
-
identifier: "iban",
|
|
70
|
-
placeholder: this.options.placeholder,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
filter(...args) {
|
|
74
|
-
return filterIdentifier(this, legal_identifiers_1.readIban, args);
|
|
75
|
-
}
|
|
76
|
-
getValidation() {
|
|
77
|
-
return identifierSchema(legal_identifiers_1.readIban, "$dms.field_errors.invalid_iban");
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
exports.IbanType = IbanType;
|
|
81
|
-
exports.IbanType = IbanType = __decorate([
|
|
82
|
-
(0, core_1.RegisterDataType)("iban"),
|
|
83
|
-
__metadata("design:paramtypes", [Object])
|
|
84
|
-
], IbanType);
|
|
85
|
-
/**
|
|
86
|
-
* The `bic` data type: a BIC of 8 or 11 characters (ISO 9362), stored
|
|
87
|
-
* without spaces in upper case.
|
|
88
|
-
*
|
|
89
|
-
* @docsApi
|
|
90
|
-
*/
|
|
91
|
-
let BicType = class BicType extends core_1.DataType {
|
|
92
|
-
options;
|
|
93
|
-
constructor(options = {}) {
|
|
94
|
-
super(IDENTIFIER_COMPARE_TYPES, compare_types_1.DefaultDataCompareTypes.Contains, options);
|
|
95
|
-
this.options = options;
|
|
96
|
-
}
|
|
97
|
-
defaultInputComponent() {
|
|
98
|
-
return form_schema_1.FormComponents.InputIdentifier({
|
|
99
|
-
identifier: "bic",
|
|
100
|
-
placeholder: this.options.placeholder,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
filter(...args) {
|
|
104
|
-
return filterIdentifier(this, legal_identifiers_1.readBic, args);
|
|
105
|
-
}
|
|
106
|
-
getValidation() {
|
|
107
|
-
return identifierSchema(legal_identifiers_1.readBic, "$dms.field_errors.invalid_bic");
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
exports.BicType = BicType;
|
|
111
|
-
exports.BicType = BicType = __decorate([
|
|
112
|
-
(0, core_1.RegisterDataType)("bic"),
|
|
113
|
-
__metadata("design:paramtypes", [Object])
|
|
114
|
-
], BicType);
|
|
115
|
-
/**
|
|
116
|
-
* The `vat_number` data type: a VAT number of the EU, Northern Ireland or
|
|
117
|
-
* Great Britain, stored as VIES writes it (`BE0123456749`).
|
|
118
|
-
*
|
|
119
|
-
* @docsApi
|
|
120
|
-
*/
|
|
121
|
-
let VatNumberType = class VatNumberType extends core_1.DataType {
|
|
122
|
-
options;
|
|
123
|
-
constructor(options = {}) {
|
|
124
|
-
super(IDENTIFIER_COMPARE_TYPES, compare_types_1.DefaultDataCompareTypes.Contains, options);
|
|
125
|
-
this.options = options;
|
|
126
|
-
}
|
|
127
|
-
defaultInputComponent() {
|
|
128
|
-
return form_schema_1.FormComponents.InputIdentifier({
|
|
129
|
-
identifier: "vat_number",
|
|
130
|
-
placeholder: this.options.placeholder,
|
|
131
|
-
defaultCountry: this.options.defaultCountry,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
filter(...args) {
|
|
135
|
-
return filterIdentifier(this, (value) => (0, legal_identifiers_1.readVatNumber)(value, this.options.defaultCountry), args);
|
|
136
|
-
}
|
|
137
|
-
getValidation() {
|
|
138
|
-
const { defaultCountry } = this.options;
|
|
139
|
-
return identifierSchema((value) => (0, legal_identifiers_1.readVatNumber)(value, defaultCountry), "$dms.field_errors.invalid_vat_number");
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
exports.VatNumberType = VatNumberType;
|
|
143
|
-
exports.VatNumberType = VatNumberType = __decorate([
|
|
144
|
-
(0, core_1.RegisterDataType)("vat_number"),
|
|
145
|
-
__metadata("design:paramtypes", [Object])
|
|
146
|
-
], VatNumberType);
|
|
147
|
-
/**
|
|
148
|
-
* The `company_number` data type: the registration number of a company in
|
|
149
|
-
* its country's register, stored as digits only.
|
|
150
|
-
*
|
|
151
|
-
* @docsApi
|
|
152
|
-
*/
|
|
153
|
-
let CompanyNumberType = class CompanyNumberType extends core_1.DataType {
|
|
154
|
-
options;
|
|
155
|
-
/** @throws When `options.country` is not a country it reads. */
|
|
156
|
-
constructor(options) {
|
|
157
|
-
if (!(0, legal_identifiers_1.isCompanyNumberCountry)(options?.country)) {
|
|
158
|
-
throw new Error(`CompanyNumberType reads a company number of "BE" or "FR", not ${JSON.stringify(options?.country)}`);
|
|
159
|
-
}
|
|
160
|
-
super(IDENTIFIER_COMPARE_TYPES, compare_types_1.DefaultDataCompareTypes.Contains, options);
|
|
161
|
-
this.options = options;
|
|
162
|
-
}
|
|
163
|
-
defaultInputComponent() {
|
|
164
|
-
return form_schema_1.FormComponents.InputIdentifier({
|
|
165
|
-
identifier: "company_number",
|
|
166
|
-
placeholder: this.options.placeholder,
|
|
167
|
-
country: this.options.country,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
filter(...args) {
|
|
171
|
-
return filterIdentifier(this, (value) => (0, legal_identifiers_1.readCompanyNumber)(value, this.options.country), args);
|
|
172
|
-
}
|
|
173
|
-
getValidation() {
|
|
174
|
-
const { country } = this.options;
|
|
175
|
-
return identifierSchema((value) => (0, legal_identifiers_1.readCompanyNumber)(value, country), "$dms.field_errors.invalid_company_number");
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
exports.CompanyNumberType = CompanyNumberType;
|
|
179
|
-
exports.CompanyNumberType = CompanyNumberType = __decorate([
|
|
180
|
-
(0, core_1.RegisterDataType)("company_number"),
|
|
181
|
-
__metadata("design:paramtypes", [Object])
|
|
182
|
-
], CompanyNumberType);
|
|
183
|
-
//# sourceMappingURL=identifiers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../../../../src/base/data-types/default/identifiers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAyE;AACzE,6BAAwB;AACxB,mDAAmD;AACnD,kCAAqD;AAErD,oDAA2D;AAO3D,qEAOuC;AAEvC,MAAM,wBAAwB,GAAG;IAC/B,uCAAuB,CAAC,EAAE;IAC1B,uCAAuB,CAAC,KAAK;IAC7B,uCAAuB,CAAC,QAAQ;IAChC,uCAAuB,CAAC,WAAW;IACnC,uCAAuB,CAAC,OAAO;IAC/B,uCAAuB,CAAC,UAAU;CACnC,CAAC;AAIF;;;;;GAKG;AACH,SAAS,gBAAgB,CACvB,IAAc,EACd,IAA2C,EAC3C,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAkB;IAExD,MAAM,IAAI,GAAG,IAAA,wCAAoB,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IACvD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,eAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CACnC,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,GAAG,CACJ,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CACvB,IAA2C,EAC3C,OAAe;IAEf,OAAO,OAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7C,MAAM,SAAS,GAA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default/options";
|
|
2
|
-
/**
|
|
3
|
-
* @internal What a filter of an identifier column looks for: the identifier
|
|
4
|
-
* `read` makes of the typed text, or else that text compacted, so a part of
|
|
5
|
-
* an identifier typed as printed (`BE68 5390`) finds the stored one.
|
|
6
|
-
*/
|
|
7
|
-
export declare function identifierFilterText(value: string, read: (value: string) => string | undefined): string;
|
|
8
|
-
/**
|
|
9
|
-
* @internal An IBAN without spaces (`BE68539007547034`), checked against its
|
|
10
|
-
* two check digits (ISO 13616, modulo 97); `undefined` when it is none.
|
|
11
|
-
*/
|
|
12
|
-
export declare function readIban(value: string): string | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* @internal A BIC of 8 or 11 characters (ISO 9362): party prefix, country,
|
|
15
|
-
* location and an optional branch; `undefined` when it is none.
|
|
16
|
-
*/
|
|
17
|
-
export declare function readBic(value: string): string | undefined;
|
|
18
|
-
/** @internal Whether `country` is one whose company number is read. */
|
|
19
|
-
export declare function isCompanyNumberCountry(country: unknown): country is CompanyNumberCountry;
|
|
20
|
-
/**
|
|
21
|
-
* @internal A company registration number of `country` as its register
|
|
22
|
-
* writes it, digits only: a Belgian enterprise number of ten digits (the
|
|
23
|
-
* nine of before 2005 get their leading zero), a French SIREN of nine.
|
|
24
|
-
* Typed with its country's code in front (`BE 0123.456.749`), it reads the
|
|
25
|
-
* same. `undefined` when it is none.
|
|
26
|
-
*/
|
|
27
|
-
export declare function readCompanyNumber(value: string, country: CompanyNumberCountry): string | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* @internal A VAT number as VIES writes it (`BE0123456749`): its country's
|
|
30
|
-
* code, then its number without spaces. The number must have its country's
|
|
31
|
-
* format; Belgium, Germany, France, Italy and Luxembourg also check its check
|
|
32
|
-
* digits. A number typed without its country's code reads in
|
|
33
|
-
* `defaultCountry`, and a Belgian one of nine digits gets its leading zero.
|
|
34
|
-
* `undefined` when it is none.
|
|
35
|
-
*/
|
|
36
|
-
export declare function readVatNumber(value: string, defaultCountry?: string): string | undefined;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.identifierFilterText = identifierFilterText;
|
|
4
|
-
exports.readIban = readIban;
|
|
5
|
-
exports.readBic = readBic;
|
|
6
|
-
exports.isCompanyNumberCountry = isCompanyNumberCountry;
|
|
7
|
-
exports.readCompanyNumber = readCompanyNumber;
|
|
8
|
-
exports.readVatNumber = readVatNumber;
|
|
9
|
-
/** What a person types, without its spaces, dots, dashes and slashes, in upper case. */
|
|
10
|
-
function compactIdentifier(value) {
|
|
11
|
-
return value.replace(/[\s.\-/]/g, "").toUpperCase();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @internal What a filter of an identifier column looks for: the identifier
|
|
15
|
-
* `read` makes of the typed text, or else that text compacted, so a part of
|
|
16
|
-
* an identifier typed as printed (`BE68 5390`) finds the stored one.
|
|
17
|
-
*/
|
|
18
|
-
function identifierFilterText(value, read) {
|
|
19
|
-
return read(value) ?? compactIdentifier(value);
|
|
20
|
-
}
|
|
21
|
-
/** The remainder of a digit string of any length divided by 97. */
|
|
22
|
-
function mod97(digits) {
|
|
23
|
-
let remainder = 0;
|
|
24
|
-
for (const digit of digits) {
|
|
25
|
-
remainder = (remainder * 10 + Number(digit)) % 97;
|
|
26
|
-
}
|
|
27
|
-
return remainder;
|
|
28
|
-
}
|
|
29
|
-
/** Whether a digit string passes the Luhn check (ISO/IEC 7812). */
|
|
30
|
-
function passesLuhn(digits) {
|
|
31
|
-
let sum = 0;
|
|
32
|
-
for (let index = 0; index < digits.length; index++) {
|
|
33
|
-
const digit = Number(digits[digits.length - 1 - index]);
|
|
34
|
-
const weighted = index % 2 === 1 ? digit * 2 : digit;
|
|
35
|
-
sum += weighted > 9 ? weighted - 9 : weighted;
|
|
36
|
-
}
|
|
37
|
-
return sum % 10 === 0;
|
|
38
|
-
}
|
|
39
|
-
const IBAN = /^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/;
|
|
40
|
-
/**
|
|
41
|
-
* @internal An IBAN without spaces (`BE68539007547034`), checked against its
|
|
42
|
-
* two check digits (ISO 13616, modulo 97); `undefined` when it is none.
|
|
43
|
-
*/
|
|
44
|
-
function readIban(value) {
|
|
45
|
-
const iban = compactIdentifier(value);
|
|
46
|
-
if (!IBAN.test(iban))
|
|
47
|
-
return undefined;
|
|
48
|
-
const numeric = `${iban.slice(4)}${iban.slice(0, 4)}`.replace(/[A-Z]/g, (letter) => String(letter.charCodeAt(0) - 55));
|
|
49
|
-
return mod97(numeric) === 1 ? iban : undefined;
|
|
50
|
-
}
|
|
51
|
-
const BIC = /^[A-Z0-9]{4}[A-Z]{2}[A-Z0-9]{2}(?:[A-Z0-9]{3})?$/;
|
|
52
|
-
/**
|
|
53
|
-
* @internal A BIC of 8 or 11 characters (ISO 9362): party prefix, country,
|
|
54
|
-
* location and an optional branch; `undefined` when it is none.
|
|
55
|
-
*/
|
|
56
|
-
function readBic(value) {
|
|
57
|
-
const bic = compactIdentifier(value);
|
|
58
|
-
return BIC.test(bic) ? bic : undefined;
|
|
59
|
-
}
|
|
60
|
-
/** The ten digits of a Belgian enterprise number, or `undefined`. */
|
|
61
|
-
function readBelgianEnterpriseNumber(digits) {
|
|
62
|
-
const number = digits.length === 9 ? `0${digits}` : digits;
|
|
63
|
-
if (!/^[01]\d{9}$/.test(number))
|
|
64
|
-
return undefined;
|
|
65
|
-
const check = 97 - mod97(number.slice(0, 8));
|
|
66
|
-
return check === Number(number.slice(8)) ? number : undefined;
|
|
67
|
-
}
|
|
68
|
-
/** The nine digits of a French SIREN, or `undefined`. */
|
|
69
|
-
function readSiren(digits) {
|
|
70
|
-
return /^\d{9}$/.test(digits) && passesLuhn(digits) ? digits : undefined;
|
|
71
|
-
}
|
|
72
|
-
const COMPANY_NUMBER_READERS = new Map([
|
|
73
|
-
["BE", readBelgianEnterpriseNumber],
|
|
74
|
-
["FR", readSiren],
|
|
75
|
-
]);
|
|
76
|
-
/** @internal Whether `country` is one whose company number is read. */
|
|
77
|
-
function isCompanyNumberCountry(country) {
|
|
78
|
-
return typeof country === "string" && COMPANY_NUMBER_READERS.has(country);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* @internal A company registration number of `country` as its register
|
|
82
|
-
* writes it, digits only: a Belgian enterprise number of ten digits (the
|
|
83
|
-
* nine of before 2005 get their leading zero), a French SIREN of nine.
|
|
84
|
-
* Typed with its country's code in front (`BE 0123.456.749`), it reads the
|
|
85
|
-
* same. `undefined` when it is none.
|
|
86
|
-
*/
|
|
87
|
-
function readCompanyNumber(value, country) {
|
|
88
|
-
const compact = compactIdentifier(value);
|
|
89
|
-
const digits = compact.startsWith(country)
|
|
90
|
-
? compact.slice(country.length)
|
|
91
|
-
: compact;
|
|
92
|
-
return COMPANY_NUMBER_READERS.get(country)?.(digits);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* The format of each country's VAT number after its country code, as the
|
|
96
|
-
* EU's VIES service lists it, plus Northern Ireland (`XI`) and Great Britain.
|
|
97
|
-
*/
|
|
98
|
-
const VAT_NUMBER_FORMATS = new Map([
|
|
99
|
-
["AT", /^U\d{8}$/],
|
|
100
|
-
["BE", /^[01]\d{9}$/],
|
|
101
|
-
["BG", /^\d{9,10}$/],
|
|
102
|
-
["CY", /^\d{8}[A-Z]$/],
|
|
103
|
-
["CZ", /^\d{8,10}$/],
|
|
104
|
-
["DE", /^\d{9}$/],
|
|
105
|
-
["DK", /^\d{8}$/],
|
|
106
|
-
["EE", /^\d{9}$/],
|
|
107
|
-
["EL", /^\d{9}$/],
|
|
108
|
-
["ES", /^[A-Z0-9]\d{7}[A-Z0-9]$/],
|
|
109
|
-
["FI", /^\d{8}$/],
|
|
110
|
-
["FR", /^[A-HJ-NP-Z0-9]{2}\d{9}$/],
|
|
111
|
-
["GB", /^(?:\d{9}|\d{12}|GD\d{3}|HA\d{3})$/],
|
|
112
|
-
["HR", /^\d{11}$/],
|
|
113
|
-
["HU", /^\d{8}$/],
|
|
114
|
-
["IE", /^(?:\d{7}[A-W][A-IW]?|\d[A-Z+*]\d{5}[A-W])$/],
|
|
115
|
-
["IT", /^\d{11}$/],
|
|
116
|
-
["LT", /^(?:\d{9}|\d{12})$/],
|
|
117
|
-
["LU", /^\d{8}$/],
|
|
118
|
-
["LV", /^\d{11}$/],
|
|
119
|
-
["MT", /^\d{8}$/],
|
|
120
|
-
["NL", /^\d{9}B\d{2}$/],
|
|
121
|
-
["PL", /^\d{10}$/],
|
|
122
|
-
["PT", /^\d{9}$/],
|
|
123
|
-
["RO", /^[1-9]\d{1,9}$/],
|
|
124
|
-
["SE", /^\d{10}01$/],
|
|
125
|
-
["SI", /^\d{8}$/],
|
|
126
|
-
["SK", /^\d{10}$/],
|
|
127
|
-
["XI", /^(?:\d{9}|\d{12}|GD\d{3}|HA\d{3})$/],
|
|
128
|
-
]);
|
|
129
|
-
/** German VAT check digit: ISO 7064 MOD 11,10 over the first eight digits. */
|
|
130
|
-
function passesGermanCheck(number) {
|
|
131
|
-
let product = 10;
|
|
132
|
-
for (const digit of number.slice(0, 8)) {
|
|
133
|
-
let sum = (Number(digit) + product) % 10;
|
|
134
|
-
if (sum === 0)
|
|
135
|
-
sum = 10;
|
|
136
|
-
product = (2 * sum) % 11;
|
|
137
|
-
}
|
|
138
|
-
const check = (11 - product) % 10;
|
|
139
|
-
return check === Number(number[8]);
|
|
140
|
-
}
|
|
141
|
-
/** French VAT key: `(12 + 3 × (SIREN mod 97)) mod 97`, when it is numeric. */
|
|
142
|
-
function passesFrenchCheck(number) {
|
|
143
|
-
const key = number.slice(0, 2);
|
|
144
|
-
if (!/^\d{2}$/.test(key))
|
|
145
|
-
return true;
|
|
146
|
-
const siren = number.slice(2);
|
|
147
|
-
return Number(key) === (12 + 3 * mod97(siren)) % 97;
|
|
148
|
-
}
|
|
149
|
-
/** Luxembourg VAT: the first six digits modulo 89 are the last two. */
|
|
150
|
-
function passesLuxembourgCheck(number) {
|
|
151
|
-
return Number(number.slice(0, 6)) % 89 === Number(number.slice(6));
|
|
152
|
-
}
|
|
153
|
-
/** The check digits of the countries whose public rule is stable; the format only elsewhere. */
|
|
154
|
-
const VAT_CHECKS = new Map([
|
|
155
|
-
["BE", (number) => readBelgianEnterpriseNumber(number) !== undefined],
|
|
156
|
-
["DE", passesGermanCheck],
|
|
157
|
-
["FR", passesFrenchCheck],
|
|
158
|
-
["IT", passesLuhn],
|
|
159
|
-
["LU", passesLuxembourgCheck],
|
|
160
|
-
]);
|
|
161
|
-
/** The code a person may type for a VAT country, read as VIES writes it. */
|
|
162
|
-
const VAT_PREFIX_ALIASES = new Map([["GR", "EL"]]);
|
|
163
|
-
/**
|
|
164
|
-
* @internal A VAT number as VIES writes it (`BE0123456749`): its country's
|
|
165
|
-
* code, then its number without spaces. The number must have its country's
|
|
166
|
-
* format; Belgium, Germany, France, Italy and Luxembourg also check its check
|
|
167
|
-
* digits. A number typed without its country's code reads in
|
|
168
|
-
* `defaultCountry`, and a Belgian one of nine digits gets its leading zero.
|
|
169
|
-
* `undefined` when it is none.
|
|
170
|
-
*/
|
|
171
|
-
function readVatNumber(value, defaultCountry) {
|
|
172
|
-
const compact = compactIdentifier(value);
|
|
173
|
-
const typedPrefix = compact.slice(0, 2);
|
|
174
|
-
const isPrefixed = /^[A-Z]{2}$/.test(typedPrefix);
|
|
175
|
-
const prefix = isPrefixed ? typedPrefix : defaultCountry?.toUpperCase();
|
|
176
|
-
if (!prefix)
|
|
177
|
-
return undefined;
|
|
178
|
-
const country = VAT_PREFIX_ALIASES.get(prefix) ?? prefix;
|
|
179
|
-
const format = VAT_NUMBER_FORMATS.get(country);
|
|
180
|
-
if (!format)
|
|
181
|
-
return undefined;
|
|
182
|
-
const typed = isPrefixed ? compact.slice(2) : compact;
|
|
183
|
-
const number = country === "BE" && typed.length === 9 ? `0${typed}` : typed;
|
|
184
|
-
if (!format.test(number))
|
|
185
|
-
return undefined;
|
|
186
|
-
const check = VAT_CHECKS.get(country);
|
|
187
|
-
if (check && !check(number))
|
|
188
|
-
return undefined;
|
|
189
|
-
return `${country}${number}`;
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=legal-identifiers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legal-identifiers.js","sourceRoot":"","sources":["../../../../src/base/data-types/internal/legal-identifiers.ts"],"names":[],"mappings":";;;;;;;;AAEA,wFAAwF;AACxF,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,8BACE,KAAa,EACb,IAA2C;IAE3C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,mEAAmE;AACnE,SAAS,KAAK,CAAC,MAAc;IAC3B,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,SAAS,GAAG,CAAC,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;IACpD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,mEAAmE;AACnE,SAAS,UAAU,CAAC,MAAc;IAChC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACrD,GAAG,IAA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9C,OAAO,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { GroupedOptions } from "../options";
|
|
3
|
-
/**
|
|
4
|
-
* The most values `grouped.order` lists: the list route reads one group at a
|
|
5
|
-
* time.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare const MAX_GROUP_ORDER_VALUES = 50;
|
|
10
|
-
/**
|
|
11
|
-
* The values a group order lists: 1 to {@link MAX_GROUP_ORDER_VALUES} scalars.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare const groupOrderSchema: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
16
|
-
/**
|
|
17
|
-
* `grouped.order` orders the groups of one value each: `"items"` on a single
|
|
18
|
-
* `SelectType` column, else values listed once each.
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export declare function validateGroupOrder(controllerName: string, grouped: GroupedOptions, typeId: string | undefined, type: {
|
|
23
|
-
options?: {
|
|
24
|
-
multiple?: boolean;
|
|
25
|
-
};
|
|
26
|
-
}): void;
|