@abyss-project/console 1.0.2 → 1.0.4

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,35 +5,23 @@ 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';
12
+ export { deleteProject as deleteProjectAdmin } from './api/project.admin.api';
10
13
  export declare const API_KEY_APPLICATION_HEADER = "abyss-console-api-key-application";
11
14
  export declare const ADMIN_TOKEN_HEADER = "abyss-admin-token";
12
15
  export declare const HEADER_WEBHOOK_SIGNATURE_NAME = "abyss-console-webhook-signature";
13
16
  export declare const WEBHOOK_SIGNATURE_ALGORITHM = "sha256";
14
- type CoreConfig<TAdmin extends boolean = false> = {
17
+ type CoreConfig = {
15
18
  token?: string;
16
19
  applicationApiKey?: string;
17
20
  applicationId?: string;
18
21
  adminToken?: string;
19
22
  baseURL?: string;
20
- admin?: TAdmin;
21
23
  };
22
- type DomainVerificationAdminSDK = {
23
- runCron: typeof domainVerificationAdminApi.runCron;
24
- };
25
- type WorkflowAdminSDK = {
26
- paginate: typeof workflowAdminApi.paginateWorkflow;
27
- get: typeof workflowAdminApi.getWorkflow;
28
- updateStatus: typeof workflowAdminApi.updateWorkflowStatus;
29
- delete: typeof workflowAdminApi.deleteWorkflow;
30
- execution: {
31
- paginate: typeof workflowAdminApi.paginateWorkflowExecution;
32
- cancel: typeof workflowAdminApi.cancelWorkflowExecution;
33
- };
34
- trigger: typeof workflowAdminApi.triggerWorkflow;
35
- };
36
- type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
24
+ type AbyssConsoleCoreSDK = {
37
25
  domainVerification: {
38
26
  create: typeof domainVerificationApi.createDomainVerification;
39
27
  list: typeof domainVerificationApi.listDomainVerification;
@@ -41,9 +29,10 @@ type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
41
29
  verify: typeof domainVerificationApi.verifyDomainVerification;
42
30
  regenerate: typeof domainVerificationApi.regenerateDomainVerification;
43
31
  delete: typeof domainVerificationApi.deleteDomainVerification;
44
- } & (TAdmin extends true ? {
45
- admin: DomainVerificationAdminSDK;
46
- } : {});
32
+ admin: {
33
+ runCron: typeof domainVerificationAdminApi.runCron;
34
+ };
35
+ };
47
36
  monitor: {
48
37
  up: typeof monitorApi.upMonitor;
49
38
  };
@@ -54,6 +43,13 @@ type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
54
43
  update: typeof ipAddressApi.updateIpAddress;
55
44
  delete: typeof ipAddressApi.deleteIpAddress;
56
45
  };
46
+ project: {
47
+ get: typeof projectApi.getProject;
48
+ activate: typeof projectApi.activateProject;
49
+ admin: {
50
+ delete: typeof projectAdminApi.deleteProject;
51
+ };
52
+ };
57
53
  workflow: {
58
54
  create: typeof workflowApi.createWorkflow;
59
55
  paginate: typeof workflowApi.paginateWorkflow;
@@ -80,19 +76,34 @@ type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
80
76
  update: typeof workflowApi.updateWorkflowTrigger;
81
77
  delete: typeof workflowApi.deleteWorkflowTrigger;
82
78
  };
83
- } & (TAdmin extends true ? {
84
- admin: WorkflowAdminSDK;
85
- } : {});
79
+ admin: {
80
+ paginate: typeof workflowAdminApi.paginateWorkflow;
81
+ get: typeof workflowAdminApi.getWorkflow;
82
+ updateStatus: typeof workflowAdminApi.updateWorkflowStatus;
83
+ delete: typeof workflowAdminApi.deleteWorkflow;
84
+ execution: {
85
+ paginate: typeof workflowAdminApi.paginateWorkflowExecution;
86
+ cancel: typeof workflowAdminApi.cancelWorkflowExecution;
87
+ };
88
+ trigger: typeof workflowAdminApi.triggerWorkflow;
89
+ };
90
+ };
91
+ };
92
+ type InternalConfig = {
93
+ token: string;
94
+ applicationApiKey: string;
95
+ applicationId: string;
96
+ adminToken: string;
97
+ baseURL: string;
98
+ admin: boolean;
86
99
  };
87
100
  export declare class AbyssConsoleCore {
88
101
  private static config;
89
102
  static axios: import("axios").AxiosInstance;
90
103
  private static _sdk;
91
- static get sdk(): AbyssConsoleCoreSDK<false> | AbyssConsoleCoreSDK<true>;
104
+ static get sdk(): AbyssConsoleCoreSDK;
92
105
  private static buildSDK;
93
- static setConfig<TAdmin extends boolean = false>(config: CoreConfig<TAdmin>): void;
94
- static getConfig(): CoreConfig & {
95
- admin: boolean;
96
- };
106
+ static setConfig(config: CoreConfig): void;
107
+ static getConfig(): InternalConfig;
97
108
  static enableAxiosRetry(axiosRetryConfig?: IAxiosRetryConfig): void;
98
109
  }
package/dist/index.js CHANGED
@@ -28,9 +28,8 @@ 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
- exports.AbyssConsoleCore = exports.WEBHOOK_SIGNATURE_ALGORITHM = exports.HEADER_WEBHOOK_SIGNATURE_NAME = exports.ADMIN_TOKEN_HEADER = exports.API_KEY_APPLICATION_HEADER = void 0;
32
+ exports.AbyssConsoleCore = exports.WEBHOOK_SIGNATURE_ALGORITHM = exports.HEADER_WEBHOOK_SIGNATURE_NAME = exports.ADMIN_TOKEN_HEADER = exports.API_KEY_APPLICATION_HEADER = exports.deleteProjectAdmin = void 0;
34
33
  const axios_1 = __importDefault(require("axios"));
35
34
  const axios_retry_1 = __importStar(require("axios-retry"));
36
35
  const domainVerificationApi = __importStar(require("./api/domain-verification.api"));
@@ -39,8 +38,12 @@ 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);
45
+ var project_admin_api_1 = require("./api/project.admin.api");
46
+ Object.defineProperty(exports, "deleteProjectAdmin", { enumerable: true, get: function () { return project_admin_api_1.deleteProject; } });
44
47
  const MONITOR_DEFAULT_BASE_URL = 'https://console-api.abyss-project.fr/api/';
45
48
  exports.API_KEY_APPLICATION_HEADER = 'abyss-console-api-key-application';
46
49
  exports.ADMIN_TOKEN_HEADER = 'abyss-admin-token';
@@ -54,10 +57,10 @@ const RETRY_CODES = [
54
57
  ];
55
58
  class AbyssConsoleCore {
56
59
  static get sdk() {
57
- if (!_a._sdk) {
58
- _a._sdk = _a.buildSDK();
60
+ if (!AbyssConsoleCore._sdk) {
61
+ AbyssConsoleCore._sdk = AbyssConsoleCore.buildSDK();
59
62
  }
60
- return _a._sdk;
63
+ return AbyssConsoleCore._sdk;
61
64
  }
62
65
  static buildSDK() {
63
66
  const domainVerificationSDK = {
@@ -67,12 +70,10 @@ class AbyssConsoleCore {
67
70
  verify: domainVerificationApi.verifyDomainVerification,
68
71
  regenerate: domainVerificationApi.regenerateDomainVerification,
69
72
  delete: domainVerificationApi.deleteDomainVerification,
70
- };
71
- if (_a.config.admin) {
72
- domainVerificationSDK.admin = {
73
+ admin: {
73
74
  runCron: domainVerificationAdminApi.runCron,
74
- };
75
- }
75
+ },
76
+ };
76
77
  const workflowSDK = {
77
78
  create: workflowApi.createWorkflow,
78
79
  paginate: workflowApi.paginateWorkflow,
@@ -99,9 +100,7 @@ class AbyssConsoleCore {
99
100
  update: workflowApi.updateWorkflowTrigger,
100
101
  delete: workflowApi.deleteWorkflowTrigger,
101
102
  },
102
- };
103
- if (_a.config.admin) {
104
- workflowSDK.admin = {
103
+ admin: {
105
104
  paginate: workflowAdminApi.paginateWorkflow,
106
105
  get: workflowAdminApi.getWorkflow,
107
106
  updateStatus: workflowAdminApi.updateWorkflowStatus,
@@ -111,8 +110,15 @@ class AbyssConsoleCore {
111
110
  cancel: workflowAdminApi.cancelWorkflowExecution,
112
111
  },
113
112
  trigger: workflowAdminApi.triggerWorkflow,
114
- };
115
- }
113
+ },
114
+ };
115
+ const projectSDK = {
116
+ get: projectApi.getProject,
117
+ activate: projectApi.activateProject,
118
+ admin: {
119
+ delete: projectAdminApi.deleteProject,
120
+ },
121
+ };
116
122
  const baseSDK = {
117
123
  domainVerification: domainVerificationSDK,
118
124
  monitor: {
@@ -125,48 +131,53 @@ class AbyssConsoleCore {
125
131
  update: ipAddressApi.updateIpAddress,
126
132
  delete: ipAddressApi.deleteIpAddress,
127
133
  },
134
+ project: projectSDK,
128
135
  workflow: workflowSDK,
129
136
  };
130
137
  return baseSDK;
131
138
  }
132
139
  static setConfig(config) {
133
- _a.config = {
134
- ..._a.config,
135
- ...config,
136
- admin: config.admin || false,
140
+ var _a, _b, _c, _d, _e;
141
+ AbyssConsoleCore.config = {
142
+ ...AbyssConsoleCore.config,
143
+ token: (_a = config.token) !== null && _a !== void 0 ? _a : AbyssConsoleCore.config.token,
144
+ applicationApiKey: (_b = config.applicationApiKey) !== null && _b !== void 0 ? _b : AbyssConsoleCore.config.applicationApiKey,
145
+ applicationId: (_c = config.applicationId) !== null && _c !== void 0 ? _c : AbyssConsoleCore.config.applicationId,
146
+ adminToken: (_d = config.adminToken) !== null && _d !== void 0 ? _d : AbyssConsoleCore.config.adminToken,
147
+ baseURL: (_e = config.baseURL) !== null && _e !== void 0 ? _e : AbyssConsoleCore.config.baseURL,
148
+ admin: false,
137
149
  };
138
- _a._sdk = null;
150
+ AbyssConsoleCore._sdk = null;
139
151
  if (config.baseURL) {
140
- _a.axios.defaults.baseURL = config.baseURL;
152
+ AbyssConsoleCore.axios.defaults.baseURL = config.baseURL;
141
153
  }
142
154
  if (config.token) {
143
- _a.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
155
+ AbyssConsoleCore.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
144
156
  }
145
157
  if (config.adminToken) {
146
- _a.axios.defaults.headers.common[exports.ADMIN_TOKEN_HEADER] = `${config.adminToken}`;
158
+ AbyssConsoleCore.axios.defaults.headers.common[exports.ADMIN_TOKEN_HEADER] = `${config.adminToken}`;
147
159
  }
148
160
  if (config.applicationApiKey) {
149
- _a.axios.defaults.headers.common[exports.API_KEY_APPLICATION_HEADER] = `${config.applicationApiKey}`;
161
+ AbyssConsoleCore.axios.defaults.headers.common[exports.API_KEY_APPLICATION_HEADER] = `${config.applicationApiKey}`;
150
162
  }
151
163
  }
152
164
  static getConfig() {
153
- return _a.config;
165
+ return AbyssConsoleCore.config;
154
166
  }
155
167
  static enableAxiosRetry(axiosRetryConfig) {
156
- (0, axios_retry_1.default)(_a.axios, {
168
+ (0, axios_retry_1.default)(AbyssConsoleCore.axios, {
157
169
  retries: NUMBER_RETRY_API,
158
170
  retryDelay: (retryCount) => retryCount * BASE_DELAY_BETWEEN_RETRY,
159
171
  retryCondition: (error) => {
160
- var _b;
172
+ var _a;
161
173
  return (0, axios_retry_1.isNetworkOrIdempotentRequestError)(error) ||
162
- RETRY_CODES.includes(((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 502);
174
+ RETRY_CODES.includes(((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) || 502);
163
175
  },
164
176
  ...axiosRetryConfig,
165
177
  });
166
178
  }
167
179
  }
168
180
  exports.AbyssConsoleCore = AbyssConsoleCore;
169
- _a = AbyssConsoleCore;
170
181
  AbyssConsoleCore.config = {
171
182
  token: '',
172
183
  applicationApiKey: '',
@@ -176,7 +187,7 @@ AbyssConsoleCore.config = {
176
187
  admin: false,
177
188
  };
178
189
  AbyssConsoleCore.axios = axios_1.default.create({
179
- baseURL: _a.config.baseURL,
190
+ baseURL: MONITOR_DEFAULT_BASE_URL,
180
191
  withCredentials: true,
181
192
  });
182
193
  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.4",
4
4
  "description": "Core package to interact with AbyssConsole",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",