Skip to content

Commit

Permalink
fix min/max options fields
Browse files Browse the repository at this point in the history
  • Loading branch information
korsvanloon committed May 21, 2024
1 parent 8a76703 commit 2ed11e3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-mails-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@labdigital/storyblok-graphql-codegen-terraform': patch
---

fix min/max option fields
8 changes: 4 additions & 4 deletions src/lib/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ const toArrayComponentField = (
use_uuid: true,
folder_slug: findStoryblokFieldValue<StringValueNode>(field, 'folder')
?.value,
minimum: ifValue(
min_options: ifValue(
findStoryblokFieldValue<IntValueNode>(field, 'min')?.value,
Number
),
maximum: ifValue(
max_options: ifValue(
findStoryblokFieldValue<IntValueNode>(field, 'max')?.value,
Number
),
Expand Down Expand Up @@ -285,11 +285,11 @@ const toArrayComponentField = (
})
)
),
minimum: ifValue(
min_options: ifValue(
findStoryblokFieldValue<IntValueNode>(field, 'min')?.value,
Number
),
maximum: ifValue(
max_options: ifValue(
findStoryblokFieldValue<IntValueNode>(field, 'max')?.value,
Number
),
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export type OptionsComponentField = ComponentFieldBase & {
folder_slug?: string
minimum?: number
maximum?: number
min_options?: number
max_options?: number
}

export type OptionComponentField = ComponentFieldBase & {
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/expected/fields.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ resource "storyblok_component" "base" {
value = "b"
}
]
minimum = 1
maximum = 2
min_options = 1
max_options = 2
}
blok = {
position = 17
Expand Down
4 changes: 2 additions & 2 deletions test/testdata/expected/story-option.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ resource "storyblok_component" "story" {
"story_a"
]
use_uuid = true
minimum = 2
maximum = 4
min_options = 2
max_options = 4
}
union = {
position = 2
Expand Down

0 comments on commit 2ed11e3

Please sign in to comment.