Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
node-version: lts/*

- name: Build Rust workspace
run: cargo build --workspace
run: cargo build --workspace --all-features

- name: Run Rust tests
run: cargo test --workspace
run: cargo test --workspace --all-features

- name: Install Node.js dependencies for client
working-directory: crates/observation-tools-client
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ uuid = { version = "1.11", features = ["v4", "v7", "serde", "js"] }
utoipa-axum = { version = "0.2"}
pulldown-cmark = "0.12"
ammonia = "4"
http = "1.0"
http-body = "1.0"
http-body-util = "0.1"
pin-project-lite = "0.2"
28 changes: 27 additions & 1 deletion crates/observation-tools-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ repository.workspace = true
[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
axum = [
"dep:axum",
"dep:tower",
"dep:http",
"dep:http-body",
"dep:http-body-util",
"dep:pin-project-lite",
"dep:bytes",
"dep:base64",
]

[dependencies]
anyhow.workspace = true
async-channel = "2.3"
Expand All @@ -18,13 +31,23 @@ napi-derive = { version = "3", features = ["type-def"] }
observation-tools-macros.workspace = true
observation-tools-shared = { workspace = true, features = ["testing"] }
progenitor-client.workspace = true
reqwest = { workspace = true, features = ["json"] }
reqwest = { workspace = true, features = ["json", "multipart"] }
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["macros", "rt", "time"] }
tracing.workspace = true

# Optional axum dependencies (only included with "axum" feature)
axum = { workspace = true, optional = true }
tower = { workspace = true, optional = true }
http = { workspace = true, optional = true }
http-body = { workspace = true, optional = true }
http-body-util = { workspace = true, optional = true }
pin-project-lite = { workspace = true, optional = true }
bytes = { workspace = true, optional = true }
base64 = { workspace = true, optional = true }

[build-dependencies]
napi-build.workspace = true
observation-tools-server.workspace = true
Expand All @@ -37,11 +60,14 @@ utoipa.workspace = true

[dev-dependencies]
anyhow.workspace = true
axum.workspace = true
bytes.workspace = true
futures.workspace = true
http.workspace = true
observation-tools-server.workspace = true
rand.workspace = true
reqwest.workspace = true
tempfile = { workspace = true }
test-log.workspace = true
tower.workspace = true
tracing-subscriber.workspace = true
76 changes: 28 additions & 48 deletions crates/observation-tools-client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,34 @@
/* eslint-disable */
/** Client for observation-tools */
export declare class Client {
beginExecution(name: string): ExecutionHandle
beginExecution(name: string): ExecutionHandle;
/**
* Begin a new execution with a specific ID (for testing)
*
* This allows tests to create an execution with a known ID, enabling
* navigation to the execution URL before the execution is uploaded.
*/
beginExecutionWithId(id: string, name: string): ExecutionHandle
beginExecutionWithId(id: string, name: string): ExecutionHandle;
}

/** Builder for Client */
export declare class ClientBuilder {
/** Create a new client builder */
constructor()
constructor();
/** Set the base URL for the server */
setBaseUrl(url: string): void
setBaseUrl(url: string): void;
/** Set the API key for authentication */
setApiKey(apiKey: string): void
setApiKey(apiKey: string): void;
/** Build the client */
build(): Client
build(): Client;
}

/** Handle to an execution that can be used to send observations */
export declare class ExecutionHandle {
/** Get the execution ID as a string */
get idString(): string
get idString(): string;
/** Get the URL to the execution page */
get url(): string
/**
* Create and send an observation
*
* # Arguments
* * `name` - The name of the observation
* * `payload_json` - The data to observe as a JSON string
* * `labels` - Optional array of labels for categorization
* * `source_file` - Optional source file path
* * `source_line` - Optional source line number
* * `metadata` - Optional metadata as an array of [key, value] pairs
*/
observe(name: string, payloadJson: string, labels?: Array<string> | undefined | null, sourceFile?: string | undefined | null, sourceLine?: number | undefined | null, metadata?: Array<Array<string>> | undefined | null): string
/**
* Create and send an observation with a specific ID (for testing)
*
* This allows tests to create an observation with a known ID, enabling
* navigation to the observation URL before the observation is uploaded.
*
* # Arguments
* * `id` - The observation ID to use
* * `name` - The name of the observation
* * `payload_json` - The data to observe as a JSON string
* * `labels` - Optional array of labels for categorization
* * `source_file` - Optional source file path
* * `source_line` - Optional source line number
* * `metadata` - Optional metadata as an array of [key, value] pairs
*/
observeWithId(id: string, name: string, payloadJson: string, labels?: Array<string> | undefined | null, sourceFile?: string | undefined | null, sourceLine?: number | undefined | null, metadata?: Array<Array<string>> | undefined | null): string
get url(): string;
}

/**
Expand All @@ -68,19 +40,26 @@ export declare class ExecutionHandle {
*/
export declare class ObservationBuilder {
/** Create a new observation builder with the given name */
constructor(name: string)
constructor(name: string);
/**
* Set a custom observation ID (for testing)
*
* This allows tests to create an observation with a known ID, enabling
* navigation to the observation URL before the observation is uploaded.
*/
withId(id: string): this;
/** Add a label to the observation */
label(label: string): this
label(label: string): this;
/** Add metadata to the observation */
metadata(key: string, value: string): this
metadata(key: string, value: string): this;
/** Set the source info for the observation */
source(file: string, line: number): this
source(file: string, line: number): this;
/** Set the payload as JSON data */
jsonPayload(jsonString: string): ObservationBuilderWithPayload
jsonPayload(jsonString: string): ObservationBuilderWithPayload;
/** Set the payload with custom data and MIME type */
rawPayload(data: string, mimeType: string): ObservationBuilderWithPayload
rawPayload(data: string, mimeType: string): ObservationBuilderWithPayload;
/** Set the payload as markdown content */
markdownPayload(content: string): ObservationBuilderWithPayload
markdownPayload(content: string): ObservationBuilderWithPayload;
}

/**
Expand All @@ -99,15 +78,16 @@ export declare class ObservationBuilderWithPayload {
*
* If sending fails, returns a stub that will fail on `wait_for_upload()`.
*/
send(execution: ExecutionHandle): SendObservation
send(execution: ExecutionHandle): SendObservation;
}

export declare class ObservationHandle {
get url(): string
get url(): string;
get id(): string;
}

export declare class SendObservation {
handle(): ObservationHandle
handle(): ObservationHandle;
}

/**
Expand All @@ -116,7 +96,7 @@ export declare class SendObservation {
* This allows tests to generate an execution ID before creating the execution,
* enabling navigation to the execution URL before the execution is uploaded.
*/
export declare function generateExecutionId(): string
export declare function generateExecutionId(): string;

/**
* Generate a new observation ID (for testing)
Expand All @@ -125,4 +105,4 @@ export declare function generateExecutionId(): string
* observation, enabling navigation to the observation URL before the
* observation is uploaded.
*/
export declare function generateObservationId(): string
export declare function generateObservationId(): string;
Loading
Loading