@beseif-solutions/prow-core 0.0.30 → 0.0.32

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,7 +1,8 @@
1
1
  import { Provider } from "../entities/provider";
2
2
  export declare class Protocol {
3
3
  private readonly provider;
4
- constructor(provider: Provider);
4
+ private readonly path;
5
+ constructor(provider: Provider, path: string);
5
6
  evaluate: (req: Protocol.Command) => Promise<any>;
6
7
  }
7
8
  export declare namespace Protocol {
@@ -36,7 +37,6 @@ export declare namespace Protocol {
36
37
  };
37
38
  type LocaleList = {
38
39
  command: `list:locales`;
39
- locale: string;
40
40
  };
41
41
  type Command = Invoke | CredentialList | ActionList | TriggerList | SourceList | LocaleList;
42
42
  }
@@ -39,11 +39,10 @@ const sourceListSchema = joi_1.default.object({
39
39
  }).required();
40
40
  const localeListSchema = joi_1.default.object({
41
41
  command: joi_1.default.string().valid(`list:locales`).required(),
42
- locale: joi_1.default.string().required(),
43
42
  }).required();
44
43
  const commandSchema = joi_1.default.alternatives(invokeSchema, credentialListSchema, actionListSchema, triggerListSchema, sourceListSchema, localeListSchema);
45
44
  class Protocol {
46
- constructor(provider) {
45
+ constructor(provider, path) {
47
46
  this.evaluate = async (req) => {
48
47
  try {
49
48
  const validation = commandSchema.validate(req);
@@ -65,7 +64,7 @@ class Protocol {
65
64
  response = Object.values(this.provider.sources || {});
66
65
  break;
67
66
  case `list:locales`:
68
- const i18nInstance = (0, locales_1.i18n)({ directory: `node_modules/prow-hubspot-repository/locales` });
67
+ const i18nInstance = (0, locales_1.i18n)({ directory: `${this.path}/locales` });
69
68
  response = i18nInstance.i18n.getLocales().map((l) => {
70
69
  i18nInstance.i18n.setLocale(l);
71
70
  return {
@@ -106,6 +105,7 @@ class Protocol {
106
105
  throw new Error(`Invalid provider for protocol`);
107
106
  }
108
107
  this.provider = provider;
108
+ this.path = path;
109
109
  }
110
110
  }
111
111
  exports.Protocol = Protocol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beseif-solutions/prow-core",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "Prow core functionalities and classes",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -39,7 +39,6 @@ const sourceListSchema = Joi.object({
39
39
 
40
40
  const localeListSchema = Joi.object({
41
41
  command: Joi.string().valid(`list:locales`).required(),
42
- locale: Joi.string().required(),
43
42
  }).required();
44
43
 
45
44
  const commandSchema = Joi.alternatives(
@@ -54,11 +53,13 @@ const commandSchema = Joi.alternatives(
54
53
  export class Protocol {
55
54
 
56
55
  private readonly provider: Provider;
56
+ private readonly path: string;
57
57
 
58
- constructor(provider: Provider) {
58
+ constructor(provider: Provider, path: string) {
59
59
  const providerValidation = providerSchema().validate(provider);
60
60
  if (providerValidation.error) { throw new Error(`Invalid provider for protocol`); }
61
61
  this.provider = provider;
62
+ this.path = path;
62
63
  }
63
64
 
64
65
  public evaluate = async (req: Protocol.Command): Promise<any> => {
@@ -81,7 +82,7 @@ export class Protocol {
81
82
  response = Object.values(this.provider.sources || {});
82
83
  break;
83
84
  case `list:locales`:
84
- const i18nInstance = i18n({ directory: `node_modules/prow-hubspot-repository/locales` });
85
+ const i18nInstance = i18n({ directory: `${this.path}/locales` });
85
86
  response = i18nInstance.i18n.getLocales().map((l) => {
86
87
  i18nInstance.i18n.setLocale(l);
87
88
  return {
@@ -157,7 +158,6 @@ export namespace Protocol {
157
158
 
158
159
  export type LocaleList = {
159
160
  command: `list:locales`,
160
- locale: string,
161
161
  };
162
162
 
163
163
  export type Command = Invoke | CredentialList | ActionList | TriggerList | SourceList | LocaleList;