Skip to content

Commit

Permalink
wip gen workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
millergarym committed Apr 17, 2023
1 parent db5f48a commit 7736092
Show file tree
Hide file tree
Showing 60 changed files with 2,225 additions and 42 deletions.
53 changes: 52 additions & 1 deletion adl/adl.work.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@
{
"adlc": "0.0.0",
"use": []
"defaultGenOptions": [
{
"tsgen": {
"referenceable": "remote",
"outputs": {
"outputDir": "",
"manifest": null
},
"includeRuntime": false,
"runtimeDir": null,
"generate_transitive": false,
"include_resolver": false,
"modules": "all",
"capitalize_branch_names_in_types": true,
"capitalize_type_names": true
}
}
],
"use": [
{
"path": "./adlc_dev"
},
{
"path": "./tests/test31/lib"
},
{
"path": "./stdlib/adlc"
},
{
"path": "./stdlib/sys"
},
{
"path": "./tests/test31/proj",
"genOptions": [
{
"tsgen": {
"outputs": {
"outputDir": "../generated/typescript/tests/test31/src",
"manifest": "../generated/typescript/tests/test31/.adl-manifest"
},
"includeRuntime": true,
"runtimeDir": "./runtime",
"generate_transitive": true,
"include_resolver": true,
"modules": "all",
"capitalize_branch_names_in_types": true,
"capitalize_type_names": true
}
}
]
}
]
}
2 changes: 1 addition & 1 deletion adl/adlc_dev/adl.pkg.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"pkg": { "path" : "" },
"path" : "github.com/adl-lang/adl/adl/adkc_dev",
"adlc": "0.0.0"
}
4 changes: 0 additions & 4 deletions adl/stdlib/adl.pkg.json

This file was deleted.

5 changes: 5 additions & 0 deletions adl/stdlib/adlc/adl.pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"path" : "github.com/adl-lang/adl/adl/stdlib/adlc",
"globalAlias": "adlc",
"adlc": "0.0.0"
}
22 changes: 16 additions & 6 deletions adl/stdlib/adlc/packaging.adl
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@

module adlc.packaging {

import sys.types.Pair;

type AdlWorkspace0 = AdlWorkspace<AdlPackageRef>;
type AdlWorkspace1 = AdlWorkspace<Pair<AdlPackageRef,AdlPackage>>;

/// Expected to live in a file named `adl.work.json`
struct AdlWorkspace {
struct AdlWorkspace<T> {
/// Version
String adlc;
AdlPackageRefs use;
Vector<GenOptions> defaultGenOptions = [];
Vector<T> use;
// AdlPackageRefs use;
};

// key must be a path to a directory directly under the folder containing the `adl.work.json` file.
// type AdlPackageRefs = StringMap<AdlPackageRef>;

type AdlPackageRefs = Vector<AdlPackageRef>;

struct AdlPackageRef {
/// must be a path to a directory directly under the folder containing the `adl.work.json` file.
String root;
Vector<GenOptions> genOptions;
String path;
Vector<GenOptions> genOptions = [];
};

union GenOptions {
Expand Down Expand Up @@ -68,7 +77,8 @@ union ReferenceableScopeOption {

/// Expected to live in a file named `adl.pkg.json`
struct AdlPackage {
PackageDirective pkg;
String path;
Nullable<String> globalAlias = null;
/// Version
String adlc;
Vector<Require> requires = [];
Expand Down
5 changes: 5 additions & 0 deletions adl/stdlib/sys/adl.pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"path" : "github.com/adl-lang/adl/adl/stdlib/sys",
"globalAlias": "sys",
"adlc": "0.0.0"
}
5 changes: 5 additions & 0 deletions adl/tests/test31/lib/adl.pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"path" : "github.com/adl-lang/adl/adl/tests/test31/lib",
"globalAlias": "common",
"adlc": "0.0.0"
}
94 changes: 94 additions & 0 deletions adl/tests/test31/lib/common.adl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module common {

import common.strings.StringNE;
import common.db.DbColumnType;

/// A instant in time, represented as milliseconds from
/// the epoch of "1970-01-01T00:00:00Z
newtype Instant = Int64;

/// A date in ISO8601 format
newtype LocalDate = String = "1970-01-01";

/// A time in ISO8601 format
newtype LocalTime = String = "00:00:00";

/// A datetime in ISO8601 format
newtype LocalDateTime = String = "1970-01-01T00:00:00";

/// The day of the week
union DayOfWeek {
Void monday;
Void tuesday;
Void wednesday;
Void thursday;
Void friday;
Void saturday;
Void sunday;
};

/// A duration in ISO8601 format
@DbColumnType "interval"
newtype Duration = String = "P1D";

/// An IANA timezone
newtype Timezone = StringNE;

/// A holder for paginated results
struct Paginated<T> {

/// The paginated items
Vector<T> items;

/// The offset used for this query
Int64 current_offset;

/// The size of the entire date set
Int64 total_size;
};

/// Empty Struct (Used mostly for Void RPC responses)
struct Unit {};

/// Phantom type to capture a StringMap with a named string key type:
type StringKeyMap<K,V> = StringMap<V>;

/// Naming aid for strings used as keys
type Key<T> = String;

/// A value of type T along with the Key<T>
struct WithKey<T> {
Key<T> key;
T value;
};

/// Postgres array of strings type that is serialized in to a list of Strings
@DbColumnType "text[]"
newtype StringList = Vector<String>;

// Postgres tsvector type for plain text searching
@DbColumnType "tsvector"
newtype TSVector = String;

/// Postgres Geography type that is serialized using GeoJson
// Maps to postgres database as 'geography' column
// See https://postgis.net/workshops/postgis-intro/geography.html#casting-to-geometry
@DbColumnType "geography"
newtype GeographyGeoJson = String;

/// Postgres Geometry type
// Maps to postgres database as 'geometry' column
// Serialise to/from WKT (Well Known Text) in the string
@DbColumnType "geometry"
newtype GeometryWKT = String;


/// A floating point decimal value
//
// In principle, the json format allows numbers with arbitrary decimal precision. However
// support for this is dependent on individual client libraries, and crucially the
// JSON.parse() function in browsers converts json numbers to a binary floating point
// double representation. Hence we take the safe option and serialize as JSON strings.
@DbColumnType "numeric"
newtype BigDecimal = String;
};
82 changes: 82 additions & 0 deletions adl/tests/test31/lib/common.adl-java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
module common
{
import adlc.config.java.*;
import common.db.JavaDbCustomType;
import sys.types.Set;

annotation JavaPackage "au.com.helixta.adl.common";

annotation Instant JavaCustomType {
"javaname" : "java.time.Instant",
"helpers" : "au.com.helixta.adl.custom.InstantHelpers"
};

annotation LocalDate JavaCustomType {
"javaname" : "java.time.LocalDate",
"helpers" : "au.com.helixta.adl.custom.LocalDateHelpers"
};

annotation LocalTime JavaCustomType {
"javaname" : "java.time.LocalTime",
"helpers" : "au.com.helixta.adl.custom.LocalTimeHelpers"
};

annotation LocalDateTime JavaCustomType {
"javaname" : "java.time.LocalDateTime",
"helpers" : "au.com.helixta.adl.custom.LocalDateTimeHelpers"
};

annotation DayOfWeek JavaCustomType {
"javaname" : "java.time.DayOfWeek",
"helpers" : "au.com.helixta.adl.custom.DayOfWeekHelpers"
};

annotation GeographyGeoJson JavaCustomType {
"javaname" : "org.postgis.PGgeometry",
"helpers": "au.com.helixta.adl.custom.PGgeometryHelpers"
};

annotation GeographyGeoJson JavaDbCustomType {
"javaDbType": "org.postgis.PGgeometry",
"helpers": "au.com.helixta.adl.custom.PGgeometryHelpers"
};

annotation GeometryWKT JavaCustomType {
"javaname" : "org.postgis.PGgeometry",
"helpers": "au.com.helixta.adl.custom.PGgeometryWKTHelpers"
};

annotation GeometryWKT JavaDbCustomType {
"javaDbType" : "org.postgis.PGgeometry",
"helpers": "au.com.helixta.adl.custom.PGgeometryWKTHelpers"
};

annotation TSVector JavaDbCustomType {
"javaDbType" : "String",
"helpers": "au.com.helixta.adl.custom.TSVectorHelpers"
};

annotation StringList JavaDbCustomType {
"javaDbType" : "au.com.helixta.nofrills.sql.StringList",
"helpers": "au.com.helixta.adl.custom.StringListHelpers"
};

annotation StringList JavaCustomType {
"javaname" : "au.com.helixta.nofrills.sql.StringList",
"helpers": "au.com.helixta.adl.custom.StringListHelpers"
};

annotation BigDecimal JavaCustomType {
"javaname" : "java.math.BigDecimal",
"helpers": "au.com.helixta.adl.custom.BigDecimalHelpers"
};

annotation BigDecimal JavaDbCustomType {
"javaDbType" : "java.math.BigDecimal",
"helpers": "au.com.helixta.adl.custom.BigDecimalHelpers"
};

/// Force adlc java runtime to include HashSetHelpers.java
newtype SetStrings = Set<String>;

};
Loading

0 comments on commit 7736092

Please sign in to comment.