Skip to content

Commit

Permalink
wip: getting typescript/workspace to work - manual edits
Browse files Browse the repository at this point in the history
  • Loading branch information
millergarym committed Apr 26, 2023
1 parent 2a09c7e commit 9c5a401
Show file tree
Hide file tree
Showing 119 changed files with 9,878 additions and 2 deletions.
3 changes: 2 additions & 1 deletion rust/compiler/src/cli/tsgen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub fn tsgen(
},
IndexEntry::Leaf(ie) => {
let iep: Vec<&str> = ie.split(".").collect();
write!(&mut out, "export * from './{}';\n", iep[0])?;
write!(&mut out, "export * as {} from './{}';\n", iep[0], iep[0])?;
},
}
}
Expand Down Expand Up @@ -294,6 +294,7 @@ pub fn gen_npm_package(pkg_path: String, wrk1: &AdlWorkspace<Payload1>) -> anyho
}
TsRuntimeOpt::Generate(_) => {}
};
npm_package.scripts.insert("tsc".to_string(), "tsc".to_string());

for d in &opts.extra_dependencies {
npm_package.dependencies.insert(d.0.clone(), d.1.clone());
Expand Down
3 changes: 2 additions & 1 deletion typescript/workspace/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
node_modules/
dist/
74 changes: 74 additions & 0 deletions typescript/workspace/adl.work.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"adlc": "0.0.0",
"use_embedded_sys_loader": true,
"runtimes": [
{
"ts_runtime": {
"output_dir": "./generated/runtime",
"npm_pkg_name": "@adl-lang/runtime"
}
}
],
"embedded_sys_loader" : { "just": {
"path": "",
"ts_opts": {
"npm_pkg_name": "@adl-lang/sys",
"npm_version": "1.0.0",
"extra_dependencies": {
"base64-js": "^1.5.1"
},
"extra_dev_dependencies": {
"tsconfig": "workspace:*",
"typescript": "^4.9.3"
}
}
}},
"use": [
{
"path": "./adl/lib",
"ts_opts": {
"npm_pkg_name": "@adl-lang/common",
"extra_dev_dependencies": {
"tsconfig": "workspace:*",
"typescript": "^4.9.3"
},
"runtime_opts": {
"workspace_ref": "@adl-lang/runtime"
},
"outputs": {
"gen": {
"output_dir": "./generated/common",
"manifest": "./generated/common/.adl-manifest",
"strip_first": true
}
},
"include_resolver": false
}
},
{
"path": "./adl/proj",
"ts_opts": {
"npm_pkg_name": "@adl-lang/protoclient",
"generate_transitive": false,
"extra_dependencies": {
"base64-js": "^1.5.1"
},
"extra_dev_dependencies": {
"tsconfig": "workspace:*",
"typescript": "^4.9.3"
},
"runtime_opts": {
"workspace_ref": "@adl-lang/runtime"
},
"outputs": {
"gen": {
"output_dir": "./generated/protoclient",
"manifest": "./generated/protoclient/.adl-manifest",
"strip_first": true
}
},
"include_resolver": true
}
}
]
}
12 changes: 12 additions & 0 deletions typescript/workspace/adl/lib/adl.pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"path" : "github.com/adl-lang/adl/typescript/workspace/adl/lib",
"global_alias": "common",
"adlc": "0.0.0",
"requires": [
{
"ref": {
"alias": "sys"
}
}
]
}
94 changes: 94 additions & 0 deletions typescript/workspace/adl/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 typescript/workspace/adl/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 9c5a401

Please sign in to comment.