From ae3afa27db4d3196966747919f10c1101324b21d Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Mon, 2 May 2022 08:20:21 -0700 Subject: [PATCH 01/21] chore: support for StructuredDataSet Input/Output type Signed-off-by: Carina Ursu --- .../components/Literals/LiteralMapViewer.tsx | 26 +- .../src/components/Literals/LiteralValue.tsx | 1 + .../__stories__/Collection.stories.tsx | 9 +- .../Literals/__stories__/Map.stories.tsx | 10 +- .../__stories__/ProtobufStruct.stories.tsx | 28 +- .../Literals/__stories__/Scalar.stories.tsx | 16 +- .../src/components/Literals/helpers.ts | 333 ++++++++++++++++++ .../src/components/common/DumpJSON.tsx | 8 +- .../src/components/common/ReactJsonView.tsx | 62 ++++ 9 files changed, 471 insertions(+), 22 deletions(-) create mode 100644 packages/zapp/console/src/components/Literals/helpers.ts create mode 100644 packages/zapp/console/src/components/common/ReactJsonView.tsx diff --git a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx index 5e594c635..8eaf58c65 100644 --- a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx @@ -1,9 +1,11 @@ import classnames from 'classnames'; import { sortedObjectEntries } from 'common/utils'; +import { ReactJsonViewWrapper } from 'components/common/ReactJsonView'; import { useCommonStyles } from 'components/common/styles'; import { Literal, LiteralMap } from 'models/Common/types'; import * as React from 'react'; import { htmlEntities } from './constants'; +import { transformLiteralMap } from './helpers'; import { LiteralValue } from './LiteralValue'; import { NoneTypeValue } from './Scalar/NoneTypeValue'; @@ -20,13 +22,21 @@ export const LiteralMapViewer: React.FC<{ className?: string; map: LiteralMap | null; showBrackets?: boolean; -}> = ({ className, map, showBrackets = false }) => { + showJson?: boolean; +}> = ({ className, map, showBrackets = false, showJson }) => { if (!map) { return ; } const commonStyles = useCommonStyles(); const { literals } = map; + + if (!Object.keys(literals).length) { + return ; + } + + let transformedLiterals = transformLiteralMap(literals); + const mapContent = Object.keys(literals).length ? (
    {sortedObjectEntries(literals).map(([key, value]) => ( @@ -40,11 +50,25 @@ export const LiteralMapViewer: React.FC<{ ); + + let rootNode: string | null = null; + + const transformedLiteralsKeys = Object.keys(transformedLiterals); + if ( + transformedLiteralsKeys.length === 1 && + typeof transformedLiterals[transformedLiteralsKeys[0]] === 'object' + ) { + rootNode = transformedLiteralsKeys[0]; + transformedLiterals = transformedLiterals[rootNode!]; + } + return ( <> {showBrackets && {htmlEntities.leftCurlyBrace}} {mapContent} {showBrackets && {htmlEntities.rightCurlyBrace}} + + {showJson !== false && } ); }; diff --git a/packages/zapp/console/src/components/Literals/LiteralValue.tsx b/packages/zapp/console/src/components/Literals/LiteralValue.tsx index 302db910e..399bef340 100644 --- a/packages/zapp/console/src/components/Literals/LiteralValue.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralValue.tsx @@ -31,6 +31,7 @@ export const LiteralValue: React.FC<{ className={literalStyles.nestedContainer} map={literal.map as LiteralMap} showBrackets={true} + showJson={false} // todo: remove /> ); diff --git a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx index 31dd5a636..2e5840aab 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx @@ -2,6 +2,7 @@ import { storiesOf } from '@storybook/react'; import { LiteralCollection } from 'models/Common/types'; import * as React from 'react'; import { LiteralValue } from '../LiteralValue'; +import { LiteralMapViewer } from '../LiteralMapViewer'; import { CardDecorator } from './CardDecorator'; import { binaryLiterals, @@ -16,7 +17,13 @@ const stories = storiesOf('Literals/Collection', module); stories.addDecorator(CardDecorator); function renderCollection(label: string, collection: LiteralCollection) { - return ; + return ( + <> + +
    NEW: + + + ); } stories.add('Binary', () => diff --git a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx index 4a4b49cdb..b470a308c 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx @@ -11,12 +11,20 @@ import { primitiveLiterals, schemaLiterals, } from './literalValues'; +import { LiteralMapViewer } from '../LiteralMapViewer'; const stories = storiesOf('Literals/Map', module); stories.addDecorator(CardDecorator); function renderMap(label: string, map: LiteralMap) { - return ; + return ( + <> + +
    NEW: + + + + ); } stories.add('Binary', () => diff --git a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx index 8781df62d..8f2f982fa 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx @@ -4,20 +4,30 @@ import * as React from 'react'; import { LiteralValue } from '../LiteralValue'; import { CardDecorator } from './CardDecorator'; import { protobufValues } from './protobufValues'; +import { LiteralMapViewer } from '../LiteralMapViewer'; const stories = storiesOf('Literals/ProtobufStruct', module); stories.addDecorator(CardDecorator); function renderStruct(label: string, struct: ProtobufStruct) { return ( - + <> + +
    NEW: + + + ); } @@ -30,7 +40,7 @@ stories.add('list', () => kind: 'listValue', listValue: { values: [ - ...Object.values(protobufValues), + // ...Object.values(protobufValues), { kind: 'structValue', structValue: { fields: protobufValues }, diff --git a/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx index f79996aea..b220ffeab 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx @@ -2,6 +2,7 @@ import { storiesOf } from '@storybook/react'; import { Scalar } from 'models/Common/types'; import * as React from 'react'; import { ScalarValue } from '../Scalar/ScalarValue'; +import { LiteralMapViewer } from '../LiteralMapViewer'; import { CardDecorator } from './CardDecorator'; import { binaryScalars, @@ -17,16 +18,19 @@ stories.addDecorator(CardDecorator); const renderScalars = (scalars: Dictionary) => Object.entries(scalars).map(([label, value]) => { - return ; + return ( + <> + +
    NEW: + + + + ); }); stories.add('Binary', () => <>{renderScalars(binaryScalars)}); stories.add('Blob', () => <>{renderScalars(blobScalars)}); stories.add('Error', () => <>{renderScalars(errorScalars)}); -stories.add('NoneType', () => ( - <> - - -)); +stories.add('NoneType', () => <>{renderScalars([noneTypeScalar])}); stories.add('Primitive', () => <>{renderScalars(primitiveScalars)}); stories.add('Schema', () => <>{renderScalars(schemaScalars)}); diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts new file mode 100644 index 000000000..b990d92c5 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -0,0 +1,333 @@ +import { formatDateUTC, protobufDurationToHMS } from 'common/formatters'; +import { sortedObjectEntries, timestampToDate } from 'common/utils'; +import { Core } from 'flyteidl'; +import { + BlobDimensionality, + ProtobufListValue, + ProtobufStruct, + ProtobufValue, + SchemaColumnType, +} from 'models/Common/types'; + +// PRIMITIVE +function processPrimitive(primitive: Core.IPrimitive) { + const type = (primitive as Core.Primitive).value!; + switch (type) { + case 'datetime': + return formatDateUTC(timestampToDate(primitive.datetime!)); + case 'duration': + return protobufDurationToHMS(primitive.duration!); + case 'boolean': + case 'floatValue': + return primitive[type]; + case 'integer': + return +`${primitive[type]}`; + case 'stringValue': + default: + return `${primitive[type]}`; + } +} + +// BLOB +const dimensionalityStrings: Record = { + [BlobDimensionality.SINGLE]: 'single', + [BlobDimensionality.MULTIPART]: 'multi-part', +}; + +function processBlobType(blobType: Core.IBlobType, typePrefix: string = '') { + const formatString = blobType && blobType.format ? ` (${blobType.format})` : ''; + const typeString = `${dimensionalityStrings[blobType!.dimensionality!]}${formatString}`; + + return `${typePrefix}${typeString} blob`; +} + +function processBlob(blob: Core.IBlob | Core.Blob) { + const type = blob?.metadata?.type; + + return { + type: processBlobType(type!), + uri: blob.uri, + }; +} + +// BINARY +function processBinary(binary: Core.IBinary) { + return { + tag: `${binary?.tag!} (binary data not shown)`, + }; +} + +// SCHEMA +function columnTypeToString(type: SchemaColumnType) { + switch (type) { + case SchemaColumnType.BOOLEAN: + return 'boolean'; + case SchemaColumnType.DATETIME: + return 'datetime'; + case SchemaColumnType.DURATION: + return 'duration'; + case SchemaColumnType.FLOAT: + return 'float'; + case SchemaColumnType.INTEGER: + return 'integer'; + case SchemaColumnType.STRING: + return 'string'; + default: + return 'unknown'; + } +} + +function processSchemaType(schemaType: Core.ISchemaType) { + let columns; + if (schemaType?.columns?.length) { + columns = schemaType?.columns.map( + (column) => `${column.name!} (${columnTypeToString(column.type!)})`, + ); + } + + return columns; +} + +function processSchema(schema: Core.ISchema) { + const columns = processSchemaType(schema?.type!); + + return { + uri: schema.uri, + ...(columns && { columns }), + }; +} + +// NONE +/* eslint-disable @typescript-eslint/no-unused-vars */ +function processNone(none?: Core.IVoid) { + return '(empty)'; +} + +function processUnionType(union: Core.IUnionType) { + return 'This type is not yet supported'; +} + +function processUnion(union: Core.IUnion) { + return 'This type is not yet supported'; +} +/* eslint-enable @typescript-eslint/no-unused-vars */ + +// ERROR +function processError(error: Core.IError) { + return { + error: error.message, + nodeId: error.failedNodeId, + }; +} + +// GENERIC -- not done +function processProtobufStructValue(struct: ProtobufStruct) { + const { fields } = struct; + const res = Object.keys(fields) + .map((v) => { + return { [v]: processProtobufValue(fields[v]) }; + }) + .reduce((acc, v) => ({ ...acc, ...v }), {}); + + return res; +} +function processProtobufValue(value: ProtobufValue) { + switch (value.kind) { + case 'nullValue': + return '(empty)'; + case 'listValue': { + const list = value.listValue as ProtobufListValue; + return list?.values?.map((x) => processProtobufValue(x)); + } + case 'structValue': + return processProtobufStructValue(value?.structValue as ProtobufStruct); + case 'stringValue': + return `${value[value.kind]}`; + default: + return value[value.kind]; + } +} +function processGeneric(struct: ProtobufStruct) { + const { fields } = struct; + const mapContent = Object.keys(fields) + .map((key) => { + const value = fields[key]; + return { [key]: processProtobufValue(value) }; + }) + .reduce((acc, v) => { + return { ...acc, ...v }; + }, {} as any); + + return mapContent; +} + +// SIMPLE +function processSimpleType(simpleType: Core.SimpleType, typePrefix: string = '') { + let returnString = ''; + switch (simpleType) { + case Core.SimpleType.NONE: + returnString = 'none'; + break; + case Core.SimpleType.INTEGER: + returnString = 'integer'; + break; + case Core.SimpleType.FLOAT: + returnString = 'float'; + break; + case Core.SimpleType.STRING: + returnString = 'string'; + break; + case Core.SimpleType.BOOLEAN: + returnString = 'booleam'; + break; + case Core.SimpleType.DATETIME: + returnString = 'datetime'; + break; + case Core.SimpleType.DURATION: + returnString = 'duration'; + break; + case Core.SimpleType.BINARY: + returnString = 'binary'; + break; + case Core.SimpleType.ERROR: + returnString = 'error'; + break; + case Core.SimpleType.STRUCT: + returnString = 'struct'; + break; + } + return `${typePrefix}${returnString}`; +} + +function processEnumType(enumType: Core.IEnumType) { + return enumType?.values || []; +} + +function processLiteralType(literalType: Core.ILiteralType, typePrefix: string = '') { + const type = (literalType as Core.LiteralType)?.type; + + switch (type) { + case 'simple': + return processSimpleType(literalType?.simple!, typePrefix); + case 'schema': + return processSchemaType(literalType?.schema!); + case 'collectionType': + return processLiteralType(literalType?.collectionType!, (typePrefix = 'collection of ')); + case 'mapValueType': + return processLiteralType(literalType?.mapValueType!, typePrefix); + case 'blob': + return processBlobType(literalType?.blob!, typePrefix); + case 'enumType': + return processEnumType(literalType?.enumType!); + case 'structuredDatasetType': + return processStructuredDatasetType(literalType?.structuredDatasetType!); + case 'unionType': + return processUnionType(literalType?.unionType!); + default: + return 'This type is not yet supported'; + } +} + +function processStructuredDatasetType(structuredDatasetType: Core.IStructuredDatasetType) { + const retJson = {} as any; + + const { columns, format } = structuredDatasetType; + + if (format) { + retJson.format = format; + } + + if (columns && (columns as Core.StructuredDatasetType.IDatasetColumn[])?.length) { + retJson.columns = columns + .map(({ name, literalType }) => [name, processLiteralType(literalType!)]) + .reduce((acc, v) => { + acc[v[0]] = v[1]; + return acc; + }, []); + } + + return retJson; +} + +function processStructuredDataset(structuredDataSet: Core.IStructuredDataset) { + const retJson = {} as any; + const { uri, metadata } = structuredDataSet; + + if (uri) { + retJson.uri = uri; + } + + const structuredDatasetType = metadata?.structuredDatasetType!; + + return { + ...retJson, + ...processStructuredDatasetType(structuredDatasetType), + }; +} + + +function processScalar(scalar: Core.Scalar | Core.IScalar) { + const type = (scalar as Core.Scalar).value; + const value = scalar[type!]; + + switch (type) { + case 'primitive': + return processPrimitive(value as Core.IPrimitive); + case 'blob': + return processBlob(value as Core.IBlob); + case 'binary': + return processBinary(value as Core.IBinary); + case 'schema': + return processSchema(value as Core.ISchema); + case 'noneType': + return processNone(value as Core.IVoid); + case 'error': + return processError(value as Core.IError); + case 'generic': + return processGeneric(value as ProtobufStruct); + case 'structuredDataset': + return processStructuredDataset(value as Core.IStructuredDataset); + case 'union': + return processUnion(value as Core.IUnion); + default: + return 'This type is not yet supported'; + } +} + +function processCollection(collection: Core.ILiteralCollection) { + return collection?.literals?.map((literal) => processLiteralValue(literal)); +} + +function processMap(map: Core.ILiteralMap) { + return transformLiteralMap(map.literals as Core.ILiteralMap); +} + +export function processLiteralValue(literal: Core.ILiteral) { + const type = (literal as Core.Literal).value; + switch (type) { + case 'scalar': + return processScalar(literal.scalar!); + case 'collection': + return processCollection(literal.collection!); + case 'map': + return processMap(literal.map!); + default: + return 'unknown type'; + } +} + +export function transformLiteralMap(json: Core.ILiteralMap) { + const obj = sortedObjectEntries(json as any) + .map(([key, literal]) => ({ + [key]: processLiteralValue(literal as any as Core.Literal), + })) + .reduce( + (acc, cur) => ({ + ...acc, + ...cur, + }), + {}, + ); + + return obj; +} diff --git a/packages/zapp/console/src/components/common/DumpJSON.tsx b/packages/zapp/console/src/components/common/DumpJSON.tsx index e20db28c4..57349eefb 100644 --- a/packages/zapp/console/src/components/common/DumpJSON.tsx +++ b/packages/zapp/console/src/components/common/DumpJSON.tsx @@ -1,8 +1,8 @@ -import { stringifyValue } from 'common/utils'; -import { useCommonStyles } from 'components/common/styles'; import * as React from 'react'; +import { ReactJsonViewWrapper } from 'components/common/ReactJsonView'; export const DumpJSON: React.FC<{ value: any }> = ({ value }) => { - const commonStyles = useCommonStyles(); - return
    {stringifyValue(value)}
    ; + return ( + + ); }; diff --git a/packages/zapp/console/src/components/common/ReactJsonView.tsx b/packages/zapp/console/src/components/common/ReactJsonView.tsx new file mode 100644 index 000000000..95b426d21 --- /dev/null +++ b/packages/zapp/console/src/components/common/ReactJsonView.tsx @@ -0,0 +1,62 @@ +import * as React from 'react'; +import { makeStyles, Theme } from '@material-ui/core/styles'; +import ReactJsonView, { ReactJsonViewProps } from 'react-json-view'; +import * as copyToClipboard from 'copy-to-clipboard'; +import { primaryTextColor, smallFontSize } from 'components/Theme/constants'; + +const useStyles = makeStyles((theme: Theme) => ({ + jsonViewer: { + marginLeft: '-10px', + width: '100%', + fontSize: smallFontSize, + '& span': { + fontWeight: 'normal !important', + }, + '& .object-container': { + overflowWrap: 'anywhere !important', + }, + '& .copy-to-clipboard-container': { + position: 'absolute', + }, + '& .copy-icon svg': { + color: `${theme.palette.primary.main} !important`, + }, + '& .variable-value': { + paddingLeft: '5px', + }, + '& .variable-value >*': { + color: `${primaryTextColor} !important`, + }, + '& .object-key-val': { + padding: '0 0 0 5px !important', + }, + '& .object-key': { + color: `${theme.palette.grey[500]} !important`, + }, + }, +})); + +export const ReactJsonViewWrapper: React.FC = (props) => { + const styles = useStyles(); + + return ( +
    + { + const objToCopy = options.src; + const text = typeof objToCopy === 'object' ? JSON.stringify(objToCopy) : objToCopy; + copyToClipboard(text); + }} + displayDataTypes={false} + quotesOnKeys={false} + iconStyle="triangle" + displayObjectSize={true} + name={null} + indentWidth={4} + collapseStringsAfterLength={80} + sortKeys={true} + {...props} + /> +
    + ); +}; From 620997412a15bfd32bb6f500365837b1bbc133dc Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Tue, 3 May 2022 13:39:15 -0700 Subject: [PATCH 02/21] chore: add tests Signed-off-by: Carina Ursu --- .../__stories__/StructuredDataSet.stories.tsx | 177 ++++++++++++++++++ .../__stories__/helpers/typeGenerators.ts | 45 +++++ .../src/components/Literals/helpers.ts | 75 ++++---- .../test/helpers/gen_collection_test_case.ts | 30 +++ .../test/helpers/gen_map_test_case.ts | 30 +++ .../helpers/gen_scalar_binary_test_case.ts | 13 ++ .../test/helpers/gen_scalar_blob_cases.ts | 45 +++++ .../test/helpers/gen_scalar_error_case.ts | 36 ++++ .../test/helpers/gen_scalar_generic_case.ts | 155 +++++++++++++++ .../test/helpers/gen_scalar_nonetype_case.ts | 11 ++ .../helpers/gen_scalar_primitive_cases.ts | 88 +++++++++ .../test/helpers/gen_scalar_schema_case.ts | 40 ++++ .../helpers/gen_scalar_structured_ds_case.ts | 130 +++++++++++++ .../components/Literals/test/helpers/index.ts | 23 +++ .../Literals/test/helpers/literalHelpers.ts | 80 ++++++++ .../Literals/test/helpers/mock_simpleTypes.ts | 17 ++ .../Literals/test/literal.helpers.test.ts | 78 ++++++++ .../src/components/Literals/test/types.d.ts | 8 + 18 files changed, 1039 insertions(+), 42 deletions(-) create mode 100644 packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx create mode 100644 packages/zapp/console/src/components/Literals/__stories__/helpers/typeGenerators.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_collection_test_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_map_test_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_binary_test_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_error_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_nonetype_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_primitive_cases.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_schema_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/index.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts create mode 100644 packages/zapp/console/src/components/Literals/test/helpers/mock_simpleTypes.ts create mode 100644 packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts create mode 100644 packages/zapp/console/src/components/Literals/test/types.d.ts diff --git a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx new file mode 100644 index 000000000..b6358ddf8 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx @@ -0,0 +1,177 @@ +import { storiesOf } from '@storybook/react'; +import { Scalar } from 'models/Common/types'; +import * as React from 'react'; +import { Core } from 'flyteidl'; +import { LiteralMapViewer } from '../LiteralMapViewer'; +import { CardDecorator } from './CardDecorator'; +import { + blobScalars, +} from './scalarValues'; +import { extractSimpleTypes, extractSchemaTypes, extractBlobTypes } from './helpers/typeGenerators'; + +const stories = storiesOf('Literals/StructuredDataSet', module); +stories.addDecorator(CardDecorator); + +function generateStructuredDataset(label: string, literalType: Core.ILiteralType) { + return { + literals: { + [label]: { + scalar: { + structuredDataset: { + uri: 's3://random-val', + metadata: { + structuredDatasetType: { + columns: [ + { + name: 'age', + literalType, + }, + ], + format: 'parquet', + }, + }, + }, + value: 'structuredDataset', + }, + value: 'scalar', + }, + }, + }; +} + +function generateSimpleTypes() { + const simpleTypes = extractSimpleTypes().map((simpleType) => { + return Object.keys(simpleType).map((key) => { + return generateStructuredDataset(`simple_${key}`, simpleType[key]); + }); + }); + return simpleTypes.flat(); +} + +function generateSchemaTypes() { + const schemaTypes = extractSchemaTypes(); + const retObj = schemaTypes + .map((schemaType) => { + return Object.keys(schemaType).map((key) => { + const v = schemaType[key]; + return generateStructuredDataset(`schema${key}`, v); + }); + }) + .flat(); + + return retObj; +} + +function generateBlobTypes() { + return Object.keys(blobScalars).map((key) => { + const value = blobScalars[key]?.['blob']?.metadata?.type; + return generateStructuredDataset(key, { + type: 'blob', + blob: value, + }); + }); +} + +function generateCollectionTypes() { + const collectionTypes = []; + + const simpleTypes = extractSimpleTypes() + .map((simpleType) => { + return Object.keys(simpleType).map((key) => { + return generateStructuredDataset(`simple_${key}`, { + type: 'collectionType', + collectionType: simpleType[key], + }); + }); + }) + .flat(); + collectionTypes.push(...simpleTypes); + + // blobTypes + const blobTypes = extractBlobTypes(); + collectionTypes.push( + ...blobTypes + .map((value) => { + return Object.keys(value).map((key) => { + return generateStructuredDataset(key, { + type: 'collectionType', + collectionType: value[key], + }); + }); + }) + .flat(), + ); + + return collectionTypes; +} + +function generateMapValueypes() { + const mapValueTypes = []; + + const simpleTypes = extractSimpleTypes() + .map((simpleType) => { + return Object.keys(simpleType).map((key) => { + return generateStructuredDataset(`simple_${key}`, { + type: 'mapValueType', + mapValueType: simpleType[key], + }); + }); + }) + .flat(); + mapValueTypes.push(...simpleTypes); + + // blobTypes + const blobTypes = extractBlobTypes(); + mapValueTypes.push( + ...blobTypes + .map((value) => { + return Object.keys(value).map((key) => { + return generateStructuredDataset(key, { + type: 'mapValueType', + mapValueType: value[key], + }); + }); + }) + .flat(), + ); + + return mapValueTypes; +} + +function generateEnumTypes() { + const mapValueTypes = [ + generateStructuredDataset(`With_values`, { + type: 'enumType', + enumType: { values: ['1', '2', '3'] }, + }), + generateStructuredDataset(`With_no_values`, { + type: 'enumType', + enumType: { values: [] }, + }), + generateStructuredDataset(`With_null_ values`, { + type: 'enumType', + enumType: { values: null }, + }), + ]; + + return mapValueTypes; +} + +const renderScalars = (scalars: Dictionary) => { + return Object.entries(scalars).map(([label, value]) => { + return ( + <> + {/* */} +
    NEW: + + + ); + }); +}; + +stories.add('Simple types', () => <>{renderScalars(generateSimpleTypes())}); +stories.add('Blob Type', () => <>{renderScalars(generateBlobTypes())}); +stories.add('Schema types', () => <>{renderScalars(generateSchemaTypes())}); +stories.add('Collection Type', () => <>{renderScalars(generateCollectionTypes())}); +stories.add('mapValue Type', () => <>{renderScalars(generateMapValueypes())}); +stories.add('Enum Type', () => <>{renderScalars(generateEnumTypes())}); diff --git a/packages/zapp/console/src/components/Literals/__stories__/helpers/typeGenerators.ts b/packages/zapp/console/src/components/Literals/__stories__/helpers/typeGenerators.ts new file mode 100644 index 000000000..edf237870 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/__stories__/helpers/typeGenerators.ts @@ -0,0 +1,45 @@ +import { Core } from 'flyteidl'; +import { + blobScalars, + schemaScalars, +} from '../scalarValues'; + +// SIMPLE +type GeneratedSimpleType = { + [key in Core.SimpleType]?: Core.LiteralType; +}; +export function extractSimpleTypes() { + const simpleTypes: GeneratedSimpleType[] = Object.keys(Core.SimpleType).map((key) => ({ + [key]: { + type: 'simple', + simple: Core.SimpleType[key], + }, + })); + return simpleTypes; +} + +// SCHEMA +export function extractSchemaTypes() { + return Object.keys(schemaScalars).map((key) => { + const value = schemaScalars[key]; + return { + [key]: { + type: 'schema', + schema: value?.schema?.type, + }, + }; + }); +} + +// COLLECTION TYPE +export function extractBlobTypes() { + return Object.keys(blobScalars).map((key) => { + const value = blobScalars[key]?.['blob']?.metadata?.type; + return { + [key]: { + type: 'blob', + blob: value, + }, + }; + }); +} diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index b990d92c5..be1922e3b 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -1,6 +1,7 @@ import { formatDateUTC, protobufDurationToHMS } from 'common/formatters'; import { sortedObjectEntries, timestampToDate } from 'common/utils'; import { Core } from 'flyteidl'; +import * as Long from 'long'; import { BlobDimensionality, ProtobufListValue, @@ -17,11 +18,12 @@ function processPrimitive(primitive: Core.IPrimitive) { return formatDateUTC(timestampToDate(primitive.datetime!)); case 'duration': return protobufDurationToHMS(primitive.duration!); + case 'integer': { + return Long.fromValue(primitive[type] as any as Long).toNumber(); + } case 'boolean': case 'floatValue': return primitive[type]; - case 'integer': - return +`${primitive[type]}`; case 'stringValue': default: return `${primitive[type]}`; @@ -58,7 +60,7 @@ function processBinary(binary: Core.IBinary) { } // SCHEMA -function columnTypeToString(type: SchemaColumnType) { +export function columnTypeToString(type: SchemaColumnType) { switch (type) { case SchemaColumnType.BOOLEAN: return 'boolean'; @@ -77,11 +79,13 @@ function columnTypeToString(type: SchemaColumnType) { } } -function processSchemaType(schemaType: Core.ISchemaType) { +function processSchemaType(schemaType: Core.ISchemaType, shortString = false) { let columns; if (schemaType?.columns?.length) { - columns = schemaType?.columns.map( - (column) => `${column.name!} (${columnTypeToString(column.type!)})`, + columns = schemaType?.columns.map((column) => + shortString + ? `${columnTypeToString(column.type!)}` + : `${column.name!} (${columnTypeToString(column.type!)})`, ); } @@ -103,7 +107,7 @@ function processNone(none?: Core.IVoid) { return '(empty)'; } -function processUnionType(union: Core.IUnionType) { +function processUnionType(union: Core.IUnionType, shortString = false) { return 'This type is not yet supported'; } @@ -131,6 +135,7 @@ function processProtobufStructValue(struct: ProtobufStruct) { return res; } + function processProtobufValue(value: ProtobufValue) { switch (value.kind) { case 'nullValue': @@ -141,12 +146,11 @@ function processProtobufValue(value: ProtobufValue) { } case 'structValue': return processProtobufStructValue(value?.structValue as ProtobufStruct); - case 'stringValue': - return `${value[value.kind]}`; default: return value[value.kind]; } } + function processGeneric(struct: ProtobufStruct) { const { fields } = struct; const mapContent = Object.keys(fields) @@ -162,67 +166,55 @@ function processGeneric(struct: ProtobufStruct) { } // SIMPLE -function processSimpleType(simpleType: Core.SimpleType, typePrefix: string = '') { - let returnString = ''; +export function processSimpleType(simpleType: Core.SimpleType) { switch (simpleType) { case Core.SimpleType.NONE: - returnString = 'none'; - break; + return 'none'; case Core.SimpleType.INTEGER: - returnString = 'integer'; - break; + return 'integer'; case Core.SimpleType.FLOAT: - returnString = 'float'; - break; + return 'float'; case Core.SimpleType.STRING: - returnString = 'string'; - break; + return 'string'; case Core.SimpleType.BOOLEAN: - returnString = 'booleam'; - break; + return 'booleam'; case Core.SimpleType.DATETIME: - returnString = 'datetime'; - break; + return 'datetime'; case Core.SimpleType.DURATION: - returnString = 'duration'; - break; + return 'duration'; case Core.SimpleType.BINARY: - returnString = 'binary'; - break; + return 'binary'; case Core.SimpleType.ERROR: - returnString = 'error'; - break; + return 'error'; case Core.SimpleType.STRUCT: - returnString = 'struct'; - break; + return 'struct'; } - return `${typePrefix}${returnString}`; } function processEnumType(enumType: Core.IEnumType) { return enumType?.values || []; } -function processLiteralType(literalType: Core.ILiteralType, typePrefix: string = '') { +function processLiteralType(literalType: Core.ILiteralType) { const type = (literalType as Core.LiteralType)?.type; switch (type) { case 'simple': - return processSimpleType(literalType?.simple!, typePrefix); + return processSimpleType(literalType?.simple!); case 'schema': - return processSchemaType(literalType?.schema!); + return `schema (${processSchemaType(literalType?.schema!, true)})`; case 'collectionType': - return processLiteralType(literalType?.collectionType!, (typePrefix = 'collection of ')); + return `collection of ${processLiteralType(literalType?.collectionType!)}`; case 'mapValueType': - return processLiteralType(literalType?.mapValueType!, typePrefix); + return `map value of ${processLiteralType(literalType?.mapValueType!)}`; case 'blob': - return processBlobType(literalType?.blob!, typePrefix); + return processBlobType(literalType?.blob!); case 'enumType': - return processEnumType(literalType?.enumType!); + return `enum (${processEnumType(literalType?.enumType!)})`; case 'structuredDatasetType': return processStructuredDatasetType(literalType?.structuredDatasetType!); case 'unionType': - return processUnionType(literalType?.unionType!); + return processUnionType(literalType?.unionType!, true); default: return 'This type is not yet supported'; } @@ -265,7 +257,6 @@ function processStructuredDataset(structuredDataSet: Core.IStructuredDataset) { }; } - function processScalar(scalar: Core.Scalar | Core.IScalar) { const type = (scalar as Core.Scalar).value; const value = scalar[type!]; @@ -302,7 +293,7 @@ function processMap(map: Core.ILiteralMap) { return transformLiteralMap(map.literals as Core.ILiteralMap); } -export function processLiteralValue(literal: Core.ILiteral) { +function processLiteralValue(literal: Core.ILiteral) { const type = (literal as Core.Literal).value; switch (type) { case 'scalar': diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_collection_test_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_collection_test_case.ts new file mode 100644 index 000000000..480d55a39 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_collection_test_case.ts @@ -0,0 +1,30 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; +import { generateBlobType, getPrimitive } from './literalHelpers'; + +const collection = { + COL_WITH_SCALARTYPE_PRIMITIVE: { + value: { + scalar: { + primitive: getPrimitive('floatValue', 2.1), + value: 'primitive', + }, + value: 'scalar', + } as Core.ILiteral, + expected: { result_var: [2.1] }, + }, + COL_WITH_SCALARTYPE_BLOB: { + value: { + scalar: { + blob: generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), + value: 'blob', + }, + value: 'scalar', + } as Core.ILiteral, + expected: { result_var: [{ type: 'single (csv) blob', uri: '1' }] }, + }, +}; + +export default { + ...collection, +} as any as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_map_test_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_map_test_case.ts new file mode 100644 index 000000000..e504d1336 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_map_test_case.ts @@ -0,0 +1,30 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; +import { generateBlobType, getPrimitive } from './literalHelpers'; + +const collection = { + COL_WITH_SCALARTYPE_PRIMITIVE: { + value: { + scalar: { + primitive: getPrimitive('floatValue', 2.1), + value: 'primitive', + }, + value: 'scalar', + }, + expected: { result_var: { value: 2.1 } }, + }, + COL_WITH_SCALARTYPE_BLOB: { + value: { + scalar: { + blob: generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), + value: 'blob', + }, + value: 'scalar', + }, + expected: { result_var: { value: { type: 'single (csv) blob', uri: '1' } } }, + }, +}; + +export default { + ...collection, +} as any as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_binary_test_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_binary_test_case.ts new file mode 100644 index 000000000..25bc2e906 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_binary_test_case.ts @@ -0,0 +1,13 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; + +export default { + WITH_VAL: { + value: { value: new Uint8Array(), tag: 'tag1' }, + expected: { result_var: { tag: 'tag1 (binary data not shown)' } }, + }, + INT_WITH_SMALL_LOW: { + value: { tag: 'tag2' }, + expected: { result_var: { tag: 'tag2 (binary data not shown)' } }, + }, +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts new file mode 100644 index 000000000..3fee83ca9 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts @@ -0,0 +1,45 @@ +import { Core, Protobuf } from 'flyteidl'; +import { generateBlobType } from './literalHelpers'; +import { TestCaseList, TestCase } from '../types'; + +export default { + single_CSV_BLOB: { + value: generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), + expected: { + result_var: { + type: 'single (csv) blob', + uri: '1', + }, + }, + }, + multi_part_CSV_BLOB: { + value: generateBlobType('csv', Core.BlobType.BlobDimensionality.MULTIPART, '2'), + description: 'low1', + expected: { + result_var: { + type: 'multi-part (csv) blob', + uri: '2', + }, + }, + }, + single_blob_BLOB: { + value: generateBlobType(undefined, Core.BlobType.BlobDimensionality.SINGLE, '3'), + description: 'low1', + expected: { + result_var: { + type: 'single blob', + uri: '3', + }, + }, + }, + single_multi_part_BLOB: { + value: generateBlobType(undefined, Core.BlobType.BlobDimensionality.MULTIPART, '4'), + description: 'low1', + expected: { + result_var: { + type: 'multi-part blob', + uri: '4', + }, + }, + }, +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_error_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_error_case.ts new file mode 100644 index 000000000..4ea352602 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_error_case.ts @@ -0,0 +1,36 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; + +export default { + ERROR_FULL: { + value: { + failedNodeId: '1', + message: 'message 1', + }, + expected: { + result_var: { error: 'message 1', nodeId: '1' }, + }, + }, + ERROR_NO_NODE: { + value: { + message: 'message 2', + }, + expected: { + result_var: { error: 'message 2', nodeId: undefined }, + }, + }, + ERROR_NO_MESSAGE: { + value: { + failedNodeId: '3', + }, + expected: { + result_var: { error: undefined, nodeId: '3' }, + }, + }, + ERROR_EMPTY: { + value: {}, + expected: { + result_var: { error: undefined, nodeId: undefined }, + }, + }, +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts new file mode 100644 index 000000000..79e5c36b0 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts @@ -0,0 +1,155 @@ +import { Protobuf } from 'flyteidl'; +import { TestCaseList } from '../types'; +import { getIValue } from './literalHelpers'; + +const nullValueTestcases = { + WITH_NULL_VAL: { + value: { + fields: { + test_field_name1: { + nullValue: Protobuf.NullValue.NULL_VALUE, + kind: 'nullValue', + }, + } , + }, + expected: { + result_var: { test_field_name1: '(empty)' }, + }, + }, +}; +const numberValueTestCases = { + WITH_NUMBER_VAL: { + value: { + fields: { + test_field_name2: { + numberValue: 1, + kind: 'numberValue', + }, + }, + }, + expected: { + result_var: { test_field_name2: 1 }, + }, + }, + WITH_NUMBER_VAL_NULL: { + value: { + fields: { + test_field_name3: { + numberValue: null, + kind: 'numberValue', + }, + }, + }, + expected: { + result_var: { test_field_name3: null }, + }, + }, +}; +const stringValueTestCases = { + WITH_STRING_VAL: { + value: { + fields: { + test_field_name4: getIValue('stringValue', 'test val'), + }, + }, + expected: { + result_var: { test_field_name4: 'test val' }, + }, + }, + WITH_STRING_VAL_NULL: { + value: { + fields: { + test_field_name: getIValue('stringValue', null), + }, + }, + expected: { + result_var: { test_field_name: null }, + }, + }, +}; + +const boolValueTestCases = { + WITH_BOOL_VAL: { + value: { + fields: { + test_field_name: getIValue('boolValue', true), + }, + }, + expected: { + result_var: { test_field_name: true }, + }, + }, + WITH_BOOL_VAL_FALSE: { + value: { + fields: { + test_field_name: getIValue('boolValue', false), + }, + }, + expected: { + result_var: { test_field_name: false }, + }, + }, + WITH_BOOL_VAL_NULL: { + value: { + fields: { + test_field_name: getIValue('boolValue', null), + }, + }, + expected: { + result_var: { test_field_name: null }, + }, + }, +}; + +const structValueTestCases = { + WITH_STRUCT_VALUE: { + value: { + fields: { + test_struct_name: { + structValue: { + fields: { + struct_string_val_copy: + stringValueTestCases?.WITH_STRING_VAL?.value?.fields?.test_field_name4, + struct_bool_val_copy: + boolValueTestCases?.WITH_BOOL_VAL?.value?.fields?.test_field_name, + }, + }, + kind: 'structValue', + }, + }, + }, + expected: { + result_var: { + test_struct_name: { struct_string_val_copy: 'test val', struct_bool_val_copy: true }, + }, + }, + }, +}; + +const listValueTestCases = { + WITH_LIST_VALUE: { + value: { + fields: { + test_list_name: { + listValue: { + values: [structValueTestCases.WITH_STRUCT_VALUE.value.fields.test_struct_name], + }, + kind: 'listValue', + }, + } , + }, + expected: { + result_var: { + test_list_name: [{ struct_bool_val_copy: true, struct_string_val_copy: 'test val' }], + }, + }, + }, +}; +export default { + ...nullValueTestcases, + ...numberValueTestCases, + ...stringValueTestCases, + ...boolValueTestCases, + ...structValueTestCases, + ...listValueTestCases, +} as any as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_nonetype_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_nonetype_case.ts new file mode 100644 index 000000000..5aa7b01ec --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_nonetype_case.ts @@ -0,0 +1,11 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; + +export default { + VOID_TYPE: { + value: {}, + expected: { + result_var: '(empty)', + }, + }, +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_primitive_cases.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_primitive_cases.ts new file mode 100644 index 000000000..c28849246 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_primitive_cases.ts @@ -0,0 +1,88 @@ +import { Core } from 'flyteidl'; +import * as Long from 'long'; +import { long } from 'test/utils'; +import { getPrimitive } from './literalHelpers'; +import { TestCaseList } from '../types'; + +export default { + INT_WITH_LARGE_LOW: { + value: getPrimitive('integer', { low: 1642627611, high: 0, unsigned: false } as Long), + expected: { result_var: 1642627611 }, + }, + INT_WITH_SMALL_LOW: { + value: getPrimitive('integer', { low: 55, high: 0, unsigned: false } as Long), + expected: { result_var: 55 }, + }, + INT_WITH_ZERO: { + value: getPrimitive('integer', { low: 0, high: 0, unsigned: false } as Long), + expected: { result_var: 0 }, + }, + FLOAT_ZERO: { + value: getPrimitive('floatValue', 0), + expected: { result_var: 0 }, + }, + FLOAT_POSITIVE: { + value: getPrimitive('floatValue', 1.5), + expected: { result_var: 1.5 }, + }, + FLOAT_NEGATIVE: { + value: getPrimitive('floatValue', -1.5), + expected: { result_var: -1.5 }, + }, + FLOAT_LARGE: { + value: getPrimitive('floatValue', 1.25e10), + expected: { result_var: 1.25e10 }, + }, + FLOAT_UNDEF: { + value: getPrimitive('floatValue', undefined), + expected: { result_var: undefined }, + }, + STRING_NULL: { + value: getPrimitive('stringValue', null), + expected: { result_var: 'null' }, + }, + STRING_VALID: { + value: getPrimitive('stringValue', 'some val'), + expected: { result_var: 'some val' }, + }, + STRING_UNDEF: { + value: getPrimitive('stringValue', undefined), + expected: { result_var: 'undefined' }, + }, + STRING_NEG: { + value: getPrimitive('stringValue', '-1'), + expected: { result_var: '-1' }, + }, + BOOL_TRUE: { + value: getPrimitive('boolean', true), + expected: { result_var: true }, + }, + BOOL_FALSE: { + value: getPrimitive('boolean', false), + expected: { result_var: false }, + }, + BOOL_NULL: { + value: getPrimitive('boolean', null), + expected: { result_var: null }, + }, + BOOL_UNDEF: { + value: getPrimitive('boolean', undefined), + expected: { result_var: undefined }, + }, + DT_VALID: { + value: getPrimitive('datetime', { seconds: long(3600), nanos: 0 }), + expected: { result_var: '1/1/1970 1:00:00 AM UTC' }, + }, + DURATION_ZERO: { + value: getPrimitive('duration', { seconds: long(0), nanos: 0 }), + expected: { result_var: '0s' }, + }, + DURATION_1H: { + value: getPrimitive('duration', { seconds: long(3600), nanos: 0 }), + expected: { result_var: '1h' }, + }, + DURATION_LARGE: { + value: getPrimitive('duration', { seconds: long(10000), nanos: 0 }), + expected: { result_var: '2h 46m 40s' }, + }, +} as any as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_schema_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_schema_case.ts new file mode 100644 index 000000000..cfd283712 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_schema_case.ts @@ -0,0 +1,40 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; + +const schemaColumnTypes = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnType) + .map((key, index) => ({ + [`SCHEMA_WITH_${key}`]: { + value: { + uri: index, + type: { + columns: [ + { name: 'name' + index, type: Core.SchemaType.SchemaColumn.SchemaColumnType[key] }, + ], + }, + }, + expected: { + result_var: { uri: index, columns: [`name${index} (${key.toLocaleLowerCase()})`] }, + }, + }, + })) + .reduce((acc, v) => { + return { + ...acc, + ...v, + }; + }, {}) as any; + +export default { + ...schemaColumnTypes, + SCHEMA_WITHOUT_TYPE: { + value: { + uri: 'test7', + type: { + columns: [{ name: 'test7' }], + }, + }, + expected: { + result_var: { uri: 'test7', columns: [`test7 (unknown)`] }, + }, + }, +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts new file mode 100644 index 000000000..488b86e98 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts @@ -0,0 +1,130 @@ +import { Core } from 'flyteidl'; +import { TestCaseList } from '../types'; +import { processSimpleType, columnTypeToString } from '../../helpers'; + +import { simple } from './mock_simpleTypes'; + +const generateColumnEntry = (columnName: string, literalType) => { + return { + name: columnName, + literalType, + }; +}; + +const generateStructuredDataset = (columnName: string, uri: string, literalType) => { + return { + uri, + metadata: { + structuredDatasetType: { + format: 'parquet', + columns: [generateColumnEntry(columnName, literalType)], + }, + }, + }; +}; + + +const sasWithMapValueTypeColumns: any = Object.keys(simple) + .map((simpleTypeKey, index) => { + const simpleType = simple[simpleTypeKey]; + + const literalType = { + mapValueType: { + ...simpleType, + }, + type: 'mapValueType', + }; + + const name = `column_name_${index}`; + const columns = []; + columns[name] = `map value of ${processSimpleType(simpleType[simpleType.type])}`; + + return { + [`STRUCT_SIMPLE_${simpleTypeKey}`]: { + value: generateStructuredDataset(name, index.toString(), literalType), + expected: { + result_var: { columns, format: 'parquet', uri: index.toString() }, + }, + }, + }; + }) + .reduce((acc, v) => ({ ...acc, ...v }), {}); + +const sasWithCollectionTypeColumns: any = Object.keys(simple) + .map((simpleTypeKey, index) => { + const simpleType = simple[simpleTypeKey]; + + const literalType = { + collectionType: { + ...simpleType, + }, + type: 'collectionType', + }; + + const name = `column_name_${index}`; + const columns = []; + columns[name] = `collection of ${processSimpleType(simpleType[simpleType.type])}`; + + return { + [`STRUCT_SIMPLE_${simpleTypeKey}`]: { + value: generateStructuredDataset(name, index.toString(), literalType), + expected: { + result_var: { columns, format: 'parquet', uri: index.toString() }, + }, + }, + }; + }) + .slice(0, 1) + .reduce((acc, v) => ({ ...acc, ...v }), {}); + +const sdsWithSimpleTypeColumns: any = Object.keys(simple) + .map((simpleTypeKey, index) => { + const literalType = simple[simpleTypeKey]; + + const name = `column_name_${index}`; + const columns = []; + columns[name] = processSimpleType(literalType[literalType.type]); + + return { + [`STRUCT_SIMPLE_${simpleTypeKey}`]: { + value: generateStructuredDataset(name, index.toString(), literalType), + expected: { + result_var: { columns, format: 'parquet', uri: index.toString() }, + }, + }, + }; + }) + .reduce((acc, v) => ({ ...acc, ...v }), {}); + +const sasWithSchemaColumns = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnType) + .map((simpleTypeKey, index) => { + const literalType = { + schema: { + columns: [{ type: Core.SchemaType.SchemaColumn.SchemaColumnType[simpleTypeKey] }], + }, + type: 'schema', + }; + + const name = `schema_column_name_${index}`; + const columns = []; + columns[name] = `schema (${columnTypeToString( + Core.SchemaType.SchemaColumn.SchemaColumnType[simpleTypeKey], + )})`; + + return { + [`STRUCT_SCHEMA_WITH_COLUMNS_${simpleTypeKey}`]: { + value: generateStructuredDataset(name, index.toString(), literalType), + expected: { + result_var: { columns, format: 'parquet', uri: index.toString() }, + }, + }, + }; + }) + .reduce((acc, v) => ({ ...acc, ...v }), {}); + +export default { + ...sdsWithSimpleTypeColumns, + ...sasWithSchemaColumns, + ...sasWithCollectionTypeColumns, + ...sasWithMapValueTypeColumns +} as any as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/index.ts b/packages/zapp/console/src/components/Literals/test/helpers/index.ts new file mode 100644 index 000000000..502682309 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/index.ts @@ -0,0 +1,23 @@ +import primitive from './gen_scalar_primitive_cases'; +import blob from './gen_scalar_blob_cases'; +import binary from './gen_scalar_binary_test_case'; +import schema from './gen_scalar_schema_case'; +import noneType from './gen_scalar_nonetype_case'; +import errorType from './gen_scalar_error_case'; +import generic from './gen_scalar_generic_case'; +import structuredDataset from './gen_scalar_structured_ds_case'; +import collection from './gen_collection_test_case'; +import map from './gen_map_test_case'; + +export { + primitive, + blob, + binary, + schema, + noneType, + errorType, + generic, + structuredDataset, + collection, + map, +}; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts new file mode 100644 index 000000000..14fbe29f1 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts @@ -0,0 +1,80 @@ +import { Core, Protobuf } from 'flyteidl'; + +export function getIValue( + kind: 'nullValue' | 'numberValue' | 'stringValue' | 'boolValue' | 'structValue' | 'listValue', + value?: + | Protobuf.NullValue + | number + | string + | boolean + | Protobuf.IStruct + | Protobuf.IListValue + | null, +): Core.Primitive | Core.IPrimitive { + return { + kind, + [kind]: value, + } as any as Protobuf.Value; +} + +export function getPrimitive( + key: 'integer' | 'floatValue' | 'stringValue' | 'boolean' | 'datetime' | 'duration', + value?: Long | number | string | boolean | Protobuf.ITimestamp | Protobuf.IDuration | null, +): Core.Primitive | Core.IPrimitive { + return { + [key]: value, + value: key, + } as any as Core.Primitive; +} + +export function generateBlobType( + format?: string, + dimensionality?: Core.BlobType.BlobDimensionality, + uri?: string, +): Core.IBlob { + return { + metadata: { + type: { + format, + dimensionality, + }, + }, + uri, + }; +} + +// TOP LEVEL SCHEMA GENERATORS: +export const getScalar = ( + value: Core.IPrimitive | Core.IBlob | Core.IBinary, + scalarType: string, +) => { + return { + scalar: { + [scalarType]: value, + value: scalarType, + }, + value: 'scalar', + } as Core.IScalar; +}; + +export const getCollection = (literals: Core.ILiteral[]) => { + return { + result_var: { + collection: { + literals, + }, + value: 'collection', + } as Core.ILiteralCollection, + }; +}; + +export const getMap = (literals: { [k: string]: Core.ILiteral } | null) => { + return { + result_var: { + map: { + literals, + }, + value: 'map', + } as Core.ILiteralMap, + }; +}; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/mock_simpleTypes.ts b/packages/zapp/console/src/components/Literals/test/helpers/mock_simpleTypes.ts new file mode 100644 index 000000000..0bd9d543f --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/helpers/mock_simpleTypes.ts @@ -0,0 +1,17 @@ +import { Core } from 'flyteidl'; + +export function extractSimpleTypes() { + const simpleTypes= Object.keys(Core.SimpleType).map((key) => ({ + [key]: { + type: 'simple', + simple: Core.SimpleType[key], + }, + })).reduce((acc, v) => ({...acc, ...v}), {}); + return simpleTypes; +} + +const simple: Core.SimpleType[] = extractSimpleTypes() as any; + +export { + simple +}; diff --git a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts new file mode 100644 index 000000000..9b17ea4ed --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts @@ -0,0 +1,78 @@ +import { Core } from 'flyteidl'; +import { transformLiteralMap } from '../helpers'; + +import { + primitive, + blob, + binary, + schema, + noneType, + errorType, + generic, + structuredDataset, + collection, + map, +} from './helpers/index'; +import { getCollection, getMap, getScalar } from './helpers/literalHelpers'; + +const literalTestCases = { + scalar: { + primitive, + blob, + binary, + schema, + noneType, + error: errorType, + generic, + structuredDataset, + union: {} as Core.IPrimitive, // todo + }, + collection, + map, +}; + +describe('scalar literal', () => { + const scalarTestTypes = Object.keys(literalTestCases?.scalar!); + scalarTestTypes.map((scalarTestType) => { + describe(scalarTestType, () => { + const cases = literalTestCases?.scalar?.[scalarTestType]; + Object.keys(cases || {}).map((testKey) => { + const { value, expected } = cases?.[testKey]!; + + it(`${testKey}: should return ${expected} for ${value}`, () => { + const scalar = { result_var: { ...getScalar(value, scalarTestType) } }; + const result = transformLiteralMap(scalar as any); + expect(result).toEqual(expected); + }); + }); + }); + }); +}); + +describe('collection literal', () => { + const cases = literalTestCases?.collection; + Object.keys(cases || {}).map((testKey) => { + const { value, expected } = cases?.[testKey]!; + + it(`${testKey}: should return ${expected} for ${value}`, () => { + const collection = getCollection([value]); + + const result = transformLiteralMap(collection as any); + expect(result).toEqual(expected); + }); + }); +}); + +describe('map literal', () => { + const cases = literalTestCases?.map; + Object.keys(cases || {}).map((testKey) => { + const { value, expected } = cases?.[testKey]!; + + it(`${testKey}: should return ${expected} for ${value}`, () => { + const collection = getMap({ value }); + + const result = transformLiteralMap(collection as any); + expect(result).toEqual(expected); + }); + }); +}); diff --git a/packages/zapp/console/src/components/Literals/test/types.d.ts b/packages/zapp/console/src/components/Literals/test/types.d.ts new file mode 100644 index 000000000..04572a2b5 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/test/types.d.ts @@ -0,0 +1,8 @@ +export type TestCase = { + value: K; + expected: any; +}; + +export type TestCaseList = { + [key: string]: TestCase; +}; From 88d46726385fe4cf364e184a727c46a8f59967a7 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Tue, 3 May 2022 14:12:45 -0700 Subject: [PATCH 03/21] chore: add package Signed-off-by: Carina Ursu --- packages/zapp/console/package.json | 1 + .../components/Literals/test/helpers/gen_scalar_blob_cases.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/zapp/console/package.json b/packages/zapp/console/package.json index fa1706344..003f9eed9 100644 --- a/packages/zapp/console/package.json +++ b/packages/zapp/console/package.json @@ -48,6 +48,7 @@ "react-chartjs-2": "^4.0.0", "react-flow-renderer": "10.1.1", "react-ga4": "^1.4.1", + "react-json-view": "1.21.3", "react-transition-group": "^2.3.1", "serve-static": "^1.12.3", "tslib": "^1.9.0" diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts index 3fee83ca9..a6665e5d1 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts @@ -1,6 +1,6 @@ -import { Core, Protobuf } from 'flyteidl'; +import { Core } from 'flyteidl'; import { generateBlobType } from './literalHelpers'; -import { TestCaseList, TestCase } from '../types'; +import { TestCaseList } from '../types'; export default { single_CSV_BLOB: { From 116122d1c8795899f1e23a7baa97980b7b90184c Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Tue, 3 May 2022 17:21:10 -0700 Subject: [PATCH 04/21] chore: resolving local package issue Signed-off-by: Carina Ursu --- packages/zapp/console/package.json | 2 +- yarn.lock | 209 ++++++++++++++--------------- 2 files changed, 104 insertions(+), 107 deletions(-) diff --git a/packages/zapp/console/package.json b/packages/zapp/console/package.json index 003f9eed9..aea34695a 100644 --- a/packages/zapp/console/package.json +++ b/packages/zapp/console/package.json @@ -48,7 +48,7 @@ "react-chartjs-2": "^4.0.0", "react-flow-renderer": "10.1.1", "react-ga4": "^1.4.1", - "react-json-view": "1.21.3", + "react-json-view": "^1.21.3", "react-transition-group": "^2.3.1", "serve-static": "^1.12.3", "tslib": "^1.9.0" diff --git a/yarn.lock b/yarn.lock index e04f21af6..55479c871 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5273,11 +5273,6 @@ aria-query@^5.0.0: resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c" integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg== -arr-diff@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" - integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= - arr-flatten@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" @@ -5380,7 +5375,7 @@ arrify@^2.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== -asap@^2.0.0: +asap@^2.0.0, asap@~2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= @@ -5739,6 +5734,11 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base16@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/base16/-/base16-1.0.0.tgz#e297f60d7ec1014a7a971a39ebc8a98c0b681e70" + integrity sha1-4pf2DX7BAUp6lxo568ipjAtoHnA= + base64-js@^1.0.2, base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -5958,7 +5958,7 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^2.3.1, braces@^2.3.2: +braces@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== @@ -5974,7 +5974,7 @@ braces@^2.3.1, braces@^2.3.2: split-string "^3.0.2" to-regex "^3.0.1" -braces@^3.0.1, braces@^3.0.2, braces@~3.0.2: +braces@^3.0.1, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -7398,6 +7398,13 @@ cronstrue@^1.31.0: resolved "https://registry.yarnpkg.com/cronstrue/-/cronstrue-1.105.0.tgz#57f89468c261d7fa56c69057f42c84eba3a37837" integrity sha512-Bv8GHi5uJvxtq/9T7lgBwum7UVKMfR+LSPHZXiezP0E5gnODPVRQBAkCwijCIaWEepqmRcxTAxrUFB0UQK2wdw== +cross-fetch@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" + integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== + dependencies: + node-fetch "2.6.7" + cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -7960,7 +7967,7 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: +debug@2.6.9, debug@^2.2.0, debug@^2.6.0, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -9174,19 +9181,6 @@ exit@^0.1.2: resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= -expand-brackets@^2.1.4: - version "2.1.4" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" - integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= - dependencies: - debug "^2.3.3" - define-property "^0.2.5" - extend-shallow "^2.0.1" - posix-character-classes "^0.1.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - expand-template@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-2.0.3.tgz#6e14b3fcee0f3a6340ecb57d2e8918692052a47c" @@ -9303,20 +9297,6 @@ extend@^3.0.0, extend@~3.0.2: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -extglob@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" - integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== - dependencies: - array-unique "^0.3.2" - define-property "^1.0.0" - expand-brackets "^2.1.4" - extend-shallow "^2.0.1" - fragment-cache "^0.2.1" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -9451,6 +9431,31 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" +fbemitter@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/fbemitter/-/fbemitter-3.0.0.tgz#00b2a1af5411254aab416cd75f9e6289bee4bff3" + integrity sha512-KWKaceCwKQU0+HPoop6gn4eOHk50bBv/VxjJtGMfwmJt3D29JpN4H4eisCtIPA+a8GVBam+ldMMpMjJUvpDyHw== + dependencies: + fbjs "^3.0.0" + +fbjs-css-vars@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz#216551136ae02fe255932c3ec8775f18e2c078b8" + integrity sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ== + +fbjs@^3.0.0, fbjs@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.4.tgz#e1871c6bd3083bac71ff2da868ad5067d37716c6" + integrity sha512-ucV0tDODnGV3JCnnkmoszb5lf4bNpzjv80K41wd4k798Etq+UYD0y0TIfalLjZoKgjive6/adkRnszwapiDgBQ== + dependencies: + cross-fetch "^3.1.5" + fbjs-css-vars "^1.0.0" + loose-envify "^1.0.0" + object-assign "^4.1.0" + promise "^7.1.1" + setimmediate "^1.0.5" + ua-parser-js "^0.7.30" + figgy-pudding@^3.4.1, figgy-pudding@^3.5.1: version "3.5.2" resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" @@ -9638,6 +9643,14 @@ flush-write-stream@^1.0.0: inherits "^2.0.3" readable-stream "^2.3.6" +flux@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/flux/-/flux-4.0.3.tgz#573b504a24982c4768fdfb59d8d2ea5637d72ee7" + integrity sha512-yKAbrp7JhZhj6uiT1FTuVMlIAT1J4jqEyBpFApi1kxpGZCvacMVc/t1pMQyotqHhAgvoE3bNvAykhCo2CLjnYw== + dependencies: + fbemitter "^3.0.0" + fbjs "^3.0.1" + follow-redirects@^1.0.0, follow-redirects@^1.14.0: version "1.14.8" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" @@ -9743,13 +9756,6 @@ forwarded@~0.1.2: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= -fragment-cache@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" - integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= - dependencies: - map-cache "^0.2.2" - fresh@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" @@ -12966,6 +12972,11 @@ lodash.clonedeep@^4.5.0, lodash.clonedeep@~4.5.0: resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= +lodash.curry@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.curry/-/lodash.curry-4.1.1.tgz#248e36072ede906501d75966200a86dab8b23170" + integrity sha1-JI42By7ekGUB11lmIAqG2riyMXA= + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" @@ -12981,6 +12992,11 @@ lodash.escaperegexp@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347" integrity sha1-ZHYsSGGAglGKw99Mz11YhtriA0c= +lodash.flow@^3.3.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/lodash.flow/-/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a" + integrity sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o= + lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" @@ -13453,26 +13469,7 @@ microevent.ts@~0.1.1: resolved "https://registry.yarnpkg.com/microevent.ts/-/microevent.ts-0.1.1.tgz#70b09b83f43df5172d0205a63025bce0f7357fa0" integrity sha512-jo1OfR4TaEwd5HOrt5+tAZ9mqT4jmpNAusXtyfNzqVm9uiSYFZlKM1wYL4oU7azZW/PxQW53wM0S6OR1JHNa2g== -micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8: - version "3.1.10" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" - integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - braces "^2.3.1" - define-property "^2.0.2" - extend-shallow "^3.0.2" - extglob "^2.0.4" - fragment-cache "^0.2.1" - kind-of "^6.0.2" - nanomatch "^1.2.9" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.2" - -micromatch@^4.0.0, micromatch@^4.0.2: +micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8, micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4: version "4.0.2" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== @@ -13480,14 +13477,6 @@ micromatch@^4.0.0, micromatch@^4.0.2: braces "^3.0.1" picomatch "^2.0.5" -micromatch@^4.0.4: - version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" @@ -13843,23 +13832,6 @@ nanoid@^3.3.1: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== -nanomatch@^1.2.9: - version "1.2.13" - resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" - integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - define-property "^2.0.2" - extend-shallow "^3.0.2" - fragment-cache "^0.2.1" - is-windows "^1.0.2" - kind-of "^6.0.2" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - napi-build-utils@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" @@ -13943,7 +13915,7 @@ node-fetch-npm@^2.0.2: json-parse-better-errors "^1.0.0" safe-buffer "^5.1.1" -node-fetch@^2.6.1: +node-fetch@2.6.7, node-fetch@^2.6.1: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== @@ -14506,13 +14478,6 @@ object.hasown@^1.1.0: define-properties "^1.1.3" es-abstract "^1.19.1" -object.pick@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" - integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= - dependencies: - isobject "^3.0.1" - object.values@^1.1.0, object.values@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" @@ -15115,7 +15080,7 @@ picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== -picomatch@^2.3.0, picomatch@^2.3.1: +picomatch@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -15235,11 +15200,6 @@ portfinder@^1.0.28: debug "^3.1.1" mkdirp "^0.5.5" -posix-character-classes@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" - integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= - postcss-flexbugs-fixes@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/postcss-flexbugs-fixes/-/postcss-flexbugs-fixes-4.2.1.tgz#9218a65249f30897deab1033aced8578562a6690" @@ -15504,6 +15464,13 @@ promise.prototype.finally@^3.1.0: define-properties "^1.1.3" es-abstract "^1.19.1" +promise@^7.1.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" + integrity sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg== + dependencies: + asap "~2.0.3" + prompts@^2.0.1: version "2.4.0" resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.0.tgz#4aa5de0723a231d1ee9121c40fdf663df73f61d7" @@ -15666,6 +15633,11 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +pure-color@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/pure-color/-/pure-color-1.3.0.tgz#1fe064fb0ac851f0de61320a8bf796836422f33e" + integrity sha1-H+Bk+wrIUfDeYTIKi/eWg2Qi8z4= + q@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" @@ -15807,6 +15779,16 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7, rc@^1.2.8: minimist "^1.2.0" strip-json-comments "~2.0.1" +react-base16-styling@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/react-base16-styling/-/react-base16-styling-0.6.0.tgz#ef2156d66cf4139695c8a167886cb69ea660792c" + integrity sha1-7yFW1mz0E5aVyKFniGy2nqZgeSw= + dependencies: + base16 "^1.0.0" + lodash.curry "^4.0.1" + lodash.flow "^3.3.0" + pure-color "^1.2.0" + react-chartjs-2@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/react-chartjs-2/-/react-chartjs-2-4.0.0.tgz#a79919c9efe5381b8cb5abfd0ac7a56c9736cdb8" @@ -15956,6 +15938,16 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339" integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA== +react-json-view@^1.21.3: + version "1.21.3" + resolved "https://registry.yarnpkg.com/react-json-view/-/react-json-view-1.21.3.tgz#f184209ee8f1bf374fb0c41b0813cff54549c475" + integrity sha512-13p8IREj9/x/Ye4WI/JpjhoIwuzEgUAtgJZNBJckfzJt1qyh24BdTm6UQNGnyTq9dapQdrqvquZTo3dz1X6Cjw== + dependencies: + flux "^4.0.1" + react-base16-styling "^0.6.0" + react-lifecycles-compat "^3.0.4" + react-textarea-autosize "^8.3.2" + react-lifecycles-compat@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" @@ -16070,7 +16062,7 @@ react-syntax-highlighter@^13.5.3: prismjs "^1.21.0" refractor "^3.1.0" -react-textarea-autosize@^8.3.0: +react-textarea-autosize@^8.3.0, react-textarea-autosize@^8.3.2: version "8.3.3" resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.3.3.tgz#f70913945369da453fd554c168f6baacd1fa04d8" integrity sha512-2XlHXK2TDxS6vbQaoPbMOfQ8GK7+irc2fVK6QFIcC8GOnH3zI/v481n+j1L0WaPVvKxwesnY93fEfH++sus2rQ== @@ -16375,7 +16367,7 @@ regenerator-transform@^0.14.2: dependencies: "@babel/runtime" "^7.8.4" -regex-not@^1.0.0, regex-not@^1.0.2: +regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== @@ -17161,7 +17153,7 @@ set-value@^2.0.0, set-value@^2.0.1: is-plain-object "^2.0.3" split-string "^3.0.1" -setimmediate@^1.0.4: +setimmediate@^1.0.4, setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= @@ -18349,7 +18341,7 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -to-regex@^3.0.1, to-regex@^3.0.2: +to-regex@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== @@ -18618,6 +18610,11 @@ typescript@^4.6.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== +ua-parser-js@^0.7.30: + version "0.7.31" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" + integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ== + uc.micro@^1.0.1: version "1.0.6" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" From 2e9725ea0fc510a0bf6b5a07b8346bb9055aa9d6 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 10:21:36 -0700 Subject: [PATCH 05/21] chore: yarn lock Signed-off-by: Carina Ursu --- yarn.lock | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 102 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index 55479c871..0e47e4ccc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5273,6 +5273,11 @@ aria-query@^5.0.0: resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c" integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg== +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= + arr-flatten@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" @@ -5958,7 +5963,7 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^2.3.2: +braces@^2.3.1, braces@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== @@ -5974,7 +5979,7 @@ braces@^2.3.2: split-string "^3.0.2" to-regex "^3.0.1" -braces@^3.0.1, braces@~3.0.2: +braces@^3.0.1, braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -7967,7 +7972,7 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@2.6.9, debug@^2.2.0, debug@^2.6.0, debug@^2.6.9: +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -9181,6 +9186,19 @@ exit@^0.1.2: resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + expand-template@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/expand-template/-/expand-template-2.0.3.tgz#6e14b3fcee0f3a6340ecb57d2e8918692052a47c" @@ -9297,6 +9315,20 @@ extend@^3.0.0, extend@~3.0.2: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -9756,6 +9788,13 @@ forwarded@~0.1.2: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= + dependencies: + map-cache "^0.2.2" + fresh@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" @@ -13469,7 +13508,26 @@ microevent.ts@~0.1.1: resolved "https://registry.yarnpkg.com/microevent.ts/-/microevent.ts-0.1.1.tgz#70b09b83f43df5172d0205a63025bce0f7357fa0" integrity sha512-jo1OfR4TaEwd5HOrt5+tAZ9mqT4jmpNAusXtyfNzqVm9uiSYFZlKM1wYL4oU7azZW/PxQW53wM0S6OR1JHNa2g== -micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8, micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4: +micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +micromatch@^4.0.0, micromatch@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259" integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q== @@ -13477,6 +13535,14 @@ micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8, micromatch@^4.0.0, mic braces "^3.0.1" picomatch "^2.0.5" +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" @@ -13832,6 +13898,23 @@ nanoid@^3.3.1: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + napi-build-utils@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" @@ -14478,6 +14561,13 @@ object.hasown@^1.1.0: define-properties "^1.1.3" es-abstract "^1.19.1" +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= + dependencies: + isobject "^3.0.1" + object.values@^1.1.0, object.values@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" @@ -15080,7 +15170,7 @@ picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== -picomatch@^2.3.0: +picomatch@^2.3.0, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -15200,6 +15290,11 @@ portfinder@^1.0.28: debug "^3.1.1" mkdirp "^0.5.5" +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= + postcss-flexbugs-fixes@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/postcss-flexbugs-fixes/-/postcss-flexbugs-fixes-4.2.1.tgz#9218a65249f30897deab1033aced8578562a6690" @@ -16367,7 +16462,7 @@ regenerator-transform@^0.14.2: dependencies: "@babel/runtime" "^7.8.4" -regex-not@^1.0.2: +regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== @@ -18341,7 +18436,7 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -to-regex@^3.0.1: +to-regex@^3.0.1, to-regex@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== From 3e716623c0d5214e9ac9987d3fe8ec092ee81021 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 13:46:21 -0700 Subject: [PATCH 06/21] chore: stories Signed-off-by: Carina Ursu --- .../ExecutionInputsOutputsModal.tsx | 10 ++-- .../Literals/DeprecatedLiteralMapViewer.tsx | 56 +++++++++++++++++++ .../components/Literals/LiteralMapViewer.tsx | 31 +--------- .../src/components/Literals/LiteralValue.tsx | 5 +- .../__stories__/Collection.stories.tsx | 28 ++++++++-- .../Literals/__stories__/Map.stories.tsx | 24 ++++++-- .../__stories__/ProtobufStruct.stories.tsx | 49 ++++++++++------ .../__stories__/StructuredDataSet.stories.tsx | 6 +- .../src/components/common/ReactJsonView.tsx | 3 +- 9 files changed, 145 insertions(+), 67 deletions(-) create mode 100644 packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx diff --git a/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx b/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx index de86f5ac7..1c73d3ec9 100644 --- a/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx +++ b/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx @@ -2,7 +2,7 @@ import { Dialog, DialogContent, Tab, Tabs } from '@material-ui/core'; import { makeStyles, Theme } from '@material-ui/core/styles'; import { ClosableDialogTitle } from 'components/common/ClosableDialogTitle'; import { WaitForData } from 'components/common/WaitForData'; -import { LiteralMapViewer } from 'components/Literals/LiteralMapViewer'; +import { DeprecatedLiteralMapViewer } from 'components/Literals/DeprecatedLiteralMapViewer'; import { emptyLiteralMapBlob } from 'models/Common/constants'; import { Execution } from 'models/Execution/types'; import * as React from 'react'; @@ -41,7 +41,7 @@ const RemoteExecutionInputs: React.FC<{ execution: Execution }> = ({ execution } const executionData = useWorkflowExecutionData(execution.id); return ( - + ); }; @@ -50,7 +50,7 @@ const RemoteExecutionOutputs: React.FC<{ execution: Execution }> = ({ execution const executionData = useWorkflowExecutionData(execution.id); return ( - + ); }; @@ -59,7 +59,7 @@ const RenderInputs: React.FC<{ execution: Execution }> = ({ execution }) => { // computedInputs is deprecated, but older data may still use that field. // For new records, the inputs will always need to be fetched separately return execution.closure.computedInputs ? ( - + ) : ( ); @@ -73,7 +73,7 @@ const RenderOutputs: React.FC<{ execution: Execution }> = ({ execution }) => { return outputs.uri ? ( ) : ( - + ); }; diff --git a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx new file mode 100644 index 000000000..c075f3959 --- /dev/null +++ b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx @@ -0,0 +1,56 @@ +import classnames from 'classnames'; +import { sortedObjectEntries } from 'common/utils'; +import { useCommonStyles } from 'components/common/styles'; +import { Literal, LiteralMap } from 'models/Common/types'; +import * as React from 'react'; +import { htmlEntities } from './constants'; +import { LiteralValue } from './LiteralValue'; +import { NoneTypeValue } from './Scalar/NoneTypeValue'; + +export const NoDataIsAvailable = () => { + return ( +

    + No data is available. +

    + ); +}; + +/** Renders a LiteralMap as a formatted object */ +export const DeprecatedLiteralMapViewer: React.FC<{ + className?: string; + map: LiteralMap | null; + showBrackets?: boolean; +}> = ({ className, map, showBrackets = false }) => { + if (!map) { + return ; + } + + const commonStyles = useCommonStyles(); + const { literals } = map; + + if (!Object.keys(literals).length) { + return ; + } + + const mapContent = Object.keys(literals).length ? ( +
      + {sortedObjectEntries(literals).map(([key, value]) => ( +
    • + +
    • + ))} +
    + ) : ( +
    + +
    + ); + + return ( + <> + {showBrackets && {htmlEntities.leftCurlyBrace}} + {mapContent} + {showBrackets && {htmlEntities.rightCurlyBrace}} + + ); +}; diff --git a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx index 8eaf58c65..40e6efee9 100644 --- a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx @@ -1,12 +1,7 @@ -import classnames from 'classnames'; -import { sortedObjectEntries } from 'common/utils'; import { ReactJsonViewWrapper } from 'components/common/ReactJsonView'; -import { useCommonStyles } from 'components/common/styles'; -import { Literal, LiteralMap } from 'models/Common/types'; +import { LiteralMap } from 'models/Common/types'; import * as React from 'react'; -import { htmlEntities } from './constants'; import { transformLiteralMap } from './helpers'; -import { LiteralValue } from './LiteralValue'; import { NoneTypeValue } from './Scalar/NoneTypeValue'; export const NoDataIsAvailable = () => { @@ -22,13 +17,11 @@ export const LiteralMapViewer: React.FC<{ className?: string; map: LiteralMap | null; showBrackets?: boolean; - showJson?: boolean; -}> = ({ className, map, showBrackets = false, showJson }) => { +}> = ({ map }) => { if (!map) { return ; } - const commonStyles = useCommonStyles(); const { literals } = map; if (!Object.keys(literals).length) { @@ -37,20 +30,6 @@ export const LiteralMapViewer: React.FC<{ let transformedLiterals = transformLiteralMap(literals); - const mapContent = Object.keys(literals).length ? ( -
      - {sortedObjectEntries(literals).map(([key, value]) => ( -
    • - -
    • - ))} -
    - ) : ( -
    - -
    - ); - let rootNode: string | null = null; const transformedLiteralsKeys = Object.keys(transformedLiterals); @@ -64,11 +43,7 @@ export const LiteralMapViewer: React.FC<{ return ( <> - {showBrackets && {htmlEntities.leftCurlyBrace}} - {mapContent} - {showBrackets && {htmlEntities.rightCurlyBrace}} - - {showJson !== false && } + ); }; diff --git a/packages/zapp/console/src/components/Literals/LiteralValue.tsx b/packages/zapp/console/src/components/Literals/LiteralValue.tsx index 399bef340..e4e4756b9 100644 --- a/packages/zapp/console/src/components/Literals/LiteralValue.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralValue.tsx @@ -1,7 +1,7 @@ import { Literal, LiteralCollection, LiteralMap, Scalar } from 'models/Common/types'; import * as React from 'react'; import { LiteralCollectionViewer } from './LiteralCollectionViewer'; -import { LiteralMapViewer } from './LiteralMapViewer'; +import { DeprecatedLiteralMapViewer } from './DeprecatedLiteralMapViewer'; import { ScalarValue } from './Scalar/ScalarValue'; import { useLiteralStyles } from './styles'; import { UnsupportedType } from './UnsupportedType'; @@ -27,11 +27,10 @@ export const LiteralValue: React.FC<{ return ( <> - ); diff --git a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx index 2e5840aab..76ba85d60 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx @@ -1,8 +1,9 @@ import { storiesOf } from '@storybook/react'; import { LiteralCollection } from 'models/Common/types'; import * as React from 'react'; -import { LiteralValue } from '../LiteralValue'; +import { Card, CardContent } from '@material-ui/core'; import { LiteralMapViewer } from '../LiteralMapViewer'; +import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; import { CardDecorator } from './CardDecorator'; import { binaryLiterals, @@ -19,9 +20,28 @@ stories.addDecorator(CardDecorator); function renderCollection(label: string, collection: LiteralCollection) { return ( <> - -
    NEW: - +
    +
    + OLD + + + + + +
    +
    + NEW + + + + + +
    +
    ); } diff --git a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx index b470a308c..fd2203df5 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx @@ -1,6 +1,7 @@ import { storiesOf } from '@storybook/react'; import { LiteralMap } from 'models/Common/types'; import * as React from 'react'; +import { Card, CardContent } from '@material-ui/core'; import { LiteralValue } from '../LiteralValue'; import { CardDecorator } from './CardDecorator'; import { @@ -12,6 +13,7 @@ import { schemaLiterals, } from './literalValues'; import { LiteralMapViewer } from '../LiteralMapViewer'; +import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; const stories = storiesOf('Literals/Map', module); stories.addDecorator(CardDecorator); @@ -19,10 +21,24 @@ stories.addDecorator(CardDecorator); function renderMap(label: string, map: LiteralMap) { return ( <> - -
    NEW: - - +
    +
    + OLD + + + + + +
    +
    + NEW + + + + + +
    +
    ); } diff --git a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx index 8f2f982fa..48ab579d6 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx @@ -1,32 +1,49 @@ import { storiesOf } from '@storybook/react'; import { ProtobufListValue, ProtobufStruct } from 'models/Common/types'; import * as React from 'react'; -import { LiteralValue } from '../LiteralValue'; +import { Card, CardContent } from '@material-ui/core'; import { CardDecorator } from './CardDecorator'; import { protobufValues } from './protobufValues'; import { LiteralMapViewer } from '../LiteralMapViewer'; +import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; + const stories = storiesOf('Literals/ProtobufStruct', module); stories.addDecorator(CardDecorator); function renderStruct(label: string, struct: ProtobufStruct) { return ( <> - -
    NEW: - - +
    +
    + OLD + + + + + +
    +
    + NEW + + + + + +
    +
    ); } diff --git a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx index b6358ddf8..84fd7c1a7 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx @@ -4,9 +4,7 @@ import * as React from 'react'; import { Core } from 'flyteidl'; import { LiteralMapViewer } from '../LiteralMapViewer'; import { CardDecorator } from './CardDecorator'; -import { - blobScalars, -} from './scalarValues'; +import { blobScalars } from './scalarValues'; import { extractSimpleTypes, extractSchemaTypes, extractBlobTypes } from './helpers/typeGenerators'; const stories = storiesOf('Literals/StructuredDataSet', module); @@ -161,8 +159,6 @@ const renderScalars = (scalars: Dictionary) => { return Object.entries(scalars).map(([label, value]) => { return ( <> - {/* */} -
    NEW: ); diff --git a/packages/zapp/console/src/components/common/ReactJsonView.tsx b/packages/zapp/console/src/components/common/ReactJsonView.tsx index 95b426d21..09710866e 100644 --- a/packages/zapp/console/src/components/common/ReactJsonView.tsx +++ b/packages/zapp/console/src/components/common/ReactJsonView.tsx @@ -2,13 +2,12 @@ import * as React from 'react'; import { makeStyles, Theme } from '@material-ui/core/styles'; import ReactJsonView, { ReactJsonViewProps } from 'react-json-view'; import * as copyToClipboard from 'copy-to-clipboard'; -import { primaryTextColor, smallFontSize } from 'components/Theme/constants'; +import { primaryTextColor } from 'components/Theme/constants'; const useStyles = makeStyles((theme: Theme) => ({ jsonViewer: { marginLeft: '-10px', width: '100%', - fontSize: smallFontSize, '& span': { fontWeight: 'normal !important', }, From 914da17688933dc67832dca1587aa16bb6c1a3e7 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 16:08:25 -0700 Subject: [PATCH 07/21] chore: fix associative arrays in copy functionality Signed-off-by: Carina Ursu --- .../Literals/__stories__/Map.stories.tsx | 1 - .../__stories__/ProtobufStruct.stories.tsx | 1 - .../__stories__/StructuredDataSet.stories.tsx | 2 +- .../src/components/Literals/helpers.ts | 1 + ..._test_case.ts => genCollectionTestcase.ts} | 0 ...gen_map_test_case.ts => genMapTestCase.ts} | 0 ...est_case.ts => genScalarBinaryTestCase.ts} | 0 ...ar_blob_cases.ts => genScalarBlobCases.ts} | 0 ...ar_error_case.ts => genScalarErrorCase.ts} | 0 ...eneric_case.ts => genScalarGenericCase.ts} | 6 +-- ..._nonetype_case.ts => genScalarNoneCase.ts} | 0 ...ve_cases.ts => genScalarPrimitiveCases.ts} | 0 ..._schema_case.ts => genScalarSchemaCase.ts} | 0 ...s_case.ts => genScalarStructuredDsCase.ts} | 3 +- .../components/Literals/test/helpers/index.ts | 20 +++++----- .../Literals/test/literal.helpers.test.ts | 2 +- .../src/components/common/ReactJsonView.tsx | 40 ++++++++++++++++++- 17 files changed, 56 insertions(+), 20 deletions(-) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_collection_test_case.ts => genCollectionTestcase.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_map_test_case.ts => genMapTestCase.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_binary_test_case.ts => genScalarBinaryTestCase.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_blob_cases.ts => genScalarBlobCases.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_error_case.ts => genScalarErrorCase.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_generic_case.ts => genScalarGenericCase.ts} (98%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_nonetype_case.ts => genScalarNoneCase.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_primitive_cases.ts => genScalarPrimitiveCases.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_schema_case.ts => genScalarSchemaCase.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{gen_scalar_structured_ds_case.ts => genScalarStructuredDsCase.ts} (99%) diff --git a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx index fd2203df5..cdd594672 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx @@ -2,7 +2,6 @@ import { storiesOf } from '@storybook/react'; import { LiteralMap } from 'models/Common/types'; import * as React from 'react'; import { Card, CardContent } from '@material-ui/core'; -import { LiteralValue } from '../LiteralValue'; import { CardDecorator } from './CardDecorator'; import { binaryLiterals, diff --git a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx index 48ab579d6..786e2a327 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx @@ -57,7 +57,6 @@ stories.add('list', () => kind: 'listValue', listValue: { values: [ - // ...Object.values(protobufValues), { kind: 'structValue', structValue: { fields: protobufValues }, diff --git a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx index 84fd7c1a7..de4454e42 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx @@ -146,7 +146,7 @@ function generateEnumTypes() { type: 'enumType', enumType: { values: [] }, }), - generateStructuredDataset(`With_null_ values`, { + generateStructuredDataset(`With_null_values`, { type: 'enumType', enumType: { values: null }, }), diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index be1922e3b..016d5d2ed 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -107,6 +107,7 @@ function processNone(none?: Core.IVoid) { return '(empty)'; } +// TODO: FC#450 ass support for union types function processUnionType(union: Core.IUnionType, shortString = false) { return 'This type is not yet supported'; } diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_collection_test_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_collection_test_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_map_test_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_map_test_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_binary_test_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_binary_test_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_blob_cases.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_error_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_error_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts similarity index 98% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts index 79e5c36b0..c93c5854e 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_generic_case.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts @@ -1,4 +1,4 @@ -import { Protobuf } from 'flyteidl'; +import { Protobuf } from 'flyteidl'; import { TestCaseList } from '../types'; import { getIValue } from './literalHelpers'; @@ -10,7 +10,7 @@ const nullValueTestcases = { nullValue: Protobuf.NullValue.NULL_VALUE, kind: 'nullValue', }, - } , + }, }, expected: { result_var: { test_field_name1: '(empty)' }, @@ -136,7 +136,7 @@ const listValueTestCases = { }, kind: 'listValue', }, - } , + }, }, expected: { result_var: { diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_nonetype_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_nonetype_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_primitive_cases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_primitive_cases.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_schema_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_schema_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts similarity index 99% rename from packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts index 488b86e98..8c946bd86 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/gen_scalar_structured_ds_case.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts @@ -23,7 +23,6 @@ const generateStructuredDataset = (columnName: string, uri: string, literalType) }; }; - const sasWithMapValueTypeColumns: any = Object.keys(simple) .map((simpleTypeKey, index) => { const simpleType = simple[simpleTypeKey]; @@ -126,5 +125,5 @@ export default { ...sdsWithSimpleTypeColumns, ...sasWithSchemaColumns, ...sasWithCollectionTypeColumns, - ...sasWithMapValueTypeColumns + ...sasWithMapValueTypeColumns, } as any as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/index.ts b/packages/zapp/console/src/components/Literals/test/helpers/index.ts index 502682309..dabd4e82a 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/index.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/index.ts @@ -1,13 +1,13 @@ -import primitive from './gen_scalar_primitive_cases'; -import blob from './gen_scalar_blob_cases'; -import binary from './gen_scalar_binary_test_case'; -import schema from './gen_scalar_schema_case'; -import noneType from './gen_scalar_nonetype_case'; -import errorType from './gen_scalar_error_case'; -import generic from './gen_scalar_generic_case'; -import structuredDataset from './gen_scalar_structured_ds_case'; -import collection from './gen_collection_test_case'; -import map from './gen_map_test_case'; +import primitive from './genScalarPrimitiveCases'; +import blob from './genScalarBlobCases'; +import binary from './genScalarBinaryTestCase'; +import schema from './genScalarSchemaCase'; +import noneType from './genScalarNoneCase'; +import errorType from './genScalarErrorCase'; +import generic from './genScalarGenericCase'; +import structuredDataset from './genScalarStructuredDsCase'; +import collection from './genCollectionTestcase'; +import map from './genMapTestCase'; export { primitive, diff --git a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts index 9b17ea4ed..e4bd8062e 100644 --- a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts +++ b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts @@ -25,7 +25,7 @@ const literalTestCases = { error: errorType, generic, structuredDataset, - union: {} as Core.IPrimitive, // todo + union: {} as Core.IPrimitive, // TODO: FC#450 ass support for union types }, collection, map, diff --git a/packages/zapp/console/src/components/common/ReactJsonView.tsx b/packages/zapp/console/src/components/common/ReactJsonView.tsx index 09710866e..ea7e9d1a1 100644 --- a/packages/zapp/console/src/components/common/ReactJsonView.tsx +++ b/packages/zapp/console/src/components/common/ReactJsonView.tsx @@ -35,6 +35,44 @@ const useStyles = makeStyles((theme: Theme) => ({ }, })); +/** + * + * Replacer functionality to pass to the JSON.stringify function that + * does proper serialization of arrays that contain non-numeric indexes + * @param _ parent element key + * @param value the element being serialized + * @returns Transformed version of input + */ +const replacer = (_, value) => { + // Check if associative array + if (value instanceof Array && Object.keys(value).some((v) => isNaN(+v))) { + // Serialize associative array + return Object.keys(value).reduce((acc, arrKey) => { + // if: + // string key is encountered insert {[key]: value} into transformed array + // else: + // insert original value + acc.push(isNaN(+arrKey) ? { [arrKey]: value[arrKey] } : value[arrKey]); + + return acc; + }, [] as any[]); + } + + // Non-associative array. return original value to allow default JSON.stringify behavior + return value; +}; + +/** + * Custom implementation for JSON.stringify to allow + * proper serialization of arrays that contain non-numeric indexes + * + * @param json Object to serialize + * @returns A string version of the input json + */ +const customStringify = (json) => { + return JSON.stringify(json, replacer); +}; + export const ReactJsonViewWrapper: React.FC = (props) => { const styles = useStyles(); @@ -43,7 +81,7 @@ export const ReactJsonViewWrapper: React.FC = (props) => { { const objToCopy = options.src; - const text = typeof objToCopy === 'object' ? JSON.stringify(objToCopy) : objToCopy; + const text = typeof objToCopy === 'object' ? customStringify(objToCopy) : objToCopy; copyToClipboard(text); }} displayDataTypes={false} From 51fbb6963b8d6c34a7eac480acf445fc2e4cee0a Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 16:39:51 -0700 Subject: [PATCH 08/21] chore: fix scalar stories Signed-off-by: Carina Ursu --- .../components/Literals/LiteralMapViewer.tsx | 15 +------ .../Literals/__stories__/Scalar.stories.tsx | 40 ++++++++++++++----- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx index 40e6efee9..69d4559fc 100644 --- a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx @@ -28,22 +28,11 @@ export const LiteralMapViewer: React.FC<{ return ; } - let transformedLiterals = transformLiteralMap(literals); - - let rootNode: string | null = null; - - const transformedLiteralsKeys = Object.keys(transformedLiterals); - if ( - transformedLiteralsKeys.length === 1 && - typeof transformedLiterals[transformedLiteralsKeys[0]] === 'object' - ) { - rootNode = transformedLiteralsKeys[0]; - transformedLiterals = transformedLiterals[rootNode!]; - } + const transformedLiterals = transformLiteralMap(literals); return ( <> - + ); }; diff --git a/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx index b220ffeab..1f638d14f 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx @@ -1,6 +1,7 @@ import { storiesOf } from '@storybook/react'; import { Scalar } from 'models/Common/types'; import * as React from 'react'; +import { Card, CardContent } from '@material-ui/core'; import { ScalarValue } from '../Scalar/ScalarValue'; import { LiteralMapViewer } from '../LiteralMapViewer'; import { CardDecorator } from './CardDecorator'; @@ -12,22 +13,43 @@ import { primitiveScalars, schemaScalars, } from './scalarValues'; +import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; const stories = storiesOf('Literals/Scalar', module); stories.addDecorator(CardDecorator); -const renderScalars = (scalars: Dictionary) => - Object.entries(scalars).map(([label, value]) => { - return ( - <> - -
    NEW: +var renderScalars = (scalars: Dictionary) => { + const literals = {}; - - - ); + Object.entries(scalars).map(([label, value]) => { + literals[label] = { scalar: value, value: 'scalar' }; }); + const map = { literals }; + return ( + <> +
    +
    + OLD + + + + + +
    +
    + NEW + + + + + +
    +
    + + ); +}; + stories.add('Binary', () => <>{renderScalars(binaryScalars)}); stories.add('Blob', () => <>{renderScalars(blobScalars)}); stories.add('Error', () => <>{renderScalars(errorScalars)}); From 4abde81510600b3ac0748924afb5e5ac1785fd44 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 16:44:45 -0700 Subject: [PATCH 09/21] chore: oops Signed-off-by: Carina Ursu --- .../Executions/ExecutionInputsOutputsModal.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx b/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx index 1c73d3ec9..de86f5ac7 100644 --- a/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx +++ b/packages/zapp/console/src/components/Executions/ExecutionInputsOutputsModal.tsx @@ -2,7 +2,7 @@ import { Dialog, DialogContent, Tab, Tabs } from '@material-ui/core'; import { makeStyles, Theme } from '@material-ui/core/styles'; import { ClosableDialogTitle } from 'components/common/ClosableDialogTitle'; import { WaitForData } from 'components/common/WaitForData'; -import { DeprecatedLiteralMapViewer } from 'components/Literals/DeprecatedLiteralMapViewer'; +import { LiteralMapViewer } from 'components/Literals/LiteralMapViewer'; import { emptyLiteralMapBlob } from 'models/Common/constants'; import { Execution } from 'models/Execution/types'; import * as React from 'react'; @@ -41,7 +41,7 @@ const RemoteExecutionInputs: React.FC<{ execution: Execution }> = ({ execution } const executionData = useWorkflowExecutionData(execution.id); return ( - + ); }; @@ -50,7 +50,7 @@ const RemoteExecutionOutputs: React.FC<{ execution: Execution }> = ({ execution const executionData = useWorkflowExecutionData(execution.id); return ( - + ); }; @@ -59,7 +59,7 @@ const RenderInputs: React.FC<{ execution: Execution }> = ({ execution }) => { // computedInputs is deprecated, but older data may still use that field. // For new records, the inputs will always need to be fetched separately return execution.closure.computedInputs ? ( - + ) : ( ); @@ -73,7 +73,7 @@ const RenderOutputs: React.FC<{ execution: Execution }> = ({ execution }) => { return outputs.uri ? ( ) : ( - + ); }; From 553f5ed9879b059a26d1c7ba8542eeb742709844 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Wed, 4 May 2022 16:55:15 -0700 Subject: [PATCH 10/21] chore: cleanup Signed-off-by: Carina Ursu --- .../__stories__/Collection.stories.tsx | 9 ++-- .../Literals/__stories__/Map.stories.tsx | 5 +- .../__stories__/ProtobufStruct.stories.tsx | 21 +++----- .../src/components/Literals/helpers.ts | 4 +- .../Literals/test/helpers/genMapTestCase.ts | 2 +- .../Literals/test/helpers/literalHelpers.ts | 51 ++++++++++++++----- .../Literals/test/literal.helpers.test.ts | 4 +- 7 files changed, 56 insertions(+), 40 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx index 76ba85d60..9056dd685 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx @@ -18,6 +18,7 @@ const stories = storiesOf('Literals/Collection', module); stories.addDecorator(CardDecorator); function renderCollection(label: string, collection: LiteralCollection) { + const map = { literals: { [label]: { collection, value: 'collection' } } }; return ( <>
    @@ -25,9 +26,7 @@ function renderCollection(label: string, collection: LiteralCollection) { OLD - +
    @@ -35,9 +34,7 @@ function renderCollection(label: string, collection: LiteralCollection) { NEW - + diff --git a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx index cdd594672..82d4463ff 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx @@ -18,6 +18,7 @@ const stories = storiesOf('Literals/Map', module); stories.addDecorator(CardDecorator); function renderMap(label: string, map: LiteralMap) { + const fullMap = { literals: { [label]: { map, value: 'map' } } }; return ( <>
    @@ -25,7 +26,7 @@ function renderMap(label: string, map: LiteralMap) { OLD - +
    @@ -33,7 +34,7 @@ function renderMap(label: string, map: LiteralMap) { NEW - + diff --git a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx index 786e2a327..c784fdbf4 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx @@ -12,6 +12,11 @@ const stories = storiesOf('Literals/ProtobufStruct', module); stories.addDecorator(CardDecorator); function renderStruct(label: string, struct: ProtobufStruct) { + const map = { + literals: { + [label]: { scalar: { value: 'generic', generic: struct }, value: 'scalar' }, + }, + }; return ( <>
    @@ -19,13 +24,7 @@ function renderStruct(label: string, struct: ProtobufStruct) { OLD - +
    @@ -33,13 +32,7 @@ function renderStruct(label: string, struct: ProtobufStruct) { NEW - + diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index 016d5d2ed..b8e253c10 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -19,7 +19,7 @@ function processPrimitive(primitive: Core.IPrimitive) { case 'duration': return protobufDurationToHMS(primitive.duration!); case 'integer': { - return Long.fromValue(primitive[type] as any as Long).toNumber(); + return Long.fromValue(primitive[type] as Long).toNumber(); } case 'boolean': case 'floatValue': @@ -311,7 +311,7 @@ function processLiteralValue(literal: Core.ILiteral) { export function transformLiteralMap(json: Core.ILiteralMap) { const obj = sortedObjectEntries(json as any) .map(([key, literal]) => ({ - [key]: processLiteralValue(literal as any as Core.Literal), + [key]: processLiteralValue(literal as Core.Literal), })) .reduce( (acc, cur) => ({ diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts index e504d1336..505920e21 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts @@ -27,4 +27,4 @@ const collection = { export default { ...collection, -} as any as TestCaseList; +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts index 14fbe29f1..90e45ae92 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts @@ -10,21 +10,21 @@ export function getIValue( | Protobuf.IStruct | Protobuf.IListValue | null, -): Core.Primitive | Core.IPrimitive { +): Protobuf.IValue & Pick { return { kind, [kind]: value, - } as any as Protobuf.Value; + }; } export function getPrimitive( key: 'integer' | 'floatValue' | 'stringValue' | 'boolean' | 'datetime' | 'duration', value?: Long | number | string | boolean | Protobuf.ITimestamp | Protobuf.IDuration | null, -): Core.Primitive | Core.IPrimitive { +): Core.IPrimitive & Pick { return { [key]: value, value: key, - } as any as Core.Primitive; + }; } export function generateBlobType( @@ -43,18 +43,43 @@ export function generateBlobType( }; } +const getScalar = ( + value: + | Core.IPrimitive + | Core.IBlob + | Core.IBinary + | Core.ISchema + | Core.IVoid + | Core.IError + | Protobuf.IStruct + | Core.IStructuredDataset + | Core.IUnion, + scalarType: any, +): Core.IScalar & Pick => { + return { + [scalarType]: value, + value: scalarType, + }; +}; + // TOP LEVEL SCHEMA GENERATORS: -export const getScalar = ( - value: Core.IPrimitive | Core.IBlob | Core.IBinary, - scalarType: string, -) => { +export const getScalarLiteral = ( + value: + | Core.IPrimitive + | Core.IBlob + | Core.IBinary + | Core.ISchema + | Core.IVoid + | Core.IError + | Protobuf.IStruct + | Core.IStructuredDataset + | Core.IUnion, + scalarType: any, +): Core.ILiteral & Pick => { return { - scalar: { - [scalarType]: value, - value: scalarType, - }, + scalar: getScalar(value, scalarType), value: 'scalar', - } as Core.IScalar; + }; }; export const getCollection = (literals: Core.ILiteral[]) => { diff --git a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts index e4bd8062e..82428a891 100644 --- a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts +++ b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts @@ -13,7 +13,7 @@ import { collection, map, } from './helpers/index'; -import { getCollection, getMap, getScalar } from './helpers/literalHelpers'; +import { getCollection, getMap, getScalarLiteral } from './helpers/literalHelpers'; const literalTestCases = { scalar: { @@ -40,7 +40,7 @@ describe('scalar literal', () => { const { value, expected } = cases?.[testKey]!; it(`${testKey}: should return ${expected} for ${value}`, () => { - const scalar = { result_var: { ...getScalar(value, scalarTestType) } }; + const scalar = { result_var: { ...getScalarLiteral(value, scalarTestType) } }; const result = transformLiteralMap(scalar as any); expect(result).toEqual(expected); }); From 4099b52d2b1a158998cb098a5208bd081def17ec Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Thu, 5 May 2022 12:50:24 -0700 Subject: [PATCH 11/21] chore: revert old viewer to original Signed-off-by: Carina Ursu --- .../components/Literals/DeprecatedLiteralMapViewer.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx index c075f3959..5e594c635 100644 --- a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx @@ -16,7 +16,7 @@ export const NoDataIsAvailable = () => { }; /** Renders a LiteralMap as a formatted object */ -export const DeprecatedLiteralMapViewer: React.FC<{ +export const LiteralMapViewer: React.FC<{ className?: string; map: LiteralMap | null; showBrackets?: boolean; @@ -27,11 +27,6 @@ export const DeprecatedLiteralMapViewer: React.FC<{ const commonStyles = useCommonStyles(); const { literals } = map; - - if (!Object.keys(literals).length) { - return ; - } - const mapContent = Object.keys(literals).length ? (
      {sortedObjectEntries(literals).map(([key, value]) => ( @@ -45,7 +40,6 @@ export const DeprecatedLiteralMapViewer: React.FC<{ ); - return ( <> {showBrackets && {htmlEntities.leftCurlyBrace}} From 14bb53b4bdacf8707487dfebe1ec647baabdec1e Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Thu, 5 May 2022 16:38:26 -0700 Subject: [PATCH 12/21] chore: fix Signed-off-by: Carina Ursu --- .../Literals/DeprecatedLiteralMapViewer.tsx | 2 +- .../Literals/__stories__/Collection.stories.tsx | 2 -- .../Literals/__stories__/Map.stories.tsx | 2 -- .../__stories__/ProtobufStruct.stories.tsx | 2 -- .../Literals/__stories__/Scalar.stories.tsx | 3 --- .../__stories__/StructuredDataSet.stories.tsx | 15 +++++++++------ 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx index 5e594c635..f8ec614bb 100644 --- a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx @@ -16,7 +16,7 @@ export const NoDataIsAvailable = () => { }; /** Renders a LiteralMap as a formatted object */ -export const LiteralMapViewer: React.FC<{ +export const DeprecatedLiteralMapViewer: React.FC<{ className?: string; map: LiteralMap | null; showBrackets?: boolean; diff --git a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx index 9056dd685..d2e4830de 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Collection.stories.tsx @@ -4,7 +4,6 @@ import * as React from 'react'; import { Card, CardContent } from '@material-ui/core'; import { LiteralMapViewer } from '../LiteralMapViewer'; import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; -import { CardDecorator } from './CardDecorator'; import { binaryLiterals, blobLiterals, @@ -15,7 +14,6 @@ import { } from './literalValues'; const stories = storiesOf('Literals/Collection', module); -stories.addDecorator(CardDecorator); function renderCollection(label: string, collection: LiteralCollection) { const map = { literals: { [label]: { collection, value: 'collection' } } }; diff --git a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx index 82d4463ff..6336fa8e0 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Map.stories.tsx @@ -2,7 +2,6 @@ import { storiesOf } from '@storybook/react'; import { LiteralMap } from 'models/Common/types'; import * as React from 'react'; import { Card, CardContent } from '@material-ui/core'; -import { CardDecorator } from './CardDecorator'; import { binaryLiterals, blobLiterals, @@ -15,7 +14,6 @@ import { LiteralMapViewer } from '../LiteralMapViewer'; import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; const stories = storiesOf('Literals/Map', module); -stories.addDecorator(CardDecorator); function renderMap(label: string, map: LiteralMap) { const fullMap = { literals: { [label]: { map, value: 'map' } } }; diff --git a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx index c784fdbf4..cc84b8386 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/ProtobufStruct.stories.tsx @@ -2,14 +2,12 @@ import { storiesOf } from '@storybook/react'; import { ProtobufListValue, ProtobufStruct } from 'models/Common/types'; import * as React from 'react'; import { Card, CardContent } from '@material-ui/core'; -import { CardDecorator } from './CardDecorator'; import { protobufValues } from './protobufValues'; import { LiteralMapViewer } from '../LiteralMapViewer'; import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; const stories = storiesOf('Literals/ProtobufStruct', module); -stories.addDecorator(CardDecorator); function renderStruct(label: string, struct: ProtobufStruct) { const map = { diff --git a/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx index 1f638d14f..051658e55 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/Scalar.stories.tsx @@ -2,9 +2,7 @@ import { storiesOf } from '@storybook/react'; import { Scalar } from 'models/Common/types'; import * as React from 'react'; import { Card, CardContent } from '@material-ui/core'; -import { ScalarValue } from '../Scalar/ScalarValue'; import { LiteralMapViewer } from '../LiteralMapViewer'; -import { CardDecorator } from './CardDecorator'; import { binaryScalars, blobScalars, @@ -16,7 +14,6 @@ import { import { DeprecatedLiteralMapViewer } from '../DeprecatedLiteralMapViewer'; const stories = storiesOf('Literals/Scalar', module); -stories.addDecorator(CardDecorator); var renderScalars = (scalars: Dictionary) => { const literals = {}; diff --git a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx index de4454e42..7f4d6458f 100644 --- a/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx +++ b/packages/zapp/console/src/components/Literals/__stories__/StructuredDataSet.stories.tsx @@ -1,14 +1,13 @@ import { storiesOf } from '@storybook/react'; import { Scalar } from 'models/Common/types'; +import { Card, CardContent } from '@material-ui/core'; import * as React from 'react'; import { Core } from 'flyteidl'; import { LiteralMapViewer } from '../LiteralMapViewer'; -import { CardDecorator } from './CardDecorator'; import { blobScalars } from './scalarValues'; import { extractSimpleTypes, extractSchemaTypes, extractBlobTypes } from './helpers/typeGenerators'; const stories = storiesOf('Literals/StructuredDataSet', module); -stories.addDecorator(CardDecorator); function generateStructuredDataset(label: string, literalType: Core.ILiteralType) { return { @@ -156,13 +155,17 @@ function generateEnumTypes() { } const renderScalars = (scalars: Dictionary) => { - return Object.entries(scalars).map(([label, value]) => { + const items = Object.entries(scalars).map(([_label, value]) => { return ( - <> - - + + + + + ); }); + + return
      {items}
      ; }; stories.add('Simple types', () => <>{renderScalars(generateSimpleTypes())}); From 2a1c0b71f055f1f98f1428e30b1ed12a21e5e5eb Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Thu, 5 May 2022 19:08:44 -0700 Subject: [PATCH 13/21] chore: remove non-null assertion Signed-off-by: Carina Ursu --- .../components/Literals/LiteralMapViewer.tsx | 4 +- .../src/components/Literals/helpers.ts | 303 +++++++++++------- .../test/helpers/genScalarPrimitiveCases.ts | 2 +- .../test/helpers/genScalarSchemaCase.ts | 4 +- .../Literals/test/literal.helpers.test.ts | 8 +- 5 files changed, 195 insertions(+), 126 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx index 69d4559fc..c6b0487bd 100644 --- a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx @@ -1,7 +1,7 @@ import { ReactJsonViewWrapper } from 'components/common/ReactJsonView'; import { LiteralMap } from 'models/Common/types'; import * as React from 'react'; -import { transformLiteralMap } from './helpers'; +import { transformLiterals } from './helpers'; import { NoneTypeValue } from './Scalar/NoneTypeValue'; export const NoDataIsAvailable = () => { @@ -28,7 +28,7 @@ export const LiteralMapViewer: React.FC<{ return ; } - const transformedLiterals = transformLiteralMap(literals); + const transformedLiterals = transformLiterals(literals); return ( <> diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index b8e253c10..1bdcb2713 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -1,32 +1,35 @@ import { formatDateUTC, protobufDurationToHMS } from 'common/formatters'; -import { sortedObjectEntries, timestampToDate } from 'common/utils'; -import { Core } from 'flyteidl'; +import { timestampToDate } from 'common/utils'; +import { Core, Protobuf } from 'flyteidl'; import * as Long from 'long'; -import { - BlobDimensionality, - ProtobufListValue, - ProtobufStruct, - ProtobufValue, - SchemaColumnType, -} from 'models/Common/types'; +import { BlobDimensionality, SchemaColumnType } from 'models/Common/types'; + +const DEFAULT_UNSUPPORTED = 'This type is not yet supported'; // PRIMITIVE -function processPrimitive(primitive: Core.IPrimitive) { - const type = (primitive as Core.Primitive).value!; +function processPrimitive(primitive?: (Core.IPrimitive & Pick) | null) { + if (!primitive) { + return 'invalid primitive'; + } + + const type = primitive.value; + switch (type) { case 'datetime': - return formatDateUTC(timestampToDate(primitive.datetime!)); + return formatDateUTC(timestampToDate(primitive.datetime as Protobuf.Timestamp)); case 'duration': - return protobufDurationToHMS(primitive.duration!); + return protobufDurationToHMS(primitive.duration as Protobuf.Duration); case 'integer': { - return Long.fromValue(primitive[type] as Long).toNumber(); + return Long.fromValue(primitive.integer as Long).toNumber(); } case 'boolean': + return primitive.boolean; case 'floatValue': - return primitive[type]; + return primitive.floatValue; case 'stringValue': - default: return `${primitive[type]}`; + default: + return 'unknown'; } } @@ -36,31 +39,50 @@ const dimensionalityStrings: Record = { [BlobDimensionality.MULTIPART]: 'multi-part', }; -function processBlobType(blobType: Core.IBlobType, typePrefix: string = '') { - const formatString = blobType && blobType.format ? ` (${blobType.format})` : ''; - const typeString = `${dimensionalityStrings[blobType!.dimensionality!]}${formatString}`; +function processBlobType(blobType?: Core.IBlobType | null) { + if (!blobType) { + return 'invalid blob type'; + } + + const formatString = blobType.format ? ` (${blobType.format})` : ''; + const dimensionality = blobType.dimensionality; + const dimensionalityString = + dimensionality !== null && dimensionality !== undefined + ? dimensionalityStrings[dimensionality] + : ''; + const typeString = `${dimensionalityString}${formatString}`; - return `${typePrefix}${typeString} blob`; + return `${typeString} blob`; } -function processBlob(blob: Core.IBlob | Core.Blob) { - const type = blob?.metadata?.type; +function processBlob(blob?: Core.IBlob | null) { + if (!blob) { + return 'invalid blob'; + } + + const type = blob.metadata?.type; return { - type: processBlobType(type!), + type: processBlobType(type), uri: blob.uri, }; } // BINARY -function processBinary(binary: Core.IBinary) { +function processBinary(binary?: Core.IBinary | null) { + const tag = binary?.tag; + + if (!tag) { + return 'invalid binary'; + } + return { - tag: `${binary?.tag!} (binary data not shown)`, + tag: `${tag} (binary data not shown)`, }; } // SCHEMA -export function columnTypeToString(type: SchemaColumnType) { +export function columnTypeToString(type?: SchemaColumnType | null) { switch (type) { case SchemaColumnType.BOOLEAN: return 'boolean'; @@ -79,95 +101,114 @@ export function columnTypeToString(type: SchemaColumnType) { } } -function processSchemaType(schemaType: Core.ISchemaType, shortString = false) { - let columns; - if (schemaType?.columns?.length) { - columns = schemaType?.columns.map((column) => - shortString - ? `${columnTypeToString(column.type!)}` - : `${column.name!} (${columnTypeToString(column.type!)})`, - ); - } +function processSchemaType(schemaType?: Core.ISchemaType | null, shortString = false) { + const columns = + schemaType?.columns?.length && + schemaType.columns.map((column) => { + return shortString + ? `${columnTypeToString(column.type)}` + : `${column.name} (${columnTypeToString(column.type)})`; + }); return columns; } -function processSchema(schema: Core.ISchema) { - const columns = processSchemaType(schema?.type!); +function processSchema(schema?: Core.ISchema | null) { + if (!schema) { + return 'invalid schema'; + } + + const uri = schema.uri; + const columns = processSchemaType(schema.type); return { - uri: schema.uri, + ...(uri && { uri }), ...(columns && { columns }), }; } // NONE /* eslint-disable @typescript-eslint/no-unused-vars */ -function processNone(none?: Core.IVoid) { +function processNone(none?: Core.IVoid | null) { return '(empty)'; } // TODO: FC#450 ass support for union types -function processUnionType(union: Core.IUnionType, shortString = false) { - return 'This type is not yet supported'; +function processUnionType(union?: Core.IUnionType | null, shortString = false) { + return DEFAULT_UNSUPPORTED; } function processUnion(union: Core.IUnion) { - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } /* eslint-enable @typescript-eslint/no-unused-vars */ // ERROR -function processError(error: Core.IError) { +function processError(error?: Core.IError | null) { return { - error: error.message, - nodeId: error.failedNodeId, + error: error?.message, + nodeId: error?.failedNodeId, }; } -// GENERIC -- not done -function processProtobufStructValue(struct: ProtobufStruct) { - const { fields } = struct; - const res = Object.keys(fields) - .map((v) => { - return { [v]: processProtobufValue(fields[v]) }; - }) - .reduce((acc, v) => ({ ...acc, ...v }), {}); +function processProtobufStructValue(struct?: Protobuf.IStruct | null) { + if (!struct) { + return 'invalid generic struct value'; + } + + const fields = struct?.fields; + const res = + fields && + Object.keys(fields) + .map((v) => { + return { [v]: processGenericValue(fields[v]) }; + }) + .reduce((acc, v) => ({ ...acc, ...v }), {}); return res; } -function processProtobufValue(value: ProtobufValue) { - switch (value.kind) { +function processGenericValue(value: Protobuf.IValue & Pick) { + const kind = value.kind; + + switch (kind) { case 'nullValue': return '(empty)'; case 'listValue': { - const list = value.listValue as ProtobufListValue; - return list?.values?.map((x) => processProtobufValue(x)); + const list = value.listValue; + return list?.values?.map((x) => processGenericValue(x)); } case 'structValue': - return processProtobufStructValue(value?.structValue as ProtobufStruct); + return processProtobufStructValue(value?.structValue); + case 'numberValue': + case 'stringValue': + case 'boolValue': + return value[kind]; default: - return value[value.kind]; + return 'unknown'; } } -function processGeneric(struct: ProtobufStruct) { +function processGeneric(struct?: Protobuf.IStruct | null) { + if (!struct || !struct?.fields) { + return null; + } + const { fields } = struct; const mapContent = Object.keys(fields) .map((key) => { const value = fields[key]; - return { [key]: processProtobufValue(value) }; + return { [key]: processGenericValue(value) }; }) .reduce((acc, v) => { return { ...acc, ...v }; - }, {} as any); + }, {}); return mapContent; } // SIMPLE -export function processSimpleType(simpleType: Core.SimpleType) { +export function processSimpleType(simpleType?: Core.SimpleType | null) { switch (simpleType) { case Core.SimpleType.NONE: return 'none'; @@ -189,60 +230,70 @@ export function processSimpleType(simpleType: Core.SimpleType) { return 'error'; case Core.SimpleType.STRUCT: return 'struct'; + default: + return 'unknown'; } } -function processEnumType(enumType: Core.IEnumType) { +function processEnumType(enumType?: Core.IEnumType | null) { return enumType?.values || []; } -function processLiteralType(literalType: Core.ILiteralType) { - const type = (literalType as Core.LiteralType)?.type; +function processLiteralType( + literalType?: (Core.ILiteralType & Pick) | null, +) { + const type = literalType?.type; switch (type) { case 'simple': - return processSimpleType(literalType?.simple!); + return processSimpleType(literalType?.simple); case 'schema': - return `schema (${processSchemaType(literalType?.schema!, true)})`; + return `schema (${processSchemaType(literalType?.schema, true)})`; case 'collectionType': - return `collection of ${processLiteralType(literalType?.collectionType!)}`; + return `collection of ${processLiteralType(literalType?.collectionType)}`; case 'mapValueType': - return `map value of ${processLiteralType(literalType?.mapValueType!)}`; + return `map value of ${processLiteralType(literalType?.mapValueType)}`; case 'blob': - return processBlobType(literalType?.blob!); + return processBlobType(literalType?.blob); case 'enumType': - return `enum (${processEnumType(literalType?.enumType!)})`; + return `enum (${processEnumType(literalType?.enumType)})`; case 'structuredDatasetType': - return processStructuredDatasetType(literalType?.structuredDatasetType!); + return processStructuredDatasetType(literalType?.structuredDatasetType); case 'unionType': - return processUnionType(literalType?.unionType!, true); + return processUnionType(literalType?.unionType, true); default: - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } } -function processStructuredDatasetType(structuredDatasetType: Core.IStructuredDatasetType) { - const retJson = {} as any; - - const { columns, format } = structuredDatasetType; - - if (format) { - retJson.format = format; +function processStructuredDatasetType(structuredDatasetType?: Core.IStructuredDatasetType | null) { + if (!structuredDatasetType) { + return {}; } - if (columns && (columns as Core.StructuredDatasetType.IDatasetColumn[])?.length) { - retJson.columns = columns - .map(({ name, literalType }) => [name, processLiteralType(literalType!)]) + const { columns, format } = structuredDatasetType; + const processedColumns = + columns?.length && + columns + .map(({ name, literalType }) => [name, processLiteralType(literalType)]) .reduce((acc, v) => { acc[v[0]] = v[1]; return acc; }, []); - } - return retJson; + const a = { + ...(format && { format }), + ...(processedColumns && { columns: processedColumns }), + }; + + return a; } -function processStructuredDataset(structuredDataSet: Core.IStructuredDataset) { +function processStructuredDataset(structuredDataSet?: Core.IStructuredDataset | null) { + if (!structuredDataSet) { + return DEFAULT_UNSUPPORTED; + } + const retJson = {} as any; const { uri, metadata } = structuredDataSet; @@ -250,68 +301,86 @@ function processStructuredDataset(structuredDataSet: Core.IStructuredDataset) { retJson.uri = uri; } - const structuredDatasetType = metadata?.structuredDatasetType!; + const structuredDatasetType = processStructuredDatasetType(metadata?.structuredDatasetType); return { - ...retJson, - ...processStructuredDatasetType(structuredDatasetType), + ...(uri && { uri }), + ...structuredDatasetType, }; } -function processScalar(scalar: Core.Scalar | Core.IScalar) { - const type = (scalar as Core.Scalar).value; - const value = scalar[type!]; +function processScalar(scalar?: (Core.IScalar & Pick) | null) { + const type = scalar?.value; switch (type) { case 'primitive': - return processPrimitive(value as Core.IPrimitive); + return processPrimitive(scalar?.primitive); case 'blob': - return processBlob(value as Core.IBlob); + return processBlob(scalar?.blob); case 'binary': - return processBinary(value as Core.IBinary); + return processBinary(scalar?.binary); case 'schema': - return processSchema(value as Core.ISchema); + return processSchema(scalar?.schema); case 'noneType': - return processNone(value as Core.IVoid); + return processNone(scalar?.noneType); case 'error': - return processError(value as Core.IError); + return processError(scalar?.error); case 'generic': - return processGeneric(value as ProtobufStruct); + return processGeneric(scalar?.generic); case 'structuredDataset': - return processStructuredDataset(value as Core.IStructuredDataset); + return processStructuredDataset(scalar?.structuredDataset); case 'union': - return processUnion(value as Core.IUnion); + return processUnion(scalar?.union as Core.IUnion); default: - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } } -function processCollection(collection: Core.ILiteralCollection) { - return collection?.literals?.map((literal) => processLiteralValue(literal)); +function processCollection(collection?: Core.ILiteralCollection | null) { + const literals = collection?.literals; + + if (!literals) { + return 'invalid collection'; + } + + return literals?.map((literal) => processLiteral(literal)); } -function processMap(map: Core.ILiteralMap) { - return transformLiteralMap(map.literals as Core.ILiteralMap); +function processMap(map?: Core.ILiteralMap | null) { + const literals = map?.literals; + + if (!literals) { + return 'invalid map'; + } + + return transformLiterals(literals); } -function processLiteralValue(literal: Core.ILiteral) { - const type = (literal as Core.Literal).value; +function processLiteral(literal?: Core.ILiteral & Pick) { + const type = literal?.value; + + if (!literal || !type || !literal[type]) { + return 'invalid literal'; + } + + // ok to cast below since the two checks above ensure that + // we're not passing invalid values switch (type) { case 'scalar': - return processScalar(literal.scalar!); + return processScalar(literal.scalar); case 'collection': - return processCollection(literal.collection!); + return processCollection(literal.collection); case 'map': - return processMap(literal.map!); + return processMap(literal.map); default: - return 'unknown type'; + return DEFAULT_UNSUPPORTED; } } -export function transformLiteralMap(json: Core.ILiteralMap) { - const obj = sortedObjectEntries(json as any) +export function transformLiterals(json: { [k: string]: Core.ILiteral }) { + const obj = Object.entries(json) .map(([key, literal]) => ({ - [key]: processLiteralValue(literal as Core.Literal), + [key]: processLiteral(literal), })) .reduce( (acc, cur) => ({ diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts index c28849246..7effbb445 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts @@ -85,4 +85,4 @@ export default { value: getPrimitive('duration', { seconds: long(10000), nanos: 0 }), expected: { result_var: '2h 46m 40s' }, }, -} as any as TestCaseList; +} as TestCaseList; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts index cfd283712..af6210123 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts @@ -5,7 +5,7 @@ const schemaColumnTypes = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnT .map((key, index) => ({ [`SCHEMA_WITH_${key}`]: { value: { - uri: index, + uri: `s3/${index}`, type: { columns: [ { name: 'name' + index, type: Core.SchemaType.SchemaColumn.SchemaColumnType[key] }, @@ -13,7 +13,7 @@ const schemaColumnTypes = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnT }, }, expected: { - result_var: { uri: index, columns: [`name${index} (${key.toLocaleLowerCase()})`] }, + result_var: { uri: `s3/${index}`, columns: [`name${index} (${key.toLocaleLowerCase()})`] }, }, }, })) diff --git a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts index 82428a891..396444798 100644 --- a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts +++ b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts @@ -1,5 +1,5 @@ import { Core } from 'flyteidl'; -import { transformLiteralMap } from '../helpers'; +import { transformLiterals } from '../helpers'; import { primitive, @@ -41,7 +41,7 @@ describe('scalar literal', () => { it(`${testKey}: should return ${expected} for ${value}`, () => { const scalar = { result_var: { ...getScalarLiteral(value, scalarTestType) } }; - const result = transformLiteralMap(scalar as any); + const result = transformLiterals(scalar as any); expect(result).toEqual(expected); }); }); @@ -57,7 +57,7 @@ describe('collection literal', () => { it(`${testKey}: should return ${expected} for ${value}`, () => { const collection = getCollection([value]); - const result = transformLiteralMap(collection as any); + const result = transformLiterals(collection as any); expect(result).toEqual(expected); }); }); @@ -71,7 +71,7 @@ describe('map literal', () => { it(`${testKey}: should return ${expected} for ${value}`, () => { const collection = getMap({ value }); - const result = transformLiteralMap(collection as any); + const result = transformLiterals(collection as any); expect(result).toEqual(expected); }); }); From 41622a7500513002cafa44be10f9ee2d8cd6397e Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Thu, 5 May 2022 19:28:58 -0700 Subject: [PATCH 14/21] chore: fix types Signed-off-by: Carina Ursu --- .../Literals/test/helpers/literalHelpers.ts | 28 +++++++++---------- .../Literals/test/literal.helpers.test.ts | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts index 90e45ae92..271a95b3f 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts @@ -82,24 +82,24 @@ export const getScalarLiteral = ( }; }; -export const getCollection = (literals: Core.ILiteral[]) => { +export const getCollection = ( + literals: Core.ILiteral[], +): Core.ILiteral & Pick => { return { - result_var: { - collection: { - literals, - }, - value: 'collection', - } as Core.ILiteralCollection, + collection: { + literals, + }, + value: 'collection', }; }; -export const getMap = (literals: { [k: string]: Core.ILiteral } | null) => { +export const getMap = ( + literals: { [k: string]: Core.ILiteral } | null, +): Core.ILiteral & Pick => { return { - result_var: { - map: { - literals, - }, - value: 'map', - } as Core.ILiteralMap, + map: { + literals, + }, + value: 'map', }; }; diff --git a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts index 396444798..6b8cb893e 100644 --- a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts +++ b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts @@ -55,7 +55,7 @@ describe('collection literal', () => { const { value, expected } = cases?.[testKey]!; it(`${testKey}: should return ${expected} for ${value}`, () => { - const collection = getCollection([value]); + const collection = { result_var: { ...getCollection([value]) } }; const result = transformLiterals(collection as any); expect(result).toEqual(expected); @@ -69,7 +69,7 @@ describe('map literal', () => { const { value, expected } = cases?.[testKey]!; it(`${testKey}: should return ${expected} for ${value}`, () => { - const collection = getMap({ value }); + const collection = { result_var: { ...getMap({ value }) } }; const result = transformLiterals(collection as any); expect(result).toEqual(expected); From fefae0bc4f0fde280b3a1a90fadb064d16df53d5 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Thu, 5 May 2022 19:46:19 -0700 Subject: [PATCH 15/21] chore: cleanup Signed-off-by: Carina Ursu --- packages/zapp/console/src/components/Literals/helpers.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index 1bdcb2713..2654de108 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -359,12 +359,10 @@ function processMap(map?: Core.ILiteralMap | null) { function processLiteral(literal?: Core.ILiteral & Pick) { const type = literal?.value; - if (!literal || !type || !literal[type]) { + if (!literal) { return 'invalid literal'; } - // ok to cast below since the two checks above ensure that - // we're not passing invalid values switch (type) { case 'scalar': return processScalar(literal.scalar); From 987a6b352dc31b18aaed2b351316201c41bc9b2e Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Fri, 6 May 2022 11:12:55 -0700 Subject: [PATCH 16/21] chore: fix tests Signed-off-by: Carina Ursu --- .../test/helpers/genCollectionTestcase.ts | 27 ++++----- .../Literals/test/helpers/genMapTestCase.ts | 23 +++----- .../test/helpers/genScalarBinaryTestCase.ts | 6 +- .../test/helpers/genScalarBlobCases.ts | 9 ++- .../test/helpers/genScalarErrorCase.ts | 6 +- .../test/helpers/genScalarGenericCase.ts | 58 ++++++++----------- .../test/helpers/genScalarNoneCase.ts | 6 +- .../test/helpers/genScalarPrimitiveCases.ts | 6 +- .../test/helpers/genScalarSchemaCase.ts | 16 +++-- .../test/helpers/genScalarStructuredDsCase.ts | 12 ++-- .../Literals/test/helpers/literalHelpers.ts | 22 ++++++- .../Literals/test/literal.helpers.test.ts | 31 +++++----- 12 files changed, 117 insertions(+), 105 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts index 480d55a39..026d64826 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts @@ -1,30 +1,23 @@ import { Core } from 'flyteidl'; import { TestCaseList } from '../types'; -import { generateBlobType, getPrimitive } from './literalHelpers'; +import { generateBlobType, getPrimitive, getScalarLiteral } from './literalHelpers'; -const collection = { +const collection: TestCaseList = { COL_WITH_SCALARTYPE_PRIMITIVE: { value: { - scalar: { - primitive: getPrimitive('floatValue', 2.1), - value: 'primitive', - }, - value: 'scalar', - } as Core.ILiteral, + ...getScalarLiteral(getPrimitive('floatValue', 2.1), 'primitive'), + }, expected: { result_var: [2.1] }, }, COL_WITH_SCALARTYPE_BLOB: { value: { - scalar: { - blob: generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), - value: 'blob', - }, - value: 'scalar', - } as Core.ILiteral, + ...getScalarLiteral( + generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), + 'blob', + ), + }, expected: { result_var: [{ type: 'single (csv) blob', uri: '1' }] }, }, }; -export default { - ...collection, -} as any as TestCaseList; +export default collection; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts index 505920e21..6eef945ee 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts @@ -1,30 +1,23 @@ import { Core } from 'flyteidl'; import { TestCaseList } from '../types'; -import { generateBlobType, getPrimitive } from './literalHelpers'; +import { generateBlobType, getPrimitive, getScalarLiteral } from './literalHelpers'; -const collection = { +const collection: TestCaseList = { COL_WITH_SCALARTYPE_PRIMITIVE: { value: { - scalar: { - primitive: getPrimitive('floatValue', 2.1), - value: 'primitive', - }, - value: 'scalar', + ...getScalarLiteral(getPrimitive('floatValue', 2.1), 'primitive'), }, expected: { result_var: { value: 2.1 } }, }, COL_WITH_SCALARTYPE_BLOB: { value: { - scalar: { - blob: generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), - value: 'blob', - }, - value: 'scalar', + ...getScalarLiteral( + generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), + 'blob', + ), }, expected: { result_var: { value: { type: 'single (csv) blob', uri: '1' } } }, }, }; -export default { - ...collection, -} as TestCaseList; +export default collection; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts index 25bc2e906..9804a0f11 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts @@ -1,7 +1,7 @@ import { Core } from 'flyteidl'; import { TestCaseList } from '../types'; -export default { +const scalarBinaryTestCases: TestCaseList = { WITH_VAL: { value: { value: new Uint8Array(), tag: 'tag1' }, expected: { result_var: { tag: 'tag1 (binary data not shown)' } }, @@ -10,4 +10,6 @@ export default { value: { tag: 'tag2' }, expected: { result_var: { tag: 'tag2 (binary data not shown)' } }, }, -} as TestCaseList; +}; + +export default scalarBinaryTestCases; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts index a6665e5d1..28073461f 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts @@ -2,7 +2,7 @@ import { Core } from 'flyteidl'; import { generateBlobType } from './literalHelpers'; import { TestCaseList } from '../types'; -export default { +const blobTestcases: TestCaseList = { single_CSV_BLOB: { value: generateBlobType('csv', Core.BlobType.BlobDimensionality.SINGLE, '1'), expected: { @@ -14,7 +14,6 @@ export default { }, multi_part_CSV_BLOB: { value: generateBlobType('csv', Core.BlobType.BlobDimensionality.MULTIPART, '2'), - description: 'low1', expected: { result_var: { type: 'multi-part (csv) blob', @@ -24,7 +23,6 @@ export default { }, single_blob_BLOB: { value: generateBlobType(undefined, Core.BlobType.BlobDimensionality.SINGLE, '3'), - description: 'low1', expected: { result_var: { type: 'single blob', @@ -34,7 +32,6 @@ export default { }, single_multi_part_BLOB: { value: generateBlobType(undefined, Core.BlobType.BlobDimensionality.MULTIPART, '4'), - description: 'low1', expected: { result_var: { type: 'multi-part blob', @@ -42,4 +39,6 @@ export default { }, }, }, -} as TestCaseList; +}; + +export default blobTestcases; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts index 4ea352602..e05e18f65 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts @@ -1,7 +1,7 @@ import { Core } from 'flyteidl'; import { TestCaseList } from '../types'; -export default { +const scalarErrorTestCases: TestCaseList = { ERROR_FULL: { value: { failedNodeId: '1', @@ -33,4 +33,6 @@ export default { result_var: { error: undefined, nodeId: undefined }, }, }, -} as TestCaseList; +}; + +export default scalarErrorTestCases; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts index c93c5854e..3cf04eedc 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts @@ -2,14 +2,11 @@ import { Protobuf } from 'flyteidl'; import { TestCaseList } from '../types'; import { getIValue } from './literalHelpers'; -const nullValueTestcases = { +const nullValueTestcases: TestCaseList = { WITH_NULL_VAL: { value: { fields: { - test_field_name1: { - nullValue: Protobuf.NullValue.NULL_VALUE, - kind: 'nullValue', - }, + test_field_name1: getIValue('nullValue', Protobuf.NullValue.NULL_VALUE), }, }, expected: { @@ -17,14 +14,11 @@ const nullValueTestcases = { }, }, }; -const numberValueTestCases = { +const numberValueTestCases: TestCaseList = { WITH_NUMBER_VAL: { value: { fields: { - test_field_name2: { - numberValue: 1, - kind: 'numberValue', - }, + test_field_name2: getIValue('numberValue', 1), }, }, expected: { @@ -34,10 +28,7 @@ const numberValueTestCases = { WITH_NUMBER_VAL_NULL: { value: { fields: { - test_field_name3: { - numberValue: null, - kind: 'numberValue', - }, + test_field_name3: getIValue('numberValue', null), }, }, expected: { @@ -45,7 +36,7 @@ const numberValueTestCases = { }, }, }; -const stringValueTestCases = { +const stringValueTestCases: TestCaseList = { WITH_STRING_VAL: { value: { fields: { @@ -68,7 +59,7 @@ const stringValueTestCases = { }, }; -const boolValueTestCases = { +const boolValueTestCases: TestCaseList = { WITH_BOOL_VAL: { value: { fields: { @@ -101,21 +92,18 @@ const boolValueTestCases = { }, }; -const structValueTestCases = { +const structValueTestCases: TestCaseList = { WITH_STRUCT_VALUE: { value: { fields: { - test_struct_name: { - structValue: { - fields: { - struct_string_val_copy: - stringValueTestCases?.WITH_STRING_VAL?.value?.fields?.test_field_name4, - struct_bool_val_copy: - boolValueTestCases?.WITH_BOOL_VAL?.value?.fields?.test_field_name, - }, + test_struct_name: getIValue('structValue', { + fields: { + struct_string_val_copy: stringValueTestCases.WITH_STRING_VAL.value?.fields + ?.test_field_name4 as Protobuf.IValue, + struct_bool_val_copy: boolValueTestCases.WITH_BOOL_VAL.value?.fields + ?.test_field_name as Protobuf.IValue, }, - kind: 'structValue', - }, + }), }, }, expected: { @@ -126,16 +114,16 @@ const structValueTestCases = { }, }; -const listValueTestCases = { +const listValueTestCases: TestCaseList = { WITH_LIST_VALUE: { value: { fields: { - test_list_name: { - listValue: { - values: [structValueTestCases.WITH_STRUCT_VALUE.value.fields.test_struct_name], - }, - kind: 'listValue', - }, + test_list_name: getIValue('listValue', { + values: [ + structValueTestCases.WITH_STRUCT_VALUE.value?.fields + ?.test_struct_name as Protobuf.IValue, + ], + }), }, }, expected: { @@ -152,4 +140,4 @@ export default { ...boolValueTestCases, ...structValueTestCases, ...listValueTestCases, -} as any as TestCaseList; +}; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts index 5aa7b01ec..140af9bed 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts @@ -1,11 +1,13 @@ import { Core } from 'flyteidl'; import { TestCaseList } from '../types'; -export default { +const scalarNoneTestCase: TestCaseList = { VOID_TYPE: { value: {}, expected: { result_var: '(empty)', }, }, -} as TestCaseList; +}; + +export default scalarNoneTestCase; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts index 7effbb445..5bff19ef4 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts @@ -4,7 +4,7 @@ import { long } from 'test/utils'; import { getPrimitive } from './literalHelpers'; import { TestCaseList } from '../types'; -export default { +const scalarPrimitiveTestCases: TestCaseList = { INT_WITH_LARGE_LOW: { value: getPrimitive('integer', { low: 1642627611, high: 0, unsigned: false } as Long), expected: { result_var: 1642627611 }, @@ -85,4 +85,6 @@ export default { value: getPrimitive('duration', { seconds: long(10000), nanos: 0 }), expected: { result_var: '2h 46m 40s' }, }, -} as TestCaseList; +}; + +export default scalarPrimitiveTestCases; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts index af6210123..a51574f9f 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts @@ -1,7 +1,9 @@ import { Core } from 'flyteidl'; import { TestCaseList } from '../types'; -const schemaColumnTypes = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnType) +const schemaColumnTypes: TestCaseList = Object.keys( + Core.SchemaType.SchemaColumn.SchemaColumnType, +) .map((key, index) => ({ [`SCHEMA_WITH_${key}`]: { value: { @@ -22,10 +24,9 @@ const schemaColumnTypes = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnT ...acc, ...v, }; - }, {}) as any; + }, {}); -export default { - ...schemaColumnTypes, +const schemaTestCases: TestCaseList = { SCHEMA_WITHOUT_TYPE: { value: { uri: 'test7', @@ -37,4 +38,9 @@ export default { result_var: { uri: 'test7', columns: [`test7 (unknown)`] }, }, }, -} as TestCaseList; +}; + +export default { + ...schemaColumnTypes, + ...schemaTestCases, +}; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts index 8c946bd86..ae6660bf1 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts @@ -23,7 +23,7 @@ const generateStructuredDataset = (columnName: string, uri: string, literalType) }; }; -const sasWithMapValueTypeColumns: any = Object.keys(simple) +const sasWithMapValueTypeColumns: TestCaseList = Object.keys(simple) .map((simpleTypeKey, index) => { const simpleType = simple[simpleTypeKey]; @@ -49,7 +49,7 @@ const sasWithMapValueTypeColumns: any = Object.keys(simple) }) .reduce((acc, v) => ({ ...acc, ...v }), {}); -const sasWithCollectionTypeColumns: any = Object.keys(simple) +const sasWithCollectionTypeColumns: TestCaseList = Object.keys(simple) .map((simpleTypeKey, index) => { const simpleType = simple[simpleTypeKey]; @@ -76,7 +76,7 @@ const sasWithCollectionTypeColumns: any = Object.keys(simple) .slice(0, 1) .reduce((acc, v) => ({ ...acc, ...v }), {}); -const sdsWithSimpleTypeColumns: any = Object.keys(simple) +const sdsWithSimpleTypeColumns: TestCaseList = Object.keys(simple) .map((simpleTypeKey, index) => { const literalType = simple[simpleTypeKey]; @@ -95,7 +95,9 @@ const sdsWithSimpleTypeColumns: any = Object.keys(simple) }) .reduce((acc, v) => ({ ...acc, ...v }), {}); -const sasWithSchemaColumns = Object.keys(Core.SchemaType.SchemaColumn.SchemaColumnType) +const sasWithSchemaColumns: TestCaseList = Object.keys( + Core.SchemaType.SchemaColumn.SchemaColumnType, +) .map((simpleTypeKey, index) => { const literalType = { schema: { @@ -126,4 +128,4 @@ export default { ...sasWithSchemaColumns, ...sasWithCollectionTypeColumns, ...sasWithMapValueTypeColumns, -} as any as TestCaseList; +}; diff --git a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts index 271a95b3f..67e4da36f 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/literalHelpers.ts @@ -54,7 +54,16 @@ const getScalar = ( | Protobuf.IStruct | Core.IStructuredDataset | Core.IUnion, - scalarType: any, + scalarType: + | 'primitive' + | 'blob' + | 'binary' + | 'schema' + | 'noneType' + | 'error' + | 'generic' + | 'structuredDataset' + | 'union', ): Core.IScalar & Pick => { return { [scalarType]: value, @@ -74,7 +83,16 @@ export const getScalarLiteral = ( | Protobuf.IStruct | Core.IStructuredDataset | Core.IUnion, - scalarType: any, + scalarType: + | 'primitive' + | 'blob' + | 'binary' + | 'schema' + | 'noneType' + | 'error' + | 'generic' + | 'structuredDataset' + | 'union', ): Core.ILiteral & Pick => { return { scalar: getScalar(value, scalarType), diff --git a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts index 6b8cb893e..8ebf97c6d 100644 --- a/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts +++ b/packages/zapp/console/src/components/Literals/test/literal.helpers.test.ts @@ -32,15 +32,18 @@ const literalTestCases = { }; describe('scalar literal', () => { - const scalarTestTypes = Object.keys(literalTestCases?.scalar!); - scalarTestTypes.map((scalarTestType) => { + const scalarTestCases = literalTestCases.scalar; + const scalarType = Object.keys(scalarTestCases); + + scalarType.map((scalarTestType) => { describe(scalarTestType, () => { - const cases = literalTestCases?.scalar?.[scalarTestType]; + const cases = scalarTestCases[scalarTestType]; + Object.keys(cases || {}).map((testKey) => { - const { value, expected } = cases?.[testKey]!; + const { value, expected } = cases[testKey]; it(`${testKey}: should return ${expected} for ${value}`, () => { - const scalar = { result_var: { ...getScalarLiteral(value, scalarTestType) } }; + const scalar = { result_var: { ...getScalarLiteral(value, scalarTestType as any) } }; const result = transformLiterals(scalar as any); expect(result).toEqual(expected); }); @@ -50,28 +53,30 @@ describe('scalar literal', () => { }); describe('collection literal', () => { - const cases = literalTestCases?.collection; - Object.keys(cases || {}).map((testKey) => { - const { value, expected } = cases?.[testKey]!; + const cases = literalTestCases.collection; + + Object.keys(cases).map((testKey) => { + const { value, expected } = cases[testKey]; it(`${testKey}: should return ${expected} for ${value}`, () => { const collection = { result_var: { ...getCollection([value]) } }; - const result = transformLiterals(collection as any); + const result = transformLiterals(collection); expect(result).toEqual(expected); }); }); }); describe('map literal', () => { - const cases = literalTestCases?.map; - Object.keys(cases || {}).map((testKey) => { - const { value, expected } = cases?.[testKey]!; + const cases = literalTestCases.map; + + Object.keys(cases).map((testKey) => { + const { value, expected } = cases[testKey]; it(`${testKey}: should return ${expected} for ${value}`, () => { const collection = { result_var: { ...getMap({ value }) } }; - const result = transformLiterals(collection as any); + const result = transformLiterals(collection); expect(result).toEqual(expected); }); }); From e30869be6863ccf2ba5f7c1c0a8ef309ab2c6779 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Fri, 6 May 2022 11:31:32 -0700 Subject: [PATCH 17/21] chore: fix test types Signed-off-by: Carina Ursu --- ...tcase.ts => genCollectionTestcase.mock.ts} | 0 ...nMapTestCase.ts => genMapTestCase.mock.ts} | 0 ...ase.ts => genScalarBinaryTestCase.mock.ts} | 0 ...lobCases.ts => genScalarBlobCases.mock.ts} | 0 ...rrorCase.ts => genScalarErrorCase.mock.ts} | 0 ...icCase.ts => genScalarGenericCase.mock.ts} | 0 ...rNoneCase.ts => genScalarNoneCase.mock.ts} | 0 ...ses.ts => genScalarPrimitiveCases.mock.ts} | 0 ...emaCase.ts => genScalarSchemaCase.mock.ts} | 0 ...e.ts => genScalarStructuredDsCase.mock.ts} | 0 .../components/Literals/test/helpers/index.ts | 20 +++++++++---------- 11 files changed, 10 insertions(+), 10 deletions(-) rename packages/zapp/console/src/components/Literals/test/helpers/{genCollectionTestcase.ts => genCollectionTestcase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genMapTestCase.ts => genMapTestCase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarBinaryTestCase.ts => genScalarBinaryTestCase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarBlobCases.ts => genScalarBlobCases.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarErrorCase.ts => genScalarErrorCase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarGenericCase.ts => genScalarGenericCase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarNoneCase.ts => genScalarNoneCase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarPrimitiveCases.ts => genScalarPrimitiveCases.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarSchemaCase.ts => genScalarSchemaCase.mock.ts} (100%) rename packages/zapp/console/src/components/Literals/test/helpers/{genScalarStructuredDsCase.ts => genScalarStructuredDsCase.mock.ts} (100%) diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genCollectionTestcase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genMapTestCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarBinaryTestCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarBlobCases.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarErrorCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarGenericCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarNoneCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarPrimitiveCases.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarSchemaCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts b/packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.mock.ts similarity index 100% rename from packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.ts rename to packages/zapp/console/src/components/Literals/test/helpers/genScalarStructuredDsCase.mock.ts diff --git a/packages/zapp/console/src/components/Literals/test/helpers/index.ts b/packages/zapp/console/src/components/Literals/test/helpers/index.ts index dabd4e82a..e1e2debc6 100644 --- a/packages/zapp/console/src/components/Literals/test/helpers/index.ts +++ b/packages/zapp/console/src/components/Literals/test/helpers/index.ts @@ -1,13 +1,13 @@ -import primitive from './genScalarPrimitiveCases'; -import blob from './genScalarBlobCases'; -import binary from './genScalarBinaryTestCase'; -import schema from './genScalarSchemaCase'; -import noneType from './genScalarNoneCase'; -import errorType from './genScalarErrorCase'; -import generic from './genScalarGenericCase'; -import structuredDataset from './genScalarStructuredDsCase'; -import collection from './genCollectionTestcase'; -import map from './genMapTestCase'; +import primitive from './genScalarPrimitiveCases.mock'; +import blob from './genScalarBlobCases.mock'; +import binary from './genScalarBinaryTestCase.mock'; +import schema from './genScalarSchemaCase.mock'; +import noneType from './genScalarNoneCase.mock'; +import errorType from './genScalarErrorCase.mock'; +import generic from './genScalarGenericCase.mock'; +import structuredDataset from './genScalarStructuredDsCase.mock'; +import collection from './genCollectionTestcase.mock'; +import map from './genMapTestCase.mock'; export { primitive, From b5c599968801138d99fa2fe52ce94e03a0d21079 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Fri, 6 May 2022 11:34:59 -0700 Subject: [PATCH 18/21] chore: cleanup Signed-off-by: Carina Ursu --- .../console/src/components/Literals/LiteralMapViewer.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx index c6b0487bd..77be18da2 100644 --- a/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/LiteralMapViewer.tsx @@ -30,9 +30,5 @@ export const LiteralMapViewer: React.FC<{ const transformedLiterals = transformLiterals(literals); - return ( - <> - - - ); + return ; }; From 242db1adea7ac31f008df2428c8cc90be8c5df07 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Fri, 6 May 2022 11:37:35 -0700 Subject: [PATCH 19/21] chore: cleanup Signed-off-by: Carina Ursu --- packages/zapp/console/src/components/Literals/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index 2654de108..62276ebb4 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -27,7 +27,7 @@ function processPrimitive(primitive?: (Core.IPrimitive & Pick Date: Fri, 6 May 2022 11:38:41 -0700 Subject: [PATCH 20/21] chore: cleanup Signed-off-by: Carina Ursu --- packages/zapp/console/src/components/Literals/helpers.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index 62276ebb4..f04f6574a 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -281,12 +281,10 @@ function processStructuredDatasetType(structuredDatasetType?: Core.IStructuredDa return acc; }, []); - const a = { + return { ...(format && { format }), ...(processedColumns && { columns: processedColumns }), }; - - return a; } function processStructuredDataset(structuredDataSet?: Core.IStructuredDataset | null) { From 33bd6755ecb1c948f9fbf699052ed893c73abb4e Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Fri, 6 May 2022 12:02:02 -0700 Subject: [PATCH 21/21] chore: cleanup Signed-off-by: Carina Ursu --- .../zapp/console/src/components/common/PanelSection/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zapp/console/src/components/common/PanelSection/index.tsx b/packages/zapp/console/src/components/common/PanelSection/index.tsx index 23b229699..ace1ab503 100644 --- a/packages/zapp/console/src/components/common/PanelSection/index.tsx +++ b/packages/zapp/console/src/components/common/PanelSection/index.tsx @@ -4,6 +4,7 @@ import { makeStyles } from '@material-ui/core/styles'; const useStyle = makeStyles((theme) => ({ detailsPanelCard: { borderBottom: `1px solid ${theme.palette.divider}`, + paddingBottom: '150px', // TODO @FC 454 temporary fix for panel height issue }, detailsPanelCardContent: { padding: `${theme.spacing(2)}px ${theme.spacing(3)}px`,