UNPKG

@seamapi/blueprint

Version:

Build tools for the Seam API using this blueprint.

612 lines (604 loc) 20.8 kB
import { z } from 'zod'; declare const LiteralSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>; type Literal = z.infer<typeof LiteralSchema>; type Json = Literal | { [key: string]: Json; } | Json[]; declare const SdkNameSchema: z.ZodEnum<["javascript", "python", "php", "ruby", "seam_cli", "go", "java", "csharp", "curl"]>; declare const SyntaxNameSchema: z.ZodEnum<["javascript", "json", "python", "php", "ruby", "bash", "go", "java", "csharp"]>; type SyntaxName = z.infer<typeof SyntaxNameSchema>; type SdkName = z.infer<typeof SdkNameSchema>; declare const CodeSampleDefinitionSchema: z.ZodObject<{ title: z.ZodString; description: z.ZodString; request: z.ZodObject<{ path: z.ZodString; parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>>>; }, "strip", z.ZodTypeAny, { path: string; parameters: Record<string, Json>; }, { path: string; parameters?: Record<string, Json> | undefined; }>; response: z.ZodObject<{ body: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>>; }, "strip", z.ZodTypeAny, { body: Record<string, Json> | null; }, { body: Record<string, Json> | null; }>; }, "strip", z.ZodTypeAny, { description: string; title: string; request: { path: string; parameters: Record<string, Json>; }; response: { body: Record<string, Json> | null; }; }, { description: string; title: string; request: { path: string; parameters?: Record<string, Json> | undefined; }; response: { body: Record<string, Json> | null; }; }>; type CodeSampleDefinitionInput = z.input<typeof CodeSampleDefinitionSchema>; declare const _CodeSampleSchema: z.ZodObject<{ title: z.ZodString; description: z.ZodString; request: z.ZodObject<{ path: z.ZodString; parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>>>; }, "strip", z.ZodTypeAny, { path: string; parameters: Record<string, Json>; }, { path: string; parameters?: Record<string, Json> | undefined; }>; response: z.ZodObject<{ body: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>>; }, "strip", z.ZodTypeAny, { body: Record<string, Json> | null; }, { body: Record<string, Json> | null; }>; } & { code: z.ZodRecord<z.ZodEnum<["javascript", "python", "php", "ruby", "seam_cli", "go", "java", "csharp", "curl"]>, z.ZodObject<{ title: z.ZodString; sdkName: z.ZodEnum<["javascript", "python", "php", "ruby", "seam_cli", "go", "java", "csharp", "curl"]>; request: z.ZodString; response: z.ZodString; request_syntax: z.ZodEnum<["javascript", "json", "python", "php", "ruby", "bash", "go", "java", "csharp"]>; response_syntax: z.ZodEnum<["javascript", "json", "python", "php", "ruby", "bash", "go", "java", "csharp"]>; }, "strip", z.ZodTypeAny, { title: string; sdkName: "javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl"; request: string; response: string; request_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; response_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }, { title: string; sdkName: "javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl"; request: string; response: string; request_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; response_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }>>; }, "strip", z.ZodTypeAny, { code: Partial<Record<"javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl", { title: string; sdkName: "javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl"; request: string; response: string; request_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; response_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }>>; description: string; title: string; request: { path: string; parameters: Record<string, Json>; }; response: { body: Record<string, Json> | null; }; }, { code: Partial<Record<"javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl", { title: string; sdkName: "javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl"; request: string; response: string; request_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; response_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }>>; description: string; title: string; request: { path: string; parameters?: Record<string, Json> | undefined; }; response: { body: Record<string, Json> | null; }; }>; type CodeSample = z.output<typeof _CodeSampleSchema>; declare const ResourceSampleDefinitionSchema: z.ZodObject<{ title: z.ZodString; description: z.ZodString; resource_type: z.ZodString; properties: z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>; }, "strip", z.ZodTypeAny, { description: string; properties: Record<string, Json>; title: string; resource_type: string; }, { description: string; properties: Record<string, Json>; title: string; resource_type: string; }>; type ResourceSampleDefinitionInput = z.input<typeof ResourceSampleDefinitionSchema>; declare const _ResourceSampleSchema: z.ZodObject<{ title: z.ZodString; description: z.ZodString; resource_type: z.ZodString; properties: z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>; } & { resource: z.ZodRecord<z.ZodEnum<["javascript", "python", "php", "ruby", "seam_cli", "go", "java", "csharp", "curl"]>, z.ZodObject<{ title: z.ZodString; resource_data: z.ZodString; resource_data_syntax: z.ZodEnum<["javascript", "json", "python", "php", "ruby", "bash", "go", "java", "csharp"]>; }, "strip", z.ZodTypeAny, { title: string; resource_data: string; resource_data_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }, { title: string; resource_data: string; resource_data_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }>>; }, "strip", z.ZodTypeAny, { description: string; properties: Record<string, Json>; title: string; resource: Partial<Record<"javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl", { title: string; resource_data: string; resource_data_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }>>; resource_type: string; }, { description: string; properties: Record<string, Json>; title: string; resource: Partial<Record<"javascript" | "python" | "php" | "ruby" | "seam_cli" | "go" | "java" | "csharp" | "curl", { title: string; resource_data: string; resource_data_syntax: "javascript" | "python" | "php" | "ruby" | "go" | "java" | "csharp" | "json" | "bash"; }>>; resource_type: string; }>; type ResourceSample = z.output<typeof _ResourceSampleSchema>; type SeamWorkspaceScope = 'none' | 'optional' | 'required'; type SeamAuthMethod = 'api_key' | 'personal_access_token' | 'console_session_token' | 'client_session_token' | 'publishable_key'; interface Blueprint { title: string; routes: Route[]; namespaces: Namespace[]; resources: Resource[]; pagination: Pagination | null; events: EventResource[]; actionAttempts: ActionAttempt[]; } interface Route { path: string; name: string; namespacePath: string | null; endpoints: Endpoint[]; parentPath: string | null; isUndocumented: boolean; isDeprecated: boolean; isDraft: boolean; } interface Resource { resourceType: string; properties: Property[]; description: string; routePath: string; isDeprecated: boolean; deprecationMessage: string; isUndocumented: boolean; undocumentedMessage: string; isDraft: boolean; draftMessage: string; propertyGroups: PropertyGroup[]; resourceSamples: ResourceSample[]; } interface PropertyGroup { name: string; propertyGroupKey: string; } interface VariantGroup { name: string; variantGroupKey: string; } interface Pagination { properties: Property[]; description: string; responseKey: string; } interface EventResource extends Resource { resourceType: 'event'; eventType: string; } interface ActionAttempt extends Resource { resourceType: 'action_attempt'; actionAttemptType: string; } interface Namespace { name: string; path: string; parentPath: string | null; isDeprecated: boolean; isUndocumented: boolean; isDraft: boolean; } interface Endpoint { title: string; path: string; name: string; parentPath: string | null; description: string; isDeprecated: boolean; deprecationMessage: string; isUndocumented: boolean; undocumentedMessage: string; isDraft: boolean; draftMessage: string; request: Request; response: Response; hasPagination: boolean; codeSamples: CodeSample[]; authMethods: SeamAuthMethod[]; workspaceScope: SeamWorkspaceScope; } interface BaseParameter { name: string; description: string; isRequired: boolean; isDeprecated: boolean; deprecationMessage: string; isUndocumented: boolean; undocumentedMessage: string; isDraft: boolean; draftMessage: string; hasDefault: boolean; } interface StringParameter extends BaseParameter { format: 'string'; jsonType: 'string'; default?: string | null; } interface NumberParameter extends BaseParameter { format: 'number'; jsonType: 'number'; default?: number | null; } interface EnumParameter extends BaseParameter { format: 'enum'; jsonType: 'string'; values: EnumValue[]; default?: string | null; } interface RecordParameter extends BaseParameter { format: 'record'; jsonType: 'object'; } interface BaseListParameter extends BaseParameter { format: 'list'; jsonType: 'array'; } type ListParameter = StringListParameter | NumberListParameter | BooleanListParameter | DatetimeListParameter | IdListParameter | EnumListParameter | ObjectListParameter | RecordListParameter | DiscriminatedListParameter; interface StringListParameter extends BaseListParameter { itemFormat: 'string'; default?: string[]; } interface NumberListParameter extends BaseListParameter { itemFormat: 'number'; default?: number[]; } interface BooleanListParameter extends BaseListParameter { itemFormat: 'boolean'; default?: boolean[]; } interface DatetimeListParameter extends BaseListParameter { itemFormat: 'datetime'; default?: string[]; } interface IdListParameter extends BaseListParameter { itemFormat: 'id'; default?: string[]; } interface EnumListParameter extends BaseListParameter { itemFormat: 'enum'; itemEnumValues: EnumValue[]; default?: EnumValue[]; } interface ObjectListParameter extends BaseListParameter { itemFormat: 'object'; itemParameters: Parameter[]; } interface RecordListParameter extends BaseListParameter { itemFormat: 'record'; } interface DiscriminatedListParameter extends BaseListParameter { itemFormat: 'discriminated_object'; discriminator: string; variants: Array<{ parameters: Parameter[]; description: BaseParameter['description']; }>; } interface BooleanParameter extends BaseParameter { format: 'boolean'; jsonType: 'boolean'; default?: boolean | null; } interface ObjectParameter extends BaseParameter { format: 'object'; jsonType: 'object'; parameters: Parameter[]; } interface DatetimeParameter extends BaseParameter { format: 'datetime'; jsonType: 'string'; default?: string | null; } interface IdParameter extends BaseParameter { format: 'id'; jsonType: 'string'; default?: string | null; } type Parameter = StringParameter | NumberParameter | EnumParameter | RecordParameter | ListParameter | BooleanParameter | ObjectParameter | DatetimeParameter | IdParameter; interface Request { methods: Method[]; semanticMethod: Method; preferredMethod: Method; parameters: Parameter[]; } type Response = VoidResponse | ResourceResponse | ResourceListResponse; interface BaseResponse { description: string; } interface VoidResponse extends BaseResponse { responseType: 'void'; } interface ResourceResponse extends BaseResponse { responseType: 'resource'; responseKey: string; resourceType: string; actionAttemptType: string | null; batchResourceTypes: Array<{ batchKey: string; resourceType: string; }> | null; } interface ResourceListResponse extends BaseResponse { responseType: 'resource_list'; responseKey: string; resourceType: string; } interface BaseProperty { name: string; description: string; isDeprecated: boolean; deprecationMessage: string; isUndocumented: boolean; undocumentedMessage: string; isDraft: boolean; draftMessage: string; propertyGroupKey: string | null; } type Property = StringProperty | NumberProperty | EnumProperty | RecordProperty | ListProperty | ObjectProperty | BooleanProperty | DatetimeProperty | IdProperty | BatchResourceProperty; interface StringProperty extends BaseProperty { format: 'string'; jsonType: 'string'; } interface NumberProperty extends BaseProperty { format: 'number'; jsonType: 'number'; } interface EnumProperty extends BaseProperty { format: 'enum'; jsonType: 'string'; values: EnumValue[]; } type EnumValue = BaseProperty; interface RecordProperty extends BaseProperty { format: 'record'; jsonType: 'object'; } interface BaseListProperty extends BaseProperty { format: 'list'; jsonType: 'array'; } interface StringListProperty extends BaseListProperty { itemFormat: 'string'; } interface NumberListProperty extends BaseListProperty { itemFormat: 'number'; } interface BooleanListProperty extends BaseListProperty { itemFormat: 'boolean'; } interface DatetimeListProperty extends BaseListProperty { itemFormat: 'datetime'; } interface IdListProperty extends BaseListProperty { itemFormat: 'id'; } interface BatchResourceProperty extends BaseProperty { format: 'record'; jsonType: 'object'; resourceType: string; } interface EnumListProperty extends BaseListProperty { itemFormat: 'enum'; itemEnumValues: EnumValue[]; } interface ObjectListProperty extends BaseListProperty { itemFormat: 'object'; itemProperties: Property[]; } interface RecordListProperty extends BaseListProperty { itemFormat: 'record'; } interface DiscriminatedListProperty extends BaseListProperty { itemFormat: 'discriminated_object'; discriminator: string; variantGroups: VariantGroup[]; variants: Array<{ resourceType: string | null; variantGroupKey: string | null; properties: Property[]; description: BaseProperty['description']; }>; } type ListProperty = StringListProperty | NumberListProperty | BooleanListProperty | DatetimeListProperty | IdListProperty | EnumListProperty | ObjectListProperty | RecordListProperty | DiscriminatedListProperty; interface BooleanProperty extends BaseProperty { format: 'boolean'; jsonType: 'boolean'; } interface ObjectProperty extends BaseProperty { format: 'object'; jsonType: 'object'; properties: Property[]; propertyGroups: PropertyGroup[]; } interface DatetimeProperty extends BaseProperty { format: 'datetime'; jsonType: 'string'; } interface IdProperty extends BaseProperty { format: 'id'; jsonType: 'string'; } type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; declare const TypesModuleSchema: z.ZodObject<{ codeSampleDefinitions: z.ZodDefault<z.ZodArray<z.ZodObject<{ title: z.ZodString; description: z.ZodString; request: z.ZodObject<{ path: z.ZodString; parameters: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>>>; }, "strip", z.ZodTypeAny, { path: string; parameters: Record<string, Json>; }, { path: string; parameters?: Record<string, Json> | undefined; }>; response: z.ZodObject<{ body: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>>; }, "strip", z.ZodTypeAny, { body: Record<string, Json> | null; }, { body: Record<string, Json> | null; }>; }, "strip", z.ZodTypeAny, { description: string; title: string; request: { path: string; parameters: Record<string, Json>; }; response: { body: Record<string, Json> | null; }; }, { description: string; title: string; request: { path: string; parameters?: Record<string, Json> | undefined; }; response: { body: Record<string, Json> | null; }; }>, "many">>; resourceSampleDefinitions: z.ZodDefault<z.ZodArray<z.ZodObject<{ title: z.ZodString; description: z.ZodString; resource_type: z.ZodString; properties: z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>; }, "strip", z.ZodTypeAny, { description: string; properties: Record<string, Json>; title: string; resource_type: string; }, { description: string; properties: Record<string, Json>; title: string; resource_type: string; }>, "many">>; openapi: z.ZodAny; schemas: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>; }, "strip", z.ZodTypeAny, { codeSampleDefinitions: { description: string; title: string; request: { path: string; parameters: Record<string, Json>; }; response: { body: Record<string, Json> | null; }; }[]; resourceSampleDefinitions: { description: string; properties: Record<string, Json>; title: string; resource_type: string; }[]; schemas: Record<string, unknown>; openapi?: any; }, { codeSampleDefinitions?: { description: string; title: string; request: { path: string; parameters?: Record<string, Json> | undefined; }; response: { body: Record<string, Json> | null; }; }[] | undefined; resourceSampleDefinitions?: { description: string; properties: Record<string, Json>; title: string; resource_type: string; }[] | undefined; openapi?: any; schemas?: Record<string, unknown> | undefined; }>; type TypesModuleInput = z.input<typeof TypesModuleSchema>; type TypesModule = z.output<typeof TypesModuleSchema>; interface BlueprintOptions { formatCode?: (content: string, syntax: SyntaxName) => Promise<string>; } declare const createBlueprint: (typesModule: TypesModuleInput, { formatCode }?: BlueprintOptions) => Promise<Blueprint>; export { type ActionAttempt, type Blueprint, type BlueprintOptions, type CodeSample, type CodeSampleDefinitionInput, CodeSampleDefinitionSchema, type DiscriminatedListProperty, type Endpoint, type EnumProperty, type EventResource, type Namespace, type Pagination, type Parameter, type Property, type PropertyGroup, type Request, type Resource, type ResourceSample, type ResourceSampleDefinitionInput, ResourceSampleDefinitionSchema, type Response, type Route, type SdkName, type SeamAuthMethod, type SeamWorkspaceScope, type SyntaxName, type TypesModule, type TypesModuleInput, TypesModuleSchema, createBlueprint };