Skip to content

Commit

Permalink
add a minimal example that works
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 12, 2024
1 parent cab3f39 commit b8cd8dd
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/target
fluentci-*.json
process-compose*
process-compose*
sdk/rescript/lib
sdk/rescript/node_modules
sdk/rescript/demo/lib
sdk/rescript/demo/node_modules
2 changes: 1 addition & 1 deletion sdk/gleam/demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.beam
*.ez
/build
erl_crash.dump
erl_crash.dump
7 changes: 7 additions & 0 deletions sdk/gleam/demo/gleam.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name = "demo"
version = "1.0.0"

target = "javascript"

[javascript]
runtime = "deno"
typescript_declarations = true

[javascript.deno]
allow_all = true

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
Expand All @@ -17,6 +23,7 @@ runtime = "deno"

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
gleam_javascript = ">= 0.11.0 and < 1.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
2 changes: 2 additions & 0 deletions sdk/gleam/demo/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_javascript", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "483631D3001FCE8EB12ADEAD5E1B808440038E96F93DA7A32D326C82F480C0B2" },
{ name = "gleam_stdlib", version = "0.39.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "2D7DE885A6EA7F1D5015D1698920C9BAF7241102836CE0C3837A4F160128A9C4" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
]

[requirements]
gleam_javascript = { version = ">= 0.11.0 and < 1.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
11 changes: 10 additions & 1 deletion sdk/gleam/demo/src/demo.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import fluentci/client.{dag, set_secret}
import fluentci/secret.{plaintext}
import gleam/io
import gleam/javascript/promise.{await, resolve}

pub fn main() {
io.println("Hello from demo!")
let secret = dag() |> set_secret("my-secret", "my-value")
secret
|> plaintext
|> await(fn(value) {
io.debug(value)
resolve(value)
})
}
13 changes: 13 additions & 0 deletions sdk/gleam/demo/src/fluentci.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { dag } from "jsr:@fluentci/sdk";

export function client() {
return dag;
}

export function setSecret(c, name, value) {
return c.setSecret(name, value);
}

export function plaintext(secret) {
return secret.plaintext();
}
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/cache.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Cache
105 changes: 105 additions & 0 deletions sdk/gleam/demo/src/fluentci/client.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import fluentci/cache.{type Cache}
import fluentci/devbox.{type Devbox}
import fluentci/devenv.{type Devenv}
import fluentci/directory.{type Directory}
import fluentci/file.{type File}
import fluentci/flox.{type Flox}
import fluentci/git.{type Git}
import fluentci/nix.{type Nix}
import fluentci/pipeline.{type Pipeline}
import fluentci/pkgx.{type Pkgx}
import fluentci/secret.{type Secret}
import fluentci/secret_manager.{type SecretManager}

pub type Client

@external(javascript, "../fluentci.mjs", "client")
pub fn dag() -> Client

@external(javascript, "../fluentci.mjs", "setSecret")
pub fn set_secret_(client: Client, name: String, value: String) -> Secret

pub fn azure_secrets_manager(
client: Client,
region: String,
access_key_id: String,
secret_access_key: String,
) -> SecretManager {
todo
}

pub fn azure_keyvault(
client: Client,
client_id: String,
client_secret: String,
tenant_id: String,
keyvault_name: String,
keyvault_url: String,
) -> SecretManager {
todo
}

pub fn cache(client: Client, key: String) -> Cache {
todo
}

pub fn devbox(client: Client) -> Devbox {
todo
}

pub fn devenv(client: Client) -> Devenv {
todo
}

pub fn directory(client: Client, path: String) -> Directory {
todo
}

pub fn file(client: Client, path: String) -> File {
todo
}

pub fn flox(client: Client) -> Flox {
todo
}

pub fn git(client: Client, url: String) -> Git {
todo
}

pub fn google_cloud_secret_manager(
client: Client,
project: String,
google_credentials_file: String,
) -> SecretManager {
todo
}

pub fn hashicorp_vault(
client: Client,
address: String,
token: String,
cacerts: String,
) -> SecretManager {
todo
}

pub fn http(client: Client, url: String) -> File {
todo
}

pub fn nix(client: Client) -> Nix {
todo
}

pub fn pipeline(client: Client, name: String) -> Pipeline {
todo
}

pub fn pkgx(client: Client) -> Pkgx {
todo
}

pub fn set_secret(client: Client, name: String, value: String) -> Secret {
set_secret_(client, name, value)
}
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/devbox.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Devbox
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/devenv.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Devenv
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/directory.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Directory
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/file.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type File
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/flox.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Flox
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/git.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Git
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/mise.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Mise
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/nix.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Nix
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/pipeline.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Pipeline
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/pixi.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Pixi
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/pkgx.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Pkgx
10 changes: 10 additions & 0 deletions sdk/gleam/demo/src/fluentci/secret.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import gleam/javascript/promise.{type Promise}

pub type Secret

@external(javascript, "../fluentci.mjs", "plaintext")
pub fn plaintext_(secret: Secret) -> Promise(String)

pub fn plaintext(secret: Secret) -> Promise(String) {
plaintext_(secret)
}
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/secret_manager.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type SecretManager
1 change: 1 addition & 0 deletions sdk/gleam/demo/src/fluentci/service.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub type Service

0 comments on commit b8cd8dd

Please sign in to comment.