@mark1russell7/workflow 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +16 -2
- package/build/index.d.ts +409 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1451 -0
- package/build/index.js.map +1 -0
- package/package.json +44 -3
- package/src/check.ts +430 -0
- package/src/edit.ts +267 -0
- package/src/index.ts +21 -0
- package/src/language.ts +225 -0
- package/src/sample.ts +64 -0
- package/src/world.ts +158 -0
package/src/world.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Kind, Namespace, PartShape as Shape, WorldPart } from "@mark1russell7/coeval";
|
|
2
|
+
|
|
3
|
+
/** The name of the format of a workflow document. */
|
|
4
|
+
export const WORKFLOW_FORMAT = "workflow/1";
|
|
5
|
+
|
|
6
|
+
const text: Shape = { shape: "text" };
|
|
7
|
+
/** An expression: a document, or a bare JSON value that is a literal. */
|
|
8
|
+
const term: Shape = { shape: "term", of: "lit" };
|
|
9
|
+
/** A document of the workflow: a trigger, a job, a step or a call. */
|
|
10
|
+
const node: Shape = { shape: "term" };
|
|
11
|
+
const data: Shape = { shape: "none" };
|
|
12
|
+
const terms: Shape = { shape: "map", item: term };
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The kinds of a trigger. A trigger is data, but a filter or a condition in it is a document. An add-on adds a trigger
|
|
16
|
+
* kind to the namespace `trigger`, for example the events of one host.
|
|
17
|
+
*/
|
|
18
|
+
const TRIGGERS: Namespace = {
|
|
19
|
+
kinds: {
|
|
20
|
+
manual: {
|
|
21
|
+
verbs: { eval: "workflow.trigger" },
|
|
22
|
+
parts: { shape: "record", fields: { summary: text, layers: data }, closed: true },
|
|
23
|
+
summary: "A person starts the workflow by a click, with the inputs of the workflow.",
|
|
24
|
+
},
|
|
25
|
+
schedule: {
|
|
26
|
+
verbs: { eval: "workflow.trigger" },
|
|
27
|
+
parts: { shape: "record", fields: { cron: text, zone: text, layers: data }, required: ["cron"], closed: true },
|
|
28
|
+
summary: "The clock starts the workflow at each time of a cron line, in a time zone.",
|
|
29
|
+
},
|
|
30
|
+
event: {
|
|
31
|
+
verbs: { eval: "workflow.trigger" },
|
|
32
|
+
parts: { shape: "record", fields: { event: text, types: { shape: "list", item: text }, when: term, layers: data }, required: ["event"], closed: true },
|
|
33
|
+
summary: "An event of the host starts the workflow. The condition when selects the events.",
|
|
34
|
+
},
|
|
35
|
+
feed: {
|
|
36
|
+
verbs: { eval: "workflow.trigger" },
|
|
37
|
+
parts: { shape: "record", fields: { from: text, collection: text, when: term, layers: data }, required: ["from", "collection"], closed: true },
|
|
38
|
+
summary: "A new or changed record of a collection of a workspace starts the workflow. This is a read of that workspace.",
|
|
39
|
+
},
|
|
40
|
+
call: {
|
|
41
|
+
verbs: { eval: "workflow.trigger" },
|
|
42
|
+
parts: { shape: "record", fields: { summary: text, layers: data }, closed: true },
|
|
43
|
+
summary: "Another workflow calls this workflow as a procedure, with its inputs and its outputs.",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The namespace `procedure`: each document under it is a call of a procedure. The keys after `procedure` are the path of the
|
|
50
|
+
* procedure, for example `["procedure", "git", "clone"]`. The value is the record of the inputs, and each input is a
|
|
51
|
+
* document. A call is on the run side, and its effect has the kind of its path, thus a grant names procedures.
|
|
52
|
+
*/
|
|
53
|
+
const PROCEDURES: Namespace = {
|
|
54
|
+
kinds: {},
|
|
55
|
+
fallback: {
|
|
56
|
+
verbs: { eval: "workflow.call" },
|
|
57
|
+
parts: { shape: "record", fields: {}, rest: term },
|
|
58
|
+
side: "run",
|
|
59
|
+
effects: "type",
|
|
60
|
+
summary: "A call of a procedure. The path after procedure names the procedure, and the value holds its inputs.",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const step: Kind = {
|
|
65
|
+
verbs: { eval: "workflow.step" },
|
|
66
|
+
parts: {
|
|
67
|
+
shape: "record",
|
|
68
|
+
fields: {
|
|
69
|
+
id: text,
|
|
70
|
+
name: text,
|
|
71
|
+
if: term,
|
|
72
|
+
do: node,
|
|
73
|
+
env: terms,
|
|
74
|
+
retry: data,
|
|
75
|
+
timeout: { shape: "number", min: 0 },
|
|
76
|
+
continue: { shape: "one", values: [true, false] },
|
|
77
|
+
layers: data,
|
|
78
|
+
},
|
|
79
|
+
required: ["do"],
|
|
80
|
+
closed: true,
|
|
81
|
+
},
|
|
82
|
+
summary: "One step of a job: a call of a procedure, with a condition, a retry rule and a time limit.",
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const job: Kind = {
|
|
86
|
+
verbs: { eval: "workflow.job" },
|
|
87
|
+
parts: {
|
|
88
|
+
shape: "record",
|
|
89
|
+
fields: {
|
|
90
|
+
name: text,
|
|
91
|
+
needs: { shape: "list", item: text },
|
|
92
|
+
if: term,
|
|
93
|
+
matrix: node,
|
|
94
|
+
env: terms,
|
|
95
|
+
steps: { shape: "list", item: node },
|
|
96
|
+
outputs: terms,
|
|
97
|
+
timeout: { shape: "number", min: 0 },
|
|
98
|
+
layers: data,
|
|
99
|
+
},
|
|
100
|
+
required: ["steps"],
|
|
101
|
+
closed: true,
|
|
102
|
+
},
|
|
103
|
+
summary: "A job: steps in order. The jobs run at the same time, unless one needs another.",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const matrix: Kind = {
|
|
107
|
+
verbs: { eval: "workflow.matrix" },
|
|
108
|
+
parts: { shape: "record", fields: { axes: terms, include: term, exclude: term, parallel: { shape: "number", whole: true, min: 1 } }, closed: true },
|
|
109
|
+
summary: "A job runs one time for each combination of the values of its axes.",
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const workflow: Kind = {
|
|
113
|
+
verbs: { eval: "workflow.workflow" },
|
|
114
|
+
parts: {
|
|
115
|
+
shape: "record",
|
|
116
|
+
fields: {
|
|
117
|
+
name: text,
|
|
118
|
+
summary: text,
|
|
119
|
+
workspace: text,
|
|
120
|
+
triggers: { shape: "list", item: node },
|
|
121
|
+
inputs: data,
|
|
122
|
+
secrets: data,
|
|
123
|
+
env: terms,
|
|
124
|
+
jobs: { shape: "map", item: node },
|
|
125
|
+
outputs: terms,
|
|
126
|
+
layers: data,
|
|
127
|
+
},
|
|
128
|
+
required: ["name", "workspace", "triggers", "jobs"],
|
|
129
|
+
closed: true,
|
|
130
|
+
},
|
|
131
|
+
summary: "A workflow: its triggers, its inputs, the names of its secrets, and its jobs. It belongs to one workspace.",
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The world of the workflow language. The formula kit of the kernel gives the expressions: `lit`, `ref`, `if`,
|
|
136
|
+
* `and`, `or` and the operations. This world adds the structure, the calls, the text templates and the secrets.
|
|
137
|
+
*/
|
|
138
|
+
export const WORKFLOW_WORLD: WorldPart = {
|
|
139
|
+
kinds: {
|
|
140
|
+
workflow,
|
|
141
|
+
job,
|
|
142
|
+
step,
|
|
143
|
+
matrix,
|
|
144
|
+
trigger: TRIGGERS,
|
|
145
|
+
procedure: PROCEDURES,
|
|
146
|
+
template: {
|
|
147
|
+
verbs: { eval: "workflow.template" },
|
|
148
|
+
parts: { shape: "list", of: "lit" },
|
|
149
|
+
pure: true,
|
|
150
|
+
summary: "A text with documents in it. Each text part stays, and each document gives its value as text.",
|
|
151
|
+
},
|
|
152
|
+
secret: {
|
|
153
|
+
verbs: { eval: "workflow.secret" },
|
|
154
|
+
pure: true,
|
|
155
|
+
summary: "A reference to a secret by its name. It never holds the value, and only a call can use it.",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
};
|