Skip to content

Commit 0b77db6

Browse files
committed
msgpack idl supporting
1 parent 8b0d3cc commit 0b77db6

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"dependencies": {
5757
"@commitlint/cli": "^17.3.0",
5858
"@commitlint/config-conventional": "^17.3.0",
59+
"@msgpack/msgpack": "^3.0.0-beta2",
5960
"@semantic-release/changelog": "^5.0.1",
6061
"@semantic-release/commit-analyzer": "^8.0.1",
6162
"@semantic-release/exec": "^6.0.3",

packages/oss-console/src/components/Launch/LaunchForm/LaunchFormComponents/StructInput.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { FC, useCallback, useMemo, useState } from 'react';
1+
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';
22
import { Form } from '@rjsf/mui';
33
import validator from '@rjsf/validator-ajv8';
44
import styled from '@mui/system/styled';
5+
import * as msgpack from '@msgpack/msgpack';
56
import { InputProps } from '../types';
67
import { protobufValueToPrimitive, PrimitiveType } from '../inputHelpers/struct';
78
import { StyledCard } from './StyledCard';
@@ -60,6 +61,7 @@ export const StructInput: FC<InputProps> = (props) => {
6061
typeDefinition: { literalType },
6162
value = '',
6263
hasCollectionParent,
64+
initialValue,
6365
} = props;
6466

6567
const { jsonFormRenderable, parsedJson } = useMemo(() => {
@@ -99,6 +101,16 @@ export const StructInput: FC<InputProps> = (props) => {
99101
setParamData(formData);
100102
}, []);
101103

104+
useEffect(() => {
105+
if (!jsonFormRenderable && initialValue) {
106+
const value = initialValue.scalar?.binary?.value;
107+
if (value) {
108+
const parsedValue = msgpack.decode(value);
109+
onChange(JSON.stringify(parsedValue));
110+
}
111+
}
112+
}, [jsonFormRenderable, initialValue]);
113+
102114
return jsonFormRenderable ? (
103115
<StyledCard error={error} label={label} name={name}>
104116
<StyledForm

packages/oss-console/src/components/Literals/helpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-use-before-define */
22
import Protobuf from '@clients/common/flyteidl/protobuf';
33
import Core from '@clients/common/flyteidl/core';
4+
import * as msgpack from '@msgpack/msgpack';
45
import Long from 'long';
56
import cloneDeep from 'lodash/cloneDeep';
67
import { formatDateUTC, protobufDurationToHMS } from '../../common/formatters';
@@ -79,6 +80,13 @@ function processBinary(binary?: Core.IBinary | null) {
7980
return 'invalid binary';
8081
}
8182

83+
if (tag === 'msgpack' && binary.value) {
84+
return {
85+
tag: 'msgpack',
86+
value: msgpack.decode(binary.value),
87+
};
88+
}
89+
8290
return {
8391
tag: `${tag} (binary data not shown)`,
8492
};

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,6 +3501,13 @@ __metadata:
35013501
languageName: node
35023502
linkType: hard
35033503

3504+
"@msgpack/msgpack@npm:^3.0.0-beta2":
3505+
version: 3.0.0-beta2
3506+
resolution: "@msgpack/msgpack@npm:3.0.0-beta2"
3507+
checksum: d86e5d48146051952d6bea35a6cf733a401cf65ad5614d79689aa48c7076021737ca2c782978dd1b6c0c9c45888b246e379e45ae906179e3a0e8ef4ee6f221c1
3508+
languageName: node
3509+
linkType: hard
3510+
35043511
"@mswjs/cookies@npm:^0.2.2":
35053512
version: 0.2.2
35063513
resolution: "@mswjs/cookies@npm:0.2.2"
@@ -14907,6 +14914,7 @@ __metadata:
1490714914
dependencies:
1490814915
"@commitlint/cli": ^17.3.0
1490914916
"@commitlint/config-conventional": ^17.3.0
14917+
"@msgpack/msgpack": ^3.0.0-beta2
1491014918
"@semantic-release/changelog": ^5.0.1
1491114919
"@semantic-release/commit-analyzer": ^8.0.1
1491214920
"@semantic-release/exec": ^6.0.3

0 commit comments

Comments
 (0)