@beseif-solutions/prow-core 0.3.7 → 0.3.9
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/core.d.ts +1 -1
- package/dist/entities/commons.d.ts +3 -2
- package/dist/entities/events.d.ts +23 -34
- package/dist/entities/events.js +1 -2
- package/package.json +1 -1
- package/src/core.ts +1 -1
- package/src/entities/commons.ts +5 -2
- package/src/entities/events.ts +22 -21
package/dist/core.d.ts
CHANGED
|
@@ -5,14 +5,15 @@ export type CoreConfig = {
|
|
|
5
5
|
credentials?: Record<string, any>;
|
|
6
6
|
outputs?: any;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Configuration<Config extends CoreConfig> = ({
|
|
9
9
|
sandbox: boolean;
|
|
10
10
|
organization?: string;
|
|
11
11
|
} & (Config[`inputs`] extends undefined ? {} : {
|
|
12
12
|
inputs: Config[`inputs`];
|
|
13
13
|
}) & (Config[`credentials`] extends undefined ? {} : {
|
|
14
14
|
credentials: Config[`credentials`];
|
|
15
|
-
}))
|
|
15
|
+
}));
|
|
16
|
+
export type CoreFunction<Config extends CoreConfig = {}> = ((core: Core, configuration: Configuration<Config>) => Promise<Config[`outputs`]>) | ((core: Core, configuration: Configuration<Config>) => Config[`outputs`]);
|
|
16
17
|
type CommonConfig = Pick<CoreConfig, `credentials`>;
|
|
17
18
|
export type Common<Config extends CommonConfig = {}> = {
|
|
18
19
|
id: string;
|
|
@@ -58,6 +58,9 @@ export type Request = {
|
|
|
58
58
|
body: Record<string, any>;
|
|
59
59
|
raw: string;
|
|
60
60
|
};
|
|
61
|
+
type SourcePreferences<Config extends EventConfig> = Config[`sources`] extends string[] ? {
|
|
62
|
+
sources: Record<Config[`sources`][number], boolean>;
|
|
63
|
+
} : {};
|
|
61
64
|
export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Config> & {
|
|
62
65
|
type: `trigger`;
|
|
63
66
|
immediate: true;
|
|
@@ -74,6 +77,17 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
74
77
|
setup?: Config[`setup`];
|
|
75
78
|
};
|
|
76
79
|
}>;
|
|
80
|
+
check?: CoreFunction<{
|
|
81
|
+
credentials: Config[`credentials`];
|
|
82
|
+
inputs: {
|
|
83
|
+
fields: Config[`fields`];
|
|
84
|
+
link: string;
|
|
85
|
+
setup?: Config[`setup`];
|
|
86
|
+
};
|
|
87
|
+
outputs: {
|
|
88
|
+
done: boolean;
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
77
91
|
unmount?: CoreFunction<{
|
|
78
92
|
credentials: Config[`credentials`];
|
|
79
93
|
inputs: {
|
|
@@ -104,7 +118,7 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
104
118
|
fields: Config[`fields`];
|
|
105
119
|
request: Request;
|
|
106
120
|
setup?: Config[`setup`];
|
|
107
|
-
}
|
|
121
|
+
} & SourcePreferences<Config>;
|
|
108
122
|
outputs: {
|
|
109
123
|
records: Config[`outputs`][];
|
|
110
124
|
flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
|
|
@@ -116,7 +130,7 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
116
130
|
fields: Config[`fields`];
|
|
117
131
|
link: string;
|
|
118
132
|
setup?: any;
|
|
119
|
-
}
|
|
133
|
+
} & SourcePreferences<Config>;
|
|
120
134
|
outputs: {
|
|
121
135
|
done: boolean;
|
|
122
136
|
};
|
|
@@ -127,7 +141,7 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
127
141
|
fields: Config[`fields`];
|
|
128
142
|
last_schedule: string;
|
|
129
143
|
limit?: number;
|
|
130
|
-
}
|
|
144
|
+
} & SourcePreferences<Config>;
|
|
131
145
|
outputs: {
|
|
132
146
|
records: Config[`outputs`][];
|
|
133
147
|
flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
|
|
@@ -146,7 +160,7 @@ export type ScheduledTrigger<Config extends EventConfig> = CommonEvents<Config>
|
|
|
146
160
|
fields: Config[`fields`];
|
|
147
161
|
last_schedule: string;
|
|
148
162
|
limit?: number;
|
|
149
|
-
}
|
|
163
|
+
} & SourcePreferences<Config>;
|
|
150
164
|
outputs: {
|
|
151
165
|
records: Config[`outputs`][];
|
|
152
166
|
flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
|
|
@@ -173,48 +187,25 @@ export type SyncAction<Config extends MemoryEventConfig> = CommonEvents<Config>
|
|
|
173
187
|
fields: Config[`fields`];
|
|
174
188
|
flags: Partial<Record<Config[`flags`][`inputs`][number], true>>;
|
|
175
189
|
memory?: Config[`memory`];
|
|
176
|
-
}
|
|
190
|
+
} & SourcePreferences<Config>;
|
|
177
191
|
outputs: StandardOutput<Config> | MemoryOutput<Config>;
|
|
178
192
|
}>;
|
|
179
193
|
};
|
|
180
194
|
};
|
|
181
|
-
export type AsyncAction<Config extends
|
|
195
|
+
export type AsyncAction<Config extends MemoryEventConfig> = CommonEvents<Config> & {
|
|
182
196
|
type: `action`;
|
|
183
197
|
inputs: [DefaultConnectableEvent<Config[`flags`][`inputs`][number]>, ...AdditionalConnectableEvent<Config[`flags`][`inputs`][number]>[]];
|
|
184
198
|
outputs: [DefaultConnectableEvent<Config[`flags`][`outputs`][number]>, ...(AdditionalConnectableEvent<Config[`flags`][`outputs`][number]> | ErrorConnectableEvent<Config[`flags`][`outputs`][number]>)[]];
|
|
185
199
|
async: true;
|
|
186
200
|
functions: {
|
|
187
|
-
mount?: CoreFunction<{
|
|
188
|
-
credentials: Config[`credentials`];
|
|
189
|
-
inputs: {
|
|
190
|
-
fields: Config[`fields`];
|
|
191
|
-
link: string;
|
|
192
|
-
};
|
|
193
|
-
outputs: {
|
|
194
|
-
done: boolean;
|
|
195
|
-
setup?: Config[`setup`];
|
|
196
|
-
};
|
|
197
|
-
}>;
|
|
198
|
-
unmount?: CoreFunction<{
|
|
199
|
-
credentials: Config[`credentials`];
|
|
200
|
-
inputs: {
|
|
201
|
-
fields: Config[`fields`];
|
|
202
|
-
link: string;
|
|
203
|
-
setup?: Config[`setup`];
|
|
204
|
-
};
|
|
205
|
-
outputs: {
|
|
206
|
-
done: boolean;
|
|
207
|
-
};
|
|
208
|
-
}>;
|
|
209
201
|
execute: CoreFunction<{
|
|
210
202
|
credentials: Config[`credentials`];
|
|
211
203
|
inputs: {
|
|
212
204
|
fields: Config[`fields`];
|
|
213
205
|
flags: Partial<Record<Config[`flags`][`inputs`][number], true>>;
|
|
214
206
|
link: string;
|
|
215
|
-
setup?: Config[`setup`];
|
|
216
207
|
memory?: Config[`memory`];
|
|
217
|
-
}
|
|
208
|
+
} & SourcePreferences<Config>;
|
|
218
209
|
outputs: {
|
|
219
210
|
done: boolean;
|
|
220
211
|
memory?: Config[`memory`];
|
|
@@ -225,9 +216,8 @@ export type AsyncAction<Config extends SetupEventConfig & MemoryEventConfig> = C
|
|
|
225
216
|
inputs: {
|
|
226
217
|
fields: Config[`fields`];
|
|
227
218
|
request: Request;
|
|
228
|
-
setup?: Config[`setup`];
|
|
229
219
|
memory?: Config[`memory`];
|
|
230
|
-
}
|
|
220
|
+
} & SourcePreferences<Config>;
|
|
231
221
|
outputs: StandardOutput<Config>;
|
|
232
222
|
}>;
|
|
233
223
|
fire?: CoreFunction<{
|
|
@@ -235,9 +225,8 @@ export type AsyncAction<Config extends SetupEventConfig & MemoryEventConfig> = C
|
|
|
235
225
|
inputs: {
|
|
236
226
|
fields: Config[`fields`];
|
|
237
227
|
link: string;
|
|
238
|
-
setup?: Config[`setup`];
|
|
239
228
|
memory?: Config[`memory`];
|
|
240
|
-
}
|
|
229
|
+
} & SourcePreferences<Config>;
|
|
241
230
|
outputs: {
|
|
242
231
|
done: boolean;
|
|
243
232
|
};
|
package/dist/entities/events.js
CHANGED
|
@@ -67,6 +67,7 @@ const immediateTriggerSchema = () => joi_1.default.object({
|
|
|
67
67
|
.required(),
|
|
68
68
|
functions: joi_1.default.object({
|
|
69
69
|
mount: joi_1.default.function(),
|
|
70
|
+
check: joi_1.default.function(),
|
|
70
71
|
unmount: joi_1.default.function(),
|
|
71
72
|
challenge: joi_1.default.function(),
|
|
72
73
|
handle: joi_1.default.function().required(),
|
|
@@ -108,8 +109,6 @@ const asyncActionSchema = () => joi_1.default.object({
|
|
|
108
109
|
.min(1)
|
|
109
110
|
.required(),
|
|
110
111
|
functions: joi_1.default.object({
|
|
111
|
-
mount: joi_1.default.function(),
|
|
112
|
-
unmount: joi_1.default.function(),
|
|
113
112
|
execute: joi_1.default.function().required(),
|
|
114
113
|
handle: joi_1.default.function().required(),
|
|
115
114
|
fire: joi_1.default.function(),
|
package/package.json
CHANGED
package/src/core.ts
CHANGED
package/src/entities/commons.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type CoreConfig = {
|
|
|
7
7
|
outputs?: any,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type Configuration<Config extends CoreConfig> = ({
|
|
11
11
|
sandbox: boolean,
|
|
12
12
|
organization?: string,
|
|
13
13
|
} & (
|
|
@@ -20,8 +20,11 @@ export type CoreFunction<Config extends CoreConfig = {}> = (core: Core, configur
|
|
|
20
20
|
{} :
|
|
21
21
|
{ credentials: Config[`credentials`] }
|
|
22
22
|
)
|
|
23
|
-
)
|
|
23
|
+
);
|
|
24
24
|
|
|
25
|
+
export type CoreFunction<Config extends CoreConfig = {}> =
|
|
26
|
+
((core: Core, configuration: Configuration<Config>) => Promise<Config[`outputs`]>)
|
|
27
|
+
| ((core: Core, configuration: Configuration<Config>) => Config[`outputs`]);
|
|
25
28
|
|
|
26
29
|
type CommonConfig = Pick<CoreConfig, `credentials`>;
|
|
27
30
|
|
package/src/entities/events.ts
CHANGED
|
@@ -70,6 +70,11 @@ export type Request = {
|
|
|
70
70
|
raw: string,
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
type SourcePreferences<Config extends EventConfig> =
|
|
74
|
+
Config[`sources`] extends string[]
|
|
75
|
+
? { sources: Record<Config[`sources`][number], boolean> }
|
|
76
|
+
: {};
|
|
77
|
+
|
|
73
78
|
export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Config> & {
|
|
74
79
|
type: `trigger`,
|
|
75
80
|
immediate: true,
|
|
@@ -80,6 +85,11 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
80
85
|
inputs: { fields: Config[`fields`], link: string },
|
|
81
86
|
outputs: { done: boolean, setup?: Config[`setup`] },
|
|
82
87
|
}>,
|
|
88
|
+
check?: CoreFunction<{
|
|
89
|
+
credentials: Config[`credentials`],
|
|
90
|
+
inputs: { fields: Config[`fields`], link: string, setup?: Config[`setup`] },
|
|
91
|
+
outputs: { done: boolean },
|
|
92
|
+
}>,
|
|
83
93
|
unmount?: CoreFunction<{
|
|
84
94
|
credentials: Config[`credentials`],
|
|
85
95
|
inputs: { fields: Config[`fields`], link: string, setup?: Config[`setup`] },
|
|
@@ -92,17 +102,17 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
92
102
|
}>,
|
|
93
103
|
handle: CoreFunction<{
|
|
94
104
|
credentials: Config[`credentials`],
|
|
95
|
-
inputs: { fields: Config[`fields`], request: Request, setup?: Config[`setup`] }
|
|
105
|
+
inputs: { fields: Config[`fields`], request: Request, setup?: Config[`setup`] } & SourcePreferences<Config>,
|
|
96
106
|
outputs: { records: Config[`outputs`][], flags: Partial<Record<Config[`flags`][`outputs`][number], true>> },
|
|
97
107
|
}>,
|
|
98
108
|
fire?: CoreFunction<{
|
|
99
109
|
credentials: Config[`credentials`],
|
|
100
|
-
inputs: { fields: Config[`fields`], link: string, setup?: any }
|
|
110
|
+
inputs: { fields: Config[`fields`], link: string, setup?: any } & SourcePreferences<Config>,
|
|
101
111
|
outputs: { done: boolean },
|
|
102
112
|
}>,
|
|
103
113
|
poll?: CoreFunction<{
|
|
104
114
|
credentials: Config[`credentials`],
|
|
105
|
-
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number }
|
|
115
|
+
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number } & SourcePreferences<Config>,
|
|
106
116
|
outputs: { records: Config[`outputs`][], flags: Partial<Record<Config[`flags`][`outputs`][number], true>> },
|
|
107
117
|
}>,
|
|
108
118
|
},
|
|
@@ -115,7 +125,7 @@ export type ScheduledTrigger<Config extends EventConfig> = CommonEvents<Config>
|
|
|
115
125
|
functions: {
|
|
116
126
|
poll: CoreFunction<{
|
|
117
127
|
credentials: Config[`credentials`],
|
|
118
|
-
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number }
|
|
128
|
+
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number } & SourcePreferences<Config>,
|
|
119
129
|
outputs: { records: Config[`outputs`][], flags: Partial<Record<Config[`flags`][`outputs`][number], true>> },
|
|
120
130
|
}>,
|
|
121
131
|
},
|
|
@@ -139,41 +149,31 @@ export type SyncAction<Config extends MemoryEventConfig> = CommonEvents<Config>
|
|
|
139
149
|
functions: {
|
|
140
150
|
execute: CoreFunction<{
|
|
141
151
|
credentials: Config[`credentials`],
|
|
142
|
-
inputs: { fields: Config[`fields`], flags: Partial<Record<Config[`flags`][`inputs`][number], true>>, memory?: Config[`memory`] }
|
|
152
|
+
inputs: { fields: Config[`fields`], flags: Partial<Record<Config[`flags`][`inputs`][number], true>>, memory?: Config[`memory`] } & SourcePreferences<Config>,
|
|
143
153
|
outputs: StandardOutput<Config> | MemoryOutput<Config>,
|
|
144
154
|
}>,
|
|
145
155
|
},
|
|
146
156
|
};
|
|
147
157
|
|
|
148
|
-
export type AsyncAction<Config extends
|
|
158
|
+
export type AsyncAction<Config extends MemoryEventConfig> = CommonEvents<Config> & {
|
|
149
159
|
type: `action`,
|
|
150
160
|
inputs: [DefaultConnectableEvent<Config[`flags`][`inputs`][number]>, ...AdditionalConnectableEvent<Config[`flags`][`inputs`][number]>[]],
|
|
151
161
|
outputs: [DefaultConnectableEvent<Config[`flags`][`outputs`][number]>, ...(AdditionalConnectableEvent<Config[`flags`][`outputs`][number]> | ErrorConnectableEvent<Config[`flags`][`outputs`][number]>)[]],
|
|
152
162
|
async: true,
|
|
153
163
|
functions: {
|
|
154
|
-
mount?: CoreFunction<{
|
|
155
|
-
credentials: Config[`credentials`],
|
|
156
|
-
inputs: { fields: Config[`fields`], link: string },
|
|
157
|
-
outputs: { done: boolean, setup?: Config[`setup`] },
|
|
158
|
-
}>,
|
|
159
|
-
unmount?: CoreFunction<{
|
|
160
|
-
credentials: Config[`credentials`],
|
|
161
|
-
inputs: { fields: Config[`fields`], link: string, setup?: Config[`setup`] },
|
|
162
|
-
outputs: { done: boolean },
|
|
163
|
-
}>,
|
|
164
164
|
execute: CoreFunction<{
|
|
165
165
|
credentials: Config[`credentials`],
|
|
166
|
-
inputs: { fields: Config[`fields`], flags: Partial<Record<Config[`flags`][`inputs`][number], true>>, link: string,
|
|
166
|
+
inputs: { fields: Config[`fields`], flags: Partial<Record<Config[`flags`][`inputs`][number], true>>, link: string, memory?: Config[`memory`] } & SourcePreferences<Config>,
|
|
167
167
|
outputs: { done: boolean, memory?: Config[`memory`] },
|
|
168
168
|
}>,
|
|
169
169
|
handle: CoreFunction<{
|
|
170
170
|
credentials: Config[`credentials`],
|
|
171
|
-
inputs: { fields: Config[`fields`], request: Request,
|
|
171
|
+
inputs: { fields: Config[`fields`], request: Request, memory?: Config[`memory`] } & SourcePreferences<Config>,
|
|
172
172
|
outputs: StandardOutput<Config>,
|
|
173
173
|
}>,
|
|
174
174
|
fire?: CoreFunction<{
|
|
175
175
|
credentials: Config[`credentials`],
|
|
176
|
-
inputs: { fields: Config[`fields`], link: string,
|
|
176
|
+
inputs: { fields: Config[`fields`], link: string, memory?: Config[`memory`] } & SourcePreferences<Config>,
|
|
177
177
|
outputs: { done: boolean },
|
|
178
178
|
}>,
|
|
179
179
|
},
|
|
@@ -260,6 +260,7 @@ export const immediateTriggerSchema = () =>
|
|
|
260
260
|
.required(),
|
|
261
261
|
functions: Joi.object({
|
|
262
262
|
mount: Joi.function(),
|
|
263
|
+
check: Joi.function(),
|
|
263
264
|
unmount: Joi.function(),
|
|
264
265
|
challenge: Joi.function(),
|
|
265
266
|
handle: Joi.function().required(),
|
|
@@ -318,8 +319,8 @@ export const asyncActionSchema = () =>
|
|
|
318
319
|
.min(1)
|
|
319
320
|
.required(),
|
|
320
321
|
functions: Joi.object({
|
|
321
|
-
mount: Joi.function(),
|
|
322
|
-
unmount: Joi.function(),
|
|
322
|
+
// mount: Joi.function(),
|
|
323
|
+
// unmount: Joi.function(),
|
|
323
324
|
execute: Joi.function().required(),
|
|
324
325
|
handle: Joi.function().required(),
|
|
325
326
|
fire: Joi.function(),
|