@scalar/workspace-store 0.74.0 → 0.75.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 (73) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/client.d.ts +3 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +55 -5
  5. package/dist/entities/auth/schema.d.ts +210 -0
  6. package/dist/entities/auth/schema.d.ts.map +1 -1
  7. package/dist/helpers/async-api-schema-resources/load-inline.d.ts +3 -1
  8. package/dist/helpers/async-api-schema-resources/load-inline.d.ts.map +1 -1
  9. package/dist/helpers/async-api-schema-resources/load-inline.js +20 -60
  10. package/dist/helpers/async-api-schema-resources/resolver.d.ts +12 -0
  11. package/dist/helpers/async-api-schema-resources/resolver.d.ts.map +1 -0
  12. package/dist/helpers/async-api-schema-resources/resolver.js +31 -0
  13. package/dist/helpers/async-api-schema-resources/resources.d.ts +3 -0
  14. package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -1
  15. package/dist/helpers/async-api-schema-resources/resources.js +17 -8
  16. package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts +9 -0
  17. package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts.map +1 -0
  18. package/dist/helpers/async-api-schema-resources/schema-wrappers.js +69 -0
  19. package/dist/helpers/async-api-schema-resources/track-edits.d.ts +3 -0
  20. package/dist/helpers/async-api-schema-resources/track-edits.d.ts.map +1 -0
  21. package/dist/helpers/async-api-schema-resources/track-edits.js +46 -0
  22. package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
  23. package/dist/helpers/resolve-async-api-schema.js +3 -1
  24. package/dist/helpers/use-async-api-schema-resources.d.ts +12 -0
  25. package/dist/helpers/use-async-api-schema-resources.d.ts.map +1 -0
  26. package/dist/helpers/use-async-api-schema-resources.js +24 -0
  27. package/dist/navigation/helpers/get-x-badges.d.ts +10 -0
  28. package/dist/navigation/helpers/get-x-badges.d.ts.map +1 -0
  29. package/dist/navigation/helpers/get-x-badges.js +26 -0
  30. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  31. package/dist/navigation/helpers/traverse-paths.js +3 -0
  32. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  33. package/dist/navigation/helpers/traverse-schemas.js +3 -0
  34. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  35. package/dist/navigation/helpers/traverse-tags.js +3 -0
  36. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  37. package/dist/navigation/helpers/traverse-webhooks.js +3 -0
  38. package/dist/plugins/bundler/async-api-schema-resources.d.ts +1 -1
  39. package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -1
  40. package/dist/plugins/bundler/async-api-schema-resources.js +9 -9
  41. package/dist/request-example/builder/build-request.d.ts.map +1 -1
  42. package/dist/request-example/builder/build-request.js +3 -2
  43. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +3 -0
  44. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  45. package/dist/request-example/builder/helpers/get-example-from-schema.js +132 -29
  46. package/dist/request-example/builder/request-factory.d.ts +2 -0
  47. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  48. package/dist/request-example/builder/security/build-request-security.d.ts +6 -4
  49. package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
  50. package/dist/request-example/builder/security/build-request-security.js +1 -0
  51. package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts +11 -0
  52. package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts.map +1 -0
  53. package/dist/schemas/extensions/security/x-scalar-token-prefix.js +8 -0
  54. package/dist/schemas/navigation.d.ts +49 -0
  55. package/dist/schemas/navigation.d.ts.map +1 -1
  56. package/dist/schemas/navigation.js +5 -0
  57. package/dist/schemas/reference-config/index.d.ts +42 -0
  58. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  59. package/dist/schemas/reference-config/settings.d.ts +42 -0
  60. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  61. package/dist/schemas/v3.1/strict/openapi-document.d.ts +1470 -0
  62. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  63. package/dist/schemas/v3.1/strict/security-scheme.d.ts +4 -1
  64. package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
  65. package/dist/schemas/v3.1/strict/security-scheme.js +2 -1
  66. package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
  67. package/dist/schemas/v3.2/openapi/index.js +2 -0
  68. package/dist/schemas/v3.2/strict/openapi-document.d.ts +1470 -0
  69. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  70. package/dist/schemas/v3.2/strict/security-scheme.d.ts +4 -1
  71. package/dist/schemas/v3.2/strict/security-scheme.d.ts.map +1 -1
  72. package/dist/schemas/v3.2/strict/security-scheme.js +2 -1
  73. package/package.json +8 -8
@@ -3,6 +3,7 @@ import { getTagKind } from '../../helpers/get-tag-kind.js';
3
3
  import { isHidden } from '../../helpers/is-hidden.js';
4
4
  import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
5
5
  import { getTagExternalDocs } from './get-tag-external-docs.js';
6
+ import { getXBadges } from './get-x-badges.js';
6
7
  import { getXKeysFromObject } from './get-x-keys.js';
7
8
  import { getTag } from './get-tag.js';
8
9
  /** Creates a traversed tag entry from an OpenAPI tag object.
@@ -24,6 +25,7 @@ const createTagEntry = ({ tag, generateId, children, isGroup = false, isTagGroup
24
25
  });
25
26
  // `summary` is the OpenAPI 3.2 display label; `x-displayName` keeps precedence for backwards compatibility.
26
27
  const externalDocs = getTagExternalDocs(tag);
28
+ const badges = getXBadges(tag);
27
29
  const title = tag['x-displayName'] ?? tag.summary ?? tag.name ?? 'Untitled Tag';
28
30
  // Update the order of the children based on the items
29
31
  // This will ensure that the sort order is always in sync with the items
@@ -40,6 +42,7 @@ const createTagEntry = ({ tag, generateId, children, isGroup = false, isTagGroup
40
42
  // Real OpenAPI 3.2 nested-tag sections keep this unset and render their summary heading.
41
43
  ...(isTagGroup ? { isTagGroup: true } : {}),
42
44
  isWebhooks: false,
45
+ ...(badges ? { badges } : {}),
43
46
  type: 'tag',
44
47
  xKeys: getXKeysFromObject(unpackProxyObject(tag)),
45
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;AA4DzG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,6EAM1B;IACD,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,wBAAwB,EAAE,MAAM,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,gBAAgB,EAwDnB,CAAA"}
1
+ {"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;AA8DzG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,6EAM1B;IACD,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,wBAAwB,EAAE,MAAM,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,gBAAgB,EAwDnB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { forEachPathItemOperation, getPathItemOperationKey } from '../../helpers/for-each-path-item-operation.js';
2
2
  import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
3
3
  import { isHidden } from '../../helpers/is-hidden.js';
4
+ import { getXBadges } from './get-x-badges.js';
4
5
  import { isDeprecatedOperation } from './traverse-paths.js';
5
6
  import { getNavigationTagNames } from './get-navigation-tag-names.js';
6
7
  import { getTag } from './get-tag.js';
@@ -24,6 +25,7 @@ const createWebhookEntry = ({ ref, method, name, title, generateId, parentTag, w
24
25
  parentTag,
25
26
  parentId: parentId,
26
27
  });
28
+ const badges = getXBadges(webhook);
27
29
  const entry = {
28
30
  id,
29
31
  title,
@@ -32,6 +34,7 @@ const createWebhookEntry = ({ ref, method, name, title, generateId, parentTag, w
32
34
  method: method,
33
35
  type: 'webhook',
34
36
  isDeprecated,
37
+ ...(badges ? { badges } : {}),
35
38
  };
36
39
  return entry;
37
40
  };
@@ -1,4 +1,4 @@
1
1
  import type { LifecyclePlugin } from '@scalar/json-magic/bundle';
2
- /** Load native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
2
+ /** Defer native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
3
3
  export declare const asyncApiSchemaResources: () => LifecyclePlugin;
4
4
  //# sourceMappingURL=async-api-schema-resources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-api-schema-resources.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/async-api-schema-resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,2GAA2G;AAC3G,eAAO,MAAM,uBAAuB,QAAO,eAe1C,CAAA"}
1
+ {"version":3,"file":"async-api-schema-resources.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/async-api-schema-resources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,4GAA4G;AAC5G,eAAO,MAAM,uBAAuB,QAAO,eAc1C,CAAA"}
@@ -1,18 +1,18 @@
1
- import { createSchemaResourceLoader } from '../../helpers/async-api-schema-resources/resources.js';
2
- /** Load native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
1
+ import { isObject } from '@scalar/helpers/object/is-object';
2
+ import { deferSchemaResources } from '../../helpers/async-api-schema-resources/resources.js';
3
+ /** Defer native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
3
4
  export const asyncApiSchemaResources = () => {
4
- const load = createSchemaResourceLoader();
5
5
  return {
6
6
  type: 'lifecycle',
7
- onBeforeNodeProcess: async (node, context) => {
7
+ onBeforeNodeProcess: (node, context) => {
8
8
  if (context.referenceContext !== 'asyncapi-schema' || typeof node.schemaFormat !== 'string' || '$ref' in node)
9
9
  return;
10
- // Serialized workspace/SSR graphs carry their origin through relocation. Authored copies are inert
11
- // data: readers validate and bound them, no credentials or loader capabilities are restored here.
12
- // Editable-document cleanup removes these graphs before an authored change is ingested again.
13
- if (node['x-scalar-schema-resources'] !== undefined)
10
+ // Completed server graphs stay portable. Deferred metadata must use the actual containing file,
11
+ // since its origin controls future downloads and may have been supplied by the document author.
12
+ const existing = node['x-scalar-schema-resources'];
13
+ if (existing !== undefined && !(isObject(existing) && existing.deferred === true))
14
14
  return;
15
- const resources = await load(node.schemaFormat, node.schema, context.origin, context.loaders);
15
+ const resources = deferSchemaResources(node.schemaFormat, context.origin);
16
16
  if (resources)
17
17
  node['x-scalar-schema-resources'] = resources;
18
18
  },
@@ -1 +1 @@
1
- {"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,YAC7B,cAAc,gBACT,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACnB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,YACd,cAAc,WACd;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,kBASF,CAAA"}
1
+ {"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/build-request.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAQnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAA;AAC/E,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,uDAAuD,CAAA;AAK9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAwClD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,YAC7B,cAAc,gBACT,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACnB;IAAE,6BAA6B,CAAC,EAAE,OAAO,CAAA;CAAE,KAC3D,MAyBF,CAAA;AAED;;;;;KAKK;AACL,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,cAAc,EAAE,cAAc,CAAA;IAC9B,2BAA2B;IAC3B,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,EAAG,sBAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAAG,6BAA6B,GAAG,OAAO,oBAAoB,CAAA;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;AAElF,eAAO,MAAM,YAAY,YACd,cAAc,WACd;IACP,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC,KACA,kBASF,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { formatTokenPrefix } from '@scalar/helpers/http/format-token-prefix';
1
2
  import { isHttpMethod } from '@scalar/helpers/http/is-http-method';
2
3
  import { X_SCALAR_DATE, X_SCALAR_DNT, X_SCALAR_REFERER, X_SCALAR_USER_AGENT } from '@scalar/helpers/http/scalar-headers';
3
4
  import { replaceEnvVariables } from '@scalar/helpers/regex/replace-variables';
@@ -25,7 +26,7 @@ const formatSecurityValue = (security, replace) => {
25
26
  // Normalize pasted tokens after resolving variables, which may also contain surrounding whitespace.
26
27
  return `Bearer ${substitutedValue.trim()}`;
27
28
  }
28
- return substitutedValue;
29
+ return formatTokenPrefix(substitutedValue, security.tokenPrefix);
29
30
  };
30
31
  const createEnvReplaceFn = (envVariables) => {
31
32
  return (value) => {
@@ -135,7 +136,7 @@ const buildRequestInner = (request, options) => {
135
136
  // Format the security value based on its authentication scheme.
136
137
  // - For 'basic': prefix with 'Basic' and base64-encode the value (username:password).
137
138
  // - For 'bearer': prefix with 'Bearer'.
138
- // - Otherwise: use the substituted value as is (for API keys, etc).
139
+ // - Otherwise: apply any configured API-key prefix to the substituted credential.
139
140
  const securityValue = formatSecurityValue(security, replace);
140
141
  if (security.in === 'header') {
141
142
  // Set the header (use replaced header name so {{ env }} placeholders work)
@@ -60,6 +60,9 @@ declare const generateExampleFromSchema: (schema: SchemaObject, options?: GetExa
60
60
  /**
61
61
  * Generate data, optionally retaining the exact schema decisions for another output format.
62
62
  * Treat returned values as read-only: cached results and padded items can share object references.
63
+ *
64
+ * An example too large to render at full depth is rendered at the deepest depth that fits instead, so
65
+ * every branch is cut at the same level rather than the first ones using up the budget.
63
66
  */
64
67
  export declare const getExampleFromSchema: (schema: SchemaObject, options?: GetExampleFromSchemaOptions, context?: Parameters<typeof generateExampleFromSchema>[2]) => unknown;
65
68
  export {};
@@ -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":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAG1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAob9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AAyvBD,sEAAsE;AACtE,MAAM,MAAM,2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,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA8BF,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":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAG1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAod9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AA0wBD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,4DAA4D;IAC5D,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,mFAAmF;IACnF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,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;AAygBD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,yBAAyB,WACrB,YAAY,YACV,2BAA2B,sGAUlC,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;IAC1B,4FAA4F;IAC5F,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,+GAA+G;IAC/G,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAC,KACD,OAgUF,CAAA;AA+ED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,WACvB,YAAY,YACV,2BAA2B,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA+BF,CAAA"}
@@ -13,6 +13,20 @@ import { generateContainsArray, getArrayDialect } from './array-contains.js';
13
13
  import { EXAMPLE_EVALUATION } from './example-evaluation.js';
14
14
  /** Maximum recursion depth to prevent infinite loops in circular references */
15
15
  const MAX_LEVELS_DEEP = 10;
16
+ /**
17
+ * How many schemas one example may visit at full depth. An example that fits is rendered exactly as the
18
+ * depth cap alone would render it.
19
+ *
20
+ * The depth cap bounds how deep the walk goes, not how wide. References to schemas that reference each
21
+ * other branch at every level, so a handful of them per schema is enough for the walk to never finish.
22
+ * The largest examples in big real-world documents (Stripe, GitHub, Kubernetes) stay just below this.
23
+ */
24
+ const MAX_EXAMPLE_VISITS = 10_000;
25
+ /**
26
+ * How many schemas each shallower attempt may visit once an example does not fit at full depth. An example
27
+ * this large is already long to read, and up to nine of these attempts can run for a single example.
28
+ */
29
+ const MAX_REDUCED_EXAMPLE_VISITS = 2_000;
16
30
  /** Default name used for additional properties when no custom name is provided */
17
31
  const DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty';
18
32
  /**
@@ -117,17 +131,28 @@ const guessFromFormat = (schema, makeUpRandomData = false, fallback = '') => {
117
131
  */
118
132
  const resultCache = new WeakMap();
119
133
  /**
120
- * Set once the depth cap has truncated something in the current top-level call.
134
+ * Set once the depth cap has truncated something in the current attempt, or the attempt ran out of visits.
121
135
  *
122
136
  * A truncated value only holds at the level it was produced at, but `resultCache` keys carry no level,
123
137
  * so a value assembled around one must not be stored. Composition reaches that case: an `allOf` member
124
138
  * climbs a level without growing `schemaPath`, so a schema rendered just above the cap in one chain
125
139
  * shares its key with the same schema used at the top of a document, and the shallow use is served the
126
140
  * truncated result. Widening the key would cost the cache its hits everywhere, so storing simply stops
127
- * for the rest of the call instead. The walk is synchronous, so resetting at level 0 scopes this to one
128
- * top-level call.
141
+ * for the rest of the attempt instead. The walk is synchronous, so resetting at level 0 scopes this to one
142
+ * attempt.
129
143
  */
130
144
  let truncated = false;
145
+ /** The depth cap of the attempt in progress. */
146
+ let levelsDeep = MAX_LEVELS_DEEP;
147
+ /** Schemas the attempt in progress may still visit. Below zero, the attempt has been abandoned. */
148
+ let visitsLeft = MAX_EXAMPLE_VISITS;
149
+ /** Whether an attempt is in progress, so that the calls it makes join it instead of starting another. */
150
+ let isGenerating = false;
151
+ /**
152
+ * What the attempt in progress has cached. An abandoned attempt removes its entries: they would make the
153
+ * next call for the same schema cheaper, and so give it a different example than this one.
154
+ */
155
+ let attemptCacheEntries = [];
131
156
  /** Prevent cached containers from retaining generated dates and times across calls. */
132
157
  let generatedCurrentTime = false;
133
158
  /** Cache required property names per parent schema for O(1) membership checks */
@@ -173,6 +198,7 @@ const cache = (schema, result, cacheKey, skip = false) => {
173
198
  const cacheMap = resultCache.get(rawSchema) ?? new Map();
174
199
  if (cacheMap) {
175
200
  cacheMap.set(cacheKey, result);
201
+ attemptCacheEntries.push([cacheMap, cacheKey]);
176
202
  }
177
203
  resultCache.set(rawSchema, cacheMap);
178
204
  return result;
@@ -540,7 +566,7 @@ const handleObjectSchema = (schema, options, level, seen, cacheKey, schemaPath,
540
566
  : undefined);
541
567
  // Past the cap only the properties the object requires are rendered: optional ones are what the cap
542
568
  // exists to stop descending into. Composition members share the names of the object they belong to.
543
- const required = level > MAX_LEVELS_DEEP
569
+ const required = level > levelsDeep
544
570
  ? (memberRequiredScope ?? getCompositionRequiredNames(schema, options, schemaPath, level, seen, dynamicScope))
545
571
  : undefined;
546
572
  if ('properties' in schema && schema.properties) {
@@ -696,9 +722,21 @@ const readArrayLengthBound = (value, fallback) => typeof value === 'number' && N
696
722
  /** Recognize an array described by its item keywords when no type was declared. */
697
723
  const inferArrayType = (schema) => !('properties' in schema) && ('items' in schema || 'prefixItems' in schema) ? 'array' : undefined;
698
724
  /** Apply the same explicit-type and inference precedence at either union selection site. */
699
- const getSelectedType = (variant, holder) => (variant && 'type' in variant ? variant.type : undefined) ??
700
- ('type' in holder ? holder.type : undefined) ??
701
- (hasUnencodedJsonContent(holder) ? 'string' : ((variant && inferArrayType(variant)) ?? inferArrayType(holder)));
725
+ const getSelectedType = (variant, holder) => {
726
+ const explicitSchema = variant && 'type' in variant && variant.type !== undefined ? variant : holder;
727
+ const type = 'type' in explicitSchema ? explicitSchema.type : undefined;
728
+ if (Array.isArray(type)) {
729
+ const named = type.filter((name) => name !== 'null');
730
+ // Only normalize containers whose own keywords can generate a value; unconstrained lists keep their fallback.
731
+ if (named.length === 1 &&
732
+ ((named[0] === 'object' && 'properties' in explicitSchema) ||
733
+ (named[0] === 'array' && ('items' in explicitSchema || 'prefixItems' in explicitSchema)))) {
734
+ return named[0];
735
+ }
736
+ }
737
+ return (type ??
738
+ (hasUnencodedJsonContent(holder) ? 'string' : ((variant && inferArrayType(variant)) ?? inferArrayType(holder))));
739
+ };
702
740
  /** These keywords describe values without restricting which values the schema accepts. */
703
741
  const ITEM_ANNOTATIONS = new Set([
704
742
  '$ref',
@@ -1007,24 +1045,29 @@ const MAX_DEPTH_EXCEEDED = '[Max Depth Exceeded]';
1007
1045
  /** How long a chain of composition wrappers may be unwrapped before the stack becomes the concern. */
1008
1046
  const MAX_COMPOSITION_DEPTH = MAX_LEVELS_DEEP * 5;
1009
1047
  /**
1010
- * How deep the walk keeps going past `MAX_LEVELS_DEEP` to fill the properties a truncated object requires.
1048
+ * How deep the walk goes to fill what a truncated object requires, as a multiple of the depth cap.
1011
1049
  *
1012
1050
  * Past the cap the walk still renders objects, but only their required properties, so a strict decoder
1013
- * reading the example finds every key it insists on. This level bounds that, well below the XML
1014
- * serializer's depth limit of 50 (which discards the whole body when crossed), and past it objects
1051
+ * reading the example finds every key it insists on. At full depth this stops at level 20, well below the
1052
+ * XML serializer's depth limit of 50 (which discards the whole body when crossed), and past it objects
1015
1053
  * stand in empty again.
1016
1054
  */
1017
- const MAX_REQUIRED_LEVELS_DEEP = MAX_LEVELS_DEEP * 2;
1055
+ const REQUIRED_LEVELS_FACTOR = 2;
1018
1056
  /**
1019
- * How many schemas the walk may enter past `MAX_LEVELS_DEEP` in one top-level call.
1057
+ * How many schemas the walk may enter past the depth cap in one attempt.
1020
1058
  *
1021
1059
  * Cycle guards stop a schema that requires itself, but not a chain of distinct schemas that each point
1022
1060
  * at the next one twice, through two required properties or an `allOf` that lists the same member
1023
1061
  * twice: the work doubles with every link. Once the budget is spent, objects stand in empty.
1024
1062
  */
1025
1063
  const MAX_REQUIRED_STEPS = 10_000;
1026
- /** Schemas the walk may still enter past `MAX_LEVELS_DEEP` in the current top-level call. */
1064
+ /** Schemas the walk may still enter past the depth cap in the current attempt. */
1027
1065
  let requiredSteps = MAX_REQUIRED_STEPS;
1066
+ /**
1067
+ * How many steps of the search for required properties cost an attempt one visit. Ordinary compositions
1068
+ * take a few steps and cost nothing; one that keeps exhausting the search soon uses up the attempt.
1069
+ */
1070
+ const REQUIRED_STEPS_PER_VISIT = 25;
1028
1071
  /** Cache requirements within one walk; generated discriminator values may select a new branch next time. */
1029
1072
  let compositionRequiredNamesCache = new WeakMap();
1030
1073
  /** Values are reused only within one call; generated dates and traversal contexts must not leak across calls. */
@@ -1131,7 +1174,7 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
1131
1174
  const keyword = current.schema.oneOf ? 'oneOf' : current.schema.anyOf ? 'anyOf' : undefined;
1132
1175
  if (keyword) {
1133
1176
  const discriminator = current.schema.discriminator;
1134
- const requiredOnly = level + current.depth > MAX_LEVELS_DEEP;
1177
+ const requiredOnly = level + current.depth > levelsDeep;
1135
1178
  const omittedDiscriminator = requiredOnly &&
1136
1179
  discriminator?.defaultMapping !== undefined &&
1137
1180
  // The negative level gathers shared requirements without evaluating discriminator values.
@@ -1182,6 +1225,8 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
1182
1225
  }
1183
1226
  }
1184
1227
  }
1228
+ // A long search does the work of many visits, so the attempt pays for it.
1229
+ visitsLeft -= Math.floor(Math.min(MAX_REQUIRED_STEPS, MAX_REQUIRED_STEPS - steps) / REQUIRED_STEPS_PER_VISIT);
1185
1230
  if (dynamicScope.length === 0) {
1186
1231
  const contexts = compositionRequiredNamesCache.get(root) ?? new Map();
1187
1232
  contexts.set(cacheKey, names);
@@ -1190,7 +1235,7 @@ const getCompositionRequiredNames = (schema, options, schemaPath, level, seen, d
1190
1235
  return names;
1191
1236
  };
1192
1237
  /**
1193
- * Whether the walk keeps rendering a schema past `MAX_LEVELS_DEEP` to fill its required properties.
1238
+ * Whether the walk keeps rendering a schema past the depth cap to fill its required properties.
1194
1239
  *
1195
1240
  * Only an object or composition with a property marked `required` qualifies, either somewhere in its
1196
1241
  * own compositions or, for a composition member, in the object it belongs to (`requiredScope`):
@@ -1389,7 +1434,7 @@ const hasUnencodedJsonContent = (schema) => {
1389
1434
  * @returns An example value for the given schema.
1390
1435
  */
1391
1436
  const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, name, seen = new WeakSet(), schemaPath = [], dynamicScope = [], requiredScope, isRequiredProperty = false, } = {}) => {
1392
- // Cache restrictions only apply to the current traversal, so every top-level call starts clean.
1437
+ // Cache restrictions only apply to the current traversal, so every attempt starts clean.
1393
1438
  if (level === 0) {
1394
1439
  truncated = false;
1395
1440
  generatedCurrentTime = false;
@@ -1397,6 +1442,12 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1397
1442
  compositionRequiredNamesCache = new WeakMap();
1398
1443
  discriminatorExamples = new WeakMap();
1399
1444
  }
1445
+ // The attempt is over budget and will be discarded. Anything finished from here on is missing children,
1446
+ // so it must not reach the cache either.
1447
+ if (--visitsLeft < 0) {
1448
+ truncated = true;
1449
+ return undefined;
1450
+ }
1400
1451
  // Resolve any $ref references to get the actual schema
1401
1452
  const _schema = resolve.schema(schema);
1402
1453
  if (!isDefined(_schema)) {
@@ -1437,7 +1488,9 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1437
1488
  }
1438
1489
  seen.add(targetValue);
1439
1490
  /** Make the cache key unique per options and schema path */
1440
- const cacheKey = getOptionsCacheKey(options, level) + (schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '');
1491
+ const cacheKey = getOptionsCacheKey(options, level) +
1492
+ (levelsDeep === MAX_LEVELS_DEEP ? '' : `:depth:${levelsDeep}`) +
1493
+ (schemaPath.length > 0 ? `:path:${schemaPath.join('.')}` : '');
1441
1494
  // Check cache first for performance - avoid recomputing the same schema (skipped under a dynamic scope)
1442
1495
  if (!skipCache) {
1443
1496
  const cached = resultCache.get(targetValue)?.get(cacheKey);
@@ -1498,15 +1551,16 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1498
1551
  // every rule that applies at a shallower level (read/write omission, composition selection, variables,
1499
1552
  // binary files) applies to them too. Required primitive compositions use the same walk so their
1500
1553
  // members retain those rules as well; arrays and anything past the bounds still stand in.
1501
- if (level > MAX_LEVELS_DEEP) {
1502
- if ((!(isRequiredProperty && getEmptyContainer(_schema) === undefined) &&
1503
- !fillsRequiredProperties(_schema, requiredScope, options, schemaPath, level, seen, dynamicScope)) ||
1504
- level > MAX_REQUIRED_LEVELS_DEEP ||
1505
- requiredSteps <= 0) {
1554
+ if (level > levelsDeep) {
1555
+ if (level > levelsDeep * REQUIRED_LEVELS_FACTOR ||
1556
+ requiredSteps <= 0 ||
1557
+ (!(isRequiredProperty && getEmptyContainer(_schema) === undefined) &&
1558
+ !fillsRequiredProperties(_schema, requiredScope, options, schemaPath, level, seen, dynamicScope))) {
1506
1559
  seen.delete(targetValue);
1507
1560
  // Deliberately not cached: the value holds only at this level, and the cache key carries none.
1508
1561
  // Constraint-only composition members must not replace a sibling's required fields with the depth marker.
1509
- const fallback = isRequiredProperty || requiredScope?.size ? null : MAX_DEPTH_EXCEEDED;
1562
+ // Neither must a shallower attempt show it where a full walk would have rendered the schema.
1563
+ const fallback = isRequiredProperty || requiredScope?.size || level <= MAX_LEVELS_DEEP ? null : MAX_DEPTH_EXCEEDED;
1510
1564
  return getMaxDepthValue(_schema, options, schemaPath, undefined, fallback);
1511
1565
  }
1512
1566
  requiredSteps--;
@@ -1526,7 +1580,8 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1526
1580
  const selectedVariant = getSelectedVariant(_schema, options, schemaPath);
1527
1581
  if (selectedComposition && selectedVariant) {
1528
1582
  const selectedType = getSelectedType(selectedVariant, _schema);
1529
- if (selectedType !== undefined && selectedType !== 'object') {
1583
+ // A declared null must be selected directly: merging it into shared object properties loses it.
1584
+ if (selectedType !== undefined && (selectedType !== 'object' || getDeclaredValue(selectedVariant) === null)) {
1530
1585
  if (seen.has(getSchemaCacheTarget(selectedVariant))) {
1531
1586
  seen.delete(targetValue);
1532
1587
  return undefined;
@@ -1663,11 +1718,8 @@ const asBinaryFile = (schema, value, options, schemaPath = []) => {
1663
1718
  }
1664
1719
  return value;
1665
1720
  };
1666
- /**
1667
- * Generate data, optionally retaining the exact schema decisions for another output format.
1668
- * Treat returned values as read-only: cached results and padded items can share object references.
1669
- */
1670
- export const getExampleFromSchema = (schema, options, context = {}) => {
1721
+ /** Generate data for one schema within the attempt in progress. */
1722
+ const generateWithCapture = (schema, options, context = {}) => {
1671
1723
  if (schema && typeof schema === 'object' && '$schema' in schema && typeof schema.$schema === 'string') {
1672
1724
  options = { ...options, jsonSchemaDialect: schema.$schema };
1673
1725
  }
@@ -1700,3 +1752,54 @@ export const getExampleFromSchema = (schema, options, context = {}) => {
1700
1752
  capture.stack.pop();
1701
1753
  }
1702
1754
  };
1755
+ /** Walks at one depth cap, returning nothing when the walk does not fit in the given number of visits. */
1756
+ const attemptExample = (schema, options, context, depth, visits) => {
1757
+ levelsDeep = depth;
1758
+ visitsLeft = visits;
1759
+ attemptCacheEntries = [];
1760
+ const value = generateWithCapture(schema, options, context);
1761
+ if (visitsLeft < 0) {
1762
+ for (const [entries, key] of attemptCacheEntries) {
1763
+ entries.delete(key);
1764
+ }
1765
+ return undefined;
1766
+ }
1767
+ return { value, evaluation: options?.[EXAMPLE_EVALUATION]?.root };
1768
+ };
1769
+ /**
1770
+ * Generate data, optionally retaining the exact schema decisions for another output format.
1771
+ * Treat returned values as read-only: cached results and padded items can share object references.
1772
+ *
1773
+ * An example too large to render at full depth is rendered at the deepest depth that fits instead, so
1774
+ * every branch is cut at the same level rather than the first ones using up the budget.
1775
+ */
1776
+ export const getExampleFromSchema = (schema, options, context = {}) => {
1777
+ if (isGenerating) {
1778
+ return generateWithCapture(schema, options, context);
1779
+ }
1780
+ isGenerating = true;
1781
+ try {
1782
+ const full = attemptExample(schema, options, context, MAX_LEVELS_DEEP, MAX_EXAMPLE_VISITS);
1783
+ if (full) {
1784
+ return full.value;
1785
+ }
1786
+ // At depth zero every child stands in, so this walk is only as long as the root is wide.
1787
+ let kept = attemptExample(schema, options, context, 0, Number.POSITIVE_INFINITY);
1788
+ for (let depth = 1; depth < MAX_LEVELS_DEEP; depth++) {
1789
+ const attempt = attemptExample(schema, options, context, depth, MAX_REDUCED_EXAMPLE_VISITS);
1790
+ if (!attempt) {
1791
+ break;
1792
+ }
1793
+ kept = attempt;
1794
+ }
1795
+ const capture = options?.[EXAMPLE_EVALUATION];
1796
+ if (capture) {
1797
+ // The last walk may be one that was abandoned.
1798
+ capture.root = kept.evaluation;
1799
+ }
1800
+ return kept.value;
1801
+ }
1802
+ finally {
1803
+ isGenerating = false;
1804
+ }
1805
+ };
@@ -157,6 +157,8 @@ export type RequestFactory = {
157
157
  * List of all security requirements for this request (e.g., API key, OAuth2, etc.)
158
158
  * Each entry reflects a selected Security Scheme.
159
159
  * Values (e.g., tokens, secrets) may still be unsubstituted at this point.
160
+ * Header API-key prefixes are carried separately in `tokenPrefix`. Consumers using
161
+ * `disableSecurity` must resolve variables and apply authentication formatting themselves.
160
162
  */
161
163
  security: BuildRequestSecurityResult[];
162
164
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAA;AAG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,cAAc,wMAcxB,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CAgFxB,CAAA"}
1
+ {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,2DAA2D,CAAA;AAClE,OAAO,KAAK,EAAE,0BAA0B,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,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE5C;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;QACf;;;WAGG;QACH,UAAU,EAAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,wMAcxB,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CAgFxB,CAAA"}
@@ -24,9 +24,9 @@ import type { SecuritySchemeObjectSecret } from './secret-types.js';
24
24
  * - `'bearer'`: HTTP Bearer token.
25
25
  * - Not present for schemes without a special format (e.g., generic API keys).
26
26
  *
27
- * - `value`: The fully resolved secret value to use in the request.
28
- * - This may already include necessary prefixes (e.g., "Bearer x", "Basic y"),
29
- * or be a direct value depending on the scheme and usage.
27
+ * - `value`: The raw credential, before environment substitution or authentication formatting.
28
+ * - HTTP Basic credentials use `username:password`; HTTP Bearer and API keys carry the token.
29
+ * - Apply `format` or `tokenPrefix` after resolving credential variables.
30
30
  *
31
31
  * NOTE: This type does not capture UI display info, secret labels, or environment binding.
32
32
  * It is intended purely for producing the final request input object. Multiple
@@ -40,8 +40,10 @@ export type BuildRequestSecurityResult = {
40
40
  name: string;
41
41
  /** Format code for HTTP schemes (e.g., 'basic' | 'bearer'), if relevant */
42
42
  format?: 'basic' | 'bearer';
43
+ /** Explicit header API-key prefix, applied after resolving credential variables. */
44
+ tokenPrefix?: string;
43
45
  /**
44
- * The fully resolved authentication value to use (may include tokens, encoded credentials, etc.)
46
+ * The raw credential. Resolve environment variables, then apply `format` or `tokenPrefix` before sending.
45
47
  */
46
48
  value: string;
47
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;yBACnC,0BAA0B,EAAE;AACrD,qEAAqE;mCAEpE,0BAA0B,EA4F5B,CAAA"}
1
+ {"version":3,"file":"build-request-security.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/security/build-request-security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8DAA8D;IAC9D,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;IACjC,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC3B,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB;AAC/B,4DAA4D;yBACnC,0BAA0B,EAAE;AACrD,qEAAqE;mCAEpE,0BAA0B,EA6F5B,CAAA"}
@@ -18,6 +18,7 @@ emptyTokenPlaceholder = '') => {
18
18
  in: scheme.in,
19
19
  name: scheme.name,
20
20
  value,
21
+ ...(scheme['x-scalar-token-prefix'] ? { tokenPrefix: scheme['x-scalar-token-prefix'] } : {}),
21
22
  });
22
23
  }
23
24
  if (scheme.in === 'query') {
@@ -0,0 +1,11 @@
1
+ /** A prefix added to header API keys only, separated from the credential by one space. */
2
+ export type XScalarTokenPrefix = {
3
+ 'x-scalar-token-prefix'?: string;
4
+ };
5
+ export declare const XScalarTokenPrefixSchema: import("@scalar/typebox").TObject<{
6
+ 'x-scalar-token-prefix': import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
7
+ }>;
8
+ export declare const XScalarTokenPrefix: import("@scalar/validation").ObjectSchema<{
9
+ 'x-scalar-token-prefix': import("@scalar/validation").OptionalSchema<import("@scalar/validation").StringSchema>;
10
+ }>;
11
+ //# sourceMappingURL=x-scalar-token-prefix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-scalar-token-prefix.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/security/x-scalar-token-prefix.ts"],"names":[],"mappings":"AAGA,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,wBAAwB;;EAEnC,CAAA;AAEF,eAAO,MAAM,kBAAkB;;EAE7B,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { Type } from '@scalar/typebox';
2
+ import { object, optional, string } from '@scalar/validation';
3
+ export const XScalarTokenPrefixSchema = Type.Object({
4
+ 'x-scalar-token-prefix': Type.Optional(Type.String()),
5
+ });
6
+ export const XScalarTokenPrefix = object({
7
+ 'x-scalar-token-prefix': optional(string()),
8
+ });