Skip to content

Commit

Permalink
Support write-only inputs in CNI (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
pattra authored Oct 8, 2024
1 parent 871d2d4 commit e4c142f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/spectral/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prismatic-io/spectral",
"version": "9.2.0",
"version": "9.3.0",
"description": "Utility library for building Prismatic components and code-native integrations",
"keywords": ["prismatic"],
"main": "dist/index.js",
Expand Down
7 changes: 6 additions & 1 deletion packages/spectral/src/serverTypes/convertComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const convertInput = (
collection === "keyvaluelist" && typeof label === "object" ? label.key : undefined;

return {
...omit(rest, ["onPremControlled", "permissionAndVisibilityType", "visibleToOrgDeployer"]),
...omit(rest, [
"onPremControlled",
"permissionAndVisibilityType",
"visibleToOrgDeployer",
"writeOnly",
]),
key,
type,
default: defaultValue ?? InputFieldDefaultMap[type],
Expand Down
17 changes: 11 additions & 6 deletions packages/spectral/src/serverTypes/convertIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,17 @@ export const convertConfigVar = (
return result;
}

const meta = convertInputPermissionAndVisibility(
pick(input, ["permissionAndVisibilityType", "visibleToOrgDeployer"]) as {
permissionAndVisibilityType?: PermissionAndVisibilityType;
visibleToOrgDeployer?: boolean;
},
);
const meta: VisibilityAndPermissionValue & { writeOnly?: true } =
convertInputPermissionAndVisibility(
pick(input, ["permissionAndVisibilityType", "visibleToOrgDeployer"]) as {
permissionAndVisibilityType?: PermissionAndVisibilityType;
visibleToOrgDeployer?: boolean;
},
);

if (input.writeOnly) {
meta.writeOnly = input.writeOnly;
}

const defaultValue = input.collection
? (input.default || []).map((defaultValue) => {
Expand Down
1 change: 1 addition & 0 deletions packages/spectral/src/types/Inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export type ConnectionInput = (
| BooleanInputField
) & {
shown?: boolean;
writeOnly?: true;
};

export type OnPremConnectionInput = {
Expand Down

0 comments on commit e4c142f

Please sign in to comment.