@team-internet/apiconnector 10.0.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.
Files changed (58) hide show
  1. package/.devcontainer/Dockerfile +66 -0
  2. package/.devcontainer/devcontainer.json +30 -0
  3. package/.devcontainer/docker-compose.yml +11 -0
  4. package/.devcontainer/supporting_files/configuration/.czrc +1 -0
  5. package/.devcontainer/supporting_files/configuration/.p10k.zsh +1735 -0
  6. package/.devcontainer/supporting_files/configuration/.zshrc +23 -0
  7. package/.devcontainer/supporting_files/configuration/p10k-instant-prompt-vscode.zsh +323 -0
  8. package/.devcontainer/supporting_files/scripts/post-create.sh +11 -0
  9. package/.nycrc +6 -0
  10. package/CHANGELOG.md +582 -0
  11. package/CONTRIBUTING.md +132 -0
  12. package/LICENSE +21 -0
  13. package/README.md +56 -0
  14. package/dist/apiclient.d.ts +233 -0
  15. package/dist/apiclient.js +517 -0
  16. package/dist/column.d.ts +40 -0
  17. package/dist/column.js +52 -0
  18. package/dist/customlogger.d.ts +15 -0
  19. package/dist/customlogger.js +23 -0
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.js +16 -0
  22. package/dist/logger.d.ts +14 -0
  23. package/dist/logger.js +21 -0
  24. package/dist/record.d.ts +31 -0
  25. package/dist/record.js +42 -0
  26. package/dist/response.d.ts +264 -0
  27. package/dist/response.js +512 -0
  28. package/dist/responseparser.d.ts +1 -0
  29. package/dist/responseparser.js +36 -0
  30. package/dist/responsetemplatemanager.d.ts +65 -0
  31. package/dist/responsetemplatemanager.js +111 -0
  32. package/dist/responsetranslator.d.ts +32 -0
  33. package/dist/responsetranslator.js +144 -0
  34. package/dist/socketconfig.d.ts +62 -0
  35. package/dist/socketconfig.js +107 -0
  36. package/package.json +86 -0
  37. package/src/apiclient.ts +579 -0
  38. package/src/column.ts +57 -0
  39. package/src/customlogger.ts +29 -0
  40. package/src/index.ts +18 -0
  41. package/src/logger.ts +23 -0
  42. package/src/record.ts +46 -0
  43. package/src/response.ts +562 -0
  44. package/src/responseparser.ts +35 -0
  45. package/src/responsetemplatemanager.ts +136 -0
  46. package/src/responsetranslator.ts +191 -0
  47. package/src/socketconfig.ts +116 -0
  48. package/tests/apiclient.spec.ts +610 -0
  49. package/tests/app.js +47 -0
  50. package/tests/column.spec.ts +23 -0
  51. package/tests/index.spec.ts +22 -0
  52. package/tests/record.spec.ts +31 -0
  53. package/tests/response.spec.ts +341 -0
  54. package/tests/responseparser.spec.ts +13 -0
  55. package/tests/responsetemplatemanager.spec.ts +52 -0
  56. package/tests/socketconfig.spec.ts +14 -0
  57. package/tsconfig.json +7 -0
  58. package/typedoc.json +7 -0
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TEAM INTERNET
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # node-sdk
2
+
3
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
4
+ [![npm version](https://img.shields.io/npm/v/@cnr/apiconnector.svg?style=flat)](https://www.npmjs.com/package/@cnr/apiconnector)
5
+ [![node](https://img.shields.io/node/v/@cnr/apiconnector.svg)](https://www.npmjs.com/package/@cnr/apiconnector)
6
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
7
+ [![Build Status](https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/workflows/Release/badge.svg?branch=master)](https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/workflows/Release/badge.svg?branch=master)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/CONTRIBUTING.md)
10
+
11
+ This module is a connector library for the insanely fast CentralNic Reseller Backend API. For further informations visit our [homepage](https://www.centralnicreseller.com) and do not hesitate to [contact us](https://www.centralnicreseller.com/contact).
12
+
13
+ ## Deprecation Notice: Hexonet Node.js SDK
14
+
15
+ This SDK succeeds the deprecated Hexonet Node.js SDK. It is an enhanced version that builds upon the foundation laid by the Hexonet SDK, offering improved features and performance. Hexonet is migrating to CentralNic Reseller, ensuring continued support and development under the new branding.
16
+
17
+ ## Resources
18
+
19
+ - [Documentation](https://support.centralnicreseller.com/hc/en-gb/articles/5714403954333-Self-Development-Kit-for-NodeJS)
20
+ - [Release Notes](https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/releases)
21
+
22
+ ## Running the Demo Application
23
+
24
+ To run the demo application, follow these steps:
25
+
26
+ 1. **Set Your Credentials**: Ensure your credentials are available. You can either:
27
+
28
+ - Replace them directly in the application file.
29
+ - Set the environment variables `CNR_TEST_USER` and `CNR_TEST_PASSWORD` in your terminal.
30
+
31
+ 2. **Execute the Demo**: Once your credentials are set, run the following command in the terminal:
32
+
33
+ ```sh
34
+ npm run test-demo
35
+ ```
36
+
37
+ 3. **Update Demo Contents**: If you need to update the contents of the demo file, you can find it at:
38
+
39
+ ```plaintext
40
+ tests/app.js
41
+ ```
42
+
43
+ By following these steps, you can successfully run and update the demo application.
44
+
45
+ ## Authors
46
+
47
+ - **Kai Schwarz** - [KaiSchwarz-cnic](https://github.com/kaischwarz-cnic)
48
+ - **Asif Nawaz** - [AsifNawaz-cnic](https://github.com/asifnawaz-cnic)
49
+
50
+ ## FAQ / Notes
51
+
52
+ ESM/CJS Support: We followed the [ESM-NODE Guide](https://www.typescriptlang.org/docs/handbook/esm-node.html) of TypeScript.
53
+
54
+ ## License
55
+
56
+ MIT
@@ -0,0 +1,233 @@
1
+ import { Logger } from "./logger.js";
2
+ import { Response } from "./response.js";
3
+ export declare const CNR_CONNECTION_URL_PROXY = "http://127.0.0.1/api/call.cgi";
4
+ export declare const CNR_CONNECTION_URL_LIVE = "https://api.rrpproxy.net/api/call.cgi";
5
+ export declare const CNR_CONNECTION_URL_OTE = "https://api-ote.rrpproxy.net/api/call.cgi";
6
+ /**
7
+ * APIClient class
8
+ */
9
+ export declare class APIClient {
10
+ /**
11
+ * API connection timeout setting
12
+ */
13
+ static readonly socketTimeout: number;
14
+ /**
15
+ * User Agent string
16
+ */
17
+ private ua;
18
+ /**
19
+ * API connection url
20
+ */
21
+ private socketURL;
22
+ /**
23
+ * Object covering API connection data
24
+ */
25
+ private socketConfig;
26
+ /**
27
+ * activity flag for debug mode
28
+ */
29
+ private debugMode;
30
+ /**
31
+ * additional connection settings
32
+ */
33
+ private curlopts;
34
+ /**
35
+ * logger function for debug mode
36
+ */
37
+ private logger;
38
+ /**
39
+ * set sub user account
40
+ */
41
+ private subUser;
42
+ /**
43
+ * set sub user account role seperater
44
+ */
45
+ private readonly roleSeparator;
46
+ constructor();
47
+ /**
48
+ * set custom logger to use instead of default one
49
+ * @param customLogger
50
+ * @returns Current APIClient instance for method chaining
51
+ */
52
+ setCustomLogger(customLogger: Logger): APIClient;
53
+ /**
54
+ * set default logger to use
55
+ * @returns Current APIClient instance for method chaining
56
+ */
57
+ setDefaultLogger(): APIClient;
58
+ /**
59
+ * Enable Debug Output to STDOUT
60
+ * @returns Current APIClient instance for method chaining
61
+ */
62
+ enableDebugMode(): APIClient;
63
+ /**
64
+ * Disable Debug Output
65
+ * @returns Current APIClient instance for method chaining
66
+ */
67
+ disableDebugMode(): APIClient;
68
+ /**
69
+ * Get the API connection url that is currently set
70
+ * @returns API connection url currently in use
71
+ */
72
+ getURL(): string;
73
+ /**
74
+ * Possibility to customize default user agent to fit your needs
75
+ * @param str user agent label
76
+ * @param rv revision of user agent
77
+ * @param modules further modules to add to user agent string, format: ["<mod1>/<rev>", "<mod2>/<rev>", ... ]
78
+ * @returns Current APIClient instance for method chaining
79
+ */
80
+ setUserAgent(str: string, rv: string, modules?: any): APIClient;
81
+ /**
82
+ * Get the User Agent
83
+ * @returns User Agent string
84
+ */
85
+ getUserAgent(): string;
86
+ /**
87
+ * Set the proxy server to use for API communication
88
+ * @param proxy proxy server to use for communicatio
89
+ * @returns Current APIClient instance for method chaining
90
+ */
91
+ setProxy(proxy: string): APIClient;
92
+ /**
93
+ * Get the proxy server configuration
94
+ * @returns proxy server configuration value or null if not set
95
+ */
96
+ getProxy(): string | null;
97
+ /**
98
+ * Set the referer to use for API communication
99
+ * @param referer Referer
100
+ * @returns Current APIClient instance for method chaining
101
+ */
102
+ setReferer(referer: string): APIClient;
103
+ /**
104
+ * Get the referer configuration
105
+ * @returns referer configuration value or null if not set
106
+ */
107
+ getReferer(): string | null;
108
+ /**
109
+ * Get the current module version
110
+ * @returns module version
111
+ */
112
+ getVersion(): string;
113
+ /**
114
+ * Apply session data (session id and system entity) to given client request session
115
+ * @param session ClientRequest session instance
116
+ * @returns Current APIClient instance for method chaining
117
+ */
118
+ saveSession(session: any): APIClient;
119
+ /**
120
+ * Use existing configuration out of ClientRequest session
121
+ * to rebuild and reuse connection settings
122
+ * @param session ClientRequest session instance
123
+ * @returns Current APIClient instance for method chaining
124
+ */
125
+ reuseSession(session: any): APIClient;
126
+ /**
127
+ * Set another connection url to be used for API communication
128
+ * @param value API connection url to set
129
+ * @returns Current APIClient instance for method chaining
130
+ */
131
+ setURL(value: string): APIClient;
132
+ /**
133
+ * Set Persistent to request session id for API communication
134
+ * @param value API session id
135
+ * @returns Current APIClient instance for method chaining
136
+ */
137
+ setPersistent(): APIClient;
138
+ /**
139
+ * Set Credentials to be used for API communication
140
+ * @param uid account name
141
+ * @param pw account password
142
+ * @returns Current APIClient instance for method chaining
143
+ */
144
+ setCredentials(uid: string, pw?: string): APIClient;
145
+ /**
146
+ * Set Credentials to be used for API communication
147
+ * @param uid account name
148
+ * @param role role user id
149
+ * @param pw role user password
150
+ * @returns Current APIClient instance for method chaining
151
+ */
152
+ setRoleCredentials(uid: string, role: string, pw?: string): APIClient;
153
+ /**
154
+ * Perform API login to start session-based communication
155
+ * @param otp optional one time password
156
+ * @returns Promise resolving with API Response
157
+ */
158
+ login(): Promise<Response>;
159
+ /**
160
+ * Perform API logout to close API session in use
161
+ * @returns Promise resolving with API Response
162
+ */
163
+ logout(): Promise<Response>;
164
+ /**
165
+ * Perform API request using the given command
166
+ * @param cmd API command to request
167
+ * @returns Promise resolving with API Response
168
+ */
169
+ request(cmd: any, setUserView?: boolean): Promise<Response>;
170
+ /**
171
+ * Request the next page of list entries for the current list query
172
+ * Useful for tables
173
+ * @param rr API Response of current page
174
+ * @returns Promise resolving with API Response or null in case there are no further list entries
175
+ */
176
+ requestNextResponsePage(rr: Response): Promise<Response | null>;
177
+ /**
178
+ * Request all pages/entries for the given query command
179
+ * @param cmd API list command to use
180
+ * @returns Promise resolving with array of API Responses
181
+ */
182
+ requestAllResponsePages(cmd: any): Promise<Response[]>;
183
+ /**
184
+ * Set a data view to a given subuser
185
+ * @param uid subuser account name
186
+ * @returns Current APIClient instance for method chaining
187
+ */
188
+ setUserView(uid: string): APIClient;
189
+ /**
190
+ * Reset data view back from subuser to user
191
+ * @returns Current APIClient instance for method chaining
192
+ */
193
+ resetUserView(): APIClient;
194
+ /**
195
+ * Activate High Performance Connection Setup
196
+ * @see https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/README.md
197
+ * @returns Current APIClient instance for method chaining
198
+ */
199
+ useHighPerformanceConnectionSetup(): APIClient;
200
+ /**
201
+ * Activate Default Connection Setup (the default)
202
+ * @returns Current APIClient instance for method chaining
203
+ */
204
+ useDefaultConnectionSetup(): APIClient;
205
+ /**
206
+ * Set OT&E System for API communication
207
+ * @returns Current APIClient instance for method chaining
208
+ */
209
+ useOTESystem(): APIClient;
210
+ /**
211
+ * Set LIVE System for API communication (this is the default setting)
212
+ * @returns Current APIClient instance for method chaining
213
+ */
214
+ useLIVESystem(): APIClient;
215
+ /**
216
+ * Serialize given command for POST request including connection configuration data
217
+ * @param cmd API command to encode
218
+ * @returns encoded POST data string
219
+ */
220
+ getPOSTData(cmd: any, secured?: boolean): string;
221
+ /**
222
+ * Flatten nested arrays in command
223
+ * @param cmd api command
224
+ * @returns api command with flattended parameters
225
+ */
226
+ private flattenCommand;
227
+ /**
228
+ * Auto convert API command parameters to punycode, if necessary.
229
+ * @param cmd api command
230
+ * @returns Promise resolving with api command with IDN values replaced to punycode
231
+ */
232
+ private autoIDNConvert;
233
+ }