@abyss-project/console 1.0.2 → 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.
@@ -0,0 +1,2 @@
1
+ import { IDeleteProjectAdminParams, IDeleteProjectAdminResponse } from '../types';
2
+ export declare const deleteProject: (params: IDeleteProjectAdminParams) => Promise<IDeleteProjectAdminResponse>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteProject = void 0;
4
+ const __1 = require("..");
5
+ const deleteProject = async (params) => {
6
+ const response = await __1.AbyssConsoleCore.axios.delete(`/project/admin/${params.projectId}`);
7
+ return response.data;
8
+ };
9
+ exports.deleteProject = deleteProject;
@@ -0,0 +1,3 @@
1
+ import { IGetProjectParams, IActivateProjectParams, IGetProjectResponse, IActivateProjectResponse } from '../types';
2
+ export declare const getProject: (params: IGetProjectParams) => Promise<IGetProjectResponse>;
3
+ export declare const activateProject: (params: IActivateProjectParams) => Promise<IActivateProjectResponse>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activateProject = exports.getProject = void 0;
4
+ const __1 = require("..");
5
+ const getProject = async (params) => {
6
+ const response = await __1.AbyssConsoleCore.axios.get(`/project/${params.projectId}`);
7
+ return response.data;
8
+ };
9
+ exports.getProject = getProject;
10
+ const activateProject = async (params) => {
11
+ const response = await __1.AbyssConsoleCore.axios.post(`/project/${params.projectId}/activate`);
12
+ return response.data;
13
+ };
14
+ exports.activateProject = activateProject;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ import * as monitorApi from './api/monitor.api';
5
5
  import * as workflowApi from './api/workflow.api';
6
6
  import * as workflowAdminApi from './api/workflow.admin.api';
7
7
  import * as ipAddressApi from './api/ip-address.api';
8
+ import * as projectApi from './api/project.api';
9
+ import * as projectAdminApi from './api/project.admin.api';
8
10
  export * from './types';
9
11
  export * from './utils';
10
12
  export declare const API_KEY_APPLICATION_HEADER = "abyss-console-api-key-application";
@@ -33,6 +35,13 @@ type WorkflowAdminSDK = {
33
35
  };
34
36
  trigger: typeof workflowAdminApi.triggerWorkflow;
35
37
  };
38
+ type ProjectAdminSDK = {
39
+ delete: typeof projectAdminApi.deleteProject;
40
+ };
41
+ type ProjectSDK = {
42
+ get: typeof projectApi.getProject;
43
+ activate: typeof projectApi.activateProject;
44
+ };
36
45
  type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
37
46
  domainVerification: {
38
47
  create: typeof domainVerificationApi.createDomainVerification;
@@ -43,7 +52,7 @@ type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
43
52
  delete: typeof domainVerificationApi.deleteDomainVerification;
44
53
  } & (TAdmin extends true ? {
45
54
  admin: DomainVerificationAdminSDK;
46
- } : {});
55
+ } : object);
47
56
  monitor: {
48
57
  up: typeof monitorApi.upMonitor;
49
58
  };
@@ -54,6 +63,9 @@ type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
54
63
  update: typeof ipAddressApi.updateIpAddress;
55
64
  delete: typeof ipAddressApi.deleteIpAddress;
56
65
  };
66
+ project: ProjectSDK & (TAdmin extends true ? {
67
+ admin: ProjectAdminSDK;
68
+ } : object);
57
69
  workflow: {
58
70
  create: typeof workflowApi.createWorkflow;
59
71
  paginate: typeof workflowApi.paginateWorkflow;
@@ -82,7 +94,15 @@ type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
82
94
  };
83
95
  } & (TAdmin extends true ? {
84
96
  admin: WorkflowAdminSDK;
85
- } : {});
97
+ } : object);
98
+ };
99
+ type InternalConfig = {
100
+ token: string;
101
+ applicationApiKey: string;
102
+ applicationId: string;
103
+ adminToken: string;
104
+ baseURL: string;
105
+ admin: boolean;
86
106
  };
87
107
  export declare class AbyssConsoleCore {
88
108
  private static config;
@@ -91,8 +111,6 @@ export declare class AbyssConsoleCore {
91
111
  static get sdk(): AbyssConsoleCoreSDK<false> | AbyssConsoleCoreSDK<true>;
92
112
  private static buildSDK;
93
113
  static setConfig<TAdmin extends boolean = false>(config: CoreConfig<TAdmin>): void;
94
- static getConfig(): CoreConfig & {
95
- admin: boolean;
96
- };
114
+ static getConfig(): InternalConfig;
97
115
  static enableAxiosRetry(axiosRetryConfig?: IAxiosRetryConfig): void;
98
116
  }
package/dist/index.js CHANGED
@@ -28,7 +28,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
- var _a;
32
31
  Object.defineProperty(exports, "__esModule", { value: true });
33
32
  exports.AbyssConsoleCore = exports.WEBHOOK_SIGNATURE_ALGORITHM = exports.HEADER_WEBHOOK_SIGNATURE_NAME = exports.ADMIN_TOKEN_HEADER = exports.API_KEY_APPLICATION_HEADER = void 0;
34
33
  const axios_1 = __importDefault(require("axios"));
@@ -39,6 +38,8 @@ const monitorApi = __importStar(require("./api/monitor.api"));
39
38
  const workflowApi = __importStar(require("./api/workflow.api"));
40
39
  const workflowAdminApi = __importStar(require("./api/workflow.admin.api"));
41
40
  const ipAddressApi = __importStar(require("./api/ip-address.api"));
41
+ const projectApi = __importStar(require("./api/project.api"));
42
+ const projectAdminApi = __importStar(require("./api/project.admin.api"));
42
43
  __exportStar(require("./types"), exports);
43
44
  __exportStar(require("./utils"), exports);
44
45
  const MONITOR_DEFAULT_BASE_URL = 'https://console-api.abyss-project.fr/api/';
@@ -54,10 +55,10 @@ const RETRY_CODES = [
54
55
  ];
55
56
  class AbyssConsoleCore {
56
57
  static get sdk() {
57
- if (!_a._sdk) {
58
- _a._sdk = _a.buildSDK();
58
+ if (!AbyssConsoleCore._sdk) {
59
+ AbyssConsoleCore._sdk = AbyssConsoleCore.buildSDK();
59
60
  }
60
- return _a._sdk;
61
+ return AbyssConsoleCore._sdk;
61
62
  }
62
63
  static buildSDK() {
63
64
  const domainVerificationSDK = {
@@ -67,12 +68,14 @@ class AbyssConsoleCore {
67
68
  verify: domainVerificationApi.verifyDomainVerification,
68
69
  regenerate: domainVerificationApi.regenerateDomainVerification,
69
70
  delete: domainVerificationApi.deleteDomainVerification,
71
+ ...(AbyssConsoleCore.config.admin
72
+ ? {
73
+ admin: {
74
+ runCron: domainVerificationAdminApi.runCron,
75
+ },
76
+ }
77
+ : {}),
70
78
  };
71
- if (_a.config.admin) {
72
- domainVerificationSDK.admin = {
73
- runCron: domainVerificationAdminApi.runCron,
74
- };
75
- }
76
79
  const workflowSDK = {
77
80
  create: workflowApi.createWorkflow,
78
81
  paginate: workflowApi.paginateWorkflow,
@@ -99,20 +102,33 @@ class AbyssConsoleCore {
99
102
  update: workflowApi.updateWorkflowTrigger,
100
103
  delete: workflowApi.deleteWorkflowTrigger,
101
104
  },
105
+ ...(AbyssConsoleCore.config.admin
106
+ ? {
107
+ admin: {
108
+ paginate: workflowAdminApi.paginateWorkflow,
109
+ get: workflowAdminApi.getWorkflow,
110
+ updateStatus: workflowAdminApi.updateWorkflowStatus,
111
+ delete: workflowAdminApi.deleteWorkflow,
112
+ execution: {
113
+ paginate: workflowAdminApi.paginateWorkflowExecution,
114
+ cancel: workflowAdminApi.cancelWorkflowExecution,
115
+ },
116
+ trigger: workflowAdminApi.triggerWorkflow,
117
+ },
118
+ }
119
+ : {}),
120
+ };
121
+ const projectSDK = {
122
+ get: projectApi.getProject,
123
+ activate: projectApi.activateProject,
124
+ ...(AbyssConsoleCore.config.admin
125
+ ? {
126
+ admin: {
127
+ delete: projectAdminApi.deleteProject,
128
+ },
129
+ }
130
+ : {}),
102
131
  };
103
- if (_a.config.admin) {
104
- workflowSDK.admin = {
105
- paginate: workflowAdminApi.paginateWorkflow,
106
- get: workflowAdminApi.getWorkflow,
107
- updateStatus: workflowAdminApi.updateWorkflowStatus,
108
- delete: workflowAdminApi.deleteWorkflow,
109
- execution: {
110
- paginate: workflowAdminApi.paginateWorkflowExecution,
111
- cancel: workflowAdminApi.cancelWorkflowExecution,
112
- },
113
- trigger: workflowAdminApi.triggerWorkflow,
114
- };
115
- }
116
132
  const baseSDK = {
117
133
  domainVerification: domainVerificationSDK,
118
134
  monitor: {
@@ -125,48 +141,53 @@ class AbyssConsoleCore {
125
141
  update: ipAddressApi.updateIpAddress,
126
142
  delete: ipAddressApi.deleteIpAddress,
127
143
  },
144
+ project: projectSDK,
128
145
  workflow: workflowSDK,
129
146
  };
130
147
  return baseSDK;
131
148
  }
132
149
  static setConfig(config) {
133
- _a.config = {
134
- ..._a.config,
135
- ...config,
136
- admin: config.admin || false,
150
+ var _a, _b, _c, _d, _e, _f;
151
+ AbyssConsoleCore.config = {
152
+ ...AbyssConsoleCore.config,
153
+ token: (_a = config.token) !== null && _a !== void 0 ? _a : AbyssConsoleCore.config.token,
154
+ applicationApiKey: (_b = config.applicationApiKey) !== null && _b !== void 0 ? _b : AbyssConsoleCore.config.applicationApiKey,
155
+ applicationId: (_c = config.applicationId) !== null && _c !== void 0 ? _c : AbyssConsoleCore.config.applicationId,
156
+ adminToken: (_d = config.adminToken) !== null && _d !== void 0 ? _d : AbyssConsoleCore.config.adminToken,
157
+ baseURL: (_e = config.baseURL) !== null && _e !== void 0 ? _e : AbyssConsoleCore.config.baseURL,
158
+ admin: (_f = config.admin) !== null && _f !== void 0 ? _f : false,
137
159
  };
138
- _a._sdk = null;
160
+ AbyssConsoleCore._sdk = null;
139
161
  if (config.baseURL) {
140
- _a.axios.defaults.baseURL = config.baseURL;
162
+ AbyssConsoleCore.axios.defaults.baseURL = config.baseURL;
141
163
  }
142
164
  if (config.token) {
143
- _a.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
165
+ AbyssConsoleCore.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
144
166
  }
145
167
  if (config.adminToken) {
146
- _a.axios.defaults.headers.common[exports.ADMIN_TOKEN_HEADER] = `${config.adminToken}`;
168
+ AbyssConsoleCore.axios.defaults.headers.common[exports.ADMIN_TOKEN_HEADER] = `${config.adminToken}`;
147
169
  }
148
170
  if (config.applicationApiKey) {
149
- _a.axios.defaults.headers.common[exports.API_KEY_APPLICATION_HEADER] = `${config.applicationApiKey}`;
171
+ AbyssConsoleCore.axios.defaults.headers.common[exports.API_KEY_APPLICATION_HEADER] = `${config.applicationApiKey}`;
150
172
  }
151
173
  }
152
174
  static getConfig() {
153
- return _a.config;
175
+ return AbyssConsoleCore.config;
154
176
  }
155
177
  static enableAxiosRetry(axiosRetryConfig) {
156
- (0, axios_retry_1.default)(_a.axios, {
178
+ (0, axios_retry_1.default)(AbyssConsoleCore.axios, {
157
179
  retries: NUMBER_RETRY_API,
158
180
  retryDelay: (retryCount) => retryCount * BASE_DELAY_BETWEEN_RETRY,
159
181
  retryCondition: (error) => {
160
- var _b;
182
+ var _a;
161
183
  return (0, axios_retry_1.isNetworkOrIdempotentRequestError)(error) ||
162
- RETRY_CODES.includes(((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 502);
184
+ RETRY_CODES.includes(((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) || 502);
163
185
  },
164
186
  ...axiosRetryConfig,
165
187
  });
166
188
  }
167
189
  }
168
190
  exports.AbyssConsoleCore = AbyssConsoleCore;
169
- _a = AbyssConsoleCore;
170
191
  AbyssConsoleCore.config = {
171
192
  token: '',
172
193
  applicationApiKey: '',
@@ -176,7 +197,7 @@ AbyssConsoleCore.config = {
176
197
  admin: false,
177
198
  };
178
199
  AbyssConsoleCore.axios = axios_1.default.create({
179
- baseURL: _a.config.baseURL,
200
+ baseURL: MONITOR_DEFAULT_BASE_URL,
180
201
  withCredentials: true,
181
202
  });
182
203
  AbyssConsoleCore._sdk = null;
@@ -26,5 +26,19 @@ export declare enum Code {
26
26
  ipAddressInvalidIPv4CIDRFormat = "ip_address_invalid_ipv4_cidr_format",
27
27
  ipAddressInvalidIPv6CIDRFormat = "ip_address_invalid_ipv6_cidr_format",
28
28
  ipAddressInvalidDomainFormat = "ip_address_invalid_domain_format",
29
- ipAddressInvalidType = "ip_address_invalid_type"
29
+ ipAddressInvalidType = "ip_address_invalid_type",
30
+ domainVerificationInvalidDomain = "domain_verification_invalid_domain",
31
+ domainVerificationDnsTimeout = "domain_verification_dns_timeout",
32
+ domainVerificationDnsNotFound = "domain_verification_dns_not_found",
33
+ domainVerificationDnsNoData = "domain_verification_dns_no_data",
34
+ domainVerificationDnsError = "domain_verification_dns_error",
35
+ domainVerificationTokenNotFound = "domain_verification_token_not_found",
36
+ domainVerificationFileNotFound = "domain_verification_file_not_found",
37
+ domainVerificationAccessForbidden = "domain_verification_access_forbidden",
38
+ domainVerificationTimeout = "domain_verification_timeout",
39
+ domainVerificationDomainNotFound = "domain_verification_domain_not_found",
40
+ domainVerificationTokenMismatch = "domain_verification_token_mismatch",
41
+ domainVerificationSsrfProtection = "domain_verification_ssrf_protection",
42
+ domainVerificationHttpError = "domain_verification_http_error",
43
+ domainVerificationUnknownError = "domain_verification_unknown_error"
30
44
  }
@@ -32,4 +32,18 @@ var Code;
32
32
  Code["ipAddressInvalidIPv6CIDRFormat"] = "ip_address_invalid_ipv6_cidr_format";
33
33
  Code["ipAddressInvalidDomainFormat"] = "ip_address_invalid_domain_format";
34
34
  Code["ipAddressInvalidType"] = "ip_address_invalid_type";
35
+ Code["domainVerificationInvalidDomain"] = "domain_verification_invalid_domain";
36
+ Code["domainVerificationDnsTimeout"] = "domain_verification_dns_timeout";
37
+ Code["domainVerificationDnsNotFound"] = "domain_verification_dns_not_found";
38
+ Code["domainVerificationDnsNoData"] = "domain_verification_dns_no_data";
39
+ Code["domainVerificationDnsError"] = "domain_verification_dns_error";
40
+ Code["domainVerificationTokenNotFound"] = "domain_verification_token_not_found";
41
+ Code["domainVerificationFileNotFound"] = "domain_verification_file_not_found";
42
+ Code["domainVerificationAccessForbidden"] = "domain_verification_access_forbidden";
43
+ Code["domainVerificationTimeout"] = "domain_verification_timeout";
44
+ Code["domainVerificationDomainNotFound"] = "domain_verification_domain_not_found";
45
+ Code["domainVerificationTokenMismatch"] = "domain_verification_token_mismatch";
46
+ Code["domainVerificationSsrfProtection"] = "domain_verification_ssrf_protection";
47
+ Code["domainVerificationHttpError"] = "domain_verification_http_error";
48
+ Code["domainVerificationUnknownError"] = "domain_verification_unknown_error";
35
49
  })(Code || (exports.Code = Code = {}));
@@ -7,9 +7,13 @@ export * from './requests/domain-verification.admin.request';
7
7
  export * from './requests/ip-address.request';
8
8
  export * from './requests/workflow.request';
9
9
  export * from './requests/workflow.admin.request';
10
+ export * from './requests/project.request';
11
+ export * from './requests/project.admin.request';
10
12
  export * from './responses/monitor.response';
11
13
  export * from './responses/domain-verification.response';
12
14
  export * from './responses/domain-verification.admin.response';
13
15
  export * from './responses/ip-address.response';
14
16
  export * from './responses/workflow.response';
15
17
  export * from './responses/workflow.admin.response';
18
+ export * from './responses/project.response';
19
+ export * from './responses/project.admin.response';
@@ -23,9 +23,13 @@ __exportStar(require("./requests/domain-verification.admin.request"), exports);
23
23
  __exportStar(require("./requests/ip-address.request"), exports);
24
24
  __exportStar(require("./requests/workflow.request"), exports);
25
25
  __exportStar(require("./requests/workflow.admin.request"), exports);
26
+ __exportStar(require("./requests/project.request"), exports);
27
+ __exportStar(require("./requests/project.admin.request"), exports);
26
28
  __exportStar(require("./responses/monitor.response"), exports);
27
29
  __exportStar(require("./responses/domain-verification.response"), exports);
28
30
  __exportStar(require("./responses/domain-verification.admin.response"), exports);
29
31
  __exportStar(require("./responses/ip-address.response"), exports);
30
32
  __exportStar(require("./responses/workflow.response"), exports);
31
33
  __exportStar(require("./responses/workflow.admin.response"), exports);
34
+ __exportStar(require("./responses/project.response"), exports);
35
+ __exportStar(require("./responses/project.admin.response"), exports);
@@ -0,0 +1,3 @@
1
+ export interface IDeleteProjectAdminParams {
2
+ projectId: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export interface IGetProjectParams {
2
+ projectId: string;
3
+ }
4
+ export interface IActivateProjectParams {
5
+ projectId: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { IResponse } from '../type-message/response';
2
+ export interface IDeleteProjectAdminData {
3
+ }
4
+ export type IDeleteProjectAdminResponse = IResponse<IDeleteProjectAdminData>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { IProject } from '../../models/project.model';
2
+ import { IResponse } from '../type-message/response';
3
+ export interface IGetProjectData {
4
+ project: IProject;
5
+ }
6
+ export type IGetProjectResponse = IResponse<IGetProjectData>;
7
+ export interface IActivateProjectData {
8
+ project: IProject;
9
+ }
10
+ export type IActivateProjectResponse = IResponse<IActivateProjectData>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import { IProject } from './project.model';
2
+ import { Code } from '../../enum/api-error.enum';
2
3
  export declare enum VerificationMethod {
3
4
  DNS_TXT = "DNS_TXT",
4
5
  HTTP_FILE = "HTTP_FILE"
@@ -38,5 +39,5 @@ export interface IDomainVerificationInstructions {
38
39
  export interface IDomainVerificationResult {
39
40
  success: boolean;
40
41
  message: string;
41
- error?: string;
42
+ code?: Code;
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/console",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Core package to interact with AbyssConsole",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",