@scalar/oas-utils 0.4.32 → 0.5.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.
- package/CHANGELOG.md +32 -0
- package/dist/entities/cookie/cookie.d.ts +2 -17
- package/dist/entities/cookie/cookie.d.ts.map +1 -1
- package/dist/entities/environment/environment.d.ts +2 -14
- package/dist/entities/environment/environment.d.ts.map +1 -1
- package/dist/entities/shared/utility.d.ts +1 -1
- package/dist/entities/shared/utility.d.ts.map +1 -1
- package/dist/entities/spec/collection.d.ts +76 -501
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/operation.d.ts +60 -290
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/parameters.d.ts +33 -50
- package/dist/entities/spec/parameters.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.d.ts +161 -998
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +11 -6
- package/dist/entities/spec/request-examples.js.map +2 -2
- package/dist/entities/spec/requests.d.ts +102 -595
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/server.d.ts +12 -156
- package/dist/entities/spec/server.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.d.ts +37 -229
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/entities/spec/x-scalar-environments.d.ts +8 -56
- package/dist/entities/spec/x-scalar-environments.d.ts.map +1 -1
- package/dist/entities/spec/x-scalar-secrets.d.ts +2 -14
- package/dist/entities/spec/x-scalar-secrets.d.ts.map +1 -1
- package/dist/entities/workspace/workspace.d.ts +218 -98
- package/dist/entities/workspace/workspace.d.ts.map +1 -1
- package/dist/entities/workspace/workspace.js +4 -5
- package/dist/entities/workspace/workspace.js.map +2 -2
- package/dist/helpers/parse.js +1 -1
- package/dist/helpers/parse.js.map +2 -2
- package/dist/helpers/schema-model.d.ts +3 -3
- package/dist/helpers/schema-model.d.ts.map +1 -1
- package/dist/helpers/schema-model.js.map +1 -1
- package/dist/helpers/security/get-schemes.d.ts +27 -27
- package/dist/helpers/security/get-schemes.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/migration.js.map +2 -2
- package/dist/spec-getters/get-example-from-schema.d.ts +26 -23
- package/dist/spec-getters/get-example-from-schema.d.ts.map +1 -1
- package/dist/spec-getters/get-example-from-schema.js +330 -174
- package/dist/spec-getters/get-example-from-schema.js.map +2 -2
- package/package.json +9 -9
- package/dist/helpers/operation-to-har/index.d.ts +0 -2
- package/dist/helpers/operation-to-har/index.d.ts.map +0 -1
- package/dist/helpers/operation-to-har/index.js +0 -5
- package/dist/helpers/operation-to-har/index.js.map +0 -7
- package/dist/helpers/operation-to-har/operation-to-har.d.ts +0 -49
- package/dist/helpers/operation-to-har/operation-to-har.d.ts.map +0 -1
- package/dist/helpers/operation-to-har/operation-to-har.js +0 -68
- package/dist/helpers/operation-to-har/operation-to-har.js.map +0 -7
- package/dist/helpers/operation-to-har/process-body.d.ts +0 -12
- package/dist/helpers/operation-to-har/process-body.d.ts.map +0 -1
- package/dist/helpers/operation-to-har/process-body.js +0 -80
- package/dist/helpers/operation-to-har/process-body.js.map +0 -7
- package/dist/helpers/operation-to-har/process-parameters.d.ts +0 -19
- package/dist/helpers/operation-to-har/process-parameters.d.ts.map +0 -1
- package/dist/helpers/operation-to-har/process-parameters.js +0 -261
- package/dist/helpers/operation-to-har/process-parameters.js.map +0 -7
- package/dist/helpers/operation-to-har/process-security-schemes.d.ts +0 -15
- package/dist/helpers/operation-to-har/process-security-schemes.d.ts.map +0 -1
- package/dist/helpers/operation-to-har/process-security-schemes.js +0 -62
- package/dist/helpers/operation-to-har/process-security-schemes.js.map +0 -7
- package/dist/helpers/operation-to-har/process-server-url.d.ts +0 -6
- package/dist/helpers/operation-to-har/process-server-url.d.ts.map +0 -1
- package/dist/helpers/operation-to-har/process-server-url.js +0 -27
- package/dist/helpers/operation-to-har/process-server-url.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/spec-getters/get-example-from-schema.ts"],
|
|
4
|
-
"sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\nconst MAX_LEVELS_DEEP = 10\n/** Sets the max number of properties after the third level to prevent exponential horizontal growth */\nconst MAX_PROPERTIES = 10\n\n/** The default name for additional properties. */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'propertyName*'\n\n/** Pre-computed values to avoid expensive date operations */\nconst currentISOString = new Date().toISOString()\nconst currentDateString = currentISOString.split('T')[0]!\nconst currentTimeString = currentISOString.split('T')[1]!.split('.')[0]!\n\nconst genericExampleValues: Record<string, string> = {\n // 'date-time': '1970-01-01T00:00:00Z',\n 'date-time': currentISOString,\n // 'date': '1970-01-01',\n 'date': currentDateString,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n // 'time': '00:00:00Z',\n 'time': currentTimeString,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * We can use the `format` to generate some random values.\n */\nfunction guessFromFormat(schema: OpenAPIV3_1.SchemaObject, makeUpRandomData: boolean = false, fallback: string = '') {\n if (schema.format === 'binary') {\n return new File([''], 'filename')\n }\n return makeUpRandomData ? (genericExampleValues[schema.format ?? ''] ?? fallback) : ''\n}\n\n/** Map of all the results */\nconst resultCache = new WeakMap<Record<string, any>, any>()\n\n/** Store result in the cache, and return the result */\nfunction cache(schema: OpenAPIV3_1.SchemaObject, result: unknown) {\n // Avoid unnecessary WeakMap operations for primitive values\n if (typeof result !== 'object' || result === null) {\n return result\n }\n\n resultCache.set(schema, result)\n\n return result\n}\n\n/**\n * This function takes an OpenAPI schema and generates an example from it\n */\nexport const getExampleFromSchema = (\n _schema: OpenAPIV3_1.SchemaObject,\n options?: {\n /**\n * The fallback string for empty string values.\n * @default ''\n */\n emptyString?: string\n /**\n * Whether to use the XML tag names as keys\n * @default false\n */\n xml?: boolean\n /**\n * Whether to show read-only/write-only properties. Otherwise all properties are shown.\n * @default undefined\n */\n mode?: 'read' | 'write'\n /**\n * Dynamic values to add to the example.\n */\n variables?: Record<string, any>\n /**\n * Whether to omit empty and optional properties.\n * @default false\n */\n omitEmptyAndOptionalProperties?: boolean\n },\n level: number = 0,\n parentSchema?: OpenAPIV3_1.SchemaObject,\n name?: string,\n): any => {\n const schema = getResolvedRef(_schema)\n\n if (!isDefined(schema)) {\n return undefined\n }\n\n // Check if we have a cached result for this schema\n if (resultCache.has(schema)) {\n return resultCache.get(schema)\n }\n\n // Check depth limit\n if (level > MAX_LEVELS_DEEP) {\n return '[Max Depth Exceeded]'\n }\n\n // Sometimes, we just want the structure and no values.\n // But if `emptyString` is set, we do want to see some values.\n const makeUpRandomData = !!options?.emptyString\n\n // Early exits for simple cases\n // If the property is deprecated anyway, we don't want to show it.\n if (schema.deprecated) {\n return undefined\n }\n\n // Check if the property is read-only/write-only\n if ((options?.mode === 'write' && schema.readOnly) || (options?.mode === 'read' && schema.writeOnly)) {\n return undefined\n }\n\n // Use given variables as values\n if (schema['x-variable']) {\n const value = options?.variables?.[schema['x-variable']]\n\n // Return the value if it's defined\n if (value !== undefined) {\n // Type-casting\n if (schema.type === 'number' || schema.type === 'integer') {\n const numValue = Number.parseInt(value, 10)\n return cache(schema, numValue)\n }\n\n return cache(schema, value)\n }\n }\n\n // Use the first example, if there's an array\n if (Array.isArray(schema.examples) && schema.examples.length > 0) {\n return cache(schema, schema.examples[0])\n }\n\n // Use an example, if there's one\n if (schema.example !== undefined) {\n return cache(schema, schema.example)\n }\n\n // Use a default value, if there's one\n if (schema.default !== undefined) {\n return cache(schema, schema.default)\n }\n\n // Use a const value, if there's one\n if (schema.const !== undefined) {\n return cache(schema, schema.const)\n }\n\n // enum: [ 'available', 'pending', 'sold' ]\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return cache(schema, schema.enum[0])\n }\n\n // Check if the property is required\n const isObjectOrArray =\n schema.type === 'object' ||\n schema.type === 'array' ||\n !!schema.allOf?.at?.(0) ||\n !!schema.anyOf?.at?.(0) ||\n !!schema.oneOf?.at?.(0)\n if (!isObjectOrArray && options?.omitEmptyAndOptionalProperties === true) {\n const isRequired =\n schema.required === true ||\n parentSchema?.required === true ||\n parentSchema?.required?.includes(name ?? schema.title ?? '')\n\n if (!isRequired) {\n return undefined\n }\n }\n\n // Object\n if (schema.type === 'object' || schema.properties !== undefined) {\n const response: Record<string, any> = {}\n let propertyCount = 0\n\n // Regular properties - optimized iteration\n if (schema.properties !== undefined) {\n const propertyNames = Object.keys(schema.properties)\n const maxProps = level > 3 ? MAX_PROPERTIES : propertyNames.length\n\n for (const propertyName of propertyNames.slice(0, maxProps)) {\n const property = getResolvedRef(schema.properties[propertyName])\n\n if (!property) {\n continue\n }\n\n const propertyXmlTagName = options?.xml ? property?.xml?.name : undefined\n const value = getExampleFromSchema(property, options, level + 1, schema, propertyName)\n\n if (typeof value !== 'undefined') {\n response[propertyXmlTagName ?? propertyName] = value\n propertyCount++\n }\n }\n\n // Add truncation indicator if we hit the limit\n if (level > 3 && propertyCount >= MAX_PROPERTIES && propertyNames.length > MAX_PROPERTIES) {\n response['...'] = '[Additional Properties Truncated]'\n }\n }\n\n // Pattern properties (regex) - optimized iteration\n if (schema.patternProperties !== undefined) {\n for (const pattern of Object.keys(schema.patternProperties)) {\n const property = getResolvedRef(schema.patternProperties[pattern])\n if (!property) {\n continue\n }\n\n // Use the regex pattern as an example key\n response[pattern] = getExampleFromSchema(property, options, level + 1, schema, pattern)\n }\n }\n\n // Additional properties\n if (schema.additionalProperties !== undefined) {\n const anyTypeIsValid =\n // true\n schema.additionalProperties === true ||\n // or an empty object {}\n (typeof schema.additionalProperties === 'object' && !Object.keys(schema.additionalProperties).length)\n\n const additionalProperties = getResolvedRef(schema.additionalProperties)\n\n // Get the custom name for additional properties if available\n const additionalPropertiesName =\n typeof additionalProperties === 'object' &&\n additionalProperties['x-additionalPropertiesName'] &&\n typeof additionalProperties['x-additionalPropertiesName'] === 'string' &&\n additionalProperties['x-additionalPropertiesName'].trim().length > 0\n ? `${additionalProperties['x-additionalPropertiesName'].trim()}*`\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n if (anyTypeIsValid) {\n response[additionalPropertiesName] = 'anything'\n } else if (typeof additionalProperties === 'object') {\n response[additionalPropertiesName] = getExampleFromSchema(additionalProperties, options, level + 1)\n }\n }\n\n if (schema.anyOf?.[0]) {\n Object.assign(response, getExampleFromSchema(getResolvedRef(schema.anyOf[0]), options, level + 1))\n } else if (schema.oneOf?.[0] !== undefined) {\n Object.assign(response, getExampleFromSchema(getResolvedRef(schema.oneOf[0]), options, level + 1))\n } else if (schema.allOf?.[0]) {\n Object.assign(\n response,\n ...schema.allOf\n .filter(isDefined)\n .map((item: any) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema)),\n )\n }\n\n // Check if we need to wrap the result in an XML root element name\n if (options?.xml && schema.xml?.name && level === 0) {\n const wrappedResponse: Record<string, any> = {}\n wrappedResponse[schema.xml.name] = response\n return cache(schema, wrappedResponse)\n }\n\n return cache(schema, response)\n }\n\n // Array\n if (schema.type === 'array' || schema.items !== undefined) {\n const items = getResolvedRef(schema.items)\n const itemsXmlTagName = items?.xml?.name\n const wrapItems = !!(options?.xml && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName]: schema.example } : schema.example)\n }\n\n // Check whether the array has a anyOf, oneOf, or allOf rule\n if (items) {\n // First handle allOf separately since it needs special handling\n if (items.allOf) {\n const allOf = items.allOf.filter(isDefined)\n const firstItem = getResolvedRef(allOf[0])\n\n // If first item is an object type, merge all schemas\n if (firstItem?.type === 'object') {\n const combined = { type: 'object', allOf } as OpenAPIV3_1.SchemaObject\n\n const mergedExample = getExampleFromSchema(combined, options, level + 1, schema)\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: mergedExample }] : [mergedExample])\n }\n // For non-objects (like strings), collect all examples\n const examples = allOf\n .map((item: any) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema))\n .filter(isDefined)\n\n return cache(schema, wrapItems ? examples.map((example: any) => ({ [itemsXmlTagName]: example })) : examples)\n }\n\n // Handle other rules (anyOf, oneOf) - optimized\n if (items.anyOf || items.oneOf) {\n const ruleItems = items.anyOf || items.oneOf\n if (ruleItems && ruleItems.length > 0) {\n const firstItem = ruleItems[0]\n if (firstItem) {\n const exampleFromRule = getExampleFromSchema(getResolvedRef(firstItem), options, level + 1, schema)\n\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromRule }] : [exampleFromRule])\n }\n }\n }\n }\n\n // if it has type: 'object', or properties, it's an object\n const isObject = items?.type === 'object' || items?.properties !== undefined\n // if it has type: 'array', or items, it's an array\n const isArray = items?.type === 'array' || items?.items !== undefined\n\n if (items?.type || isObject || isArray) {\n const exampleFromSchema = getExampleFromSchema(items, options, level + 1)\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromSchema }] : [exampleFromSchema])\n }\n\n return cache(schema, [])\n }\n\n const exampleValues: Record<any, any> = {\n string: guessFromFormat(schema, makeUpRandomData, options?.emptyString),\n boolean: true,\n integer: schema.minimum ?? 1,\n number: schema.minimum ?? 1,\n array: [],\n }\n if (schema.type && !Array.isArray(schema.type) && exampleValues[schema.type] !== undefined) {\n return cache(schema, exampleValues[schema.type])\n }\n\n const discriminateSchema = schema.oneOf || schema.anyOf\n // Check if property has the `oneOf` | `anyOf` key\n if (Array.isArray(discriminateSchema) && discriminateSchema.length > 0) {\n // Find the first non-null type in the oneOf/anyOf array\n const firstNonNullItem = discriminateSchema.map((item) => getResolvedRef(item)).find((item) => item.type !== 'null')\n\n if (firstNonNullItem) {\n // Return an example for the first non-null item\n const result = getExampleFromSchema(firstNonNullItem, options, level + 1)\n return cache(schema, result)\n }\n\n // If all items are null, return null\n return cache(schema, null)\n }\n\n // Check if schema has the `allOf` key\n if (Array.isArray(schema.allOf)) {\n let example: any = null\n\n // Loop through all `allOf` schemas\n schema.allOf.forEach((allOfItem) => {\n // Return an example from the schema\n const newExample = getExampleFromSchema(getResolvedRef(allOfItem), options, level + 1)\n\n // Merge or overwrite the example\n example =\n typeof newExample === 'object' && typeof example === 'object'\n ? {\n ...(example ?? {}),\n ...newExample,\n }\n : Array.isArray(newExample) && Array.isArray(example)\n ? [...(example ?? {}), ...newExample]\n : newExample\n })\n\n return cache(schema, example)\n }\n\n // Check if schema is a union type\n if (Array.isArray(schema.type)) {\n // Return null if the type is nullable\n if (schema.type.includes('null')) {\n return cache(schema, null)\n }\n // Return an example for the first type in the union\n const exampleValue = exampleValues[schema.type[0] ?? '']\n if (exampleValue !== undefined) {\n return cache(schema, exampleValue)\n }\n }\n\n // Warn if the type is unknown \u2026\n // console.warn(`[getExampleFromSchema] Unknown property type \"${schema.type}\".`)\n\n // \u2026 and just return null for now.\n return cache(schema, null)\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { getRaw } from '@scalar/json-magic/magic-proxy'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackOverridesProxy } from '@scalar/workspace-store/helpers/overrides-proxy'\n\n/** Maximum recursion depth to prevent infinite loops in circular references */\nconst MAX_LEVELS_DEEP = 10\n\n/**\n * Maximum properties to include after level 3 to prevent exponential growth\n * in deeply nested object structures\n */\nconst MAX_PROPERTIES = 10\n\n/** Default name used for additional properties when no custom name is provided */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'propertyName*'\n\n/**\n * Pre-computed date/time values to avoid expensive Date operations on every call.\n * These are calculated once at module load time for better performance.\n */\nconst currentISOString = new Date().toISOString()\nconst currentDateString = currentISOString.split('T')[0]!\nconst currentTimeString = currentISOString.split('T')[1]!.split('.')[0]!\n\n/**\n * Mapping of OpenAPI string formats to example values.\n * Used to generate realistic examples for different string formats.\n */\nconst genericExampleValues: Record<string, string> = {\n 'date-time': currentISOString,\n 'date': currentDateString,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n 'time': currentTimeString,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * Generate example values for string types based on their format.\n * Special handling for binary format which returns a File object.\n */\nconst guessFromFormat = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean = false,\n fallback: string = '',\n): string | File => {\n // Handle binary format specially - return a File object\n if ('type' in schema && schema.type === 'string' && 'format' in schema && schema.format === 'binary') {\n return new File([''], 'filename')\n }\n\n // Return format-specific example if we have one and are making up data\n if (makeUpRandomData && 'format' in schema && schema.format) {\n return genericExampleValues[schema.format] ?? fallback\n }\n\n return fallback\n}\n\n/**\n * WeakMap cache for memoizing resolved example results.\n * Uses the resolved schema object as the key for efficient lookups.\n */\nconst resultCache = new WeakMap<object, unknown>()\n\n/** Cache required property names per parent schema for O(1) membership checks */\nconst requiredNamesCache = new WeakMap<object, ReadonlySet<string>>()\n\n/**\n * Retrieves the set of required property names from a schema.\n * Caches the result in a WeakMap for efficient lookups.\n */\nconst getRequiredNames = (parentSchema: OpenAPIV3_1.SchemaObject | undefined): ReadonlySet<string> | undefined => {\n if (!parentSchema) {\n return undefined\n }\n\n const cached = requiredNamesCache.get(parentSchema)\n if (cached) {\n return cached\n }\n\n if ('required' in parentSchema) {\n const required = parentSchema.required\n if (Array.isArray(required) && required.length > 0) {\n const set = new Set<string>(required)\n requiredNamesCache.set(parentSchema, set)\n return set\n }\n }\n\n return undefined\n}\n\n/**\n * Cache the result for a schema if it is an object type.\n * Primitive values are not cached to avoid unnecessary WeakMap operations.\n */\nconst cache = (schema: OpenAPIV3_1.SchemaObject, result: unknown) => {\n if (typeof result !== 'object' || result === null) {\n return result\n }\n resultCache.set(getRaw(unpackOverridesProxy(schema)), result)\n return result\n}\n\n/**\n * Check if a schema uses composition keywords (allOf, oneOf, anyOf).\n * These require special handling for merging or selecting schemas.\n */\nconst isComposed = (schema: OpenAPIV3_1.SchemaObject): boolean => !!(schema.allOf || schema.oneOf || schema.anyOf)\n\n/**\n * Determine if a property should be omitted based on the options.\n * Properties are omitted if they are not required and the option is enabled.\n */\nconst shouldOmitProperty = (\n schema: OpenAPIV3_1.SchemaObject,\n parentSchema: OpenAPIV3_1.SchemaObject | undefined,\n propertyName: string | undefined,\n options: { omitEmptyAndOptionalProperties?: boolean } | undefined,\n): boolean => {\n if (options?.omitEmptyAndOptionalProperties !== true) {\n return false\n }\n\n // Never omit container types (objects/arrays) or composed schemas\n const isContainer = ('type' in schema && (schema.type === 'object' || schema.type === 'array')) || isComposed(schema)\n if (isContainer) {\n return false\n }\n\n // Do not omit if explicit example-like values are present\n if (\n ('examples' in schema && Array.isArray(schema.examples) && schema.examples.length > 0) ||\n ('example' in schema && schema.example !== undefined) ||\n ('default' in schema && schema.default !== undefined) ||\n ('const' in schema && schema.const !== undefined) ||\n ('enum' in schema && Array.isArray(schema.enum) && schema.enum.length > 0)\n ) {\n return false\n }\n\n // Check if the property is required\n const name = propertyName ?? schema.title ?? ''\n const requiredNames = getRequiredNames(parentSchema)\n const isRequired = requiredNames ? requiredNames.has(name) : false\n\n return !isRequired\n}\n\n/**\n * Merge two example values with predictable semantics.\n * Arrays are concatenated, objects are merged, otherwise the new value wins.\n */\nconst mergeExamples = (baseValue: unknown, newValue: unknown): unknown => {\n if (Array.isArray(baseValue) && Array.isArray(newValue)) {\n return [...baseValue, ...newValue]\n }\n if (baseValue && typeof baseValue === 'object' && newValue && typeof newValue === 'object') {\n return { ...(baseValue as Record<string, unknown>), ...(newValue as Record<string, unknown>) }\n }\n return newValue\n}\n\n/**\n * Build an example for an object schema, including properties, patternProperties,\n * additionalProperties, and composition (allOf/oneOf/anyOf) merging.\n */\nconst handleObjectSchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n): unknown => {\n const response: Record<string, unknown> = {}\n\n if ('properties' in schema && schema.properties) {\n const propertyNames = Object.keys(schema.properties)\n const limit = level > 3 ? Math.min(MAX_PROPERTIES, propertyNames.length) : propertyNames.length\n\n for (let i = 0; i < limit; i++) {\n const propertyName = propertyNames[i]!\n const propertySchema = getResolvedRef(schema.properties[propertyName])\n if (!propertySchema) {\n continue\n }\n\n const propertyXmlName = options?.xml && 'xml' in propertySchema ? propertySchema.xml?.name : undefined\n const value = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: propertyName,\n seen,\n })\n\n if (typeof value !== 'undefined') {\n response[propertyXmlName ?? propertyName] = value\n }\n }\n\n if (level > 3 && propertyNames.length > MAX_PROPERTIES) {\n response['...'] = '[Additional Properties Truncated]'\n }\n }\n\n if ('patternProperties' in schema && schema.patternProperties) {\n for (const pattern of Object.keys(schema.patternProperties)) {\n const propertySchema = getResolvedRef(schema.patternProperties[pattern])\n if (!propertySchema) {\n continue\n }\n response[pattern] = getExampleFromSchema(propertySchema, options, {\n level: level + 1,\n parentSchema: schema,\n name: pattern,\n seen,\n })\n }\n }\n\n if ('additionalProperties' in schema && schema.additionalProperties !== undefined) {\n const additional = getResolvedRef(schema.additionalProperties)\n const isAnyType =\n schema.additionalProperties === true ||\n (typeof schema.additionalProperties === 'object' && Object.keys(schema.additionalProperties).length === 0)\n\n const additionalName =\n typeof additional === 'object' &&\n 'x-additionalPropertiesName' in additional &&\n typeof additional['x-additionalPropertiesName'] === 'string' &&\n additional['x-additionalPropertiesName'].trim().length > 0\n ? `${additional['x-additionalPropertiesName'].trim()}*`\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n response[additionalName] = isAnyType\n ? 'anything'\n : typeof additional === 'object'\n ? getExampleFromSchema(additional, options, {\n level: level + 1,\n seen,\n })\n : 'anything'\n }\n\n // onOf\n if (schema.oneOf?.[0]) {\n Object.assign(\n response,\n getExampleFromSchema(getResolvedRef(schema.oneOf[0]), options, {\n level: level + 1,\n seen,\n }),\n )\n }\n // anyOf\n else if (schema.anyOf?.[0]) {\n Object.assign(\n response,\n getExampleFromSchema(getResolvedRef(schema.anyOf[0]), options, {\n level: level + 1,\n seen,\n }),\n )\n }\n // allOf\n else if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {\n let merged: unknown = response\n for (const item of schema.allOf) {\n const ex = getExampleFromSchema(getResolvedRef(item), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n merged = mergeExamples(merged, ex)\n }\n if (merged && typeof merged === 'object') {\n Object.assign(response, merged as Record<string, unknown>)\n }\n }\n\n if (options?.xml && 'xml' in schema && schema.xml?.name && level === 0) {\n const wrapped: Record<string, unknown> = {}\n wrapped[schema.xml.name] = response\n return cache(schema, wrapped)\n }\n\n return cache(schema, response)\n}\n\n/** Build an example for an array schema, including items, allOf, oneOf/anyOf, and XML wrapping */\nconst handleArraySchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options: Parameters<typeof getExampleFromSchema>[1],\n level: number,\n seen: WeakSet<object>,\n) => {\n const items = 'items' in schema ? getResolvedRef(schema.items) : undefined\n const itemsXmlTagName = items && typeof items === 'object' && 'xml' in items ? items.xml?.name : undefined\n const wrapItems = !!(options?.xml && 'xml' in schema && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName as string]: schema.example } : schema.example)\n }\n\n if (items && typeof items === 'object') {\n if (Array.isArray(items.allOf) && items.allOf.length > 0) {\n const allOf = items.allOf.filter(isDefined)\n const first = getResolvedRef(allOf[0])\n\n if (first && typeof first === 'object' && 'type' in first && first.type === 'object') {\n const combined: OpenAPIV3_1.SchemaObject = { type: 'object', allOf }\n const merged = getExampleFromSchema(combined, options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: merged }] : [merged])\n }\n\n const examples = allOf\n .map((s: any) =>\n getExampleFromSchema(getResolvedRef(s), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n }),\n )\n .filter(isDefined)\n return cache(\n schema,\n wrapItems ? (examples as unknown[]).map((e) => ({ [itemsXmlTagName as string]: e })) : examples,\n )\n }\n\n const union = items.anyOf || items.oneOf\n if (union && union.length > 0) {\n const first = union[0] as OpenAPIV3_1.SchemaObject\n const ex = getExampleFromSchema(getResolvedRef(first), options, {\n level: level + 1,\n parentSchema: schema,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex])\n }\n }\n\n const isObject =\n items && typeof items === 'object' && (('type' in items && items.type === 'object') || 'properties' in items)\n const isArray =\n items && typeof items === 'object' && (('type' in items && items.type === 'array') || 'items' in items)\n\n if (items && typeof items === 'object' && (('type' in items && items.type) || isObject || isArray)) {\n const ex = getExampleFromSchema(items as OpenAPIV3_1.SchemaObject, options, {\n level: level + 1,\n seen,\n })\n return cache(schema, wrapItems ? [{ [itemsXmlTagName as string]: ex }] : [ex])\n }\n\n return cache(schema, [])\n}\n\n/** Return primitive example value for single-type schemas, or undefined if not primitive */\nconst getPrimitiveValue = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean,\n emptyString: string | undefined,\n) => {\n if ('type' in schema && schema.type && !Array.isArray(schema.type)) {\n switch (schema.type) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'array':\n return []\n default:\n return undefined\n }\n }\n return undefined\n}\n\n/** Return primitive example value for union-type schemas (type: string[]) */\nconst getUnionPrimitiveValue = (\n schema: OpenAPIV3_1.SchemaObject,\n makeUpRandomData: boolean,\n emptyString: string | undefined,\n) => {\n if ('type' in schema && Array.isArray(schema.type)) {\n if (schema.type.includes('null')) {\n return null\n }\n\n const first = schema.type[0]\n if (first) {\n switch (first) {\n case 'string':\n return guessFromFormat(schema, makeUpRandomData, emptyString ?? '')\n case 'boolean':\n return true\n case 'integer':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'number':\n return 'minimum' in schema && typeof schema.minimum === 'number' ? schema.minimum : 1\n case 'null':\n return null\n default:\n return undefined\n }\n }\n }\n return undefined\n}\n\n/**\n * Generate an example value from a given OpenAPI SchemaObject.\n *\n * This function recursively processes OpenAPI schemas to create realistic example data.\n * It handles all OpenAPI schema types including primitives, objects, arrays, and\n * composition schemas (allOf, oneOf, anyOf).\n * Uses a tonne of caching for maximum performance.\n *\n * @param schema - The OpenAPI SchemaObject to generate an example from.\n * @param options - Options to customize example generation.\n * @param level - The current recursion depth.\n * @param parentSchema - The parent schema, if any.\n * @param name - The name of the property being processed.\n * @returns An example value for the given schema.\n */\nexport const getExampleFromSchema = (\n schema: OpenAPIV3_1.SchemaObject,\n options?: {\n /** Fallback string for empty string values. */\n emptyString?: string\n /** Whether to use XML tag names as keys. */\n xml?: boolean\n /** Whether to show read-only/write-only properties. */\n mode?: 'read' | 'write'\n /** Dynamic variables which can replace values via x-variable. */\n variables?: Record<string, unknown>\n /** Whether to omit empty and optional properties. */\n omitEmptyAndOptionalProperties?: boolean\n },\n args?: Partial<{\n level: number\n parentSchema: OpenAPIV3_1.SchemaObject\n name: string\n seen: WeakSet<object>\n }>,\n): any => {\n const { level = 0, parentSchema, name, seen = new WeakSet() } = args ?? {}\n\n // Resolve any $ref references to get the actual schema\n const _schema = getResolvedRef(schema)\n if (!isDefined(_schema)) {\n return undefined\n }\n\n // Unpack from all proxies to get the raw schema object for cycle detection\n const targetValue = getRaw(unpackOverridesProxy(_schema))\n if (seen.has(targetValue)) {\n return '[Circular Reference]'\n }\n seen.add(targetValue)\n\n // Check cache first for performance - avoid recomputing the same schema\n if (resultCache.has(targetValue)) {\n seen.delete(targetValue)\n return resultCache.get(targetValue)\n }\n\n // Prevent infinite recursion in circular references\n if (level > MAX_LEVELS_DEEP) {\n seen.delete(targetValue)\n return '[Max Depth Exceeded]'\n }\n\n // Determine if we should generate realistic example data\n const makeUpRandomData = !!options?.emptyString\n\n // Early exits for schemas that should not be included (deprecated, readOnly, writeOnly, omitEmptyAndOptionalProperties)\n if (\n _schema.deprecated ||\n (options?.mode === 'write' && _schema.readOnly) ||\n (options?.mode === 'read' && _schema.writeOnly) ||\n shouldOmitProperty(_schema, parentSchema, name, options)\n ) {\n seen.delete(targetValue)\n return undefined\n }\n\n // Handle custom variables (x-variable extension)\n if ('x-variable' in _schema && _schema['x-variable']) {\n const value = options?.variables?.[_schema['x-variable']]\n if (value !== undefined) {\n // Type coercion for numeric types\n if ('type' in _schema && (_schema.type === 'number' || _schema.type === 'integer')) {\n seen.delete(targetValue)\n return cache(_schema, Number(value))\n }\n seen.delete(targetValue)\n return cache(_schema, value)\n }\n }\n\n // Priority order: examples > example > default > const > enum\n if (Array.isArray(_schema.examples) && _schema.examples.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.examples[0])\n }\n if (_schema.example !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.example)\n }\n if (_schema.default !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.default)\n }\n if (_schema.const !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, _schema.const)\n }\n if (Array.isArray(_schema.enum) && _schema.enum.length > 0) {\n seen.delete(targetValue)\n return cache(_schema, _schema.enum[0])\n }\n\n // Handle object types - check for properties to identify objects\n if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {\n const result = handleObjectSchema(_schema, options, level, seen)\n seen.delete(targetValue)\n return result\n }\n\n // Handle array types\n if (('type' in _schema && _schema.type === 'array') || 'items' in _schema) {\n const result = handleArraySchema(_schema, options, level, seen)\n seen.delete(targetValue)\n return result\n }\n\n // Handle primitive types without allocating temporary objects\n const primitive = getPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (primitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, primitive)\n }\n\n // Handle composition schemas (oneOf, anyOf) at root level\n const discriminate = _schema.oneOf || _schema.anyOf\n if (Array.isArray(discriminate) && discriminate.length > 0) {\n // Find the first non-null type without allocating intermediate arrays\n for (const item of discriminate) {\n const resolved = getResolvedRef(item)\n if (resolved && (!('type' in resolved) || resolved.type !== 'null')) {\n seen.delete(targetValue)\n return cache(\n _schema,\n getExampleFromSchema(resolved, options, {\n level: level + 1,\n seen,\n }),\n )\n }\n }\n seen.delete(targetValue)\n return cache(_schema, null)\n }\n\n // Handle allOf at root level (non-object/array schemas)\n if (Array.isArray(_schema.allOf) && _schema.allOf.length > 0) {\n let merged: unknown = undefined\n const items = _schema.allOf\n for (const item of items) {\n const ex = getExampleFromSchema(item as OpenAPIV3_1.SchemaObject, options, {\n level: level + 1,\n parentSchema: _schema,\n seen,\n })\n if (merged === undefined) {\n merged = ex\n } else if (merged && typeof merged === 'object' && ex && typeof ex === 'object') {\n merged = mergeExamples(merged, ex)\n } else if (ex !== undefined) {\n // Prefer the latest defined primitive value\n merged = ex\n }\n }\n seen.delete(targetValue)\n return cache(_schema, merged ?? null)\n }\n\n // Handle union types (array of types)\n const unionPrimitive = getUnionPrimitiveValue(_schema, makeUpRandomData, options?.emptyString)\n if (unionPrimitive !== undefined) {\n seen.delete(targetValue)\n return cache(_schema, unionPrimitive)\n }\n\n // Default fallback\n seen.delete(targetValue)\n return cache(_schema, null)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAEvB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAGrC,MAAM,kBAAkB;AAMxB,MAAM,iBAAiB;AAGvB,MAAM,qCAAqC;AAM3C,MAAM,oBAAmB,oBAAI,KAAK,GAAE,YAAY;AAChD,MAAM,oBAAoB,iBAAiB,MAAM,GAAG,EAAE,CAAC;AACvD,MAAM,oBAAoB,iBAAiB,MAAM,GAAG,EAAE,CAAC,EAAG,MAAM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A,MACnC,WAAW,OAAO,QAAW;AAE3B,iBAAS;AAAA,MACX;AAAA,IACF;AACA,SAAK,OAAO,WAAW;AACvB,WAAO,MAAM,SAAS,UAAU,IAAI;AAAA,EACtC;AAGA,QAAM,iBAAiB,uBAAuB,SAAS,kBAAkB,SAAS,WAAW;AAC7F,MAAI,mBAAmB,QAAW;AAChC,SAAK,OAAO,WAAW;AACvB,WAAO,MAAM,SAAS,cAAc;AAAA,EACtC;AAGA,OAAK,OAAO,WAAW;AACvB,SAAO,MAAM,SAAS,IAAI;AAC5B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.5.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
@@ -99,14 +99,14 @@
|
|
|
99
99
|
"nanoid": "5.1.5",
|
|
100
100
|
"type-fest": "4.41.0",
|
|
101
101
|
"yaml": "2.8.0",
|
|
102
|
-
"zod": "
|
|
102
|
+
"zod": "4.1.11",
|
|
103
103
|
"@scalar/helpers": "0.0.11",
|
|
104
|
-
"@scalar/json-magic": "0.
|
|
104
|
+
"@scalar/json-magic": "0.6.0",
|
|
105
105
|
"@scalar/object-utils": "1.2.7",
|
|
106
|
-
"@scalar/openapi-types": "0.
|
|
107
|
-
"@scalar/
|
|
108
|
-
"@scalar/types": "0.
|
|
109
|
-
"@scalar/
|
|
106
|
+
"@scalar/openapi-types": "0.4.0",
|
|
107
|
+
"@scalar/workspace-store": "0.16.2",
|
|
108
|
+
"@scalar/types": "0.3.0",
|
|
109
|
+
"@scalar/themes": "0.13.20"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@types/node": "^22.9.0",
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
"vitest": "3.2.4",
|
|
116
116
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
117
117
|
"@scalar/build-tooling": "0.2.7",
|
|
118
|
-
"@scalar/openapi-parser": "0.
|
|
119
|
-
"@scalar/openapi-types": "0.
|
|
118
|
+
"@scalar/openapi-parser": "0.22.1",
|
|
119
|
+
"@scalar/openapi-types": "0.4.0"
|
|
120
120
|
},
|
|
121
121
|
"scripts": {
|
|
122
122
|
"build": "scalar-build-esbuild",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
-
import type { Request as HarRequest } from 'har-format';
|
|
3
|
-
import type { ServerObject, SecuritySchemeObject, OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
4
|
-
export type OperationToHarProps = {
|
|
5
|
-
/** OpenAPI Operation object */
|
|
6
|
-
operation: OperationObject;
|
|
7
|
-
/** HTTP method of the operation */
|
|
8
|
-
method: HttpMethod;
|
|
9
|
-
/** Path of the operation */
|
|
10
|
-
path: string;
|
|
11
|
-
/**
|
|
12
|
-
* requestBody.content[contentType].example to use for the request, it should be pre-selected and discriminated
|
|
13
|
-
*/
|
|
14
|
-
example?: unknown;
|
|
15
|
-
/**
|
|
16
|
-
* Content type of the request
|
|
17
|
-
*
|
|
18
|
-
* @defaults to the first content type in the operation.requestBody.content
|
|
19
|
-
*/
|
|
20
|
-
contentType?: string;
|
|
21
|
-
/** OpenAPI Server object */
|
|
22
|
-
server?: ServerObject | undefined;
|
|
23
|
-
/** OpenAPI SecurityScheme objects which are applicable to the operation */
|
|
24
|
-
securitySchemes?: SecuritySchemeObject[];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.
|
|
28
|
-
*
|
|
29
|
-
* This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,
|
|
30
|
-
* which can be used to generate code snippets for various programming languages and HTTP clients.
|
|
31
|
-
*
|
|
32
|
-
* The conversion handles:
|
|
33
|
-
* - Server URL processing and path parameter substitution
|
|
34
|
-
* - Query parameter formatting based on OpenAPI parameter styles
|
|
35
|
-
* - Request body processing with content type handling
|
|
36
|
-
* - Security scheme integration (API keys, etc.)
|
|
37
|
-
*
|
|
38
|
-
* The resulting HarRequest object follows the HAR specification and includes:
|
|
39
|
-
* - HTTP method and URL
|
|
40
|
-
* - Headers and query parameters
|
|
41
|
-
* - Request body (if present)
|
|
42
|
-
* - Cookie information
|
|
43
|
-
* - Size calculations for headers and body
|
|
44
|
-
*
|
|
45
|
-
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
46
|
-
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
47
|
-
*/
|
|
48
|
-
export declare const operationToHar: ({ operation, contentType, method, path, server, securitySchemes, example, }: OperationToHarProps) => HarRequest;
|
|
49
|
-
//# sourceMappingURL=operation-to-har.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvD,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,eAAe,EAChB,MAAM,8DAA8D,CAAA;AAGrE,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IACjC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;CACzC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,6EAQ5B,mBAAmB,KAAG,UAoExB,CAAA"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { processServerUrl } from "./process-server-url.js";
|
|
2
|
-
import { processParameters } from "./process-parameters.js";
|
|
3
|
-
import { processBody } from "./process-body.js";
|
|
4
|
-
import { processSecuritySchemes } from "./process-security-schemes.js";
|
|
5
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
6
|
-
const operationToHar = ({
|
|
7
|
-
operation,
|
|
8
|
-
contentType,
|
|
9
|
-
method,
|
|
10
|
-
path,
|
|
11
|
-
server,
|
|
12
|
-
securitySchemes,
|
|
13
|
-
example
|
|
14
|
-
}) => {
|
|
15
|
-
const harRequest = {
|
|
16
|
-
method,
|
|
17
|
-
url: path,
|
|
18
|
-
headers: [],
|
|
19
|
-
queryString: [],
|
|
20
|
-
postData: void 0,
|
|
21
|
-
httpVersion: "HTTP/1.1",
|
|
22
|
-
cookies: [],
|
|
23
|
-
headersSize: -1,
|
|
24
|
-
bodySize: -1
|
|
25
|
-
};
|
|
26
|
-
if (server?.url) {
|
|
27
|
-
harRequest.url = processServerUrl(server, path);
|
|
28
|
-
}
|
|
29
|
-
if (operation.parameters) {
|
|
30
|
-
const { url, headers, queryString, cookies } = processParameters(harRequest, operation.parameters, example);
|
|
31
|
-
harRequest.url = url;
|
|
32
|
-
harRequest.headers = headers;
|
|
33
|
-
harRequest.queryString = queryString;
|
|
34
|
-
harRequest.cookies = cookies;
|
|
35
|
-
}
|
|
36
|
-
const body = getResolvedRef(operation.requestBody);
|
|
37
|
-
if (body?.content) {
|
|
38
|
-
const postData = processBody({ content: body.content, contentType, example });
|
|
39
|
-
harRequest.postData = postData;
|
|
40
|
-
harRequest.bodySize = postData.text?.length ?? -1;
|
|
41
|
-
if (postData.mimeType) {
|
|
42
|
-
const existingContentTypeHeader = harRequest.headers.find(
|
|
43
|
-
(header) => header.name.toLowerCase() === "content-type"
|
|
44
|
-
);
|
|
45
|
-
if (existingContentTypeHeader && !existingContentTypeHeader.value) {
|
|
46
|
-
existingContentTypeHeader.value = postData.mimeType;
|
|
47
|
-
} else {
|
|
48
|
-
harRequest.headers.push({
|
|
49
|
-
name: "Content-Type",
|
|
50
|
-
value: postData.mimeType
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (securitySchemes) {
|
|
56
|
-
const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes);
|
|
57
|
-
harRequest.headers.push(...headers);
|
|
58
|
-
harRequest.queryString.push(...queryString);
|
|
59
|
-
harRequest.cookies.push(...cookies);
|
|
60
|
-
}
|
|
61
|
-
const headerText = harRequest.headers.map((h) => `${h.name}: ${h.value}`).join("\r\n");
|
|
62
|
-
harRequest.headersSize = headerText.length;
|
|
63
|
-
return harRequest;
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
operationToHar
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=operation-to-har.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/operation-to-har/operation-to-har.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { processServerUrl } from './process-server-url'\nimport { processParameters } from './process-parameters'\nimport { processBody } from './process-body'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport type {\n ServerObject,\n SecuritySchemeObject,\n OperationObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: HttpMethod\n /** Path of the operation */\n path: string\n /**\n * requestBody.content[contentType].example to use for the request, it should be pre-selected and discriminated\n */\n example?: unknown\n /**\n * Content type of the request\n *\n * @defaults to the first content type in the operation.requestBody.content\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | undefined\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObject[]\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n}: OperationToHarProps): HarRequest => {\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: path,\n headers: [],\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n // Server URL\n if (server?.url) {\n harRequest.url = processServerUrl(server, path)\n }\n\n // Handle parameters\n if (operation.parameters) {\n const { url, headers, queryString, cookies } = processParameters(harRequest, operation.parameters, example)\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = cookies\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({ content: body.content, contentType, example })\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (existingContentTypeHeader && !existingContentTypeHeader.value) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Calculate headers size\n const headerText = harRequest.headers.map((h) => `${h.name}: ${h.value}`).join('\\r\\n')\n harRequest.headersSize = headerText.length\n\n return harRequest\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AAMvC,SAAS,sBAAsB;AA+CxB,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAuC;AAErC,QAAM,aAAyB;AAAA,IAC7B;AAAA,IACA,KAAK;AAAA,IACL,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAGA,MAAI,QAAQ,KAAK;AACf,eAAW,MAAM,iBAAiB,QAAQ,IAAI;AAAA,EAChD;AAGA,MAAI,UAAU,YAAY;AACxB,UAAM,EAAE,KAAK,SAAS,aAAa,QAAQ,IAAI,kBAAkB,YAAY,UAAU,YAAY,OAAO;AAC1G,eAAW,MAAM;AACjB,eAAW,UAAU;AACrB,eAAW,cAAc;AACzB,eAAW,UAAU;AAAA,EACvB;AAEA,QAAM,OAAO,eAAe,UAAU,WAAW;AAGjD,MAAI,MAAM,SAAS;AACjB,UAAM,WAAW,YAAY,EAAE,SAAS,KAAK,SAAS,aAAa,QAAQ,CAAC;AAC5E,eAAW,WAAW;AACtB,eAAW,WAAW,SAAS,MAAM,UAAU;AAG/C,QAAI,SAAS,UAAU;AACrB,YAAM,4BAA4B,WAAW,QAAQ;AAAA,QACnD,CAAC,WAAW,OAAO,KAAK,YAAY,MAAM;AAAA,MAC5C;AAEA,UAAI,6BAA6B,CAAC,0BAA0B,OAAO;AACjE,kCAA0B,QAAQ,SAAS;AAAA,MAC7C,OAEK;AACH,mBAAW,QAAQ,KAAK;AAAA,UACtB,MAAM;AAAA,UACN,OAAO,SAAS;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAGA,MAAI,iBAAiB;AACnB,UAAM,EAAE,SAAS,aAAa,QAAQ,IAAI,uBAAuB,eAAe;AAChF,eAAW,QAAQ,KAAK,GAAG,OAAO;AAClC,eAAW,YAAY,KAAK,GAAG,WAAW;AAC1C,eAAW,QAAQ,KAAK,GAAG,OAAO;AAAA,EACpC;AAGA,QAAM,aAAa,WAAW,QAAQ,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,MAAM;AACrF,aAAW,cAAc,WAAW;AAEpC,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
-
import type { PostData } from 'har-format';
|
|
3
|
-
import type { OperationToHarProps } from './operation-to-har.js';
|
|
4
|
-
type ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example'> & {
|
|
5
|
-
content: RequestBodyObject['content'];
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Processes the request body and returns the processed data
|
|
9
|
-
*/
|
|
10
|
-
export declare const processBody: ({ content, contentType, example }: ProcessBodyProps) => PostData;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=process-body.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8DAA8D,CAAA;AACrG,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,SAAS,CAAC,GAAG;IAC7E,OAAO,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;CACtC,CAAA;AAoCD;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,mCAAmC,gBAAgB,KAAG,QAiEjF,CAAA"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { getExampleFromSchema } from "../../spec-getters/get-example-from-schema.js";
|
|
2
|
-
import { json2xml } from "@scalar/helpers/file/json2xml";
|
|
3
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
|
-
const objectToFormParams = (obj) => {
|
|
5
|
-
const params = [];
|
|
6
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
7
|
-
if (value === void 0 || value === null) {
|
|
8
|
-
continue;
|
|
9
|
-
}
|
|
10
|
-
if (Array.isArray(value)) {
|
|
11
|
-
for (const item of value) {
|
|
12
|
-
params.push({ name: key, value: String(item) });
|
|
13
|
-
}
|
|
14
|
-
} else if (typeof value === "object") {
|
|
15
|
-
const nestedParams = objectToFormParams(value);
|
|
16
|
-
for (const param of nestedParams) {
|
|
17
|
-
params.push({ name: `${key}.${param.name}`, value: param.value });
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
params.push({ name: key, value: String(value) });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return params;
|
|
24
|
-
};
|
|
25
|
-
const processBody = ({ content, contentType, example }) => {
|
|
26
|
-
const _contentType = (contentType || Object.keys(content)[0]) ?? "";
|
|
27
|
-
const isFormData = _contentType === "multipart/form-data" || _contentType === "application/x-www-form-urlencoded";
|
|
28
|
-
const isXml = _contentType === "application/xml";
|
|
29
|
-
if (example) {
|
|
30
|
-
if (isFormData && typeof example === "object" && example !== null) {
|
|
31
|
-
return {
|
|
32
|
-
mimeType: _contentType,
|
|
33
|
-
params: objectToFormParams(example)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (isXml && typeof example === "object" && example !== null) {
|
|
37
|
-
return {
|
|
38
|
-
mimeType: _contentType,
|
|
39
|
-
text: json2xml(example)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
mimeType: _contentType,
|
|
44
|
-
text: JSON.stringify(example)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const contentSchema = getResolvedRef(content[_contentType]?.schema);
|
|
48
|
-
if (contentSchema) {
|
|
49
|
-
const extractedExample = getExampleFromSchema(contentSchema, {
|
|
50
|
-
mode: "write",
|
|
51
|
-
xml: isXml
|
|
52
|
-
});
|
|
53
|
-
if (extractedExample !== void 0) {
|
|
54
|
-
if (isFormData && typeof extractedExample === "object" && extractedExample !== null) {
|
|
55
|
-
return {
|
|
56
|
-
mimeType: _contentType,
|
|
57
|
-
params: objectToFormParams(extractedExample)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (isXml && typeof extractedExample === "object" && extractedExample !== null) {
|
|
61
|
-
return {
|
|
62
|
-
mimeType: _contentType,
|
|
63
|
-
text: json2xml(extractedExample)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
mimeType: _contentType,
|
|
68
|
-
text: JSON.stringify(extractedExample)
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
mimeType: _contentType,
|
|
74
|
-
text: "null"
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
export {
|
|
78
|
-
processBody
|
|
79
|
-
};
|
|
80
|
-
//# sourceMappingURL=process-body.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/operation-to-har/process-body.ts"],
|
|
4
|
-
"sourcesContent": ["import { getExampleFromSchema } from '@/spec-getters/get-example-from-schema'\nimport { json2xml } from '@scalar/helpers/file/json2xml'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { Param, PostData } from 'har-format'\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example'> & {\n content: RequestBodyObject['content']\n}\n\n/**\n * Converts an object to an array of form parameters\n * @param obj - The object to convert\n * @returns Array of form parameters with name and value properties\n */\nconst objectToFormParams = (obj: Record<string, unknown>): Param[] => {\n const params: Param[] = []\n\n for (const [key, value] of Object.entries(obj)) {\n if (value === undefined || value === null) {\n continue\n }\n\n // Handle arrays by adding each item with the same key\n if (Array.isArray(value)) {\n for (const item of value) {\n params.push({ name: key, value: String(item) })\n }\n }\n // Handle nested objects by flattening them\n else if (typeof value === 'object') {\n const nestedParams = objectToFormParams(value as Record<string, unknown>)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({ name: key, value: String(value) })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n */\nexport const processBody = ({ content, contentType, example }: ProcessBodyProps): PostData => {\n const _contentType = (contentType || Object.keys(content)[0]) ?? ''\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n const isXml = _contentType === 'application/xml'\n\n // Return the provided top level example\n if (example) {\n if (isFormData && typeof example === 'object' && example !== null) {\n return {\n mimeType: _contentType,\n params: objectToFormParams(example as Record<string, unknown>),\n }\n }\n\n if (isXml && typeof example === 'object' && example !== null) {\n return {\n mimeType: _contentType,\n text: json2xml(example as Record<string, unknown>),\n }\n }\n\n return {\n mimeType: _contentType,\n text: JSON.stringify(example),\n }\n }\n\n // Try to extract examples from the schema\n const contentSchema = getResolvedRef(content[_contentType]?.schema)\n if (contentSchema) {\n const extractedExample = getExampleFromSchema(contentSchema, {\n mode: 'write',\n xml: isXml,\n })\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: _contentType,\n params: objectToFormParams(extractedExample as Record<string, unknown>),\n }\n }\n\n if (isXml && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: _contentType,\n text: json2xml(extractedExample as Record<string, unknown>),\n }\n }\n\n return {\n mimeType: _contentType,\n text: JSON.stringify(extractedExample),\n }\n }\n }\n\n return {\n mimeType: _contentType,\n text: 'null',\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAc/B,MAAM,qBAAqB,CAAC,QAA0C;AACpE,QAAM,SAAkB,CAAC;AAEzB,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC;AAAA,IACF;AAGA,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,iBAAW,QAAQ,OAAO;AACxB,eAAO,KAAK,EAAE,MAAM,KAAK,OA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;AAAA,MACF;AAEA,UAAI,SAAS,OAAO,qBAAqB,YAAY,qBAAqB,MAAM;AAC9E,eAAO;AAAA,UACL,UAAU;AAAA,UACV,MAAM,SAAS,gBAA2C;AAAA,QAC5D;AAAA,MACF;AAEA,aAAO;AAAA,QACL,UAAU;AAAA,QACV,MAAM,KAAK,UAAU,gBAAgB;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
-
import type { Request as HarRequest } from 'har-format';
|
|
3
|
-
type ProcessedParameters = {
|
|
4
|
-
url: string;
|
|
5
|
-
headers: HarRequest['headers'];
|
|
6
|
-
queryString: HarRequest['queryString'];
|
|
7
|
-
cookies: HarRequest['cookies'];
|
|
8
|
-
};
|
|
9
|
-
/** Ensures we don't have any references in the parameters */
|
|
10
|
-
export declare const deReferenceParams: (params: OperationObject["parameters"]) => ParameterObject[];
|
|
11
|
-
/**
|
|
12
|
-
* Process OpenAPI parameters and return the updated properties.
|
|
13
|
-
* Handles path, query, and header parameters with various styles and explode options.
|
|
14
|
-
*
|
|
15
|
-
* @see https://spec.openapis.org/oas/latest.html#style-values
|
|
16
|
-
*/
|
|
17
|
-
export declare const processParameters: (harRequest: HarRequest, parameters: OperationObject["parameters"], example?: unknown) => ProcessedParameters;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=process-parameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAEf,eAAe,EAChB,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,CAAC,YAAY,CAAC,KAAG,eAAe,EACnC,CAAA;AAoEtD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,UAAU,EACtB,YAAY,eAAe,CAAC,YAAY,CAAC,EACzC,UAAU,OAAO,KAChB,mBAsNF,CAAA"}
|