@beseif-solutions/prow-core 0.3.8 → 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 +12 -12
- package/package.json +1 -1
- package/src/core.ts +1 -1
- package/src/entities/commons.ts +5 -2
- package/src/entities/events.ts +14 -19
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;
|
|
@@ -115,7 +118,7 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
115
118
|
fields: Config[`fields`];
|
|
116
119
|
request: Request;
|
|
117
120
|
setup?: Config[`setup`];
|
|
118
|
-
}
|
|
121
|
+
} & SourcePreferences<Config>;
|
|
119
122
|
outputs: {
|
|
120
123
|
records: Config[`outputs`][];
|
|
121
124
|
flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
|
|
@@ -127,7 +130,7 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
127
130
|
fields: Config[`fields`];
|
|
128
131
|
link: string;
|
|
129
132
|
setup?: any;
|
|
130
|
-
}
|
|
133
|
+
} & SourcePreferences<Config>;
|
|
131
134
|
outputs: {
|
|
132
135
|
done: boolean;
|
|
133
136
|
};
|
|
@@ -138,7 +141,7 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
138
141
|
fields: Config[`fields`];
|
|
139
142
|
last_schedule: string;
|
|
140
143
|
limit?: number;
|
|
141
|
-
}
|
|
144
|
+
} & SourcePreferences<Config>;
|
|
142
145
|
outputs: {
|
|
143
146
|
records: Config[`outputs`][];
|
|
144
147
|
flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
|
|
@@ -157,7 +160,7 @@ export type ScheduledTrigger<Config extends EventConfig> = CommonEvents<Config>
|
|
|
157
160
|
fields: Config[`fields`];
|
|
158
161
|
last_schedule: string;
|
|
159
162
|
limit?: number;
|
|
160
|
-
}
|
|
163
|
+
} & SourcePreferences<Config>;
|
|
161
164
|
outputs: {
|
|
162
165
|
records: Config[`outputs`][];
|
|
163
166
|
flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
|
|
@@ -184,12 +187,12 @@ export type SyncAction<Config extends MemoryEventConfig> = CommonEvents<Config>
|
|
|
184
187
|
fields: Config[`fields`];
|
|
185
188
|
flags: Partial<Record<Config[`flags`][`inputs`][number], true>>;
|
|
186
189
|
memory?: Config[`memory`];
|
|
187
|
-
}
|
|
190
|
+
} & SourcePreferences<Config>;
|
|
188
191
|
outputs: StandardOutput<Config> | MemoryOutput<Config>;
|
|
189
192
|
}>;
|
|
190
193
|
};
|
|
191
194
|
};
|
|
192
|
-
export type AsyncAction<Config extends
|
|
195
|
+
export type AsyncAction<Config extends MemoryEventConfig> = CommonEvents<Config> & {
|
|
193
196
|
type: `action`;
|
|
194
197
|
inputs: [DefaultConnectableEvent<Config[`flags`][`inputs`][number]>, ...AdditionalConnectableEvent<Config[`flags`][`inputs`][number]>[]];
|
|
195
198
|
outputs: [DefaultConnectableEvent<Config[`flags`][`outputs`][number]>, ...(AdditionalConnectableEvent<Config[`flags`][`outputs`][number]> | ErrorConnectableEvent<Config[`flags`][`outputs`][number]>)[]];
|
|
@@ -201,9 +204,8 @@ export type AsyncAction<Config extends SetupEventConfig & MemoryEventConfig> = C
|
|
|
201
204
|
fields: Config[`fields`];
|
|
202
205
|
flags: Partial<Record<Config[`flags`][`inputs`][number], true>>;
|
|
203
206
|
link: string;
|
|
204
|
-
setup?: Config[`setup`];
|
|
205
207
|
memory?: Config[`memory`];
|
|
206
|
-
}
|
|
208
|
+
} & SourcePreferences<Config>;
|
|
207
209
|
outputs: {
|
|
208
210
|
done: boolean;
|
|
209
211
|
memory?: Config[`memory`];
|
|
@@ -214,9 +216,8 @@ export type AsyncAction<Config extends SetupEventConfig & MemoryEventConfig> = C
|
|
|
214
216
|
inputs: {
|
|
215
217
|
fields: Config[`fields`];
|
|
216
218
|
request: Request;
|
|
217
|
-
setup?: Config[`setup`];
|
|
218
219
|
memory?: Config[`memory`];
|
|
219
|
-
}
|
|
220
|
+
} & SourcePreferences<Config>;
|
|
220
221
|
outputs: StandardOutput<Config>;
|
|
221
222
|
}>;
|
|
222
223
|
fire?: CoreFunction<{
|
|
@@ -224,9 +225,8 @@ export type AsyncAction<Config extends SetupEventConfig & MemoryEventConfig> = C
|
|
|
224
225
|
inputs: {
|
|
225
226
|
fields: Config[`fields`];
|
|
226
227
|
link: string;
|
|
227
|
-
setup?: Config[`setup`];
|
|
228
228
|
memory?: Config[`memory`];
|
|
229
|
-
}
|
|
229
|
+
} & SourcePreferences<Config>;
|
|
230
230
|
outputs: {
|
|
231
231
|
done: boolean;
|
|
232
232
|
};
|
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,
|
|
@@ -97,17 +102,17 @@ export type ImmediateTrigger<Config extends SetupEventConfig> = CommonEvents<Con
|
|
|
97
102
|
}>,
|
|
98
103
|
handle: CoreFunction<{
|
|
99
104
|
credentials: Config[`credentials`],
|
|
100
|
-
inputs: { fields: Config[`fields`], request: Request, setup?: Config[`setup`] }
|
|
105
|
+
inputs: { fields: Config[`fields`], request: Request, setup?: Config[`setup`] } & SourcePreferences<Config>,
|
|
101
106
|
outputs: { records: Config[`outputs`][], flags: Partial<Record<Config[`flags`][`outputs`][number], true>> },
|
|
102
107
|
}>,
|
|
103
108
|
fire?: CoreFunction<{
|
|
104
109
|
credentials: Config[`credentials`],
|
|
105
|
-
inputs: { fields: Config[`fields`], link: string, setup?: any }
|
|
110
|
+
inputs: { fields: Config[`fields`], link: string, setup?: any } & SourcePreferences<Config>,
|
|
106
111
|
outputs: { done: boolean },
|
|
107
112
|
}>,
|
|
108
113
|
poll?: CoreFunction<{
|
|
109
114
|
credentials: Config[`credentials`],
|
|
110
|
-
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number }
|
|
115
|
+
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number } & SourcePreferences<Config>,
|
|
111
116
|
outputs: { records: Config[`outputs`][], flags: Partial<Record<Config[`flags`][`outputs`][number], true>> },
|
|
112
117
|
}>,
|
|
113
118
|
},
|
|
@@ -120,7 +125,7 @@ export type ScheduledTrigger<Config extends EventConfig> = CommonEvents<Config>
|
|
|
120
125
|
functions: {
|
|
121
126
|
poll: CoreFunction<{
|
|
122
127
|
credentials: Config[`credentials`],
|
|
123
|
-
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number }
|
|
128
|
+
inputs: { fields: Config[`fields`], last_schedule: string, limit?: number } & SourcePreferences<Config>,
|
|
124
129
|
outputs: { records: Config[`outputs`][], flags: Partial<Record<Config[`flags`][`outputs`][number], true>> },
|
|
125
130
|
}>,
|
|
126
131
|
},
|
|
@@ -144,41 +149,31 @@ export type SyncAction<Config extends MemoryEventConfig> = CommonEvents<Config>
|
|
|
144
149
|
functions: {
|
|
145
150
|
execute: CoreFunction<{
|
|
146
151
|
credentials: Config[`credentials`],
|
|
147
|
-
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>,
|
|
148
153
|
outputs: StandardOutput<Config> | MemoryOutput<Config>,
|
|
149
154
|
}>,
|
|
150
155
|
},
|
|
151
156
|
};
|
|
152
157
|
|
|
153
|
-
export type AsyncAction<Config extends
|
|
158
|
+
export type AsyncAction<Config extends MemoryEventConfig> = CommonEvents<Config> & {
|
|
154
159
|
type: `action`,
|
|
155
160
|
inputs: [DefaultConnectableEvent<Config[`flags`][`inputs`][number]>, ...AdditionalConnectableEvent<Config[`flags`][`inputs`][number]>[]],
|
|
156
161
|
outputs: [DefaultConnectableEvent<Config[`flags`][`outputs`][number]>, ...(AdditionalConnectableEvent<Config[`flags`][`outputs`][number]> | ErrorConnectableEvent<Config[`flags`][`outputs`][number]>)[]],
|
|
157
162
|
async: true,
|
|
158
163
|
functions: {
|
|
159
|
-
// mount?: CoreFunction<{
|
|
160
|
-
// credentials: Config[`credentials`],
|
|
161
|
-
// inputs: { fields: Config[`fields`], link: string },
|
|
162
|
-
// outputs: { done: boolean, setup?: Config[`setup`] },
|
|
163
|
-
// }>,
|
|
164
|
-
// unmount?: CoreFunction<{
|
|
165
|
-
// credentials: Config[`credentials`],
|
|
166
|
-
// inputs: { fields: Config[`fields`], link: string, setup?: Config[`setup`] },
|
|
167
|
-
// outputs: { done: boolean },
|
|
168
|
-
// }>,
|
|
169
164
|
execute: CoreFunction<{
|
|
170
165
|
credentials: Config[`credentials`],
|
|
171
|
-
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>,
|
|
172
167
|
outputs: { done: boolean, memory?: Config[`memory`] },
|
|
173
168
|
}>,
|
|
174
169
|
handle: CoreFunction<{
|
|
175
170
|
credentials: Config[`credentials`],
|
|
176
|
-
inputs: { fields: Config[`fields`], request: Request,
|
|
171
|
+
inputs: { fields: Config[`fields`], request: Request, memory?: Config[`memory`] } & SourcePreferences<Config>,
|
|
177
172
|
outputs: StandardOutput<Config>,
|
|
178
173
|
}>,
|
|
179
174
|
fire?: CoreFunction<{
|
|
180
175
|
credentials: Config[`credentials`],
|
|
181
|
-
inputs: { fields: Config[`fields`], link: string,
|
|
176
|
+
inputs: { fields: Config[`fields`], link: string, memory?: Config[`memory`] } & SourcePreferences<Config>,
|
|
182
177
|
outputs: { done: boolean },
|
|
183
178
|
}>,
|
|
184
179
|
},
|