@serptech/api 1.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/LICENSE.md +21 -0
  2. package/Makefile +12 -0
  3. package/README.md +39 -0
  4. package/dist/SerpApi.node.js +65 -0
  5. package/dist/SerpApi.web.js +65 -0
  6. package/eslint.config.mjs +51 -0
  7. package/mychange.diff +50452 -0
  8. package/package.json +62 -0
  9. package/packages/serp-rest-api/LICENSE.md +21 -0
  10. package/packages/serp-rest-api/README.md +30 -0
  11. package/packages/serp-rest-api/dist/index.node.js +1752 -0
  12. package/packages/serp-rest-api/dist/index.web.js +1282 -0
  13. package/packages/serp-rest-api/package.json +59 -0
  14. package/packages/serp-rest-api/src/base/api.ts +15 -0
  15. package/packages/serp-rest-api/src/base/auth-api.ts +25 -0
  16. package/packages/serp-rest-api/src/base/types.ts +33 -0
  17. package/packages/serp-rest-api/src/constants/index.js +13 -0
  18. package/packages/serp-rest-api/src/http-client.ts +207 -0
  19. package/packages/serp-rest-api/src/index.ts +3 -0
  20. package/packages/serp-rest-api/src/serp-rest-api/api-facade/auth/index.ts +50 -0
  21. package/packages/serp-rest-api/src/serp-rest-api/api-facade/base.ts +58 -0
  22. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/entries/index.ts +87 -0
  23. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/index.ts +106 -0
  24. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/licenses/index.ts +28 -0
  25. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/notifications/index.ts +40 -0
  26. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/persons/index.ts +60 -0
  27. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/persons-groups/index.ts +54 -0
  28. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/sources/index.ts +46 -0
  29. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/spaces/index.ts +27 -0
  30. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/stream-tokens/index.ts +37 -0
  31. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/thresholds/index.ts +17 -0
  32. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/tokens/index.ts +32 -0
  33. package/packages/serp-rest-api/src/serp-rest-api/api-facade/v1/utilities/index.ts +82 -0
  34. package/packages/serp-rest-api/src/serp-rest-api/features/auth/v1/index.ts +58 -0
  35. package/packages/serp-rest-api/src/serp-rest-api/features/entries/v1/index.ts +70 -0
  36. package/packages/serp-rest-api/src/serp-rest-api/features/licenses/v1/index.ts +82 -0
  37. package/packages/serp-rest-api/src/serp-rest-api/features/notifications/v1/index.ts +100 -0
  38. package/packages/serp-rest-api/src/serp-rest-api/features/persons/v1/index.ts +110 -0
  39. package/packages/serp-rest-api/src/serp-rest-api/features/persons-groups/v1/index.ts +128 -0
  40. package/packages/serp-rest-api/src/serp-rest-api/features/sources/v1/index.ts +113 -0
  41. package/packages/serp-rest-api/src/serp-rest-api/features/spaces/v1/index.ts +65 -0
  42. package/packages/serp-rest-api/src/serp-rest-api/features/stream-tokens/v1/index.ts +76 -0
  43. package/packages/serp-rest-api/src/serp-rest-api/features/thresholds/v1/index.ts +32 -0
  44. package/packages/serp-rest-api/src/serp-rest-api/features/tokens/v1/index.ts +61 -0
  45. package/packages/serp-rest-api/src/serp-rest-api/features/utilities/v1/index.ts +114 -0
  46. package/packages/serp-rest-api/src/serp-rest-api/index.ts +82 -0
  47. package/packages/serp-rest-api/src/utils/data.ts +13 -0
  48. package/packages/serp-rest-api/src/utils/files.ts +83 -0
  49. package/packages/serp-rest-api/src/utils/index.ts +2 -0
  50. package/packages/serp-websocket/LICENSE.md +21 -0
  51. package/packages/serp-websocket/README.md +32 -0
  52. package/packages/serp-websocket/dist/index.node.js +400 -0
  53. package/packages/serp-websocket/dist/index.web.js +158 -0
  54. package/packages/serp-websocket/package.json +60 -0
  55. package/packages/serp-websocket/src/constants/index.ts +7 -0
  56. package/packages/serp-websocket/src/index.ts +43 -0
  57. package/packages/serp-websocket/src/v1/index.ts +183 -0
  58. package/src/index.js +7 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2024, SERP, d@serptech.ru
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ 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/Makefile ADDED
@@ -0,0 +1,12 @@
1
+ install-all:
2
+ npm run install:all
3
+ install-ci:
4
+ npm run ci:all
5
+ test-all:
6
+ npm run test:all
7
+ validate:
8
+ npm run validate
9
+ publish-dry:
10
+ npm publish --dry-run
11
+ publish:
12
+ npm publish
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Serp API JS library
2
+
3
+ ## Installation
4
+
5
+ ### NPM
6
+
7
+ ```bash
8
+ npm i --save @serp/api
9
+ ```
10
+
11
+ ### Yarn
12
+
13
+ ```bash
14
+ yarn add @serp/api
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ // ES2015 module import:
21
+ import { createSerpRestApi, createSerpWsApi } from "@serp/api";
22
+
23
+ // CommonJS module require:
24
+ const { createSerpRestApi, createSerpWsApi } = require("@serp/api");
25
+
26
+ // REST
27
+ const SerpRestApi = createSerpRestApi({
28
+ version: 1,
29
+ token: "YOUR_SERP_TOKEN",
30
+ });
31
+
32
+ // WebSocket
33
+ const SerpWsApi = createSerpWsApi({
34
+ version: 1,
35
+ token: "YOUR_SERP_TOKEN",
36
+ });
37
+
38
+ SerpWsApi.connect();
39
+ ```
@@ -0,0 +1,65 @@
1
+ /*
2
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3
+ * This devtool is neither made for production nor for readable output files.
4
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
5
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6
+ * or disable the default devtool with "devtool: false".
7
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory();
12
+ else if(typeof define === 'function' && define.amd)
13
+ define([], factory);
14
+ else if(typeof exports === 'object')
15
+ exports["SerpApi"] = factory();
16
+ else
17
+ root["SerpApi"] = factory();
18
+ })(this, () => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ var __webpack_modules__ = ({
21
+
22
+ /***/ "./src/index.js":
23
+ /***/ ((module) => {
24
+
25
+ eval("var _packagesSerpRes = \"../packages/serp-rest-api/dist/index.web.js\",\n createSerpRestApi = _packagesSerpRes.createSerpRestApi;\nvar _packagesSerpWeb = \"../packages/serp-websocket/dist/index.web.js\",\n createSerpWsApi = _packagesSerpWeb.createSerpWsApi;\nmodule.exports = {\n createSerpRestApi: createSerpRestApi,\n createSerpWsApi: createSerpWsApi\n};\n\n//# sourceURL=webpack://SerpApi/./src/index.js?");
26
+
27
+ /***/ })
28
+
29
+ /******/ });
30
+ /************************************************************************/
31
+ /******/ // The module cache
32
+ /******/ var __webpack_module_cache__ = {};
33
+ /******/
34
+ /******/ // The require function
35
+ /******/ function __webpack_require__(moduleId) {
36
+ /******/ // Check if module is in cache
37
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
38
+ /******/ if (cachedModule !== undefined) {
39
+ /******/ return cachedModule.exports;
40
+ /******/ }
41
+ /******/ // Create a new module (and put it into the cache)
42
+ /******/ var module = __webpack_module_cache__[moduleId] = {
43
+ /******/ // no module.id needed
44
+ /******/ // no module.loaded needed
45
+ /******/ exports: {}
46
+ /******/ };
47
+ /******/
48
+ /******/ // Execute the module function
49
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
50
+ /******/
51
+ /******/ // Return the exports of the module
52
+ /******/ return module.exports;
53
+ /******/ }
54
+ /******/
55
+ /************************************************************************/
56
+ /******/
57
+ /******/ // startup
58
+ /******/ // Load entry module and return exports
59
+ /******/ // This entry module is referenced by other modules so it can't be inlined
60
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.js");
61
+ /******/
62
+ /******/ return __webpack_exports__;
63
+ /******/ })()
64
+ ;
65
+ });
@@ -0,0 +1,65 @@
1
+ /*
2
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3
+ * This devtool is neither made for production nor for readable output files.
4
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
5
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6
+ * or disable the default devtool with "devtool: false".
7
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory();
12
+ else if(typeof define === 'function' && define.amd)
13
+ define([], factory);
14
+ else if(typeof exports === 'object')
15
+ exports["SerpApi"] = factory();
16
+ else
17
+ root["SerpApi"] = factory();
18
+ })(this, () => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ var __webpack_modules__ = ({
21
+
22
+ /***/ "./src/index.js":
23
+ /***/ ((module) => {
24
+
25
+ eval("var _packagesSerpRes = \"../packages/serp-rest-api/dist/index.web.js\",\n createSerpRestApi = _packagesSerpRes.createSerpRestApi;\nvar _packagesSerpWeb = \"../packages/serp-websocket/dist/index.web.js\",\n createSerpWsApi = _packagesSerpWeb.createSerpWsApi;\nmodule.exports = {\n createSerpRestApi: createSerpRestApi,\n createSerpWsApi: createSerpWsApi\n};\n\n//# sourceURL=webpack://SerpApi/./src/index.js?");
26
+
27
+ /***/ })
28
+
29
+ /******/ });
30
+ /************************************************************************/
31
+ /******/ // The module cache
32
+ /******/ var __webpack_module_cache__ = {};
33
+ /******/
34
+ /******/ // The require function
35
+ /******/ function __webpack_require__(moduleId) {
36
+ /******/ // Check if module is in cache
37
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
38
+ /******/ if (cachedModule !== undefined) {
39
+ /******/ return cachedModule.exports;
40
+ /******/ }
41
+ /******/ // Create a new module (and put it into the cache)
42
+ /******/ var module = __webpack_module_cache__[moduleId] = {
43
+ /******/ // no module.id needed
44
+ /******/ // no module.loaded needed
45
+ /******/ exports: {}
46
+ /******/ };
47
+ /******/
48
+ /******/ // Execute the module function
49
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
50
+ /******/
51
+ /******/ // Return the exports of the module
52
+ /******/ return module.exports;
53
+ /******/ }
54
+ /******/
55
+ /************************************************************************/
56
+ /******/
57
+ /******/ // startup
58
+ /******/ // Load entry module and return exports
59
+ /******/ // This entry module is referenced by other modules so it can't be inlined
60
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.js");
61
+ /******/
62
+ /******/ return __webpack_exports__;
63
+ /******/ })()
64
+ ;
65
+ });
@@ -0,0 +1,51 @@
1
+ import prettier from "eslint-plugin-prettier";
2
+ import jest from "eslint-plugin-jest";
3
+ import globals from "globals";
4
+ import babelParser from "@babel/eslint-parser";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import js from "@eslint/js";
8
+ import { FlatCompat } from "@eslint/eslintrc";
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const compat = new FlatCompat({
13
+ baseDirectory: __dirname,
14
+ recommendedConfig: js.configs.recommended,
15
+ allConfig: js.configs.all
16
+ });
17
+
18
+ export default [{
19
+ ignores: ["dist/*", "node_modules/*"],
20
+ }, ...compat.extends("eslint:recommended", "prettier", "plugin:jest/recommended"), {
21
+ settings: {
22
+ jest: {
23
+ version: jest.meta.version,
24
+ },
25
+ },
26
+
27
+ plugins: {
28
+ prettier,
29
+ jest,
30
+ },
31
+
32
+ languageOptions: {
33
+ globals: {
34
+ ...globals.browser,
35
+ ...globals.commonjs,
36
+ ...globals.node,
37
+ ...globals.jest,
38
+ },
39
+
40
+ parser: babelParser,
41
+ ecmaVersion: 5,
42
+ sourceType: "module",
43
+
44
+ parserOptions: {
45
+ requireConfigFile: false,
46
+ ecmaFeatures: {
47
+ modules: true,
48
+ },
49
+ },
50
+ },
51
+ }];