@vimhead.dev/norn 0.1.0-tip.35568631545.1 → 0.1.0-tip.35570530940.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +4 -8
- package/dist/api.js +2 -2
- package/dist/schema.js +5 -5
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -18,8 +18,7 @@ export type NornWorkflowDeclaration<Id extends string = string, ArgsSchema exten
|
|
|
18
18
|
(args: StaticEncode<ArgsSchema>): NornRunNext;
|
|
19
19
|
readonly kind: typeof WORKFLOW_DECLARATION_KIND;
|
|
20
20
|
readonly id: Id;
|
|
21
|
-
readonly
|
|
22
|
-
readonly instructions?: string;
|
|
21
|
+
readonly entrypoint: NornWorkflowEntrypoint;
|
|
23
22
|
readonly args: ArgsSchema;
|
|
24
23
|
readonly gate?: NornWorkflowGate<ArgsSchema> & {
|
|
25
24
|
describe?(context: NornWorkflowContext<ArgsSchema, ConfigSchema, Scope>): MaybePromise<string>;
|
|
@@ -43,12 +42,8 @@ export type NornWorkflowGate<ArgsSchema extends TSchema> = unknown extends Stati
|
|
|
43
42
|
readonly enabled: true;
|
|
44
43
|
readonly fields?: never;
|
|
45
44
|
};
|
|
46
|
-
type
|
|
47
|
-
readonly isEntrypoint: true;
|
|
45
|
+
export type NornWorkflowEntrypoint = false | {
|
|
48
46
|
readonly instructions: string;
|
|
49
|
-
} | {
|
|
50
|
-
readonly isEntrypoint: false;
|
|
51
|
-
readonly instructions?: string;
|
|
52
47
|
};
|
|
53
48
|
type WorkflowConfig<Schema extends TSchema | undefined> = Schema extends TSchema ? StaticDecode<Schema> : undefined;
|
|
54
49
|
export type NornWorkflowContext<ArgsSchema extends TSchema = TSchema, ConfigSchema extends TSchema | undefined = TSchema | undefined, Scope extends NornWorkflowScopeInfo | undefined = NornWorkflowScopeInfo | undefined> = {
|
|
@@ -67,13 +62,14 @@ export type NornWorkflowContext<ArgsSchema extends TSchema = TSchema, ConfigSche
|
|
|
67
62
|
} : {});
|
|
68
63
|
export type NornWorkflowDefinition<Name extends string = string, ArgsSchema extends TSchema = TSchema, ConfigSchema extends TSchema | undefined = undefined, Scope extends NornWorkflowScopeInfo | undefined = undefined> = {
|
|
69
64
|
readonly name: Name;
|
|
65
|
+
readonly entrypoint: NornWorkflowEntrypoint;
|
|
70
66
|
readonly args: ArgsSchema;
|
|
71
67
|
readonly config?: ConfigSchema;
|
|
72
68
|
readonly gate?: NornWorkflowGate<ArgsSchema> & {
|
|
73
69
|
describe?(context: NornWorkflowContext<ArgsSchema, ConfigSchema, Scope>): MaybePromise<string>;
|
|
74
70
|
};
|
|
75
71
|
execute(context: NornWorkflowContext<ArgsSchema, ConfigSchema, Scope>): MaybePromise<WorkflowResult>;
|
|
76
|
-
}
|
|
72
|
+
};
|
|
77
73
|
export type NornWorkflowScopeInfo = {
|
|
78
74
|
readonly id: string;
|
|
79
75
|
readonly config?: TSchema;
|
package/dist/api.js
CHANGED
|
@@ -23,8 +23,8 @@ function createWorkflow(input) {
|
|
|
23
23
|
id,
|
|
24
24
|
scope
|
|
25
25
|
});
|
|
26
|
-
if (!isWorkflowDeclaration(result)) throw new Error(`Invalid workflow definition: ${id}`);
|
|
27
26
|
assertWorkflowMetadata(result);
|
|
27
|
+
if (!isWorkflowDeclaration(result)) throw new Error(`Invalid workflow definition: ${id}`);
|
|
28
28
|
return result;
|
|
29
29
|
}
|
|
30
30
|
function workflowScope(input) {
|
|
@@ -62,7 +62,7 @@ function assertDeclarationName(name) {
|
|
|
62
62
|
function isWorkflowDeclaration(value) {
|
|
63
63
|
if (typeof value !== "function") return false;
|
|
64
64
|
const candidate = value;
|
|
65
|
-
return candidate.kind === WORKFLOW_DECLARATION_KIND && typeof candidate.id === "string" && candidate.id.length > 0 && (candidate.
|
|
65
|
+
return candidate.kind === WORKFLOW_DECLARATION_KIND && typeof candidate.id === "string" && candidate.id.length > 0 && (candidate.entrypoint === false || isPlainObject(candidate.entrypoint) && typeof candidate.entrypoint.instructions === "string") && Boolean(candidate.args) && typeof candidate.execute === "function";
|
|
66
66
|
}
|
|
67
67
|
function isWorkflowNext(value) {
|
|
68
68
|
if (!value || typeof value !== "object") return false;
|
package/dist/schema.js
CHANGED
|
@@ -40,11 +40,11 @@ function assertWorkflowReferenceAnnotations(schema) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function assertWorkflowMetadata(workflow) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
if (
|
|
47
|
-
throw new Error(`
|
|
43
|
+
const { entrypoint } = workflow;
|
|
44
|
+
if (entrypoint === false) return;
|
|
45
|
+
if (!isPlainObject(entrypoint)) throw new Error(`Workflow entrypoint must be false or an object with instructions: ${workflow.id}`);
|
|
46
|
+
if (typeof entrypoint.instructions !== "string" || entrypoint.instructions.trim().length === 0) {
|
|
47
|
+
throw new Error(`Workflow entrypoint.instructions must be a nonempty string: ${workflow.id}`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
function unwrapSchema(schema) {
|
package/package.json
CHANGED