@scalar/workspace-store 0.42.0 → 0.43.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 (136) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/events/definitions/operation.d.ts +6 -1
  3. package/dist/events/definitions/operation.d.ts.map +1 -1
  4. package/dist/events/definitions/server.d.ts +5 -1
  5. package/dist/events/definitions/server.d.ts.map +1 -1
  6. package/dist/events/definitions/ui.d.ts +5 -3
  7. package/dist/events/definitions/ui.d.ts.map +1 -1
  8. package/dist/helpers/get-resolved-ref-deep.d.ts +27 -0
  9. package/dist/helpers/get-resolved-ref-deep.d.ts.map +1 -0
  10. package/dist/helpers/get-resolved-ref-deep.js +49 -0
  11. package/dist/mutators/operation/operation.d.ts +1 -1
  12. package/dist/mutators/operation/operation.d.ts.map +1 -1
  13. package/dist/mutators/operation/operation.js +4 -4
  14. package/dist/mutators/server.d.ts +1 -1
  15. package/dist/mutators/server.d.ts.map +1 -1
  16. package/dist/mutators/server.js +5 -2
  17. package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
  18. package/dist/navigation/helpers/traverse-description.js +19 -21
  19. package/dist/navigation/helpers/utils.js +2 -2
  20. package/dist/request-example/builder/body/build-request-body.d.ts +42 -0
  21. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -0
  22. package/dist/request-example/builder/body/build-request-body.js +134 -0
  23. package/dist/request-example/builder/body/get-request-body-example.d.ts +6 -0
  24. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -0
  25. package/dist/request-example/builder/body/get-request-body-example.js +31 -0
  26. package/dist/request-example/builder/body/get-selected-body-content-type.d.ts +10 -0
  27. package/dist/request-example/builder/body/get-selected-body-content-type.d.ts.map +1 -0
  28. package/dist/request-example/builder/body/get-selected-body-content-type.js +10 -0
  29. package/dist/request-example/builder/build-request.d.ts +9 -0
  30. package/dist/request-example/builder/build-request.d.ts.map +1 -0
  31. package/dist/request-example/builder/build-request.js +135 -0
  32. package/dist/request-example/builder/header/build-request-cookie-header.d.ts +25 -0
  33. package/dist/request-example/builder/header/build-request-cookie-header.d.ts.map +1 -0
  34. package/dist/request-example/builder/header/build-request-cookie-header.js +39 -0
  35. package/dist/request-example/builder/header/build-request-parameters.d.ts +24 -0
  36. package/dist/request-example/builder/header/build-request-parameters.d.ts.map +1 -0
  37. package/dist/request-example/builder/header/build-request-parameters.js +215 -0
  38. package/dist/request-example/builder/header/de-serialize-parameter.d.ts +4 -0
  39. package/dist/request-example/builder/header/de-serialize-parameter.d.ts.map +1 -0
  40. package/dist/request-example/builder/header/de-serialize-parameter.js +49 -0
  41. package/dist/request-example/builder/header/filter-global-cookies.d.ts +14 -0
  42. package/dist/request-example/builder/header/filter-global-cookies.d.ts.map +1 -0
  43. package/dist/request-example/builder/header/filter-global-cookies.js +26 -0
  44. package/dist/request-example/builder/header/is-param-disabled.d.ts +13 -0
  45. package/dist/request-example/builder/header/is-param-disabled.d.ts.map +1 -0
  46. package/dist/request-example/builder/header/is-param-disabled.js +19 -0
  47. package/dist/request-example/builder/header/matches-domain.d.ts +9 -0
  48. package/dist/request-example/builder/header/matches-domain.d.ts.map +1 -0
  49. package/dist/request-example/builder/header/matches-domain.js +27 -0
  50. package/dist/request-example/builder/header/serialize-parameter.d.ts +96 -0
  51. package/dist/request-example/builder/header/serialize-parameter.d.ts.map +1 -0
  52. package/dist/request-example/builder/header/serialize-parameter.js +222 -0
  53. package/dist/request-example/builder/helpers/apply-allow-reserved-to-url.d.ts +6 -0
  54. package/dist/request-example/builder/helpers/apply-allow-reserved-to-url.d.ts.map +1 -0
  55. package/dist/request-example/builder/helpers/apply-allow-reserved-to-url.js +69 -0
  56. package/dist/request-example/builder/helpers/get-environment-variables.d.ts +9 -0
  57. package/dist/request-example/builder/helpers/get-environment-variables.d.ts.map +1 -0
  58. package/dist/request-example/builder/helpers/get-environment-variables.js +12 -0
  59. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +40 -0
  60. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -0
  61. package/dist/request-example/builder/helpers/get-example-from-schema.js +568 -0
  62. package/dist/request-example/builder/helpers/get-example.d.ts +10 -0
  63. package/dist/request-example/builder/helpers/get-example.d.ts.map +1 -0
  64. package/dist/request-example/builder/helpers/get-example.js +66 -0
  65. package/dist/request-example/builder/helpers/get-resolved-url.d.ts +20 -0
  66. package/dist/request-example/builder/helpers/get-resolved-url.d.ts.map +1 -0
  67. package/dist/request-example/builder/helpers/get-resolved-url.js +19 -0
  68. package/dist/request-example/builder/helpers/get-server-variables.d.ts +10 -0
  69. package/dist/request-example/builder/helpers/get-server-variables.d.ts.map +1 -0
  70. package/dist/request-example/builder/helpers/get-server-variables.js +19 -0
  71. package/dist/request-example/builder/index.d.ts +15 -0
  72. package/dist/request-example/builder/index.d.ts.map +1 -0
  73. package/dist/request-example/builder/index.js +13 -0
  74. package/dist/request-example/builder/request-factory.d.ts +60 -0
  75. package/dist/request-example/builder/request-factory.d.ts.map +1 -0
  76. package/dist/request-example/builder/request-factory.js +78 -0
  77. package/dist/request-example/builder/security/build-request-security.d.ts +24 -0
  78. package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -0
  79. package/dist/request-example/builder/security/build-request-security.js +79 -0
  80. package/dist/request-example/builder/security/secret-types.d.ts +25 -0
  81. package/dist/request-example/builder/security/secret-types.d.ts.map +1 -0
  82. package/dist/request-example/builder/security/secret-types.js +1 -0
  83. package/dist/request-example/context/environment.d.ts +21 -0
  84. package/dist/request-example/context/environment.d.ts.map +1 -0
  85. package/dist/request-example/context/environment.js +49 -0
  86. package/dist/request-example/context/get-request-example-context.d.ts +57 -0
  87. package/dist/request-example/context/get-request-example-context.d.ts.map +1 -0
  88. package/dist/request-example/context/get-request-example-context.js +115 -0
  89. package/dist/request-example/context/headers.d.ts +33 -0
  90. package/dist/request-example/context/headers.d.ts.map +1 -0
  91. package/dist/request-example/context/headers.js +54 -0
  92. package/dist/request-example/context/helpers/combine-params.d.ts +4 -0
  93. package/dist/request-example/context/helpers/combine-params.d.ts.map +1 -0
  94. package/dist/request-example/context/helpers/combine-params.js +21 -0
  95. package/dist/request-example/context/index.d.ts +12 -0
  96. package/dist/request-example/context/index.d.ts.map +1 -0
  97. package/dist/request-example/context/index.js +10 -0
  98. package/dist/request-example/context/proxy.d.ts +18 -0
  99. package/dist/request-example/context/proxy.d.ts.map +1 -0
  100. package/dist/request-example/context/proxy.js +26 -0
  101. package/dist/request-example/context/security/extract-security-scheme-secrets.d.ts +10 -0
  102. package/dist/request-example/context/security/extract-security-scheme-secrets.d.ts.map +1 -0
  103. package/dist/request-example/context/security/extract-security-scheme-secrets.js +167 -0
  104. package/dist/request-example/context/security/get-security-requirements.d.ts +12 -0
  105. package/dist/request-example/context/security/get-security-requirements.d.ts.map +1 -0
  106. package/dist/request-example/context/security/get-security-requirements.js +16 -0
  107. package/dist/request-example/context/security/get-security-schemes.d.ts +9 -0
  108. package/dist/request-example/context/security/get-security-schemes.d.ts.map +1 -0
  109. package/dist/request-example/context/security/get-security-schemes.js +13 -0
  110. package/dist/request-example/context/security/get-selected-security.d.ts +15 -0
  111. package/dist/request-example/context/security/get-selected-security.d.ts.map +1 -0
  112. package/dist/request-example/context/security/get-selected-security.js +49 -0
  113. package/dist/request-example/context/security/is-auth-optional.d.ts +4 -0
  114. package/dist/request-example/context/security/is-auth-optional.d.ts.map +1 -0
  115. package/dist/request-example/context/security/is-auth-optional.js +6 -0
  116. package/dist/request-example/context/security/merge-security.d.ts +9 -0
  117. package/dist/request-example/context/security/merge-security.d.ts.map +1 -0
  118. package/dist/request-example/context/security/merge-security.js +29 -0
  119. package/dist/request-example/context/servers.d.ts +26 -0
  120. package/dist/request-example/context/servers.d.ts.map +1 -0
  121. package/dist/request-example/context/servers.js +89 -0
  122. package/dist/request-example/index.d.ts +5 -0
  123. package/dist/request-example/index.d.ts.map +1 -0
  124. package/dist/request-example/index.js +2 -0
  125. package/dist/request-example/types.d.ts +14 -0
  126. package/dist/request-example/types.d.ts.map +1 -0
  127. package/dist/request-example/types.js +1 -0
  128. package/dist/schemas/extensions/operation/index.d.ts +2 -1
  129. package/dist/schemas/extensions/operation/index.d.ts.map +1 -1
  130. package/dist/schemas/extensions/operation/index.js +1 -0
  131. package/dist/schemas/extensions/tag/x-tag-groups.d.ts +8 -8
  132. package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -1
  133. package/dist/schemas/v3.1/openapi/index.d.ts +110 -1
  134. package/dist/schemas/v3.1/openapi/index.d.ts.map +1 -1
  135. package/dist/schemas/v3.1/openapi/index.js +50 -66
  136. package/package.json +15 -10
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Matches, when:
3
+ * - Isn't scoped to a domain, or
4
+ * - matches the current host, or
5
+ * - or ends with the current host, or
6
+ * - matches the current host with a wildcard.
7
+ */
8
+ export const matchesDomain = (givenUrl, configuredHostname) => {
9
+ if (!givenUrl || !configuredHostname) {
10
+ return true;
11
+ }
12
+ try {
13
+ // Add protocol if not present
14
+ const urlWithProtocol = givenUrl.startsWith('http') ? givenUrl : `http://${givenUrl}`;
15
+ // Get just the hostname
16
+ const givenHostname = new URL(urlWithProtocol).hostname;
17
+ // Let's see if the configured hostname matches the given hostname in some way
18
+ const noHostnameConfigured = !configuredHostname;
19
+ const hostnameMatches = configuredHostname === givenHostname;
20
+ const domainMatchesWildcard = configuredHostname.startsWith('.') && configuredHostname === `.${givenHostname}`;
21
+ const subdomainMatchesWildcard = configuredHostname.startsWith('.') && givenHostname?.endsWith(configuredHostname);
22
+ return noHostnameConfigured || hostnameMatches || subdomainMatchesWildcard || domainMatchesWildcard;
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ };
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Shared parameter serialization utilities for OpenAPI style values.
3
+ * Used by both build-request-parameters and process-parameters.
4
+ *
5
+ * @see https://spec.openapis.org/oas/v3.1.1.html#style-values
6
+ */
7
+ /**
8
+ * Serializes a value based on the content type for content-based query parameters.
9
+ * Content-based query parameters do not use style serialization and instead follow
10
+ * their content type specification (e.g., application/json should be JSON.stringified).
11
+ *
12
+ * @param value - The value to serialize
13
+ * @param contentType - The content type to use for serialization
14
+ * @returns The serialized value as a string
15
+ */
16
+ export declare const serializeContentValue: (value: unknown, contentType: string) => string;
17
+ /**
18
+ * Serializes a value according to OpenAPI simple style.
19
+ * Used for path and header parameters.
20
+ *
21
+ * Simple style with explode: false
22
+ * - Primitive: blue
23
+ * - Array: blue,black,brown
24
+ * - Object: R,100,G,200,B,150
25
+ *
26
+ * Simple style with explode: true
27
+ * - Primitive: blue
28
+ * - Array: blue,black,brown
29
+ * - Object: R=100,G=200,B=150
30
+ */
31
+ export declare const serializeSimpleStyle: (value: unknown, explode: boolean) => unknown;
32
+ /**
33
+ * Serializes a value according to OpenAPI form style.
34
+ * Used for query and cookie parameters.
35
+ *
36
+ * Form style with explode: true (default for query)
37
+ * - Primitive: color=blue
38
+ * - Array: color=blue&color=black&color=brown (multiple entries)
39
+ * - Object: R=100&G=200&B=150 (multiple entries)
40
+ *
41
+ * Form style with explode: false
42
+ * - Primitive: color=blue
43
+ * - Array: color=blue,black,brown
44
+ * - Object: color=R,100,G,200,B,150
45
+ */
46
+ export declare const serializeFormStyle: (value: unknown, explode: boolean) => unknown | Array<{
47
+ key: string;
48
+ value: unknown;
49
+ }>;
50
+ /**
51
+ * Serializes a value according to OpenAPI form style for cookies.
52
+ * This is similar to serializeFormStyle but handles nested objects recursively
53
+ * and treats null values specially for cookie serialization.
54
+ *
55
+ * Form style with explode: true (default for cookies)
56
+ * - Primitive: color=blue
57
+ * - Array: color=blue&color=black&color=brown (multiple entries)
58
+ * - Object: R=100&G=200&B=150 (multiple entries)
59
+ *
60
+ * Form style with explode: false
61
+ * - Primitive: color=blue
62
+ * - Array: color=blue,black,brown (null becomes "null")
63
+ * - Object: color=R,100,G,200,B,150 (recursively flattened)
64
+ */
65
+ export declare const serializeFormStyleForCookies: (value: unknown, explode: boolean) => unknown | Array<{
66
+ key: string;
67
+ value: unknown;
68
+ }>;
69
+ /**
70
+ * Serializes a value according to OpenAPI spaceDelimited style.
71
+ * Only valid for query parameters with array or object values.
72
+ *
73
+ * SpaceDelimited array: blue black brown
74
+ * SpaceDelimited object: R 100 G 200 B 150
75
+ */
76
+ export declare const serializeSpaceDelimitedStyle: (value: unknown) => string;
77
+ /**
78
+ * Serializes a value according to OpenAPI pipeDelimited style.
79
+ * Only valid for query parameters with array or object values.
80
+ *
81
+ * PipeDelimited array: blue|black|brown
82
+ * PipeDelimited object: R|100|G|200|B|150
83
+ */
84
+ export declare const serializePipeDelimitedStyle: (value: unknown) => string;
85
+ /**
86
+ * Serializes a value according to OpenAPI deepObject style.
87
+ * Only valid for query parameters with explode: true.
88
+ *
89
+ * DeepObject: color[R]=100&color[G]=200&color[B]=150
90
+ * Nested: user[name][first]=Alex&user[name][last]=Smith&user[role]=admin
91
+ */
92
+ export declare const serializeDeepObjectStyle: (paramName: string, value: unknown) => Array<{
93
+ key: string;
94
+ value: string;
95
+ }>;
96
+ //# sourceMappingURL=serialize-parameter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize-parameter.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/header/serialize-parameter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,EAAE,aAAa,MAAM,KAAG,MAa3E,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAqBvE,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,OAAO,EACd,SAAS,OAAO,KACf,OAAO,GAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CA4BjD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,OAAO,EACd,SAAS,OAAO,KACf,OAAO,GAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CA2CjD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,OAAO,OAAO,KAAG,MAe7D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,KAAG,MAe5D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,WAAW,MAAM,EAAE,OAAO,OAAO,KAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAyBhH,CAAA"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Shared parameter serialization utilities for OpenAPI style values.
3
+ * Used by both build-request-parameters and process-parameters.
4
+ *
5
+ * @see https://spec.openapis.org/oas/v3.1.1.html#style-values
6
+ */
7
+ /**
8
+ * Serializes a value based on the content type for content-based query parameters.
9
+ * Content-based query parameters do not use style serialization and instead follow
10
+ * their content type specification (e.g., application/json should be JSON.stringified).
11
+ *
12
+ * @param value - The value to serialize
13
+ * @param contentType - The content type to use for serialization
14
+ * @returns The serialized value as a string
15
+ */
16
+ export const serializeContentValue = (value, contentType) => {
17
+ // If already a string, return as is
18
+ if (typeof value === 'string') {
19
+ return value;
20
+ }
21
+ // Handle JSON content types
22
+ if (contentType.includes('json') || (typeof value === 'object' && value !== null && !Array.isArray(value))) {
23
+ return JSON.stringify(value);
24
+ }
25
+ // Default: convert to string
26
+ return String(value);
27
+ };
28
+ /**
29
+ * Serializes a value according to OpenAPI simple style.
30
+ * Used for path and header parameters.
31
+ *
32
+ * Simple style with explode: false
33
+ * - Primitive: blue
34
+ * - Array: blue,black,brown
35
+ * - Object: R,100,G,200,B,150
36
+ *
37
+ * Simple style with explode: true
38
+ * - Primitive: blue
39
+ * - Array: blue,black,brown
40
+ * - Object: R=100,G=200,B=150
41
+ */
42
+ export const serializeSimpleStyle = (value, explode) => {
43
+ // Handle arrays
44
+ if (Array.isArray(value)) {
45
+ return value.join(',');
46
+ }
47
+ // Handle objects
48
+ if (typeof value === 'object' && value !== null) {
49
+ const entries = Object.entries(value);
50
+ if (explode) {
51
+ // Simple explode object: R=100,G=200,B=150
52
+ return entries.map(([k, v]) => `${k}=${v}`).join(',');
53
+ }
54
+ // Simple no explode object: R,100,G,200,B,150
55
+ return entries.map(([k, v]) => `${k},${v}`).join(',');
56
+ }
57
+ // Handle primitives - return as-is to preserve type
58
+ return value;
59
+ };
60
+ /**
61
+ * Serializes a value according to OpenAPI form style.
62
+ * Used for query and cookie parameters.
63
+ *
64
+ * Form style with explode: true (default for query)
65
+ * - Primitive: color=blue
66
+ * - Array: color=blue&color=black&color=brown (multiple entries)
67
+ * - Object: R=100&G=200&B=150 (multiple entries)
68
+ *
69
+ * Form style with explode: false
70
+ * - Primitive: color=blue
71
+ * - Array: color=blue,black,brown
72
+ * - Object: color=R,100,G,200,B,150
73
+ */
74
+ export const serializeFormStyle = (value, explode) => {
75
+ // Handle arrays with explode
76
+ if (Array.isArray(value) && explode) {
77
+ return value.map((v) => ({ key: '', value: v }));
78
+ }
79
+ // Handle arrays without explode
80
+ if (Array.isArray(value)) {
81
+ return value.join(',');
82
+ }
83
+ // Handle objects with explode
84
+ if (typeof value === 'object' && value !== null && explode) {
85
+ return Object.entries(value).map(([k, v]) => ({
86
+ key: k,
87
+ value: v,
88
+ }));
89
+ }
90
+ // Handle objects without explode
91
+ if (typeof value === 'object' && value !== null) {
92
+ return Object.entries(value)
93
+ .map(([k, v]) => `${k},${v}`)
94
+ .join(',');
95
+ }
96
+ // Handle primitives - return as-is to preserve type
97
+ return value;
98
+ };
99
+ /**
100
+ * Serializes a value according to OpenAPI form style for cookies.
101
+ * This is similar to serializeFormStyle but handles nested objects recursively
102
+ * and treats null values specially for cookie serialization.
103
+ *
104
+ * Form style with explode: true (default for cookies)
105
+ * - Primitive: color=blue
106
+ * - Array: color=blue&color=black&color=brown (multiple entries)
107
+ * - Object: R=100&G=200&B=150 (multiple entries)
108
+ *
109
+ * Form style with explode: false
110
+ * - Primitive: color=blue
111
+ * - Array: color=blue,black,brown (null becomes "null")
112
+ * - Object: color=R,100,G,200,B,150 (recursively flattened)
113
+ */
114
+ export const serializeFormStyleForCookies = (value, explode) => {
115
+ // Handle arrays with explode
116
+ if (Array.isArray(value) && explode) {
117
+ return value.map((v) => ({ key: '', value: v }));
118
+ }
119
+ // Handle arrays without explode - convert null to "null" string
120
+ if (Array.isArray(value)) {
121
+ return value.map((v) => (v === null ? 'null' : String(v))).join(',');
122
+ }
123
+ // Handle objects with explode
124
+ if (typeof value === 'object' && value !== null && explode) {
125
+ return Object.entries(value).map(([k, v]) => ({
126
+ key: k,
127
+ value: v,
128
+ }));
129
+ }
130
+ // Handle objects without explode - recursively flatten nested objects
131
+ if (typeof value === 'object' && value !== null) {
132
+ const flattenObject = (obj) => {
133
+ const result = [];
134
+ for (const [key, val] of Object.entries(obj)) {
135
+ // Recursively flatten nested objects
136
+ if (typeof val === 'object' && val !== null && !Array.isArray(val)) {
137
+ result.push(key, ...flattenObject(val));
138
+ }
139
+ // Handle primitive values
140
+ else {
141
+ result.push(key, val === null ? 'null' : String(val));
142
+ }
143
+ }
144
+ return result;
145
+ };
146
+ return flattenObject(value).join(',');
147
+ }
148
+ // Handle primitives - return as-is to preserve type
149
+ return value;
150
+ };
151
+ /**
152
+ * Serializes a value according to OpenAPI spaceDelimited style.
153
+ * Only valid for query parameters with array or object values.
154
+ *
155
+ * SpaceDelimited array: blue black brown
156
+ * SpaceDelimited object: R 100 G 200 B 150
157
+ */
158
+ export const serializeSpaceDelimitedStyle = (value) => {
159
+ // Handle arrays
160
+ if (Array.isArray(value)) {
161
+ return value.join(' ');
162
+ }
163
+ // Handle objects
164
+ if (typeof value === 'object' && value !== null) {
165
+ return Object.entries(value)
166
+ .map(([k, v]) => `${k} ${v}`)
167
+ .join(' ');
168
+ }
169
+ // Handle primitives (shouldn't happen for spaceDelimited)
170
+ return String(value);
171
+ };
172
+ /**
173
+ * Serializes a value according to OpenAPI pipeDelimited style.
174
+ * Only valid for query parameters with array or object values.
175
+ *
176
+ * PipeDelimited array: blue|black|brown
177
+ * PipeDelimited object: R|100|G|200|B|150
178
+ */
179
+ export const serializePipeDelimitedStyle = (value) => {
180
+ // Handle arrays
181
+ if (Array.isArray(value)) {
182
+ return value.join('|');
183
+ }
184
+ // Handle objects
185
+ if (typeof value === 'object' && value !== null) {
186
+ return Object.entries(value)
187
+ .flat()
188
+ .join('|');
189
+ }
190
+ // Handle primitives (shouldn't happen for pipeDelimited)
191
+ return String(value);
192
+ };
193
+ /**
194
+ * Serializes a value according to OpenAPI deepObject style.
195
+ * Only valid for query parameters with explode: true.
196
+ *
197
+ * DeepObject: color[R]=100&color[G]=200&color[B]=150
198
+ * Nested: user[name][first]=Alex&user[name][last]=Smith&user[role]=admin
199
+ */
200
+ export const serializeDeepObjectStyle = (paramName, value) => {
201
+ const result = [];
202
+ /**
203
+ * Recursively flattens nested objects into deepObject notation.
204
+ */
205
+ const flatten = (obj, prefix) => {
206
+ for (const [key, val] of Object.entries(obj)) {
207
+ const fullKey = `${prefix}[${key}]`;
208
+ if (typeof val === 'object' && val !== null && !Array.isArray(val)) {
209
+ // Recursively flatten nested objects
210
+ flatten(val, fullKey);
211
+ }
212
+ else {
213
+ // Add primitive values
214
+ result.push({ key: fullKey, value: String(val) });
215
+ }
216
+ }
217
+ };
218
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
219
+ flatten(value, paramName);
220
+ }
221
+ return result;
222
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Decodes reserved character percent-encodings only for query keys marked with
3
+ * OpenAPI's `allowReserved: true`.
4
+ */
5
+ export declare const applyAllowReservedToUrl: (url: string, allowReservedQueryParameters: Set<string>) => string;
6
+ //# sourceMappingURL=apply-allow-reserved-to-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-allow-reserved-to-url.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/apply-allow-reserved-to-url.ts"],"names":[],"mappings":"AAsCA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,EAAE,8BAA8B,GAAG,CAAC,MAAM,CAAC,KAAG,MAwChG,CAAA"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Reserved characters we can safely decode in query values when OpenAPI
3
+ * `allowReserved` is enabled.
4
+ *
5
+ * We intentionally keep percent-encodings for characters that can break query
6
+ * parsing (`#`, `&`, `=`, `?`, `[`, `]`) or change x-www-form-urlencoded
7
+ * semantics (`+`).
8
+ *
9
+ * @see https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-10
10
+ */
11
+ const DECODABLE_RESERVED_CHARACTERS_BY_PERCENT_ENCODING = {
12
+ '21': '!',
13
+ '24': '$',
14
+ '27': "'",
15
+ '28': '(',
16
+ '29': ')',
17
+ '2A': '*',
18
+ '2C': ',',
19
+ '2F': '/',
20
+ '3A': ':',
21
+ '3B': ';',
22
+ '40': '@',
23
+ };
24
+ const decodeReservedCharacters = (value) => value.replace(/%([0-9A-Fa-f]{2})/g, (match, code) => DECODABLE_RESERVED_CHARACTERS_BY_PERCENT_ENCODING[code.toUpperCase()] ?? match);
25
+ const decodeQueryKey = (key) => {
26
+ try {
27
+ return decodeURIComponent(key.replaceAll('+', '%20'));
28
+ }
29
+ catch {
30
+ return key;
31
+ }
32
+ };
33
+ /**
34
+ * Decodes reserved character percent-encodings only for query keys marked with
35
+ * OpenAPI's `allowReserved: true`.
36
+ */
37
+ export const applyAllowReservedToUrl = (url, allowReservedQueryParameters) => {
38
+ if (allowReservedQueryParameters.size === 0) {
39
+ return url;
40
+ }
41
+ const queryStart = url.indexOf('?');
42
+ if (queryStart === -1) {
43
+ return url;
44
+ }
45
+ const hashStart = url.indexOf('#', queryStart);
46
+ const urlPrefix = url.slice(0, queryStart + 1);
47
+ const query = hashStart === -1 ? url.slice(queryStart + 1) : url.slice(queryStart + 1, hashStart);
48
+ const hash = hashStart === -1 ? '' : url.slice(hashStart);
49
+ if (!query) {
50
+ return url;
51
+ }
52
+ const decodedQuery = query
53
+ .split('&')
54
+ .map((segment) => {
55
+ if (!segment) {
56
+ return segment;
57
+ }
58
+ const equalsIndex = segment.indexOf('=');
59
+ const rawKey = equalsIndex === -1 ? segment : segment.slice(0, equalsIndex);
60
+ const key = decodeQueryKey(rawKey);
61
+ if (!allowReservedQueryParameters.has(key) || equalsIndex === -1) {
62
+ return segment;
63
+ }
64
+ const rawValue = segment.slice(equalsIndex + 1);
65
+ return `${rawKey}=${decodeReservedCharacters(rawValue)}`;
66
+ })
67
+ .join('&');
68
+ return `${urlPrefix}${decodedQuery}${hash}`;
69
+ };
@@ -0,0 +1,9 @@
1
+ import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
2
+ /**
3
+ * Flattens the environment variables array into a key-value object.
4
+ * If a variable value is a string, use it directly; otherwise, use its default value.
5
+ *
6
+ * @returns An object mapping variable names to their resolved values.
7
+ */
8
+ export declare const getEnvironmentVariables: (environment: XScalarEnvironment) => Record<string, string>;
9
+ //# sourceMappingURL=get-environment-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-environment-variables.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-environment-variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAEnH;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,aAAa,kBAAkB,2BAKtE,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Flattens the environment variables array into a key-value object.
3
+ * If a variable value is a string, use it directly; otherwise, use its default value.
4
+ *
5
+ * @returns An object mapping variable names to their resolved values.
6
+ */
7
+ export const getEnvironmentVariables = (environment) => {
8
+ return environment.variables.reduce((acc, curr) => {
9
+ acc[curr.name] = typeof curr.value === 'string' ? curr.value : curr.value.default;
10
+ return acc;
11
+ }, {});
12
+ };
@@ -0,0 +1,40 @@
1
+ import type { SchemaObject } from '../../../schemas/v3.1/strict/openapi-document.js';
2
+ type GetExampleFromSchemaOptions = {
3
+ /** Fallback string for empty string values. */
4
+ emptyString?: string;
5
+ /** Whether to use XML tag names as keys. */
6
+ xml?: boolean;
7
+ /** Whether to show read-only/write-only properties. */
8
+ mode?: 'read' | 'write';
9
+ /** Dynamic variables which can replace values via x-variable. */
10
+ variables?: Record<string, unknown>;
11
+ /** Whether to omit empty and optional properties. */
12
+ omitEmptyAndOptionalProperties?: boolean;
13
+ /** Selected oneOf/anyOf variants keyed by schema path. */
14
+ compositionSelection?: Record<string, number>;
15
+ };
16
+ /**
17
+ * Generate an example value from a given OpenAPI SchemaObject.
18
+ *
19
+ * This function recursively processes OpenAPI schemas to create realistic example data.
20
+ * It handles all OpenAPI schema types including primitives, objects, arrays, and
21
+ * composition schemas (allOf, oneOf, anyOf).
22
+ * Uses a tonne of caching for maximum performance.
23
+ *
24
+ * @param schema - The OpenAPI SchemaObject to generate an example from.
25
+ * @param options - Options to customize example generation.
26
+ * @param level - The current recursion depth.
27
+ * @param parentSchema - The parent schema, if any.
28
+ * @param name - The name of the property being processed.
29
+ * @returns An example value for the given schema.
30
+ */
31
+ export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, { level, parentSchema, name, seen, schemaPath, }?: Partial<{
32
+ level: number;
33
+ parentSchema: SchemaObject;
34
+ name: string;
35
+ seen: WeakSet<object>;
36
+ /** Internal traversal path used to resolve nested composition selections. */
37
+ schemaPath: string[];
38
+ }>) => unknown;
39
+ export {};
40
+ //# sourceMappingURL=get-example-from-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAwf1E,KAAK,2BAA2B,GAAG;IACjC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AAeD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,mDAMG,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB,CAAM,KACN,OAiKF,CAAA"}