@beseif-solutions/prow-core 1.5.1 → 1.6.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.
@@ -3,7 +3,7 @@ import { Core } from "../core";
3
3
  export type CoreConfig = {
4
4
  inputs?: Record<string, any>;
5
5
  credentials?: Record<string, any>;
6
- outputs?: any;
6
+ outputs?: Record<string, any> | any[];
7
7
  };
8
8
  type Configuration<Config extends CoreConfig> = ({
9
9
  sandbox: boolean;
@@ -48,7 +48,10 @@ type CommonEvents<Config extends EventConfig> = Common<Config> & {
48
48
  credentials: string[];
49
49
  sandbox: boolean;
50
50
  fields: Field[];
51
- examples: Config[`outputs`][];
51
+ examples: {
52
+ data: Config[`outputs`];
53
+ flags: Partial<Record<Config[`flags`][`outputs`][number], true>>;
54
+ }[];
52
55
  sources?: SourceConnection<Config[`sources`][number]>[];
53
56
  };
54
57
  export type Request = {
@@ -33,7 +33,12 @@ const commonEventsSchema = () => joi_1.default.object({
33
33
  credentials: joi_1.default.array().items((0, commons_1.idSchema)().optional()).required().min(0),
34
34
  sandbox: joi_1.default.bool().required(),
35
35
  fields: (0, validation_1.fieldsSchema)().required(),
36
- examples: joi_1.default.array(),
36
+ examples: joi_1.default.array().items(joi_1.default.object({
37
+ data: joi_1.default.alternatives(joi_1.default.array(), joi_1.default.object()).required(),
38
+ flags: joi_1.default.object()
39
+ .pattern(joi_1.default.string(), joi_1.default.valid(true))
40
+ .required(),
41
+ })),
37
42
  sources: joi_1.default.array().items(joi_1.default.object({
38
43
  role: joi_1.default.valid(`subscriber`, `consumer`).required(),
39
44
  id: (0, commons_1.idSchema)(),
@@ -6,12 +6,16 @@ export type Condition = {
6
6
  export type CommonField = {
7
7
  key: string;
8
8
  altered_by?: Condition[];
9
- disabled?: boolean;
10
- required?: boolean;
11
9
  as_password?: boolean;
10
+ disabled?: boolean;
12
11
  show?: boolean;
13
12
  t?: string;
14
13
  } & ({
14
+ required: true;
15
+ } | {
16
+ required?: false;
17
+ additional?: boolean;
18
+ }) & ({
15
19
  as_array?: false;
16
20
  } | {
17
21
  as_array: true;
@@ -16,10 +16,15 @@ const conditionSchema = () => joi_1.default.object({
16
16
  const commonFieldSchema = () => joi_1.default.object({
17
17
  key: joi_1.default.string().required(),
18
18
  altered_by: joi_1.default.array().items(conditionSchema()),
19
- disabled: joi_1.default.bool(),
20
- required: joi_1.default.bool(),
21
19
  as_password: joi_1.default.bool(),
20
+ required: joi_1.default.bool(),
21
+ disabled: joi_1.default.bool(),
22
22
  show: joi_1.default.bool(),
23
+ additional: joi_1.default.when(`required`, {
24
+ is: false,
25
+ then: joi_1.default.bool(),
26
+ otherwise: joi_1.default.forbidden(),
27
+ }),
23
28
  t: joi_1.default.string(),
24
29
  as_array: joi_1.default.bool(),
25
30
  array_min: joi_1.default.when(`as_array`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beseif-solutions/prow-core",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Prow core functionalities and classes",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -4,7 +4,7 @@ import { Core } from "../core";
4
4
  export type CoreConfig = {
5
5
  inputs?: Record<string, any>,
6
6
  credentials?: Record<string, any>,
7
- outputs?: any,
7
+ outputs?: Record<string, any> | any[],
8
8
  };
9
9
 
10
10
  type Configuration<Config extends CoreConfig> = ({
@@ -59,7 +59,10 @@ type CommonEvents<Config extends EventConfig> = Common<Config> & {
59
59
  credentials: string[],
60
60
  sandbox: boolean,
61
61
  fields: Field[],
62
- examples: Config[`outputs`][],
62
+ examples: {
63
+ data: Config[`outputs`],
64
+ flags: Partial<Record<Config[`flags`][`outputs`][number], true>>,
65
+ }[],
63
66
  sources?: SourceConnection<Config[`sources`][number]>[],
64
67
  };
65
68
 
@@ -274,7 +277,15 @@ const commonEventsSchema = () =>
274
277
  credentials: Joi.array().items(idSchema().optional()).required().min(0),
275
278
  sandbox: Joi.bool().required(),
276
279
  fields: fieldsSchema().required(),
277
- examples: Joi.array(),
280
+ examples: Joi.array().items(Joi.object({
281
+ data: Joi.alternatives(
282
+ Joi.array(),
283
+ Joi.object(),
284
+ ).required(),
285
+ flags: Joi.object()
286
+ .pattern(Joi.string(), Joi.valid(true))
287
+ .required(),
288
+ })),
278
289
  sources: Joi.array().items(
279
290
  Joi.object({
280
291
  role: Joi.valid(`subscriber`, `consumer`).required(),
@@ -8,19 +8,21 @@ export type Condition = {
8
8
  export type CommonField = {
9
9
  key: string,
10
10
  altered_by?: Condition[],
11
- disabled?: boolean,
12
- required?: boolean,
13
11
  as_password?: boolean,
12
+ disabled?: boolean,
14
13
  show?: boolean,
15
14
  t?: string,
16
- } & ({
17
- as_array?: false,
18
- } | {
19
- as_array: true,
20
- array_min?: number,
21
- array_max?: number,
22
- array_length?: number,
23
- })
15
+ } & (
16
+ | { required: true }
17
+ | { required?: false, additional?: boolean }
18
+ ) & ({
19
+ as_array?: false,
20
+ } | {
21
+ as_array: true,
22
+ array_min?: number,
23
+ array_max?: number,
24
+ array_length?: number,
25
+ })
24
26
  // experimental properties for custom front features
25
27
  & Record<`experimental_${string}`, any>
26
28
  ;
@@ -29,10 +29,15 @@ const commonFieldSchema = () =>
29
29
  Joi.object({
30
30
  key: Joi.string().required(),
31
31
  altered_by: Joi.array().items(conditionSchema()),
32
- disabled: Joi.bool(),
33
- required: Joi.bool(),
34
32
  as_password: Joi.bool(),
33
+ required: Joi.bool(),
34
+ disabled: Joi.bool(),
35
35
  show: Joi.bool(),
36
+ additional: Joi.when(`required`, {
37
+ is: false,
38
+ then: Joi.bool(),
39
+ otherwise: Joi.forbidden(),
40
+ }),
36
41
  t: Joi.string(),
37
42
  as_array: Joi.bool(),
38
43
  array_min: Joi.when(`as_array`, {