diff --git a/core/player/src/player.ts b/core/player/src/player.ts index b6b6ef6d2..5b47d795a 100644 --- a/core/player/src/player.ts +++ b/core/player/src/player.ts @@ -73,6 +73,10 @@ export interface ExtendedPlayerPlugin< Expressions = void, // eslint-disable-next-line @typescript-eslint/no-unused-vars DataTypes = void, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + Formatters = void, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + Validators = void, > {} export interface PlayerConfigOptions { diff --git a/package.json b/package.json index 388add6e1..eee4a9f1c 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,9 @@ "@docsearch/react": "3", "@eslint/js": "^9.22.0", "@monaco-editor/react": "^4.6.0", - "@player-tools/cli": "0.12.0", - "@player-tools/dsl": "0.12.0", - "@player-tools/xlr": "0.12.0", + "@player-tools/cli": "0.13.0--canary.242.6147", + "@player-tools/dsl": "0.13.0--canary.242.6147", + "@player-tools/xlr": "0.13.0--canary.242.6147", "@player-tools/xlr-utils": "0.6.1-next.2", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-separator": "^1.0.3", diff --git a/plugins/common-types/core/BUILD b/plugins/common-types/core/BUILD index d68839132..b9d564688 100644 --- a/plugins/common-types/core/BUILD +++ b/plugins/common-types/core/BUILD @@ -1,4 +1,4 @@ -load("@rules_player//javascript:defs.bzl", "js_pipeline") +load("@rules_player//player:defs.bzl", "js_xlr_pipeline") load("@npm//:defs.bzl", "npm_link_all_packages") load("//tools:defs.bzl", "NATIVE_BUILD_DEPS", "tsup_config", "vitest_config") @@ -8,7 +8,7 @@ tsup_config(name = "tsup_config") vitest_config(name = "vitest_config") -js_pipeline( +js_xlr_pipeline( package_name = "@player-ui/common-types-plugin", build_deps = NATIVE_BUILD_DEPS, native_bundle = "CommonTypesPlugin", diff --git a/plugins/common-types/core/src/index.ts b/plugins/common-types/core/src/index.ts index a63938009..7860a60f5 100644 --- a/plugins/common-types/core/src/index.ts +++ b/plugins/common-types/core/src/index.ts @@ -4,7 +4,7 @@ import { TypesProviderPlugin } from "@player-ui/types-provider-plugin"; import * as validators from "./validators"; import * as dataTypes from "./data-types/types"; import * as formats from "./formats"; -import type { +import { BooleanType, IntegerType, IntegerPosType, @@ -15,6 +15,25 @@ import type { PhoneType, } from "./data-types/types"; +import { commaNumber, currency, date, integer, phone } from "./formats/index"; + +import { + collection, + email, + expression, + integer as vinteger, + length, + max, + min, + oneOf, + phone as vphone, + readonly, + regex, + required, + string, + zip, +} from "./validators/index"; + export { validators, dataTypes, formats }; export * from "./formats/utils"; @@ -37,12 +56,35 @@ export class CommonTypesPlugin typeof CollectionType, typeof DateType, typeof PhoneType, + ], + [ + typeof commaNumber, + typeof currency, + typeof date, + typeof integer, + typeof phone, + ], + [ + typeof collection, + typeof email, + typeof expression, + typeof vinteger, + typeof length, + typeof max, + typeof min, + typeof oneOf, + typeof vphone, + typeof readonly, + typeof regex, + typeof required, + typeof string, + typeof zip, ] > { name = "CommonTypes"; - apply(player: Player) { + apply(player: Player): void { player.registerPlugin( new TypesProviderPlugin({ types: Object.values(dataTypes), diff --git a/plugins/common-types/core/src/validators/index.ts b/plugins/common-types/core/src/validators/index.ts index 0f9ac3d0b..8764aef94 100644 --- a/plugins/common-types/core/src/validators/index.ts +++ b/plugins/common-types/core/src/validators/index.ts @@ -347,21 +347,21 @@ const stringRegexValidator = ( }; /** Checks that the given value represents an email */ -export const email = stringRegexValidator( +export const email: ValidatorFunction = stringRegexValidator( EMAIL_REGEX, "validation.email", "Improper email format", ); /** Checks that the given value represents a phone number */ -export const phone = stringRegexValidator( +export const phone: ValidatorFunction = stringRegexValidator( PHONE_REGEX, "validation.phone", "Invalid phone number", ); /** Checks that the given value represents a phone number */ -export const zip = stringRegexValidator( +export const zip: ValidatorFunction = stringRegexValidator( ZIP_REGEX, "validation.regex", "Invalid zip code", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7c9345125..e27bfbf77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,14 +64,14 @@ importers: specifier: ^4.6.0 version: 4.7.0(monaco-editor@0.51.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@player-tools/cli': - specifier: 0.12.0 - version: 0.12.0(@babel/core@7.28.0)(@oclif/config@1.18.16)(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(jsonc-parser@2.3.1) + specifier: 0.13.0--canary.242.6147 + version: 0.13.0--canary.242.6147(@babel/core@7.28.0)(@oclif/config@1.18.16)(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(jsonc-parser@2.3.1) '@player-tools/dsl': - specifier: 0.12.0 - version: 0.12.0(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(react@18.3.1) + specifier: 0.13.0--canary.242.6147 + version: 0.13.0--canary.242.6147(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(react@18.3.1) '@player-tools/xlr': - specifier: 0.12.0 - version: 0.12.0 + specifier: 0.13.0--canary.242.6147 + version: 0.13.0--canary.242.6147 '@player-tools/xlr-utils': specifier: 0.6.1-next.2 version: 0.6.1-next.2(jsonc-parser@2.3.1)(typescript@5.5.3) @@ -2565,31 +2565,31 @@ packages: resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==, tarball: https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} - '@player-tools/cli@0.12.0': - resolution: {integrity: sha512-Mcl4WE8Z63hBzEsDYfA40Bo4zHgtJHmMRDv+62kbOPJdEVqvurxE14oy1IusfJneTgtXjyAdKaLgtsYiMTrnmA==, tarball: https://registry.npmjs.org/@player-tools/cli/-/cli-0.12.0.tgz} + '@player-tools/cli@0.13.0--canary.242.6147': + resolution: {integrity: sha512-NMEuR3KSmc2fPS3Z53UvVTRzocSr6CDQ3+wDa/fDBbkgM0yZXSGKsCO7VBXnkdaDdTSt4a5LucgVb07crP5vig==, tarball: https://registry.npmjs.org/@player-tools/cli/-/cli-0.13.0--canary.242.6147.tgz} hasBin: true - '@player-tools/dsl@0.12.0': - resolution: {integrity: sha512-HA5Qei+yZEdCCxa6zjr7klOb1DhCxAHVER+CxiVGB2IlTKFX34jMY+UECLZViVF1vlhmmCQI50BcksWev3Qb3Q==, tarball: https://registry.npmjs.org/@player-tools/dsl/-/dsl-0.12.0.tgz} + '@player-tools/dsl@0.13.0--canary.242.6147': + resolution: {integrity: sha512-lzaqLMDf1WtX7BMwtDazYp0SvrnlcolxxaImIjU2/Sr2m51di13m1ibIOwsPtR5CPYDSYPcCOXcsiRQqa/2oWQ==, tarball: https://registry.npmjs.org/@player-tools/dsl/-/dsl-0.13.0--canary.242.6147.tgz} peerDependencies: '@types/react': ^18.2.51 react: ^18.2.0 - '@player-tools/json-language-service@0.12.0': - resolution: {integrity: sha512-ASwRnmV/mNuPvIUbvmXj3On67w8qq3i0tEtfZk5+6030qyI0KEK0HcghCcGPbzdslWGOlAGyidt7LjKtA6BJrA==, tarball: https://registry.npmjs.org/@player-tools/json-language-service/-/json-language-service-0.12.0.tgz} + '@player-tools/json-language-service@0.13.0--canary.242.6147': + resolution: {integrity: sha512-RXMDUtY4x+NlmED2ECCbigoIzV363/9eCLlLgwYDfmpdLWn/cHYUZWaeNKuB5ctocaxexkUvijECOjH7ZvdfWw==, tarball: https://registry.npmjs.org/@player-tools/json-language-service/-/json-language-service-0.13.0--canary.242.6147.tgz} - '@player-tools/xlr-converters@0.12.0': - resolution: {integrity: sha512-FMhxpDnlHnty05QtfL6BLuC5K1+gikwm/OBXy0AM8iTQ5w4W4t/XX8aWvd/DNizE/i9Erp9/pD4jIV9av1ToyQ==, tarball: https://registry.npmjs.org/@player-tools/xlr-converters/-/xlr-converters-0.12.0.tgz} + '@player-tools/xlr-converters@0.13.0--canary.242.6147': + resolution: {integrity: sha512-v1cMVSxsxDd8Yq6GYFZXrO3hw8Vb6cyx3s5H6gRryOyP7wllhqYaXpSUCd613NNIni2pkJ6K4ewRLfqSAn349g==, tarball: https://registry.npmjs.org/@player-tools/xlr-converters/-/xlr-converters-0.13.0--canary.242.6147.tgz} peerDependencies: typescript: 5.5.4 - '@player-tools/xlr-sdk@0.12.0': - resolution: {integrity: sha512-KMzv/hJLJ0zQVhamFv4HMNl7I7EpuJJuOs7kj5zK3ywHCs1z08jheqzyfA1ka14vo2lvha3aS1CS5H7Ayw1ErA==, tarball: https://registry.npmjs.org/@player-tools/xlr-sdk/-/xlr-sdk-0.12.0.tgz} + '@player-tools/xlr-sdk@0.13.0--canary.242.6147': + resolution: {integrity: sha512-0Caay8BeWn8sLGRYpHClOSB1W9CGvcV16BZMG15FbAVG4lWuxycN+l7fxlVbbXB1siY5NxOIwgoTcFtSyCf6Ow==, tarball: https://registry.npmjs.org/@player-tools/xlr-sdk/-/xlr-sdk-0.13.0--canary.242.6147.tgz} peerDependencies: typescript: 5.5.4 - '@player-tools/xlr-utils@0.12.0': - resolution: {integrity: sha512-PzdNkiJy/RvHuorW2ece/Swq1GQ2XUWiNnsxFdLEud5TFVrynePuFCEJZm+7Bssf4Ju3nCLFr0ARUB8M4zHq4w==, tarball: https://registry.npmjs.org/@player-tools/xlr-utils/-/xlr-utils-0.12.0.tgz} + '@player-tools/xlr-utils@0.13.0--canary.242.6147': + resolution: {integrity: sha512-ljKEGztbaO5MW7/Gh/mL3O5JmvjS1OIkrKakzvXXPTR86BSGmrFYP6v8qa++wWHIDlGXBiE6/pMbg/bNJcnuWw==, tarball: https://registry.npmjs.org/@player-tools/xlr-utils/-/xlr-utils-0.13.0--canary.242.6147.tgz} peerDependencies: jsonc-parser: ^2.3.1 typescript: 5.5.4 @@ -2600,8 +2600,8 @@ packages: jsonc-parser: ^2.3.1 typescript: ^5.4.4 - '@player-tools/xlr@0.12.0': - resolution: {integrity: sha512-iB3PmIJd8dygTgjak8GKdQqkAkc23JpxMyd+OCnAU8Uctrsl46YPTBZIhtKn2Vbn4vzAQmJkl4cz2C8xDgnvDg==, tarball: https://registry.npmjs.org/@player-tools/xlr/-/xlr-0.12.0.tgz} + '@player-tools/xlr@0.13.0--canary.242.6147': + resolution: {integrity: sha512-WhbkyJObAUVbuqW2718Szgomsg3E0+0a3iidaCiOcsSvNAKj2i6JmR1KPdGNBTDl6K3/vQ1m/ljeSgW6nfYw0g==, tarball: https://registry.npmjs.org/@player-tools/xlr/-/xlr-0.13.0--canary.242.6147.tgz} '@player-tools/xlr@0.6.1-next.2': resolution: {integrity: sha512-0wAtiDR/7Xjxe3zVrYP+i1MuhR1VyEgu8x2FiSqxfTwWPP3cQn9UGPt2jL6W2hdVZRER3JBQpe1Giw8WM+xH7w==, tarball: https://registry.npmjs.org/@player-tools/xlr/-/xlr-0.6.1-next.2.tgz} @@ -11375,7 +11375,7 @@ snapshots: '@pkgr/core@0.2.9': {} - '@player-tools/cli@0.12.0(@babel/core@7.28.0)(@oclif/config@1.18.16)(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(jsonc-parser@2.3.1)': + '@player-tools/cli@0.13.0--canary.242.6147(@babel/core@7.28.0)(@oclif/config@1.18.16)(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(jsonc-parser@2.3.1)': dependencies: '@babel/plugin-transform-react-jsx-source': 7.27.1(@babel/core@7.28.0) '@babel/preset-env': 7.28.0(@babel/core@7.28.0) @@ -11384,12 +11384,12 @@ snapshots: '@babel/register': 7.27.1(@babel/core@7.28.0) '@oclif/core': 1.9.0 '@oclif/plugin-plugins': 1.10.11(@oclif/config@1.18.16) - '@player-tools/dsl': 0.12.0(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(react@18.3.1) - '@player-tools/json-language-service': 0.12.0 - '@player-tools/xlr': 0.12.0 - '@player-tools/xlr-converters': 0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4) - '@player-tools/xlr-sdk': 0.12.0(typescript@5.5.4) - '@player-tools/xlr-utils': 0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4) + '@player-tools/dsl': 0.13.0--canary.242.6147(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(react@18.3.1) + '@player-tools/json-language-service': 0.13.0--canary.242.6147 + '@player-tools/xlr': 0.13.0--canary.242.6147 + '@player-tools/xlr-converters': 0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4) + '@player-tools/xlr-sdk': 0.13.0--canary.242.6147(typescript@5.5.4) + '@player-tools/xlr-utils': 0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4) chalk: 4.1.2 cosmiconfig: 7.1.0 cross-fetch: 3.2.0 @@ -11420,7 +11420,7 @@ snapshots: - jsonc-parser - supports-color - '@player-tools/dsl@0.12.0(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(react@18.3.1)': + '@player-tools/dsl@0.13.0--canary.242.6147(@swc/core@1.13.3(@swc/helpers@0.5.17))(@types/node@20.19.10)(@types/react@18.3.23)(react@18.3.1)': dependencies: '@player-ui/player': 0.12.0-next.1 '@player-ui/types': 0.12.0-next.1 @@ -11445,11 +11445,11 @@ snapshots: - '@swc/wasm' - '@types/node' - '@player-tools/json-language-service@0.12.0': + '@player-tools/json-language-service@0.13.0--canary.242.6147': dependencies: - '@player-tools/xlr': 0.12.0 - '@player-tools/xlr-sdk': 0.12.0(typescript@5.5.4) - '@player-tools/xlr-utils': 0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4) + '@player-tools/xlr': 0.13.0--canary.242.6147 + '@player-tools/xlr-sdk': 0.13.0--canary.242.6147(typescript@5.5.4) + '@player-tools/xlr-utils': 0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4) '@player-ui/player': 0.12.0-next.1 change-case: 4.1.2 cross-fetch: 3.2.0 @@ -11464,20 +11464,20 @@ snapshots: transitivePeerDependencies: - encoding - '@player-tools/xlr-converters@0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4)': + '@player-tools/xlr-converters@0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4)': dependencies: - '@player-tools/xlr': 0.12.0 - '@player-tools/xlr-utils': 0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4) + '@player-tools/xlr': 0.13.0--canary.242.6147 + '@player-tools/xlr-utils': 0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4) tslib: 2.8.1 typescript: 5.5.4 transitivePeerDependencies: - jsonc-parser - '@player-tools/xlr-sdk@0.12.0(typescript@5.5.4)': + '@player-tools/xlr-sdk@0.13.0--canary.242.6147(typescript@5.5.4)': dependencies: - '@player-tools/xlr': 0.12.0 - '@player-tools/xlr-converters': 0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4) - '@player-tools/xlr-utils': 0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4) + '@player-tools/xlr': 0.13.0--canary.242.6147 + '@player-tools/xlr-converters': 0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4) + '@player-tools/xlr-utils': 0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4) '@types/fs-extra': 9.0.13 '@types/node': 18.19.122 fs-extra: 10.1.0 @@ -11485,9 +11485,9 @@ snapshots: tslib: 2.8.1 typescript: 5.5.4 - '@player-tools/xlr-utils@0.12.0(jsonc-parser@2.3.1)(typescript@5.5.4)': + '@player-tools/xlr-utils@0.13.0--canary.242.6147(jsonc-parser@2.3.1)(typescript@5.5.4)': dependencies: - '@player-tools/xlr': 0.12.0 + '@player-tools/xlr': 0.13.0--canary.242.6147 jsonc-parser: 2.3.1 tslib: 2.8.1 typescript: 5.5.4 @@ -11502,7 +11502,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@player-tools/xlr@0.12.0': + '@player-tools/xlr@0.13.0--canary.242.6147': dependencies: tslib: 2.8.1