gws.spec¶
Specs for the GWS app.
Specs are a set of metadata that describe GWS configuration and runtime objects. Specs are generated from the source code before the app is run or a build step is performed.
The Specs support module consists of two main components:
Generator (
gws.spec.generator.main) that creates Specs from sourcesRuntime (
gws.spec.runtime) that loads Specs and provides methods to validate configuration or request objects
Generated Specs are also used by the Client builder and documentation generators.
Spec Data¶
gws.spec.core.SpecData is the central data object produced by the Generator and consumed by the Runtime.
It contains the following fields:
meta: Build-time metadata. Includes the application manifest, manifest path, and generator version.chunks: Source-code “chunks” (collections of related files) that make up the application.serverTypes: All types the server needs at runtime — configuration types, request/response types, and command descriptors.strings: Localised documentation strings keyed first by language code (e.g.'en','de') and then by type uid.
Server Types¶
Each entry in serverTypes is a gws.spec.core.Type instance. The c field (a gws.spec.core.TypeKind string)
determines what kind of type it represents and which other fields are populated.
It contains the following fields (not all are populated for every type; see c):
c: Type kind (see below).uid: Unique string identifier, used as key throughout the spec.name: Short name (e.g. class name, property name).ident: Fully qualified source-code identifier, used in docs.constValue: Value forCONSTANTtypes.defaultExpression: Source-expression string for computed defaults.defaultValue: Literal default value.doc: Inline docstring from the source.enumDocs: ForENUM—{member_name → docstring}dict.enumValues: ForENUM—{member_name → value}dict.extName:gws.extname, set only for extension types and commands.hasDefault:Truewhen a default exists.literalValues: ForLITERAL— list of allowed literal values.pos: Source file position (file:line).tArg: ForMETHOD— uid of the last (request) argument.tArgs: ForMETHOD— uids of all arguments in order.tItem: ForLIST,SET,DICT— uid of the element type.tItems: ForUNION,TUPLE— uids of member types.tKey: ForDICT— uid of the key type.tMembers: ForVARIANT—{tag → uid}map of discriminated members.tModule: uid of the module type that contains this type.tOwner: ForPROPERTY— uid of the owning class.tProperties: ForCLASS—{name → uid}map of property types.tReturn: ForMETHOD— uid of the return type.tSupers: ForCLASS— uids of base classes.tTarget: ForTYPE,EXT— uid of the aliased/target type.tValue: ForPROPERTY— uid of the property’s value type.
The gws.spec.core.TypeKind (c) field can be one of the following values defined in gws.spec.core.c:
ATOM: Built-in primitive:any,bool,bytes,float,int,str.CALLABLE: Untyped callable argument.CLASS: User-defined data class (config, props, request, response objects). UsestProperties,tSupers.COMMAND: Agws.ext.command.*endpoint. UsestArg,tOwner,extName.CONSTANT: Named constant; value stored inconstValue.DICT: Genericdict[K, V]. UsestKey,tItem.ENUM: PythonEnumsubclass. UsesenumValues,enumDocs.EXPR: Compile-time expression; not validated at runtime.EXT: Agws.ext.*alias pointing to an extension type. UsestTarget,extName.FUNCTION: Stand-alone callable. UsestArgs,tReturn.LIST: Genericlist[T]. UsestItem.LITERAL:Literal[v1, v2, …]. UsesliteralValues.METHOD: Class method / command handler. UsestArg,tArgs,tReturn,tOwner.MODULE: Python module node; groups types by source file.NONE: TheNone/NoneTypesingleton.OPTIONAL:Optional[T](i.e.T | None). UsestItem.PROPERTY: A single property slot inside aCLASS. UsestOwner,tValue.SET: Genericset[T]. UsestItem.TUPLE: Generictuple[T, …]. UsestItems.TYPE: Type alias (TypeAlias). UsestTarget.UNDEFINED: Placeholder for a type that could not be resolved.UNION:Union[T1, T2, …](untagged). UsestItems.VARIANT: Tagged union discriminated by atypeproperty. UsestMembers.
Source code: gws.spec