UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

526 lines (485 loc) 18.2 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { smartUnion } from "../types/smartUnion.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type GetMicrofrontendsConfigForProjectRequest = { /** * The name or ID of the project */ projectIdOrName: string; /** * The Team identifier to perform the request on behalf of. */ teamId?: string | undefined; /** * The Team slug to perform the request on behalf of. */ slug?: string | undefined; }; /** * The version of the microfrontends config schema. */ export const GetMicrofrontendsConfigForProjectVersion = { One: "1", } as const; /** * The version of the microfrontends config schema. */ export type GetMicrofrontendsConfigForProjectVersion = ClosedEnum< typeof GetMicrofrontendsConfigForProjectVersion >; export type GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocal = | string | number; /** * Development configuration for the child application. */ export type GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment = { /** * Fallback for local development, could point to any environment. If not provided for child apps, the fallback of the default app will be used. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS. See https://vercel.com/docs/microfrontends/local-development. */ fallback?: string | undefined; local?: string | number | undefined; /** * The task to run when starting the development server. Should reference a script in the package.json of the application. The default value is "dev". See https://vercel.com/docs/microfrontends/local-development. */ task?: string | undefined; }; /** * Groups of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing. */ export type ApplicationsRouting = { /** * Group name for the paths. */ group?: string | undefined; /** * The name of the feature flag that controls routing for this group of paths. See https://vercel.com/docs/microfrontends/path-routing#routing-changes-safely-with-flags. */ flag?: string | undefined; /** * A list of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions. */ paths: Array<string>; }; export type GetMicrofrontendsConfigForProjectApplications2 = { /** * Development configuration for the child application. */ development?: | GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment | undefined; /** * Groups of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing. */ routing: Array<ApplicationsRouting>; /** * The name of the asset prefix to use instead of the auto-generated name. The asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain. An auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided. When this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field. The default value is the auto-generated asset prefix of the form `vc-ap-<hash>`. See https://vercel.com/docs/microfrontends/path-routing#asset-prefix. */ assetPrefix?: string | undefined; /** * The name used to run the application, e.g. the `name` field in the `package.json`. This is used by the local proxy to map the application config to the locally running app. This is only necessary when the application name does not match the `name` used in `package.json`. See https://vercel.com/docs/microfrontends/configuration#application-naming. */ packageName?: string | undefined; projectId: string; }; export type GetMicrofrontendsConfigForProjectApplicationsLocal = | string | number; /** * Development configuration for the default application. */ export type GetMicrofrontendsConfigForProjectApplicationsDevelopment = { /** * Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS. See https://vercel.com/docs/microfrontends/local-development. */ fallback: string; local?: string | number | undefined; /** * The task to run when starting the development server. Should reference a script in the package.json of the application. The default value is "dev". See https://vercel.com/docs/microfrontends/local-development. */ task?: string | undefined; }; export type GetMicrofrontendsConfigForProjectApplications1 = { /** * Development configuration for the default application. */ development: GetMicrofrontendsConfigForProjectApplicationsDevelopment; /** * The name used to run the application, e.g. the `name` field in the `package.json`. This is used by the local proxy to map the application config to the locally running app. This is only necessary when the application name does not match the `name` used in `package.json`. See https://vercel.com/docs/microfrontends/configuration#application-naming. */ packageName?: string | undefined; projectId: string; }; export type GetMicrofrontendsConfigForProjectApplications = | GetMicrofrontendsConfigForProjectApplications1 | GetMicrofrontendsConfigForProjectApplications2; /** * Optional configuration options for the microfrontend. */ export type GetMicrofrontendsConfigForProjectOptions = { /** * If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect. See https://vercel.com/docs/microfrontends/managing-microfrontends/vercel-toolbar#routing-overrides. */ disableOverrides?: boolean | undefined; /** * The port number used by the local proxy server. The default value is 3024. See https://vercel.com/docs/microfrontends/local-development. */ localProxyPort?: number | undefined; }; /** * projectIds are added when the config is uploaded to s3 deployment assets. */ export type GetMicrofrontendsConfigForProjectConfig = { /** * See https://openapi.vercel.sh/microfrontends.json. */ dollarSchema?: string | undefined; /** * The version of the microfrontends config schema. */ version?: GetMicrofrontendsConfigForProjectVersion | undefined; applications: { [k: string]: | GetMicrofrontendsConfigForProjectApplications1 | GetMicrofrontendsConfigForProjectApplications2; }; /** * Optional configuration options for the microfrontend. */ options?: GetMicrofrontendsConfigForProjectOptions | undefined; }; export type GetMicrofrontendsConfigForProjectResponseBody = { /** * projectIds are added when the config is uploaded to s3 deployment assets. */ config: GetMicrofrontendsConfigForProjectConfig | null; }; /** @internal */ export type GetMicrofrontendsConfigForProjectRequest$Outbound = { projectIdOrName: string; teamId?: string | undefined; slug?: string | undefined; }; /** @internal */ export const GetMicrofrontendsConfigForProjectRequest$outboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectRequest$Outbound, z.ZodTypeDef, GetMicrofrontendsConfigForProjectRequest > = z.object({ projectIdOrName: z.string(), teamId: z.string().optional(), slug: z.string().optional(), }); export function getMicrofrontendsConfigForProjectRequestToJSON( getMicrofrontendsConfigForProjectRequest: GetMicrofrontendsConfigForProjectRequest, ): string { return JSON.stringify( GetMicrofrontendsConfigForProjectRequest$outboundSchema.parse( getMicrofrontendsConfigForProjectRequest, ), ); } /** @internal */ export const GetMicrofrontendsConfigForProjectVersion$inboundSchema: z.ZodNativeEnum<typeof GetMicrofrontendsConfigForProjectVersion> = z .nativeEnum(GetMicrofrontendsConfigForProjectVersion); /** @internal */ export const GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocal$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocal, z.ZodTypeDef, unknown > = smartUnion([types.string(), types.number()]); export function getMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocalFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocal, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocal$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsLocal' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment, z.ZodTypeDef, unknown > = z.object({ fallback: types.optional(types.string()), local: types.optional(smartUnion([types.string(), types.number()])), task: types.optional(types.string()), }); export function getMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopmentFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment' from JSON`, ); } /** @internal */ export const ApplicationsRouting$inboundSchema: z.ZodType< ApplicationsRouting, z.ZodTypeDef, unknown > = z.object({ group: types.optional(types.string()), flag: types.optional(types.string()), paths: z.array(types.string()), }); export function applicationsRoutingFromJSON( jsonString: string, ): SafeParseResult<ApplicationsRouting, SDKValidationError> { return safeParse( jsonString, (x) => ApplicationsRouting$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApplicationsRouting' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectApplications2$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplications2, z.ZodTypeDef, unknown > = z.object({ development: types.optional( z.lazy(() => GetMicrofrontendsConfigForProjectApplicationsMicrofrontendsDevelopment$inboundSchema ), ), routing: z.array(z.lazy(() => ApplicationsRouting$inboundSchema)), assetPrefix: types.optional(types.string()), packageName: types.optional(types.string()), projectId: types.string(), }); export function getMicrofrontendsConfigForProjectApplications2FromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplications2, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplications2$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectApplications2' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectApplicationsLocal$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplicationsLocal, z.ZodTypeDef, unknown > = smartUnion([types.string(), types.number()]); export function getMicrofrontendsConfigForProjectApplicationsLocalFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplicationsLocal, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplicationsLocal$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectApplicationsLocal' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectApplicationsDevelopment$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplicationsDevelopment, z.ZodTypeDef, unknown > = z.object({ fallback: types.string(), local: types.optional(smartUnion([types.string(), types.number()])), task: types.optional(types.string()), }); export function getMicrofrontendsConfigForProjectApplicationsDevelopmentFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplicationsDevelopment, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplicationsDevelopment$inboundSchema .parse(JSON.parse(x)), `Failed to parse 'GetMicrofrontendsConfigForProjectApplicationsDevelopment' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectApplications1$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplications1, z.ZodTypeDef, unknown > = z.object({ development: z.lazy(() => GetMicrofrontendsConfigForProjectApplicationsDevelopment$inboundSchema ), packageName: types.optional(types.string()), projectId: types.string(), }); export function getMicrofrontendsConfigForProjectApplications1FromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplications1, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplications1$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectApplications1' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectApplications$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectApplications, z.ZodTypeDef, unknown > = smartUnion([ z.lazy(() => GetMicrofrontendsConfigForProjectApplications1$inboundSchema), z.lazy(() => GetMicrofrontendsConfigForProjectApplications2$inboundSchema), ]); export function getMicrofrontendsConfigForProjectApplicationsFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectApplications, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectApplications$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectApplications' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectOptions$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectOptions, z.ZodTypeDef, unknown > = z.object({ disableOverrides: types.optional(types.boolean()), localProxyPort: types.optional(types.number()), }); export function getMicrofrontendsConfigForProjectOptionsFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectOptions, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectOptions$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectOptions' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectConfig$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectConfig, z.ZodTypeDef, unknown > = z.object({ $schema: types.optional(types.string()), version: types.optional( GetMicrofrontendsConfigForProjectVersion$inboundSchema, ), applications: z.record( smartUnion([ z.lazy(() => GetMicrofrontendsConfigForProjectApplications1$inboundSchema ), z.lazy(() => GetMicrofrontendsConfigForProjectApplications2$inboundSchema ), ]), ), options: types.optional( z.lazy(() => GetMicrofrontendsConfigForProjectOptions$inboundSchema), ), }).transform((v) => { return remap$(v, { "$schema": "dollarSchema", }); }); export function getMicrofrontendsConfigForProjectConfigFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectConfig, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectConfig$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectConfig' from JSON`, ); } /** @internal */ export const GetMicrofrontendsConfigForProjectResponseBody$inboundSchema: z.ZodType< GetMicrofrontendsConfigForProjectResponseBody, z.ZodTypeDef, unknown > = z.object({ config: types.nullable( z.lazy(() => GetMicrofrontendsConfigForProjectConfig$inboundSchema), ), }); export function getMicrofrontendsConfigForProjectResponseBodyFromJSON( jsonString: string, ): SafeParseResult< GetMicrofrontendsConfigForProjectResponseBody, SDKValidationError > { return safeParse( jsonString, (x) => GetMicrofrontendsConfigForProjectResponseBody$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetMicrofrontendsConfigForProjectResponseBody' from JSON`, ); }