@scalar/workspace-store 0.55.6 → 0.56.1

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 (52) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +1 -1
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +9 -0
  5. package/dist/entities/auth/index.d.ts +1 -1
  6. package/dist/entities/auth/index.d.ts.map +1 -1
  7. package/dist/entities/auth/schema.d.ts +114 -4
  8. package/dist/entities/auth/schema.d.ts.map +1 -1
  9. package/dist/entities/auth/schema.js +29 -1
  10. package/dist/events/definitions/auth.d.ts +15 -2
  11. package/dist/events/definitions/auth.d.ts.map +1 -1
  12. package/dist/mutators/auth.d.ts +1 -1
  13. package/dist/mutators/auth.d.ts.map +1 -1
  14. package/dist/mutators/auth.js +19 -2
  15. package/dist/mutators/operation/helpers/fetch-request-to-har.d.ts.map +1 -1
  16. package/dist/mutators/operation/helpers/fetch-request-to-har.js +7 -2
  17. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  18. package/dist/navigation/get-navigation-options.js +4 -1
  19. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  20. package/dist/request-example/builder/body/build-request-body.js +1 -99
  21. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  22. package/dist/request-example/builder/body/get-request-body-example.js +4 -2
  23. package/dist/request-example/builder/body/schema-value-coercion.d.ts +34 -0
  24. package/dist/request-example/builder/body/schema-value-coercion.d.ts.map +1 -0
  25. package/dist/request-example/builder/body/schema-value-coercion.js +120 -0
  26. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  27. package/dist/request-example/builder/helpers/get-example-from-schema.js +26 -5
  28. package/dist/request-example/builder/index.d.ts +3 -1
  29. package/dist/request-example/builder/index.d.ts.map +1 -1
  30. package/dist/request-example/builder/index.js +2 -0
  31. package/dist/request-example/builder/security/broker-scheme-types.d.ts +16 -0
  32. package/dist/request-example/builder/security/broker-scheme-types.d.ts.map +1 -0
  33. package/dist/request-example/builder/security/broker-scheme-types.js +12 -0
  34. package/dist/request-example/builder/security/secret-types.d.ts +19 -2
  35. package/dist/request-example/builder/security/secret-types.d.ts.map +1 -1
  36. package/dist/request-example/context/security/extract-security-scheme-secrets.d.ts.map +1 -1
  37. package/dist/request-example/context/security/extract-security-scheme-secrets.js +61 -4
  38. package/dist/request-example/index.d.ts +2 -2
  39. package/dist/request-example/index.d.ts.map +1 -1
  40. package/dist/request-example/index.js +1 -1
  41. package/dist/schemas/extensions/security/index.d.ts +1 -1
  42. package/dist/schemas/extensions/security/index.d.ts.map +1 -1
  43. package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts +48 -0
  44. package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts.map +1 -1
  45. package/dist/schemas/extensions/security/x-scalar-security-secrets.js +24 -0
  46. package/dist/schemas/reference-config/index.d.ts +1 -1
  47. package/dist/schemas/v3.1/openapi/index.d.ts +19 -1
  48. package/dist/schemas/v3.1/openapi/index.d.ts.map +1 -1
  49. package/dist/schemas/v3.1/openapi/index.js +115 -104
  50. package/dist/schemas/workspace-specification/index.d.ts +1 -1
  51. package/dist/schemas/workspace.d.ts +1 -1
  52. package/package.json +13 -13
@@ -3,109 +3,11 @@ import { isObject } from '@scalar/helpers/object/is-object';
3
3
  import { setValueAtPath } from '@scalar/helpers/object/set-value-at-path';
4
4
  import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
5
5
  import { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy';
6
- import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards';
7
6
  import { getExampleFromBody } from './get-request-body-example.js';
8
7
  import { getSelectedBodyContentType } from './get-selected-body-content-type.js';
8
+ import { buildDottedNestedRowPredicate, coerceLeafValueToSchemaType, resolveLeafSchema } from './schema-value-coercion.js';
9
9
  import { serializeFormPropertyWithEncoding } from './serialize-form-property.js';
10
10
  const getMultipartEncodingContentType = (requestBody, bodyContentType, fieldName) => requestBody.content[bodyContentType]?.encoding?.[fieldName]?.contentType;
11
- /**
12
- * Build a predicate that recognizes multipart rows whose dotted name encodes a path
13
- * into a nested object property of the multipart schema. Without a schema (or when
14
- * the dotted prefix is not declared as a nested object), a row like `user.email`
15
- * is treated as a literal name and stays flat — only schema-derived leaves emitted
16
- * by `get-form-body-rows.ts` are folded back via `foldDottedRowsToObject`.
17
- */
18
- const buildDottedNestedRowPredicate = (schema) => {
19
- const resolved = schema ? getResolvedRef(schema, mergeSiblingReferences) : undefined;
20
- if (!resolved || !isObjectSchema(resolved) || !resolved.properties) {
21
- return (_name, _value) => false;
22
- }
23
- const nestedTopKeys = new Set();
24
- for (const [key, child] of Object.entries(resolved.properties)) {
25
- const childResolved = child
26
- ? getResolvedRef(child, mergeSiblingReferences)
27
- : undefined;
28
- if (childResolved && isObjectSchema(childResolved) && childResolved.properties) {
29
- nestedTopKeys.add(key);
30
- }
31
- }
32
- return (name, value) => {
33
- if (value instanceof File || !name.includes('.')) {
34
- return false;
35
- }
36
- const head = name.split('.', 1)[0];
37
- return !!head && nestedTopKeys.has(head);
38
- };
39
- };
40
- /** Normalize a schema's `type` (string | string[] | absent) into a plain string array. */
41
- const normalizeSchemaTypes = (schema) => {
42
- const type = 'type' in schema ? schema.type : undefined;
43
- return Array.isArray(type) ? [...type] : type == null ? [] : [type];
44
- };
45
- /**
46
- * Walk an object schema along a dotted-row path and return the resolved leaf schema,
47
- * or undefined when any segment is not a declared object property.
48
- */
49
- const resolveLeafSchema = (schema, segments) => {
50
- let current = schema;
51
- for (const segment of segments) {
52
- if (!current || !isObjectSchema(current) || !current.properties) {
53
- return undefined;
54
- }
55
- current = getResolvedRef(current.properties[segment], mergeSiblingReferences);
56
- }
57
- return current;
58
- };
59
- /** True when a JSON-parsed value's runtime type is allowed by the schema's declared types. */
60
- const parsedValueMatchesSchemaType = (value, types) => {
61
- if (value === null) {
62
- return types.includes('null');
63
- }
64
- if (Array.isArray(value)) {
65
- return types.includes('array');
66
- }
67
- if (typeof value === 'object') {
68
- return types.includes('object');
69
- }
70
- if (typeof value === 'boolean') {
71
- return types.includes('boolean');
72
- }
73
- if (typeof value === 'number') {
74
- // A fractional value only satisfies `number`; `integer` requires a whole number so a
75
- // string like "3.14" against an integer-only leaf stays untouched instead of being coerced.
76
- return types.includes('number') || (types.includes('integer') && Number.isInteger(value));
77
- }
78
- if (typeof value === 'string') {
79
- return types.includes('string');
80
- }
81
- return false;
82
- };
83
- /**
84
- * The form table stringifies every value for display, so an edited nested field comes back
85
- * as a string (`false` -> "false", `[]` -> "[]"). When the leaf schema declares a non-string
86
- * type, parse the string back to that type so the regrouped JSON part keeps its original
87
- * shape instead of becoming string-typed (issue #9416).
88
- *
89
- * Coercion is deliberately conservative: schemas that allow `string` keep the raw text, and a
90
- * value that does not parse as its declared type is left untouched so user input is never lost.
91
- */
92
- const coerceLeafValueToSchemaType = (value, schema) => {
93
- if (typeof value !== 'string' || !schema) {
94
- return value;
95
- }
96
- const types = normalizeSchemaTypes(schema);
97
- // No declared type, or a string is allowed: keep the user's text as-is.
98
- if (types.length === 0 || types.includes('string')) {
99
- return value;
100
- }
101
- try {
102
- const parsed = JSON.parse(value);
103
- return parsedValueMatchesSchemaType(parsed, types) ? parsed : value;
104
- }
105
- catch {
106
- return value;
107
- }
108
- };
109
11
  /**
110
12
  * Create the fetch request body
111
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAMrE;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,aAAa,GAAG,IAgClB,CAAA"}
1
+ {"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAMrE;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,EAC9B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,kCAAkC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACvD,aAAa,GAAG,IAkClB,CAAA"}
@@ -7,9 +7,11 @@ import { getExampleFromSchema } from '../../../request-example/builder/helpers/g
7
7
  */
8
8
  export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection) => {
9
9
  const content = requestBody.content?.[contentType];
10
- // Return existing example value if we have one
10
+ // Return the existing example when it carries a usable value. An example that only has an
11
+ // `externalValue` (not yet resolved to a `value`) is treated as missing, so we fall back to a
12
+ // schema-generated example instead of building an empty request body.
11
13
  const example = getExample(requestBody, exampleName, contentType);
12
- if (example) {
14
+ if (example && example.value !== undefined) {
13
15
  return example;
14
16
  }
15
17
  const schema = getResolvedRef(content?.schema);
@@ -0,0 +1,34 @@
1
+ import type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
+ /**
3
+ * Walk an object schema along a dotted-row path and return the resolved leaf schema,
4
+ * or undefined when any segment is not a declared object property.
5
+ */
6
+ export declare const resolveLeafSchema: (schema: SchemaObject | undefined, segments: string[]) => SchemaObject | undefined;
7
+ /**
8
+ * The form table stringifies every value for display, so an edited nested field comes back
9
+ * as a string (`false` -> "false", `[]` -> "[]"). When the leaf schema declares a non-string
10
+ * type, parse the string back to that type so the regrouped JSON part keeps its original
11
+ * shape instead of becoming string-typed (issue #9416).
12
+ *
13
+ * Coercion is deliberately conservative: schemas that allow `string` keep the raw text, and a
14
+ * value that does not parse as its declared type is left untouched so user input is never lost.
15
+ */
16
+ export declare const coerceLeafValueToSchemaType: (value: unknown, schema: SchemaObject | undefined) => unknown;
17
+ /**
18
+ * Best-effort coercion for row values whose property is not declared in the schema.
19
+ *
20
+ * Without a declared type we have no authority to keep `"5"` a string, and leaving it
21
+ * untouched would string-type every undeclared number/boolean on the first form edit.
22
+ * So values that parse as non-string JSON (`5`, `true`, `null`, `[1]`, `{"a":1}`) become
23
+ * that value, and anything else stays the raw text the user typed.
24
+ */
25
+ export declare const coerceUntypedValue: (value: unknown) => unknown;
26
+ /**
27
+ * Build a predicate that recognizes rows whose dotted name encodes a path into a nested
28
+ * object property of the body schema. Without a schema (or when the dotted prefix is not
29
+ * declared as a nested object), a row like `user.email` is treated as a literal name and
30
+ * stays flat — only schema-derived leaves emitted by the form-row builders are folded
31
+ * back into nested objects.
32
+ */
33
+ export declare const buildDottedNestedRowPredicate: (schema: unknown) => (_name: string, _value: unknown) => boolean;
34
+ //# sourceMappingURL=schema-value-coercion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-value-coercion.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/schema-value-coercion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAShG;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,UAAU,MAAM,EAAE,KAAG,YAAY,GAAG,SASvG,CAAA;AA2BD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,OAAO,EAAE,QAAQ,YAAY,GAAG,SAAS,KAAG,OAe9F,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,OAUnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,GAAI,QAAQ,OAAO,aAG1C,MAAM,UAAU,OAAO,YAkBzC,CAAA"}
@@ -0,0 +1,120 @@
1
+ import { getResolvedRef, mergeSiblingReferences } from '@scalar/workspace-store/helpers/get-resolved-ref';
2
+ import { isObjectSchema } from '@scalar/workspace-store/schemas/v3.1/strict/type-guards';
3
+ /** Normalize a schema's `type` (string | string[] | absent) into a plain string array. */
4
+ const normalizeSchemaTypes = (schema) => {
5
+ const type = 'type' in schema ? schema.type : undefined;
6
+ return Array.isArray(type) ? [...type] : type == null ? [] : [type];
7
+ };
8
+ /**
9
+ * Walk an object schema along a dotted-row path and return the resolved leaf schema,
10
+ * or undefined when any segment is not a declared object property.
11
+ */
12
+ export const resolveLeafSchema = (schema, segments) => {
13
+ let current = schema;
14
+ for (const segment of segments) {
15
+ if (!current || !isObjectSchema(current) || !current.properties) {
16
+ return undefined;
17
+ }
18
+ current = getResolvedRef(current.properties[segment], mergeSiblingReferences);
19
+ }
20
+ return current;
21
+ };
22
+ /** True when a JSON-parsed value's runtime type is allowed by the schema's declared types. */
23
+ const parsedValueMatchesSchemaType = (value, types) => {
24
+ if (value === null) {
25
+ return types.includes('null');
26
+ }
27
+ if (Array.isArray(value)) {
28
+ return types.includes('array');
29
+ }
30
+ if (typeof value === 'object') {
31
+ return types.includes('object');
32
+ }
33
+ if (typeof value === 'boolean') {
34
+ return types.includes('boolean');
35
+ }
36
+ if (typeof value === 'number') {
37
+ // A fractional value only satisfies `number`; `integer` requires a whole number so a
38
+ // string like "3.14" against an integer-only leaf stays untouched instead of being coerced.
39
+ return types.includes('number') || (types.includes('integer') && Number.isInteger(value));
40
+ }
41
+ if (typeof value === 'string') {
42
+ return types.includes('string');
43
+ }
44
+ return false;
45
+ };
46
+ /**
47
+ * The form table stringifies every value for display, so an edited nested field comes back
48
+ * as a string (`false` -> "false", `[]` -> "[]"). When the leaf schema declares a non-string
49
+ * type, parse the string back to that type so the regrouped JSON part keeps its original
50
+ * shape instead of becoming string-typed (issue #9416).
51
+ *
52
+ * Coercion is deliberately conservative: schemas that allow `string` keep the raw text, and a
53
+ * value that does not parse as its declared type is left untouched so user input is never lost.
54
+ */
55
+ export const coerceLeafValueToSchemaType = (value, schema) => {
56
+ if (typeof value !== 'string' || !schema) {
57
+ return value;
58
+ }
59
+ const types = normalizeSchemaTypes(schema);
60
+ // No declared type, or a string is allowed: keep the user's text as-is.
61
+ if (types.length === 0 || types.includes('string')) {
62
+ return value;
63
+ }
64
+ try {
65
+ const parsed = JSON.parse(value);
66
+ return parsedValueMatchesSchemaType(parsed, types) ? parsed : value;
67
+ }
68
+ catch {
69
+ return value;
70
+ }
71
+ };
72
+ /**
73
+ * Best-effort coercion for row values whose property is not declared in the schema.
74
+ *
75
+ * Without a declared type we have no authority to keep `"5"` a string, and leaving it
76
+ * untouched would string-type every undeclared number/boolean on the first form edit.
77
+ * So values that parse as non-string JSON (`5`, `true`, `null`, `[1]`, `{"a":1}`) become
78
+ * that value, and anything else stays the raw text the user typed.
79
+ */
80
+ export const coerceUntypedValue = (value) => {
81
+ if (typeof value !== 'string') {
82
+ return value;
83
+ }
84
+ try {
85
+ const parsed = JSON.parse(value);
86
+ return typeof parsed === 'string' ? value : parsed;
87
+ }
88
+ catch {
89
+ return value;
90
+ }
91
+ };
92
+ /**
93
+ * Build a predicate that recognizes rows whose dotted name encodes a path into a nested
94
+ * object property of the body schema. Without a schema (or when the dotted prefix is not
95
+ * declared as a nested object), a row like `user.email` is treated as a literal name and
96
+ * stays flat — only schema-derived leaves emitted by the form-row builders are folded
97
+ * back into nested objects.
98
+ */
99
+ export const buildDottedNestedRowPredicate = (schema) => {
100
+ const resolved = schema ? getResolvedRef(schema, mergeSiblingReferences) : undefined;
101
+ if (!resolved || !isObjectSchema(resolved) || !resolved.properties) {
102
+ return (_name, _value) => false;
103
+ }
104
+ const nestedTopKeys = new Set();
105
+ for (const [key, child] of Object.entries(resolved.properties)) {
106
+ const childResolved = child
107
+ ? getResolvedRef(child, mergeSiblingReferences)
108
+ : undefined;
109
+ if (childResolved && isObjectSchema(childResolved) && childResolved.properties) {
110
+ nestedTopKeys.add(key);
111
+ }
112
+ }
113
+ return (name, value) => {
114
+ if (value instanceof File || !name.includes('.')) {
115
+ return false;
116
+ }
117
+ const head = name.split('.', 1)[0];
118
+ return !!head && nestedTopKeys.has(head);
119
+ };
120
+ };
@@ -1 +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":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAisB1E,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,iEAOG,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;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAM,KACN,OAmMF,CAAA"}
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAitB1E,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,iEAOG,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;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAM,KACN,OAwMF,CAAA"}
@@ -169,6 +169,14 @@ const shouldOmitProperty = (schema, parentSchema, propertyName, options) => {
169
169
  * Arrays are concatenated, objects are merged, otherwise the new value wins.
170
170
  */
171
171
  const mergeExamples = (baseValue, newValue) => {
172
+ // A null/undefined contribution (e.g. a constraint-only allOf member such as
173
+ // `not` or `if/then/else`, which produce no example) must not wipe what we have.
174
+ if (newValue === undefined || newValue === null) {
175
+ return baseValue;
176
+ }
177
+ if (baseValue === undefined || baseValue === null) {
178
+ return newValue;
179
+ }
172
180
  if (Array.isArray(baseValue) && Array.isArray(newValue)) {
173
181
  return [...baseValue, ...newValue];
174
182
  }
@@ -411,15 +419,23 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
411
419
  }));
412
420
  }
413
421
  }
414
- // allOf
422
+ // allOf — thread a choice-ordinal into schemaPath for each direct oneOf/anyOf
423
+ // member so multiple mutually-exclusive groups get distinct composition-selection
424
+ // keys that match the per-group pickers. Object members keep the parent path so
425
+ // their property-nested compositions still resolve by property name.
415
426
  else if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {
416
427
  let merged = response;
428
+ let choiceIndex = 0;
417
429
  for (const item of schema.allOf) {
418
- const ex = getExampleFromSchema(resolve.schema(item), options, {
430
+ const resolvedItem = resolve.schema(item);
431
+ const isChoiceMember = !!resolvedItem && (Array.isArray(resolvedItem.oneOf) || Array.isArray(resolvedItem.anyOf));
432
+ const memberSchemaPath = isChoiceMember ? [...schemaPath, String(choiceIndex++)] : schemaPath;
433
+ const ex = getExampleFromSchema(resolvedItem, options, {
419
434
  level: level + 1,
420
435
  parentSchema: schema,
421
436
  seen,
422
437
  dynamicScope: childScope,
438
+ schemaPath: memberSchemaPath,
423
439
  });
424
440
  merged = mergeExamples(merged, ex);
425
441
  }
@@ -726,11 +742,15 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
726
742
  if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {
727
743
  let merged = undefined;
728
744
  const items = _schema.allOf;
745
+ let choiceIndex = 0;
729
746
  for (const item of items) {
747
+ const resolvedItem = resolve.schema(item);
748
+ const isChoiceMember = !!resolvedItem && (Array.isArray(resolvedItem.oneOf) || Array.isArray(resolvedItem.anyOf));
749
+ const memberSchemaPath = isChoiceMember ? [...schemaPath, String(choiceIndex++)] : schemaPath;
730
750
  const ex = getExampleFromSchema(item, options, {
731
751
  level: level + 1,
732
752
  parentSchema: _schema,
733
- schemaPath,
753
+ schemaPath: memberSchemaPath,
734
754
  seen,
735
755
  dynamicScope: childScope,
736
756
  });
@@ -740,8 +760,9 @@ export const getExampleFromSchema = (schema, options, { level = 0, parentSchema,
740
760
  else if (merged && typeof merged === 'object' && ex && typeof ex === 'object') {
741
761
  merged = mergeExamples(merged, ex);
742
762
  }
743
- else if (ex !== undefined) {
744
- // Prefer the latest defined primitive value
763
+ else if (ex !== undefined && ex !== null) {
764
+ // Prefer the latest defined primitive value (but a null contribution —
765
+ // e.g. a constraint-only `not`/`if-then-else` member — must not clobber).
745
766
  merged = ex;
746
767
  }
747
768
  }
@@ -1,5 +1,6 @@
1
1
  export { getExampleFromBody } from './body/get-request-body-example.js';
2
2
  export { getSelectedBodyContentType } from './body/get-selected-body-content-type.js';
3
+ export { buildDottedNestedRowPredicate, coerceLeafValueToSchemaType, coerceUntypedValue, resolveLeafSchema, } from './body/schema-value-coercion.js';
3
4
  export { type SerializedFormProperty, serializeFormPropertyWithEncoding } from './body/serialize-form-property.js';
4
5
  export { BUILD_REQUEST_FAILED, type BuildRequestData, type BuildRequestFailureCode, type BuildRequestResult, type RequestPayload, buildRequest, resolveExecutableRequestUrl, } from './build-request.js';
5
6
  export { deSerializeParameter, deSerializeSchemaValue } from './header/de-serialize-parameter.js';
@@ -14,6 +15,7 @@ export { getServerVariables } from './helpers/get-server-variables.js';
14
15
  export type { RequestFactory } from './request-factory.js';
15
16
  export { requestFactory } from './request-factory.js';
16
17
  export { INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, type ResolveRequestFactoryUrlError, type ResolveRequestFactoryUrlResult, resolveRequestFactoryUrl, } from './resolve-request-factory-url.js';
18
+ export { isEncryptionSchemeType, isSaslSchemeType } from './security/broker-scheme-types.js';
17
19
  export { buildRequestSecurity } from './security/build-request-security.js';
18
- export type { ApiKeyObjectSecret, HttpObjectSecret, OAuth2ObjectSecret, OAuthFlowAuthorizationCodeSecret, OAuthFlowClientCredentialsSecret, OAuthFlowImplicitSecret, OAuthFlowPasswordSecret, OAuthFlowsObjectSecret, OpenIdConnectObjectSecret, SecuritySchemeObjectSecret, } from './security/secret-types.js';
20
+ export type { ApiKeyObjectSecret, EncryptionObjectSecret, GssapiObjectSecret, HttpObjectSecret, OAuth2ObjectSecret, OAuthFlowAuthorizationCodeSecret, OAuthFlowClientCredentialsSecret, OAuthFlowImplicitSecret, OAuthFlowPasswordSecret, OAuthFlowsObjectSecret, OpenIdConnectObjectSecret, SaslObjectSecret, SecuritySchemeObjectSecret, X509ObjectSecret, } from './security/secret-types.js';
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAClF,OAAO,EAAE,KAAK,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAA;AAC/G,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,wBAAwB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAClF,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,KAAK,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAA;AAC/G,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,wBAAwB,GACzB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,yBAAyB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export { getExampleFromBody } from './body/get-request-body-example.js';
2
2
  export { getSelectedBodyContentType } from './body/get-selected-body-content-type.js';
3
+ export { buildDottedNestedRowPredicate, coerceLeafValueToSchemaType, coerceUntypedValue, resolveLeafSchema, } from './body/schema-value-coercion.js';
3
4
  export { serializeFormPropertyWithEncoding } from './body/serialize-form-property.js';
4
5
  export { BUILD_REQUEST_FAILED, buildRequest, resolveExecutableRequestUrl, } from './build-request.js';
5
6
  export { deSerializeParameter, deSerializeSchemaValue } from './header/de-serialize-parameter.js';
@@ -13,4 +14,5 @@ export { getResolvedUrl } from './helpers/get-resolved-url.js';
13
14
  export { getServerVariables } from './helpers/get-server-variables.js';
14
15
  export { requestFactory } from './request-factory.js';
15
16
  export { INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, resolveRequestFactoryUrl, } from './resolve-request-factory-url.js';
17
+ export { isEncryptionSchemeType, isSaslSchemeType } from './security/broker-scheme-types.js';
16
18
  export { buildRequestSecurity } from './security/build-request-security.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AsyncAPI broker security scheme type names, grouped by the credential shape they share.
3
+ *
4
+ * These sets are the single source of truth for the runtime type guards used both when extracting
5
+ * stored secrets and when rendering the credential inputs, so the two stay in sync.
6
+ */
7
+ /** SASL-style broker schemes: all of them authenticate with a username + password pair. */
8
+ declare const SASL_SCHEME_TYPES: readonly ["userPassword", "plain", "scramSha256", "scramSha512"];
9
+ export type SaslSchemeType = (typeof SASL_SCHEME_TYPES)[number];
10
+ export declare const isSaslSchemeType: (type: string | undefined) => type is SaslSchemeType;
11
+ /** Encryption broker schemes: a single key value. */
12
+ declare const ENCRYPTION_SCHEME_TYPES: readonly ["symmetricEncryption", "asymmetricEncryption"];
13
+ export type EncryptionSchemeType = (typeof ENCRYPTION_SCHEME_TYPES)[number];
14
+ export declare const isEncryptionSchemeType: (type: string | undefined) => type is EncryptionSchemeType;
15
+ export {};
16
+ //# sourceMappingURL=broker-scheme-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-scheme-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/broker-scheme-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2FAA2F;AAC3F,QAAA,MAAM,iBAAiB,kEAAmE,CAAA;AAE1F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/D,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,IAAI,IAAI,cACO,CAAA;AAE3E,qDAAqD;AACrD,QAAA,MAAM,uBAAuB,0DAA2D,CAAA;AAExF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3E,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,IAAI,IAAI,oBACO,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * AsyncAPI broker security scheme type names, grouped by the credential shape they share.
3
+ *
4
+ * These sets are the single source of truth for the runtime type guards used both when extracting
5
+ * stored secrets and when rendering the credential inputs, so the two stay in sync.
6
+ */
7
+ /** SASL-style broker schemes: all of them authenticate with a username + password pair. */
8
+ const SASL_SCHEME_TYPES = ['userPassword', 'plain', 'scramSha256', 'scramSha512'];
9
+ export const isSaslSchemeType = (type) => Boolean(type) && SASL_SCHEME_TYPES.includes(type);
10
+ /** Encryption broker schemes: a single key value. */
11
+ const ENCRYPTION_SCHEME_TYPES = ['symmetricEncryption', 'asymmetricEncryption'];
12
+ export const isEncryptionSchemeType = (type) => Boolean(type) && ENCRYPTION_SCHEME_TYPES.includes(type);
@@ -1,4 +1,5 @@
1
- import type { XScalarAuthUrl, XScalarCredentialsLocation, XScalarSecretClientId, XScalarSecretClientSecret, XScalarSecretHTTP, XScalarSecretRedirectUri, XScalarSecretRefreshToken, XScalarSecretToken, XScalarTokenUrl } from '../../../schemas/extensions/security/index.js';
1
+ import type { EncryptionSchemeType, SaslSchemeType } from '../../../request-example/builder/security/broker-scheme-types.js';
2
+ import type { XScalarAuthUrl, XScalarCredentialsLocation, XScalarSecretClientCertificate, XScalarSecretClientId, XScalarSecretClientSecret, XScalarSecretHTTP, XScalarSecretPrivateKey, XScalarSecretRedirectUri, XScalarSecretRefreshToken, XScalarSecretServiceName, XScalarSecretToken, XScalarTokenUrl } from '../../../schemas/extensions/security/index.js';
2
3
  import type { OAuthFlowAuthorizationCode, OAuthFlowClientCredentials, OAuthFlowImplicit, OAuthFlowPassword } from '../../../schemas/v3.1/strict/oauth-flow.js';
3
4
  import type { ApiKeyObject, HttpObject, OAuth2Object, OpenIdConnectObject } from '../../../schemas/v3.1/strict/security-scheme.js';
4
5
  type OAuthFlowCommonSecret = XScalarSecretClientId & XScalarSecretToken & XScalarSecretRefreshToken & XScalarAuthUrl & XScalarTokenUrl;
@@ -20,6 +21,22 @@ export type OAuth2ObjectSecret = Omit<OAuth2Object, 'flows'> & {
20
21
  export type OpenIdConnectObjectSecret = OpenIdConnectObject & {
21
22
  flows?: OAuthFlowsObjectSecret;
22
23
  };
23
- export type SecuritySchemeObjectSecret = ApiKeyObjectSecret | HttpObjectSecret | OpenIdConnectObjectSecret | OAuth2ObjectSecret;
24
+ /**
25
+ * Base shape for AsyncAPI broker-only security schemes. These types live outside the strict
26
+ * OpenAPI `SecuritySchemeObject` union (they are AsyncAPI-only), so only the shared fields are modeled.
27
+ */
28
+ type AsyncApiBrokerScheme<T extends string> = {
29
+ type: T;
30
+ description?: string;
31
+ };
32
+ /** SASL-style AsyncAPI broker schemes: authenticate with a username + password pair. */
33
+ export type SaslObjectSecret = AsyncApiBrokerScheme<SaslSchemeType> & XScalarSecretHTTP;
34
+ /** AsyncAPI X509 scheme: a client certificate + private key pair (PEM). */
35
+ export type X509ObjectSecret = AsyncApiBrokerScheme<'X509'> & XScalarSecretClientCertificate & XScalarSecretPrivateKey;
36
+ /** AsyncAPI encryption schemes: a single key value, stored in the shared token slot. */
37
+ export type EncryptionObjectSecret = AsyncApiBrokerScheme<EncryptionSchemeType> & XScalarSecretToken;
38
+ /** AsyncAPI GSSAPI (Kerberos) scheme: the service name the client authenticates against. */
39
+ export type GssapiObjectSecret = AsyncApiBrokerScheme<'gssapi'> & XScalarSecretServiceName;
40
+ export type SecuritySchemeObjectSecret = ApiKeyObjectSecret | HttpObjectSecret | OpenIdConnectObjectSecret | OAuth2ObjectSecret | SaslObjectSecret | X509ObjectSecret | EncryptionObjectSecret | GssapiObjectSecret;
24
41
  export {};
25
42
  //# sourceMappingURL=secret-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secret-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/secret-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAExH,KAAK,qBAAqB,GAAG,qBAAqB,GAChD,kBAAkB,GAClB,yBAAyB,GACzB,cAAc,GACd,eAAe,CAAA;AAEjB,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,wBAAwB,CAAA;AAE1G,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GACrD,qBAAqB,GACrB,iBAAiB,GACjB,yBAAyB,GACzB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,wBAAwB,GACxB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;IACpD,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAClE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAClF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAEhG,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB,gBAAgB,GAChB,yBAAyB,GACzB,kBAAkB,CAAA"}
1
+ {"version":3,"file":"secret-types.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/secret-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAA;AAClH,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EAChB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAExH,KAAK,qBAAqB,GAAG,qBAAqB,GAChD,kBAAkB,GAClB,yBAAyB,GACzB,cAAc,GACd,eAAe,CAAA;AAEjB,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,wBAAwB,CAAA;AAE1G,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GACrD,qBAAqB,GACrB,iBAAiB,GACjB,yBAAyB,GACzB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,wBAAwB,GACxB,0BAA0B,CAAA;AAE5B,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;IACpD,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAClE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAClF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAEhG;;;GAGG;AACH,KAAK,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC5C,IAAI,EAAE,CAAC,CAAA;IACP,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,wFAAwF;AACxF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,cAAc,CAAC,GAAG,iBAAiB,CAAA;AAEvF,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,GAAG,8BAA8B,GAAG,uBAAuB,CAAA;AAEtH,wFAAwF;AACxF,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,oBAAoB,CAAC,GAAG,kBAAkB,CAAA;AAEpG,4FAA4F;AAC5F,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,GAAG,wBAAwB,CAAA;AAE1F,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB,gBAAgB,GAChB,yBAAyB,GACzB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,sBAAsB,GACtB,kBAAkB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"extract-security-scheme-secrets.d.ts","sourceRoot":"","sources":["../../../../src/request-example/context/security/extract-security-scheme-secrets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAA2C,MAAM,uCAAuC,CAAA;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAA;AAQlF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAExG,OAAO,KAAK,EAUV,0BAA0B,EAC3B,MAAM,iDAAiD,CAAA;AAExD,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAA;AAyLjF,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,GAEvC,QAAQ,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,EAC1D,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,cAAc,MAAM,EACpB,oBAAoB,MAAM,KACzB,0BA4DF,CAAA"}
1
+ {"version":3,"file":"extract-security-scheme-secrets.d.ts","sourceRoot":"","sources":["../../../../src/request-example/context/security/extract-security-scheme-secrets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EACV,SAAS,EAOV,MAAM,uCAAuC,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAA;AAQlF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAGxG,OAAO,KAAK,EAaV,0BAA0B,EAE3B,MAAM,iDAAiD,CAAA;AAExD,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAA;AAgMjF,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,GAEvC,QAAQ,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,EAC1D,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,cAAc,MAAM,EACpB,oBAAoB,MAAM,KACzB,0BA6HF,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { isObject } from '@scalar/helpers/object/is-object';
2
2
  import { objectEntries } from '@scalar/helpers/object/object-entries';
3
+ import { isEncryptionSchemeType, isSaslSchemeType } from '../../../request-example/builder/security/broker-scheme-types.js';
3
4
  /**
4
5
  * Maps x-scalar-secret fields to their corresponding input field names.
5
6
  * This allows us to fall back to config values when auth store secrets are not available.
@@ -32,6 +33,11 @@ const mergeFlowSecrets = (properties, configSecrets, authStoreSecrets = {}, oaut
32
33
  : authStoreValue || configValue || configInputValue || '';
33
34
  return [property, value];
34
35
  }));
36
+ /** Secret extensions are not part of the strict scheme types, so they are read the same way the OAuth flows read theirs */
37
+ const documentSecret = (scheme, property) => {
38
+ const value = scheme[property];
39
+ return typeof value === 'string' ? value : '';
40
+ };
35
41
  const extractRefreshTokenSecret = (authStoreSecrets = {}) => {
36
42
  const refreshToken = authStoreSecrets['x-scalar-secret-refresh-token'];
37
43
  if (typeof refreshToken === 'string') {
@@ -127,12 +133,19 @@ export const extractSecuritySchemeSecrets = (
127
133
  // Include the config fields
128
134
  scheme, authStore, name, documentSlug, oauth2RedirectUri) => {
129
135
  const secrets = authStore.getAuthSecrets(documentSlug, name);
136
+ // AsyncAPI broker schemes live outside the OpenAPI `SecuritySchemeObject` union, so their type
137
+ // (and any config credential fields) are read through this alias. Captured before the OpenAPI
138
+ // branches below, where `scheme` gets narrowed to `never` once all four OpenAPI types are handled.
139
+ const brokerScheme = scheme;
130
140
  // Handle API Key security schemes
131
141
  if (scheme.type === 'apiKey') {
132
142
  const storeSecrets = secrets?.type === 'apiKey' ? secrets : undefined;
133
143
  return {
134
144
  ...scheme,
135
- 'x-scalar-secret-token': storeSecrets?.['x-scalar-secret-token'] || scheme.value || '',
145
+ 'x-scalar-secret-token': storeSecrets?.['x-scalar-secret-token'] ||
146
+ documentSecret(scheme, 'x-scalar-secret-token') ||
147
+ scheme.value ||
148
+ '',
136
149
  };
137
150
  }
138
151
  // Handle HTTP Auth security schemes (e.g., Basic, Bearer)
@@ -140,9 +153,18 @@ scheme, authStore, name, documentSlug, oauth2RedirectUri) => {
140
153
  const storeSecrets = secrets?.type === 'http' ? secrets : undefined;
141
154
  return {
142
155
  ...scheme,
143
- 'x-scalar-secret-token': storeSecrets?.['x-scalar-secret-token'] || scheme.token || '',
144
- 'x-scalar-secret-username': storeSecrets?.['x-scalar-secret-username'] || scheme.username || '',
145
- 'x-scalar-secret-password': storeSecrets?.['x-scalar-secret-password'] || scheme.password || '',
156
+ 'x-scalar-secret-token': storeSecrets?.['x-scalar-secret-token'] ||
157
+ documentSecret(scheme, 'x-scalar-secret-token') ||
158
+ scheme.token ||
159
+ '',
160
+ 'x-scalar-secret-username': storeSecrets?.['x-scalar-secret-username'] ||
161
+ documentSecret(scheme, 'x-scalar-secret-username') ||
162
+ scheme.username ||
163
+ '',
164
+ 'x-scalar-secret-password': storeSecrets?.['x-scalar-secret-password'] ||
165
+ documentSecret(scheme, 'x-scalar-secret-password') ||
166
+ scheme.password ||
167
+ '',
146
168
  };
147
169
  }
148
170
  // Handle OAuth2 security schemes and all supported flows
@@ -173,5 +195,40 @@ scheme, authStore, name, documentSlug, oauth2RedirectUri) => {
173
195
  ...(objectEntries(extracted.flows).length ? { flows: extracted.flows } : {}),
174
196
  };
175
197
  }
198
+ // SASL-style schemes (userPassword, plain, scramSha256, scramSha512): username + password,
199
+ // with the same config fallbacks as HTTP basic.
200
+ if (isSaslSchemeType(brokerScheme.type)) {
201
+ const storeSecrets = secrets?.type === brokerScheme.type ? secrets : undefined;
202
+ return {
203
+ ...brokerScheme,
204
+ 'x-scalar-secret-username': storeSecrets?.['x-scalar-secret-username'] || brokerScheme.username || '',
205
+ 'x-scalar-secret-password': storeSecrets?.['x-scalar-secret-password'] || brokerScheme.password || '',
206
+ };
207
+ }
208
+ // X509: a client certificate + private key pair (PEM), stored in the auth store only.
209
+ if (brokerScheme.type === 'X509') {
210
+ const storeSecrets = secrets?.type === 'X509' ? secrets : undefined;
211
+ return {
212
+ ...brokerScheme,
213
+ 'x-scalar-secret-client-certificate': storeSecrets?.['x-scalar-secret-client-certificate'] || '',
214
+ 'x-scalar-secret-private-key': storeSecrets?.['x-scalar-secret-private-key'] || '',
215
+ };
216
+ }
217
+ // Encryption schemes (symmetricEncryption, asymmetricEncryption): a single key value in the token slot.
218
+ if (isEncryptionSchemeType(brokerScheme.type)) {
219
+ const storeSecrets = secrets?.type === brokerScheme.type ? secrets : undefined;
220
+ return {
221
+ ...brokerScheme,
222
+ 'x-scalar-secret-token': storeSecrets?.['x-scalar-secret-token'] || brokerScheme.token || '',
223
+ };
224
+ }
225
+ // GSSAPI (Kerberos): the service name the client authenticates against.
226
+ if (brokerScheme.type === 'gssapi') {
227
+ const storeSecrets = secrets?.type === 'gssapi' ? secrets : undefined;
228
+ return {
229
+ ...brokerScheme,
230
+ 'x-scalar-secret-service-name': storeSecrets?.['x-scalar-secret-service-name'] || '',
231
+ };
232
+ }
176
233
  return scheme;
177
234
  };
@@ -1,5 +1,5 @@
1
- export type { ApiKeyObjectSecret, BuildRequestData, BuildRequestFailureCode, BuildRequestResult, HttpObjectSecret, OAuth2ObjectSecret, OAuthFlowAuthorizationCodeSecret, OAuthFlowClientCredentialsSecret, OAuthFlowImplicitSecret, OAuthFlowPasswordSecret, OAuthFlowsObjectSecret, OpenIdConnectObjectSecret, RequestPayload, ResolveRequestFactoryUrlError, ResolveRequestFactoryUrlResult, SecuritySchemeObjectSecret, } from './builder/index.js';
2
- export { BUILD_REQUEST_FAILED, INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, type RequestFactory, type SerializedFormProperty, buildRequest, buildRequestSecurity, deSerializeParameter, deSerializeSchemaValue, filterGlobalCookie, getEnvironmentVariables, getExample, getExampleFromBody, getExampleFromSchema, getResolvedUrl, getSelectedBodyContentType, getServerVariables, isParamDisabled, requestFactory, resolveExecutableRequestUrl, resolveRequestFactoryUrl, serializeContentValue, serializeDeepObjectStyle, serializeFormPropertyWithEncoding, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './builder/index.js';
1
+ export type { ApiKeyObjectSecret, BuildRequestData, BuildRequestFailureCode, BuildRequestResult, EncryptionObjectSecret, GssapiObjectSecret, HttpObjectSecret, OAuth2ObjectSecret, OAuthFlowAuthorizationCodeSecret, OAuthFlowClientCredentialsSecret, OAuthFlowImplicitSecret, OAuthFlowPasswordSecret, OAuthFlowsObjectSecret, OpenIdConnectObjectSecret, RequestPayload, ResolveRequestFactoryUrlError, ResolveRequestFactoryUrlResult, SaslObjectSecret, SecuritySchemeObjectSecret, X509ObjectSecret, } from './builder/index.js';
2
+ export { BUILD_REQUEST_FAILED, INVALID_REQUEST_FACTORY_URL, MISSING_REQUEST_SERVER_BASE, type RequestFactory, type SerializedFormProperty, buildDottedNestedRowPredicate, buildRequest, buildRequestSecurity, coerceLeafValueToSchemaType, coerceUntypedValue, deSerializeParameter, deSerializeSchemaValue, filterGlobalCookie, getEnvironmentVariables, getExample, getExampleFromBody, getExampleFromSchema, getResolvedUrl, getSelectedBodyContentType, getServerVariables, isEncryptionSchemeType, isParamDisabled, isSaslSchemeType, requestFactory, resolveExecutableRequestUrl, resolveLeafSchema, resolveRequestFactoryUrl, serializeContentValue, serializeDeepObjectStyle, serializeFormPropertyWithEncoding, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle, } from './builder/index.js';
3
3
  export type { MergedSecuritySchemes } from './context/index.js';
4
4
  export { type BuildRequestExampleContext, combineParams, filterDisabledDefaultHeaders, getActiveEnvironment, getActiveProxyUrl, getDefaultHeaders, getRequestExampleContext, getSecurityRequirements, getSecuritySchemes, getSelectedSecurity, getSelectedServer, getServers, isAuthOptional, mergeSecurity, restoreConventionalDefaultHeaderNames, restoreConventionalHeaderName, } from './context/index.js';
5
5
  export { CONTEXT_FUNCTION_NAMES, type ContextFunctionEntry, type ContextFunctionName, POPULAR_CONTEXT_FUNCTION_KEYS, contextFunctions, getContextFunctionComment, isContextFunctionName, } from './functions.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,iCAAiC,EACjC,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EACL,KAAK,0BAA0B,EAC/B,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/request-example/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,gCAAgC,EAChC,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,6BAA6B,EAC7B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,iCAAiC,EACjC,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EACL,KAAK,0BAA0B,EAC/B,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,aAAa,EACb,qCAAqC,EACrC,6BAA6B,GAC9B,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,6BAA6B,EAC7B,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA"}