UNPKG

@compas/code-gen

Version:

Generate various boring parts of your server

1,404 lines (1,292 loc) 39.1 kB
// Generated by @compas/code-gen export type StructureAnyDefinitionTarget = "js"|"ts"|"jsKoaReceive"|"tsKoaReceive"|"jsKoaSend"|"tsKoaSend"|"jsPostgres"|"tsPostgres"|"jsAxios"|"tsAxios"|"jsAxiosNode"|"tsAxiosBrowser"|"tsAxiosReactNative"|"jsFetch"|"tsFetch"|"jsFetchNode"|"tsFetchBrowser"|"tsFetchReactNative"; export type StructureAnyDefinition = { "type": "any"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; }; /** * Support different 'any' behaviours for different targets. All targets are optional and will be tried from most specific to least specific. */ "targets"?: Partial<Record<StructureAnyDefinitionTarget,{ "validatorInputType": string; "validatorOutputType": string; /** * Expression that synchronously resolves to a boolean. Should be 'true' if the input is valid, and 'false' otherwise. Interpolates '$value$' with the current property that is being validated */ "validatorExpression"?: string|undefined; /** * A raw import that is added to the files where the provided validator expression is used. */ "validatorImport"?: string|undefined; }>>|undefined; }; export type StructureAnyDefinitionInput = { "type": "any"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull": boolean|"true"|"false"; }; /** * Support different 'any' behaviours for different targets. All targets are optional and will be tried from most specific to least specific. */ "targets"?: Partial<Record<StructureAnyDefinitionTarget,{ "validatorInputType": string; "validatorOutputType": string; /** * Expression that synchronously resolves to a boolean. Should be 'true' if the input is valid, and 'false' otherwise. Interpolates '$value$' with the current property that is being validated */ "validatorExpression"?: string|undefined; /** * A raw import that is added to the files where the provided validator expression is used. */ "validatorImport"?: string|undefined; }>>|undefined; }; export type StructureArrayDefinition = { "type": "array"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "convert": boolean; "min"?: number|undefined; "max"?: number|undefined; }; "values": StructureTypeSystemDefinition; }; export type StructureBooleanDefinition = { "type": "boolean"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; }; "oneOf"?: boolean|undefined; }; export type StructureNamePart = string; export type StructureReferenceDefinition = { "type": "reference"; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { }; "reference": { "group": StructureNamePart; "name": StructureNamePart; }; }; export type StructureCrudDefinition = { "type": "crud"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { }; "basePath"?: string|undefined; "entity"?: StructureReferenceDefinition|undefined; "fromParent"?: { "field": string; "options"?: { "name"?: string|undefined; }|undefined; }|undefined; "routeOptions": { "listRoute"?: boolean|undefined; "singleRoute"?: boolean|undefined; "createRoute"?: boolean|undefined; "updateRoute"?: boolean|undefined; "deleteRoute"?: boolean|undefined; }; "fieldOptions": { "readable"?: { "$omit"?: (string)[]|undefined; "$pick"?: (string)[]|undefined; }|undefined; "readableType"?: StructureReferenceDefinition|undefined; "writable"?: { "$omit"?: (string)[]|undefined; "$pick"?: (string)[]|undefined; }|undefined; }; "inlineRelations": (StructureCrudDefinition)[]; "nestedRelations": (StructureCrudDefinition)[]; }; export type StructureDateDefinition = { "type": "date"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; "min"?: Date|undefined; "max"?: Date|undefined; "inFuture"?: boolean|undefined; "inPast"?: boolean|undefined; }; "specifier"?: "dateOnly"|"timeOnly"|undefined; }; export type StructureRelationDefinition = { "type": "relation"; "subType": "manyToOne"|"oneToMany"|"oneToOne"|"oneToOneReverse"; "reference": StructureReferenceDefinition; "ownKey": string; "referencedKey"?: string|undefined; "isOptional": boolean; }; export type StructureExtendDefinition = { "type": "extend"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { }; "keys": { [key: string]: StructureTypeSystemDefinition}; "reference": StructureReferenceDefinition; "relations": (StructureRelationDefinition)[]; }; export type StructureFileDefinition = { "type": "file"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "mimeTypes"?: (string)[]|undefined; }; }; export type StructureGenericDefinition = { "type": "generic"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { }; "keys": StructureTypeSystemDefinition; "values": StructureTypeSystemDefinition; }; export type StructureNumberDefinition = { "type": "number"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "floatingPoint": boolean; "min"?: number|undefined; "max"?: number|undefined; "allowNull": boolean; }; "oneOf"?: (number)[]|undefined; }; export type StructureObjectDefinition = { "type": "object"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; "strict": boolean; }; "shortName"?: string|undefined; "keys": { [key: string]: StructureTypeSystemDefinition}; "enableQueries"?: boolean|undefined; "queryOptions"?: { "withSoftDeletes"?: boolean|undefined; "withDates"?: boolean|undefined; "withPrimaryKey": boolean; "isView"?: boolean|undefined; "schema"?: string|undefined; }|undefined; "relations": (StructureRelationDefinition)[]; }; export type StructureOmitDefinition = { "type": "omit"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; "strict": boolean; }; "keys": (string)[]; "reference": StructureTypeSystemDefinition; }; export type StructurePickDefinition = { "type": "pick"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; "strict": boolean; }; "keys": (string)[]; "reference": StructureTypeSystemDefinition; }; export type StructureStringDefinition = { "type": "string"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "trim": boolean; "lowerCase": boolean; "upperCase": boolean; "min": number; "max"?: number|undefined; "pattern"?: string|undefined; "allowNull": boolean; "disallowedCharacters"?: (string)[]|undefined; }; "oneOf"?: (string)[]|undefined; }; export type StructureUuidDefinition = { "type": "uuid"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "allowNull": boolean; }; }; /** * All type definitions that can be used inside other types, like object keys. */ export type StructureTypeSystemDefinition = |StructureAnyDefinition |StructureAnyOfDefinition |StructureArrayDefinition |StructureBooleanDefinition |StructureCrudDefinition |StructureDateDefinition |StructureExtendDefinition |StructureFileDefinition |StructureGenericDefinition |StructureNumberDefinition |StructureObjectDefinition |StructureOmitDefinition |StructurePickDefinition |StructureReferenceDefinition |StructureStringDefinition |StructureUuidDefinition; export type StructureAnyOfDefinition = { "type": "anyOf"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { "discriminant"?: string|undefined; }; "values": (StructureTypeSystemDefinition)[]; }; export type StructureArrayDefinitionInput = { "type": "array"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "convert": boolean|"true"|"false"; "min"?: number|undefined; "max"?: number|undefined; }; "values": StructureTypeSystemDefinitionInput; }; export type StructureBooleanDefinitionInput = { "type": "boolean"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull"?: boolean|"true"|"false"|undefined; }; "oneOf"?: boolean|"true"|"false"|undefined; }; export type StructureReferenceDefinitionInput = { "type": "reference"; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator"?: { }|undefined; "reference": { "group": StructureNamePart; "name": StructureNamePart; }; }; export type StructureCrudDefinitionInput = { "type": "crud"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator"?: { }|undefined; "basePath"?: string|undefined; "entity"?: StructureReferenceDefinitionInput|undefined; "fromParent"?: { "field": string; "options"?: { "name"?: string|undefined; }|undefined; }|undefined; "routeOptions": { "listRoute"?: boolean|"true"|"false"|undefined; "singleRoute"?: boolean|"true"|"false"|undefined; "createRoute"?: boolean|"true"|"false"|undefined; "updateRoute"?: boolean|"true"|"false"|undefined; "deleteRoute"?: boolean|"true"|"false"|undefined; }; "fieldOptions": { "readable"?: { "$omit"?: (string)[]|undefined; "$pick"?: (string)[]|undefined; }|undefined; "readableType"?: StructureReferenceDefinitionInput|undefined; "writable"?: { "$omit"?: (string)[]|undefined; "$pick"?: (string)[]|undefined; }|undefined; }; "inlineRelations": (StructureCrudDefinitionInput)[]; "nestedRelations": (StructureCrudDefinitionInput)[]; }; export type StructureDateDefinitionInput = { "type": "date"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull"?: boolean|"true"|"false"|undefined; "min"?: Date|string|number|undefined; "max"?: Date|string|number|undefined; "inFuture"?: boolean|"true"|"false"|undefined; "inPast"?: boolean|"true"|"false"|undefined; }; "specifier"?: "dateOnly"|"timeOnly"|undefined; }; export type StructureRelationDefinitionInput = { "type": "relation"; "subType": "manyToOne"|"oneToMany"|"oneToOne"|"oneToOneReverse"; "reference": StructureReferenceDefinitionInput; "ownKey": string; "referencedKey"?: string|undefined; "isOptional": boolean|"true"|"false"; }; export type StructureExtendDefinitionInput = { "type": "extend"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator"?: { }|undefined; "keys": { [key: string]: StructureTypeSystemDefinitionInput}; "reference": StructureReferenceDefinitionInput; "relations": (StructureRelationDefinitionInput)[]; }; export type StructureFileDefinitionInput = { "type": "file"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "mimeTypes"?: (string)[]|undefined; }; }; export type StructureGenericDefinitionInput = { "type": "generic"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator"?: { }|undefined; "keys": StructureTypeSystemDefinitionInput; "values": StructureTypeSystemDefinitionInput; }; export type StructureNumberDefinitionInput = { "type": "number"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "floatingPoint": boolean|"true"|"false"; "min"?: number|undefined; "max"?: number|undefined; "allowNull"?: boolean|"true"|"false"|undefined; }; "oneOf"?: (number)[]|undefined; }; export type StructureObjectDefinitionInput = { "type": "object"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull"?: boolean|"true"|"false"|undefined; "strict": boolean|"true"|"false"; }; "shortName"?: string|undefined; "keys": { [key: string]: StructureTypeSystemDefinitionInput}; "enableQueries"?: boolean|"true"|"false"|undefined; "queryOptions"?: { "withSoftDeletes"?: boolean|"true"|"false"|undefined; "withDates"?: boolean|"true"|"false"|undefined; "withPrimaryKey": boolean|"true"|"false"; "isView"?: boolean|"true"|"false"|undefined; "schema"?: string|undefined; }|undefined; "relations": (StructureRelationDefinitionInput)[]; }; export type StructureOmitDefinitionInput = { "type": "omit"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull"?: boolean|"true"|"false"|undefined; "strict": boolean|"true"|"false"; }; "keys": (string)[]; "reference": StructureTypeSystemDefinitionInput; }; export type StructurePickDefinitionInput = { "type": "pick"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull"?: boolean|"true"|"false"|undefined; "strict": boolean|"true"|"false"; }; "keys": (string)[]; "reference": StructureTypeSystemDefinitionInput; }; export type StructureStringDefinitionInput = { "type": "string"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "trim": boolean|"true"|"false"; "lowerCase": boolean|"true"|"false"; "upperCase": boolean|"true"|"false"; "min"?: number|undefined; "max"?: number|undefined; "pattern"?: string|undefined; "allowNull"?: boolean|"true"|"false"|undefined; "disallowedCharacters"?: (string)[]|undefined; }; "oneOf"?: (string)[]|undefined; }; export type StructureUuidDefinitionInput = { "type": "uuid"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator": { "allowNull"?: boolean|"true"|"false"|undefined; }; }; /** * All type definitions that can be used inside other types, like object keys. */ export type StructureTypeSystemDefinitionInput = |StructureAnyDefinitionInput |StructureAnyOfDefinitionInput |StructureArrayDefinitionInput |StructureBooleanDefinitionInput |StructureCrudDefinitionInput |StructureDateDefinitionInput |StructureExtendDefinitionInput |StructureFileDefinitionInput |StructureGenericDefinitionInput |StructureNumberDefinitionInput |StructureObjectDefinitionInput |StructureOmitDefinitionInput |StructurePickDefinitionInput |StructureReferenceDefinitionInput |StructureStringDefinitionInput |StructureUuidDefinitionInput; export type StructureAnyOfDefinitionInput = { "type": "anyOf"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator"?: { "discriminant"?: string|undefined; }|undefined; "values": (StructureTypeSystemDefinitionInput)[]; }; /** * Select the targets and generators to be used when generating. See {@link https://compasjs.com/generators/targets.html} for more information. */ export type StructureGenerateOptions = { "targetLanguage": "js"|"ts"; /** * Output '.ts' extension in imports for use with Node.js new type stripping features. */ "forceTsExtensionImports"?: boolean|undefined; /** * Where to write the files to. If no directory is provided, a list of in memory files with contents is returned from the {@link Generator.generate} call. */ "outputDirectory"?: string|undefined; "generators": { /** * Enable a structure dump. This way this structure can be reused via 'Generator#addStructure */ "structure"?: { }|undefined; /** * Enable the OpenAPI generator. */ "openApi"?: { /** * Custom top level properties. */ "openApiExtensions": { "version"?: string|undefined; "title"?: string|undefined; "description"?: string|undefined; }; /** * Add or overwrite specific properties per route. The keys should be formatted as 'upperCaseFirst(group) + upperCaseFirst(name)'. */ "openApiRouteExtensions": { [key: string]: any}; }|undefined; /** * Generate a validating router with entry points for your route handlers. */ "router"?: { /** * Select one of the supported libraries to generate a router for. */ "target": |{ "library": "koa"; }; /** * Adds a Compas '_compas/structure.json' route to the generated router that includes all available routes. */ "exposeApiStructure": boolean; }|undefined; /** * Generate one of the compatible database interfaces. */ "database"?: { /** * Select one of the supported dialects to generate queries for. */ "target": |{ "dialect": "postgres"; /** * Write out 'common/structure.sql' with a naive DDL approach. */ "includeDDL": boolean; }; /** * Create a markdown file containing the ERD in a 'mermaid' block. */ "includeEntityDiagram": boolean; }|undefined; /** * Alter the output of generated validators. Other generators will always include validators in their output if necessary. */ "validators"?: { /** * Always generate validators for all named types even if no other generator needs it. This implies {@link StructureGenerateOptions.generators.types.includeBaseTypes}. */ "includeBaseTypes": boolean; }|undefined; /** * Generate an API client, based on the routes in your structure. */ "apiClient"?: { /** * Select your HTTP client of choice. */ "target": |{ "library": "axios"; "targetRuntime": "node.js"|"browser"|"react-native"; /** * Include an API client wrapper to use the api easier with your user interface library. */ "includeWrapper"?: "react-query"|undefined; /** * Use a global api client that will be used for all requests. */ "globalClient": boolean; } |{ "library": "fetch"; "targetRuntime": "node.js"|"browser"|"react-native"; /** * Include an API client wrapper to use the api easier with your user interface library. */ "includeWrapper"?: "react-query"|undefined; /** * Use a global api client that will be used for all requests. */ "globalClient": boolean; }; /** * Determine how strict the API client response validations are. This defaults to loose object validation, allowing extra values in the responses which are not returned in the validated result. It is advised to disable this when you use the API client for e2e testing your server. */ "responseValidation": { "looseObjectValidation": boolean; }; }|undefined; /** * Alter the output of the generated types, they are always generated as a result of other enabled generators. */ "types"?: { /** * Always generate types for all named types even if no other generator needs it. */ "includeBaseTypes": boolean; /** * Declare all types in the global namespace. Only applicable when using 'targetLanguage' when set to 'js' or 'ts'. */ "declareGlobalTypes": boolean; }|undefined; }; }; /** * Select the targets and generators to be used when generating. See {@link https://compasjs.com/generators/targets.html} for more information. */ export type StructureGenerateOptionsInput = { "targetLanguage": "js"|"ts"; /** * Output '.ts' extension in imports for use with Node.js new type stripping features. */ "forceTsExtensionImports"?: boolean|"true"|"false"|undefined; /** * Where to write the files to. If no directory is provided, a list of in memory files with contents is returned from the {@link Generator.generate} call. */ "outputDirectory"?: string|undefined; "generators": { /** * Enable a structure dump. This way this structure can be reused via 'Generator#addStructure */ "structure"?: { }|undefined; /** * Enable the OpenAPI generator. */ "openApi"?: { /** * Custom top level properties. */ "openApiExtensions"?: { "version"?: string|undefined; "title"?: string|undefined; "description"?: string|undefined; }|undefined; /** * Add or overwrite specific properties per route. The keys should be formatted as 'upperCaseFirst(group) + upperCaseFirst(name)'. */ "openApiRouteExtensions"?: { [key: string]: any}|undefined; }|undefined; /** * Generate a validating router with entry points for your route handlers. */ "router"?: { /** * Select one of the supported libraries to generate a router for. */ "target": |{ "library": "koa"; }; /** * Adds a Compas '_compas/structure.json' route to the generated router that includes all available routes. */ "exposeApiStructure"?: boolean|"true"|"false"|undefined; }|undefined; /** * Generate one of the compatible database interfaces. */ "database"?: { /** * Select one of the supported dialects to generate queries for. */ "target": |{ "dialect": "postgres"; /** * Write out 'common/structure.sql' with a naive DDL approach. */ "includeDDL"?: boolean|"true"|"false"|undefined; }; /** * Create a markdown file containing the ERD in a 'mermaid' block. */ "includeEntityDiagram"?: boolean|"true"|"false"|undefined; }|undefined; /** * Alter the output of generated validators. Other generators will always include validators in their output if necessary. */ "validators"?: { /** * Always generate validators for all named types even if no other generator needs it. This implies {@link StructureGenerateOptions.generators.types.includeBaseTypes}. */ "includeBaseTypes"?: boolean|"true"|"false"|undefined; }|undefined; /** * Generate an API client, based on the routes in your structure. */ "apiClient"?: { /** * Select your HTTP client of choice. */ "target": |{ "library": "axios"; "targetRuntime": "node.js"|"browser"|"react-native"; /** * Include an API client wrapper to use the api easier with your user interface library. */ "includeWrapper"?: "react-query"|undefined; /** * Use a global api client that will be used for all requests. */ "globalClient"?: boolean|"true"|"false"|undefined; } |{ "library": "fetch"; "targetRuntime": "node.js"|"browser"|"react-native"; /** * Include an API client wrapper to use the api easier with your user interface library. */ "includeWrapper"?: "react-query"|undefined; /** * Use a global api client that will be used for all requests. */ "globalClient"?: boolean|"true"|"false"|undefined; }; /** * Determine how strict the API client response validations are. This defaults to loose object validation, allowing extra values in the responses which are not returned in the validated result. It is advised to disable this when you use the API client for e2e testing your server. */ "responseValidation"?: { "looseObjectValidation": boolean|"true"|"false"; }|undefined; }|undefined; /** * Alter the output of the generated types, they are always generated as a result of other enabled generators. */ "types"?: { /** * Always generate types for all named types even if no other generator needs it. */ "includeBaseTypes"?: boolean|"true"|"false"|undefined; /** * Declare all types in the global namespace. Only applicable when using 'targetLanguage' when set to 'js' or 'ts'. */ "declareGlobalTypes"?: boolean|"true"|"false"|undefined; }|undefined; }; }; export type StructureNamePartOptional = string|undefined; export type StructureRouteInvalidationDefinition = { "type": "routeInvalidation"; "target": { "group": StructureNamePart; "name"?: StructureNamePartOptional|undefined; }; "properties": { "useSharedParams"?: boolean|undefined; "useSharedQuery"?: boolean|undefined; "specification"?: { "params": { [key: string]: (string)[]}; "query": { [key: string]: (string)[]}; }|undefined; }; }; export type StructureRouteDefinition = { "type": "route"; "group"?: string|undefined; "name"?: string|undefined; "docString": string; "isOptional": boolean; "defaultValue"?: |string |boolean |number |undefined; "sql": { "primary"?: boolean|undefined; "searchable"?: boolean|undefined; "hasDefaultValue"?: boolean|undefined; }; "validator": { }; "method": "GET"|"POST"|"PUT"|"DELETE"|"HEAD"|"PATCH"; "idempotent": boolean; "path": string; "tags": (string)[]; "query"?: StructureReferenceDefinition|undefined; "params"?: StructureReferenceDefinition|undefined; "body"?: StructureReferenceDefinition|undefined; "response"?: StructureReferenceDefinition|undefined; "invalidations": (StructureRouteInvalidationDefinition)[]; "metadata"?: { "requestBodyType"?: "json"|"form-data"|undefined; }|undefined; }; /** * This contains all types that can be added top level to the structure. */ export type StructureNamedTypeDefinition = |StructureAnyDefinition |StructureAnyOfDefinition |StructureArrayDefinition |StructureBooleanDefinition |StructureCrudDefinition |StructureDateDefinition |StructureExtendDefinition |StructureFileDefinition |StructureGenericDefinition |StructureNumberDefinition |StructureObjectDefinition |StructureOmitDefinition |StructurePickDefinition |StructureRouteDefinition |StructureStringDefinition |StructureUuidDefinition; export type StructureRouteInvalidationDefinitionInput = { "type": "routeInvalidation"; "target": { "group": StructureNamePart; "name"?: StructureNamePartOptional|undefined; }; "properties": { "useSharedParams"?: boolean|"true"|"false"|undefined; "useSharedQuery"?: boolean|"true"|"false"|undefined; "specification"?: { "params": { [key: string]: (string)[]}; "query": { [key: string]: (string)[]}; }|undefined; }; }; export type StructureRouteDefinitionInput = { "type": "route"; "group"?: string|undefined; "name"?: string|undefined; "docString"?: string|undefined; "isOptional"?: boolean|"true"|"false"|undefined; "defaultValue"?: |string |boolean|"true"|"false" |number |undefined; "sql"?: { "primary"?: boolean|"true"|"false"|undefined; "searchable"?: boolean|"true"|"false"|undefined; "hasDefaultValue"?: boolean|"true"|"false"|undefined; }|undefined; "validator"?: { }|undefined; "method": "GET"|"POST"|"PUT"|"DELETE"|"HEAD"|"PATCH"; "idempotent": boolean|"true"|"false"; "path": string; "tags": (string)[]; "query"?: StructureReferenceDefinitionInput|undefined; "params"?: StructureReferenceDefinitionInput|undefined; "body"?: StructureReferenceDefinitionInput|undefined; "response"?: StructureReferenceDefinitionInput|undefined; "invalidations": (StructureRouteInvalidationDefinitionInput)[]; "metadata"?: { "requestBodyType"?: "json"|"form-data"|undefined; }|undefined; }; /** * This contains all types that can be added top level to the structure. */ export type StructureNamedTypeDefinitionInput = |StructureAnyDefinitionInput |StructureAnyOfDefinitionInput |StructureArrayDefinitionInput |StructureBooleanDefinitionInput |StructureCrudDefinitionInput |StructureDateDefinitionInput |StructureExtendDefinitionInput |StructureFileDefinitionInput |StructureGenericDefinitionInput |StructureNumberDefinitionInput |StructureObjectDefinitionInput |StructureOmitDefinitionInput |StructurePickDefinitionInput |StructureRouteDefinitionInput |StructureStringDefinitionInput |StructureUuidDefinitionInput; export type StructureStructure = { [key: StructureNamePart]: { [key: StructureNamePart]: StructureNamedTypeDefinition}}; export type StructureStructureInput = { [key: StructureNamePart]: { [key: StructureNamePart]: StructureNamedTypeDefinitionInput}}; /** * This contains all known type definitions. */ export type StructureTypeDefinition = |StructureNamedTypeDefinition |StructureReferenceDefinition |StructureRelationDefinition |StructureRouteInvalidationDefinition; /** * This contains all known type definitions. */ export type StructureTypeDefinitionInput = |StructureNamedTypeDefinitionInput |StructureReferenceDefinitionInput |StructureRelationDefinitionInput |StructureRouteInvalidationDefinitionInput;