@scalar/types 0.2.16 → 0.3.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 +11 -0
- package/dist/api-client/api-client-plugin.d.ts +19 -155
- package/dist/api-client/api-client-plugin.d.ts.map +1 -1
- package/dist/api-client/api-client-plugin.js +13 -12
- package/dist/api-client/api-client-plugin.js.map +2 -2
- package/dist/api-reference/api-reference-configuration.d.ts +452 -1952
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-configuration.js +106 -46
- package/dist/api-reference/api-reference-configuration.js.map +2 -2
- package/dist/api-reference/api-reference-plugin.d.ts +4 -62
- package/dist/api-reference/api-reference-plugin.d.ts.map +1 -1
- package/dist/api-reference/api-reference-plugin.js +4 -3
- package/dist/api-reference/api-reference-plugin.js.map +2 -2
- package/dist/api-reference/html-rendering-configuration.d.ts +1 -19
- package/dist/api-reference/html-rendering-configuration.d.ts.map +1 -1
- package/dist/entities/security-scheme.d.ts +220 -1641
- package/dist/entities/security-scheme.d.ts.map +1 -1
- package/dist/entities/security-scheme.js +11 -2
- package/dist/entities/security-scheme.js.map +2 -2
- package/dist/snippetz/snippetz.d.ts +8 -2
- package/dist/snippetz/snippetz.d.ts.map +1 -1
- package/dist/snippetz/snippetz.js.map +2 -2
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security-scheme.d.ts","sourceRoot":"","sources":["../../src/entities/security-scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAsBvB,eAAO,MAAM,sBAAsB,wCAAyC,CAAA;AAc5E,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"security-scheme.d.ts","sourceRoot":"","sources":["../../src/entities/security-scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAsBvB,eAAO,MAAM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O,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAKlC,CAAA;AAEF,oDAAoD;AACpD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAa7B,CAAA;AAEJ;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -81,7 +81,7 @@ const credentialsLocationExtension = z.enum(["header", "body"]).optional();
|
|
|
81
81
|
const oasSecuritySchemeOauth2 = commonProps.extend({
|
|
82
82
|
type: z.literal("oauth2"),
|
|
83
83
|
/** The default scopes for the oauth flow */
|
|
84
|
-
"x-default-scopes": z.
|
|
84
|
+
"x-default-scopes": z.array(z.string()).optional(),
|
|
85
85
|
/** REQUIRED. An object containing configuration information for the flow types supported. */
|
|
86
86
|
flows: z.object({
|
|
87
87
|
/** Configuration for the OAuth Implicit flow */
|
|
@@ -117,7 +117,16 @@ const oasSecuritySchemeOauth2 = commonProps.extend({
|
|
|
117
117
|
"x-scalar-credentials-location": credentialsLocationExtension
|
|
118
118
|
})
|
|
119
119
|
}).partial().default({
|
|
120
|
-
implicit: {
|
|
120
|
+
implicit: {
|
|
121
|
+
selectedScopes: [],
|
|
122
|
+
scopes: {},
|
|
123
|
+
"x-scalar-client-id": "",
|
|
124
|
+
refreshUrl: "",
|
|
125
|
+
token: "",
|
|
126
|
+
type: "implicit",
|
|
127
|
+
authorizationUrl: "http://localhost:8080",
|
|
128
|
+
"x-scalar-redirect-uri": defaultRedirectUri
|
|
129
|
+
}
|
|
121
130
|
})
|
|
122
131
|
});
|
|
123
132
|
const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/entities/security-scheme.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod'\n\nimport { type ENTITY_BRANDS, nanoidSchema } from '../utils/nanoid'\n\n// ---------------------------------------------------------------------------\n// COMMON PROPS FOR ALL SECURITY SCHEMES\n\n/** Some common properties used in all security schemes */\nconst commonProps = z.object({\n /* A description for security scheme. CommonMark syntax MAY be used for rich text representation. */\n description: z.string().optional(),\n})\n\nconst extendedSecuritySchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['SECURITY_SCHEME']>(),\n /** The name key that links a security requirement to a security object */\n nameKey: z.string().optional().default(''),\n})\n\n// ---------------------------------------------------------------------------\n// API KEY\n\nexport const securitySchemeApiKeyIn = ['query', 'header', 'cookie'] as const\n\nconst oasSecuritySchemeApiKey = commonProps.extend({\n type: z.literal('apiKey'),\n /** REQUIRED. The name of the header, query or cookie parameter to be used. */\n name: z.string().optional().default(''),\n /** REQUIRED. The location of the API key. Valid values are \"query\", \"header\" or \"cookie\". */\n in: z.enum(securitySchemeApiKeyIn).optional().default('header').catch('header'),\n})\n\nconst apiKeyValueSchema = z.object({\n value: z.string().default(''),\n})\n\nexport const securityApiKeySchema = oasSecuritySchemeApiKey.merge(extendedSecuritySchema).merge(apiKeyValueSchema)\nexport type SecuritySchemeApiKey = z.infer<typeof securityApiKeySchema>\n\n// ---------------------------------------------------------------------------\n// HTTP\n\nconst oasSecuritySchemeHttp = commonProps.extend({\n type: z.literal('http'),\n /**\n * REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in\n * [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry.\n */\n scheme: z\n .string()\n .toLowerCase()\n .pipe(z.enum(['basic', 'bearer']))\n .optional()\n .default('basic'),\n /**\n * A hint to the client to identify how the bearer token is formatted.\n * Bearer tokens are usually generated by an authorization server, so\n * this information is primarily for documentation purposes.\n */\n bearerFormat: z\n .union([z.literal('JWT'), z.string()])\n .optional()\n .default('JWT'),\n})\n\nconst httpValueSchema = z.object({\n username: z.string().default(''),\n password: z.string().default(''),\n token: z.string().default(''),\n})\n\nexport const securityHttpSchema = oasSecuritySchemeHttp.merge(extendedSecuritySchema).merge(httpValueSchema)\nexport type SecuritySchemaHttp = z.infer<typeof securityHttpSchema>\n\n// ---------------------------------------------------------------------------\n// OPENID CONNECT\nconst oasSecuritySchemeOpenId = commonProps.extend({\n type: z.literal('openIdConnect'),\n /**\n * REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the\n * form of a URL. The OpenID Connect standard requires the use of TLS.\n */\n openIdConnectUrl: z.string().optional().default(''),\n})\n\nexport const securityOpenIdSchema = oasSecuritySchemeOpenId.merge(extendedSecuritySchema)\nexport type SecuritySchemaOpenId = z.infer<typeof securityOpenIdSchema>\n\n// ---------------------------------------------------------------------------\n\n/**\n * REQUIRED. The authorization URL to be used for this flow. This MUST be in\n * the form of a URL. The OAuth2 standard requires the use of TLS.\n */\nconst authorizationUrl = z.string().default('')\n\n/**\n * REQUIRED. The token URL to be used for this flow. This MUST be in the\n * form of a URL. The OAuth2 standard requires the use of TLS.\n */\nconst tokenUrl = z.string().default('')\n\n/** Common properties used across all oauth2 flows */\nconst flowsCommon = z.object({\n /**\n * The URL to be used for obtaining refresh tokens. This MUST be in the form of a\n * URL. The OAuth2 standard requires the use of TLS.\n */\n 'refreshUrl': z.string().optional().default(''),\n /**\n * REQUIRED. The available scopes for the OAuth2 security scheme. A map\n * between the scope name and a short description for it. The map MAY be empty.\n */\n 'scopes': z.record(z.string(), z.string().optional().default('')).optional().default({}).catch({}),\n 'selectedScopes': z.array(z.string()).optional().default([]),\n /** Extension to save the client Id associated with an oauth flow */\n 'x-scalar-client-id': z.string().optional().default(''),\n /** The auth token */\n 'token': z.string().default(''),\n /** Additional query parameters for the OAuth authorization request. Example: { prompt: 'consent', audience: 'scalar' }. */\n 'x-scalar-security-query': z.record(z.string(), z.string()).optional(),\n /** Additional body parameters for the OAuth token request. Example: { audience: 'foo' }. */\n 'x-scalar-security-body': z.record(z.string(), z.string()).optional(),\n /** Extension to specify custom token name in the response (defaults to 'access_token') */\n 'x-tokenName': z.string().optional(),\n})\n\n/** Setup a default redirect uri if we can */\nconst defaultRedirectUri = typeof window !== 'undefined' ? window.location.origin + window.location.pathname : ''\n\n/** Options for the x-usePkce extension */\nexport const pkceOptions = ['SHA-256', 'plain', 'no'] as const\n\nconst credentialsLocationExtension = z.enum(['header', 'body']).optional()\n\n/** Oauth2 security scheme */\nconst oasSecuritySchemeOauth2 = commonProps.extend({\n type: z.literal('oauth2'),\n /** The default scopes for the oauth flow */\n 'x-default-scopes': z.string().or(z.array(z.string())).optional(),\n /** REQUIRED. An object containing configuration information for the flow types supported. */\n flows: z\n .object({\n /** Configuration for the OAuth Implicit flow */\n implicit: flowsCommon.extend({\n 'type': z.literal('implicit').default('implicit'),\n authorizationUrl,\n 'x-scalar-redirect-uri': z.string().optional().default(defaultRedirectUri),\n }),\n /** Configuration for the OAuth Resource Owner Password flow */\n password: flowsCommon.extend({\n type: z.literal('password').default('password'),\n tokenUrl,\n clientSecret: z.string().default(''),\n username: z.string().default(''),\n password: z.string().default(''),\n 'x-scalar-credentials-location': credentialsLocationExtension,\n }),\n /** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */\n clientCredentials: flowsCommon.extend({\n type: z.literal('clientCredentials').default('clientCredentials'),\n tokenUrl,\n clientSecret: z.string().default(''),\n 'x-scalar-credentials-location': credentialsLocationExtension,\n }),\n /** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/\n authorizationCode: flowsCommon.extend({\n 'type': z.literal('authorizationCode').default('authorizationCode'),\n authorizationUrl,\n 'x-usePkce': z.enum(pkceOptions).optional().default('no'),\n 'x-scalar-redirect-uri': z.string().optional().default(defaultRedirectUri),\n tokenUrl,\n clientSecret: z.string().default(''),\n 'x-scalar-credentials-location': credentialsLocationExtension,\n }),\n })\n .partial()\n .default({\n implicit: { type: 'implicit', authorizationUrl: 'http://localhost:8080' },\n }),\n})\n\nexport const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema)\n\nexport type SecuritySchemeOauth2 = z.infer<typeof securityOauthSchema>\nexport type SecuritySchemeOauth2Payload = z.input<typeof securityOauthSchema>\nexport type Oauth2Flow = NonNullable<\n SecuritySchemeOauth2['flows']['authorizationCode' | 'clientCredentials' | 'implicit' | 'password']\n>\n/** Payload for the oauth 2 flows + extensions */\nexport type Oauth2FlowPayload = NonNullable<SecuritySchemeOauth2Payload['flows']>[\n | 'authorizationCode'\n | 'clientCredentials'\n | 'implicit'\n | 'password'] &\n Record<`x-${string}`, string>\n\n// ---------------------------------------------------------------------------\n// Final Types\n\n/**\n * Security Requirement\n * Lists the required security schemes to execute this operation OR the whole collection/spec.\n * The name used for each property MUST correspond to a security scheme declared in the Security\n * Schemes under the Components Object.\n *\n * The key (name) here will be matched to the key of the securityScheme for linking\n *\n * @see https://spec.openapis.org/oas/latest.html#security-requirement-object\n */\nexport const oasSecurityRequirementSchema = z.record(z.string(), z.array(z.string()).optional().default([]))\n\n/** OAS Compliant security schemes */\nexport const oasSecuritySchemeSchema = z.union([\n oasSecuritySchemeApiKey,\n oasSecuritySchemeHttp,\n oasSecuritySchemeOauth2,\n oasSecuritySchemeOpenId,\n])\n\n/** Extended security schemes for workspace usage */\nexport const securitySchemeSchema = z\n .discriminatedUnion('type', [securityApiKeySchema, securityHttpSchema, securityOpenIdSchema, securityOauthSchema])\n .transform((data) => {\n // Set selected scopes from x-default-scopes\n if (data.type === 'oauth2' && data['x-default-scopes']?.length) {\n const keys = Object.keys(data.flows) as Array<keyof typeof data.flows>\n keys.forEach((key) => {\n if (data.flows[key]?.selectedScopes && data['x-default-scopes']) {\n data.flows[key].selectedScopes = [data['x-default-scopes']].flat()\n }\n })\n }\n return data\n })\n\n/**\n * Security Scheme Object\n *\n * @see https://spec.openapis.org/oas/latest.html#security-scheme-object\n */\nexport type SecurityScheme = z.infer<typeof securitySchemeSchema>\nexport type SecuritySchemePayload = z.input<typeof securitySchemeSchema>\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAElB,SAA6B,oBAAoB;AAMjD,MAAM,cAAc,EAAE,OAAO;AAAA;AAAA,EAE3B,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,KAAK,aAAa,MAAwC;AAAA;AAAA,EAE1D,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;AAC3C,CAAC;AAKM,MAAM,yBAAyB,CAAC,SAAS,UAAU,QAAQ;AAElE,MAAM,0BAA0B,YAAY,OAAO;AAAA,EACjD,MAAM,EAAE,QAAQ,QAAQ;AAAA;AAAA,EAExB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;AAAA;AAAA,EAEtC,IAAI,EAAE,KAAK,sBAAsB,EAAE,SAAS,EAAE,QAAQ,QAAQ,EAAE,MAAM,QAAQ;AAChF,CAAC;AAED,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACjC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;AAC9B,CAAC;AAEM,MAAM,uBAAuB,wBAAwB,MAAM,sBAAsB,EAAE,MAAM,iBAAiB;AAMjH,MAAM,wBAAwB,YAAY,OAAO;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ACjG,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAE3D,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;AAAA;AAAA,EAEtD,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA;AAAA,EAE9B,2BAA2B,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA,EAErE,0BAA0B,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA,EAEpE,eAAe,EAAE,OAAO,EAAE,SAAS;AACrC,CAAC;AAGD,MAAM,qBAAqB,OAAO,WAAW,cAAc,OAAO,SAAS,SAAS,OAAO,SAAS,WAAW;AAGxG,MAAM,cAAc,CAAC,WAAW,SAAS,IAAI;AAEpD,MAAM,+BAA+B,EAAE,KAAK,CAAC,UAAU,MAAM,CAAC,EAAE,SAAS;AAGzE,MAAM,0BAA0B,YAAY,OAAO;AAAA,EACjD,MAAM,EAAE,QAAQ,QAAQ;AAAA;AAAA,EAExB,oBAAoB,EAAE,
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\n\nimport { type ENTITY_BRANDS, nanoidSchema } from '../utils/nanoid'\n\n// ---------------------------------------------------------------------------\n// COMMON PROPS FOR ALL SECURITY SCHEMES\n\n/** Some common properties used in all security schemes */\nconst commonProps = z.object({\n /* A description for security scheme. CommonMark syntax MAY be used for rich text representation. */\n description: z.string().optional(),\n})\n\nconst extendedSecuritySchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['SECURITY_SCHEME']>(),\n /** The name key that links a security requirement to a security object */\n nameKey: z.string().optional().default(''),\n})\n\n// ---------------------------------------------------------------------------\n// API KEY\n\nexport const securitySchemeApiKeyIn = ['query', 'header', 'cookie'] as const\n\nconst oasSecuritySchemeApiKey = commonProps.extend({\n type: z.literal('apiKey'),\n /** REQUIRED. The name of the header, query or cookie parameter to be used. */\n name: z.string().optional().default(''),\n /** REQUIRED. The location of the API key. Valid values are \"query\", \"header\" or \"cookie\". */\n in: z.enum(securitySchemeApiKeyIn).optional().default('header').catch('header'),\n})\n\nconst apiKeyValueSchema = z.object({\n value: z.string().default(''),\n})\n\nexport const securityApiKeySchema = oasSecuritySchemeApiKey.merge(extendedSecuritySchema).merge(apiKeyValueSchema)\nexport type SecuritySchemeApiKey = z.infer<typeof securityApiKeySchema>\n\n// ---------------------------------------------------------------------------\n// HTTP\n\nconst oasSecuritySchemeHttp = commonProps.extend({\n type: z.literal('http'),\n /**\n * REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in\n * [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry.\n */\n scheme: z\n .string()\n .toLowerCase()\n .pipe(z.enum(['basic', 'bearer']))\n .optional()\n .default('basic'),\n /**\n * A hint to the client to identify how the bearer token is formatted.\n * Bearer tokens are usually generated by an authorization server, so\n * this information is primarily for documentation purposes.\n */\n bearerFormat: z\n .union([z.literal('JWT'), z.string()])\n .optional()\n .default('JWT'),\n})\n\nconst httpValueSchema = z.object({\n username: z.string().default(''),\n password: z.string().default(''),\n token: z.string().default(''),\n})\n\nexport const securityHttpSchema = oasSecuritySchemeHttp.merge(extendedSecuritySchema).merge(httpValueSchema)\nexport type SecuritySchemaHttp = z.infer<typeof securityHttpSchema>\n\n// ---------------------------------------------------------------------------\n// OPENID CONNECT\nconst oasSecuritySchemeOpenId = commonProps.extend({\n type: z.literal('openIdConnect'),\n /**\n * REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the\n * form of a URL. The OpenID Connect standard requires the use of TLS.\n */\n openIdConnectUrl: z.string().optional().default(''),\n})\n\nexport const securityOpenIdSchema = oasSecuritySchemeOpenId.merge(extendedSecuritySchema)\nexport type SecuritySchemaOpenId = z.infer<typeof securityOpenIdSchema>\n\n// ---------------------------------------------------------------------------\n\n/**\n * REQUIRED. The authorization URL to be used for this flow. This MUST be in\n * the form of a URL. The OAuth2 standard requires the use of TLS.\n */\nconst authorizationUrl = z.string().default('')\n\n/**\n * REQUIRED. The token URL to be used for this flow. This MUST be in the\n * form of a URL. The OAuth2 standard requires the use of TLS.\n */\nconst tokenUrl = z.string().default('')\n\n/** Common properties used across all oauth2 flows */\nconst flowsCommon = z.object({\n /**\n * The URL to be used for obtaining refresh tokens. This MUST be in the form of a\n * URL. The OAuth2 standard requires the use of TLS.\n */\n 'refreshUrl': z.string().optional().default(''),\n /**\n * REQUIRED. The available scopes for the OAuth2 security scheme. A map\n * between the scope name and a short description for it. The map MAY be empty.\n */\n 'scopes': z.record(z.string(), z.string().optional().default('')).optional().default({}).catch({}),\n 'selectedScopes': z.array(z.string()).optional().default([]),\n /** Extension to save the client Id associated with an oauth flow */\n 'x-scalar-client-id': z.string().optional().default(''),\n /** The auth token */\n 'token': z.string().default(''),\n /** Additional query parameters for the OAuth authorization request. Example: { prompt: 'consent', audience: 'scalar' }. */\n 'x-scalar-security-query': z.record(z.string(), z.string()).optional(),\n /** Additional body parameters for the OAuth token request. Example: { audience: 'foo' }. */\n 'x-scalar-security-body': z.record(z.string(), z.string()).optional(),\n /** Extension to specify custom token name in the response (defaults to 'access_token') */\n 'x-tokenName': z.string().optional(),\n})\n\n/** Setup a default redirect uri if we can */\nconst defaultRedirectUri = typeof window !== 'undefined' ? window.location.origin + window.location.pathname : ''\n\n/** Options for the x-usePkce extension */\nexport const pkceOptions = ['SHA-256', 'plain', 'no'] as const\n\nconst credentialsLocationExtension = z.enum(['header', 'body']).optional()\n\n/** Oauth2 security scheme */\nconst oasSecuritySchemeOauth2 = commonProps.extend({\n type: z.literal('oauth2'),\n /** The default scopes for the oauth flow */\n 'x-default-scopes': z.array(z.string()).optional(),\n /** REQUIRED. An object containing configuration information for the flow types supported. */\n flows: z\n .object({\n /** Configuration for the OAuth Implicit flow */\n implicit: flowsCommon.extend({\n 'type': z.literal('implicit').default('implicit'),\n authorizationUrl,\n 'x-scalar-redirect-uri': z.string().optional().default(defaultRedirectUri),\n }),\n /** Configuration for the OAuth Resource Owner Password flow */\n password: flowsCommon.extend({\n type: z.literal('password').default('password'),\n tokenUrl,\n clientSecret: z.string().default(''),\n username: z.string().default(''),\n password: z.string().default(''),\n 'x-scalar-credentials-location': credentialsLocationExtension,\n }),\n /** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */\n clientCredentials: flowsCommon.extend({\n type: z.literal('clientCredentials').default('clientCredentials'),\n tokenUrl,\n clientSecret: z.string().default(''),\n 'x-scalar-credentials-location': credentialsLocationExtension,\n }),\n /** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/\n authorizationCode: flowsCommon.extend({\n 'type': z.literal('authorizationCode').default('authorizationCode'),\n authorizationUrl,\n 'x-usePkce': z.enum(pkceOptions).optional().default('no'),\n 'x-scalar-redirect-uri': z.string().optional().default(defaultRedirectUri),\n tokenUrl,\n clientSecret: z.string().default(''),\n 'x-scalar-credentials-location': credentialsLocationExtension,\n }),\n })\n .partial()\n .default({\n implicit: {\n selectedScopes: [],\n scopes: {},\n 'x-scalar-client-id': '',\n refreshUrl: '',\n token: '',\n type: 'implicit',\n authorizationUrl: 'http://localhost:8080',\n 'x-scalar-redirect-uri': defaultRedirectUri,\n },\n }),\n})\n\nexport const securityOauthSchema = oasSecuritySchemeOauth2.merge(extendedSecuritySchema)\n\nexport type SecuritySchemeOauth2 = z.infer<typeof securityOauthSchema>\nexport type SecuritySchemeOauth2Payload = z.input<typeof securityOauthSchema>\nexport type Oauth2Flow = NonNullable<\n SecuritySchemeOauth2['flows']['authorizationCode' | 'clientCredentials' | 'implicit' | 'password']\n>\n/** Payload for the oauth 2 flows + extensions */\nexport type Oauth2FlowPayload = NonNullable<SecuritySchemeOauth2Payload['flows']>[\n | 'authorizationCode'\n | 'clientCredentials'\n | 'implicit'\n | 'password'] &\n Record<`x-${string}`, string>\n\n// ---------------------------------------------------------------------------\n// Final Types\n\n/**\n * Security Requirement\n * Lists the required security schemes to execute this operation OR the whole collection/spec.\n * The name used for each property MUST correspond to a security scheme declared in the Security\n * Schemes under the Components Object.\n *\n * The key (name) here will be matched to the key of the securityScheme for linking\n *\n * @see https://spec.openapis.org/oas/latest.html#security-requirement-object\n */\nexport const oasSecurityRequirementSchema = z.record(z.string(), z.array(z.string()).optional().default([]))\n\n/** OAS Compliant security schemes */\nexport const oasSecuritySchemeSchema = z.union([\n oasSecuritySchemeApiKey,\n oasSecuritySchemeHttp,\n oasSecuritySchemeOauth2,\n oasSecuritySchemeOpenId,\n])\n\n/** Extended security schemes for workspace usage */\nexport const securitySchemeSchema = z\n .discriminatedUnion('type', [securityApiKeySchema, securityHttpSchema, securityOpenIdSchema, securityOauthSchema])\n .transform((data) => {\n // Set selected scopes from x-default-scopes\n if (data.type === 'oauth2' && data['x-default-scopes']?.length) {\n const keys = Object.keys(data.flows) as Array<keyof typeof data.flows>\n keys.forEach((key) => {\n if (data.flows[key]?.selectedScopes && data['x-default-scopes']) {\n data.flows[key].selectedScopes = [data['x-default-scopes']].flat()\n }\n })\n }\n return data\n })\n\n/**\n * Security Scheme Object\n *\n * @see https://spec.openapis.org/oas/latest.html#security-scheme-object\n */\nexport type SecurityScheme = z.infer<typeof securitySchemeSchema>\nexport type SecuritySchemePayload = z.input<typeof securitySchemeSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAElB,SAA6B,oBAAoB;AAMjD,MAAM,cAAc,EAAE,OAAO;AAAA;AAAA,EAE3B,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,KAAK,aAAa,MAAwC;AAAA;AAAA,EAE1D,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE;AAC3C,CAAC;AAKM,MAAM,yBAAyB,CAAC,SAAS,UAAU,QAAQ;AAElE,MAAM,0BAA0B,YAAY,OAAO;AAAA,EAC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B;AAAA,EACF,CAAC;AACL,CAAC;AAEM,MAAM,sBAAsB,wBAAwB,MAAM,sBAAsB;AA4BhF,MAAM,+BAA+B,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGpG,MAAM,0BAA0B,EAAE,MAAM;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,uBAAuB,EACjC,mBAAmB,QAAQ,CAAC,sBAAsB,oBAAoB,sBAAsB,mBAAmB,CAAC,EAChH,UAAU,CAAC,SAAS;AAEnB,MAAI,KAAK,SAAS,YAAY,KAAK,kBAAkB,GAAG,QAAQ;AAC9D,UAAM,OAAO,OAAO,KAAK,KAAK,KAAK;AACnC,SAAK,QAAQ,CAAC,QAAQ;AACpB,UAAI,KAAK,MAAM,GAAG,GAAG,kBAAkB,KAAK,kBAAkB,GAAG;AAC/D,aAAK,MAAM,GAAG,EAAE,iBAAiB,CAAC,KAAK,kBAAkB,CAAC,EAAE,KAAK;AAAA,MACnE;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Request as HarRequest } from 'har-format';
|
|
2
|
-
|
|
2
|
+
import type { Writable } from 'type-fest/source/writable';
|
|
3
|
+
export type { Param as FormDataParam, Request as HarRequest } from 'har-format';
|
|
3
4
|
/**
|
|
4
5
|
* List of available clients
|
|
5
6
|
*/
|
|
6
7
|
export declare const AVAILABLE_CLIENTS: readonly ["c/libcurl", "clojure/clj_http", "csharp/httpclient", "csharp/restsharp", "dart/http", "go/native", "http/http1.1", "java/asynchttp", "java/nethttp", "java/okhttp", "java/unirest", "js/axios", "js/fetch", "js/jquery", "js/ofetch", "js/xhr", "kotlin/okhttp", "node/axios", "node/fetch", "node/ofetch", "node/undici", "objc/nsurlsession", "ocaml/cohttp", "php/curl", "php/guzzle", "powershell/restmethod", "powershell/webrequest", "python/python3", "python/requests", "python/httpx_sync", "python/httpx_async", "r/httr", "ruby/native", "rust/reqwest", "shell/curl", "shell/httpie", "shell/wget", "swift/nsurlsession"];
|
|
7
|
-
|
|
8
|
+
/** Non read only tuple of available clients */
|
|
9
|
+
export type AvailableClients = Writable<typeof AVAILABLE_CLIENTS>;
|
|
10
|
+
/** A union for a single available client */
|
|
11
|
+
export type AvailableClient = AvailableClients[number];
|
|
12
|
+
/** A non read only array of available clients */
|
|
13
|
+
export type AvailableClientsArray = AvailableClients[number][];
|
|
8
14
|
/** Programming language */
|
|
9
15
|
export type TargetId = AvailableClients[number] extends `${infer T}/${string}` ? T : never;
|
|
10
16
|
/** Configuration for a target */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippetz.d.ts","sourceRoot":"","sources":["../../src/snippetz/snippetz.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"snippetz.d.ts","sourceRoot":"","sources":["../../src/snippetz/snippetz.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAEzD,YAAY,EAAE,KAAK,IAAI,aAAa,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAE/E;;GAEG;AACH,eAAO,MAAM,iBAAiB,mnBAuCpB,CAAA;AAEV,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,iBAAiB,CAAC,CAAA;AACjE,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;AACtD,iDAAiD;AACjD,MAAM,MAAM,qBAAqB,GAAG,gBA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 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/snippetz/snippetz.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Request as HarRequest } from 'har-format'\n\nexport type {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { Request as HarRequest } from 'har-format'\nimport type { Writable } from 'type-fest/source/writable'\n\nexport type { Param as FormDataParam, Request as HarRequest } from 'har-format'\n\n/**\n * List of available clients\n */\nexport const AVAILABLE_CLIENTS = [\n 'c/libcurl',\n 'clojure/clj_http',\n 'csharp/httpclient',\n 'csharp/restsharp',\n 'dart/http',\n 'go/native',\n 'http/http1.1',\n 'java/asynchttp',\n 'java/nethttp',\n 'java/okhttp',\n 'java/unirest',\n 'js/axios',\n 'js/fetch',\n 'js/jquery',\n 'js/ofetch',\n 'js/xhr',\n 'kotlin/okhttp',\n 'node/axios',\n 'node/fetch',\n 'node/ofetch',\n 'node/undici',\n 'objc/nsurlsession',\n 'ocaml/cohttp',\n 'php/curl',\n 'php/guzzle',\n 'powershell/restmethod',\n 'powershell/webrequest',\n 'python/python3',\n 'python/requests',\n 'python/httpx_sync',\n 'python/httpx_async',\n 'r/httr',\n 'ruby/native',\n 'rust/reqwest',\n 'shell/curl',\n 'shell/httpie',\n 'shell/wget',\n 'swift/nsurlsession',\n] as const\n\n/** Non read only tuple of available clients */\nexport type AvailableClients = Writable<typeof AVAILABLE_CLIENTS>\n/** A union for a single available client */\nexport type AvailableClient = AvailableClients[number]\n/** A non read only array of available clients */\nexport type AvailableClientsArray = AvailableClients[number][]\n\n/** Programming language */\nexport type TargetId = AvailableClients[number] extends `${infer T}/${string}` ? T : never\n\n/** Configuration for a target */\nexport type Target = {\n [K in TargetId]: {\n key: K\n title: string\n default: ClientId<K>\n clients: Plugin[]\n }\n}[TargetId]\n\n/** HTTP client */\nexport type ClientId<T extends string> = T extends TargetId\n ? Extract<AvailableClients[number], `${T}/${string}`> extends `${T}/${infer C}`\n ? C\n : never\n : never\n\n/** What any plugins needs to return */\nexport type Plugin = {\n /** The language or environment. */\n target: TargetId\n /** The identifier of the client. */\n client: ClientId<TargetId>\n /** The title of the client. */\n title: string\n /** The actual source code. */\n generate: (request?: Partial<HarRequest>, configuration?: PluginConfiguration) => string\n}\n\n/**\n * Optional configuration for any plugin\n */\nexport type PluginConfiguration = {\n /** Credentials to add HTTP Basic Authentication */\n auth?: { username: string; password: string }\n}\n"],
|
|
5
|
+
"mappings": "AAQO,MAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"scalar",
|
|
17
17
|
"references"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.3.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
],
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"nanoid": "5.1.5",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
68
|
+
"type-fest": "4.41.0",
|
|
69
|
+
"zod": "4.1.11",
|
|
70
|
+
"@scalar/openapi-types": "0.4.0"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@types/har-format": "^1.2.15",
|
|
73
|
-
"type-fest": "4.41.0",
|
|
74
74
|
"vite": "7.1.5",
|
|
75
75
|
"@scalar/build-tooling": "0.2.7"
|
|
76
76
|
},
|