Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Common Types Plugin restoring old dataRefs #302

Merged
merged 11 commits into from
Mar 6, 2024
33 changes: 0 additions & 33 deletions plugins/common-types/core/src/data-types/refs.ts

This file was deleted.

26 changes: 8 additions & 18 deletions plugins/common-types/core/src/data-types/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import type { Schema } from '@player-ui/types';
import {
BooleanTypeRef,
CollectionTypeRef,
DateTypeRef,
IntegerPosTypeRef,
IntegerTypeRef,
PhoneTypeRef,
StringTypeRef,
IntegerNNTypeRef,
} from './refs';

export const BooleanType: Schema.DataType<boolean> = {
...BooleanTypeRef,
type: 'BooleanType',
default: false,
validation: [
{
Expand All @@ -23,7 +13,7 @@ export const BooleanType: Schema.DataType<boolean> = {
};

export const IntegerType: Schema.DataType<number> = {
...IntegerTypeRef,
type: 'IntegerType',
validation: [
{
type: 'integer',
Expand All @@ -35,7 +25,7 @@ export const IntegerType: Schema.DataType<number> = {
};

export const IntegerPosType: Schema.DataType<number> = {
...IntegerPosTypeRef,
type: 'IntegerPosType',
validation: [
{
type: 'integer',
Expand All @@ -51,7 +41,7 @@ export const IntegerPosType: Schema.DataType<number> = {
};

export const IntegerNNType: Schema.DataType<number> = {
...IntegerNNTypeRef,
type: 'IntegerNNType',
validation: [
{
type: 'integer',
Expand All @@ -67,7 +57,7 @@ export const IntegerNNType: Schema.DataType<number> = {
};

export const StringType: Schema.DataType<string> = {
...StringTypeRef,
type: 'StringType',
default: '',
validation: [
{
Expand All @@ -80,7 +70,7 @@ export const StringType: Schema.DataType<string> = {
};

export const CollectionType: Schema.DataType<Array<unknown>> = {
...CollectionTypeRef,
type: 'CollectionType',
validation: [
{
type: 'collection',
Expand All @@ -89,7 +79,7 @@ export const CollectionType: Schema.DataType<Array<unknown>> = {
};

export const DateType: Schema.DataType<string> = {
...DateTypeRef,
type: 'DateType',
validation: [
{
type: 'string',
Expand All @@ -101,7 +91,7 @@ export const DateType: Schema.DataType<string> = {
};

export const PhoneType: Schema.DataType<string> = {
...PhoneTypeRef,
type: 'PhoneType',
validation: [
{
type: 'phone',
Expand Down
4 changes: 2 additions & 2 deletions plugins/common-types/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { TypesProviderPlugin } from '@player-ui/types-provider-plugin';

import * as validators from './validators';
import * as dataTypes from './data-types/types';
import * as dataRefs from './data-types/refs';
import * as formats from './formats';
import type {
BooleanType,
Expand All @@ -16,7 +15,8 @@ import type {
PhoneType,
} from './data-types/types';

export { validators, dataTypes, dataRefs, formats };
export { validators, dataTypes, formats };

export * from './formats/utils';

/**
Expand Down
1 change: 1 addition & 0 deletions plugins/reference-assets/components/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("//:index.bzl", "javascript_pipeline")
javascript_pipeline(
name = "@player-ui/reference-assets-components",
dependencies = [
"//plugins/common-types/core:@player-ui/common-types-plugin",
"//plugins/reference-assets/core:@player-ui/reference-assets-plugin"
],

Expand Down
26 changes: 25 additions & 1 deletion plugins/reference-assets/components/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ import type {
AssetPropsWithChildren,
BindingTemplateInstance,
ExpressionTemplateInstance,
DSLSchema as PlayerDSLSchema,
DataTypeReference,
DataTypeRefs,
ValidatorFunctionRefs,
} from '@player-tools/dsl';
import {
createSlot,
Asset,
View,
getObjectReferences,
} from '@player-tools/dsl';
import { createSlot, Asset, View } from '@player-tools/dsl';
import type { Asset as AssetType } from '@player-ui/player';
import type {
ActionAsset,
Expand All @@ -13,6 +22,21 @@ import type {
InfoAsset,
InputAsset,
} from '@player-ui/reference-assets-plugin';
import { dataTypes, validators } from '@player-ui/common-types-plugin';

export const dataRefs = getObjectReferences<
typeof dataTypes,
DataTypeRefs<typeof dataTypes>
>(dataTypes);

export const validationRefs = getObjectReferences<
typeof validators,
ValidatorFunctionRefs<typeof validators>
>(validators);

export type DSLSchema = PlayerDSLSchema<
DataTypeReference<typeof dataTypes, ValidatorFunctionRefs<typeof validators>>
>;

export const Text = (
props: Omit<AssetPropsWithChildren<TextAsset>, 'value'> & {
Expand Down