Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Keywords, which define the name, inheritance structure, and properties of a C3.ai Type
  • Fields, which define attributes or data elements on a C3.ai Type
  • Methods, which define business logic on C3.ai Types
  • Annotations like '@db', which often precede fields or methods, and futrher configure the behavior of a C3.ai type
  • Constants such as strings or integers.
  • Comments which aren't parsed by C3, and instead provide a message to the developer.

...

  • type: All .c3typ files have the keyword 'type'. This keyword tells the C3 AI Suite that this file defines a C3.ai Type. 
  • entity: The keyword 'entity' keyword indicates the C3.ai Type is a 'Persistable' (i.e., needs to be stored in a database in the C3 AI Suite). Since a large majority of C3.ai Types are Persistable, 'entity' is an important keyword to include in .c3typ files. 
  • mixes: Adding the keyword `mixes AnotherType`, a C3.ai Type inherits the properties (e.g., fields, methods) of `AnotherType'. A C3.ai Type can mix-in multiple Types. 
  • remixes: Adding the keyword`remix AType`, allows C3.ai developer to modify an existing C3.ai Type (e.g., add new fields or methods, update existing fields or methods). Re-mixing is useful when you don't have access to the original .c3type file for a particular C3.ai Type, but wish to edit that C3.ai Type. 
  • extends: C3.ai developers often add the keyword `extends AnotherType`, to define a subclass of a particular C3.ai Type (e.g., SmartBulb extends Lightbulb). The extension Type (i.e., Smartbulb) inherits all the fields and methods of the original Type (i.e., Lightbulb). Additionally, data associated with the extension and original C3.ai Types are stored in the same database table. Therefore, you must specify a `type key`(on the extension Type), so the C3 AI Suite can distinguish data associated with the extension and original C3.ai Types. Please note, a C3.ai Type can only extend ONE other Type. 
  • extendable: All extended Types (i.e., Lightbulb) MUST be marked with the keyword "extendable".  Under the covers, the keyword "extendable" tells the C3 AI Suite to add a field (called 'key') to the database table, storing the extended (or base) C3.ai Type. This 'key' field is used to distinguish data associated with different varieties of the extended C3.ai Type.
  • type key: All extension types (i.e., Smartbulb) MUST BE marked with the keyword 'type key VALUE' (e.g., "type key SMRT_BLB").
  • schema name: A set of keywords indicating the name of the database table, used to store data for a Persistable C3.ai Type. Developer Developers specify a schema name to customize database table names.

...

Annotations

With annotations, you can further configure a C3.ai Type. Annotations can appear before Type definitions, field declarations, and method declarations. They do a variety of things such as configure As example, annotations can be used to specify the database technology used to store that Type, mark what type of ActionRuntime should be used a C3.ai Type (e.g., Cassandra, Azure Blob), mark the ActionRuntime in which to run a particular method, Mark deprecate a field or method as deprecated or beta, Specify a timeseries treatment, and specify parameters of C3 Analytics (discussion to come soon). These are only a selection of what annotations can do.specify how time-series data should be treated, and specify how to trigger analytics or DFEs (DataFlow Events) (tutorial coming soon).

Here are a few examples of defining annotations: Here, we show a couple of examples:

Code Block
  /**
   * This bulb's historical predictions.
   */
  @db(order='descending(timestamp)')
  bulbPredictions: [SmartBulbPrediction](smartBulb)

The bulbPredictions field is annotated that the database should store the bulbPredictions With the `@db(order = 'descending(timestamp)'` annotation, the bulbPrediction field's records are stored in descending order by timestamp.

Code Block
@ts(treatment='avg')
lumens: double

The With the `@ts(treatment = 'avg') annotation, the value of the lumens field of a type be default is now going to use the 'AVG' treatment.for a given SmartBulb is the average of all that Smartbulb's lumens data. 

To learn more about Annotations, please see the C3.ai Developer Resources here: C3.ai developer resources on Annotations:

Final

...

Types

Types, methods, and fields can be made 'final' using the 'final' keyword. This prevents The fields and methods from being overridden by any type which mixes them in. If a type is made final, all fields and methods of that type are made finalof a Final Type cannot be modified or overridden (via 'mixes' or 'exends').

Code Block
type FinalType {
    final method: function(): string
}

To learn more about the Final Types, see the C3.ai developer resources on the final keywordDeveloper Resources here: 

...

The C3 AI Suite also supports abstract types. If you use To define an Abstract Type, add the keyword 'abstract' before the type definition, this will indicate an abstract type. You cannot instantiate an abstract type, . Abstract Types cannot be instantiated and must mix it into another concrete type. This provides a great way to standardize interfaces. Here's an example:

Code Block
abstract type Interace {
	field1: int
    method1: function(double): int
}

To learn more about Abstract Types, see the C3.ai developer resources on Abstract types:Developer Resources here: 

Examples

Look through the lightbulbAD package and find To see more examples of C3.ai Types, check out the .c3typ files . Look at these to see the range of possibilitiesin the lightbulbAD package.