Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More GRPC Docs #611

Merged
merged 14 commits into from
Jan 22, 2024
Merged
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/acls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a protoc version change. Weird. @sauljabin any ideas?

const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
122 changes: 114 additions & 8 deletions dashboard/apps/web/littlehorse-public-api/common_wfspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,35 @@ export function variableMutationTypeToNumber(object: VariableMutationType): numb
}
}

/** Operator for comparing two values to create a boolean expression. */
export enum Comparator {
/** LESS_THAN - Equivalent to `<`. Only valid for primitive types (no JSON_OBJ or JSON_ARR). */
LESS_THAN = "LESS_THAN",
/** GREATER_THAN - Equivalent to `>`. Only valid for primitive types (no JSON_OBJ or JSON_ARR). */
GREATER_THAN = "GREATER_THAN",
/** LESS_THAN_EQ - Equivalent to `<=`. Only valid for primitive types (no JSON_OBJ or JSON_ARR). */
LESS_THAN_EQ = "LESS_THAN_EQ",
/** GREATER_THAN_EQ - Equivalent to `>=`. Only valid for primitive types (no JSON_OBJ or JSON_ARR). */
GREATER_THAN_EQ = "GREATER_THAN_EQ",
/**
* EQUALS - This is valid for any variable type, and is similar to .equals() in Java.
*
* One note: if the RHS is a different type from the LHS, then LittleHorse will
* try to cast the RHS to the same type as the LHS. If the cast fails, then the
* ThreadRun fails with a VAR_SUB_ERROR.
*/
EQUALS = "EQUALS",
/** NOT_EQUALS - This is the inverse of `EQUALS` */
NOT_EQUALS = "NOT_EQUALS",
/**
* IN - Only valid if the RHS is a JSON_OBJ or JSON_ARR. Valid for any type on the LHS.
*
* For the JSON_OBJ type, this returns true if the LHS is equal to a *KEY* in the
* RHS. For the JSON_ARR type, it returns true if one of the elements of the RHS
* is equal to the LHS.
*/
IN = "IN",
/** NOT_IN - The inverse of IN. */
NOT_IN = "NOT_IN",
UNRECOGNIZED = "UNRECOGNIZED",
}
Expand Down Expand Up @@ -253,22 +274,58 @@ export interface VariableAssignment_FormatString {
args: VariableAssignment[];
}

/**
* A VariableMutation defines a modification made to one of a ThreadRun's variables.
* The LHS determines the variable that is modified; the operation determines how
* it is modified, and the RHS is the input to the operation.
*
* Day-to-day users of LittleHorse generally don't interact with this structure unless
* they are writing their own WfSpec SDK.
*/
export interface VariableMutation {
/** The name of the variable to mutate */
lhsName: string;
lhsJsonPath?: string | undefined;
/**
* For JSON_ARR and JSON_OBJ variables, this allows you to optionally mutate
* a specific sub-field of the variable.
*/
lhsJsonPath?:
| string
| undefined;
/** Defines the operation that we are executing. */
operation: VariableMutationType;
sourceVariable?: VariableAssignment | undefined;
literalValue?: VariableValue | undefined;
/**
* Set the source_variable as the RHS to use another variable from the workflow to
* as the RHS/
*/
sourceVariable?:
| VariableAssignment
| undefined;
/** Use a literal value as the RHS. */
literalValue?:
| VariableValue
| undefined;
/** Use the output of the current node as the RHS. */
nodeOutput?: VariableMutation_NodeOutputSource | undefined;
}

/** Specifies to use the output of a NodeRun as the RHS. */
export interface VariableMutation_NodeOutputSource {
/** Use this specific field from a JSON output */
jsonpath?: string | undefined;
}

/** Declares a Variable. */
export interface VariableDef {
/** The Type of the variable. */
type: VariableType;
/** The name of the variable. */
name: string;
/**
* Optional default value if the variable isn't set; for example, in a ThreadRun
* if you start a ThreadRun or WfRun without passing a variable in, then this is
* used.
*/
defaultValue?: VariableValue | undefined;
}

Expand All @@ -292,13 +349,31 @@ export interface UTActionTrigger {
reassign?:
| UTActionTrigger_UTAReassign
| undefined;
/** Action's delay */
delaySeconds: VariableAssignment | undefined;
/**
* The Action is triggered some time after the Hook matures. The delay is controlled
* by this field.
*/
delaySeconds:
| VariableAssignment
| undefined;
/** The hook on which this UserTaskAction is scheduled. */
hook: UTActionTrigger_UTHook;
}

/** Enumerates the different lifecycle hooks that can cause the timer to start running. */
export enum UTActionTrigger_UTHook {
/**
* ON_ARRIVAL - The hook should be scheduled `delay_seconds` after the UserTaskRun is created. This
* hook only causes the action to be scheduled once.
*/
ON_ARRIVAL = "ON_ARRIVAL",
/**
* ON_TASK_ASSIGNED - The hook should be scheduled `delay_seconds` after the ownership of the UserTaskRun
* changes. This hook causes the Action to be scheduled one or more times. The first
* time is scheduled when the UserTaskRun is created, since we treat the change from
* "UserTaskRun is nonexistent" to "UserTaskRun is owned by a userId or userGroup" as
* a change in ownership.
*/
ON_TASK_ASSIGNED = "ON_TASK_ASSIGNED",
UNRECOGNIZED = "UNRECOGNIZED",
}
Expand Down Expand Up @@ -342,23 +417,54 @@ export function uTActionTrigger_UTHookToNumber(object: UTActionTrigger_UTHook):
}
}

/** A UserTaskAction that causes a UserTaskRun to be CANCELLED when it fires. */
export interface UTActionTrigger_UTACancel {
}

/** A UserTaskAction that causes a TaskRun to be scheduled when it fires. */
export interface UTActionTrigger_UTATask {
task: TaskNode | undefined;
/** The specification of the Task to schedule. */
task:
| TaskNode
| undefined;
/** EXPERIMENTAL: Any variables in the ThreadRun which we should mutate. */
mutations: VariableMutation[];
}

/** A UserTaskAction that causes a UserTaskRun to be reassigned when it fires. */
export interface UTActionTrigger_UTAReassign {
userId?: VariableAssignment | undefined;
/**
* A variable assignment that resolves to a STR representing the new user_id. If
* not set, the user_id of the UserTaskRun will be un-set.
*/
userId?:
| VariableAssignment
| undefined;
/**
* A variable assignment that resolves to a STR representing the new user_group. If
* not set, the user_group of the UserTaskRun will be un-set.
*/
userGroup?: VariableAssignment | undefined;
}

/** Defines a TaskRun execution. Used in a Node and also in the UserTask Trigger Actions. */
export interface TaskNode {
taskDefId: TaskDefId | undefined;
/** The type of TaskRun to schedule. */
taskDefId:
| TaskDefId
| undefined;
/**
* How long until LittleHorse determines that the Task Worker had a technical ERROR if
* the worker does not yet reply to the Server.
*/
timeoutSeconds: number;
/**
* EXPERIMENTAL: How many times we should retry on retryable ERROR's.
* Please note that this API may change before version 1.0.0, as we are going to
* add significant functionality including backoff policies.
*/
retries: number;
/** Input variables into the TaskDef. */
variables: VariableAssignment[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/node_run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/object_id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8638,7 +8638,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/task_def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/task_run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/user_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed? Did someone change the protoc version?

const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/wf_run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/apps/web/littlehorse-public-api/wf_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3371,7 +3371,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P

function toTimestamp(dateStr: string): Timestamp {
const date = new globalThis.Date(dateStr);
const seconds = date.getTime() / 1_000;
const seconds = Math.trunc(date.getTime() / 1_000);
const nanos = (date.getTime() % 1_000) * 1_000_000;
return { seconds, nanos };
}
Expand Down
Loading