@beseif-solutions/prow-core 1.0.1 → 1.0.3

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.
@@ -1,6 +1,6 @@
1
1
  import Joi from "joi";
2
- import { Field } from "../minified-utils/fields";
3
2
  import { Common, CoreConfig, CoreFunction } from "./commons";
3
+ import { Field } from "../minified-utils/fields";
4
4
  type CredentialsConfig = Pick<CoreConfig, `credentials`>;
5
5
  type CommonCredentials<Config extends CredentialsConfig = {}> = Common<Config> & {
6
6
  model: `credentials`;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.credentialsSchema = exports.staticCredentialsSchema = exports.sessionCredentialsSchema = exports.oauthCredentialsSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
- const fields_1 = require("../minified-utils/fields");
8
+ const validation_1 = require("../minified-utils/validation");
9
9
  const commons_1 = require("./commons");
10
10
  const commonCredentialsSchema = () => joi_1.default.object({
11
11
  model: joi_1.default.valid(`credentials`).required(),
@@ -38,7 +38,7 @@ const sessionCredentialsSchema = () => joi_1.default.object({
38
38
  exports.sessionCredentialsSchema = sessionCredentialsSchema;
39
39
  const staticCredentialsSchema = () => joi_1.default.object({
40
40
  type: joi_1.default.valid(`static`).required(),
41
- fields: (0, fields_1.fieldsSchema)()
41
+ fields: (0, validation_1.fieldsSchema)()
42
42
  .required()
43
43
  .min(1),
44
44
  })
@@ -1,7 +1,7 @@
1
1
  import Joi from "joi";
2
- import { Field } from "../minified-utils/fields";
3
2
  import { Common, CoreConfig, CoreFunction } from "./commons";
4
3
  import { ObjectOrArray } from "../minified-utils/types";
4
+ import { Field } from "../minified-utils/fields";
5
5
  type CommonConnectableEvent<Keys extends string = string> = {
6
6
  key: Keys;
7
7
  };
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.actionOutputSchema = exports.triggerOutputSchema = exports.eventSchema = exports.actionSchema = exports.asyncActionSchema = exports.syncActionSchema = exports.triggerSchema = exports.immediateTriggerSchema = exports.scheduledTriggerSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
- const fields_1 = require("../minified-utils/fields");
8
+ const validation_1 = require("../minified-utils/validation");
9
9
  const commons_1 = require("./commons");
10
10
  const commonConnectableEventSchema = () => joi_1.default.object({
11
11
  key: joi_1.default.string().required(),
@@ -32,7 +32,7 @@ const commonEventsSchema = () => joi_1.default.object({
32
32
  }).required(),
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
- fields: (0, fields_1.fieldsSchema)().required(),
35
+ fields: (0, validation_1.fieldsSchema)().required(),
36
36
  examples: joi_1.default.array(),
37
37
  sources: joi_1.default.array().items(joi_1.default.object({
38
38
  role: joi_1.default.valid(`subscriber`, `consumer`).required(),
@@ -1,6 +1,6 @@
1
1
  import Joi from "joi";
2
- import { Field } from "../minified-utils/fields";
3
2
  import { Common } from "./commons";
3
+ import { Field } from "../minified-utils/fields";
4
4
  export type SourceConfig = {
5
5
  id: string;
6
6
  fields: Record<string, any>;
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.sourceSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
- const fields_1 = require("../minified-utils/fields");
8
+ const validation_1 = require("../minified-utils/validation");
9
9
  const commons_1 = require("./commons");
10
10
  const sourceSchema = () => joi_1.default.object({
11
11
  model: joi_1.default.valid(`source`).required(),
12
12
  sandbox: joi_1.default.boolean().required(),
13
- fields: (0, fields_1.fieldsSchema)().required().min(1),
13
+ fields: (0, validation_1.fieldsSchema)().required().min(1),
14
14
  }).concat((0, commons_1.commonSchema)());
15
15
  exports.sourceSchema = sourceSchema;
package/dist/index.d.ts CHANGED
@@ -5,7 +5,8 @@ export { Action, actionOutputSchema, actionSchema, AsyncAction, Event, eventSche
5
5
  export { Provider, providerSchema } from './entities/provider';
6
6
  export { Source } from './entities/source';
7
7
  export { getPath, hasExpression, isDynamic, isExpression, split } from './minified-utils/context';
8
- export { alter, Condition, extract, Field, fieldSchema, fieldsSchema, File, SelectFieldChoice, validate, ValidationResult } from './minified-utils/fields';
8
+ export { alter, extract, fieldSchema, fieldsSchema, validate, ValidationResult } from './minified-utils/validation';
9
+ export { Condition, Field, File, SelectFieldChoice } from './minified-utils/fields';
9
10
  export { DEFAULT_LOCALE, i18n, LocalizedField, LocalizedProperties, localizeFields, localizeGroup, localizeInputs, localizeOutputs, localizeProperties } from './minified-utils/locales';
10
11
  export { Properties } from './minified-utils/properties';
11
12
  export { Protocol } from './minified-utils/protocol';
package/dist/index.js CHANGED
@@ -27,12 +27,12 @@ Object.defineProperty(exports, "hasExpression", { enumerable: true, get: functio
27
27
  Object.defineProperty(exports, "isDynamic", { enumerable: true, get: function () { return context_1.isDynamic; } });
28
28
  Object.defineProperty(exports, "isExpression", { enumerable: true, get: function () { return context_1.isExpression; } });
29
29
  Object.defineProperty(exports, "split", { enumerable: true, get: function () { return context_1.split; } });
30
- var fields_1 = require("./minified-utils/fields");
31
- Object.defineProperty(exports, "alter", { enumerable: true, get: function () { return fields_1.alter; } });
32
- Object.defineProperty(exports, "extract", { enumerable: true, get: function () { return fields_1.extract; } });
33
- Object.defineProperty(exports, "fieldSchema", { enumerable: true, get: function () { return fields_1.fieldSchema; } });
34
- Object.defineProperty(exports, "fieldsSchema", { enumerable: true, get: function () { return fields_1.fieldsSchema; } });
35
- Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return fields_1.validate; } });
30
+ var validation_1 = require("./minified-utils/validation");
31
+ Object.defineProperty(exports, "alter", { enumerable: true, get: function () { return validation_1.alter; } });
32
+ Object.defineProperty(exports, "extract", { enumerable: true, get: function () { return validation_1.extract; } });
33
+ Object.defineProperty(exports, "fieldSchema", { enumerable: true, get: function () { return validation_1.fieldSchema; } });
34
+ Object.defineProperty(exports, "fieldsSchema", { enumerable: true, get: function () { return validation_1.fieldsSchema; } });
35
+ Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validation_1.validate; } });
36
36
  var locales_1 = require("./minified-utils/locales");
37
37
  Object.defineProperty(exports, "DEFAULT_LOCALE", { enumerable: true, get: function () { return locales_1.DEFAULT_LOCALE; } });
38
38
  Object.defineProperty(exports, "i18n", { enumerable: true, get: function () { return locales_1.i18n; } });
@@ -71,7 +71,7 @@ class Context {
71
71
  }
72
72
  }
73
73
  else {
74
- resolved = ``;
74
+ return undefined;
75
75
  }
76
76
  }
77
77
  else {
@@ -1,10 +1,9 @@
1
- import Joi from "joi";
2
1
  import { Where } from "./where";
3
2
  export type Condition = {
4
3
  condition: Where;
5
4
  overrides: Partial<Field>;
6
5
  };
7
- type Common = {
6
+ export type CommonField = {
8
7
  key: string;
9
8
  altered_by?: Condition[];
10
9
  disabled?: boolean;
@@ -20,17 +19,17 @@ type Common = {
20
19
  array_max?: number;
21
20
  array_length?: number;
22
21
  }) & Record<`experimental_${string}`, any>;
23
- export type Field<Extend = Record<never, never>> = Common & InputField<Extend>;
24
- type InputField<Extend = Record<never, never>> = (AnyInputField<Extend> | StringInputField<Extend> | NumberInputField<Extend> | BooleanInputField<Extend> | DateTimeInputField<Extend> | DateInputField<Extend> | TimeInputField<Extend> | DictInputField<Extend> | FileInputField<Extend>) & Extend;
25
- type Any = string | number | boolean | Any[] | {
22
+ export type Field<Extend = Record<never, never>> = CommonField & InputField<Extend>;
23
+ export type InputField<Extend = Record<never, never>> = (AnyInputField<Extend> | StringInputField<Extend> | NumberInputField<Extend> | BooleanInputField<Extend> | DateTimeInputField<Extend> | DateInputField<Extend> | TimeInputField<Extend> | DictInputField<Extend> | FileInputField<Extend>) & Extend;
24
+ export type Any = string | number | boolean | Any[] | {
26
25
  [key: string]: Any;
27
26
  };
28
- type AnyInputField<Extend = Record<never, never>> = {
27
+ export type AnyInputField<Extend = Record<never, never>> = {
29
28
  type: `any`;
30
29
  default?: Any | Any[];
31
30
  allow_nullish?: boolean;
32
31
  } & (SelectField<Any, Extend> | {});
33
- type StringInputField<Extend = Record<never, never>> = {
32
+ export type StringInputField<Extend = Record<never, never>> = {
34
33
  type: `string`;
35
34
  default?: string | string[];
36
35
  length?: number;
@@ -40,7 +39,7 @@ type StringInputField<Extend = Record<never, never>> = {
40
39
  pattern?: `email` | `uri`;
41
40
  allow_empty?: boolean;
42
41
  } & (SelectField<string, Extend> | CustomDisplayTextField | IDETextField | {});
43
- type NumberInputField<Extend = Record<never, never>> = {
42
+ export type NumberInputField<Extend = Record<never, never>> = {
44
43
  type: `number`;
45
44
  default?: number | number[];
46
45
  min?: number;
@@ -51,7 +50,7 @@ type NumberInputField<Extend = Record<never, never>> = {
51
50
  } | {
52
51
  float?: false;
53
52
  }) & (SelectField<number, Extend> | {});
54
- type BooleanInputField<Extend = Record<never, never>> = {
53
+ export type BooleanInputField<Extend = Record<never, never>> = {
55
54
  type: `boolean`;
56
55
  default?: boolean | boolean[];
57
56
  } & (SelectField<boolean, Extend> | {
@@ -59,25 +58,25 @@ type BooleanInputField<Extend = Record<never, never>> = {
59
58
  } | {
60
59
  format: `switch`;
61
60
  } | {});
62
- type DateTimeInputField<Extend = Record<never, never>> = {
61
+ export type DateTimeInputField<Extend = Record<never, never>> = {
63
62
  type: `datetime`;
64
63
  timezone?: string;
65
64
  default?: string | number | (string | number)[];
66
65
  min?: number | string;
67
66
  max?: number | string;
68
67
  } & (SelectField<string | number, Extend> | {});
69
- type DateInputField<Extend = Record<never, never>> = {
68
+ export type DateInputField<Extend = Record<never, never>> = {
70
69
  type: `date`;
71
70
  default?: string | string[];
72
71
  min?: string;
73
72
  max?: string;
74
73
  } & (SelectField<string, Extend> | {});
75
- type TimeInputField<Extend = Record<never, never>> = {
74
+ export type TimeInputField<Extend = Record<never, never>> = {
76
75
  type: `time`;
77
76
  timezone?: string;
78
77
  default?: string | string[];
79
78
  } & (SelectField<string, Extend> | {});
80
- type DictInputField<Extend = Record<never, never>> = {
79
+ export type DictInputField<Extend = Record<never, never>> = {
81
80
  type: `dict`;
82
81
  default?: Record<string, any> | Record<string, any>[];
83
82
  items?: Field<Extend>[];
@@ -88,12 +87,12 @@ export type File = {
88
87
  type: string;
89
88
  content: string;
90
89
  };
91
- type FileInputField<Extend = Record<never, never>> = {
90
+ export type FileInputField<Extend = Record<never, never>> = {
92
91
  type: `file`;
93
92
  default?: File | File[];
94
93
  accept?: string | string[];
95
94
  } & (SelectField<File, Extend> | {});
96
- type SelectField<Values = string | number | boolean | File, Extend = Record<never, never>> = {
95
+ export type SelectField<Values = string | number | boolean | File, Extend = Record<never, never>> = {
97
96
  format: `select`;
98
97
  choices: SelectFieldChoice<Values, Extend>[] | string;
99
98
  unknown?: boolean;
@@ -103,39 +102,10 @@ export type SelectFieldChoice<Values = string | number | boolean | File, Extend
103
102
  value: Values;
104
103
  group?: string;
105
104
  } & Extend;
106
- type CustomDisplayTextField = {
105
+ export type CustomDisplayTextField = {
107
106
  format: `textarea` | `rich-text` | `markdown`;
108
107
  };
109
- type IDETextField = {
108
+ export type IDETextField = {
110
109
  format: `code`;
111
110
  language?: string;
112
111
  };
113
- type ValidationExtended = {
114
- original: any;
115
- value: any;
116
- } & ({
117
- valid: true;
118
- } | {
119
- valid: false;
120
- errors: {
121
- path: string;
122
- message: string;
123
- type: string;
124
- }[];
125
- });
126
- export declare const fieldSchema: () => Joi.ObjectSchema<any>;
127
- export declare const fieldsSchema: () => Joi.ArraySchema<any[]>;
128
- export type ValidationResult<Extended = Record<string, never>> = {
129
- valid: boolean;
130
- fields: Field<Extended & ValidationExtended>[];
131
- };
132
- export declare const alter: (field: Field, relative: string, data: Record<string, any>) => Field<Record<never, never>>;
133
- export declare const validate: <I>(fields: Field<I>[], data: Record<string, any>, options?: {
134
- secure?: boolean;
135
- break?: boolean;
136
- context?: Record<string, any>;
137
- }) => Promise<ValidationResult<I>>;
138
- export declare const extract: (validation: Field<ValidationExtended>[], options?: {
139
- original?: boolean;
140
- }) => Promise<Record<string, any>>;
141
- export {};