@scalar/api-client 3.21.5 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/hooks/use-file-dialog.js +1 -1
  3. package/dist/hooks/use-file-dialog.js.map +1 -1
  4. package/dist/style.css +1226 -69
  5. package/dist/styles/tailwind.config.css +1 -0
  6. package/dist/v2/blocks/operation-block/helpers/persist-response-cookies.d.ts +3 -3
  7. package/dist/v2/blocks/operation-block/helpers/persist-response-cookies.d.ts.map +1 -1
  8. package/dist/v2/blocks/operation-block/helpers/persist-response-cookies.js +4 -4
  9. package/dist/v2/blocks/operation-block/helpers/persist-response-cookies.js.map +1 -1
  10. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -1
  11. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
  12. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
  13. package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
  14. package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
  15. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +13 -8
  16. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
  17. package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
  18. package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
  19. package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
  20. package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +64 -13
  21. package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
  22. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts +2 -0
  23. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts.map +1 -1
  24. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.js.map +1 -1
  25. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.script.js +5 -3
  26. package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.script.js.map +1 -1
  27. package/dist/v2/blocks/request-block/components/RequestBodyViewToggle.vue.d.ts +9 -3
  28. package/dist/v2/blocks/request-block/components/RequestBodyViewToggle.vue.d.ts.map +1 -1
  29. package/dist/v2/blocks/request-block/components/RequestBodyViewToggle.vue.js.map +1 -1
  30. package/dist/v2/blocks/request-block/components/RequestBodyViewToggle.vue.script.js +44 -16
  31. package/dist/v2/blocks/request-block/components/RequestBodyViewToggle.vue.script.js.map +1 -1
  32. package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts +12 -0
  33. package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts.map +1 -1
  34. package/dist/v2/blocks/request-block/components/RequestParams.vue.js.map +1 -1
  35. package/dist/v2/blocks/request-block/components/RequestParams.vue.script.js +132 -32
  36. package/dist/v2/blocks/request-block/components/RequestParams.vue.script.js.map +1 -1
  37. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +3 -1
  38. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
  39. package/dist/v2/blocks/request-block/components/RequestTable.vue.js +1 -1
  40. package/dist/v2/blocks/request-block/components/RequestTable.vue.js.map +1 -1
  41. package/dist/v2/blocks/request-block/components/RequestTable.vue.script.js +13 -2
  42. package/dist/v2/blocks/request-block/components/RequestTable.vue.script.js.map +1 -1
  43. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +3 -1
  44. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
  45. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
  46. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +6 -2
  47. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
  48. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts.map +1 -1
  49. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js +10 -3
  50. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js.map +1 -1
  51. package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts.map +1 -1
  52. package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js +10 -1
  53. package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js.map +1 -1
  54. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts +3 -2
  55. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts.map +1 -1
  56. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +14 -11
  57. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js.map +1 -1
  58. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
  59. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +1 -1
  60. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js.map +1 -1
  61. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js +3 -3
  62. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.script.js.map +1 -1
  63. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
  64. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
  65. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
  66. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +55 -16
  67. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js.map +1 -1
  68. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.d.ts +3 -3
  69. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.d.ts.map +1 -1
  70. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.js.map +1 -1
  71. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.script.js +20 -7
  72. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.script.js.map +1 -1
  73. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
  74. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
  75. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js +32 -27
  76. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js.map +1 -1
  77. package/dist/v2/blocks/scalar-auth-selector-block/helpers/openid-discovery-to-flows.d.ts.map +1 -1
  78. package/dist/v2/blocks/scalar-auth-selector-block/helpers/openid-discovery-to-flows.js +2 -1
  79. package/dist/v2/blocks/scalar-auth-selector-block/helpers/openid-discovery-to-flows.js.map +1 -1
  80. package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
  81. package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
  82. package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
  83. package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
  84. package/dist/v2/components/code-input/PillTooltipHost.vue.d.ts.map +1 -1
  85. package/dist/v2/components/code-input/PillTooltipHost.vue.js.map +1 -1
  86. package/dist/v2/components/code-input/PillTooltipHost.vue.script.js +4 -1
  87. package/dist/v2/components/code-input/PillTooltipHost.vue.script.js.map +1 -1
  88. package/dist/v2/components/code-input/code-variable-widget.js +1 -1
  89. package/dist/v2/components/code-input/code-variable-widget.js.map +1 -1
  90. package/dist/v2/components/data-table/DataTableInput.vue.d.ts +3 -1
  91. package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
  92. package/dist/v2/components/data-table/DataTableInput.vue.js +1 -1
  93. package/dist/v2/components/data-table/DataTableInput.vue.js.map +1 -1
  94. package/dist/v2/components/data-table/DataTableInput.vue.script.js +46 -15
  95. package/dist/v2/components/data-table/DataTableInput.vue.script.js.map +1 -1
  96. package/dist/v2/components/server/ServerDropdown.vue.d.ts.map +1 -1
  97. package/dist/v2/components/server/ServerDropdown.vue.js.map +1 -1
  98. package/dist/v2/components/server/ServerDropdown.vue.script.js +7 -9
  99. package/dist/v2/components/server/ServerDropdown.vue.script.js.map +1 -1
  100. package/dist/v2/constants.js +1 -1
  101. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
  102. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.js.map +1 -1
  103. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js +27 -31
  104. package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js.map +1 -1
  105. package/dist/v2/features/localization/index.d.ts.map +1 -1
  106. package/dist/v2/features/localization/index.js +2 -0
  107. package/dist/v2/features/localization/index.js.map +1 -1
  108. package/dist/v2/features/localization/locales/ar.d.ts +4 -0
  109. package/dist/v2/features/localization/locales/ar.d.ts.map +1 -1
  110. package/dist/v2/features/localization/locales/ar.js +4 -0
  111. package/dist/v2/features/localization/locales/ar.js.map +1 -1
  112. package/dist/v2/features/localization/locales/de.d.ts +4 -0
  113. package/dist/v2/features/localization/locales/de.d.ts.map +1 -1
  114. package/dist/v2/features/localization/locales/de.js +4 -0
  115. package/dist/v2/features/localization/locales/de.js.map +1 -1
  116. package/dist/v2/features/localization/locales/es.d.ts +4 -0
  117. package/dist/v2/features/localization/locales/es.d.ts.map +1 -1
  118. package/dist/v2/features/localization/locales/es.js +4 -0
  119. package/dist/v2/features/localization/locales/es.js.map +1 -1
  120. package/dist/v2/features/localization/locales/fr.d.ts +4 -0
  121. package/dist/v2/features/localization/locales/fr.d.ts.map +1 -1
  122. package/dist/v2/features/localization/locales/fr.js +4 -0
  123. package/dist/v2/features/localization/locales/fr.js.map +1 -1
  124. package/dist/v2/features/localization/locales/pt.d.ts +4 -0
  125. package/dist/v2/features/localization/locales/pt.d.ts.map +1 -1
  126. package/dist/v2/features/localization/locales/pt.js +4 -0
  127. package/dist/v2/features/localization/locales/pt.js.map +1 -1
  128. package/dist/v2/features/localization/locales/ru.d.ts +4 -0
  129. package/dist/v2/features/localization/locales/ru.d.ts.map +1 -1
  130. package/dist/v2/features/localization/locales/ru.js +4 -0
  131. package/dist/v2/features/localization/locales/ru.js.map +1 -1
  132. package/dist/v2/features/localization/locales/zh-cn.d.ts +4 -0
  133. package/dist/v2/features/localization/locales/zh-cn.d.ts.map +1 -1
  134. package/dist/v2/features/localization/locales/zh-cn.js +4 -0
  135. package/dist/v2/features/localization/locales/zh-cn.js.map +1 -1
  136. package/dist/v2/features/localization/locales/zh-tw.d.ts +398 -0
  137. package/dist/v2/features/localization/locales/zh-tw.d.ts.map +1 -0
  138. package/dist/v2/features/localization/locales/zh-tw.js +360 -0
  139. package/dist/v2/features/localization/locales/zh-tw.js.map +1 -0
  140. package/dist/v2/features/localization/translations.d.ts +4 -0
  141. package/dist/v2/features/localization/translations.d.ts.map +1 -1
  142. package/dist/v2/features/localization/translations.js +4 -0
  143. package/dist/v2/features/localization/translations.js.map +1 -1
  144. package/dist/v2/features/modal/index.d.ts +1 -1
  145. package/dist/v2/features/modal/index.d.ts.map +1 -1
  146. package/dist/v2/helpers/handle-hotkeys.d.ts.map +1 -1
  147. package/dist/v2/helpers/handle-hotkeys.js +4 -1
  148. package/dist/v2/helpers/handle-hotkeys.js.map +1 -1
  149. package/dist/vue-styles.css +39 -40
  150. package/package.json +13 -13
@@ -56,7 +56,9 @@ export type TableRowUpsertPayload = {
56
56
  isDisabled: boolean;
57
57
  shouldRenameExpandedRow?: boolean;
58
58
  };
59
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
59
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
60
+ focusValue: () => void;
61
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
60
62
  deleteRow: () => any;
61
63
  navigate: (route: NonNullable<({
62
64
  replace?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTableRow.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"names":[],"mappings":"AAkaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAgBrE,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,kBAAkB,CAAA;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAC;AAwBF,MAAM,MAAM,QAAQ,GAAG;IACrB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mFAAmF;IACnF,WAAW,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAA;IAC/C,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,4FAA4F;IAC5F,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,wEAAwE;IACxE,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAAA;IAC1C,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,eAAe,CAAA;IACnC,2FAA2F;IAC3F,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAA;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AA2sBD,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"RequestTableRow.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"names":[],"mappings":"AAwaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8DAA8D,CAAA;AAgBrE,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,kBAAkB,CAAA;IAC/B,gBAAgB,CAAC,EAAE,OA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AAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTableRow.vue.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconGlobe, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ParameterObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, watch } from 'vue'\n\nimport { getFileName } from '@/v2/blocks/request-block/helpers/files'\nimport { validateParameter } from '@/v2/blocks/request-block/helpers/validate-parameter'\nimport { CodeInputLite } from '@/v2/components/code-input'\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableInputSelect,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nimport RequestTableTooltip from './RequestTableTooltip.vue'\n\nconst {\n data,\n environment,\n hasCheckboxDisabled,\n deferKeyUpdates,\n invalidParams,\n showUploadButton,\n} = defineProps<{\n data: TableRow\n /** Keep key edits local until blur when the row identity depends on its name. */\n deferKeyUpdates?: boolean\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n environment: XScalarEnvironment\n showUploadButton?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'upsertRow', payload: TableRowUpsertPayload): void\n (e: 'deleteRow'): void\n (e: 'uploadFile'): void\n (e: 'removeFile'): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset. */\n (e: 'selectPreset', value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nexport type TableRow = {\n /** The parameter or field name/key */\n name: string\n /** The parameter value, can be a string, file, or null */\n value: string | File | null\n /** Optional description for the parameter */\n description?: string\n /** Optional route for global parameters (e.g., cookies shared across workspace) */\n globalRoute?: ApiReferenceEvents['ui:navigate']\n /** Whether the parameter is disabled/inactive */\n isDisabled?: boolean\n /** Whether an optional parameter is disabled because it has no explicit x-disabled value */\n isDisabledByDefault?: boolean\n /** OpenAPI schema object with type, validation rules, examples, etc. */\n schema?: SchemaObject\n /** Preserve array values even while their JSON text is temporarily invalid. */\n isArray?: boolean\n /** Text representation used by array enum controls. */\n arrayEncoding?: 'json' | 'comma-separated'\n /** Whether the parameter is required */\n isRequired?: boolean\n /**\n * Whether the parameter is readonly and can not be modifies directly\n * User can still override the parameter which is going to show up with the linethrough style\n */\n isReadonly?: boolean\n /** Whether the parameter is overridden later on */\n isOverridden?: boolean\n /** Track the original parameter so we can update it */\n originalParameter?: ParameterObject\n /** Path to a value inside the original parameter example for expanded object parameters */\n sourceParameterValuePath?: string[]\n /**\n * Selectable values for a grouped global cookie preset. When set, the value cell renders a\n * dropdown to switch between predefined values (for example a `Culture` cookie with `PL`/`EN`)\n * instead of an editable input.\n */\n presetOptions?: string[]\n}\n\nexport type TableRowUpsertPayload = {\n name: string\n value: string | File\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\n/**\n * Track local state for the row\n *\n * Now this is required because of the way we get default values from the schema.\n * If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now\n * we have an example where value: ''. This is why we need to track the local state and update all of the params at the\n * same time.\n */\nconst name = ref<string>(data.name ?? '')\nconst value = ref<string | File>(unpackProxyObject(data.value) ?? '')\nconst isDisabled = ref<boolean>(data.isDisabled ?? false)\n\n// Keep the above state synced with the data prop\nwatch(\n () => data.name,\n (newName) => {\n // Do not overwrite a valid local name with an empty incoming prop — this\n // can happen when the placeholder row (appended by displayData) is briefly\n // mapped onto this component instance before Vue re-keys the list.\n if (!newName && name.value && !deferKeyUpdates) return\n name.value = newName ?? ''\n },\n)\nwatch(\n () => data.value,\n (newValue) => (value.value = unpackProxyObject(newValue) ?? ''),\n)\nwatch(\n () => data.isDisabled,\n (newIsDisabled) => (isDisabled.value = newIsDisabled ?? false),\n)\n\n/** Check if the value is a File instance */\nconst isFile = computed(() => value.value instanceof File)\n\n/** Display value handles File instances and shows filename instead */\nconst displayValue = computed(\n () =>\n (isFile.value\n ? getFileName(value.value as File)\n : (value.value as string)) ?? '',\n)\n\nconst defaultValue = computed(() => data.schema?.default as string)\n\n/** See if we can extract enum values from the schema */\nconst enumValue = computed<unknown[]>(() => {\n if (!data.schema) {\n return []\n }\n\n // Grab the enum from the schema\n if (data.schema.enum) {\n return data.schema.enum.map((item) => String(item))\n }\n\n // Grab the enum from the items schema\n if ('items' in data.schema) {\n const resolved = resolve.schema(data.schema.items)\n if (resolved?.enum) {\n return data.arrayEncoding === 'json'\n ? resolved.enum\n : resolved.enum.map((item) => String(item))\n }\n }\n\n return []\n})\n\nconst typeValue = computed(() =>\n data.schema && 'type' in data.schema ? data.schema.type : undefined,\n)\n\nconst validationResult = computed(() =>\n validateParameter(data.schema, value.value),\n)\n\n/** Handle row updates while preserving existing properties */\nconst handleUpdateRow = (\n payload: Partial<{ name: string; value: string; isDisabled: boolean }>,\n options: { shouldRenameExpandedRow?: boolean; commitKey?: boolean } = {},\n): void => {\n // Update our local state\n if (payload.name !== undefined) {\n name.value = payload.name\n }\n if (payload.value !== undefined) {\n value.value = payload.value\n\n // Optional parameters start unchecked, but entering a value expresses intent to send it.\n // Explicit x-disabled values stay unchanged so a deliberate opt-out is preserved.\n if (data.isDisabledByDefault) {\n isDisabled.value = false\n }\n }\n\n // Is disabled should only be updated when explicitly provided in the payload\n if (payload.isDisabled !== undefined) {\n isDisabled.value = payload.isDisabled\n }\n\n if (\n payload.name !== undefined &&\n (deferKeyUpdates || data.sourceParameterValuePath) &&\n !options.shouldRenameExpandedRow &&\n !options.commitKey\n ) {\n return\n }\n\n // Emit all of the local state\n emit('upsertRow', {\n name: name.value,\n value: value.value,\n isDisabled: isDisabled.value,\n ...(options.shouldRenameExpandedRow\n ? { shouldRenameExpandedRow: true }\n : {}),\n })\n}\n\n/**\n * Commit a key edit when the input loses focus. Body and expanded-object rows defer their rename to blur (see\n * handleUpdateRow), so we only emit when the key actually changed. Focusing and blurring the field\n * without typing should not re-emit the row or silently reset its disabled state. The current\n * disabled state is passed through so a renamed row keeps it.\n */\nconst handleKeyBlur = (newName: string): void => {\n if (newName === data.name) {\n return\n }\n // Do not emit an update that would blank the parameter name — this can fire\n // when CodeInputLite blurs before it has rendered its initial value.\n if (!newName && data.name && (!deferKeyUpdates || name.value !== '')) {\n return\n }\n\n handleUpdateRow(\n { name: newName, isDisabled: isDisabled.value },\n {\n shouldRenameExpandedRow: Boolean(data.sourceParameterValuePath),\n commitKey: true,\n },\n )\n}\n\n/** Save a pending body key before the send shortcut reaches the request handler. */\nconst handleKeydown = (event: KeyboardEvent): void => {\n if (\n deferKeyUpdates &&\n event.key === 'Enter' &&\n (event.metaKey || event.ctrlKey)\n ) {\n handleKeyBlur(name.value)\n }\n}\n</script>\n\n<template>\n <DataTableRow\n :id=\"data.name\"\n :class=\"{\n alert: validationResult.ok === false,\n error: validationResult.ok === false && invalidParams?.has(data.name),\n }\">\n <DataTableCheckbox\n :ariaLabel=\"\n translate('apiClient.requestTableRow.include', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"!border-r\"\n :disabled=\"hasCheckboxDisabled ?? false\"\n :modelValue=\"!isDisabled\"\n @update:modelValue=\"(v) => handleUpdateRow({ isDisabled: !v })\" />\n\n <!-- Name -->\n <DataTableCell>\n <CodeInputLite\n :aria-label=\"\n translate('apiClient.requestTableRow.keyLabel', { name: label ?? '' })\n \"\n :disabled=\"data.isReadonly\"\n :environment=\"environment\"\n :modelValue=\"name\"\n :placeholder=\"translate('apiClient.requestTableRow.key')\"\n :required=\"Boolean(data.isRequired)\"\n @blur=\"(v) => handleKeyBlur(v)\"\n @keydown.capture=\"handleKeydown\"\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ name: v })\" />\n </DataTableCell>\n\n <!-- Value -->\n <DataTableCell>\n <!-- Preset switcher for grouped global cookies that share a name -->\n <DataTableInputSelect\n v-if=\"data.presetOptions?.length\"\n :canAddCustomValue=\"false\"\n :modelValue=\"displayValue\"\n :value=\"data.presetOptions\"\n @update:modelValue=\"(v) => emit('selectPreset', v)\" />\n <CodeInputLite\n v-else\n :aria-label=\"\n translate('apiClient.requestTableRow.valueLabel', {\n name: label ?? '',\n })\n \"\n :arrayEncoding=\"data.arrayEncoding\"\n class=\"pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10\"\n :default=\"defaultValue\"\n :disabled=\"data.isReadonly\"\n :enum=\"enumValue\"\n :environment=\"environment\"\n :examples=\"\n data.schema?.examples?.map((example) => String(example)) ?? []\n \"\n :linethrough=\"data.isOverridden\"\n :modelValue=\"displayValue\"\n :placeholder=\"translate('apiClient.requestTableRow.value')\"\n :type=\"typeValue\"\n withFakeData\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ value: v })\">\n <template #icon>\n <ScalarButton\n v-if=\"\n Boolean(data.name || value) &&\n !data.isRequired &&\n data.isReadonly !== true\n \"\n :aria-label=\"\n translate('apiClient.requestTableRow.deleteRow', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('deleteRow')\">\n <ScalarIconTrash class=\"size-3.5\" />\n </ScalarButton>\n\n <ScalarIconButton\n v-if=\"data.globalRoute !== undefined\"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit\"\n :icon=\"ScalarIconGlobe\"\n :label=\"translate('apiClient.requestTableRow.globalCookieHint')\"\n size=\"xs\"\n tooltip=\"top\"\n variant=\"ghost\"\n @click=\"emit('navigate', data.globalRoute)\" />\n\n <RequestTableTooltip\n v-if=\"data.isReadonly\"\n :description=\"translate('apiClient.requestTableRow.readOnlyHint')\"\n :value=\"null\" />\n <RequestTableTooltip\n v-else-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value />\n </template>\n </CodeInputLite>\n </DataTableCell>\n\n <!-- File upload -->\n <DataTableCell\n v-if=\"showUploadButton\"\n class=\"group/upload flex items-center justify-center whitespace-nowrap\">\n <template v-if=\"isFile\">\n <div\n class=\"text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1\">\n <span\n class=\"truncate\"\n :title=\"displayValue\"\n >{{ displayValue }}</span\n >\n </div>\n <button\n class=\"bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100\"\n type=\"button\"\n @click=\"emit('removeFile')\">\n {{ translate('apiClient.requestTableRow.delete') }}\n </button>\n </template>\n <template v-else>\n <div class=\"p-0.5\">\n <ScalarButton\n class=\"bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"emit('uploadFile')\">\n <span>{{ translate('apiClient.requestTableRow.selectFile') }}</span>\n <ScalarIcon\n class=\"ml-1\"\n icon=\"Upload\"\n size=\"xs\"\n thickness=\"2.5\" />\n </ScalarButton>\n </div>\n </template>\n </DataTableCell>\n </DataTableRow>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"RequestTableRow.vue.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconGlobe, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ParameterObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { getFileName } from '@/v2/blocks/request-block/helpers/files'\nimport { validateParameter } from '@/v2/blocks/request-block/helpers/validate-parameter'\nimport { CodeInputLite } from '@/v2/components/code-input'\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableInputSelect,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nimport RequestTableTooltip from './RequestTableTooltip.vue'\n\nconst {\n data,\n environment,\n hasCheckboxDisabled,\n deferKeyUpdates,\n invalidParams,\n showUploadButton,\n} = defineProps<{\n data: TableRow\n /** Keep key edits local until blur when the row identity depends on its name. */\n deferKeyUpdates?: boolean\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n environment: XScalarEnvironment\n showUploadButton?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'upsertRow', payload: TableRowUpsertPayload): void\n (e: 'deleteRow'): void\n (e: 'uploadFile'): void\n (e: 'removeFile'): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset. */\n (e: 'selectPreset', value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nconst valueInput = useTemplateRef('valueInput')\ndefineExpose({ focusValue: (): void => valueInput.value?.focus() })\n\nexport type TableRow = {\n /** The parameter or field name/key */\n name: string\n /** The parameter value, can be a string, file, or null */\n value: string | File | null\n /** Optional description for the parameter */\n description?: string\n /** Optional route for global parameters (e.g., cookies shared across workspace) */\n globalRoute?: ApiReferenceEvents['ui:navigate']\n /** Whether the parameter is disabled/inactive */\n isDisabled?: boolean\n /** Whether an optional parameter is disabled because it has no explicit x-disabled value */\n isDisabledByDefault?: boolean\n /** OpenAPI schema object with type, validation rules, examples, etc. */\n schema?: SchemaObject\n /** Preserve array values even while their JSON text is temporarily invalid. */\n isArray?: boolean\n /** Text representation used by array enum controls. */\n arrayEncoding?: 'json' | 'comma-separated'\n /** Whether the parameter is required */\n isRequired?: boolean\n /**\n * Whether the parameter is readonly and can not be modifies directly\n * User can still override the parameter which is going to show up with the linethrough style\n */\n isReadonly?: boolean\n /** Whether the parameter is overridden later on */\n isOverridden?: boolean\n /** Track the original parameter so we can update it */\n originalParameter?: ParameterObject\n /** Path to a value inside the original parameter example for expanded object parameters */\n sourceParameterValuePath?: string[]\n /**\n * Selectable values for a grouped global cookie preset. When set, the value cell renders a\n * dropdown to switch between predefined values (for example a `Culture` cookie with `PL`/`EN`)\n * instead of an editable input.\n */\n presetOptions?: string[]\n}\n\nexport type TableRowUpsertPayload = {\n name: string\n value: string | File\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\n/**\n * Track local state for the row\n *\n * Now this is required because of the way we get default values from the schema.\n * If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now\n * we have an example where value: ''. This is why we need to track the local state and update all of the params at the\n * same time.\n */\nconst name = ref<string>(data.name ?? '')\nconst value = ref<string | File>(unpackProxyObject(data.value) ?? '')\nconst isDisabled = ref<boolean>(data.isDisabled ?? false)\n\n// Keep the above state synced with the data prop\nwatch(\n () => data.name,\n (newName) => {\n // Do not overwrite a valid local name with an empty incoming prop — this\n // can happen when the placeholder row (appended by displayData) is briefly\n // mapped onto this component instance before Vue re-keys the list.\n if (!newName && name.value && !deferKeyUpdates) {\n return\n }\n name.value = newName ?? ''\n },\n)\nwatch(\n () => data.value,\n (newValue) => (value.value = unpackProxyObject(newValue) ?? ''),\n)\nwatch(\n () => data.isDisabled,\n (newIsDisabled) => (isDisabled.value = newIsDisabled ?? false),\n)\n\n/** Check if the value is a File instance */\nconst isFile = computed(() => value.value instanceof File)\n\n/** Display value handles File instances and shows filename instead */\nconst displayValue = computed(\n () =>\n (isFile.value\n ? getFileName(value.value as File)\n : (value.value as string)) ?? '',\n)\n\nconst defaultValue = computed(() => data.schema?.default as string)\n\n/** See if we can extract enum values from the schema */\nconst enumValue = computed<unknown[]>(() => {\n if (!data.schema) {\n return []\n }\n\n // Grab the enum from the schema\n if (data.schema.enum) {\n return data.schema.enum.map((item) => String(item))\n }\n\n // Grab the enum from the items schema\n if ('items' in data.schema) {\n const resolved = resolve.schema(data.schema.items)\n if (resolved?.enum) {\n return data.arrayEncoding === 'json'\n ? resolved.enum\n : resolved.enum.map((item) => String(item))\n }\n }\n\n return []\n})\n\nconst typeValue = computed(() =>\n data.schema && 'type' in data.schema ? data.schema.type : undefined,\n)\n\nconst validationResult = computed(() =>\n validateParameter(data.schema, value.value),\n)\n\n/** Handle row updates while preserving existing properties */\nconst handleUpdateRow = (\n payload: Partial<{ name: string; value: string; isDisabled: boolean }>,\n options: { shouldRenameExpandedRow?: boolean; commitKey?: boolean } = {},\n): void => {\n // Update our local state\n if (payload.name !== undefined) {\n name.value = payload.name\n }\n if (payload.value !== undefined) {\n value.value = payload.value\n\n // Optional parameters start unchecked, but entering a value expresses intent to send it.\n // Explicit x-disabled values stay unchanged so a deliberate opt-out is preserved.\n if (data.isDisabledByDefault) {\n isDisabled.value = false\n }\n }\n\n // Is disabled should only be updated when explicitly provided in the payload\n if (payload.isDisabled !== undefined) {\n isDisabled.value = payload.isDisabled\n }\n\n if (\n payload.name !== undefined &&\n (deferKeyUpdates || data.sourceParameterValuePath) &&\n !options.shouldRenameExpandedRow &&\n !options.commitKey\n ) {\n return\n }\n\n // Emit all of the local state\n emit('upsertRow', {\n name: name.value,\n value: value.value,\n isDisabled: isDisabled.value,\n ...(options.shouldRenameExpandedRow\n ? { shouldRenameExpandedRow: true }\n : {}),\n })\n}\n\n/**\n * Commit a key edit when the input loses focus. Body and expanded-object rows defer their rename to blur (see\n * handleUpdateRow), so we only emit when the key actually changed. Focusing and blurring the field\n * without typing should not re-emit the row or silently reset its disabled state. The current\n * disabled state is passed through so a renamed row keeps it.\n */\nconst handleKeyBlur = (newName: string): void => {\n if (newName === data.name) {\n return\n }\n // Do not emit an update that would blank the parameter name — this can fire\n // when CodeInputLite blurs before it has rendered its initial value.\n if (!newName && data.name && (!deferKeyUpdates || name.value !== '')) {\n return\n }\n\n handleUpdateRow(\n { name: newName, isDisabled: isDisabled.value },\n {\n shouldRenameExpandedRow: Boolean(data.sourceParameterValuePath),\n commitKey: true,\n },\n )\n}\n\n/** Save a pending body key before the send shortcut reaches the request handler. */\nconst handleKeydown = (event: KeyboardEvent): void => {\n if (\n deferKeyUpdates &&\n event.key === 'Enter' &&\n (event.metaKey || event.ctrlKey)\n ) {\n handleKeyBlur(name.value)\n }\n}\n</script>\n\n<template>\n <DataTableRow\n :id=\"data.name\"\n :class=\"{\n alert: validationResult.ok === false,\n error: validationResult.ok === false && invalidParams?.has(data.name),\n }\">\n <DataTableCheckbox\n :ariaLabel=\"\n translate('apiClient.requestTableRow.include', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"!border-r\"\n :disabled=\"hasCheckboxDisabled ?? false\"\n :modelValue=\"!isDisabled\"\n @update:modelValue=\"(v) => handleUpdateRow({ isDisabled: !v })\" />\n\n <!-- Name -->\n <DataTableCell>\n <CodeInputLite\n :aria-label=\"\n translate('apiClient.requestTableRow.keyLabel', { name: label ?? '' })\n \"\n :disabled=\"data.isReadonly\"\n :environment=\"environment\"\n :modelValue=\"name\"\n :placeholder=\"translate('apiClient.requestTableRow.key')\"\n :required=\"Boolean(data.isRequired)\"\n @blur=\"(v) => handleKeyBlur(v)\"\n @keydown.capture=\"handleKeydown\"\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ name: v })\" />\n </DataTableCell>\n\n <!-- Value -->\n <DataTableCell>\n <!-- Preset switcher for grouped global cookies that share a name -->\n <DataTableInputSelect\n v-if=\"data.presetOptions?.length\"\n :canAddCustomValue=\"false\"\n :modelValue=\"displayValue\"\n :value=\"data.presetOptions\"\n @update:modelValue=\"(v) => emit('selectPreset', v)\" />\n <CodeInputLite\n v-else\n ref=\"valueInput\"\n :aria-label=\"\n translate('apiClient.requestTableRow.valueLabel', {\n name: label ?? '',\n })\n \"\n :arrayEncoding=\"data.arrayEncoding\"\n class=\"pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10\"\n :default=\"defaultValue\"\n :disabled=\"data.isReadonly\"\n :enum=\"enumValue\"\n :environment=\"environment\"\n :examples=\"\n data.schema?.examples?.map((example) => String(example)) ?? []\n \"\n :linethrough=\"data.isOverridden\"\n :modelValue=\"displayValue\"\n :placeholder=\"translate('apiClient.requestTableRow.value')\"\n :type=\"typeValue\"\n withFakeData\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ value: v })\">\n <template #icon>\n <ScalarButton\n v-if=\"\n Boolean(data.name || value) &&\n !data.isRequired &&\n data.isReadonly !== true\n \"\n :aria-label=\"\n translate('apiClient.requestTableRow.deleteRow', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('deleteRow')\">\n <ScalarIconTrash class=\"size-3.5\" />\n </ScalarButton>\n\n <ScalarIconButton\n v-if=\"data.globalRoute !== undefined\"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit\"\n :icon=\"ScalarIconGlobe\"\n :label=\"translate('apiClient.requestTableRow.globalCookieHint')\"\n size=\"xs\"\n tooltip=\"top\"\n variant=\"ghost\"\n @click=\"emit('navigate', data.globalRoute)\" />\n\n <RequestTableTooltip\n v-if=\"data.isReadonly\"\n :description=\"translate('apiClient.requestTableRow.readOnlyHint')\"\n :value=\"null\" />\n <RequestTableTooltip\n v-else-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value />\n </template>\n </CodeInputLite>\n </DataTableCell>\n\n <!-- File upload -->\n <DataTableCell\n v-if=\"showUploadButton\"\n class=\"group/upload flex items-center justify-center whitespace-nowrap\">\n <template v-if=\"isFile\">\n <div\n class=\"text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1\">\n <span\n class=\"truncate\"\n :title=\"displayValue\"\n >{{ displayValue }}</span\n >\n </div>\n <button\n class=\"bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100\"\n type=\"button\"\n @click=\"emit('removeFile')\">\n {{ translate('apiClient.requestTableRow.delete') }}\n </button>\n </template>\n <template v-else>\n <div class=\"p-0.5\">\n <ScalarButton\n class=\"bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"emit('uploadFile')\">\n <span>{{ translate('apiClient.requestTableRow.selectFile') }}</span>\n <ScalarIcon\n class=\"ml-1\"\n icon=\"Upload\"\n size=\"xs\"\n thickness=\"2.5\" />\n </ScalarButton>\n </div>\n </template>\n </DataTableCell>\n </DataTableRow>\n</template>\n"],"mappings":""}
@@ -7,7 +7,7 @@ import DataTableRow_default from "../../../components/data-table/DataTableRow.vu
7
7
  import { getFileName } from "../helpers/files.js";
8
8
  import { validateParameter } from "../helpers/validate-parameter.js";
9
9
  import RequestTableTooltip_default from "./RequestTableTooltip.vue.js";
10
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, toDisplayString, unref, watch, withCtx } from "vue";
10
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, toDisplayString, unref, useTemplateRef, watch, withCtx } from "vue";
11
11
  import { ScalarButton } from "@scalar/components/button";
12
12
  import { ScalarIconGlobe, ScalarIconTrash } from "@scalar/icons";
13
13
  import { ScalarIcon } from "@scalar/components/icon";
@@ -48,9 +48,11 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
48
48
  "navigate",
49
49
  "selectPreset"
50
50
  ],
51
- setup(__props, { emit: __emit }) {
51
+ setup(__props, { expose: __expose, emit: __emit }) {
52
52
  const emit = __emit;
53
53
  const { translate } = useLocalization();
54
+ const valueInput = useTemplateRef("valueInput");
55
+ __expose({ focusValue: () => valueInput.value?.focus() });
54
56
  const name = ref(__props.data.name ?? "");
55
57
  const value = ref(unpackProxyObject(__props.data.value) ?? "");
56
58
  const isDisabled = ref(__props.data.isDisabled ?? false);
@@ -165,6 +167,8 @@ var RequestTableRow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
165
167
  "onUpdate:modelValue": _cache[4] || (_cache[4] = (v) => emit("selectPreset", v))
166
168
  }, null, 8, ["modelValue", "value"])) : (openBlock(), createBlock(unref(CodeInputLite_default), {
167
169
  key: 1,
170
+ ref_key: "valueInput",
171
+ ref: valueInput,
168
172
  "aria-label": unref(translate)("apiClient.requestTableRow.valueLabel", { name: __props.label ?? "" }),
169
173
  arrayEncoding: __props.data.arrayEncoding,
170
174
  class: "pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10",
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTableRow.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconGlobe, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ParameterObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, watch } from 'vue'\n\nimport { getFileName } from '@/v2/blocks/request-block/helpers/files'\nimport { validateParameter } from '@/v2/blocks/request-block/helpers/validate-parameter'\nimport { CodeInputLite } from '@/v2/components/code-input'\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableInputSelect,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nimport RequestTableTooltip from './RequestTableTooltip.vue'\n\nconst {\n data,\n environment,\n hasCheckboxDisabled,\n deferKeyUpdates,\n invalidParams,\n showUploadButton,\n} = defineProps<{\n data: TableRow\n /** Keep key edits local until blur when the row identity depends on its name. */\n deferKeyUpdates?: boolean\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n environment: XScalarEnvironment\n showUploadButton?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'upsertRow', payload: TableRowUpsertPayload): void\n (e: 'deleteRow'): void\n (e: 'uploadFile'): void\n (e: 'removeFile'): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset. */\n (e: 'selectPreset', value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nexport type TableRow = {\n /** The parameter or field name/key */\n name: string\n /** The parameter value, can be a string, file, or null */\n value: string | File | null\n /** Optional description for the parameter */\n description?: string\n /** Optional route for global parameters (e.g., cookies shared across workspace) */\n globalRoute?: ApiReferenceEvents['ui:navigate']\n /** Whether the parameter is disabled/inactive */\n isDisabled?: boolean\n /** Whether an optional parameter is disabled because it has no explicit x-disabled value */\n isDisabledByDefault?: boolean\n /** OpenAPI schema object with type, validation rules, examples, etc. */\n schema?: SchemaObject\n /** Preserve array values even while their JSON text is temporarily invalid. */\n isArray?: boolean\n /** Text representation used by array enum controls. */\n arrayEncoding?: 'json' | 'comma-separated'\n /** Whether the parameter is required */\n isRequired?: boolean\n /**\n * Whether the parameter is readonly and can not be modifies directly\n * User can still override the parameter which is going to show up with the linethrough style\n */\n isReadonly?: boolean\n /** Whether the parameter is overridden later on */\n isOverridden?: boolean\n /** Track the original parameter so we can update it */\n originalParameter?: ParameterObject\n /** Path to a value inside the original parameter example for expanded object parameters */\n sourceParameterValuePath?: string[]\n /**\n * Selectable values for a grouped global cookie preset. When set, the value cell renders a\n * dropdown to switch between predefined values (for example a `Culture` cookie with `PL`/`EN`)\n * instead of an editable input.\n */\n presetOptions?: string[]\n}\n\nexport type TableRowUpsertPayload = {\n name: string\n value: string | File\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\n/**\n * Track local state for the row\n *\n * Now this is required because of the way we get default values from the schema.\n * If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now\n * we have an example where value: ''. This is why we need to track the local state and update all of the params at the\n * same time.\n */\nconst name = ref<string>(data.name ?? '')\nconst value = ref<string | File>(unpackProxyObject(data.value) ?? '')\nconst isDisabled = ref<boolean>(data.isDisabled ?? false)\n\n// Keep the above state synced with the data prop\nwatch(\n () => data.name,\n (newName) => {\n // Do not overwrite a valid local name with an empty incoming prop — this\n // can happen when the placeholder row (appended by displayData) is briefly\n // mapped onto this component instance before Vue re-keys the list.\n if (!newName && name.value && !deferKeyUpdates) return\n name.value = newName ?? ''\n },\n)\nwatch(\n () => data.value,\n (newValue) => (value.value = unpackProxyObject(newValue) ?? ''),\n)\nwatch(\n () => data.isDisabled,\n (newIsDisabled) => (isDisabled.value = newIsDisabled ?? false),\n)\n\n/** Check if the value is a File instance */\nconst isFile = computed(() => value.value instanceof File)\n\n/** Display value handles File instances and shows filename instead */\nconst displayValue = computed(\n () =>\n (isFile.value\n ? getFileName(value.value as File)\n : (value.value as string)) ?? '',\n)\n\nconst defaultValue = computed(() => data.schema?.default as string)\n\n/** See if we can extract enum values from the schema */\nconst enumValue = computed<unknown[]>(() => {\n if (!data.schema) {\n return []\n }\n\n // Grab the enum from the schema\n if (data.schema.enum) {\n return data.schema.enum.map((item) => String(item))\n }\n\n // Grab the enum from the items schema\n if ('items' in data.schema) {\n const resolved = resolve.schema(data.schema.items)\n if (resolved?.enum) {\n return data.arrayEncoding === 'json'\n ? resolved.enum\n : resolved.enum.map((item) => String(item))\n }\n }\n\n return []\n})\n\nconst typeValue = computed(() =>\n data.schema && 'type' in data.schema ? data.schema.type : undefined,\n)\n\nconst validationResult = computed(() =>\n validateParameter(data.schema, value.value),\n)\n\n/** Handle row updates while preserving existing properties */\nconst handleUpdateRow = (\n payload: Partial<{ name: string; value: string; isDisabled: boolean }>,\n options: { shouldRenameExpandedRow?: boolean; commitKey?: boolean } = {},\n): void => {\n // Update our local state\n if (payload.name !== undefined) {\n name.value = payload.name\n }\n if (payload.value !== undefined) {\n value.value = payload.value\n\n // Optional parameters start unchecked, but entering a value expresses intent to send it.\n // Explicit x-disabled values stay unchanged so a deliberate opt-out is preserved.\n if (data.isDisabledByDefault) {\n isDisabled.value = false\n }\n }\n\n // Is disabled should only be updated when explicitly provided in the payload\n if (payload.isDisabled !== undefined) {\n isDisabled.value = payload.isDisabled\n }\n\n if (\n payload.name !== undefined &&\n (deferKeyUpdates || data.sourceParameterValuePath) &&\n !options.shouldRenameExpandedRow &&\n !options.commitKey\n ) {\n return\n }\n\n // Emit all of the local state\n emit('upsertRow', {\n name: name.value,\n value: value.value,\n isDisabled: isDisabled.value,\n ...(options.shouldRenameExpandedRow\n ? { shouldRenameExpandedRow: true }\n : {}),\n })\n}\n\n/**\n * Commit a key edit when the input loses focus. Body and expanded-object rows defer their rename to blur (see\n * handleUpdateRow), so we only emit when the key actually changed. Focusing and blurring the field\n * without typing should not re-emit the row or silently reset its disabled state. The current\n * disabled state is passed through so a renamed row keeps it.\n */\nconst handleKeyBlur = (newName: string): void => {\n if (newName === data.name) {\n return\n }\n // Do not emit an update that would blank the parameter name — this can fire\n // when CodeInputLite blurs before it has rendered its initial value.\n if (!newName && data.name && (!deferKeyUpdates || name.value !== '')) {\n return\n }\n\n handleUpdateRow(\n { name: newName, isDisabled: isDisabled.value },\n {\n shouldRenameExpandedRow: Boolean(data.sourceParameterValuePath),\n commitKey: true,\n },\n )\n}\n\n/** Save a pending body key before the send shortcut reaches the request handler. */\nconst handleKeydown = (event: KeyboardEvent): void => {\n if (\n deferKeyUpdates &&\n event.key === 'Enter' &&\n (event.metaKey || event.ctrlKey)\n ) {\n handleKeyBlur(name.value)\n }\n}\n</script>\n\n<template>\n <DataTableRow\n :id=\"data.name\"\n :class=\"{\n alert: validationResult.ok === false,\n error: validationResult.ok === false && invalidParams?.has(data.name),\n }\">\n <DataTableCheckbox\n :ariaLabel=\"\n translate('apiClient.requestTableRow.include', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"!border-r\"\n :disabled=\"hasCheckboxDisabled ?? false\"\n :modelValue=\"!isDisabled\"\n @update:modelValue=\"(v) => handleUpdateRow({ isDisabled: !v })\" />\n\n <!-- Name -->\n <DataTableCell>\n <CodeInputLite\n :aria-label=\"\n translate('apiClient.requestTableRow.keyLabel', { name: label ?? '' })\n \"\n :disabled=\"data.isReadonly\"\n :environment=\"environment\"\n :modelValue=\"name\"\n :placeholder=\"translate('apiClient.requestTableRow.key')\"\n :required=\"Boolean(data.isRequired)\"\n @blur=\"(v) => handleKeyBlur(v)\"\n @keydown.capture=\"handleKeydown\"\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ name: v })\" />\n </DataTableCell>\n\n <!-- Value -->\n <DataTableCell>\n <!-- Preset switcher for grouped global cookies that share a name -->\n <DataTableInputSelect\n v-if=\"data.presetOptions?.length\"\n :canAddCustomValue=\"false\"\n :modelValue=\"displayValue\"\n :value=\"data.presetOptions\"\n @update:modelValue=\"(v) => emit('selectPreset', v)\" />\n <CodeInputLite\n v-else\n :aria-label=\"\n translate('apiClient.requestTableRow.valueLabel', {\n name: label ?? '',\n })\n \"\n :arrayEncoding=\"data.arrayEncoding\"\n class=\"pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10\"\n :default=\"defaultValue\"\n :disabled=\"data.isReadonly\"\n :enum=\"enumValue\"\n :environment=\"environment\"\n :examples=\"\n data.schema?.examples?.map((example) => String(example)) ?? []\n \"\n :linethrough=\"data.isOverridden\"\n :modelValue=\"displayValue\"\n :placeholder=\"translate('apiClient.requestTableRow.value')\"\n :type=\"typeValue\"\n withFakeData\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ value: v })\">\n <template #icon>\n <ScalarButton\n v-if=\"\n Boolean(data.name || value) &&\n !data.isRequired &&\n data.isReadonly !== true\n \"\n :aria-label=\"\n translate('apiClient.requestTableRow.deleteRow', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('deleteRow')\">\n <ScalarIconTrash class=\"size-3.5\" />\n </ScalarButton>\n\n <ScalarIconButton\n v-if=\"data.globalRoute !== undefined\"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit\"\n :icon=\"ScalarIconGlobe\"\n :label=\"translate('apiClient.requestTableRow.globalCookieHint')\"\n size=\"xs\"\n tooltip=\"top\"\n variant=\"ghost\"\n @click=\"emit('navigate', data.globalRoute)\" />\n\n <RequestTableTooltip\n v-if=\"data.isReadonly\"\n :description=\"translate('apiClient.requestTableRow.readOnlyHint')\"\n :value=\"null\" />\n <RequestTableTooltip\n v-else-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value />\n </template>\n </CodeInputLite>\n </DataTableCell>\n\n <!-- File upload -->\n <DataTableCell\n v-if=\"showUploadButton\"\n class=\"group/upload flex items-center justify-center whitespace-nowrap\">\n <template v-if=\"isFile\">\n <div\n class=\"text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1\">\n <span\n class=\"truncate\"\n :title=\"displayValue\"\n >{{ displayValue }}</span\n >\n </div>\n <button\n class=\"bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100\"\n type=\"button\"\n @click=\"emit('removeFile')\">\n {{ translate('apiClient.requestTableRow.delete') }}\n </button>\n </template>\n <template v-else>\n <div class=\"p-0.5\">\n <ScalarButton\n class=\"bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"emit('uploadFile')\">\n <span>{{ translate('apiClient.requestTableRow.selectFile') }}</span>\n <ScalarIcon\n class=\"ml-1\"\n icon=\"Upload\"\n size=\"xs\"\n thickness=\"2.5\" />\n </ScalarButton>\n </div>\n </template>\n </DataTableCell>\n </DataTableRow>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CA,MAAM,OAAO;EAUb,MAAM,EAAE,cAAc,gBAAgB;EAyDtC,MAAM,OAAO,IAAY,QAAA,KAAK,QAAQ,EAAE;EACxC,MAAM,QAAQ,IAAmB,kBAAkB,QAAA,KAAK,KAAK,KAAK,EAAE;EACpE,MAAM,aAAa,IAAa,QAAA,KAAK,cAAc,KAAK;EAGxD,YACQ,QAAA,KAAK,OACV,YAAY;GAIX,IAAI,CA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,aAAA,KAAY,GAAA,GAAA,UAAA,CAAA,CAAA,GAGpB,mBAKS,UAAA;OAJP,OAAM;OACN,MAAK;OACJ,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,YAAA;yBACT,MAAA,SAAA,CAAS,CAAA,kCAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,MAAA,UAAA,GAId,mBAaM,OAbN,YAaM,CAZJ,YAWe,MAAA,YAAA,GAAA;OAVb,OAAM;OACN,MAAK;OACL,SAAQ;OACP,SAAK,OAAA,QAAA,OAAA,OAAA,WAAE,KAAI,YAAA;;8BACwD,CAApE,mBAAoE,QAAA,MAAA,gBAA3D,MAAA,SAAA,CAAS,CAAA,sCAAA,CAAA,GAAA,CAAA,GAClB,YAIoB,MAAA,UAAA,GAAA;QAHlB,OAAM;QACN,MAAK;QACL,MAAK;QACL,WAAU"}
1
+ {"version":3,"file":"RequestTableRow.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestTableRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconGlobe, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport { resolve } from '@scalar/workspace-store/resolve'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type {\n ParameterObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { getFileName } from '@/v2/blocks/request-block/helpers/files'\nimport { validateParameter } from '@/v2/blocks/request-block/helpers/validate-parameter'\nimport { CodeInputLite } from '@/v2/components/code-input'\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableInputSelect,\n DataTableRow,\n} from '@/v2/components/data-table'\nimport { useLocalization } from '@/v2/features/localization'\n\nimport RequestTableTooltip from './RequestTableTooltip.vue'\n\nconst {\n data,\n environment,\n hasCheckboxDisabled,\n deferKeyUpdates,\n invalidParams,\n showUploadButton,\n} = defineProps<{\n data: TableRow\n /** Keep key edits local until blur when the row identity depends on its name. */\n deferKeyUpdates?: boolean\n hasCheckboxDisabled?: boolean\n invalidParams?: Set<string>\n label?: string\n environment: XScalarEnvironment\n showUploadButton?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'upsertRow', payload: TableRowUpsertPayload): void\n (e: 'deleteRow'): void\n (e: 'uploadFile'): void\n (e: 'removeFile'): void\n (e: 'navigate', route: NonNullable<TableRow['globalRoute']>): void\n /** Select a value for a grouped global cookie preset. */\n (e: 'selectPreset', value: string): void\n}>()\n\nconst { translate } = useLocalization()\n\nconst valueInput = useTemplateRef('valueInput')\ndefineExpose({ focusValue: (): void => valueInput.value?.focus() })\n\nexport type TableRow = {\n /** The parameter or field name/key */\n name: string\n /** The parameter value, can be a string, file, or null */\n value: string | File | null\n /** Optional description for the parameter */\n description?: string\n /** Optional route for global parameters (e.g., cookies shared across workspace) */\n globalRoute?: ApiReferenceEvents['ui:navigate']\n /** Whether the parameter is disabled/inactive */\n isDisabled?: boolean\n /** Whether an optional parameter is disabled because it has no explicit x-disabled value */\n isDisabledByDefault?: boolean\n /** OpenAPI schema object with type, validation rules, examples, etc. */\n schema?: SchemaObject\n /** Preserve array values even while their JSON text is temporarily invalid. */\n isArray?: boolean\n /** Text representation used by array enum controls. */\n arrayEncoding?: 'json' | 'comma-separated'\n /** Whether the parameter is required */\n isRequired?: boolean\n /**\n * Whether the parameter is readonly and can not be modifies directly\n * User can still override the parameter which is going to show up with the linethrough style\n */\n isReadonly?: boolean\n /** Whether the parameter is overridden later on */\n isOverridden?: boolean\n /** Track the original parameter so we can update it */\n originalParameter?: ParameterObject\n /** Path to a value inside the original parameter example for expanded object parameters */\n sourceParameterValuePath?: string[]\n /**\n * Selectable values for a grouped global cookie preset. When set, the value cell renders a\n * dropdown to switch between predefined values (for example a `Culture` cookie with `PL`/`EN`)\n * instead of an editable input.\n */\n presetOptions?: string[]\n}\n\nexport type TableRowUpsertPayload = {\n name: string\n value: string | File\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\n/**\n * Track local state for the row\n *\n * Now this is required because of the way we get default values from the schema.\n * If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now\n * we have an example where value: ''. This is why we need to track the local state and update all of the params at the\n * same time.\n */\nconst name = ref<string>(data.name ?? '')\nconst value = ref<string | File>(unpackProxyObject(data.value) ?? '')\nconst isDisabled = ref<boolean>(data.isDisabled ?? false)\n\n// Keep the above state synced with the data prop\nwatch(\n () => data.name,\n (newName) => {\n // Do not overwrite a valid local name with an empty incoming prop — this\n // can happen when the placeholder row (appended by displayData) is briefly\n // mapped onto this component instance before Vue re-keys the list.\n if (!newName && name.value && !deferKeyUpdates) {\n return\n }\n name.value = newName ?? ''\n },\n)\nwatch(\n () => data.value,\n (newValue) => (value.value = unpackProxyObject(newValue) ?? ''),\n)\nwatch(\n () => data.isDisabled,\n (newIsDisabled) => (isDisabled.value = newIsDisabled ?? false),\n)\n\n/** Check if the value is a File instance */\nconst isFile = computed(() => value.value instanceof File)\n\n/** Display value handles File instances and shows filename instead */\nconst displayValue = computed(\n () =>\n (isFile.value\n ? getFileName(value.value as File)\n : (value.value as string)) ?? '',\n)\n\nconst defaultValue = computed(() => data.schema?.default as string)\n\n/** See if we can extract enum values from the schema */\nconst enumValue = computed<unknown[]>(() => {\n if (!data.schema) {\n return []\n }\n\n // Grab the enum from the schema\n if (data.schema.enum) {\n return data.schema.enum.map((item) => String(item))\n }\n\n // Grab the enum from the items schema\n if ('items' in data.schema) {\n const resolved = resolve.schema(data.schema.items)\n if (resolved?.enum) {\n return data.arrayEncoding === 'json'\n ? resolved.enum\n : resolved.enum.map((item) => String(item))\n }\n }\n\n return []\n})\n\nconst typeValue = computed(() =>\n data.schema && 'type' in data.schema ? data.schema.type : undefined,\n)\n\nconst validationResult = computed(() =>\n validateParameter(data.schema, value.value),\n)\n\n/** Handle row updates while preserving existing properties */\nconst handleUpdateRow = (\n payload: Partial<{ name: string; value: string; isDisabled: boolean }>,\n options: { shouldRenameExpandedRow?: boolean; commitKey?: boolean } = {},\n): void => {\n // Update our local state\n if (payload.name !== undefined) {\n name.value = payload.name\n }\n if (payload.value !== undefined) {\n value.value = payload.value\n\n // Optional parameters start unchecked, but entering a value expresses intent to send it.\n // Explicit x-disabled values stay unchanged so a deliberate opt-out is preserved.\n if (data.isDisabledByDefault) {\n isDisabled.value = false\n }\n }\n\n // Is disabled should only be updated when explicitly provided in the payload\n if (payload.isDisabled !== undefined) {\n isDisabled.value = payload.isDisabled\n }\n\n if (\n payload.name !== undefined &&\n (deferKeyUpdates || data.sourceParameterValuePath) &&\n !options.shouldRenameExpandedRow &&\n !options.commitKey\n ) {\n return\n }\n\n // Emit all of the local state\n emit('upsertRow', {\n name: name.value,\n value: value.value,\n isDisabled: isDisabled.value,\n ...(options.shouldRenameExpandedRow\n ? { shouldRenameExpandedRow: true }\n : {}),\n })\n}\n\n/**\n * Commit a key edit when the input loses focus. Body and expanded-object rows defer their rename to blur (see\n * handleUpdateRow), so we only emit when the key actually changed. Focusing and blurring the field\n * without typing should not re-emit the row or silently reset its disabled state. The current\n * disabled state is passed through so a renamed row keeps it.\n */\nconst handleKeyBlur = (newName: string): void => {\n if (newName === data.name) {\n return\n }\n // Do not emit an update that would blank the parameter name — this can fire\n // when CodeInputLite blurs before it has rendered its initial value.\n if (!newName && data.name && (!deferKeyUpdates || name.value !== '')) {\n return\n }\n\n handleUpdateRow(\n { name: newName, isDisabled: isDisabled.value },\n {\n shouldRenameExpandedRow: Boolean(data.sourceParameterValuePath),\n commitKey: true,\n },\n )\n}\n\n/** Save a pending body key before the send shortcut reaches the request handler. */\nconst handleKeydown = (event: KeyboardEvent): void => {\n if (\n deferKeyUpdates &&\n event.key === 'Enter' &&\n (event.metaKey || event.ctrlKey)\n ) {\n handleKeyBlur(name.value)\n }\n}\n</script>\n\n<template>\n <DataTableRow\n :id=\"data.name\"\n :class=\"{\n alert: validationResult.ok === false,\n error: validationResult.ok === false && invalidParams?.has(data.name),\n }\">\n <DataTableCheckbox\n :ariaLabel=\"\n translate('apiClient.requestTableRow.include', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"!border-r\"\n :disabled=\"hasCheckboxDisabled ?? false\"\n :modelValue=\"!isDisabled\"\n @update:modelValue=\"(v) => handleUpdateRow({ isDisabled: !v })\" />\n\n <!-- Name -->\n <DataTableCell>\n <CodeInputLite\n :aria-label=\"\n translate('apiClient.requestTableRow.keyLabel', { name: label ?? '' })\n \"\n :disabled=\"data.isReadonly\"\n :environment=\"environment\"\n :modelValue=\"name\"\n :placeholder=\"translate('apiClient.requestTableRow.key')\"\n :required=\"Boolean(data.isRequired)\"\n @blur=\"(v) => handleKeyBlur(v)\"\n @keydown.capture=\"handleKeydown\"\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ name: v })\" />\n </DataTableCell>\n\n <!-- Value -->\n <DataTableCell>\n <!-- Preset switcher for grouped global cookies that share a name -->\n <DataTableInputSelect\n v-if=\"data.presetOptions?.length\"\n :canAddCustomValue=\"false\"\n :modelValue=\"displayValue\"\n :value=\"data.presetOptions\"\n @update:modelValue=\"(v) => emit('selectPreset', v)\" />\n <CodeInputLite\n v-else\n ref=\"valueInput\"\n :aria-label=\"\n translate('apiClient.requestTableRow.valueLabel', {\n name: label ?? '',\n })\n \"\n :arrayEncoding=\"data.arrayEncoding\"\n class=\"pr-6 group-hover:pr-10 group-has-[.code-input-lite__editor:focus]:pr-10\"\n :default=\"defaultValue\"\n :disabled=\"data.isReadonly\"\n :enum=\"enumValue\"\n :environment=\"environment\"\n :examples=\"\n data.schema?.examples?.map((example) => String(example)) ?? []\n \"\n :linethrough=\"data.isOverridden\"\n :modelValue=\"displayValue\"\n :placeholder=\"translate('apiClient.requestTableRow.value')\"\n :type=\"typeValue\"\n withFakeData\n @navigate=\"(route) => emit('navigate', route)\"\n @update:modelValue=\"(v) => handleUpdateRow({ value: v })\">\n <template #icon>\n <ScalarButton\n v-if=\"\n Boolean(data.name || value) &&\n !data.isRequired &&\n data.isReadonly !== true\n \"\n :aria-label=\"\n translate('apiClient.requestTableRow.deleteRow', {\n name: data.name || translate('apiClient.requestTableRow.row'),\n })\n \"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.code-input-lite__editor:focus]:flex\"\n size=\"sm\"\n variant=\"ghost\"\n @click=\"emit('deleteRow')\">\n <ScalarIconTrash class=\"size-3.5\" />\n </ScalarButton>\n\n <ScalarIconButton\n v-if=\"data.globalRoute !== undefined\"\n class=\"text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit\"\n :icon=\"ScalarIconGlobe\"\n :label=\"translate('apiClient.requestTableRow.globalCookieHint')\"\n size=\"xs\"\n tooltip=\"top\"\n variant=\"ghost\"\n @click=\"emit('navigate', data.globalRoute)\" />\n\n <RequestTableTooltip\n v-if=\"data.isReadonly\"\n :description=\"translate('apiClient.requestTableRow.readOnlyHint')\"\n :value=\"null\" />\n <RequestTableTooltip\n v-else-if=\"data.schema\"\n :description=\"data.description\"\n :schema=\"data.schema\"\n :value />\n </template>\n </CodeInputLite>\n </DataTableCell>\n\n <!-- File upload -->\n <DataTableCell\n v-if=\"showUploadButton\"\n class=\"group/upload flex items-center justify-center whitespace-nowrap\">\n <template v-if=\"isFile\">\n <div\n class=\"text-c-2 flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1\">\n <span\n class=\"truncate\"\n :title=\"displayValue\"\n >{{ displayValue }}</span\n >\n </div>\n <button\n class=\"bg-b-2 mt-1 block rounded p-0.5 text-center text-xs font-medium md:pointer-events-none md:absolute md:inset-x-1 md:top-1/2 md:mt-0 md:-translate-y-1/2 md:opacity-0 md:group-hover/upload:pointer-events-auto md:group-hover/upload:opacity-100\"\n type=\"button\"\n @click=\"emit('removeFile')\">\n {{ translate('apiClient.requestTableRow.delete') }}\n </button>\n </template>\n <template v-else>\n <div class=\"p-0.5\">\n <ScalarButton\n class=\"bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"emit('uploadFile')\">\n <span>{{ translate('apiClient.requestTableRow.selectFile') }}</span>\n <ScalarIcon\n class=\"ml-1\"\n icon=\"Upload\"\n size=\"xs\"\n thickness=\"2.5\" />\n </ScalarButton>\n </div>\n </template>\n </DataTableCell>\n </DataTableRow>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CA,MAAM,OAAO;EAUb,MAAM,EAAE,cAAc,gBAAgB;EAEtC,MAAM,aAAa,eAAe,YAAY;EAC9C,SAAa,EAAE,kBAAwB,WAAW,OAAO,MAAM,EAAE,CAAC;EAyDlE,MAAM,OAAO,IAAY,QAAA,KAAK,QAAQ,EAAE;EACxC,MAAM,QAAQ,IAAmB,kBAAkB,QAAA,KAAK,KAAK,KAAK,EAAE;EACpE,MAAM,aAAa,IAAa,QAAA,KAAK,cAAc,KAAK;EAGxD,YACQ,QAAA,KAAK,OACV,YAAY;GAIX,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,QAAA,iBAC7B;GAEF,KAAK,QAAQ,WAAW;EAC1B,CACF;EACA,YACQ,QAAA,KAAK,QACV,aAAc,MAAM,QAAQ,kBAAkB,QAAQ,KAAK,EAC9D;EACA,YACQ,QAAA,KAAK,aACV,kBAAmB,WAAW,QAAQ,iBAAiB,KAC1D;;EAGA,MAAM,SAAS,eAAe,MAAM,iBAAiB,IAAI;;EAGzD,MAAM,eAAe,gBAEhB,OAAO,QACJ,YAAY,MAAM,KAAa,IAC9B,MAAM,UAAqB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K,OAAA,QAAA,OAAA,OAAA,WAAE,KAAI,YAAA;;8BACwD,CAApE,mBAAoE,QAAA,MAAA,gBAA3D,MAAA,SAAA,CAAS,CAAA,sCAAA,CAAA,GAAA,CAAA,GAClB,YAIoB,MAAA,UAAA,GAAA;QAHlB,OAAM;QACN,MAAK;QACL,MAAK;QACL,WAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-parameter-handlers.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAG7F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,KAAK,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE3D,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,OAAO,CAAA;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AAkHD,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,GAClC,MAAM,aAAa,EACnB,UAAU,iBAAiB,EAC3B,MAAM,oBAAoB,EAC1B,6FAMG;IACD,OAAO,EAAE,QAAQ,EAAE,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC7C,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;CACtE;sBAKmB;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;;oBAuCnB,MAAM,WAAW,sBAAsB;CA+C1D,CAAA"}
1
+ {"version":3,"file":"create-parameter-handlers.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAGjH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,KAAK,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE3D,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,OAAO,CAAA;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AAqHD,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,GAClC,MAAM,aAAa,EACnB,UAAU,iBAAiB,EAC3B,MAAM,oBAAoB,EAC1B,6FAMG;IACD,OAAO,EAAE,QAAQ,EAAE,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC7C,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;CACtE;sBAKmB;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;;oBAuCnB,MAAM,WAAW,sBAAsB;CA+C1D,CAAA"}
@@ -40,15 +40,22 @@ var getExpandedObjectPayload = (row, context, payload) => {
40
40
  const isEditedRow = contextRow === row && payload !== void 0;
41
41
  const nextValue = isEditedRow ? payload.value : contextRow.value;
42
42
  if (isEmptyValue(nextValue)) continue;
43
- const path = isEditedRow ? payload.shouldRenameExpandedRow ? getEditedValuePath(payload.name, row.originalParameter?.name, contextRow.sourceParameterValuePath) : contextRow.sourceParameterValuePath : contextRow.sourceParameterValuePath;
43
+ const path = isEditedRow && payload.shouldRenameExpandedRow ? getEditedValuePath(payload.name, row.originalParameter?.name, contextRow.sourceParameterValuePath) : contextRow.sourceParameterValuePath;
44
44
  const isCommittedRename = isEditedRow && Boolean(payload.shouldRenameExpandedRow);
45
- const leafSchema = hasArrayMarker(isCommittedRename ? payload.name : contextRow.name) ? { type: "array" } : isCommittedRename ? void 0 : contextRow.schema;
45
+ const hasArrayLeafMarker = hasArrayMarker(isCommittedRename ? payload.name : contextRow.name);
46
+ const existingLeafSchema = isCommittedRename ? void 0 : contextRow.schema;
47
+ const leafSchema = hasArrayLeafMarker ? { type: "array" } : existingLeafSchema;
46
48
  setValueAtPath(value, path, isDeepObjectParameter && leafSchema ? deSerializeSchemaValue(nextValue, leafSchema) : nextValue);
47
49
  }
48
50
  return {
49
51
  name: row.originalParameter?.name ?? payload?.name ?? row.name,
50
52
  value,
51
- isDisabled: payload?.isDisabled ?? row.isDisabled ?? false
53
+ isDisabled: payload?.isDisabled ?? row.isDisabled ?? false,
54
+ propertyState: {
55
+ path: payload?.shouldRenameExpandedRow ? getEditedValuePath(payload.name, row.originalParameter?.name, row.sourceParameterValuePath ?? []) : row.sourceParameterValuePath ?? [],
56
+ ...payload ? { isDisabled: payload.isDisabled } : {},
57
+ ...payload?.shouldRenameExpandedRow ? { previousPath: row.sourceParameterValuePath } : {}
58
+ }
52
59
  };
53
60
  };
54
61
  /** Create parameter event handlers for a given type */
@@ -1 +1 @@
1
- {"version":3,"file":"create-parameter-handlers.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-handlers.ts"],"sourcesContent":["import { setValueAtPath } from '@scalar/helpers/object/set-value-at-path'\nimport type { OperationExampleMeta, WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { deSerializeSchemaValue } from '@scalar/workspace-store/request-example'\n\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\n\ntype ParameterType = 'path' | 'cookie' | 'header' | 'query'\n\ntype ParameterUpsertPayload = {\n name: string\n value: string\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\nconst isEmptyValue = (value: unknown): boolean => value === undefined || value === null || value === ''\n\n/**\n * Whether a row name carries the display-only deepObject array marker (`filters[id][in][]`). The\n * marker is only ever appended after a real path bracket, so it always shows up as `][]`. That lets\n * us tell it apart from a genuinely empty key: an interior empty (`filters[][in]`) or a lone empty\n * group (`filters[]`, value path `['']`) is not a marker and keeps its segment.\n */\nconst hasArrayMarker = (name: string): boolean => name.endsWith('][]')\n\n/** Parse a parameter key like `filter[a][b]` into its path segments `['filter', 'a', 'b']`. */\nconst parseBracketKey = (name: string): string[] => {\n // Strip the trailing array marker first. The trailing brackets on a deepObject array leaf are\n // display-only, not part of the value path — keeping them would add a bogus empty key that drops\n // the value on write-back and corrupts rename tracking.\n const withoutArrayMarker = hasArrayMarker(name) ? name.slice(0, -2) : name\n\n const segments: string[] = []\n const head = withoutArrayMarker.match(/^[^[\\]]*/)?.[0] ?? ''\n if (head) {\n segments.push(head)\n }\n for (const match of withoutArrayMarker.matchAll(/\\[([^\\]]*)\\]/g)) {\n segments.push(match[1] ?? '')\n }\n return segments\n}\n\n/**\n * Derives the value path for an edited expanded row from the key the user typed, so renaming a\n * property actually moves the value to the new key instead of being dropped. deepObject rows are\n * prefixed with the parent parameter name (`filter[a]`), which we strip to get the path inside the\n * value. Falls back to the row's original path when the typed name cannot be parsed.\n */\nconst getEditedValuePath = (typedName: string, parameterName: string | undefined, fallback: string[]): string[] => {\n const segments = parseBracketKey(typedName)\n if (segments.length === 0) {\n return fallback\n }\n if (parameterName && segments[0] === parameterName && segments.length > 1) {\n return segments.slice(1)\n }\n return segments\n}\n\nconst getExpandedObjectPayload = (\n row: TableRow,\n context: TableRow[],\n payload?: ParameterUpsertPayload,\n): { name: string; value: Record<string, unknown>; isDisabled: boolean } => {\n const value: Record<string, unknown> = {}\n\n // Only deepObject leaves use the comma-to-array coercion below. The trailing-bracket array\n // convention (`key[]=1&key[]=2`) is deepObject-specific, and deepObject leaves never carry a\n // meaningful comma. Form-style object parameters can (e.g. Spring `sort=username,asc`), so they\n // keep their leaves verbatim.\n const parameter = row.originalParameter\n const isDeepObjectParameter = Boolean(parameter && 'style' in parameter && parameter.style === 'deepObject')\n\n for (const contextRow of context) {\n if (contextRow.originalParameter !== row.originalParameter || !contextRow.sourceParameterValuePath) {\n continue\n }\n\n if (contextRow === row && !payload) {\n continue\n }\n\n const isEditedRow = contextRow === row && payload !== undefined\n const nextValue = isEditedRow ? payload.value : contextRow.value\n if (isEmptyValue(nextValue)) {\n continue\n }\n\n // Key edits are debounced while the user is still typing. Only committed key edits can move\n // the value to a new object path; regular value updates keep the stable source path.\n const path = isEditedRow\n ? payload.shouldRenameExpandedRow\n ? getEditedValuePath(payload.name, row.originalParameter?.name, contextRow.sourceParameterValuePath)\n : contextRow.sourceParameterValuePath\n : contextRow.sourceParameterValuePath\n\n // Rows always hold the string the user sees, so a deepObject array leaf arrives comma-joined\n // (\"1,2\"). Coerce it back to an array before storing — otherwise deepObject serialization\n // re-collapses it into a single `key[in]=1,2` entry instead of repeating `key[in][]=1&key[in][]=2`.\n //\n // The display-only `][]` marker is the authoritative array signal: a leaf gets it whenever its\n // schema OR its stored value is an array, so it must win over a non-array property schema, which\n // would otherwise skip the coercion and serialize the array comma-joined. A committed rename\n // re-derives the marker from the freshly typed name, since the row's `schema` and `name` still\n // describe the old key — renaming an array leaf to a scalar key must not store a one-element array.\n // Non-array leaves fall back to the property schema so object leaves still coerce; renamed rows\n // have no reliable schema, so they rely on the marker alone.\n const isCommittedRename = isEditedRow && Boolean(payload.shouldRenameExpandedRow)\n const hasArrayLeafMarker = hasArrayMarker(isCommittedRename ? payload.name : contextRow.name)\n const leafSchema = hasArrayLeafMarker\n ? ({ type: 'array' } as const)\n : isCommittedRename\n ? undefined\n : contextRow.schema\n const leafValue = isDeepObjectParameter && leafSchema ? deSerializeSchemaValue(nextValue, leafSchema) : nextValue\n\n setValueAtPath(value, path, leafValue)\n }\n\n return {\n name: row.originalParameter?.name ?? payload?.name ?? row.name,\n value,\n isDisabled: payload?.isDisabled ?? row.isDisabled ?? false,\n }\n}\n\n/** Create parameter event handlers for a given type */\nexport const createParameterHandlers = (\n type: ParameterType,\n eventBus: WorkspaceEventBus,\n meta: OperationExampleMeta,\n {\n context,\n defaultParameters = 0,\n globalParameters = 0,\n onDeleteExpandedRow,\n onRenameExpandedRow,\n }: {\n context: TableRow[]\n defaultParameters?: number\n globalParameters?: number\n onDeleteExpandedRow?: (row: TableRow) => void\n onRenameExpandedRow?: (row: TableRow, newValuePath: string[]) => void\n },\n) => {\n const offset = defaultParameters + globalParameters\n\n return {\n delete: (payload: { index: number }) => {\n const row = context[payload.index]\n if (!row?.originalParameter) {\n return\n }\n\n if (row.sourceParameterValuePath) {\n onDeleteExpandedRow?.(row)\n\n return eventBus.emit(\n 'operation:upsert:parameter',\n {\n type,\n payload: getExpandedObjectPayload(row, context),\n originalParameter: row.originalParameter,\n meta,\n },\n {\n skipUnpackProxy: true,\n },\n )\n }\n\n eventBus.emit(\n 'operation:delete:parameter',\n {\n originalParameter: row.originalParameter,\n meta,\n },\n {\n skipUnpackProxy: true,\n },\n )\n },\n deleteAll: () =>\n eventBus.emit('operation:delete-all:parameters', {\n type,\n meta,\n }),\n upsert: (index: number, payload: ParameterUpsertPayload) => {\n const row = context[index]\n const { shouldRenameExpandedRow, ...parameterPayload } = payload\n\n if (index < defaultParameters + globalParameters) {\n const extraParameterType = index < defaultParameters ? 'default' : 'global'\n\n return eventBus.emit('operation:update:extra-parameters', {\n type: extraParameterType,\n in: type,\n meta: { ...meta, name: row?.name?.toLowerCase?.() ?? 'NON_VALID' },\n payload: { isDisabled: payload.isDisabled ?? false },\n })\n }\n\n if (index >= offset) {\n const isExpandedRow = Boolean(row?.sourceParameterValuePath && row.originalParameter)\n\n // When the key of an expanded row changes, report the new value path so the row keeps its\n // original slot (rendered in place of the old schema property) instead of jumping to the end.\n if (isExpandedRow && row && shouldRenameExpandedRow && payload.name !== row.name) {\n const newValuePath = getEditedValuePath(\n payload.name,\n row.originalParameter?.name,\n row.sourceParameterValuePath ?? [],\n )\n onRenameExpandedRow?.(row, newValuePath)\n }\n\n const nextPayload = isExpandedRow && row ? getExpandedObjectPayload(row, context, payload) : parameterPayload\n\n return eventBus.emit(\n 'operation:upsert:parameter',\n {\n type,\n payload: nextPayload,\n originalParameter: row?.originalParameter ?? null,\n meta,\n },\n {\n skipUnpackProxy: true,\n debounceKey: `update:parameter-${type}-${index - offset}`,\n },\n )\n }\n },\n }\n}\n"],"mappings":";;;AAeA,IAAM,gBAAgB,UAA4B,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU;;;;;;;AAQrG,IAAM,kBAAkB,SAA0B,KAAK,SAAS,KAAK;;AAGrE,IAAM,mBAAmB,SAA2B;CAIlD,MAAM,qBAAqB,eAAe,IAAI,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;CAEtE,MAAM,WAAqB,CAAC;CAC5B,MAAM,OAAO,mBAAmB,MAAM,UAAU,CAAC,GAAG,MAAM;CAC1D,IAAI,MACF,SAAS,KAAK,IAAI;CAEpB,KAAK,MAAM,SAAS,mBAAmB,SAAS,eAAe,GAC7D,SAAS,KAAK,MAAM,MAAM,EAAE;CAE9B,OAAO;AACT;;;;;;;AAQA,IAAM,sBAAsB,WAAmB,eAAmC,aAAiC;CACjH,MAAM,WAAW,gBAAgB,SAAS;CAC1C,IAAI,SAAS,WAAW,GACtB,OAAO;CAET,IAAI,iBAAiB,SAAS,OAAO,iBAAiB,SAAS,SAAS,GACtE,OAAO,SAAS,MAAM,CAAC;CAEzB,OAAO;AACT;AAEA,IAAM,4BACJ,KACA,SACA,YAC0E;CAC1E,MAAM,QAAiC,CAAC;CAMxC,MAAM,YAAY,IAAI;CACtB,MAAM,wBAAwB,QAAQ,aAAa,WAAW,aAAa,UAAU,UAAU,YAAY;CAE3G,KAAK,MAAM,cAAc,SAAS;EAChC,IAAI,WAAW,s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,MAAM,QAAQ;GACpB,MAAM,EAAE,yBAAyB,GAAG,qBAAqB;GAEzD,IAAI,QAAQ,oBAAoB,kBAAkB;IAChD,MAAM,qBAAqB,QAAQ,oBAAoB,YAAY;IAEnE,OAAO,SAAS,KAAK,qCAAqC;KACxD,MAAM;KACN,IAAI;KACJ,MAAM;MAAE,GAAG;MAAM,MAAM,KAAK,MAAM,cAAc,KAAK;KAAY;KACjE,SAAS,EAAE,YAAY,QAAQ,cAAc,MAAM;IACrD,CAAC;GACH;GAEA,IAAI,SAAS,QAAQ;IACnB,MAAM,gBAAgB,QAAQ,KAAK,4BAA4B,IAAI,iBAAiB;IAIpF,IAAI,iBAAiB,OAAO,2BAA2B,QAAQ,SAAS,IAAI,MAAM;KAChF,MAAM,eAAe,mBACnB,QAAQ,MACR,IAAI,mBAAmB,MACvB,IAAI,4BAA4B,CAAC,CACnC;KACA,sBAAsB,KAAK,YAAY;IACzC;IAEA,MAAM,cAAc,iBAAiB,MAAM,yBAAyB,KAAK,SAAS,OAAO,IAAI;IAE7F,OAAO,SAAS,KACd,8BACA;KACE;KACA,SAAS;KACT,mBAAmB,KAAK,qBAAqB;KAC7C;IACF,GACA;KACE,iBAAiB;KACjB,aAAa,oBAAoB,KAAK,GAAG,QAAQ;IACnD,CACF;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"create-parameter-handlers.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-handlers.ts"],"sourcesContent":["import { setValueAtPath } from '@scalar/helpers/object/set-value-at-path'\nimport type { ApiReferenceEvents, OperationExampleMeta, WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { deSerializeSchemaValue } from '@scalar/workspace-store/request-example'\n\nimport type { TableRow } from '@/v2/blocks/request-block/components/RequestTableRow.vue'\n\ntype ParameterType = 'path' | 'cookie' | 'header' | 'query'\n\ntype ParameterUpsertPayload = {\n name: string\n value: string\n isDisabled: boolean\n shouldRenameExpandedRow?: boolean\n}\n\nconst isEmptyValue = (value: unknown): boolean => value === undefined || value === null || value === ''\n\n/**\n * Whether a row name carries the display-only deepObject array marker (`filters[id][in][]`). The\n * marker is only ever appended after a real path bracket, so it always shows up as `][]`. That lets\n * us tell it apart from a genuinely empty key: an interior empty (`filters[][in]`) or a lone empty\n * group (`filters[]`, value path `['']`) is not a marker and keeps its segment.\n */\nconst hasArrayMarker = (name: string): boolean => name.endsWith('][]')\n\n/** Parse a parameter key like `filter[a][b]` into its path segments `['filter', 'a', 'b']`. */\nconst parseBracketKey = (name: string): string[] => {\n // Strip the trailing array marker first. The trailing brackets on a deepObject array leaf are\n // display-only, not part of the value path — keeping them would add a bogus empty key that drops\n // the value on write-back and corrupts rename tracking.\n const withoutArrayMarker = hasArrayMarker(name) ? name.slice(0, -2) : name\n\n const segments: string[] = []\n const head = withoutArrayMarker.match(/^[^[\\]]*/)?.[0] ?? ''\n if (head) {\n segments.push(head)\n }\n for (const match of withoutArrayMarker.matchAll(/\\[([^\\]]*)\\]/g)) {\n segments.push(match[1] ?? '')\n }\n return segments\n}\n\n/**\n * Derives the value path for an edited expanded row from the key the user typed, so renaming a\n * property actually moves the value to the new key instead of being dropped. deepObject rows are\n * prefixed with the parent parameter name (`filter[a]`), which we strip to get the path inside the\n * value. Falls back to the row's original path when the typed name cannot be parsed.\n */\nconst getEditedValuePath = (typedName: string, parameterName: string | undefined, fallback: string[]): string[] => {\n const segments = parseBracketKey(typedName)\n if (segments.length === 0) {\n return fallback\n }\n if (parameterName && segments[0] === parameterName && segments.length > 1) {\n return segments.slice(1)\n }\n return segments\n}\n\nconst getExpandedObjectPayload = (\n row: TableRow,\n context: TableRow[],\n payload?: ParameterUpsertPayload,\n): ApiReferenceEvents['operation:upsert:parameter']['payload'] => {\n const value: Record<string, unknown> = {}\n\n // Only deepObject leaves use the comma-to-array coercion below. The trailing-bracket array\n // convention (`key[]=1&key[]=2`) is deepObject-specific, and deepObject leaves never carry a\n // meaningful comma. Form-style object parameters can (e.g. Spring `sort=username,asc`), so they\n // keep their leaves verbatim.\n const parameter = row.originalParameter\n const isDeepObjectParameter = Boolean(parameter && 'style' in parameter && parameter.style === 'deepObject')\n\n for (const contextRow of context) {\n if (contextRow.originalParameter !== row.originalParameter || !contextRow.sourceParameterValuePath) {\n continue\n }\n\n if (contextRow === row && !payload) {\n continue\n }\n\n const isEditedRow = contextRow === row && payload !== undefined\n const nextValue = isEditedRow ? payload.value : contextRow.value\n if (isEmptyValue(nextValue)) {\n continue\n }\n\n // Key edits are debounced while the user is still typing. Only committed key edits can move\n // the value to a new object path; regular value updates keep the stable source path.\n const path =\n isEditedRow && payload.shouldRenameExpandedRow\n ? getEditedValuePath(payload.name, row.originalParameter?.name, contextRow.sourceParameterValuePath)\n : contextRow.sourceParameterValuePath\n\n // Rows always hold the string the user sees, so a deepObject array leaf arrives comma-joined\n // (\"1,2\"). Coerce it back to an array before storing — otherwise deepObject serialization\n // re-collapses it into a single `key[in]=1,2` entry instead of repeating `key[in][]=1&key[in][]=2`.\n //\n // The display-only `][]` marker is the authoritative array signal: a leaf gets it whenever its\n // schema OR its stored value is an array, so it must win over a non-array property schema, which\n // would otherwise skip the coercion and serialize the array comma-joined. A committed rename\n // re-derives the marker from the freshly typed name, since the row's `schema` and `name` still\n // describe the old key — renaming an array leaf to a scalar key must not store a one-element array.\n // Non-array leaves fall back to the property schema so object leaves still coerce; renamed rows\n // have no reliable schema, so they rely on the marker alone.\n const isCommittedRename = isEditedRow && Boolean(payload.shouldRenameExpandedRow)\n const hasArrayLeafMarker = hasArrayMarker(isCommittedRename ? payload.name : contextRow.name)\n const existingLeafSchema = isCommittedRename ? undefined : contextRow.schema\n const leafSchema = hasArrayLeafMarker ? ({ type: 'array' } as const) : existingLeafSchema\n const leafValue = isDeepObjectParameter && leafSchema ? deSerializeSchemaValue(nextValue, leafSchema) : nextValue\n\n setValueAtPath(value, path, leafValue)\n }\n\n return {\n name: row.originalParameter?.name ?? payload?.name ?? row.name,\n value,\n isDisabled: payload?.isDisabled ?? row.isDisabled ?? false,\n propertyState: {\n path: payload?.shouldRenameExpandedRow\n ? getEditedValuePath(payload.name, row.originalParameter?.name, row.sourceParameterValuePath ?? [])\n : (row.sourceParameterValuePath ?? []),\n ...(payload ? { isDisabled: payload.isDisabled } : {}),\n ...(payload?.shouldRenameExpandedRow ? { previousPath: row.sourceParameterValuePath } : {}),\n },\n }\n}\n\n/** Create parameter event handlers for a given type */\nexport const createParameterHandlers = (\n type: ParameterType,\n eventBus: WorkspaceEventBus,\n meta: OperationExampleMeta,\n {\n context,\n defaultParameters = 0,\n globalParameters = 0,\n onDeleteExpandedRow,\n onRenameExpandedRow,\n }: {\n context: TableRow[]\n defaultParameters?: number\n globalParameters?: number\n onDeleteExpandedRow?: (row: TableRow) => void\n onRenameExpandedRow?: (row: TableRow, newValuePath: string[]) => void\n },\n) => {\n const offset = defaultParameters + globalParameters\n\n return {\n delete: (payload: { index: number }) => {\n const row = context[payload.index]\n if (!row?.originalParameter) {\n return\n }\n\n if (row.sourceParameterValuePath) {\n onDeleteExpandedRow?.(row)\n\n return eventBus.emit(\n 'operation:upsert:parameter',\n {\n type,\n payload: getExpandedObjectPayload(row, context),\n originalParameter: row.originalParameter,\n meta,\n },\n {\n skipUnpackProxy: true,\n },\n )\n }\n\n eventBus.emit(\n 'operation:delete:parameter',\n {\n originalParameter: row.originalParameter,\n meta,\n },\n {\n skipUnpackProxy: true,\n },\n )\n },\n deleteAll: () =>\n eventBus.emit('operation:delete-all:parameters', {\n type,\n meta,\n }),\n upsert: (index: number, payload: ParameterUpsertPayload) => {\n const row = context[index]\n const { shouldRenameExpandedRow, ...parameterPayload } = payload\n\n if (index < defaultParameters + globalParameters) {\n const extraParameterType = index < defaultParameters ? 'default' : 'global'\n\n return eventBus.emit('operation:update:extra-parameters', {\n type: extraParameterType,\n in: type,\n meta: { ...meta, name: row?.name?.toLowerCase?.() ?? 'NON_VALID' },\n payload: { isDisabled: payload.isDisabled ?? false },\n })\n }\n\n if (index >= offset) {\n const isExpandedRow = Boolean(row?.sourceParameterValuePath && row.originalParameter)\n\n // When the key of an expanded row changes, report the new value path so the row keeps its\n // original slot (rendered in place of the old schema property) instead of jumping to the end.\n if (isExpandedRow && row && shouldRenameExpandedRow && payload.name !== row.name) {\n const newValuePath = getEditedValuePath(\n payload.name,\n row.originalParameter?.name,\n row.sourceParameterValuePath ?? [],\n )\n onRenameExpandedRow?.(row, newValuePath)\n }\n\n const nextPayload = isExpandedRow && row ? getExpandedObjectPayload(row, context, payload) : parameterPayload\n\n return eventBus.emit(\n 'operation:upsert:parameter',\n {\n type,\n payload: nextPayload,\n originalParameter: row?.originalParameter ?? null,\n meta,\n },\n {\n skipUnpackProxy: true,\n debounceKey: `update:parameter-${type}-${index - offset}`,\n },\n )\n }\n },\n }\n}\n"],"mappings":";;;AAeA,IAAM,gBAAgB,UAA4B,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU;;;;;;;AAQrG,IAAM,kBAAkB,SAA0B,KAAK,SAAS,KAAK;;AAGrE,IAAM,mBAAmB,SAA2B;CAIlD,MAAM,qBAAqB,eAAe,IAAI,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;CAEtE,MAAM,WAAqB,CAAC;CAC5B,MAAM,OAAO,mBAAmB,MAAM,UAAU,CAAC,GAAG,MAAM;CAC1D,IAAI,MACF,SAAS,KAAK,IAAI;CAEpB,KAAK,MAAM,SAAS,mBAAmB,SAAS,eAAe,GAC7D,SAAS,KAAK,MAAM,MAAM,EAAE;CAE9B,OAAO;AACT;;;;;;;AAQA,IAAM,sBAAsB,WAAmB,eAAmC,aAAiC;CACjH,MAAM,WAAW,gBAAgB,SAAS;CAC1C,IAAI,SAAS,WAAW,GACtB,OAAO;CAET,IAAI,iBAAiB,SAAS,OAAO,iBAAiB,SAAS,SAAS,GACtE,OAAO,SAAS,MAAM,CAAC;CAEzB,OAAO;AACT;AAEA,IAAM,4BACJ,KACA,SACA,YACgE;CAChE,MAAM,QAAiC,CAAC;CAMxC,MAAM,YAAY,IA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@ -1 +1 @@
1
- {"version":3,"file":"create-parameter-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-rows.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAA;AAkWjE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,eAAe,EAC1B,YAAY,MAAM,EAClB,UAAS;IACP,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAA;IACtC,iBAAiB,CAAC,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,EAAE,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CAC3D,KACL,QAAQ,EAsFV,CAAA"}
1
+ {"version":3,"file":"create-parameter-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-rows.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,8DAA8D,CAAA;AAGrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAA;AAkWjE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,eAAe,EAC1B,YAAY,MAAM,EAClB,UAAS;IACP,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAA;IACtC,iBAAiB,CAAC,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,EAAE,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CAC3D,KACL,QAAQ,EAmGV,CAAA"}
@@ -229,7 +229,16 @@ var createParameterRows = (parameter, exampleKey, options = {}) => {
229
229
  isDisabledByDefault,
230
230
  renamedValuePaths
231
231
  });
232
- return [...rows, ...unmappedRows];
232
+ return [...rows, ...unmappedRows].map((row) => {
233
+ const states = example?.["x-scalar-disabled-properties"];
234
+ const path = row.sourceParameterValuePath ?? [];
235
+ const disabled = path.map((_, index) => states?.[JSON.stringify(path.slice(0, index + 1))]).reverse().find((state) => state !== void 0);
236
+ return {
237
+ ...row,
238
+ isDisabled: disabled ?? states?.["[]"] ?? row.isDisabled,
239
+ ...disabled === void 0 ? {} : { isDisabledByDefault: false }
240
+ };
241
+ });
233
242
  };
234
243
  //#endregion
235
244
  export { createParameterRows };
@@ -1 +1 @@
1
- {"version":3,"file":"create-parameter-rows.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-rows.ts"],"sourcesContent":["import { getValueAtPath } from '@scalar/helpers/object/get-value-at-path'\nimport { isObject } from '@scalar/helpers/object/is-object'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport { deSerializeParameter, isParamDisabled } from '@scalar/workspace-store/request-example'\nimport type {\n ParameterObject,\n ParameterWithSchemaObject,\n ReferenceType,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema, isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport type { TableRow } from '../components/RequestTableRow.vue'\nimport { getParameterSchema } from './get-parameter-schema'\n\ntype ParameterWithRequiredSchema = ParameterWithSchemaObject & {\n schema: ReferenceType<SchemaObject>\n}\n\n/** Serialization mode for object-typed query parameters that we expand into multiple rows. */\ntype ExpansionMode = 'form' | 'deepObject'\n\nconst isParameterWithSchema = (parameter: ParameterObject): parameter is ParameterWithRequiredSchema =>\n 'schema' in parameter && parameter.schema !== undefined\n\nconst resolveSchema = (schema: unknown): SchemaObject | undefined => {\n const resolvedSchema = getResolvedRef(schema as SchemaObject | { '$ref': string; '$ref-value': SchemaObject })\n\n return resolvedSchema\n}\n\n/**\n * Resolves the OpenAPI serialization style and explode flag for a parameter, falling back to the\n * spec defaults (style: 'form', explode: true when style is 'form').\n */\nconst getParameterStyleAndExplode = (parameter: ParameterObject): { style: string; explode: boolean } => {\n const style = 'style' in parameter && parameter.style ? parameter.style : 'form'\n const explode = 'explode' in parameter && parameter.explode !== undefined ? parameter.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Decides whether an object-typed query parameter should be expanded into one row per property,\n * and which expansion mode to use. Returns null when the parameter should stay as a single row\n * (non-query, non-object schema, or a serialization style we do not expand).\n */\nconst getExpansionMode = (parameter: ParameterObject, schema: SchemaObject | undefined): ExpansionMode | null => {\n if (parameter.in !== 'query' || !isParameterWithSchema(parameter) || !schema || !isObjectSchema(schema)) {\n return null\n }\n\n const { style, explode } = getParameterStyleAndExplode(parameter)\n if (!explode) {\n return null\n }\n\n if (style === 'form') {\n return 'form'\n }\n if (style === 'deepObject') {\n return 'deepObject'\n }\n\n return null\n}\n\nconst toTableValue = (value: unknown): string => {\n if (value === undefined || value === null) {\n return ''\n }\n\n if (Array.isArray(value)) {\n return value.join(',')\n }\n\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n\n return String(value)\n}\n\nconst toPathKey = (path: readonly string[]): string => path.join('\\u0000')\n\nconst toTableRow = ({\n parameter,\n name,\n value,\n description,\n schema,\n isRequired,\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath,\n}: {\n parameter: ParameterObject\n name: string\n value: unknown\n description: string | undefined\n schema: SchemaObject | undefined\n isRequired: boolean | undefined\n isDisabled: boolean\n isDisabledByDefault?: boolean\n sourceParameterValuePath?: string[]\n}): TableRow => ({\n name,\n value: toTableValue(value),\n description,\n schema,\n isRequired,\n isDisabled,\n ...(isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n originalParameter: parameter,\n sourceParameterValuePath,\n})\n\n/**\n * Builds the row name for an expanded property at a given value path. deepObject rows mirror the\n * wire format (`parent[a][b]`); form-style explode uses the bare top-level key.\n */\nconst getExpandedRowName = (parameter: ParameterObject, path: string[], mode: ExpansionMode): string =>\n mode === 'deepObject' ? `${parameter.name}${path.map((segment) => `[${segment}]`).join('')}` : (path[0] ?? '')\n\n/**\n * Appends the display-only trailing `[]` to deepObject array leaves so the name matches the\n * serialized `parent[ids][]=1&parent[ids][]=2` form. The bracket is display-only — the row's\n * `sourceParameterValuePath` stays bracket-free. It also lets write-back recognize the leaf as an\n * array even on renamed and unmapped rows, which carry no schema.\n */\nconst withArrayBracket = (name: string, mode: ExpansionMode, isArray: boolean): string =>\n mode === 'deepObject' && isArray ? `${name}[]` : name\n\n/** Build the single-row representation used when a parameter is not expanded. */\nconst toSingleParameterRow = (\n parameter: ParameterObject,\n schema: SchemaObject | undefined,\n value: unknown,\n isDisabled: boolean,\n isDisabledByDefault: boolean,\n): TableRow =>\n toTableRow({\n parameter,\n name: parameter.name,\n value,\n description: parameter.description,\n schema,\n isRequired: parameter.required,\n isDisabled,\n isDisabledByDefault,\n })\n\n/**\n * Walks an object schema and produces one row per property.\n *\n * - In `form` mode (the OpenAPI default for query parameters) only the top-level properties are\n * flattened, and each row is named after the property itself (`status`).\n * - In `deepObject` mode we recurse into nested objects and emit bracketed names that mirror the\n * serialization on the wire (`filter[user][id]`).\n *\n * `pathPrefix` tracks the path inside the parent parameter value so the handler can later\n * reassemble all sibling rows back into a single object payload.\n */\nconst getExpandedPropertyRows = ({\n parameter,\n schema,\n value,\n pathPrefix,\n namePrefix,\n mode,\n isDisabled,\n isDisabledByDefault,\n hiddenValuePaths,\n renamedValuePaths,\n renameTargetPaths,\n}: {\n parameter: ParameterObject\n schema: Extract<SchemaObject, { type: 'object' }>\n value: unknown\n pathPrefix: string[]\n namePrefix: string\n mode: ExpansionMode\n isDisabled: boolean\n isDisabledByDefault: boolean\n hiddenValuePaths: ReadonlySet<string>\n renamedValuePaths: ReadonlyMap<string, string[]>\n renameTargetPaths: ReadonlySet<string>\n}): TableRow[] => {\n if (!schema.properties) {\n return []\n }\n\n const requiredProperties = new Set(schema.required ?? [])\n\n return Object.entries(schema.properties).flatMap(([propertyName, propertySchema]) => {\n const resolvedPropertySchema = resolveSchema(propertySchema)\n if (!resolvedPropertySchema) {\n return []\n }\n\n const path = [...pathPrefix, propertyName]\n const name = namePrefix ? `${namePrefix}[${propertyName}]` : propertyName\n\n // When this property was renamed, the value lives at the typed key instead of the schema path.\n // Keep the row in its original slot so it does not jump to the end of the table.\n const renamedTo = renamedValuePaths.get(toPathKey(path))\n const effectivePath = renamedTo ?? path\n\n if (hiddenValuePaths.has(toPathKey(effectivePath))) {\n return []\n }\n\n if (renamedTo) {\n // The value move is debounced, so until it lands the value still sits at the old schema path.\n // Fall back to it so the renamed row shows its value immediately instead of flickering empty.\n const renamedValue = getValueAtPath(value, renamedTo)\n const effectiveValue = renamedValue === undefined ? getValueAtPath(value, path) : renamedValue\n\n return [\n toTableRow({\n parameter,\n // The renamed key carries no schema, so the value's array-ness drives the `[]` marker.\n name: withArrayBracket(getExpandedRowName(parameter, renamedTo, mode), mode, Array.isArray(effectiveValue)),\n value: effectiveValue,\n description: parameter.description,\n // The renamed key no longer maps to the schema property, so it carries no schema.\n schema: undefined,\n isRequired: false,\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath: renamedTo,\n }),\n ]\n }\n\n // Another property was renamed onto this path (for example \"a\" renamed to an existing \"b\").\n // The renamed row already occupies this slot, so skip the schema-derived row to avoid rendering\n // two rows for the same value path.\n if (renameTargetPaths.has(toPathKey(path))) {\n return []\n }\n\n // Only deepObject style recurses into nested objects. The OpenAPI 3.1 spec says form-style\n // explode flattens only the top-level properties.\n const shouldRecurse =\n mode === 'deepObject' && isObjectSchema(resolvedPropertySchema) && Boolean(resolvedPropertySchema.properties)\n\n if (shouldRecurse) {\n return getExpandedPropertyRows({\n parameter,\n schema: resolvedPropertySchema,\n value,\n pathPrefix: path,\n namePrefix: name,\n mode,\n isDisabled,\n isDisabledByDefault,\n hiddenValuePaths,\n renamedValuePaths,\n renameTargetPaths,\n })\n }\n\n const leafValue = getValueAtPath(value, path)\n\n // deepObject array values serialize with the trailing-bracket convention\n // (filter[ids][]=1&filter[ids][]=2), so mirror that in the displayed name. We base this on the\n // resolved value too, since the schema can be a composition (anyOf) that hides the array type.\n const displayName = withArrayBracket(name, mode, isArraySchema(resolvedPropertySchema) || Array.isArray(leafValue))\n\n return [\n toTableRow({\n parameter,\n name: displayName,\n value: leafValue,\n description: resolvedPropertySchema.description ?? parameter.description,\n schema: resolvedPropertySchema,\n isRequired: requiredProperties.has(propertyName),\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath: path,\n }),\n ]\n })\n}\n\n/**\n * Collects the leaf paths of an object value. In `form` mode only the top-level keys are leaves\n * (form-style explode does not flatten nested objects); in `deepObject` mode we recurse into nested\n * objects, mirroring how the rows and serialization are built.\n */\nconst collectValueLeafPaths = (value: unknown, mode: ExpansionMode): string[][] => {\n if (!isObject(value)) {\n return []\n }\n\n const paths: string[][] = []\n\n const walk = (node: Record<string, unknown>, prefix: string[]): void => {\n for (const [key, val] of Object.entries(node)) {\n const path = [...prefix, key]\n\n if (mode === 'deepObject' && isObject(val)) {\n walk(val, path)\n } else {\n paths.push(path)\n }\n }\n }\n\n walk(value, [])\n\n return paths\n}\n\n/**\n * Builds rows for value paths that the schema does not describe. This keeps user-edited keys (for\n * example a property that was renamed in the table) visible instead of snapping back to the\n * schema-derived rows on the next render.\n */\nconst getUnmappedValueRows = ({\n parameter,\n value,\n schemaRows,\n mode,\n isDisabled,\n isDisabledByDefault,\n renamedValuePaths,\n}: {\n parameter: ParameterObject\n value: unknown\n schemaRows: TableRow[]\n mode: ExpansionMode\n isDisabled: boolean\n isDisabledByDefault: boolean\n renamedValuePaths: ReadonlyMap<string, string[]>\n}): TableRow[] => {\n // Skip the renamed-away source paths too: the value move is debounced, so the old key lingers in\n // the value for a moment and would otherwise flash as a duplicate row next to the renamed one.\n const seen = new Set([\n ...schemaRows.map((row) => toPathKey(row.sourceParameterValuePath ?? [])),\n ...renamedValuePaths.keys(),\n ])\n\n // These rows always render: a key that carries a value should stay visible. The hidden-path set\n // only suppresses empty schema suggestions, so it is intentionally not applied here.\n return collectValueLeafPaths(value, mode)\n .filter((path) => !seen.has(toPathKey(path)))\n .map((path) => {\n const leafValue = getValueAtPath(value, path)\n\n return toTableRow({\n parameter,\n // No schema describes these rows, so the value's array-ness drives the `[]` marker.\n name: withArrayBracket(getExpandedRowName(parameter, path, mode), mode, Array.isArray(leafValue)),\n value: leafValue,\n description: parameter.description,\n schema: undefined,\n isRequired: false,\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath: path,\n })\n })\n}\n\n/**\n * Turns a single OpenAPI parameter into one or more table rows.\n *\n * For object-typed query parameters with `form`/`explode: true` (the default) or `deepObject`\n * serialization, each property becomes its own row so the user can edit them individually,\n * matching how tools like Postman present the same parameter. Every other parameter passes\n * through as a single row.\n */\nexport const createParameterRows = (\n parameter: ParameterObject,\n exampleKey: string,\n options: {\n hiddenValuePaths?: readonly string[][]\n renamedValuePaths?: readonly { from: string[]; to: string[] }[]\n } = {},\n): TableRow[] => {\n const selected = getParameterExample(parameter, exampleKey)\n const { example } = selected\n const displayValue = selected.value === null && example?.dataValue === null ? 'null' : selected.value\n const isDisabled = isParamDisabled(parameter, example)\n // Preserve type-to-enable behavior until the user explicitly chooses a checkbox state.\n const isDisabledByDefault = !parameter.required && parameter.in !== 'path' && example?.['x-disabled'] === undefined\n const schema = getParameterSchema(parameter)\n if (parameter.in === 'querystring') {\n const querystring = getQuerystringParameter(parameter, exampleKey, { includeDisabled: true })\n return [\n toSingleParameterRow(\n parameter,\n // The editor accepts URI-ready text; decoded schema suggestions are not valid wire values.\n undefined,\n querystring ? serializeQuerystringParameter(querystring) : '',\n isDisabled,\n isDisabledByDefault,\n ),\n ]\n }\n const mode = selected.serialized ? null : getExpansionMode(parameter, schema)\n\n // Non-expandable parameters: render as a single row.\n if (mode === null || !schema || !isObjectSchema(schema)) {\n return [\n toSingleParameterRow(\n parameter,\n selected.serialized ? undefined : schema,\n displayValue,\n isDisabled,\n isDisabledByDefault,\n ),\n ]\n }\n\n // Expand into per-property rows. The deserialized value is used so existing per-property values\n // can be displayed in the table even when the example arrives as a serialized string.\n const value = selected.value === undefined ? undefined : deSerializeParameter(selected.value, parameter)\n\n // Fall back to a single row only when the schema has no properties to expand.\n if (!schema.properties) {\n return [\n toSingleParameterRow(\n parameter,\n selected.serialized ? undefined : schema,\n displayValue,\n isDisabled,\n isDisabledByDefault,\n ),\n ]\n }\n\n const hiddenValuePaths = new Set(options.hiddenValuePaths?.map(toPathKey) ?? [])\n const renamedValuePaths = new Map((options.renamedValuePaths ?? []).map(({ from, to }) => [toPathKey(from), to]))\n // Paths a property was renamed onto, used to suppress the colliding schema-derived row.\n const renameTargetPaths = new Set((options.renamedValuePaths ?? []).map(({ to }) => toPathKey(to)))\n\n const rows = getExpandedPropertyRows({\n parameter,\n schema,\n value,\n pathPrefix: [],\n // deepObject names every row with a `parent[child]` prefix; form-style names use bare property names.\n namePrefix: mode === 'deepObject' ? parameter.name : '',\n mode,\n isDisabled,\n isDisabledByDefault,\n hiddenValuePaths,\n renamedValuePaths,\n renameTargetPaths,\n })\n\n // Surface keys present in the value but not in the schema (for example a renamed property) so the\n // edited key keeps showing up instead of snapping back to the schema-derived rows.\n const unmappedRows = getUnmappedValueRows({\n parameter,\n value,\n schemaRows: rows,\n mode,\n isDisabled,\n isDisabledByDefault,\n renamedValuePaths,\n })\n\n return [...rows, ...unmappedRows]\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAM,yBAAyB,cAC7B,YAAY,aAAa,UAAU,WAAW,KAAA;AAEhD,IAAM,iBAAiB,WAA8C;CAGnE,OAFuB,eAAe,MAE/B;AACT;;;;;AAMA,IAAM,+BAA+B,cAAoE;CACvG,MAAM,QAAQ,WAAW,aAAa,UAAU,QAAQ,UAAU,QAAQ;CAG1E,OAAO;EAAE;EAAO,SAFA,aAAa,aAAa,UAAU,YAAY,KAAA,IAAY,UA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AU,OAAO;EACrD;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAID,MAAM,eAAe,qBAAqB;EACxC;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO,CAAC,GAAG,MAAM,GAAG,YAAY;AAClC"}
1
+ {"version":3,"file":"create-parameter-rows.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/create-parameter-rows.ts"],"sourcesContent":["import { getValueAtPath } from '@scalar/helpers/object/get-value-at-path'\nimport { isObject } from '@scalar/helpers/object/is-object'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport { deSerializeParameter, isParamDisabled } from '@scalar/workspace-store/request-example'\nimport type {\n ParameterObject,\n ParameterWithSchemaObject,\n ReferenceType,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { isArraySchema, isObjectSchema } from '@scalar/workspace-store/schemas/v3.2/strict/type-guards'\n\nimport type { TableRow } from '../components/RequestTableRow.vue'\nimport { getParameterSchema } from './get-parameter-schema'\n\ntype ParameterWithRequiredSchema = ParameterWithSchemaObject & {\n schema: ReferenceType<SchemaObject>\n}\n\n/** Serialization mode for object-typed query parameters that we expand into multiple rows. */\ntype ExpansionMode = 'form' | 'deepObject'\n\nconst isParameterWithSchema = (parameter: ParameterObject): parameter is ParameterWithRequiredSchema =>\n 'schema' in parameter && parameter.schema !== undefined\n\nconst resolveSchema = (schema: unknown): SchemaObject | undefined => {\n const resolvedSchema = getResolvedRef(schema as SchemaObject | { '$ref': string; '$ref-value': SchemaObject })\n\n return resolvedSchema\n}\n\n/**\n * Resolves the OpenAPI serialization style and explode flag for a parameter, falling back to the\n * spec defaults (style: 'form', explode: true when style is 'form').\n */\nconst getParameterStyleAndExplode = (parameter: ParameterObject): { style: string; explode: boolean } => {\n const style = 'style' in parameter && parameter.style ? parameter.style : 'form'\n const explode = 'explode' in parameter && parameter.explode !== undefined ? parameter.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Decides whether an object-typed query parameter should be expanded into one row per property,\n * and which expansion mode to use. Returns null when the parameter should stay as a single row\n * (non-query, non-object schema, or a serialization style we do not expand).\n */\nconst getExpansionMode = (parameter: ParameterObject, schema: SchemaObject | undefined): ExpansionMode | null => {\n if (parameter.in !== 'query' || !isParameterWithSchema(parameter) || !schema || !isObjectSchema(schema)) {\n return null\n }\n\n const { style, explode } = getParameterStyleAndExplode(parameter)\n if (!explode) {\n return null\n }\n\n if (style === 'form') {\n return 'form'\n }\n if (style === 'deepObject') {\n return 'deepObject'\n }\n\n return null\n}\n\nconst toTableValue = (value: unknown): string => {\n if (value === undefined || value === null) {\n return ''\n }\n\n if (Array.isArray(value)) {\n return value.join(',')\n }\n\n if (typeof value === 'object') {\n return JSON.stringify(value)\n }\n\n return String(value)\n}\n\nconst toPathKey = (path: readonly string[]): string => path.join('\\u0000')\n\nconst toTableRow = ({\n parameter,\n name,\n value,\n description,\n schema,\n isRequired,\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath,\n}: {\n parameter: ParameterObject\n name: string\n value: unknown\n description: string | undefined\n schema: SchemaObject | undefined\n isRequired: boolean | undefined\n isDisabled: boolean\n isDisabledByDefault?: boolean\n sourceParameterValuePath?: string[]\n}): TableRow => ({\n name,\n value: toTableValue(value),\n description,\n schema,\n isRequired,\n isDisabled,\n ...(isDisabledByDefault ? { isDisabledByDefault: true } : {}),\n originalParameter: parameter,\n sourceParameterValuePath,\n})\n\n/**\n * Builds the row name for an expanded property at a given value path. deepObject rows mirror the\n * wire format (`parent[a][b]`); form-style explode uses the bare top-level key.\n */\nconst getExpandedRowName = (parameter: ParameterObject, path: string[], mode: ExpansionMode): string =>\n mode === 'deepObject' ? `${parameter.name}${path.map((segment) => `[${segment}]`).join('')}` : (path[0] ?? '')\n\n/**\n * Appends the display-only trailing `[]` to deepObject array leaves so the name matches the\n * serialized `parent[ids][]=1&parent[ids][]=2` form. The bracket is display-only — the row's\n * `sourceParameterValuePath` stays bracket-free. It also lets write-back recognize the leaf as an\n * array even on renamed and unmapped rows, which carry no schema.\n */\nconst withArrayBracket = (name: string, mode: ExpansionMode, isArray: boolean): string =>\n mode === 'deepObject' && isArray ? `${name}[]` : name\n\n/** Build the single-row representation used when a parameter is not expanded. */\nconst toSingleParameterRow = (\n parameter: ParameterObject,\n schema: SchemaObject | undefined,\n value: unknown,\n isDisabled: boolean,\n isDisabledByDefault: boolean,\n): TableRow =>\n toTableRow({\n parameter,\n name: parameter.name,\n value,\n description: parameter.description,\n schema,\n isRequired: parameter.required,\n isDisabled,\n isDisabledByDefault,\n })\n\n/**\n * Walks an object schema and produces one row per property.\n *\n * - In `form` mode (the OpenAPI default for query parameters) only the top-level properties are\n * flattened, and each row is named after the property itself (`status`).\n * - In `deepObject` mode we recurse into nested objects and emit bracketed names that mirror the\n * serialization on the wire (`filter[user][id]`).\n *\n * `pathPrefix` tracks the path inside the parent parameter value so the handler can later\n * reassemble all sibling rows back into a single object payload.\n */\nconst getExpandedPropertyRows = ({\n parameter,\n schema,\n value,\n pathPrefix,\n namePrefix,\n mode,\n isDisabled,\n isDisabledByDefault,\n hiddenValuePaths,\n renamedValuePaths,\n renameTargetPaths,\n}: {\n parameter: ParameterObject\n schema: Extract<SchemaObject, { type: 'object' }>\n value: unknown\n pathPrefix: string[]\n namePrefix: string\n mode: ExpansionMode\n isDisabled: boolean\n isDisabledByDefault: boolean\n hiddenValuePaths: ReadonlySet<string>\n renamedValuePaths: ReadonlyMap<string, string[]>\n renameTargetPaths: ReadonlySet<string>\n}): TableRow[] => {\n if (!schema.properties) {\n return []\n }\n\n const requiredProperties = new Set(schema.required ?? [])\n\n return Object.entries(schema.properties).flatMap(([propertyName, propertySchema]) => {\n const resolvedPropertySchema = resolveSchema(propertySchema)\n if (!resolvedPropertySchema) {\n return []\n }\n\n const path = [...pathPrefix, propertyName]\n const name = namePrefix ? `${namePrefix}[${propertyName}]` : propertyName\n\n // When this property was renamed, the value lives at the typed key instead of the schema path.\n // Keep the row in its original slot so it does not jump to the end of the table.\n const renamedTo = renamedValuePaths.get(toPathKey(path))\n const effectivePath = renamedTo ?? path\n\n if (hiddenValuePaths.has(toPathKey(effectivePath))) {\n return []\n }\n\n if (renamedTo) {\n // The value move is debounced, so until it lands the value still sits at the old schema path.\n // Fall back to it so the renamed row shows its value immediately instead of flickering empty.\n const renamedValue = getValueAtPath(value, renamedTo)\n const effectiveValue = renamedValue === undefined ? getValueAtPath(value, path) : renamedValue\n\n return [\n toTableRow({\n parameter,\n // The renamed key carries no schema, so the value's array-ness drives the `[]` marker.\n name: withArrayBracket(getExpandedRowName(parameter, renamedTo, mode), mode, Array.isArray(effectiveValue)),\n value: effectiveValue,\n description: parameter.description,\n // The renamed key no longer maps to the schema property, so it carries no schema.\n schema: undefined,\n isRequired: false,\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath: renamedTo,\n }),\n ]\n }\n\n // Another property was renamed onto this path (for example \"a\" renamed to an existing \"b\").\n // The renamed row already occupies this slot, so skip the schema-derived row to avoid rendering\n // two rows for the same value path.\n if (renameTargetPaths.has(toPathKey(path))) {\n return []\n }\n\n // Only deepObject style recurses into nested objects. The OpenAPI 3.1 spec says form-style\n // explode flattens only the top-level properties.\n const shouldRecurse =\n mode === 'deepObject' && isObjectSchema(resolvedPropertySchema) && Boolean(resolvedPropertySchema.properties)\n\n if (shouldRecurse) {\n return getExpandedPropertyRows({\n parameter,\n schema: resolvedPropertySchema,\n value,\n pathPrefix: path,\n namePrefix: name,\n mode,\n isDisabled,\n isDisabledByDefault,\n hiddenValuePaths,\n renamedValuePaths,\n renameTargetPaths,\n })\n }\n\n const leafValue = getValueAtPath(value, path)\n\n // deepObject array values serialize with the trailing-bracket convention\n // (filter[ids][]=1&filter[ids][]=2), so mirror that in the displayed name. We base this on the\n // resolved value too, since the schema can be a composition (anyOf) that hides the array type.\n const displayName = withArrayBracket(name, mode, isArraySchema(resolvedPropertySchema) || Array.isArray(leafValue))\n\n return [\n toTableRow({\n parameter,\n name: displayName,\n value: leafValue,\n description: resolvedPropertySchema.description ?? parameter.description,\n schema: resolvedPropertySchema,\n isRequired: requiredProperties.has(propertyName),\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath: path,\n }),\n ]\n })\n}\n\n/**\n * Collects the leaf paths of an object value. In `form` mode only the top-level keys are leaves\n * (form-style explode does not flatten nested objects); in `deepObject` mode we recurse into nested\n * objects, mirroring how the rows and serialization are built.\n */\nconst collectValueLeafPaths = (value: unknown, mode: ExpansionMode): string[][] => {\n if (!isObject(value)) {\n return []\n }\n\n const paths: string[][] = []\n\n const walk = (node: Record<string, unknown>, prefix: string[]): void => {\n for (const [key, val] of Object.entries(node)) {\n const path = [...prefix, key]\n\n if (mode === 'deepObject' && isObject(val)) {\n walk(val, path)\n } else {\n paths.push(path)\n }\n }\n }\n\n walk(value, [])\n\n return paths\n}\n\n/**\n * Builds rows for value paths that the schema does not describe. This keeps user-edited keys (for\n * example a property that was renamed in the table) visible instead of snapping back to the\n * schema-derived rows on the next render.\n */\nconst getUnmappedValueRows = ({\n parameter,\n value,\n schemaRows,\n mode,\n isDisabled,\n isDisabledByDefault,\n renamedValuePaths,\n}: {\n parameter: ParameterObject\n value: unknown\n schemaRows: TableRow[]\n mode: ExpansionMode\n isDisabled: boolean\n isDisabledByDefault: boolean\n renamedValuePaths: ReadonlyMap<string, string[]>\n}): TableRow[] => {\n // Skip the renamed-away source paths too: the value move is debounced, so the old key lingers in\n // the value for a moment and would otherwise flash as a duplicate row next to the renamed one.\n const seen = new Set([\n ...schemaRows.map((row) => toPathKey(row.sourceParameterValuePath ?? [])),\n ...renamedValuePaths.keys(),\n ])\n\n // These rows always render: a key that carries a value should stay visible. The hidden-path set\n // only suppresses empty schema suggestions, so it is intentionally not applied here.\n return collectValueLeafPaths(value, mode)\n .filter((path) => !seen.has(toPathKey(path)))\n .map((path) => {\n const leafValue = getValueAtPath(value, path)\n\n return toTableRow({\n parameter,\n // No schema describes these rows, so the value's array-ness drives the `[]` marker.\n name: withArrayBracket(getExpandedRowName(parameter, path, mode), mode, Array.isArray(leafValue)),\n value: leafValue,\n description: parameter.description,\n schema: undefined,\n isRequired: false,\n isDisabled,\n isDisabledByDefault,\n sourceParameterValuePath: path,\n })\n })\n}\n\n/**\n * Turns a single OpenAPI parameter into one or more table rows.\n *\n * For object-typed query parameters with `form`/`explode: true` (the default) or `deepObject`\n * serialization, each property becomes its own row so the user can edit them individually,\n * matching how tools like Postman present the same parameter. Every other parameter passes\n * through as a single row.\n */\nexport const createParameterRows = (\n parameter: ParameterObject,\n exampleKey: string,\n options: {\n hiddenValuePaths?: readonly string[][]\n renamedValuePaths?: readonly { from: string[]; to: string[] }[]\n } = {},\n): TableRow[] => {\n const selected = getParameterExample(parameter, exampleKey)\n const { example } = selected\n const displayValue = selected.value === null && example?.dataValue === null ? 'null' : selected.value\n const isDisabled = isParamDisabled(parameter, example)\n // Preserve type-to-enable behavior until the user explicitly chooses a checkbox state.\n const isDisabledByDefault = !parameter.required && parameter.in !== 'path' && example?.['x-disabled'] === undefined\n const schema = getParameterSchema(parameter)\n if (parameter.in === 'querystring') {\n const querystring = getQuerystringParameter(parameter, exampleKey, { includeDisabled: true })\n return [\n toSingleParameterRow(\n parameter,\n // The editor accepts URI-ready text; decoded schema suggestions are not valid wire values.\n undefined,\n querystring ? serializeQuerystringParameter(querystring) : '',\n isDisabled,\n isDisabledByDefault,\n ),\n ]\n }\n const mode = selected.serialized ? null : getExpansionMode(parameter, schema)\n\n // Non-expandable parameters: render as a single row.\n if (mode === null || !schema || !isObjectSchema(schema)) {\n return [\n toSingleParameterRow(\n parameter,\n selected.serialized ? undefined : schema,\n displayValue,\n isDisabled,\n isDisabledByDefault,\n ),\n ]\n }\n\n // Expand into per-property rows. The deserialized value is used so existing per-property values\n // can be displayed in the table even when the example arrives as a serialized string.\n const value = selected.value === undefined ? undefined : deSerializeParameter(selected.value, parameter)\n\n // Fall back to a single row only when the schema has no properties to expand.\n if (!schema.properties) {\n return [\n toSingleParameterRow(\n parameter,\n selected.serialized ? undefined : schema,\n displayValue,\n isDisabled,\n isDisabledByDefault,\n ),\n ]\n }\n\n const hiddenValuePaths = new Set(options.hiddenValuePaths?.map(toPathKey) ?? [])\n const renamedValuePaths = new Map((options.renamedValuePaths ?? []).map(({ from, to }) => [toPathKey(from), to]))\n // Paths a property was renamed onto, used to suppress the colliding schema-derived row.\n const renameTargetPaths = new Set((options.renamedValuePaths ?? []).map(({ to }) => toPathKey(to)))\n\n const rows = getExpandedPropertyRows({\n parameter,\n schema,\n value,\n pathPrefix: [],\n // deepObject names every row with a `parent[child]` prefix; form-style names use bare property names.\n namePrefix: mode === 'deepObject' ? parameter.name : '',\n mode,\n isDisabled,\n isDisabledByDefault,\n hiddenValuePaths,\n renamedValuePaths,\n renameTargetPaths,\n })\n\n // Surface keys present in the value but not in the schema (for example a renamed property) so the\n // edited key keeps showing up instead of snapping back to the schema-derived rows.\n const unmappedRows = getUnmappedValueRows({\n parameter,\n value,\n schemaRows: rows,\n mode,\n isDisabled,\n isDisabledByDefault,\n renamedValuePaths,\n })\n\n return [...rows, ...unmappedRows].map((row) => {\n const states = example?.['x-scalar-disabled-properties']\n const path = row.sourceParameterValuePath ?? []\n // A saved object-level override also applies if the schema later expands its children.\n const disabled = path\n .map((_, index) => states?.[JSON.stringify(path.slice(0, index + 1))])\n .reverse()\n .find((state) => state !== undefined)\n return {\n ...row,\n isDisabled: disabled ?? states?.['[]'] ?? row.isDisabled,\n ...(disabled === undefined ? {} : { isDisabledByDefault: false }),\n }\n })\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAM,yBAAyB,cAC7B,YAAY,aAAa,UAAU,WAAW,KAAA;AAEhD,IAAM,iBAAiB,WAA8C;CAGnE,OAFuB,eAAe,MAE/B;AACT;;;;;AAMA,IAA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CAAC,EAAA,CAAG,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC,CAAC;CAElG,MAAM,OAAO,wBAAwB;EACnC;EACA;EACA;EACA,YAAY,CAAC;EAEb,YAAY,SAAS,eAAe,UAAU,OAAO;EACrD;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAID,MAAM,eAAe,qBAAqB;EACxC;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;CACF,CAAC;CAED,OAAO,CAAC,GAAG,MAAM,GAAG,YAAY,CAAC,CAAC,KAAK,QAAQ;EAC7C,MAAM,SAAS,UAAU;EACzB,MAAM,OAAO,IAAI,4BAA4B,CAAC;EAE9C,MAAM,WAAW,KACd,KAAK,GAAG,UAAU,SAAS,KAAK,UAAU,KAAK,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CACrE,QAAQ,CAAC,CACT,MAAM,UAAU,UAAU,KAAA,CAAS;EACtC,OAAO;GACL,GAAG;GACH,YAAY,YAAY,SAAS,SAAS,IAAI;GAC9C,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,qBAAqB,MAAM;EACjE;CACF,CAAC;AACH"}
@@ -5,6 +5,7 @@ export type LeafRow = {
5
5
  path: string[];
6
6
  schema: SchemaObject | undefined;
7
7
  isRequired: boolean;
8
+ description?: string;
8
9
  };
9
10
  /**
10
11
  * Walk a (possibly nested) object schema and collect one entry per leaf property.
@@ -14,7 +15,7 @@ export type LeafRow = {
14
15
  * placeholders all stop the recursion. Object properties recurse, so the widget example
15
16
  * (`file` + `props.{name,description,created_at}`) yields four leaves.
16
17
  */
17
- export declare const collectLeafProperties: (schema: SchemaObject, parentPath?: string[], parentRequired?: boolean) => LeafRow[];
18
+ export declare const collectLeafProperties: (schema: SchemaObject, parentPath?: string[], parentRequired?: boolean, parentDescription?: string) => LeafRow[];
18
19
  /**
19
20
  * Walk a schema + example together and collect one row per leaf, including example-only
20
21
  * keys that the schema does not declare. Schema-declared properties come first in schema
@@ -31,5 +32,5 @@ export declare const collectExampleRows: (example: unknown, schema: SchemaObject
31
32
  /** Restore array values after text editing without parsing ordinary string fields. */
32
33
  export declare const getFormBodyValue: (row: TableRow) => string | File | unknown[] | undefined;
33
34
  /** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
34
- export declare const getFormBodyRows: (example: ExampleObject | undefined | null, contentType: string, formBodySchema?: SchemaObject) => TableRow[];
35
+ export declare const getFormBodyRows: (example: ExampleObject | undefined | null, contentType: string, formBodySchema?: SchemaObject, compositionSelection?: Record<string, number>) => TableRow[];
35
36
  //# sourceMappingURL=get-form-body-rows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-form-body-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAG/G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAQ5C,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,YAAY,EACpB,aAAY,MAAM,EAAO,EACzB,wBAAqB,KACpB,OAAO,EA6BT,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,QAAQ,YAAY,GAAG,SAAS,EAChC,aAAY,MAAM,EAAO,KACxB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAqCpC,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAG5E,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,aAAa,MAAM,EACnB,iBAAiB,YAAY,KAC5B,QAAQ,EAyIV,CAAA"}
1
+ {"version":3,"file":"get-form-body-rows.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/get-form-body-rows.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAG/G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0DAA0D,CAAA;AAExF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAQ5C,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IAChC,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,YAAY,EACpB,aAAY,MAAM,EAAO,EACzB,wBAAqB,EACrB,oBAAoB,MAAM,KACzB,OAAO,EA6BT,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,EAChB,QAAQ,YAAY,GAAG,SAAS,EAChC,aAAY,MAAM,EAAO,KACxB;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAqCpC,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,GAAG,SAG5E,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAC1B,SAAS,aAAa,GAAG,SAAS,GAAG,IAAI,EACzC,aAAa,MAAM,EACnB,iBAAiB,YAAY,EAC7B,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5C,QAAQ,EA0IV,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import { objectEntries } from "@scalar/helpers/object/object-entries";
2
2
  import { coerceLeafValueToSchemaType } from "@scalar/workspace-store/request-example";
3
3
  import { isObject } from "@scalar/helpers/object/is-object";
4
- import { resolve } from "@scalar/workspace-store/resolve";
5
4
  import { isObjectSchema } from "@scalar/workspace-store/schemas/v3.2/strict/type-guards";
5
+ import { resolveFormSchema } from "@scalar/workspace-store/helpers/resolve-form-schema";
6
+ import { resolveSchemaWithAnnotations } from "@scalar/workspace-store/helpers/resolve-schema-with-annotations";
6
7
  //#region src/v2/blocks/request-block/helpers/get-form-body-rows.ts
7
8
  var stringifyValue = (value) => {
8
9
  if (value instanceof File) return value.name;
@@ -17,19 +18,20 @@ var stringifyValue = (value) => {
17
18
  * placeholders all stop the recursion. Object properties recurse, so the widget example
18
19
  * (`file` + `props.{name,description,created_at}`) yields four leaves.
19
20
  */
20
- var collectLeafProperties = (schema, parentPath = [], parentRequired = true) => {
21
+ var collectLeafProperties = (schema, parentPath = [], parentRequired = true, parentDescription) => {
21
22
  if (!isObjectSchema(schema) || !schema.properties) return [];
22
23
  const requiredSet = new Set(schema.required ?? []);
23
24
  const leaves = [];
24
25
  for (const [key, rawChildSchema] of objectEntries(schema.properties)) {
25
- const childSchema = resolve.schema(rawChildSchema);
26
+ const childSchema = resolveSchemaWithAnnotations(rawChildSchema);
26
27
  const path = [...parentPath, String(key)];
27
28
  const isRequired = parentRequired && requiredSet.has(String(key));
28
- if (childSchema && isObjectSchema(childSchema) && childSchema.properties) leaves.push(...collectLeafProperties(childSchema, path, isRequired));
29
+ if (childSchema && isObjectSchema(childSchema) && childSchema.properties) leaves.push(...collectLeafProperties(childSchema, path, isRequired, childSchema.description ?? parentDescription));
29
30
  else leaves.push({
30
31
  path,
31
32
  schema: childSchema,
32
- isRequired
33
+ isRequired,
34
+ description: childSchema?.description ?? parentDescription
33
35
  });
34
36
  }
35
37
  return leaves;
@@ -52,7 +54,7 @@ var collectExampleRows = (example, schema, parentPath = []) => {
52
54
  for (const [key, rawChildSchema] of objectEntries(schemaProperties)) {
53
55
  const keyStr = String(key);
54
56
  declaredKeys.add(keyStr);
55
- const childSchema = resolve.schema(rawChildSchema);
57
+ const childSchema = resolveSchemaWithAnnotations(rawChildSchema);
56
58
  const path = [...parentPath, keyStr];
57
59
  const exampleSubvalue = exampleByKey.get(keyStr);
58
60
  if (childSchema && isObjectSchema(childSchema) && childSchema.properties) rows.push(...collectExampleRows(exampleSubvalue, childSchema, path));
@@ -77,10 +79,11 @@ var getFormBodyValue = (row) => {
77
79
  return Array.isArray(value) ? value : row.value ?? void 0;
78
80
  };
79
81
  /** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
80
- var getFormBodyRows = (example, contentType, formBodySchema) => {
82
+ var getFormBodyRows = (example, contentType, formBodySchema, compositionSelection) => {
81
83
  const value = example?.dataValue !== void 0 ? example.dataValue : example?.value;
82
84
  if (!value || contentType !== "multipart/form-data" && contentType !== "application/x-www-form-urlencoded") return [];
83
- const schemaWithProperties = formBodySchema && isObjectSchema(formBodySchema) ? formBodySchema : void 0;
85
+ const resolvedBodySchema = resolveFormSchema(formBodySchema, compositionSelection);
86
+ const schemaWithProperties = resolvedBodySchema && isObjectSchema(resolvedBodySchema) ? resolvedBodySchema : void 0;
84
87
  const isComposed = Boolean(schemaWithProperties?.allOf || schemaWithProperties?.oneOf || schemaWithProperties?.anyOf);
85
88
  const requiredSet = schemaWithProperties ? new Set(schemaWithProperties.required ?? []) : void 0;
86
89
  const leafByDottedName = /* @__PURE__ */ new Map();
@@ -93,9 +96,9 @@ var getFormBodyRows = (example, contentType, formBodySchema) => {
93
96
  };
94
97
  if (!schemaWithProperties || !name) return row;
95
98
  const leaf = leafByDottedName.get(name);
96
- const propSchema = leaf?.schema ?? resolve.schema(schemaWithProperties.properties?.[name]);
99
+ const propSchema = leaf?.schema ?? resolveSchemaWithAnnotations(schemaWithProperties.properties?.[name]);
97
100
  row.schema = propSchema;
98
- row.description = propSchema?.description;
101
+ row.description = leaf?.description ?? propSchema?.description;
99
102
  row.isRequired = leaf?.isRequired ?? requiredSet?.has(name) ?? false;
100
103
  if (isDisabled === void 0 && !isComposed && schemaWithProperties.properties && Object.hasOwn(schemaWithProperties.properties, name)) {
101
104
  row.isDisabled = !row.isRequired;
@@ -111,7 +114,7 @@ var getFormBodyRows = (example, contentType, formBodySchema) => {
111
114
  }));
112
115
  const row = mapRow({
113
116
  name,
114
- value: value instanceof File ? value : value == null ? "" : stringifyValue(value),
117
+ value: value instanceof File || value == null ? value ?? "" : stringifyValue(value),
115
118
  isDisabled
116
119
  });
117
120
  if (contentType === "multipart/form-data" && (Array.isArray(value) || isArray)) row.isArray = true;