diff --git a/.changeset/35488-standard-unit-table-sys-unit.md b/.changeset/35488-standard-unit-table-sys-unit.md new file mode 100644 index 00000000000..428b1754e4b --- /dev/null +++ b/.changeset/35488-standard-unit-table-sys-unit.md @@ -0,0 +1,18 @@ +--- +'@objectstack/spec': patch +'@objectstack/platform-objects': patch +'@objectstack/plugin-security': patch +'@objectstack/cli': patch +--- + +feat(spec, platform-objects): the standard unit table and the organization unit object `sys_unit` (ADR-0158 U1–U3) + +Clause-②: yes (widening) +Metadata-protocol: none + +Units of measure, first release (ADR-0158 U7 R1). Nothing reads these tables yet: the unit declaration on a `number` field, the write-time membership check and the display of a quantity with its unit ship with their own cards. No field key ships here. + +- **`@objectstack/spec`** (`@objectstack/spec/data`) exports `STANDARD_UNITS`, a closed table of 41 UN/ECE Recommendation 20 codes. Each code carries its dimension (`UNIT_DIMENSIONS`: `mass`, `length`, `area`, `volume`, `time`, `count`, `package`) and its ratio to the dimension's base unit (`UNIT_DIMENSION_BASE_CODES`: `KGM`, `MTR`, `MTK`, `MTQ`, `SEC`, `H87`), as an exact decimal string: `1 CODE = ratio × BASE`. Package codes (`XBX`, `XCT`, `XPX`, …) carry no ratio. The piece is `H87`; `C62` and `EA` are not members. `ORGANIZATION_UNIT_CODE_PATTERN` is the namespace of an organization's own codes (uppercase letters, digits and underscores, at least 4 characters or containing an underscore), which no standard code can match. `PLATFORM_OBJECTS_BY_PACKAGE['platform-objects']` gains `sys_unit`. The table is not a value domain: `ValueDomainSchema` keeps its three members. +- **`@objectstack/platform-objects`** registers `sys_unit` (Setup → Configuration → Units of Measure), an organization's own units: `code`, `label`, `dimension`, `ratio` (scale 12; required on every dimension but `package`, refused on `package`), `decimal_places` (a display default) and `retired`. It is organization-owned behind the tenant wall and ships no rows. A code outside the organization namespace is refused, the code is unique within the organization, and the code and dimension cannot change after create. A unit is retired instead of deleted, and retiring cannot be undone, so a code is never created again with another meaning; the data API serves no delete on it. Every column carries field history. +- **`@objectstack/plugin-security`**: `member_default` reads `sys_unit`, so a unit's label displays to every member; organization administrators write it through their existing grant. +- **`@objectstack/cli`**: the organization-ownership inventory lists `sys_unit` as attributed to its organization. diff --git a/docs/adr/0158-units-of-measure-standard-unit-table-org-units-quantity-unit-declaration-base-quantity.md b/docs/adr/0158-units-of-measure-standard-unit-table-org-units-quantity-unit-declaration-base-quantity.md index 369a93e9777..028a8710f4c 100644 --- a/docs/adr/0158-units-of-measure-standard-unit-table-org-units-quantity-unit-declaration-base-quantity.md +++ b/docs/adr/0158-units-of-measure-standard-unit-table-org-units-quantity-unit-declaration-base-quantity.md @@ -435,6 +435,8 @@ U7 is the ruled plan; this table restates it and adds nothing. first, and only an organization admin edits a ratio, audited. - **A unit row's code and dimension cannot change after create** (L1, settled by the seat). A deleted code can be created again with another dimension; what that does to resting rows is [Open item](#open-items) 11. + *Note (2026-11-19):* Open item 11 is settled: a deleted code stays retired, and the retired row keeps its code, so it + is never created again. - **A deleted org unit leaves its rows readable** (L1, settled by the seat): they keep their code and stored conversion and show the code without a label, and a new save with that code is refused. Which writes count as such a save is [Open item](#open-items) 9. @@ -469,11 +471,63 @@ amended with each answer, the way ADR-0144's open items were. 1. **U1's membership.** Which Rec 20 common codes the curated subset holds, each one's dimension and ratio, and which package codes it lists. U2 fixes one code (`H87`) and refuses two (`C62`, `EA`). + *Note (2026-11-19):* settled on the `sys_unit` card + ([#35488](https://github.com/objectstack-ai/objectstack/issues/35488)), under the owning seat's contract review; the + table is `packages/spec/src/data/standard-units.ts#STANDARD_UNITS`, 41 codes. Seven dimensions, the closed + vocabulary `UNIT_DIMENSIONS`; each ratio dimension has a base unit (`UNIT_DIMENSION_BASE_CODES`), whose ratio is + `1`. The ratio reads `1 CODE = ratio × BASE`, so a quantity converts to the base unit by multiplying it by the + ratio. Every ratio is a decimal string of at most 12 places, exact by definition: + + | Dimension | Base | Members, with ratio | + |:--|:--|:--| + | `mass` | `KGM` | `GRM` 0.001, `MGM` 0.000001, `TNE` 1000, `LBR` 0.45359237, `ONZ` 0.028349523125 | + | `length` | `MTR` | `MMT` 0.001, `CMT` 0.01, `KMT` 1000, `INH` 0.0254, `FOT` 0.3048, `YRD` 0.9144 | + | `area` | `MTK` | `CMK` 0.0001, `MMK` 0.000001, `FTK` 0.09290304 | + | `volume` | `MTQ` | `LTR` 0.001, `MLT` 0.000001, `GLL` 0.003785411784 | + | `time` | `SEC` | `MIN` 60, `HUR` 3600, `DAY` 86400, `WEE` 604800 | + | `count` | `H87` | `PR` 2, `DZN` 12 | + | `package` | none | `XBG`, `XBE`, `XBO`, `XBX`, `XCT`, `XCS`, `XCR`, `XDR`, `XPK`, `XPX`, `XRO`, `XSA`; no ratio | + + Sources: the SI prefixes (`GRM`, `MGM`, `MMT`, `CMT`, `KMT`, `CMK`, `MMK`, `MLT`) and the units accepted for use with + the SI (`TNE`, `LTR`, `MIN`, `HUR`, `DAY`), SI Brochure 9th edition, Tables 7 and 8; the international yard and + pound of 1959 (`LBR`, `ONZ` as 1/16 lb, `INH`, `FOT`, `YRD`, `FTK`); the United States gallon of 231 cubic inches + (`GLL`); Recommendation 20's own factor (`WEE`, `PR`, `DZN`). Recommendation 20 prints `ONZ` and `GLL` rounded + (2.834 952 × 10⁻² kg, 3.785 412 × 10⁻³ m³); the table holds the exact values. Left out: hectare (`HAR`), which + Recommendation 20 marks deprecated; month (`MON`) and year (`ANN`), whose Recommendation 20 factors rest on a + 365.25-day year that no calendar month or year equals; and every affine unit (U7 R2). The dimension is named + `count`, not `piece`: a pair and a dozen are counts measured in pieces, as a gram is a mass measured in kilograms. + Codes, names, statuses and factors were read from the Recommendation 20 annex (the `datasets/unece-units-of-measure` + mirror, data package 17.0) and the package codes from the Peppol BIS Billing 3.0 list `UNECERec20` ("including + Recommendation 21 codes - prefixed with X", Revision 11e). The organization namespace of U3 is the same file's + `ORGANIZATION_UNIT_CODE_PATTERN`: uppercase letters, digits and underscores, starting with a letter or a digit, at + most 32 characters, at least 4 long or containing an underscore. The table widens only by an amendment of this + record. 2. **`sys_unit`'s owning package, its fields and its write grants.** Its fields beyond what U3, U6, U7 R2, L1 and L2 name, against [ADR-0029](./0029-kernel-object-ownership-and-platform-objects-decomposition.md) D1, D3 and D6. ADR-0144 D3 left `sys_exchange_rate`'s owner to its card the same way. Its write grants: who creates, relabels and deletes an org unit. The seat's L1 settlement names only who edits a ratio, and a delete is the act L1 attaches refusals to. + *Note (2026-11-19):* settled on the `sys_unit` card + ([#35488](https://github.com/objectstack-ai/objectstack/issues/35488)), under the owning seat's contract review, + answering [#35465](https://github.com/objectstack-ai/objectstack/issues/35465). + - **Owner: `@objectstack/platform-objects`** + (`packages/platform-objects/src/system/sys-unit.object.ts#SysUnit`), registered in its first manifest beside + `sys_exchange_rate`. ADR-0029 D3 asks for one owner per object, and this is the only one. Its readers are the + engine's write-time membership check (U5) and the display of a quantity with its unit, present in every + composition that can write or read a record, so it has no on/off boundary of its own (D2) and no capability plugin + (D1) would own it; it joins the per-organization reference table ADR-0144's Open item 11 settled into the same + package. D6's decomposition, when it comes, moves both together. + - **Fields:** `code` (text, at most 32, required, unique per organization, in U3's namespace, immutable after + create); `label` (text, at most 80, required: L2's one org-written label); `dimension` (select over U1's closed + vocabulary, required, immutable after create); `ratio` (number, scale 12, precision 24, at least 10⁻¹², required + on every dimension but `package` and refused on `package`, U1's shape; editable, an edit affecting later writes + only, L1); `decimal_places` (whole number 0 to 12, optional, the display default of U6, never a storage rule, L4); + `retired` (boolean, default false, Open item 11). `organization_id` is injected (U3). Every authored column + carries field history. + - **Grants:** every member reads (`member_default` names `sys_unit`, read only; the seat's first U3 note). An + organization owner or administrator creates, relabels, edits a ratio and retires a unit, through + `organization_admin`'s wildcard grant, the way `sys_exchange_rate` is written; no member holds a write bit. No one + deletes: retiring is the delete (Open item 11). 3. **The codes of the new refusals**: U5's membership refusal, U7 R1's aggregate refusal, U7 R2's refusal of a write with no ratio and no factor, and the refusal of a new save with a deleted org unit's code (L1, settled by the seat). [ADR-0112](./0112-error-code-vocabulary-and-ledger.md) sets their codes and envelope. @@ -539,6 +593,23 @@ amended with each answer, the way ADR-0144's open items were. record declines a lock for the ratio only, and L1 rules out scanning for "used", so a use check cannot close it. For the `sys_unit` card: either a deleted code stays retired, or re-creation is admitted and its consequence is stated. Not settled here. + *Note (2026-11-19):* settled on the `sys_unit` card + ([#35488](https://github.com/objectstack-ai/objectstack/issues/35488)), under the owning seat's contract review, + answering [#35466](https://github.com/objectstack-ai/objectstack/issues/35466): **a deleted code stays retired.** + L1's delete is spelled as a one-way `retired` flag on the row. The row is never removed, so it keeps holding the + organization-scoped unique key on `code`, and the same code can never be created again with another dimension, + ratio or label; the hazard above cannot arise. The mechanism, each part pinned: the data API serves no delete on + `sys_unit`, single or batched (`enable.apiMethods` is `get`, `list`, `create`, `update`, `bulk`, and a batch admits + only a granted verb), Setup offers no Delete + (`userActions.delete: false`), and a rule refuses clearing `retired` once set. Rows resting on a retired unit keep + their code and stored conversion, as L1 states for a deleted unit. Two consequences are left to their cards: the + membership card (U5, [Open item](#open-items) 9) refuses a new save with a retired code, as L1's delete bullet + requires; and the display card says whether a resting row shows the retired unit's label, which stays on file, or + the bare code that L1 wrote for a deleted unit. Re-creation was not admitted: no measured reason favoured it, and + an organization that needs the code's old meaning back has the retired row's history, while one that needs a new + meaning names a new code. Not closed by this mechanism: `apiMethods` governs the data API, so a delete issued to the + engine directly, below that door, is not refused by it; no platform path issues one, and whether an automation + could is not measured here. 12. **R1's backfill and its raw aggregates.** The backfill mirrors `os migrate record-currency-codes` loosely. That door writes one code, the operator's, into the rows whose code is blank (`packages/objectql/src/record-currency-backfill.ts#backfillRecordCurrencyCodes`); the unit door rewrites free diff --git a/packages/cli/src/utils/organization-ownership-inventory.ts b/packages/cli/src/utils/organization-ownership-inventory.ts index 953ac18b4ce..9af89898b10 100644 --- a/packages/cli/src/utils/organization-ownership-inventory.ts +++ b/packages/cli/src/utils/organization-ownership-inventory.ts @@ -851,6 +851,10 @@ export const ORGANIZATION_OWNERSHIP_INVENTORY: readonly InventoryEntry[] = [ // Exchange rates (`@objectstack/platform-objects`, #27185): an organization's // administrators author its own rate table; no parent row anchors a rate. { object: 'sys_exchange_rate', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); ${D10_SINGLE}`, anchors: [] }, + // Units of measure (`@objectstack/platform-objects`, ADR-0158 U3): an + // organization's administrators author its own units; the platform ships no + // row, and no parent row anchors a unit. + { object: 'sys_unit', census: PMAIN, fate: 'attribution', citation: `${CENSUS_MAIN} (in reach, added since the first census); ${D10_SINGLE}`, anchors: [] }, // The recycle bin (`@objectstack/platform-objects`, ADR-0148, #30237): the // engine writes each entry with the organization of the record it holds, // else the deleting context's. A NULL row comes only from a delete with diff --git a/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts b/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts index abd6b9c0770..b1b173208c6 100644 --- a/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts +++ b/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts @@ -274,16 +274,19 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', ( // Configuration; 32 until the recycle bin entry, `nav_recycle_bin`, // joined Configuration (#30239); 33 until objectstack#34724 retired // the Packaged Actions entry, `nav_packaged_actions`, the one entry - // `group_apps` held here, so that group collapses too.) + // `group_apps` held here, so that group collapses too; 31 until the + // Units of Measure entry, `nav_units_of_measure`, joined Configuration + // (#35488).) // `nav_settings_branding` is not among them, and not because of a // tenancy wall (this harness boots none): since #24766 it is // contributed by `@objectstack/service-settings` together with the // `branding` namespace, offered only where no organization wall stands, // and this harness composes platform-objects and the MCP bundle alone. - expect(allowedIds).toHaveLength(31); + expect(allowedIds).toHaveLength(32); expect(allowedIds).not.toContain('nav_packaged_actions'); expect(allowedIds).toContain('nav_settings_access_policy'); expect(allowedIds).toContain('nav_recycle_bin'); + expect(allowedIds).toContain('nav_units_of_measure'); expect(allowedIds).not.toContain('nav_settings_branding'); // The two per-user stores are reached from the User record page, not // from Setup's menu (#23803). @@ -306,8 +309,8 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', ( expect(withAccountHalf.statusCode).toBe(200); expect(withoutAccountHalf.statusCode).toBe(200); expect(navIds(withAccountHalf.body?.item)).toEqual(navIds(withoutAccountHalf.body?.item)); - // 31: the composition the count in the test above states. - expect(navIds(withAccountHalf.body?.item)).toHaveLength(31); + // 32: the composition the count in the test above states. + expect(navIds(withAccountHalf.body?.item)).toHaveLength(32); // The mechanism behind the invariance, asserted rather than assumed: // the bundle aims exactly one contribution at `setup` and one at diff --git a/packages/platform-objects/scripts/i18n-extract.config.ts b/packages/platform-objects/scripts/i18n-extract.config.ts index 3d59bc05744..1edd6352b2b 100644 --- a/packages/platform-objects/scripts/i18n-extract.config.ts +++ b/packages/platform-objects/scripts/i18n-extract.config.ts @@ -203,6 +203,7 @@ import { SysPlatformSettingAudit, SysMigration, SysExchangeRate, + SysUnit, } from '../src/system/index.js'; // ── Existing Setup app + dashboards + translations ──────────────────────── @@ -360,6 +361,7 @@ const config: ObjectStackDefinition = defineStack({ SysPlatformSettingAudit, SysMigration, SysExchangeRate, + SysUnit, ] as any, apps: [SETUP_APP, STUDIO_APP, ACCOUNT_APP] as any, diff --git a/packages/platform-objects/src/apps/setup-nav.contributions.ts b/packages/platform-objects/src/apps/setup-nav.contributions.ts index a7d13fe83b4..e88cb7ba273 100644 --- a/packages/platform-objects/src/apps/setup-nav.contributions.ts +++ b/packages/platform-objects/src/apps/setup-nav.contributions.ts @@ -134,6 +134,11 @@ export const SETUP_NAV_CONTRIBUTIONS: NavigationContribution[] = [ // `requiredPermissions`: the object grant decides who reads and writes // (organization admins), and Setup itself already needs `setup.access`. { id: 'nav_exchange_rates', type: 'object', label: 'Exchange Rates', objectName: 'sys_exchange_rate', viewName: 'all_rates', icon: 'arrow-right-left' }, + // [ADR-0158 U3] The organization's own units of measure, beside the + // exchange rates as the other per-organization reference table. No + // `requiredPermissions`: the object grant decides (every member reads, + // organization admins write), and Setup itself already needs `setup.access`. + { id: 'nav_units_of_measure', type: 'object', label: 'Units of Measure', objectName: 'sys_unit', viewName: 'all_units', icon: 'ruler' }, { id: 'nav_settings_company', type: 'url', label: 'Company', url: '/apps/setup/system/settings/company', icon: 'building-2' }, // `nav_settings_branding` is contributed by `@objectstack/service-settings` // with the `branding` namespace, which is offered only where no diff --git a/packages/platform-objects/src/apps/translations/ar.objects.generated.ts b/packages/platform-objects/src/apps/translations/ar.objects.generated.ts index 1df359ee862..a3641d37e38 100644 --- a/packages/platform-objects/src/apps/translations/ar.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.objects.generated.ts @@ -4422,5 +4422,78 @@ export const arObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts index 88e6df5d443..d479df87bc1 100644 --- a/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts @@ -84,6 +84,39 @@ export const arGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider._actions.register_sso_provider.params.tokenEndpoint.label": "7cba958c95cef146", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb", "objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98", diff --git a/packages/platform-objects/src/apps/translations/ar.ts b/packages/platform-objects/src/apps/translations/ar.ts index b5576f775e0..20296403eeb 100644 --- a/packages/platform-objects/src/apps/translations/ar.ts +++ b/packages/platform-objects/src/apps/translations/ar.ts @@ -94,6 +94,7 @@ export const ar: TranslationData = { nav_settings_hub: { label: 'جميع الإعدادات' }, nav_settings_localization: { label: 'الترجمة والإعدادات المحلية' }, nav_exchange_rates: { label: 'أسعار الصرف' }, + nav_units_of_measure: { label: 'وحدات القياس' }, nav_settings_company: { label: 'الشركة' }, nav_settings_mail: { label: 'إرسال البريد' }, nav_settings_sms: { label: 'إرسال الرسائل النصية' }, diff --git a/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts b/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts index 648ef7e731a..450ca84c8db 100644 --- a/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts +++ b/packages/platform-objects/src/apps/translations/bundle-ownership.test.ts @@ -55,7 +55,7 @@ const OWNED_OBJECTS = new Set([ // metadata (sys_view_definition retired as inert, ADR-0131 D13) 'sys_metadata', 'sys_metadata_history', 'sys_metadata_audit', 'sys_metadata_commit', // system - 'sys_setting', 'sys_platform_setting', 'sys_secret', 'sys_setting_audit', 'sys_platform_setting_audit', 'sys_migration', 'sys_exchange_rate', + 'sys_setting', 'sys_platform_setting', 'sys_secret', 'sys_setting_audit', 'sys_platform_setting_audit', 'sys_migration', 'sys_exchange_rate', 'sys_unit', ]); describe('objects translation bundle ownership (ADR-0029 D8)', () => { diff --git a/packages/platform-objects/src/apps/translations/de.objects.generated.ts b/packages/platform-objects/src/apps/translations/de.objects.generated.ts index a83e2630d8e..7f8ae4e8064 100644 --- a/packages/platform-objects/src/apps/translations/de.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.objects.generated.ts @@ -4422,5 +4422,78 @@ export const deObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts index 628a3fca820..de915ff9cfa 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts @@ -223,6 +223,39 @@ export const deGeneratedSourceHashes: Readonly> = { "objects.sys_team.label": "42b87165ac826b2b", "objects.sys_team.pluralLabel": "3fe8519872f65108", "objects.sys_team_member.fields.team_id.label": "42b87165ac826b2b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.add_sso_user.params.positions.label": "9a24c02e441eb0b4", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.register_service_account.params.name.label": "5274417ff1ccaf01", diff --git a/packages/platform-objects/src/apps/translations/de.ts b/packages/platform-objects/src/apps/translations/de.ts index a90ba6d2117..1c880264407 100644 --- a/packages/platform-objects/src/apps/translations/de.ts +++ b/packages/platform-objects/src/apps/translations/de.ts @@ -96,6 +96,7 @@ export const de: TranslationData = { nav_settings_hub: { label: 'Alle Einstellungen' }, nav_settings_localization: { label: 'Lokalisierung' }, nav_exchange_rates: { label: 'Wechselkurse' }, + nav_units_of_measure: { label: 'Maßeinheiten' }, nav_settings_company: { label: 'Unternehmen' }, nav_settings_mail: { label: 'E-Mail-Versand' }, nav_settings_sms: { label: 'SMS-Versand' }, diff --git a/packages/platform-objects/src/apps/translations/en.objects.generated.ts b/packages/platform-objects/src/apps/translations/en.objects.generated.ts index 64f13a0d72b..ade2e693e94 100644 --- a/packages/platform-objects/src/apps/translations/en.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.objects.generated.ts @@ -4422,5 +4422,78 @@ export const enObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/en.ts b/packages/platform-objects/src/apps/translations/en.ts index 0d94a1f54d2..209cf5e9542 100644 --- a/packages/platform-objects/src/apps/translations/en.ts +++ b/packages/platform-objects/src/apps/translations/en.ts @@ -130,6 +130,7 @@ export const en: TranslationData = { nav_settings_hub: { label: 'All Settings' }, nav_settings_localization: { label: 'Localization' }, nav_exchange_rates: { label: 'Exchange Rates' }, + nav_units_of_measure: { label: 'Units of Measure' }, nav_settings_company: { label: 'Company' }, nav_settings_mail: { label: 'Mail Delivery' }, nav_settings_sms: { label: 'SMS Delivery' }, diff --git a/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts index 4a7ef584e34..1775ccb2b6c 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts @@ -4422,5 +4422,78 @@ export const esESObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts index 99c0176fec9..083d6760f5e 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts @@ -159,6 +159,39 @@ export const esESGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072", }; diff --git a/packages/platform-objects/src/apps/translations/es-ES.ts b/packages/platform-objects/src/apps/translations/es-ES.ts index 414d4372176..4d25c35819d 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.ts @@ -85,6 +85,7 @@ export const esES: TranslationData = { nav_settings_hub: { label: 'Todos los Ajustes' }, nav_settings_localization: { label: 'Localización' }, nav_exchange_rates: { label: 'Tipos de cambio' }, + nav_units_of_measure: { label: 'Unidades de medida' }, nav_settings_company: { label: 'Empresa' }, nav_settings_mail: { label: 'Envío de correo' }, nav_settings_sms: { label: 'Envío de SMS' }, diff --git a/packages/platform-objects/src/apps/translations/fr.objects.generated.ts b/packages/platform-objects/src/apps/translations/fr.objects.generated.ts index 8a974a89c8d..33bc167a618 100644 --- a/packages/platform-objects/src/apps/translations/fr.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.objects.generated.ts @@ -4422,5 +4422,78 @@ export const frObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts index 19e26f7989d..5ee18217878 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts @@ -252,6 +252,39 @@ export const frGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", "objects.sys_two_factor.fields.secret.label": "03cb32e33fa5cc45", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb", "objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98", diff --git a/packages/platform-objects/src/apps/translations/fr.ts b/packages/platform-objects/src/apps/translations/fr.ts index 8512a22f91a..78dfd740927 100644 --- a/packages/platform-objects/src/apps/translations/fr.ts +++ b/packages/platform-objects/src/apps/translations/fr.ts @@ -96,6 +96,7 @@ export const fr: TranslationData = { nav_settings_hub: { label: 'Tous les paramètres' }, nav_settings_localization: { label: 'Localisation' }, nav_exchange_rates: { label: 'Taux de change' }, + nav_units_of_measure: { label: 'Unités de mesure' }, nav_settings_company: { label: 'Entreprise' }, nav_settings_mail: { label: 'Envoi des e-mails' }, nav_settings_sms: { label: 'Envoi des SMS' }, diff --git a/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts index 5cd6eb158c0..673397b6584 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts @@ -4422,5 +4422,78 @@ export const jaJPObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts index c539c773da5..d32dc63c581 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts @@ -149,6 +149,39 @@ export const jaJPGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072", }; diff --git a/packages/platform-objects/src/apps/translations/ja-JP.ts b/packages/platform-objects/src/apps/translations/ja-JP.ts index 39eabfd756e..a22990d5464 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.ts @@ -85,6 +85,7 @@ export const jaJP: TranslationData = { nav_settings_hub: { label: 'すべての設定' }, nav_settings_localization: { label: 'ローカリゼーション' }, nav_exchange_rates: { label: '為替レート' }, + nav_units_of_measure: { label: '計量単位' }, nav_settings_company: { label: '会社' }, nav_settings_mail: { label: 'メール配信' }, nav_settings_sms: { label: 'SMS 配信' }, diff --git a/packages/platform-objects/src/apps/translations/ko.objects.generated.ts b/packages/platform-objects/src/apps/translations/ko.objects.generated.ts index c9c54c6edd0..42bdfb4a3eb 100644 --- a/packages/platform-objects/src/apps/translations/ko.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.objects.generated.ts @@ -4422,5 +4422,78 @@ export const koObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts index f70c7e7adb7..411acd1c50d 100644 --- a/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts @@ -114,6 +114,39 @@ export const koGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb", "objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98", diff --git a/packages/platform-objects/src/apps/translations/ko.ts b/packages/platform-objects/src/apps/translations/ko.ts index 98c3ccc6ee0..cd8f7ba6b75 100644 --- a/packages/platform-objects/src/apps/translations/ko.ts +++ b/packages/platform-objects/src/apps/translations/ko.ts @@ -95,6 +95,7 @@ export const ko: TranslationData = { nav_settings_hub: { label: '전체 설정' }, nav_settings_localization: { label: '현지화' }, nav_exchange_rates: { label: '환율' }, + nav_units_of_measure: { label: '측정 단위' }, nav_settings_company: { label: '회사' }, nav_settings_mail: { label: '메일 전송' }, nav_settings_sms: { label: 'SMS 전송' }, diff --git a/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts index b9beef7b7b0..3e5e728008b 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts @@ -4422,5 +4422,78 @@ export const ptBRObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts index c86d9109f75..c994c3f5da0 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts @@ -157,6 +157,39 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb", "objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.ts b/packages/platform-objects/src/apps/translations/pt-BR.ts index 4869a68d45b..02bd5fd65d2 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.ts @@ -96,6 +96,7 @@ export const ptBR: TranslationData = { nav_settings_hub: { label: 'Todas as configurações' }, nav_settings_localization: { label: 'Localização' }, nav_exchange_rates: { label: 'Taxas de câmbio' }, + nav_units_of_measure: { label: 'Unidades de medida' }, nav_settings_company: { label: 'Empresa' }, nav_settings_mail: { label: 'Envio de e-mail' }, nav_settings_sms: { label: 'Envio de SMS' }, diff --git a/packages/platform-objects/src/apps/translations/ru.objects.generated.ts b/packages/platform-objects/src/apps/translations/ru.objects.generated.ts index a831dc63a37..954dc22ecb8 100644 --- a/packages/platform-objects/src/apps/translations/ru.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.objects.generated.ts @@ -4422,5 +4422,78 @@ export const ruObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts index c5c1bc306f5..23dd8275115 100644 --- a/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts @@ -113,6 +113,39 @@ export const ruGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb", "objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98", diff --git a/packages/platform-objects/src/apps/translations/ru.ts b/packages/platform-objects/src/apps/translations/ru.ts index 26a165608d7..ccad773ff3e 100644 --- a/packages/platform-objects/src/apps/translations/ru.ts +++ b/packages/platform-objects/src/apps/translations/ru.ts @@ -96,6 +96,7 @@ export const ru: TranslationData = { nav_settings_hub: { label: 'Все настройки' }, nav_settings_localization: { label: 'Локализация' }, nav_exchange_rates: { label: 'Курсы валют' }, + nav_units_of_measure: { label: 'Единицы измерения' }, nav_settings_company: { label: 'Компания' }, nav_settings_mail: { label: 'Доставка почты' }, nav_settings_sms: { label: 'Доставка SMS' }, diff --git a/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts index 314ed4ba79b..61d876999d5 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts @@ -4422,5 +4422,78 @@ export const zhCNObjects: NonNullable = { } } } + }, + sys_unit: { + label: "计量单位", + pluralLabel: "计量单位", + description: "组织自定义的计量单位,与所有组织共有的标准单位并列——每个单位一行,以组织命名空间中的代码标识。", + fields: { + id: { + label: "ID" + }, + code: { + label: "代码", + help: "数量所存储的代码,须为大写:字母、数字和下划线,至少 4 个字符或包含下划线(如 BOX_12、JIN1)。KGM、H87 等标准代码所有组织均可使用,无需在此添加。单位创建后代码不可更改。" + }, + label: { + label: "名称", + help: "数量旁显示的单位名称,使用组织自己的语言填写。" + }, + dimension: { + label: "量纲", + help: "该单位度量的是什么。包装单位(箱、袋)没有固定换算比例。单位创建后量纲不可更改。", + options: { + mass: "质量", + length: "长度", + area: "面积", + volume: "体积", + time: "时间", + count: "计数", + package: "包装" + } + }, + ratio: { + label: "换算比例", + help: "1 个本单位 = 换算比例 × 其量纲的基本单位(质量 KGM、长度 MTR、面积 MTK、体积 MTQ、时间 SEC、计数 H87)。例:质量量纲中半千克的单位,换算比例为 0.5。包装单位没有换算比例。修改换算比例只影响之后保存的记录;已保存的记录保留保存时的数量和换算。规格变了应新建单位,而不是修改比例。" + }, + decimal_places: { + label: "小数位数", + help: "该单位的数量默认显示几位小数。它从不对已存储的值取整,存储的位数仍受字段自身的小数位数限制。" + }, + retired: { + label: "已停用", + help: "停用的单位仍保留在档,其代码永不再用,已使用它的记录照常显示。新记录不能使用已停用的单位。停用不可撤销。" + } + }, + _views: { + all_units: { + label: "全部", + description: "1 个本单位 = 换算比例 × 其量纲的基本单位(质量 KGM、长度 MTR、面积 MTK、体积 MTQ、时间 SEC、计数 H87)。例:质量量纲中半千克的单位,换算比例为 0.5。包装单位没有换算比例。", + emptyState: { + title: "尚无计量单位", + message: "千克(KGM)、件(H87)等标准单位已可直接使用。仅当组织需要标准单位未涵盖的单位时,才在此添加。" + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "单位代码由大写字母、数字和下划线组成,至少 4 个字符或包含下划线(例如 BOX_12 或 JIN1)。更短的代码保留给标准单位。" + }, + unit_code_immutable: { + message: "单位创建后代码不可更改。请用新代码新建一个单位。" + }, + unit_dimension_immutable: { + message: "单位创建后量纲不可更改。请用新量纲新建一个单位。" + }, + unit_ratio_required: { + message: "请填写相对于该量纲基本单位的换算比例。" + }, + unit_package_has_no_ratio: { + message: "包装单位没有换算比例:一个包装装多少属于物品,而不属于单位。请清空换算比例。" + }, + unit_retired_one_way: { + message: "已停用的单位不能恢复。请用新代码新建一个单位。" + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts index 5fc27e139ad..efbf3898dfc 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts @@ -89,6 +89,7 @@ export const zhCNGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072", }; diff --git a/packages/platform-objects/src/apps/translations/zh-CN.ts b/packages/platform-objects/src/apps/translations/zh-CN.ts index 0ab64b2e61b..d90a82dca05 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.ts @@ -89,6 +89,7 @@ export const zhCN: TranslationData = { nav_settings_hub: { label: '全部设置' }, nav_settings_localization: { label: '本地化' }, nav_exchange_rates: { label: '汇率' }, + nav_units_of_measure: { label: '计量单位' }, nav_settings_company: { label: '公司' }, nav_settings_mail: { label: '邮件投递' }, nav_settings_sms: { label: '短信投递' }, diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts index 891c35c6a8f..1b8d0495af9 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts @@ -4422,5 +4422,78 @@ export const zhHantObjects: NonNullable = { } } } + }, + sys_unit: { + label: "Unit of Measure", + pluralLabel: "Units of Measure", + description: "The organization's own units of measure, beside the standard units every organization has — one row per unit, named by a code in the organization namespace.", + fields: { + id: { + label: "ID" + }, + code: { + label: "Code", + help: "The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created." + }, + label: { + label: "Label", + help: "The name shown beside a quantity in this unit, in the organization's own language." + }, + dimension: { + label: "Dimension", + help: "What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.", + options: { + mass: "Mass", + length: "Length", + area: "Area", + volume: "Volume", + time: "Time", + count: "Count", + package: "Package" + } + }, + ratio: { + label: "Ratio", + help: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio. Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. A changed specification is a new unit, not an edited ratio." + }, + decimal_places: { + label: "Decimal Places", + help: "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored." + }, + retired: { + label: "Retired", + help: "A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. New records cannot use a retired unit. Retiring cannot be undone." + } + }, + _views: { + all_units: { + label: "All", + description: "1 of this unit = Ratio × the base unit of its dimension (mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87). Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.", + emptyState: { + title: "No units of measure yet", + message: "Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover." + } + } + }, + _validations: { + unit_code_organization_namespace: { + message: "A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). Shorter codes are reserved for the standard units." + }, + unit_code_immutable: { + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead." + }, + unit_dimension_immutable: { + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead." + }, + unit_ratio_required: { + message: "Enter the ratio to the base unit of this dimension." + }, + unit_package_has_no_ratio: { + message: "A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio." + }, + unit_retired_one_way: { + message: "A retired unit cannot be brought back. Create a unit with a new code instead." + } + } } }; diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts index cedbb33ccf7..4687a89b941 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts @@ -107,6 +107,39 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "objects.sys_sso_provider.fields.id.label": "00b0385c9c152888", "objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81", "objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b", + "objects.sys_unit._validations.unit_code_immutable.message": "c8ce340a53339ba2", + "objects.sys_unit._validations.unit_code_organization_namespace.message": "a1feea8fefab1228", + "objects.sys_unit._validations.unit_dimension_immutable.message": "b12c97027d369d60", + "objects.sys_unit._validations.unit_package_has_no_ratio.message": "409480663e26604f", + "objects.sys_unit._validations.unit_ratio_required.message": "e57c3e0a9db5dee6", + "objects.sys_unit._validations.unit_retired_one_way.message": "08452030c4e5c496", + "objects.sys_unit._views.all_units.description": "e7186dc986f81dcc", + "objects.sys_unit._views.all_units.emptyState.message": "f3acc94658d7ba1c", + "objects.sys_unit._views.all_units.emptyState.title": "0b2377a2cc72afc9", + "objects.sys_unit._views.all_units.label": "6d6f653f8264ab17", + "objects.sys_unit.description": "83aacf7f0b86b13c", + "objects.sys_unit.fields.code.help": "dd8679ed8ba261f5", + "objects.sys_unit.fields.code.label": "083180bdf83435b3", + "objects.sys_unit.fields.decimal_places.help": "136c777d0eb119a9", + "objects.sys_unit.fields.decimal_places.label": "c376c70ccdda79b3", + "objects.sys_unit.fields.dimension.help": "ba2475d735824211", + "objects.sys_unit.fields.dimension.label": "1e87121e98dcb2d0", + "objects.sys_unit.fields.dimension.options.area": "1b04344359103476", + "objects.sys_unit.fields.dimension.options.count": "421d540d1c4a0baf", + "objects.sys_unit.fields.dimension.options.length": "9b0c51900376c255", + "objects.sys_unit.fields.dimension.options.mass": "3e83cd35fb68a95c", + "objects.sys_unit.fields.dimension.options.package": "aacf5e74a8641b2b", + "objects.sys_unit.fields.dimension.options.time": "7ac05596efef4387", + "objects.sys_unit.fields.dimension.options.volume": "3222478fe5408184", + "objects.sys_unit.fields.id.label": "00b0385c9c152888", + "objects.sys_unit.fields.label.help": "8622e6b318aa127c", + "objects.sys_unit.fields.label.label": "c680364257b11569", + "objects.sys_unit.fields.ratio.help": "00c786619342b6cb", + "objects.sys_unit.fields.ratio.label": "c40e5f49691a6d86", + "objects.sys_unit.fields.retired.help": "87aacd1c4ebed47f", + "objects.sys_unit.fields.retired.label": "ca99ff610a094e8d", + "objects.sys_unit.label": "f93104f23789c9b0", + "objects.sys_unit.pluralLabel": "b52fcf82e54fdb7e", "objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222", "objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb", "objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.ts b/packages/platform-objects/src/apps/translations/zh-Hant.ts index 876aec38241..4f231af1a92 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.ts @@ -94,6 +94,7 @@ export const zhHant: TranslationData = { nav_settings_hub: { label: '全部設定' }, nav_settings_localization: { label: '在地化' }, nav_exchange_rates: { label: '匯率' }, + nav_units_of_measure: { label: '計量單位' }, nav_settings_company: { label: '公司' }, nav_settings_mail: { label: '郵件投遞' }, nav_settings_sms: { label: '簡訊投遞' }, diff --git a/packages/platform-objects/src/platform-objects.test.ts b/packages/platform-objects/src/platform-objects.test.ts index a9c80336b27..c61106bdeb4 100644 --- a/packages/platform-objects/src/platform-objects.test.ts +++ b/packages/platform-objects/src/platform-objects.test.ts @@ -37,7 +37,7 @@ import { SysMetadata, SysMetadataHistoryObject, } from './metadata/index.js'; -import { SysExchangeRate, SysSecret, SysSetting } from './system/index.js'; +import { SysExchangeRate, SysSecret, SysSetting, SysUnit } from './system/index.js'; import { ACCOUNT_APP, SETUP_APP, SETUP_NAV_CONTRIBUTIONS, STUDIO_APP } from './apps/index.js'; import { AppSchema } from '@objectstack/spec/ui'; import { resolveEffectiveApiMethods, isApiOperationAllowed, canServeApiOperation } from '@objectstack/spec/data'; @@ -607,6 +607,7 @@ describe('@objectstack/platform-objects', () => { sys_organization: SysOrganization, sys_session: SysSession, sys_team: SysTeam, + sys_unit: SysUnit, sys_user: SysUser, sys_user_preference: SysUserPreference, }; diff --git a/packages/platform-objects/src/plugin.test.ts b/packages/platform-objects/src/plugin.test.ts index a3cb50e646c..11f0f2520d6 100644 --- a/packages/platform-objects/src/plugin.test.ts +++ b/packages/platform-objects/src/plugin.test.ts @@ -11,7 +11,7 @@ import { describe, it, expect } from 'vitest'; import { assertEngineFindOnePredicate, assertEngineUpdateDispatch } from '@objectstack/metadata-core'; import { ObjectSchema, RECYCLE_BIN_ENTRY_FIELDS, RECYCLE_BIN_OBJECT } from '@objectstack/spec/data'; import { PlatformObjectsPlugin } from './plugin.js'; -import { SysExchangeRate, SysLifecycleState, SysMetadataActivation, SysMigration, SysMigrationJournal, SysRecycleBin, SysSecret, SysSeedLandedKey, SysTrustedKey } from './system/index.js'; +import { SysExchangeRate, SysUnit, SysLifecycleState, SysMetadataActivation, SysMigration, SysMigrationJournal, SysRecycleBin, SysSecret, SysSeedLandedKey, SysTrustedKey } from './system/index.js'; /** * Hand-rolled fake PluginContext (mirrors the service-plugin tests) — this @@ -47,7 +47,7 @@ function makeCtx() { } describe('PlatformObjectsPlugin: platform-infrastructure object registration (#4243, #4270)', () => { - it('registers SysMigration, SysMigrationJournal, SysSecret, SysExchangeRate, SysTrustedKey, SysLifecycleState, SysRecycleBin and SysSeedLandedKey through the manifest service', async () => { + it('registers SysMigration, SysMigrationJournal, SysSecret, SysExchangeRate, SysUnit, SysTrustedKey, SysLifecycleState, SysRecycleBin and SysSeedLandedKey through the manifest service', async () => { const ctx = makeCtx(); const manifests: any[] = []; ctx.registerService('manifest', { register: (m: any) => manifests.push(m) }); @@ -57,7 +57,7 @@ describe('PlatformObjectsPlugin: platform-infrastructure object registration (#4 const infra = manifests.find((m) => m.id === 'com.objectstack.platform-objects'); expect(infra).toBeDefined(); expect(infra.scope).toBe('system'); - expect(infra.objects).toEqual([SysMigration, SysMigrationJournal, SysSecret, SysExchangeRate, SysTrustedKey, SysLifecycleState, SysRecycleBin, SysSeedLandedKey]); + expect(infra.objects).toEqual([SysMigration, SysMigrationJournal, SysSecret, SysExchangeRate, SysUnit, SysTrustedKey, SysLifecycleState, SysRecycleBin, SysSeedLandedKey]); expect(infra.objects.map((o: any) => o.name)).toEqual([ 'sys_migration', // ADR-0119 D2 (#4617). Registered UNCONDITIONALLY, alongside the flag @@ -70,6 +70,10 @@ describe('PlatformObjectsPlugin: platform-infrastructure object registration (#4 // home-currency projection, so it registers with the engine-facing // infrastructure, on the project database. 'sys_exchange_rate', + // [ADR-0158 U3, Open item 2] The organization's own units of measure, + // read by the engine's unit membership check and by the display of a + // quantity with its unit, so it registers beside the exchange rates. + 'sys_unit', // [ADR-0025 §3.5 M1, #27123] The environment's trusted plugin-publisher // keys, read by `os plugin install` from a one-shot boot that composes // this plugin and nothing that would register it otherwise. @@ -85,7 +89,7 @@ describe('PlatformObjectsPlugin: platform-infrastructure object registration (#4 // and written only by the seed loader, beside the rows it describes. 'sys_seed_landed_key', ]); - // ⛔ The eight above must NOT acquire the ledger's routing triple. They + // ⛔ The nine above must NOT acquire the ledger's routing triple. They // ride the project database today; moving them is a different question. expect(infra.defaultDatasource).toBeUndefined(); }); diff --git a/packages/platform-objects/src/plugin.ts b/packages/platform-objects/src/plugin.ts index b2838397578..1ae62e63402 100644 --- a/packages/platform-objects/src/plugin.ts +++ b/packages/platform-objects/src/plugin.ts @@ -7,6 +7,7 @@ import { SysMigration } from './system/sys-migration.object.js'; import { SysMigrationJournal } from './system/sys-migration-journal.object.js'; import { SysSecret } from './system/sys-secret.object.js'; import { SysExchangeRate } from './system/sys-exchange-rate.object.js'; +import { SysUnit } from './system/sys-unit.object.js'; import { SysTrustedKey } from './system/sys-trusted-key.object.js'; import { SysLifecycleState } from './system/sys-lifecycle-state.object.js'; import { SysRecycleBin } from './system/sys-recycle-bin.object.js'; @@ -113,6 +114,13 @@ import { SEED_SETTLEMENT_SERVICE } from '@objectstack/spec/contracts'; * engine-facing infrastructure above, not with an optional service. Rides * the first manifest (the project database), like every per-organization * table here. + * - **`sys_unit`** — the organization's own units of measure (ADR-0158 U3; + * its owner settled by Open item 2 on the same reasoning as + * `sys_exchange_rate`). Its readers are the engine's write-time unit + * membership check and the display of a quantity with its unit, present + * in every composition that can write or read a record, so it has no + * on/off capability boundary of its own (ADR-0029 D2) and registers here, + * in the first manifest beside the exchange rates. * - **Fresh-datastore attestation** (#3438, ADR-0104 2026-07-30) — * travels with the ledger registration: a store this boot created from * empty is attested once that boot's own data has settled @@ -222,7 +230,7 @@ export class PlatformObjectsPlugin { version: this.version, type: 'plugin', scope: 'system', - objects: [SysMigration, SysMigrationJournal, SysSecret, SysExchangeRate, SysTrustedKey, SysLifecycleState, SysRecycleBin, SysSeedLandedKey], + objects: [SysMigration, SysMigrationJournal, SysSecret, SysExchangeRate, SysUnit, SysTrustedKey, SysLifecycleState, SysRecycleBin, SysSeedLandedKey], }); ctx?.getService?.('manifest')?.register?.({ ...ACTIVATION_LEDGER_MANIFEST, diff --git a/packages/platform-objects/src/system/index.ts b/packages/platform-objects/src/system/index.ts index 3957ce32118..3a49d55eb48 100644 --- a/packages/platform-objects/src/system/index.ts +++ b/packages/platform-objects/src/system/index.ts @@ -37,6 +37,16 @@ export { EXCHANGE_RATE_SCALE, EXCHANGE_RATE_PRECISION, } from './sys-exchange-rate.object.js'; +// [ADR-0158 U3; Open items 2 and 11] The organization's own units of measure, +// beside the standard unit table in the spec. Zero platform rows. +export { + SysUnit, + UNIT_RATIO_DIRECTION, + UNIT_RATIO_EDIT_NOTICE, + UNIT_RATIO_SCALE, + UNIT_RATIO_PRECISION, + UNIT_DECIMAL_PLACES_MAX, +} from './sys-unit.object.js'; export { readDataMigrationFlag, isDataMigrationVerified, diff --git a/packages/platform-objects/src/system/sys-unit.object.test.ts b/packages/platform-objects/src/system/sys-unit.object.test.ts new file mode 100644 index 00000000000..b1418f727ff --- /dev/null +++ b/packages/platform-objects/src/system/sys-unit.object.test.ts @@ -0,0 +1,292 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { describe, it, expect } from 'vitest'; +import { celEngine } from '@objectstack/formula'; +import { + IndexSchema, + ObjectSchema, + ORGANIZATION_UNIT_CODE_PATTERN, + STANDARD_UNITS, + UNIT_DIMENSIONS, + apiExposureDenialReason, + resolveCrudAffordances, + resolveInjectedSystemColumns, +} from '@objectstack/spec/data'; +import { + SysUnit, + UNIT_DECIMAL_PLACES_MAX, + UNIT_RATIO_DIRECTION, + UNIT_RATIO_EDIT_NOTICE, + UNIT_RATIO_PRECISION, + UNIT_RATIO_SCALE, +} from './sys-unit.object.js'; +import { SETUP_NAV_CONTRIBUTIONS } from '../apps/setup-nav.contributions.js'; +import { PlatformObjectsPlugin } from '../plugin.js'; + +/** + * ADR-0158 U3: `sys_unit`'s declaration, with its Open items 2 (owner, fields, + * grants) and 11 (a deleted code stays retired) as this package settles them. + * + * Like `sys_exchange_rate`'s suite, the facts decided by a mechanism that + * lives elsewhere — the organization-scoped unique key (driver-sql), the + * Layer 0 tenant wall (ADR-0095 D1), the grants (plugin-security's + * `default-permission-sets.ts`, whose real-stack suite + * `default-permission-sets.unit-of-measure.integration.test.ts` drives this + * object), the audit writer — are pinned here as the DECLARATION each + * mechanism reads, asserted on the built value. The rules are EVALUATED: the + * format rule's regex through `RegExp`, the predicates through the canonical + * CEL engine (`@objectstack/formula`) in the scope the rule validator binds + * (`record`, and `previous`: null on insert, the prior row on update). + */ +describe('sys_unit — declaration (ADR-0158 U3)', () => { + const fields = SysUnit.fields as Record; + const rules = (SysUnit.validations ?? []) as Array>; + const rule = (name: string): Record => { + const found = rules.find((r) => r.name === name); + if (!found) throw new Error(`no rule ${name}`); + return found; + }; + + it('parses as an ObjectSchema', () => { + expect(() => ObjectSchema.parse(SysUnit)).not.toThrow(); + }); + + it('carries exactly the settled columns (Open item 2)', () => { + expect(Object.keys(fields).sort()).toEqual(['code', 'decimal_places', 'dimension', 'id', 'label', 'ratio', 'retired']); + for (const name of ['code', 'label', 'dimension']) expect(fields[name].required, name).toBe(true); + // The ratio is required by dimension (the rules below), never by the column. + for (const name of ['ratio', 'decimal_places', 'retired']) expect(fields[name].required, name).toBeFalsy(); + }); + + it('is labelled a unit of measure, never a bare "unit" beside the business units', () => { + expect(SysUnit.label).toBe('Unit of Measure'); + expect(SysUnit.pluralLabel).toBe('Units of Measure'); + }); + + describe('uniqueness', () => { + const uniqueIndexes = (SysUnit.indexes ?? []).filter((i: any) => i.unique); + + it("declares exactly one unique key, on code, scoped 'organization'", () => { + expect(uniqueIndexes).toHaveLength(1); + expect((uniqueIndexes[0] as any).fields).toEqual(['code']); + expect((uniqueIndexes[0] as any).unique).toBe('organization'); + expect(IndexSchema.parse(uniqueIndexes[0])).toMatchObject({ unique: 'organization' }); + }); + }); + + describe('tenant isolation (U3)', () => { + it('takes no tenancy opt-out, so organization_id is injected and the tenant wall scopes it', () => { + const plan = resolveInjectedSystemColumns(SysUnit); + expect((SysUnit as any).tenancy).toBeUndefined(); + expect((SysUnit as any).systemFields?.tenant).not.toBe(false); + expect(plan.tenant).toBe(true); + expect(plan.names.has('organization_id')).toBe(true); + }); + }); + + describe('zero platform rows (U3)', () => { + it('ships no record: the manifest that registers it carries no data', async () => { + const manifests: any[] = []; + const services: Record = { manifest: { register: (m: any) => manifests.push(m) } }; + const ctx = { + getService: (n: string) => services[n], + registerService: (n: string, s: unknown) => { services[n] = s; }, + hook: () => {}, + logger: { info() {}, warn() {}, error() {}, debug() {} }, + }; + await new PlatformObjectsPlugin().init(ctx as any); + const owner = manifests.find((m) => (m.objects ?? []).some((o: any) => o.name === 'sys_unit')); + expect(owner).toBeDefined(); + // No manifest this plugin registers seeds a row of it. + for (const m of manifests) { + for (const entry of (m.data ?? []) as Array<{ object?: string }>) expect(entry.object, m.id).not.toBe('sys_unit'); + } + expect(owner.data ?? []).toEqual([]); + }); + }); + + describe('who writes (Open item 2)', () => { + it('stays reachable by the organization admin wildcard grant: not private, no extra capability gate', () => { + expect((SysUnit as any).access?.default).not.toBe('private'); + expect((SysUnit as any).requiredPermissions).toBeUndefined(); + expect(SysUnit.managedBy).toBe('system-data'); + }); + + it('offers New and Edit, and no Delete: retiring is the delete (Open item 11)', () => { + const affordances = resolveCrudAffordances(SysUnit as any); + expect(SysUnit.userActions).toEqual({ delete: false }); + expect(affordances).toMatchObject({ create: true, edit: true, delete: false }); + }); + + it('serves list, read, create and update on the data API, batched or not, and refuses a delete either way', () => { + // `apiExposureDenialReason` is the function the REST door turns into its 405. + expect(SysUnit.enable?.apiEnabled).toBe(true); + expect(SysUnit.enable?.apiMethods).toEqual(['get', 'list', 'create', 'update', 'bulk']); + for (const op of ['get', 'list', 'create', 'update']) expect(apiExposureDenialReason(SysUnit.enable, op), op).toBeNull(); + for (const child of ['create', 'update']) { + expect(apiExposureDenialReason(SysUnit.enable, 'bulk', { bulkChild: child }), child).toBeNull(); + } + expect(apiExposureDenialReason(SysUnit.enable, 'delete')).toBe('method-not-allowed'); + expect(apiExposureDenialReason(SysUnit.enable, 'bulk', { bulkChild: 'delete' })).toBe('method-not-allowed'); + }); + }); + + describe('audit (L1)', () => { + it('surfaces the History tab, with every authored column tracked', () => { + expect(SysUnit.enable?.trackHistory).toBe(true); + for (const name of ['code', 'label', 'dimension', 'ratio', 'decimal_places', 'retired']) { + expect(fields[name].trackHistory, name).toBe(true); + } + }); + }); + + describe('values', () => { + it("dimension is the standard table's closed vocabulary, in its order", () => { + expect(fields.dimension.type).toBe('select'); + expect(fields.dimension.options.map((o: any) => o.value)).toEqual([...UNIT_DIMENSIONS]); + }); + + it('ratio is an exact decimal, scale 12 and precision 24, strictly positive (U7 R2)', () => { + expect(fields.ratio.type).toBe('number'); + expect(UNIT_RATIO_SCALE).toBe(12); + expect(UNIT_RATIO_PRECISION).toBe(24); + expect(fields.ratio.scale).toBe(UNIT_RATIO_SCALE); + expect(fields.ratio.precision).toBe(UNIT_RATIO_PRECISION); + expect(fields.ratio.min).toBe(10 ** -UNIT_RATIO_SCALE); + }); + + it('decimal_places is a whole number from 0 to 12, a display default only (U6, L4)', () => { + expect(fields.decimal_places.type).toBe('number'); + expect(fields.decimal_places.scale).toBe(0); + expect(fields.decimal_places.min).toBe(0); + expect(fields.decimal_places.max).toBe(UNIT_DECIMAL_PLACES_MAX); + expect(UNIT_DECIMAL_PLACES_MAX).toBe(12); + expect(fields.decimal_places.defaultValue).toBeUndefined(); + }); + + it('retired is a boolean defaulting to false', () => { + expect(fields.retired.type).toBe('boolean'); + expect(fields.retired.defaultValue).toBe(false); + }); + + it('states the ratio direction and the edit notice on the field and on the Setup list page (L1)', () => { + expect(UNIT_RATIO_DIRECTION).toMatch(/^1 of this unit = Ratio × the base unit of its dimension \(mass KGM, length MTR, area MTK, volume MTQ, time SEC, count H87\)/); + expect(UNIT_RATIO_EDIT_NOTICE).toMatch(/affects only records saved afterwards/); + expect(fields.ratio.description).toBe(`${UNIT_RATIO_DIRECTION} ${UNIT_RATIO_EDIT_NOTICE}`); + expect((SysUnit.listViews as any).all_units.description).toBe(UNIT_RATIO_DIRECTION); + }); + }); + + describe('the organization code namespace (U3)', () => { + const format = rule('unit_code_organization_namespace'); + const re = new RegExp(format.regex); + + it("is a format rule on code, spelled with the spec's one pattern", () => { + expect(format).toMatchObject({ type: 'format', field: 'code', severity: 'error' }); + expect(format.regex).toBe(ORGANIZATION_UNIT_CODE_PATTERN); + expect(fields.code.maxLength).toBe(32); + }); + + it('refuses every standard code, and every other short code with no underscore', () => { + for (const code of [...Object.keys(STANDARD_UNITS), 'C62', 'EA', 'ABC', 'Q1']) expect(re.test(code), code).toBe(false); + }); + + it('refuses a code that is not exact uppercase', () => { + for (const code of ['box_12', 'Box12', 'jin1']) expect(re.test(code), code).toBe(false); + }); + + it('admits an organization code: four characters or more, or one with an underscore', () => { + for (const code of ['BOX_12', 'JIN1', 'BAG_25KG', 'P_1']) expect(re.test(code), code).toBe(true); + }); + }); + + /** The verdict of a rule predicate, or the fault spelled out so a faulting predicate fails loudly. */ + const violates = (name: string, record: Record, previous: Record | null): boolean | string => { + const r = rule(name); + const scope = previous === null ? { record, extra: { previous: null } } : { record, previous }; + // The built rule carries the lowered expression envelope; its CEL source is what the validator evaluates. + const source = typeof r.condition === 'string' ? r.condition : r.condition?.source; + if (typeof source !== 'string') throw new Error(`rule ${name} has no CEL source`); + const out = celEngine.evaluate({ dialect: 'cel', source }, scope as any); + if (!out.ok) return `FAULT ${out.error.message.split('\n')[0].trim()}`; + return out.value as boolean; + }; + const ROW = { code: 'BOX_12', label: 'Box of 12', dimension: 'count', ratio: 12, decimal_places: 0, retired: false }; + + describe('code and dimension are immutable after create (L1)', () => { + it('are update-only rules attached to the field they guard', () => { + expect(rule('unit_code_immutable')).toMatchObject({ type: 'cross_field', events: ['update'], fields: ['code'], severity: 'error' }); + expect(rule('unit_dimension_immutable')).toMatchObject({ type: 'cross_field', events: ['update'], fields: ['dimension'], severity: 'error' }); + }); + + it('refuse an update that changes the code or the dimension', () => { + expect(violates('unit_code_immutable', { ...ROW, code: 'BOX_24' }, ROW)).toBe(true); + expect(violates('unit_dimension_immutable', { ...ROW, dimension: 'package', ratio: null }, ROW)).toBe(true); + }); + + it('admit an update that keeps them, a ratio edit included', () => { + expect(violates('unit_code_immutable', { ...ROW, ratio: 10, label: 'Box' }, ROW)).toBe(false); + expect(violates('unit_dimension_immutable', { ...ROW, ratio: 10 }, ROW)).toBe(false); + }); + }); + + describe('a ratio on every dimension but package, none on package (U1 shape)', () => { + it('refuses a ratio dimension with no ratio, and a package unit with one', () => { + expect(violates('unit_ratio_required', { ...ROW, ratio: null }, null)).toBe(true); + expect(violates('unit_package_has_no_ratio', { ...ROW, dimension: 'package', ratio: 12 }, null)).toBe(true); + }); + + it('admits a ratio dimension with a ratio, and a package unit without one', () => { + expect(violates('unit_ratio_required', ROW, null)).toBe(false); + expect(violates('unit_package_has_no_ratio', ROW, null)).toBe(false); + const pallet = { ...ROW, code: 'PALLET_EU', dimension: 'package', ratio: null }; + expect(violates('unit_ratio_required', pallet, null)).toBe(false); + expect(violates('unit_package_has_no_ratio', pallet, null)).toBe(false); + }); + + it('attach the refusal to the ratio field, on insert and update', () => { + for (const name of ['unit_ratio_required', 'unit_package_has_no_ratio']) { + expect(rule(name)).toMatchObject({ type: 'cross_field', fields: ['ratio'], severity: 'error' }); + expect(rule(name).events ?? ['insert', 'update']).toEqual(['insert', 'update']); + } + }); + }); + + describe('a retired unit stays retired (Open item 11)', () => { + it('is an update-only rule attached to retired', () => { + expect(rule('unit_retired_one_way')).toMatchObject({ type: 'cross_field', events: ['update'], fields: ['retired'], severity: 'error' }); + }); + + it('refuses bringing a retired unit back, whichever way the flag is cleared', () => { + const retired = { ...ROW, retired: true }; + expect(violates('unit_retired_one_way', { ...ROW, retired: false }, retired)).toBe(true); + expect(violates('unit_retired_one_way', { ...ROW, retired: null }, retired)).toBe(true); + }); + + it('admits retiring, and editing a retired unit that stays retired', () => { + expect(violates('unit_retired_one_way', { ...ROW, retired: true }, ROW)).toBe(false); + const retired = { ...ROW, retired: true }; + expect(violates('unit_retired_one_way', { ...retired, label: 'Box (old)' }, retired)).toBe(false); + }); + }); + + describe('Setup', () => { + const configuration = SETUP_NAV_CONTRIBUTIONS.find((c) => c.group === 'group_configuration'); + const items = (configuration?.items ?? []) as any[]; + + it('lists the units directly under the exchange rates, opening the all-units view', () => { + const at = items.findIndex((i) => i.id === 'nav_units_of_measure'); + expect(at).toBeGreaterThan(0); + expect(items[at - 1].id).toBe('nav_exchange_rates'); + expect(items[at]).toMatchObject({ type: 'object', label: 'Units of Measure', objectName: 'sys_unit', viewName: 'all_units' }); + expect(items[at].requiredPermissions).toBeUndefined(); + }); + + it('names a view the object declares', () => { + const view = (SysUnit.listViews as any).all_units; + expect(view.data).toEqual({ provider: 'object', object: 'sys_unit' }); + expect(view.columns).toEqual(['code', 'label', 'dimension', 'ratio', 'decimal_places', 'retired']); + expect(view.emptyState?.title).toBeTruthy(); + }); + }); +}); diff --git a/packages/platform-objects/src/system/sys-unit.object.ts b/packages/platform-objects/src/system/sys-unit.object.ts new file mode 100644 index 00000000000..d27e3716ab5 --- /dev/null +++ b/packages/platform-objects/src/system/sys-unit.object.ts @@ -0,0 +1,294 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { + ObjectSchema, + Field, + ORGANIZATION_UNIT_CODE_PATTERN, + UNIT_DIMENSIONS, + UNIT_DIMENSION_BASE_CODES, +} from '@objectstack/spec/data'; + +/** + * Decimal places a `ratio` keeps — twelve, as U7 R2 rules for every unit + * ratio ("decimal, scale 12, never float") and as `sys_exchange_rate`'s + * `rate` keeps. A write carrying more is refused at the engine's `scale` + * seam, never rounded. + */ +export const UNIT_RATIO_SCALE = 12; + +/** Total digits a `ratio` may carry: twelve on each side of the point. */ +export const UNIT_RATIO_PRECISION = 24; + +/** + * The most decimal places a unit's display default may name. It is a display + * default only (ADR-0158 L4): the field's own `scale` stays the storage + * ceiling, and nothing is rounded at write by it. + */ +export const UNIT_DECIMAL_PLACES_MAX = 12; + +/** + * The ratio direction, stated once and read by every face that has to say it: + * the `ratio` field's description and the Setup list page's description carry + * this sentence verbatim. The base units are read from the standard unit + * table, so the sentence cannot drift from it. + */ +export const UNIT_RATIO_DIRECTION = + '1 of this unit = Ratio × the base unit of its dimension (' + + `mass ${UNIT_DIMENSION_BASE_CODES.mass}, length ${UNIT_DIMENSION_BASE_CODES.length}, ` + + `area ${UNIT_DIMENSION_BASE_CODES.area}, volume ${UNIT_DIMENSION_BASE_CODES.volume}, ` + + `time ${UNIT_DIMENSION_BASE_CODES.time}, count ${UNIT_DIMENSION_BASE_CODES.count}). ` + + 'Example: a unit of half a kilogram in the mass dimension has ratio 0.5. A package unit takes no ratio.'; + +/** + * What editing a ratio does (ADR-0158 L1, the maintainer's pick 「可改,只影响以后」 + * with the owning seat's UI sentence): an edit applies to records saved after + * it and leaves stored records as they are. + */ +export const UNIT_RATIO_EDIT_NOTICE = + 'Changing the ratio affects only records saved afterwards; records already saved keep the quantity and conversion they were saved with. ' + + 'A changed specification is a new unit, not an edited ratio.'; + +/** The Setup labels of the closed dimension vocabulary, in its order. */ +const DIMENSION_LABELS: Record<(typeof UNIT_DIMENSIONS)[number], string> = { + mass: 'Mass', + length: 'Length', + area: 'Area', + volume: 'Volume', + time: 'Time', + count: 'Count', + package: 'Package', +}; + +/** + * sys_unit — Unit of Measure (ADR-0158 U3; its Open items 2 and 11 settled + * here) + * + * One row per unit of measure an ORGANIZATION adds beside the standard unit + * table (`STANDARD_UNITS` in `@objectstack/spec`, U1). The platform ships + * zero rows (U3). A quantity names a unit by its code, never by this row's id + * (U4), and the membership check that admits a code (U5) reads the standard + * table and this object; neither reader ships here. + * + * - **Code** — exact uppercase, in the organization namespace + * (`ORGANIZATION_UNIT_CODE_PATTERN`, U3): at least four characters, or + * containing an underscore, so it can never collide with a standard code. + * Unique within the organization, refused on every write when outside the + * namespace, and immutable after create (L1). + * - **Dimension** — one of the standard table's closed vocabulary + * (`UNIT_DIMENSIONS`); immutable after create (L1). + * - **Ratio** — to the dimension's base unit, {@link UNIT_RATIO_DIRECTION}: + * required for every dimension but `package`, refused on `package`, the + * shape a standard code has (U1). An exact decimal, scale + * {@link UNIT_RATIO_SCALE}. Editable, and an edit affects later writes only + * (L1, {@link UNIT_RATIO_EDIT_NOTICE}); audited by field history. + * - **Label** — one per unit, written by the organization in its own + * language (L2); translation of organization labels is a later card. + * - **Decimal places** — the unit's display default (U6), never a storage + * rule: the field's `scale` is the ceiling (L4). + * - **Retired** — the delete of L1, spelled as a one-way flag (Open item 11): + * a retired row keeps its code, so the code can never be created again with + * another dimension, ratio or label, and resting quantities never take a + * stranger's meaning. A hard delete is not served (`apiMethods` has no + * `delete`), a retired unit cannot be brought back, and the membership card + * refuses a new save with a retired code. + * - **Tenancy** — no tenancy opt-out, so `organization_id` is injected and the + * Layer 0 tenant wall (ADR-0095 D1) scopes every read and write. + * - **Who reads, who writes** — every member READS it (`member_default` names + * this object, read only), so a quantity's unit label displays to everyone + * who reads the quantity (the seat's U3 note). Organization administrators + * create, edit and retire units through `organization_admin`'s wildcard + * grant (Open item 2); a member holds no write bit on it. + * + * @namespace sys + */ +export const SysUnit = ObjectSchema.create({ + name: 'sys_unit', + label: 'Unit of Measure', + pluralLabel: 'Units of Measure', + icon: 'ruler', + isSystem: true, + // Platform-defined schema, organization-administered data. + managedBy: 'system-data', + // Retiring is the delete (Open item 11): no row is ever removed, so no + // delete affordance is offered and the data API serves none. + userActions: { delete: false }, + description: + "The organization's own units of measure, beside the standard units every organization has — " + + 'one row per unit, named by a code in the organization namespace.', + displayNameField: 'code', + nameField: 'code', // [ADR-0079] canonical primary-title pointer (mirrors deprecated displayNameField) + highlightFields: ['code', 'label', 'dimension', 'ratio', 'retired'], + + fields: { + id: Field.text({ label: 'ID', required: true, readonly: true, group: 'System' }), + + code: Field.text({ + label: 'Code', + required: true, + searchable: true, + maxLength: 32, + trackHistory: true, + description: + 'The code a quantity stores, in exact uppercase: letters, digits and underscores, at least 4 characters or containing an underscore (BOX_12, JIN1). ' + + 'Standard codes such as KGM and H87 are available to every organization and are not added here. The code cannot be changed after the unit is created.', + group: 'Unit', + }), + + label: Field.text({ + label: 'Label', + required: true, + searchable: true, + maxLength: 80, + trackHistory: true, + description: "The name shown beside a quantity in this unit, in the organization's own language.", + group: 'Unit', + }), + + dimension: Field.select( + UNIT_DIMENSIONS.map((value) => ({ value, label: DIMENSION_LABELS[value] })), + { + label: 'Dimension', + required: true, + trackHistory: true, + description: + 'What the unit measures. A package unit (a box, a bag) has no fixed ratio. The dimension cannot be changed after the unit is created.', + group: 'Unit', + }, + ), + + ratio: Field.number({ + label: 'Ratio', + // The smallest positive value at this scale: a zero or negative ratio + // would silently zero or flip every quantity converted through it. + min: 10 ** -UNIT_RATIO_SCALE, + scale: UNIT_RATIO_SCALE, + precision: UNIT_RATIO_PRECISION, + trackHistory: true, + description: `${UNIT_RATIO_DIRECTION} ${UNIT_RATIO_EDIT_NOTICE}`, + group: 'Conversion', + }), + + decimal_places: Field.number({ + label: 'Decimal Places', + min: 0, + max: UNIT_DECIMAL_PLACES_MAX, + scale: 0, + trackHistory: true, + description: + "How many decimal places a quantity in this unit displays with by default. It never rounds a stored value, and a field's own decimal places still limit what is stored.", + group: 'Display', + }), + + retired: Field.boolean({ + label: 'Retired', + defaultValue: false, + trackHistory: true, + description: + 'A retired unit stays on file so its code can never be reused, and records that already use it keep showing it. ' + + 'New records cannot use a retired unit. Retiring cannot be undone.', + group: 'Unit', + }), + }, + + indexes: [ + { fields: ['code'], unique: 'organization' }, + ], + + // `validations` is the server-enforced channel: objectql's rule validator runs + // it on insert, by-id update and bulk update (ADR-0049 declared = enforced). + validations: [ + { + // U3: the organization namespace. An absent value is left to `required`. + type: 'format', + name: 'unit_code_organization_namespace', + field: 'code', + regex: ORGANIZATION_UNIT_CODE_PATTERN, + severity: 'error', + message: + 'A unit code is uppercase letters, digits and underscores, at least 4 characters long or containing an underscore (for example BOX_12 or JIN1). ' + + 'Shorter codes are reserved for the standard units.', + }, + { + // L1: a unit's code is immutable after create. `cross_field` so the + // refusal is attached to the field it is about. + type: 'cross_field', + name: 'unit_code_immutable', + events: ['update'], + condition: 'previous != null && record.code != previous.code', + fields: ['code'], + severity: 'error', + message: "A unit's code cannot be changed after it is created. Create a new unit with the new code instead.", + }, + { + // L1: a unit's dimension is immutable after create. + type: 'cross_field', + name: 'unit_dimension_immutable', + events: ['update'], + condition: 'previous != null && record.dimension != previous.dimension', + fields: ['dimension'], + severity: 'error', + message: "A unit's dimension cannot be changed after it is created. Create a new unit with the new dimension instead.", + }, + { + // U1's shape: a ratio dimension carries a ratio. + type: 'cross_field', + name: 'unit_ratio_required', + condition: "record.dimension != 'package' && record.ratio == null", + fields: ['ratio'], + severity: 'error', + message: 'Enter the ratio to the base unit of this dimension.', + }, + { + // U1's shape: a package unit carries no ratio. + type: 'cross_field', + name: 'unit_package_has_no_ratio', + condition: "record.dimension == 'package' && record.ratio != null", + fields: ['ratio'], + severity: 'error', + message: 'A package unit has no ratio: how much a package holds belongs to the item, not to the unit. Clear the ratio.', + }, + { + // Open item 11: retiring is one-way, like the delete it stands for. + type: 'cross_field', + name: 'unit_retired_one_way', + events: ['update'], + condition: 'previous != null && previous.retired == true && record.retired != true', + fields: ['retired'], + severity: 'error', + message: 'A retired unit cannot be brought back. Create a unit with a new code instead.', + }, + ], + + listViews: { + all_units: { + type: 'grid', + name: 'all_units', + label: 'All', + description: UNIT_RATIO_DIRECTION, + data: { provider: 'object', object: 'sys_unit' }, + columns: ['code', 'label', 'dimension', 'ratio', 'decimal_places', 'retired'], + sort: [ + { field: 'dimension', order: 'asc' }, + { field: 'code', order: 'asc' }, + ], + pagination: { pageSize: 50 }, + emptyState: { + title: 'No units of measure yet', + message: + 'Standard units such as kilogram (KGM) and piece (H87) are available already. Add a unit here only when your organization needs one they do not cover.', + }, + }, + }, + + enable: { + trackHistory: true, + searchable: false, + apiEnabled: true, + // Retiring is the delete (Open item 11): the generic data API serves no + // delete, so no request can free a code. `bulk` batches only the verbs + // granted here (`bulk ∧ child`), so a batched delete is refused too. + apiMethods: ['get', 'list', 'create', 'update', 'bulk'], + // A unit is reference data, not a discussion surface. + feeds: false, + }, +}); diff --git a/packages/plugins/plugin-security/src/default-permission-sets.unit-of-measure.integration.test.ts b/packages/plugins/plugin-security/src/default-permission-sets.unit-of-measure.integration.test.ts new file mode 100644 index 00000000000..9ae3fdf8581 --- /dev/null +++ b/packages/plugins/plugin-security/src/default-permission-sets.unit-of-measure.integration.test.ts @@ -0,0 +1,258 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * [ADR-0158 U3; Open items 2 and 11] Who reads and writes an organization's + * units of measure, and what a write may do to one, on a real stack: + * + * - the REAL `SecurityPlugin` with the shipped permission sets, so a member's + * read comes from `member_default`'s `sys_unit` line and an administrator's + * writes from `organization_admin`'s wildcard; + * - the REAL `sys_unit` object (`@objectstack/platform-objects`), so the + * organization-scoped unique key and the object's `validations` are what + * the engine enforces; + * - the REAL caller resolution (`resolveAuthzContext`, then + * `assembleExecutionContext`) over the identity rows seeded below. + * + * What it holds: every member reads the units and writes none (the seat's U3 + * note; Open item 2); an organization administrator or owner creates, relabels + * and edits a ratio (L1); the organization code namespace (U3), the immutable + * code and dimension (L1) and the one-way retirement are refused through the + * engine's rule validator; and a retired code can never be created again, + * because the retired row keeps holding its organization-scoped unique key + * (Open item 11). + * + * Refusals assert the wire `code` AND `status` the data door maps the engine's + * error to (ADR-0112), and that nothing was stored. + */ + +import { describe, it, expect, beforeAll, afterAll } from 'vitest'; +import { ObjectKernel, resolveAuthzContext, assembleExecutionContext, type Plugin, type PluginContext } from '@objectstack/core'; +import { ObjectQL, ObjectQLPlugin } from '@objectstack/objectql'; +import { SqlDriver } from '@objectstack/driver-sql'; +import { SysMember, SysOrganization, SysUser } from '@objectstack/platform-objects/identity'; +import { SysUnit } from '@objectstack/platform-objects/system'; +import { mapDataError } from '@objectstack/types'; +import { SecurityPlugin } from './security-plugin.js'; +import { defaultPermissionSets } from './objects/default-permission-sets.js'; + +const OBJ = 'sys_unit'; +const ORG = 'org_units'; +const ALICE = 'usr_units_alice'; +const CAROL = 'usr_units_carol'; +const OWEN = 'usr_units_owen'; + +const SYS = { isSystem: true, tenantId: ORG } as const; + +type Row = Record; +type Ctx = Record; + +function sqliteDriverPlugin(): Plugin { + return { + name: 'test.driver.sqlite', + type: 'standard', + version: '1.0.0', + async init(ctx: PluginContext) { + ctx.registerService( + 'driver.default', + new SqlDriver({ client: 'better-sqlite3', connection: { filename: ':memory:' }, useNullAsDefault: true }), + ); + }, + }; +} + +function objectsPlugin(): Plugin { + return { + name: 'test.objects', + type: 'standard', + version: '1.0.0', + dependencies: ['com.objectstack.engine.objectql'], + async init(ctx: PluginContext) { + ctx.getService<{ register(m: unknown): unknown }>('manifest').register({ + id: 'test.unit-of-measure-grants', + namespace: 'units', + version: '1.0.0', + type: 'plugin', + name: 'Unit of measure grants fixture', + objects: [SysUser, SysMember, SysOrganization, SysUnit], + }); + }, + }; +} + +/** The wire answer a refused engine call maps to, as the data door sends it. */ +async function refusal(run: () => Promise): Promise<{ status: number; code: string }> { + let thrown: unknown; + try { + await run(); + } catch (e) { + thrown = e; + } + expect(thrown, `the ${OBJ} call was refused`).toBeDefined(); + const wire = mapDataError(thrown, OBJ); + return { status: wire.status, code: String(wire.body.code) }; +} + +/** A validation refusal: the wire envelope, and which field failed which constraint (the rule that fired). */ +async function invalid(run: () => Promise): Promise<{ status: number; code: string; fields: string[] }> { + let thrown: unknown; + try { + await run(); + } catch (e) { + thrown = e; + } + expect(thrown, `the ${OBJ} write was refused`).toBeDefined(); + const wire = mapDataError(thrown, OBJ); + const fields = ((wire.body as { fields?: Array<{ field: string; code: string }> }).fields ?? []).map((f) => `${f.field}:${f.code}`); + return { status: wire.status, code: String(wire.body.code), fields }; +} + +const FAILED = (...fields: string[]) => ({ status: 400, code: 'VALIDATION_FAILED', fields }); + +describe('sys_unit on a real stack: member read, administrator write, and the rules a write meets', () => { + let kernel: ObjectKernel; + let ql: ObjectQL; + const as: Record = {}; + let seeded = ''; + + const contextOf = async (userId: string): Promise => { + const authz = await resolveAuthzContext({ + ql, + headers: {}, + getSession: async () => ({ + user: { id: userId }, + session: { id: `ses_${userId}`, userId, activeOrganizationId: ORG }, + }), + } as never); + return assembleExecutionContext({ + authz, + oauth: undefined, + localization: undefined, + requestLocale: undefined, + accessToken: undefined, + } as never) as unknown as Ctx; + }; + + const insert = (ctx: Ctx, data: Row) => ql.insert(OBJ, data, { context: ctx } as never) as Promise; + const update = (ctx: Ctx, id: string, data: Row) => ql.update(OBJ, data, { where: { id }, context: ctx } as never); + const list = async (ctx: Ctx) => (await ql.find(OBJ, { context: ctx } as never)) as Row[]; + const stored = async (where: Row) => (await ql.find(OBJ, { where, context: SYS } as never)) as Row[]; + const storedById = async (id: string) => (await stored({ id }))[0]; + + beforeAll(async () => { + kernel = new ObjectKernel({ logger: { level: 'silent' } }); + await kernel.use(sqliteDriverPlugin()); + await kernel.use(new ObjectQLPlugin()); + await kernel.use(objectsPlugin()); + await kernel.use(new SecurityPlugin({ defaultPermissionSets })); + await kernel.bootstrap(); + ql = kernel.getService('objectql'); + + await ql.insert('sys_organization', { id: ORG, name: 'Units Co', slug: 'units-co' }, { context: SYS } as never); + const role: Record = { [ALICE]: 'member', [CAROL]: 'admin', [OWEN]: 'owner' }; + for (const userId of Object.keys(role)) { + await ql.insert( + 'sys_user', + { id: userId, name: userId, email: `${userId}@units-co.test`, email_verified: true }, + { context: SYS } as never, + ); + await ql.insert('sys_member', { user_id: userId, organization_id: ORG, role: role[userId] }, { context: SYS } as never); + } + for (const [key, userId] of [['alice', ALICE], ['carol', CAROL], ['owen', OWEN]] as const) as[key] = await contextOf(userId); + seeded = String( + (await insert(as.carol, { code: 'JIN1', label: 'Jin', dimension: 'mass', ratio: 0.5 })).id, + ); + }, 120_000); + + afterAll(async () => { + if (kernel) await Promise.race([kernel.shutdown(), new Promise((r) => setTimeout(r, 10_000))]); + }, 30_000); + + it('the fixture is armed: each persona holds the position this suite is about', () => { + expect(as.alice.positions).toEqual(expect.arrayContaining(['org_member', 'everyone'])); + expect(as.carol.positions).toEqual(expect.arrayContaining(['org_admin', 'everyone'])); + expect(as.owen.positions).toEqual(expect.arrayContaining(['org_owner', 'everyone'])); + expect(as.carol.positions).not.toContain('org_member'); + }); + + describe('a member', () => { + it("reads the organization's units, so a quantity's unit label displays to them", async () => { + const rows = await list(as.alice); + expect(rows.map((r) => r.code)).toContain('JIN1'); + }); + + it('creates none: 403 PERMISSION_DENIED, nothing stored', async () => { + expect(await refusal(() => insert(as.alice, { code: 'MEMBER_UNIT', label: 'Mine', dimension: 'count', ratio: 1 }))).toEqual({ + status: 403, + code: 'PERMISSION_DENIED', + }); + expect(await stored({ code: 'MEMBER_UNIT' })).toEqual([]); + }); + + it('edits none, the ratio included: 403 PERMISSION_DENIED, the row unchanged', async () => { + expect(await refusal(() => update(as.alice, seeded, { ratio: 2 }))).toEqual({ status: 403, code: 'PERMISSION_DENIED' }); + expect(await refusal(() => update(as.alice, seeded, { label: 'Renamed' }))).toEqual({ status: 403, code: 'PERMISSION_DENIED' }); + expect(await storedById(seeded)).toMatchObject({ label: 'Jin', ratio: 0.5 }); + }); + }); + + for (const key of ['carol', 'owen'] as const) { + describe(`an organization ${key === 'carol' ? 'administrator' : 'owner'}`, () => { + it('creates a unit, relabels it and edits its ratio', async () => { + const code = `BOX_${key.toUpperCase()}`; + const id = String((await insert(as[key], { code, label: 'Box', dimension: 'count', ratio: 12 })).id); + await update(as[key], id, { label: 'Box of 12' }); + await update(as[key], id, { ratio: 10 }); + // Stamped with the writer's organization: the row is the organization's (U3). + expect(await storedById(id)).toMatchObject({ code, label: 'Box of 12', dimension: 'count', ratio: 10, retired: false, organization_id: ORG }); + }); + }); + } + + describe('the rules a write meets', () => { + for (const code of ['KGM', 'H87', 'C62', 'EA', 'box_12']) { + it(`refuses the code ${code} outside the organization namespace: 400 VALIDATION_FAILED on code, nothing stored`, async () => { + expect(await invalid(() => insert(as.carol, { code, label: 'Taken', dimension: 'count', ratio: 1 }))).toEqual( + FAILED('code:invalid_format'), + ); + expect(await stored({ code })).toEqual([]); + }); + } + + it('refuses changing a code or a dimension: 400 VALIDATION_FAILED on that field, the row unchanged', async () => { + expect(await invalid(() => update(as.carol, seeded, { code: 'JIN2' }))).toEqual(FAILED('code:rule_violation')); + expect(await invalid(() => update(as.carol, seeded, { dimension: 'volume' }))).toEqual(FAILED('dimension:rule_violation')); + expect(await storedById(seeded)).toMatchObject({ code: 'JIN1', dimension: 'mass' }); + }); + + it('refuses a ratio dimension with no ratio and a package unit with one: 400 VALIDATION_FAILED on ratio', async () => { + expect(await invalid(() => insert(as.carol, { code: 'NO_RATIO', label: 'x', dimension: 'length' }))).toEqual( + FAILED('ratio:rule_violation'), + ); + expect(await invalid(() => insert(as.carol, { code: 'CRATE_X', label: 'x', dimension: 'package', ratio: 4 }))).toEqual( + FAILED('ratio:rule_violation'), + ); + expect(await stored({ code: 'NO_RATIO' })).toEqual([]); + expect(await stored({ code: 'CRATE_X' })).toEqual([]); + const pallet = String((await insert(as.carol, { code: 'PALLET_EU', label: 'Euro pallet', dimension: 'package' })).id); + expect(await storedById(pallet)).toMatchObject({ dimension: 'package', ratio: null }); + }); + }); + + describe('a retired code stays retired (Open item 11)', () => { + it('retires a unit, refuses bringing it back, and refuses creating its code again', async () => { + const id = String((await insert(as.carol, { code: 'SACK_50', label: 'Sack', dimension: 'mass', ratio: 50 })).id); + await update(as.carol, id, { retired: true }); + expect((await storedById(id))?.retired).toBe(true); + + expect(await invalid(() => update(as.carol, id, { retired: false }))).toEqual(FAILED('retired:rule_violation')); + expect((await storedById(id))?.retired).toBe(true); + + // The same code with another dimension, ratio and label: the hazard + // ADR-0158 Open item 11 names. The retired row holds the key. + const again = await refusal(() => insert(as.carol, { code: 'SACK_50', label: 'Sack (new)', dimension: 'volume', ratio: 0.05 })); + expect(again).toEqual({ status: 409, code: 'UNIQUE_VIOLATION' }); + expect(await stored({ code: 'SACK_50' })).toHaveLength(1); + expect((await storedById(id))).toMatchObject({ label: 'Sack', dimension: 'mass', ratio: 50, retired: true }); + }); + }); +}); diff --git a/packages/plugins/plugin-security/src/objects/default-permission-sets.ts b/packages/plugins/plugin-security/src/objects/default-permission-sets.ts index 841439950bb..c1199f6f844 100644 --- a/packages/plugins/plugin-security/src/objects/default-permission-sets.ts +++ b/packages/plugins/plugin-security/src/objects/default-permission-sets.ts @@ -897,6 +897,22 @@ const baseDefaultPermissionSets: PermissionSet[] = [ // `sys_approval_action` and `sys_approval_approver` are not named. An // external member resolves `external_default` and gets no such line. sys_approval_request: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false }, + // [ADR-0158 U3, the owning seat's settlement under U3] The organization's + // own units of measure, READ only, so the label of a quantity's unit + // displays to every member who reads the quantity. A new read grant on + // this baseline, ruled for this object alone: `sys_exchange_rate`'s + // posture (no member line at all) is deliberately not copied. + // + // ⛔ No row policy: every row of this object is reference data of the + // member's own organization, and Layer 0, the tenant wall (ADR-0095 D1), + // already confines a read to it. ⛔ No write bit (ADR-0158 Open item 2): + // organization administrators create, edit and retire units through + // `organization_admin`'s wildcard grant; a unit's ratio is an admin act + // (L1). No `allowDelete` either way: the object serves no delete, since + // retiring is its delete (Open item 11), and this set is anchor-safe + // (ADR-0090 D5). An external member resolves `external_default` and gets + // no such line. + sys_unit: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false }, }, // [#21237] The identity object's `Admin` group is admin-review data, not a // staff directory: `sys_user_org_members` below opens every org peer's row, diff --git a/packages/spec/api-surface/data.json b/packages/spec/api-surface/data.json index d69183d4b25..42f6dda4262 100644 --- a/packages/spec/api-surface/data.json +++ b/packages/spec/api-surface/data.json @@ -560,6 +560,7 @@ "NumericStringReading (type)", "OBJECT_KEY_GUIDANCE (const)", "ORACLE_DEFAULT_PORT (const)", + "ORGANIZATION_UNIT_CODE_PATTERN (const)", "OWNER_FIELD_DEF (const)", "OWNING_BUSINESS_UNIT_FIELD_DEF (const)", "ObjectAccessConfig (type)", @@ -686,6 +687,7 @@ "RPC_QUERY_ALIAS_SLOTS (const)", "RUNTIME_OWNED_FIELD_TYPES (const)", "RangeOperatorSchema (const)", + "RatioUnitDimension (type)", "ReadableIds (const)", "ReadableIds (interface)", "ReadableIdsCase (type)", @@ -765,6 +767,7 @@ "SSL_DETAIL_BELONGS_ON_DATASOURCE (const)", "STACK_KEY_GUIDANCE (const)", "STACK_RUNTIME_MEMBERS (const)", + "STANDARD_UNITS (const)", "STRING_STORED_COMPARAND_DOOR_FAMILIES (const)", "STRING_STORED_COMPARAND_DOOR_LIST_OPERATORS (const)", "STRING_STORED_COMPARAND_DOOR_SCALAR_OPERATORS (const)", @@ -838,6 +841,7 @@ "SqliteWasmConfigSchema (const)", "SqliteWasmPersistMode (type)", "SqliteWasmPersistModeSchema (const)", + "StandardUnit (type)", "StateMachineValidation (type)", "StateMachineValidationParsed (type)", "StateMachineValidationSchema (const)", @@ -895,6 +899,8 @@ "UNBOUNDED_ABOVE (const)", "UNIQUE_NULL_DISTINCT_CASES (const)", "UNIQUE_NULL_DISTINCT_OBJECTS (const)", + "UNIT_DIMENSIONS (const)", + "UNIT_DIMENSION_BASE_CODES (const)", "UNRESOLVED_PLACEHOLDER_REFUSED (const)", "URL_CREDENTIAL_QUERY_PARAM_REFUSED (const)", "URL_EMBEDDED_CREDENTIAL_REFUSED (const)", @@ -902,6 +908,7 @@ "UniqueNullDistinctCase (interface)", "UniqueScope (type)", "UniqueScopeSchema (const)", + "UnitDimension (type)", "UnknownAuthoringKeyFinding (interface)", "UnknownImportMappingTarget (interface)", "UnorderedPaginationConformanceCase (interface)", diff --git a/packages/spec/export-origins/data.json b/packages/spec/export-origins/data.json index aabb17a6b31..cc6aaf44e31 100644 --- a/packages/spec/export-origins/data.json +++ b/packages/spec/export-origins/data.json @@ -550,6 +550,7 @@ "NumericStringReading": "src/data/filter-number-comparand-declared-type.ts#NumericStringReading (type)", "OBJECT_KEY_GUIDANCE": "src/data/authoring-key-lint.ts#OBJECT_KEY_GUIDANCE (const)", "ORACLE_DEFAULT_PORT": "src/data/driver/oracle.zod.ts#ORACLE_DEFAULT_PORT (const)", + "ORGANIZATION_UNIT_CODE_PATTERN": "src/data/standard-units.ts#ORGANIZATION_UNIT_CODE_PATTERN (const)", "OWNER_FIELD_DEF": "src/data/injected-system-column-provenance.ts#OWNER_FIELD_DEF (const)", "OWNING_BUSINESS_UNIT_FIELD_DEF": "src/data/injected-system-column-provenance.ts#OWNING_BUSINESS_UNIT_FIELD_DEF (const)", "ObjectAccessConfig": "src/data/object.zod.ts#ObjectAccessConfig (type)", @@ -675,6 +676,7 @@ "RPC_QUERY_ALIAS_SLOTS": "src/data/data-engine.zod.ts#RPC_QUERY_ALIAS_SLOTS (const)", "RUNTIME_OWNED_FIELD_TYPES": "src/data/field.zod.ts#RUNTIME_OWNED_FIELD_TYPES (const)", "RangeOperatorSchema": "src/data/filter.zod.ts#RangeOperatorSchema (const)", + "RatioUnitDimension": "src/data/standard-units.ts#RatioUnitDimension (type)", "ReadableIds": "src/data/readable-ids.ts#ReadableIds (interface)", "ReadableIdsCase": "src/data/readable-ids-conformance.ts#ReadableIdsCase (type)", "ReadableIdsChildRow": "src/data/readable-ids-conformance.ts#ReadableIdsChildRow (interface)", @@ -753,6 +755,7 @@ "SSL_DETAIL_BELONGS_ON_DATASOURCE": "src/data/driver/common.zod.ts#SSL_DETAIL_BELONGS_ON_DATASOURCE (const)", "STACK_KEY_GUIDANCE": "src/data/authoring-key-lint.ts#STACK_KEY_GUIDANCE (const)", "STACK_RUNTIME_MEMBERS": "src/data/authoring-key-lint.ts#STACK_RUNTIME_MEMBERS (const)", + "STANDARD_UNITS": "src/data/standard-units.ts#STANDARD_UNITS (const)", "STRING_STORED_COMPARAND_DOOR_FAMILIES": "src/data/filter-string-stored-comparand-declared-type.ts#STRING_STORED_COMPARAND_DOOR_FAMILIES (const)", "STRING_STORED_COMPARAND_DOOR_LIST_OPERATORS": "src/data/filter-string-stored-comparand-declared-type.ts#STRING_STORED_COMPARAND_DOOR_LIST_OPERATORS (const)", "STRING_STORED_COMPARAND_DOOR_SCALAR_OPERATORS": "src/data/filter-string-stored-comparand-declared-type.ts#STRING_STORED_COMPARAND_DOOR_SCALAR_OPERATORS (const)", @@ -826,6 +829,7 @@ "SqliteWasmConfigSchema": "src/data/driver/sqlite.zod.ts#SqliteWasmConfigSchema (const)", "SqliteWasmPersistMode": "src/data/driver/sqlite.zod.ts#SqliteWasmPersistMode (type)", "SqliteWasmPersistModeSchema": "src/data/driver/sqlite.zod.ts#SqliteWasmPersistModeSchema (const)", + "StandardUnit": "src/data/standard-units.ts#StandardUnit (type)", "StateMachineValidation": "src/data/validation.zod.ts#StateMachineValidation (type)", "StateMachineValidationParsed": "src/data/validation.zod.ts#StateMachineValidationParsed (type)", "StateMachineValidationSchema": "src/data/validation.zod.ts#StateMachineValidationSchema (const)", @@ -881,6 +885,8 @@ "UNBOUNDED_ABOVE": "src/data/calendar-day.ts#UNBOUNDED_ABOVE (const)", "UNIQUE_NULL_DISTINCT_CASES": "src/data/unique-null-distinct-conformance.ts#UNIQUE_NULL_DISTINCT_CASES (const)", "UNIQUE_NULL_DISTINCT_OBJECTS": "src/data/unique-null-distinct-conformance.ts#UNIQUE_NULL_DISTINCT_OBJECTS (const)", + "UNIT_DIMENSIONS": "src/data/standard-units.ts#UNIT_DIMENSIONS (const)", + "UNIT_DIMENSION_BASE_CODES": "src/data/standard-units.ts#UNIT_DIMENSION_BASE_CODES (const)", "UNRESOLVED_PLACEHOLDER_REFUSED": "src/data/driver/common.zod.ts#UNRESOLVED_PLACEHOLDER_REFUSED (const)", "URL_CREDENTIAL_QUERY_PARAM_REFUSED": "src/data/driver/common.zod.ts#URL_CREDENTIAL_QUERY_PARAM_REFUSED (const)", "URL_EMBEDDED_CREDENTIAL_REFUSED": "src/data/driver/common.zod.ts#URL_EMBEDDED_CREDENTIAL_REFUSED (const)", @@ -888,6 +894,7 @@ "UniqueNullDistinctCase": "src/data/unique-null-distinct-conformance.ts#UniqueNullDistinctCase (interface)", "UniqueScope": "src/data/field.zod.ts#UniqueScope (type)", "UniqueScopeSchema": "src/data/field.zod.ts#UniqueScopeSchema (const)", + "UnitDimension": "src/data/standard-units.ts#UnitDimension (type)", "UnknownAuthoringKeyFinding": "src/data/authoring-key-lint.ts#UnknownAuthoringKeyFinding (interface)", "UnknownImportMappingTarget": "src/data/import-mapping-target.ts#UnknownImportMappingTarget (interface)", "UnorderedPaginationConformanceCase": "src/data/pagination-conformance.ts#UnorderedPaginationConformanceCase (interface)", diff --git a/packages/spec/src/data/index.ts b/packages/spec/src/data/index.ts index b32ed5b7492..324e35cff97 100644 --- a/packages/spec/src/data/index.ts +++ b/packages/spec/src/data/index.ts @@ -213,6 +213,11 @@ export * from './field-customization'; // home currency's CLDR fraction digits with it, from this one table rather // than a second copy or a runtime `Intl` probe. export * from './currency-fraction-digits'; +// [ADR-0158 U1, U2; Open item 1] The standard unit table: the closed set of +// UN/ECE Recommendation 20 codes with each one's dimension and its ratio to the +// dimension's base unit, kept apart from the value-domain vocabulary the way +// the CLDR digits table is, and the organization unit code namespace (U3). +export * from './standard-units'; // The credential read mask (ADR-0100) — the ONE string a masked read serves, in // place of the two byte-identical literals objectql and service-settings each // declared until #7572. Both now import this one, so the mask a console sees on diff --git a/packages/spec/src/data/standard-units.test.ts b/packages/spec/src/data/standard-units.test.ts new file mode 100644 index 00000000000..cd9ddba2887 --- /dev/null +++ b/packages/spec/src/data/standard-units.test.ts @@ -0,0 +1,125 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { describe, it, expect } from 'vitest'; +import { + ORGANIZATION_UNIT_CODE_PATTERN, + STANDARD_UNITS, + UNIT_DIMENSIONS, + UNIT_DIMENSION_BASE_CODES, + type StandardUnit, +} from './standard-units'; +import { ValueDomainSchema } from '../shared/value-domain.zod'; + +/** + * ADR-0158 U1, U2 and U3's namespace, with the membership its Open item 1 + * settles. The table is closed, so its membership is pinned by name: a code + * added or dropped is an amendment of the ADR, and this list moves with it. + */ +const has = (code: string): boolean => Object.prototype.hasOwnProperty.call(STANDARD_UNITS, code); +const orgCode = new RegExp(ORGANIZATION_UNIT_CODE_PATTERN); + +describe('STANDARD_UNITS — the closed standard unit table (ADR-0158 U1)', () => { + it('holds exactly the settled membership, per dimension', () => { + const byDimension: Record = {}; + for (const [code, unit] of Object.entries(STANDARD_UNITS)) (byDimension[unit.dimension] ??= []).push(code); + for (const codes of Object.values(byDimension)) codes.sort(); + expect(byDimension).toEqual({ + mass: ['GRM', 'KGM', 'LBR', 'MGM', 'ONZ', 'TNE'], + length: ['CMT', 'FOT', 'INH', 'KMT', 'MMT', 'MTR', 'YRD'], + area: ['CMK', 'FTK', 'MMK', 'MTK'], + volume: ['GLL', 'LTR', 'MLT', 'MTQ'], + time: ['DAY', 'HUR', 'MIN', 'SEC', 'WEE'], + count: ['DZN', 'H87', 'PR'], + package: ['XBE', 'XBG', 'XBO', 'XBX', 'XCR', 'XCS', 'XCT', 'XDR', 'XPK', 'XPX', 'XRO', 'XSA'], + }); + expect(Object.keys(STANDARD_UNITS)).toHaveLength(41); + }); + + it('admits the piece as H87 and refuses its near-synonyms C62 and EA (U2)', () => { + expect(STANDARD_UNITS.H87).toEqual({ dimension: 'count', ratio: '1' }); + expect(has('C62')).toBe(false); + expect(has('EA')).toBe(false); + }); + + it('leaves out the deprecated hectare and the inexact month and year', () => { + for (const code of ['HAR', 'MON', 'ANN']) expect(has(code), code).toBe(false); + }); + + it('is closed: a lowercase spelling, an unknown code and an inherited name are not members', () => { + for (const code of ['kgm', 'Kgm', 'ZZZ', 'constructor', 'toString', '__proto__']) expect(has(code), code).toBe(false); + expect(Object.isFrozen(STANDARD_UNITS)).toBe(true); + }); + + it('keys every code in exact uppercase, at most three letters or digits (the Recommendation 20 code shape)', () => { + for (const code of Object.keys(STANDARD_UNITS)) expect(code, code).toMatch(/^[A-Z0-9]{2,3}$/); + }); + + it('is not a value domain: the 2026-09-02 vocabulary keeps its three members', () => { + expect([...ValueDomainSchema.options].sort()).toEqual(['iana_time_zone', 'iso_3166_alpha2', 'iso_4217_currency']); + }); +}); + +describe('dimensions and ratios (ADR-0158 Open item 1)', () => { + const ratioDimensions = UNIT_DIMENSIONS.filter((d) => d !== 'package'); + + it('names seven dimensions, and a base unit for each but package', () => { + expect([...UNIT_DIMENSIONS]).toEqual(['mass', 'length', 'area', 'volume', 'time', 'count', 'package']); + expect(Object.keys(UNIT_DIMENSION_BASE_CODES).sort()).toEqual([...ratioDimensions].sort()); + expect(UNIT_DIMENSION_BASE_CODES).toEqual({ + mass: 'KGM', length: 'MTR', area: 'MTK', volume: 'MTQ', time: 'SEC', count: 'H87', + }); + }); + + it('gives every base unit its own dimension and the ratio 1', () => { + for (const [dimension, code] of Object.entries(UNIT_DIMENSION_BASE_CODES)) { + expect(STANDARD_UNITS[code], code).toEqual({ dimension, ratio: '1' }); + } + }); + + it('carries a ratio on every ratio dimension and none on a package code', () => { + for (const [code, unit] of Object.entries(STANDARD_UNITS) as Array<[string, StandardUnit & { ratio?: unknown }]>) { + if (unit.dimension === 'package') { + expect(code, code).toMatch(/^X/); + expect('ratio' in unit, code).toBe(false); + } else { + expect(typeof unit.ratio, code).toBe('string'); + } + } + }); + + it('spells every ratio as a positive decimal string, at most 12 places, no trailing zero — never a float', () => { + for (const [code, unit] of Object.entries(STANDARD_UNITS)) { + if (unit.dimension === 'package') continue; + expect(unit.ratio, code).toMatch(/^(?:0|[1-9][0-9]*)(?:\.[0-9]{0,11}[1-9])?$/); + expect(Number(unit.ratio) > 0, code).toBe(true); + } + }); + + it('holds the exact definitions where Recommendation 20 prints a rounded factor', () => { + // 1/16 of the 1959 pound, and 231 cubic inches of the 1959 inch, by exact + // decimal arithmetic. Recommendation 20 prints 2.834 952 × 10⁻² kg and + // 3.785 412 × 10⁻³ m³. + expect(STANDARD_UNITS.LBR).toEqual({ dimension: 'mass', ratio: '0.45359237' }); + expect(STANDARD_UNITS.ONZ).toEqual({ dimension: 'mass', ratio: '0.028349523125' }); + expect(STANDARD_UNITS.INH).toEqual({ dimension: 'length', ratio: '0.0254' }); + expect(STANDARD_UNITS.GLL).toEqual({ dimension: 'volume', ratio: '0.003785411784' }); + }); +}); + +describe('ORGANIZATION_UNIT_CODE_PATTERN — the organization code namespace (ADR-0158 U3)', () => { + it('admits a code of at least four characters, or one containing an underscore', () => { + for (const code of ['BOX12', 'JIN1', 'BAG_25KG', 'A_B', 'AB_', 'A_', 'P_1', '1234', 'X'.repeat(32)]) { + expect(orgCode.test(code), code).toBe(true); + } + }); + + it('refuses a short code with no underscore, a lowercase or spaced code, and an over-long one', () => { + for (const code of ['KGM', 'XBX', 'AB', 'A', '', 'jin1', 'Box12', 'BAG 25', 'BAG-25', '_ABC', '__', 'X'.repeat(33)]) { + expect(orgCode.test(code), code).toBe(false); + } + }); + + it('can never match a standard code, so an organization code never collides with one', () => { + for (const code of Object.keys(STANDARD_UNITS)) expect(orgCode.test(code), code).toBe(false); + }); +}); diff --git a/packages/spec/src/data/standard-units.ts b/packages/spec/src/data/standard-units.ts new file mode 100644 index 00000000000..d56df7f2676 --- /dev/null +++ b/packages/spec/src/data/standard-units.ts @@ -0,0 +1,194 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The standard unit table — ADR-0158 U1 and U2, membership settled by its + * Open item 1. + * + * A closed, checked-in table of UN/ECE Recommendation 20 common codes. Each + * code carries its DIMENSION and its RATIO to that dimension's base unit; + * package codes (Recommendation 21, admitted through the Recommendation 20 + * annex with the `X` prefix) carry the `package` dimension and no ratio. The + * table is three things at once (U1): the build-time oracle for a fixed-unit + * field, the source of truth for standard codes, and a pure conversion table. + * + * It is a separate table, the way `CURRENCY_FRACTION_DIGITS` is + * (`./currency-fraction-digits.ts`), and NOT a member of `ValueDomainSchema`: + * the value-domain vocabulary of 2026-09-02 stays closed (U1). Organization + * units live in the `sys_unit` object (U3), never here, and an organization + * code cannot collide with a code of this table: see + * {@link ORGANIZATION_UNIT_CODE_PATTERN}. + * + * ## The ratio, as arithmetic + * + * `1 CODE = ratio × BASE`, where BASE is {@link UNIT_DIMENSION_BASE_CODES} of + * the code's dimension. So GRM's ratio `0.001` says 1 gram = 0.001 kilogram, + * and a quantity in grams is converted to the base unit by MULTIPLYING it by + * the ratio. A base code's own ratio is `1`. + * + * Every ratio is a decimal STRING with at most 12 places and no trailing + * zero, never a JavaScript number: a float cannot hold 0.45359237 or + * 0.028349523125 exactly, and U7 R2 rules ratios "decimal, scale 12, never + * float". Every ratio below is exact by definition; none is rounded. + * + * ## Membership (ADR-0158 Open item 1) + * + * Seven dimensions, kept small on purpose: mass, length, area, volume and + * time (the coherent SI units are their bases), count (base: piece, `H87`, + * U2) and package. A code earns its place by being one an order line, a + * bill of material or a delivery note actually writes; the table widens by an + * amendment of ADR-0158, never by a reader's convenience. + * + * - **U2.** The piece is `H87`. Its near-synonyms `C62` ("one") and `EA` + * ("each") are NOT members, and no row may add them back. + * - **Active codes only.** No code whose Recommendation 20 status is `D` + * (deprecated) or `X` (deleted). Hectare (`HAR`) is the one common code + * this excludes: Recommendation 20 marks it deprecated. + * - **Exact ratios only.** Month (`MON`) and year (`ANN`) are left out: + * Recommendation 20 defines them through a 365.25-day year, which no + * calendar month or year equals, so a ratio would convert a quantity to a + * number nobody means. A quantity in months stays an organization unit or + * a package-like count until a ruling says otherwise. + * - **Affine units** such as degrees Celsius are not members (U7 R2 excludes + * them from ratio conversion). + * + * ## Sources, per ratio + * + * | Source | Codes | + * |:---|:---| + * | SI prefixes (SI Brochure, 9th edition, 2019, Table 7) | GRM, MGM, MMT, CMT, KMT, CMK, MMK, MLT | + * | Units accepted for use with the SI (SI Brochure, 9th edition, Table 8) | TNE, LTR, MIN, HUR, DAY | + * | International yard and pound (1959): yard = 0.9144 m, pound = 0.45359237 kg | LBR, INH (1/36 yd), FOT (1/3 yd), YRD, FTK (1 ft²), ONZ (1/16 lb) | + * | United States gallon = 231 cubic inches | GLL | + * | Recommendation 20's own factor | WEE (7 days), PR (2), DZN (12) | + * + * Where Recommendation 20 prints a ROUNDED factor, the exact definition wins + * and is what the table holds: ONZ (Rec 20: 2.834 952 × 10⁻² kg; exact: + * 0.028349523125) and GLL (Rec 20: 3.785 412 × 10⁻³ m³; exact: + * 0.003785411784). Every other factor here equals Recommendation 20's. + * + * ## Provenance — read, not recalled + * + * Codes, names, statuses and factors were read on 2026-11-19 from the + * Recommendation 20 annex as published in the `datasets/unece-units-of-measure` + * mirror (data package version 17.0, `data/units-of-measure.csv`, its + * `Status` and `ConversionFactor` columns), and the package codes from the + * Peppol BIS Billing 3.0 code list `UNECERec20` ("Recommendation 20, including + * Recommendation 21 codes - prefixed with X", Revision 11e). Each package code + * below carries the Recommendation 21 name in its comment. + */ + +/** + * The closed dimension vocabulary of the standard unit table (ADR-0158 Open + * item 1). `package` is the dimension of the Recommendation 21 package codes, + * which take no ratio; every other dimension has a base unit + * ({@link UNIT_DIMENSION_BASE_CODES}). + */ +export const UNIT_DIMENSIONS = ['mass', 'length', 'area', 'volume', 'time', 'count', 'package'] as const; + +/** One of {@link UNIT_DIMENSIONS}. */ +export type UnitDimension = (typeof UNIT_DIMENSIONS)[number]; + +/** A dimension whose units convert by ratio: every dimension but `package`. */ +export type RatioUnitDimension = Exclude; + +/** + * The base unit of each ratio dimension: the code whose ratio is `1`, and the + * unit a ratio converts into (`1 CODE = ratio × BASE`). The five measured + * dimensions take the coherent SI unit; count takes the piece (U2). + */ +export const UNIT_DIMENSION_BASE_CODES: Readonly> = Object.freeze({ + mass: 'KGM', + length: 'MTR', + area: 'MTK', + volume: 'MTQ', + time: 'SEC', + count: 'H87', +}); + +/** + * One entry of {@link STANDARD_UNITS}: a ratio dimension with its ratio to the + * dimension's base unit (a decimal string, at most 12 places), or the + * `package` dimension with no ratio. + */ +export type StandardUnit = + | { readonly dimension: RatioUnitDimension; readonly ratio: string } + | { readonly dimension: 'package' }; + +/** + * The standard unit table (ADR-0158 U1, U2; membership: Open item 1). Keyed + * by the Recommendation 20 common code, in exact uppercase. Closed: a code + * absent here is not a standard unit (an organization adds its own through + * `sys_unit`, U3). + */ +export const STANDARD_UNITS: Readonly> = Object.freeze({ + // Mass. Base: kilogram. + KGM: { dimension: 'mass', ratio: '1' }, // kilogram + GRM: { dimension: 'mass', ratio: '0.001' }, // gram + MGM: { dimension: 'mass', ratio: '0.000001' }, // milligram + TNE: { dimension: 'mass', ratio: '1000' }, // tonne (metric ton) + LBR: { dimension: 'mass', ratio: '0.45359237' }, // pound + ONZ: { dimension: 'mass', ratio: '0.028349523125' }, // ounce (avoirdupois) + + // Length. Base: metre. + MTR: { dimension: 'length', ratio: '1' }, // metre + MMT: { dimension: 'length', ratio: '0.001' }, // millimetre + CMT: { dimension: 'length', ratio: '0.01' }, // centimetre + KMT: { dimension: 'length', ratio: '1000' }, // kilometre + INH: { dimension: 'length', ratio: '0.0254' }, // inch + FOT: { dimension: 'length', ratio: '0.3048' }, // foot + YRD: { dimension: 'length', ratio: '0.9144' }, // yard + + // Area. Base: square metre. + MTK: { dimension: 'area', ratio: '1' }, // square metre + CMK: { dimension: 'area', ratio: '0.0001' }, // square centimetre + MMK: { dimension: 'area', ratio: '0.000001' }, // square millimetre + FTK: { dimension: 'area', ratio: '0.09290304' }, // square foot + + // Volume. Base: cubic metre. + MTQ: { dimension: 'volume', ratio: '1' }, // cubic metre + LTR: { dimension: 'volume', ratio: '0.001' }, // litre + MLT: { dimension: 'volume', ratio: '0.000001' }, // millilitre + GLL: { dimension: 'volume', ratio: '0.003785411784' }, // gallon (US) + + // Time. Base: second. + SEC: { dimension: 'time', ratio: '1' }, // second + MIN: { dimension: 'time', ratio: '60' }, // minute + HUR: { dimension: 'time', ratio: '3600' }, // hour + DAY: { dimension: 'time', ratio: '86400' }, // day + WEE: { dimension: 'time', ratio: '604800' }, // week + + // Count. Base: piece (U2). + H87: { dimension: 'count', ratio: '1' }, // piece + PR: { dimension: 'count', ratio: '2' }, // pair + DZN: { dimension: 'count', ratio: '12' }, // dozen + + // Package (Recommendation 21 through the Recommendation 20 annex). No ratio: + // how many pieces a box holds is the item's, read by R2 through a + // suite-supplied factor (U7 R2), never the code's. + XBG: { dimension: 'package' }, // Bag + XBE: { dimension: 'package' }, // Bundle + XBO: { dimension: 'package' }, // Bottle, non-protected, cylindrical + XBX: { dimension: 'package' }, // Box + XCT: { dimension: 'package' }, // Carton + XCS: { dimension: 'package' }, // Case + XCR: { dimension: 'package' }, // Crate + XDR: { dimension: 'package' }, // Drum + XPK: { dimension: 'package' }, // Package + XPX: { dimension: 'package' }, // Pallet + XRO: { dimension: 'package' }, // Roll + XSA: { dimension: 'package' }, // Sack +}); + +/** + * The organization unit code namespace (ADR-0158 U3), as a regular-expression + * source: uppercase letters, digits and underscores, starting with a letter or + * a digit, at most 32 characters, and EITHER at least 4 characters long OR + * containing an underscore. + * + * Every Recommendation 20 common code is at most three letters and digits with + * no underscore, so no standard code, in this table or added to it later, can + * match: an organization code never collides with one. `sys_unit` refuses a + * code outside this pattern on every write. + */ +export const ORGANIZATION_UNIT_CODE_PATTERN = + '^(?:[A-Z0-9][A-Z0-9_]{3,31}|[A-Z0-9](?:_[A-Z0-9_]?|[A-Z0-9]_))$'; diff --git a/packages/spec/src/system/constants/platform-object-names.ts b/packages/spec/src/system/constants/platform-object-names.ts index b66cf6552ab..170c8604967 100644 --- a/packages/spec/src/system/constants/platform-object-names.ts +++ b/packages/spec/src/system/constants/platform-object-names.ts @@ -99,6 +99,7 @@ export const PLATFORM_OBJECTS_BY_PACKAGE: Readonly