@fission-codes/homestar
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -45,6 +45,6 @@ /** | ||
* | ||
* @param {Schemas.Workflow} workflow | ||
* @param {import('./workflow/index.js').Workflow} workflow | ||
* @param {(data: MaybeResult<Schemas.WorkflowNotification, Schemas.WorkflowNotificationError>)=>void} [receiptCb] - Callback for workflow notifications | ||
*/ | ||
runWorkflow(workflow: Schemas.Workflow, receiptCb?: ((data: MaybeResult<Schemas.WorkflowNotification, Schemas.WorkflowNotificationError>) => void) | undefined): Promise<{ | ||
runWorkflow(workflow: import('./workflow/index.js').Workflow, receiptCb?: ((data: MaybeResult<Schemas.WorkflowNotification, Schemas.WorkflowNotificationError>) => void) | undefined): Promise<{ | ||
result: string; | ||
@@ -51,0 +51,0 @@ error?: undefined; |
@@ -8,3 +8,2 @@ export type Metrics = import('zod').z.infer<typeof Metrics>; | ||
* @typedef {import('zod').z.infer<typeof Task>} Task | ||
* @typedef {import('zod').z.infer<typeof Workflow>} Workflow | ||
* @typedef {import('./types.js').InferError<typeof Metrics>} MetricsError | ||
@@ -247,2 +246,4 @@ * @typedef {import('./types.js').InferError<typeof Health>} HealthError | ||
}, "strip", z.ZodTypeAny, { | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
run: { | ||
@@ -257,4 +258,2 @@ op: string; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
@@ -272,2 +271,4 @@ cause?: { | ||
}, { | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
run: { | ||
@@ -282,4 +283,2 @@ op: string; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
@@ -297,222 +296,2 @@ cause?: { | ||
}>; | ||
export type Workflow = import('zod').z.infer<typeof Workflow>; | ||
export const Workflow: z.ZodObject<{ | ||
name: z.ZodString; | ||
workflow: z.ZodObject<{ | ||
tasks: z.ZodArray<z.ZodObject<{ | ||
v: z.ZodOptional<z.ZodString>; | ||
run: z.ZodObject<{ | ||
op: z.ZodString; | ||
rsc: z.ZodString; | ||
nnc: z.ZodString; | ||
input: z.ZodObject<{ | ||
func: z.ZodString; | ||
args: z.ZodArray<z.ZodAny, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
func: string; | ||
args: any[]; | ||
}, { | ||
func: string; | ||
args: any[]; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}, { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}>; | ||
cause: z.ZodNullable<z.ZodOptional<z.ZodObject<{ | ||
ran: z.ZodType<import("multiformats").Link<any, number, number, 1>, z.ZodTypeDef, import("multiformats").Link<any, number, number, 1>>; | ||
out: z.ZodTuple<[z.ZodUnion<[z.ZodLiteral<"ok">, z.ZodLiteral<"error">]>, z.ZodAny], null>; | ||
fx: z.ZodOptional<z.ZodAny>; | ||
meta: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
iss: z.ZodNullable<z.ZodOptional<z.ZodString>>; | ||
prf: z.ZodArray<z.ZodType<import("multiformats").Link<any, number, number, 1>, z.ZodTypeDef, import("multiformats").Link<any, number, number, 1>>, "many">; | ||
s: z.ZodOptional<z.ZodAny>; | ||
}, "strip", z.ZodTypeAny, { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
}, { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
}>>>; | ||
auth: z.ZodOptional<z.ZodAny>; | ||
meta: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
prf: z.ZodArray<z.ZodType<import("multiformats").Link<any, number, number, 1>, z.ZodTypeDef, import("multiformats").Link<any, number, number, 1>>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
run: { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
cause?: { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
} | null | undefined; | ||
auth?: any; | ||
}, { | ||
run: { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
cause?: { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
} | null | undefined; | ||
auth?: any; | ||
}>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
tasks: { | ||
run: { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
cause?: { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
} | null | undefined; | ||
auth?: any; | ||
}[]; | ||
}, { | ||
tasks: { | ||
run: { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
cause?: { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
} | null | undefined; | ||
auth?: any; | ||
}[]; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
workflow: { | ||
tasks: { | ||
run: { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
cause?: { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
} | null | undefined; | ||
auth?: any; | ||
}[]; | ||
}; | ||
}, { | ||
name: string; | ||
workflow: { | ||
tasks: { | ||
run: { | ||
op: string; | ||
rsc: string; | ||
nnc: string; | ||
input: { | ||
func: string; | ||
args: any[]; | ||
}; | ||
}; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
v?: string | undefined; | ||
cause?: { | ||
ran: import("multiformats").Link<any, number, number, 1>; | ||
out: ["error" | "ok", any]; | ||
meta: Record<string, any>; | ||
prf: import("multiformats").Link<any, number, number, 1>[]; | ||
fx?: any; | ||
iss?: string | null | undefined; | ||
s?: any; | ||
} | null | undefined; | ||
auth?: any; | ||
}[]; | ||
}; | ||
}>; | ||
export const WorkflowMetadata: z.ZodObject<{ | ||
@@ -524,8 +303,8 @@ name: z.ZodString; | ||
name: string; | ||
replayed: boolean; | ||
workflow: import("multiformats").Link<any, number, number, 1>; | ||
replayed: boolean; | ||
}, { | ||
name: string; | ||
replayed: boolean; | ||
workflow: import("multiformats").Link<any, number, number, 1>; | ||
replayed: boolean; | ||
}>; | ||
@@ -540,8 +319,8 @@ export type WorkflowNotification = import('zod').z.infer<typeof WorkflowNotification>; | ||
name: string; | ||
replayed: boolean; | ||
workflow: import("multiformats").Link<any, number, number, 1>; | ||
replayed: boolean; | ||
}, { | ||
name: string; | ||
replayed: boolean; | ||
workflow: import("multiformats").Link<any, number, number, 1>; | ||
replayed: boolean; | ||
}>; | ||
@@ -577,4 +356,4 @@ receipt: z.ZodObject<{ | ||
name: string; | ||
replayed: boolean; | ||
workflow: import("multiformats").Link<any, number, number, 1>; | ||
replayed: boolean; | ||
}; | ||
@@ -594,4 +373,4 @@ receipt: { | ||
name: string; | ||
replayed: boolean; | ||
workflow: import("multiformats").Link<any, number, number, 1>; | ||
replayed: boolean; | ||
}; | ||
@@ -598,0 +377,0 @@ receipt: { |
import type { ZodTypeAny } from 'zod'; | ||
import type { CID } from 'multiformats/cid'; | ||
import type { Transport } from './channel/transports/types'; | ||
import type { Invocation, Task, Workflow } from './schemas'; | ||
export type InferError<S extends ZodTypeAny> = Extract<ReturnType<S['safeParse']>, { | ||
@@ -15,95 +13,2 @@ success: false; | ||
export type Result<Out> = ['ok' | 'error', Out]; | ||
export interface TemplateWorkflow<Args extends any[] = any[]> extends Workflow { | ||
workflow: { | ||
tasks: Array<TemplateInvocation<Args>>; | ||
}; | ||
} | ||
export interface TemplateTask<Args extends any[]> extends Task { | ||
name: string; | ||
needs?: string; | ||
input: { | ||
args: Args; | ||
func: string; | ||
}; | ||
} | ||
export interface TemplateInvocation<Args extends any[] = any[]> extends Invocation { | ||
run: TemplateTask<Args>; | ||
} | ||
export type Placeholder = `{{${string}${`:${string}` | ''}}}`; | ||
export type DataURI = `data:${string};base64,${string}`; | ||
export interface InvocationOptions<Args extends Record<string, any> = Record<string, any>> { | ||
name: string; | ||
needs?: string; | ||
args: Args; | ||
/** | ||
* The resource to use for the invocation. This should be a URI but for now just pass the CID string. | ||
*/ | ||
resource: string; | ||
} | ||
export type CropInvocation = TemplateInvocation<[ | ||
CID | Placeholder | DataURI, | ||
number, | ||
number, | ||
number, | ||
number | ||
]>; | ||
export type CropOptions = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI; | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}>; | ||
export type GrayscaleInvocation = TemplateInvocation<[ | ||
CID | Placeholder | DataURI | ||
]>; | ||
export type GrayscaleOptions = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI; | ||
}>; | ||
export type Rotate90Invocation = TemplateInvocation<[ | ||
CID | Placeholder | DataURI | ||
]>; | ||
export type Rotate90Options = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI; | ||
}>; | ||
export type BlurInvocation = TemplateInvocation<[ | ||
CID | Placeholder | DataURI, | ||
number | ||
]>; | ||
export type BlurOptions = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI; | ||
sigma: number; | ||
}>; | ||
export type AddOneInvocation = TemplateInvocation<[number | Placeholder]>; | ||
export type AddOneOptions = InvocationOptions<{ | ||
a: number | Placeholder; | ||
}>; | ||
export type AppendStringInvocation = TemplateInvocation<[string | Placeholder]>; | ||
export type AppendStringOptions = InvocationOptions<{ | ||
a: string | Placeholder; | ||
}>; | ||
export type JoinStringsInvocation = TemplateInvocation<[ | ||
string | Placeholder, | ||
string | Placeholder | ||
]>; | ||
export type JoinStringsOptions = InvocationOptions<{ | ||
a: string | Placeholder; | ||
b: string | Placeholder; | ||
}>; | ||
export type TransposeInvocation = TemplateInvocation<[[[number]] | Placeholder]>; | ||
export type TransposeOptions = InvocationOptions<{ | ||
matrix: [[number]] | Placeholder; | ||
}>; | ||
export interface WorkflowContext { | ||
needs: Record<string, { | ||
output?: { | ||
'await/ok': { | ||
'/': string; | ||
}; | ||
}; | ||
}>; | ||
cid: (str: string) => CID; | ||
} | ||
export type TemplateInput = string | Record<string, any> | any[]; | ||
export type TemplateOutput<T extends TemplateInput> = T extends string ? string : T extends any[] ? any[] : T extends Record<string, any> ? Task : T; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@fission-codes/homestar", | ||
"type": "module", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Homestart Client.", | ||
@@ -22,8 +22,8 @@ "author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)", | ||
"./workflow": { | ||
"types": "./dist/src/workflow.d.ts", | ||
"default": "./src/workflow.js" | ||
"types": "./dist/src/workflow/index.d.ts", | ||
"default": "./src/workflow/index.js" | ||
}, | ||
"./channel": { | ||
"types": "./dist/src/channel/channel.d.ts", | ||
"default": "./src/channel/channel.js" | ||
"types": "./dist/src/channel/index.d.ts", | ||
"default": "./src/channel/index.js" | ||
}, | ||
@@ -47,6 +47,6 @@ "./transports/*": { | ||
"workflow": [ | ||
"dist/src/workflow" | ||
"dist/src/workflow/index" | ||
], | ||
"channel": [ | ||
"dist/src/channel/channel" | ||
"dist/src/channel/index" | ||
], | ||
@@ -53,0 +53,0 @@ "transports/*": [ |
@@ -88,3 +88,3 @@ import { decode } from '@ipld/dag-json' | ||
* | ||
* @param {Schemas.Workflow} workflow | ||
* @param {import('./workflow/index.js').Workflow} workflow | ||
* @param {(data: MaybeResult<Schemas.WorkflowNotification, Schemas.WorkflowNotificationError>)=>void} [receiptCb] - Callback for workflow notifications | ||
@@ -91,0 +91,0 @@ */ |
@@ -10,3 +10,2 @@ import { z } from 'zod' | ||
* @typedef {import('zod').z.infer<typeof Task>} Task | ||
* @typedef {import('zod').z.infer<typeof Workflow>} Workflow | ||
* @typedef {import('./types.js').InferError<typeof Metrics>} MetricsError | ||
@@ -90,9 +89,2 @@ * @typedef {import('./types.js').InferError<typeof Health>} HealthError | ||
export const Workflow = z.object({ | ||
name: z.string(), | ||
workflow: z.object({ | ||
tasks: z.array(Invocation), | ||
}), | ||
}) | ||
export const WorkflowMetadata = z.object({ | ||
@@ -99,0 +91,0 @@ name: z.string(), |
114
src/types.ts
import type { ZodTypeAny } from 'zod' | ||
import type { CID } from 'multiformats/cid' | ||
import type { Transport } from './channel/transports/types' | ||
import type { Invocation, Task, Workflow } from './schemas' | ||
@@ -20,112 +19,1 @@ export type InferError<S extends ZodTypeAny> = Extract< | ||
export type Result<Out> = ['ok' | 'error', Out] | ||
export interface TemplateWorkflow<Args extends any[] = any[]> extends Workflow { | ||
workflow: { | ||
tasks: Array<TemplateInvocation<Args>> | ||
} | ||
} | ||
export interface TemplateTask<Args extends any[]> extends Task { | ||
name: string | ||
needs?: string | ||
input: { | ||
args: Args | ||
func: string | ||
} | ||
} | ||
export interface TemplateInvocation<Args extends any[] = any[]> | ||
extends Invocation { | ||
run: TemplateTask<Args> | ||
} | ||
export type Placeholder = `{{${string}${`:${string}` | ''}}}` | ||
export type DataURI = `data:${string};base64,${string}` | ||
export interface InvocationOptions< | ||
Args extends Record<string, any> = Record<string, any>, | ||
> { | ||
name: string | ||
needs?: string | ||
args: Args | ||
/** | ||
* The resource to use for the invocation. This should be a URI but for now just pass the CID string. | ||
*/ | ||
resource: string | ||
} | ||
export type CropInvocation = TemplateInvocation< | ||
[CID | Placeholder | DataURI, number, number, number, number] | ||
> | ||
export type CropOptions = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI | ||
x: number | ||
y: number | ||
width: number | ||
height: number | ||
}> | ||
export type GrayscaleInvocation = TemplateInvocation< | ||
[CID | Placeholder | DataURI] | ||
> | ||
export type GrayscaleOptions = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI | ||
}> | ||
export type Rotate90Invocation = TemplateInvocation< | ||
[CID | Placeholder | DataURI] | ||
> | ||
export type Rotate90Options = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI | ||
}> | ||
export type BlurInvocation = TemplateInvocation< | ||
[CID | Placeholder | DataURI, number] | ||
> | ||
export type BlurOptions = InvocationOptions<{ | ||
data: CID | Placeholder | DataURI | ||
sigma: number | ||
}> | ||
export type AddOneInvocation = TemplateInvocation<[number | Placeholder]> | ||
export type AddOneOptions = InvocationOptions<{ | ||
a: number | Placeholder | ||
}> | ||
export type AppendStringInvocation = TemplateInvocation<[string | Placeholder]> | ||
export type AppendStringOptions = InvocationOptions<{ | ||
a: string | Placeholder | ||
}> | ||
export type JoinStringsInvocation = TemplateInvocation< | ||
[string | Placeholder, string | Placeholder] | ||
> | ||
export type JoinStringsOptions = InvocationOptions<{ | ||
a: string | Placeholder | ||
b: string | Placeholder | ||
}> | ||
export type TransposeInvocation = TemplateInvocation<[[[number]] | Placeholder]> | ||
export type TransposeOptions = InvocationOptions<{ | ||
matrix: [[number]] | Placeholder | ||
}> | ||
export interface WorkflowContext { | ||
needs: Record< | ||
string, | ||
{ | ||
output?: { | ||
'await/ok': { '/': string } | ||
} | ||
} | ||
> | ||
cid: (str: string) => CID | ||
} | ||
export type TemplateInput = string | Record<string, any> | any[] | ||
export type TemplateOutput<T extends TemplateInput> = T extends string | ||
? string | ||
: T extends any[] | ||
? any[] | ||
: T extends Record<string, any> | ||
? Task | ||
: T |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67701
1819