Compare commits

...

202 Commits

Author SHA1 Message Date
  David Ludwig 82a26cd523 Fix Jest package info 4 years ago
  David Ludwig 446e000d8f IPC abstract client/server implementation ready for use I think 4 years ago
  David Ludwig 821ef2f07f Progress on IPC rewrite 4 years ago
  David Ludwig 2d46925f0f Use Jest mock functions 4 years ago
  David Ludwig 9b51f2418f Add Jest and target ES6 in TypeScript 4 years ago
  David Ludwig 3eda319bde Add global jest config 4 years ago
  David Ludwig 3d1767744c Rewrote microservice architecture 4 years ago
  David Ludwig f3c599676d Update readme and add new diagram 4 years ago
  David Ludwig 939ee8f32e Update Plex IPC interface to match the new IPC package 4 years ago
  David Ludwig 4741ea339e Use the Manager's new ticket creation system in the interface 4 years ago
  David Ludwig 10e7960459 Add ticket manager and ticket creation to manager 4 years ago
  David Ludwig 69db4566ec Fix error types in IPC package 4 years ago
  David Ludwig 1cdcaf96f4 Add response error handling to IPC package 4 years ago
  David Ludwig c10fe73f70 Add hasMovie method to Plex service 4 years ago
  David Ludwig 1f42d67d77 Add exists method to PlexMovie entity 4 years ago
  David Ludwig ed42d02e6d Rename seeker and request services to manager and interface 4 years ago
  David Ludwig a0d750442f Add progress handling to request service 4 years ago
  David Ludwig 62d1b80376 Add progress handling to Seeker 4 years ago
  David Ludwig 60eca7af43 Fix package issues 4 years ago
  David Ludwig 8b1b8aa05c Remove old torrent handling code in Seeker 4 years ago
  David Ludwig 0a561b8b91 Add progress method to seeker API 4 years ago
  David Ludwig e9ad0b4837 Added progress to webui 4 years ago
  David Ludwig bb3f133805 Revert back to ES5 for now 4 years ago
  David Ludwig 5d736c97bf Merge branch 'dev' of ssh://git.dlii.tech:222/Autoplex/autoplex into dev 4 years ago
  David Ludwig 86cc33ec6c Fix IPC broadcast function failing 4 years ago
  David Ludwig 60badac3b1 Fix WebSocketServer response incorrectly stringifying the payload 4 years ago
  David Ludwig 4bf6b559d4 Add ticket ID to converted ticket objects in request service 4 years ago
  David Ludwig a4b877e9af Add progress to movie request info 4 years ago
  David Ludwig 1b86c2ce89 Add progress to movie request info 4 years ago
  David Ludwig 6e736cafdf Cancel/create movie requests trigger movie ticket updates 4 years ago
  David Ludwig 8c6843980a Add progress to movie list item 4 years ago
  David Ludwig 43989d86b7 Fix movie list component mixin not using update movies action 4 years ago
  David Ludwig 1bb3324014 Use the new movie store action instead of directly mutating 4 years ago
  David Ludwig f252dbd7d8 Add movie ticket caching to state. Include actions and mutations as well 4 years ago
  David Ludwig e9639daa3f Add websocket method enum to Request API 4 years ago
  David Ludwig 2c799e800c Update Vite 4 years ago
  David Ludwig ffc83ea182 Remove test code from websocket 4 years ago
  David Ludwig 0ec01dbaf9 Add websocket ports to docker compose 4 years ago
  David Ludwig 4f746bcfdd Update global tsconfig configuration 4 years ago
  David Ludwig 727b6c9585 Add websocket client to webui 4 years ago
  David Ludwig 8f38f265b6 Update click listeners on dashboard and search for movie list 4 years ago
  David Ludwig 74ff3b5265 Clean up store 4 years ago
  David Ludwig 507527c17f Add emits to movie list 4 years ago
  David Ludwig 48318bc760 Add websocket server to request 4 years ago
  David Ludwig 8a4cc5540a Added websocket packages 4 years ago
  David Ludwig cd68c89663 Require cookies to store JWT signature 4 years ago
  David Ludwig dd58226e32 Required override keyword 4 years ago
  David Ludwig 3933b9426d Add override keyword to torrent-search service 4 years ago
  David Ludwig 92a21e0639 Add override keyword to torrent client service 4 years ago
  David Ludwig e8c2f5072f Add override keyword to seeker 4 years ago
  David Ludwig 18360561f2 Add override keyword to search service 4 years ago
  David Ludwig 61579f252a Add override keyword to request service 4 years ago
  David Ludwig 95b9f15f5c Add override keyword to Plex service 4 years ago
  David Ludwig f1d8cc3dd0 Add doc to movies getter 4 years ago
  David Ludwig 639f5872dc Fix movies getter not returning the movie object by default 4 years ago
  David Ludwig a1288e80ca Remove unused imports 4 years ago
  David Ludwig 7aba016fb5 Add MovieListItem component. Integrate MovieListComponentMixin into MovieList 4 years ago
  David Ludwig 284ba38cff Add movies to store to provide global realtime updates in the future 4 years ago
  David Ludwig 603fc7e0f9 Fix plex scan interval 4 years ago
  David Ludwig 1c90101653 Allow Lerna to use shared dependencies across all packages. Fix production builds. 4 years ago
  David Ludwig fe50363134 Add option to remove torrent files to the torrent REST API 4 years ago
  David Ludwig 53f07107b5 Torrent client can now also remove a torrent's files. Fixed bug where torrent was removed before files were deleted 4 years ago
  David Ludwig 21ae611d90 Adjust download path parameter name for torrent REST API 4 years ago
  David Ludwig 63b292da2c Add .m4v to Seeker post-processor 4 years ago
  David Ludwig ad5126427d Clean up formatting a bit in RARBG provider. Also use the error code enum 4 years ago
  David Ludwig b9f9618d7a Improved the general torrent provider. Added RARBG as a provider 4 years ago
  David Ludwig 2162305c3e Add readme containing torrent sites 4 years ago
  David Ludwig 040bdf952f Clean up request service services index 4 years ago
  David Ludwig af10748392 Update Cheerio dependency 4 years ago
  David Ludwig 931d182835 Remove env file from Seeker 4 years ago
  David Ludwig cfaae99af3 3x+ speed boost for dev build 4 years ago
  David Ludwig 368e98c6ec Add torrent-search service to Seeker. Remove old application code from Seeker 4 years ago
  David Ludwig f83a4716d3 Merge branch 'dev' of ssh://git.dlii.tech:222/Autoplex/autoplex into dev 4 years ago
  David Ludwig bab5c62abd Adjust API parameter types in torrent-search service 4 years ago
  David Ludwig c55c1e0461 Adjust API parameter types 4 years ago
  David Ludwig aeda397bcf Fix typo 4 years ago
  David Ludwig 0d6069c0d2 Add additional stage to microservice internal service to link to other internal services 4 years ago
  David Ludwig 8e42868561 Add torrent-search service 4 years ago
  David Ludwig d40d46eed4 Canceled movies are remove from the dashboard 4 years ago
  David Ludwig 23e852f9d9 Implement movie request canceling in web UI 4 years ago
  David Ludwig 404f44f047 Add movie request cancel requests to API 4 years ago
  David Ludwig c4dcfe9cea Fix Font Awesome not loading 4 years ago
  David Ludwig 50d55f4ff3 Add IBM Plex Sans font 4 years ago
  David Ludwig 18b1f4bd73 Remove old logging 4 years ago
  David Ludwig b4ed9cb4d1 Fix Request API schema to match the webserver RESTful schema 4 years ago
  David Ludwig 544127a635 Update Web UI REST API 4 years ago
  David Ludwig af07ad3b2f Use RESTful response generation for request service 4 years ago
  David Ludwig 66e30ad23c Add module definition to Request API package 4 years ago
  David Ludwig 61692646ed Move the copy of tsconfig to after install dependencies in the Dockerfile to reduce the chance of rebuilds 4 years ago
  David Ludwig 095a745f77 Update Web UI to use the request API package. Implement all API requests as Vuex actions. Fix components 4 years ago
  David Ludwig e8936dc92f Fix up API routes in request service 4 years ago
  David Ludwig 4442468119 Add utility function to convert movie tickets to movies 4 years ago
  David Ludwig dd562a6505 Adjust movie ticket and movie info models in database 4 years ago
  David Ludwig 844f02bac9 Adjust movie search schema 4 years ago
  David Ludwig e5f96d19d6 Convert movie request to a POST request in the Request service 4 years ago
  David Ludwig eee4b984cc Add RESTful package to Web UI 4 years ago
  David Ludwig 4b782c9a88 Fix return type of movie search result in Request service 4 years ago
  David Ludwig 1922eb0083 Add RESTful package to webserver package 4 years ago
  David Ludwig 568bb0ae59 Clean up request API 4 years ago
  David Ludwig 784c15f496 Fix movie search wrapper not returning the correct number of results 4 years ago
  David Ludwig 79e7112968 Add RESTful package to provide common details among services 4 years ago
  David Ludwig 6a895c5e7e Revert previous commit 4 years ago
  David Ludwig c7c499c2a8 Remove the retyped password requirement from registration request 4 years ago
  David Ludwig ebc2b89cb5 Request uses request API package. Common modules are gone, therefore no need for server folder anymore. Request module uses the microservices properly 4 years ago
  David Ludwig 8cb2a6e2fb Add utils and movie link interface method to Plex package 4 years ago
  David Ludwig 1367f7bc20 Update search service to use updated API 4 years ago
  David Ludwig db21241355 Transfer old common library code to the request API package 4 years ago
  David Ludwig a3f12efff1 Fix formatting issue in webserver package 4 years ago
  David Ludwig d742366335 Drop plex related utilities from the utils package as they will be used in the Plex library alone 4 years ago
  David Ludwig db2306cc91 Add interface method to Plex API to grab links for given movie items 4 years ago
  David Ludwig 24c3d58660 Add template to paginated response in the search API package 4 years ago
  David Ludwig 73177e38af Add request service API 4 years ago
  David Ludwig 9d51e51ea4 Spaces should be tabs 4 years ago
  David Ludwig 3b92895fa2 Fix database package bug not properly registering to the connection manager with custom database service instances 4 years ago
  David Ludwig 3cd46d8f47 Prevent duplicate service registration in microservice application 4 years ago
  David Ludwig 0ef6e6a0cb Use Seeker API in Request service 4 years ago
  David Ludwig 9527954d6a Add Seeker API 4 years ago
  David Ludwig e95fe3e4f3 Use the Database package in the torrent client 4 years ago
  David Ludwig deb2ac5327 Remove old console log 4 years ago
  David Ludwig d0629743ab Update example environment 4 years ago
  David Ludwig 7de3efba3c Add Plex microservice and API 4 years ago
  David Ludwig 9f0499eee6 Add Application state logging to the microservice package 4 years ago
  David Ludwig 2ef0a7a1b2 Request now uses the updated Database service 4 years ago
  David Ludwig c95412df3e Remove Plex Library update code as it is going to be moved. 4 years ago
  David Ludwig 145883b8c7 Update Seeker service to use new Database module. Clean up torrent IPC 4 years ago
  David Ludwig ec0391c2ee Fix IPC client services not waiting for connection upon boot 4 years ago
  David Ludwig d6c46a5d79 Add environment script to use BuildKit 4 years ago
  David Ludwig 1970789ab6 Rename the main autoplex database 4 years ago
  David Ludwig ab329544ab Enable custom entity registration in database package. Add environment variable for database selection 4 years ago
  David Ludwig aeef2ba7ca Drop old Dockerfile from Seeker service 4 years ago
  David Ludwig d13e4454c9 Drop database environment requirements from .env files 4 years ago
  David Ludwig c5e82e5acc Update torrent IPC in the torrent-rest service 4 years ago
  David Ludwig bcbcaaa936 Provide default database info to the database package to remove environment requirements 4 years ago
  David Ludwig 89f5c6090c Fix Database class name and add missing template parameters 4 years ago
  David Ludwig f03faf95a8 Database package: Add database service 4 years ago
  David Ludwig 8ff03a6f87 Trorent API: Fix return type of 'has' method 4 years ago
  David Ludwig 80f3c78fcb Search API: Rename methods, add error handling, fix return types 4 years ago
  David Ludwig 84cc81f893 Fix search API methods being protected instead of being public 4 years ago
  David Ludwig 944b64e4c9 Provide API IPC clients a default service name to remove unnecessary abstraction 4 years ago
  David Ludwig e0d66f6804 Fix comment typo 4 years ago
  David Ludwig ce58a260aa Update yarn.lock files 4 years ago
  David Ludwig 3079710dbf Remove torrent webui for now 4 years ago
  David Ludwig 787e9ee74e Fix torrent-rest buildscript 4 years ago
  David Ludwig 93b4e6c90a Update Dockerfiles and build scripts to fix production build errors. 4 years ago
  David Ludwig bfd9b51281 Add regex corrections for alpine in the Docker export scripts 4 years ago
  David Ludwig ae51e0684c Remove old webui folder 4 years ago
  David Ludwig f0f1c50956 Add missing IPC dependency to seeker 4 years ago
  David Ludwig 96ec56f1d7 Rename autoplex-webui to just webui 4 years ago
  David Ludwig 5dd181d1ac Add services readme 4 years ago
  David Ludwig b04769f7a7 Update tsconfig files to extend from the root 4 years ago
  David Ludwig 4622ed42ef Fix build directory for torrent-rest service 4 years ago
  David Ludwig f6e046bdff Update seeker torrent IPC 4 years ago
  David Ludwig 78278ab88f Added search service to fetch movie and tv show data 4 years ago
  David Ludwig fb6f535050 Revert adding The Movie DB package 4 years ago
  David Ludwig f4b4aba65e Add TheMovieDB package 4 years ago
  David Ludwig b9971282a4 Finish rewrite of torrent REST API service 4 years ago
  David Ludwig 2313c0f0aa Clean up torrent client interface 4 years ago
  David Ludwig 6bc6a82df8 Clean up torrent client API interface 4 years ago
  David Ludwig c50ab3016a Add more response codes to webserver package. Clean up response generation 4 years ago
  David Ludwig 16976dc5a3 Add 404 status to webserver package 4 years ago
  David Ludwig f28281921f Added a respond function and status code definitions 4 years ago
  David Ludwig 96d6e10484 Export FastifyReply from webserver package 4 years ago
  David Ludwig e26d5110fa Remove old torrent-client. Add torrent REST API service 4 years ago
  David Ludwig 4bc8698f34 Rename torrent client service to just torrent. Use IPC package and include IPC API 4 years ago
  David Ludwig ff3422b344 Request service uses IPC package 4 years ago
  David Ludwig 9661d9a261 Use new IPC package and add torrent client IPC 4 years ago
  David Ludwig 226ea4a39b Torrent IPC API Methods should be public 4 years ago
  David Ludwig ce5e18affe Added torrent client API package 4 years ago
  David Ludwig 80079090cf Added readme to packages 4 years ago
  David Ludwig 6ef5248792 Add service API package support 4 years ago
  David Ludwig 3a3a0796c2 Separate IPC from Microservice package into its own package 4 years ago
  David Ludwig 8d0fec91c8 Remove unused package script from request 4 years ago
  David Ludwig a831ebb5dc Add PUT and DELETE requests to webserver module 4 years ago
  David Ludwig 19f54296ab Separated the Autoplex web UI into its own service 4 years ago
  David Ludwig 5b2e3ea2a6 Remove temporary SPA routes from the generic webserver package 4 years ago
  David Ludwig abf2548989 Convert the request service to use the new webserver package 4 years ago
  David Ludwig e3b93d869d Add webserver package 4 years ago
  David Ludwig 1d7f8bb923 Update services to match the new microservice name changes 4 years ago
  David Ludwig fce43dc18c Change socket path in IPC services to use a constant rather than a getter in the microservice IPC package 4 years ago
  David Ludwig a5ff98a304 Convert service name to use a constant rather than a getter in the microservice package 4 years ago
  David Ludwig 038aade267 Remove test IPC request from seeker 4 years ago
  David Ludwig 11c9e69eb1 Convert Seeker service to use the new generic IPC services from the microservice package 4 years ago
  David Ludwig 59f7cddbf8 Convert Request service to use the new generic IPC services from the microservice package 4 years ago
  David Ludwig f459f4ed93 Add generic IPC services to microservice package 4 years ago
  David Ludwig 4f137f6793 Implement Microservice package into torrent client 4 years ago
  David Ludwig 4b0c76d400 Add SIGINT handler in microservice package. Add better error logging for failed boot 4 years ago
  David Ludwig 56f371dba1 Update microservice package to make microservice internal services event emitters 4 years ago
  David Ludwig 0722e99dc0 Use the new exec function in Request and Seeker 4 years ago
  David Ludwig c629768715 Refactor the microservice lifecycle so that exec returns an exit code 4 years ago
  David Ludwig 04639a6ad8 Clean up services and remove no-op boot/shutdown methods 4 years ago
  David Ludwig 4e00d04627 Convert Seeker to use the Microservice package 4 years ago
  David Ludwig d37ee95e37 Remove the requirement of overriding boot and shutdown methods in the microservice package 4 years ago
  David Ludwig 331455fed9 Enable decorators 4 years ago
  David Ludwig 67250e4a30 Convert Request service to use the Microservice package 4 years ago
  David Ludwig ba8e00b54d Add microservice package 4 years ago
  David Ludwig 6a6fe5a2b5 Add rimraf to utils package 4 years ago
  David Ludwig f68cb9698d Converted Seeker uses database package. Adjust environment variables for UID and GID 4 years ago
  David Ludwig eca50dd905 Use the Database package in request service 4 years ago
  David Ludwig aaf78ed5df Database package exports entities correctly. Database connection function connects via arguments instead of environment variables 4 years ago
  David Ludwig 2a58ac8f0f Add utils and database packages 4 years ago
  David Ludwig 2859bcf612 Fix up docker files and add more generic tsconfig files. Also fix run scripts 4 years ago
  David Ludwig 624006303a Rename service packages 4 years ago
402 changed files with 19687 additions and 8125 deletions
Split View
  1. +3
    -4
      .env.example
  2. +48
    -5
      .gitignore
  3. +20
    -20
      Dockerfile
  4. +11
    -4
      README.md
  5. +18
    -0
      api/interface/package.json
  6. +3
    -0
      api/interface/src/index.ts
  7. +71
    -0
      api/interface/src/schema.ts
  8. +1
    -1
      api/interface/src/validation.ts
  9. +18
    -0
      api/interface/src/websocket.ts
  10. +7
    -0
      api/interface/tsconfig.json
  11. +92
    -0
      api/interface/yarn.lock
  12. +16
    -0
      api/manager/package.json
  13. +76
    -0
      api/manager/src/IpcClient.ts
  14. +4
    -0
      api/manager/src/constants.ts
  15. +3
    -0
      api/manager/src/index.ts
  16. +8
    -0
      api/manager/src/schema.ts
  17. +7
    -0
      api/manager/tsconfig.json
  18. +92
    -0
      api/manager/yarn.lock
  19. +15
    -0
      api/plex/package.json
  20. +30
    -0
      api/plex/src/IpcClient.ts
  21. +4
    -0
      api/plex/src/constants.ts
  22. +3
    -0
      api/plex/src/index.ts
  23. +0
    -0
      api/plex/src/schema.ts
  24. +7
    -0
      api/plex/tsconfig.json
  25. +92
    -0
      api/plex/yarn.lock
  26. +15
    -0
      api/search/package.json
  27. +65
    -0
      api/search/src/IpcClient.ts
  28. +4
    -0
      api/search/src/constants.ts
  29. +3
    -0
      api/search/src/index.ts
  30. +39
    -0
      api/search/src/schema.ts
  31. +7
    -0
      api/search/tsconfig.json
  32. +92
    -0
      api/search/yarn.lock
  33. +15
    -0
      api/torrent-search/package.json
  34. +32
    -0
      api/torrent-search/src/IpcClient.ts
  35. +4
    -0
      api/torrent-search/src/constants.ts
  36. +3
    -0
      api/torrent-search/src/index.ts
  37. +18
    -0
      api/torrent-search/src/schema.ts
  38. +7
    -0
      api/torrent-search/tsconfig.json
  39. +92
    -0
      api/torrent-search/yarn.lock
  40. +15
    -0
      api/torrent/package.json
  41. +76
    -0
      api/torrent/src/IpcClient.ts
  42. +4
    -0
      api/torrent/src/constants.ts
  43. +3
    -0
      api/torrent/src/index.ts
  44. +12
    -12
      api/torrent/src/schema.ts
  45. +7
    -0
      api/torrent/tsconfig.json
  46. +92
    -0
      api/torrent/yarn.lock
  47. +1
    -1
      bootstrap/database/init/01-databases.sql
  48. BIN
      diagrams/architecture.png
  49. +1
    -0
      diagrams/diagrams.drawio
  50. +53
    -17
      docker-compose.dev.yml
  51. +28
    -4
      docker-compose.prod.yml
  52. +79
    -29
      docker-compose.yml
  53. +9
    -2
      docker/scripts/export_builds.sh
  54. +9
    -2
      docker/scripts/export_deps.sh
  55. +5
    -0
      env.sh
  56. +196
    -0
      jest.config.ts
  57. +1
    -0
      lerna.json
  58. +15
    -3
      package.json
  59. +21
    -0
      packages/database/package.json
  60. +83
    -0
      packages/database/src/DatabaseService.ts
  61. +24
    -0
      packages/database/src/constants.ts
  62. +0
    -0
      packages/database/src/entities/DiscordAccount.ts
  63. +0
    -0
      packages/database/src/entities/DiscordChannel.ts
  64. +0
    -0
      packages/database/src/entities/DiscordLinkRequest.ts
  65. +0
    -0
      packages/database/src/entities/DiscordRequest.ts
  66. +6
    -0
      packages/database/src/entities/MovieInfo.ts
  67. +0
    -0
      packages/database/src/entities/MovieQuota.ts
  68. +28
    -21
      packages/database/src/entities/MovieTicket.ts
  69. +0
    -0
      packages/database/src/entities/MovieTorrent.ts
  70. +7
    -1
      packages/database/src/entities/PlexMovie.ts
  71. +1
    -2
      packages/database/src/entities/RegisterToken.ts
  72. +1
    -10
      packages/database/src/entities/User.ts
  73. +0
    -0
      packages/database/src/entities/index.ts
  74. +3
    -0
      packages/database/src/index.ts
  75. +10
    -0
      packages/database/tsconfig.json
  76. +808
    -0
      packages/database/yarn.lock
  77. +11
    -0
      packages/ipc/jest.config.ts
  78. +22
    -0
      packages/ipc/package.json
  79. +39
    -0
      packages/ipc/src/AbstractClient.ts
  80. +151
    -0
      packages/ipc/src/AbstractConnection.ts
  81. +20
    -0
      packages/ipc/src/AbstractMethodMap.ts
  82. +67
    -0
      packages/ipc/src/AbstractServer.ts
  83. +14
    -0
      packages/ipc/src/errors.ts
  84. +5
    -0
      packages/ipc/src/index.ts
  85. +23
    -0
      packages/ipc/src/schema.ts
  86. +45
    -0
      packages/ipc/test/unit/AbstractConnection.spec.ts
  87. +23
    -0
      packages/ipc/test/unit/AbstractMethodMap.spec.ts
  88. +7
    -0
      packages/ipc/tsconfig.json
  89. +51
    -0
      packages/ipc/yarn.lock
  90. +3
    -0
      packages/microservice/README.md
  91. +11
    -0
      packages/microservice/jest.config.ts
  92. +14
    -0
      packages/microservice/package.json
  93. +60
    -0
      packages/microservice/src/InternalService.ts
  94. +246
    -0
      packages/microservice/src/Microservice.ts
  95. +13
    -0
      packages/microservice/src/errors.ts
  96. +4
    -0
      packages/microservice/src/index.ts
  97. +21
    -0
      packages/microservice/src/schema.ts
  98. +65
    -0
      packages/microservice/test/integration/internal-services.test.ts
  99. +20
    -0
      packages/microservice/test/unit/InternalService.spec.ts
  100. +109
    -0
      packages/microservice/test/unit/Microservice.spec.ts

+ 3
- 4
.env.example View File

@ -1,5 +1,4 @@
UID=1000
GID=1000
# Docker User Info ---------------------------------------------------------------------------------
DOCKER_BUILDKIT=1
COMPOSE_DOCKER_CLI_BUILD=1
USER_ID = 1000
GROUP_ID = 1000

+ 48
- 5
.gitignore View File

@ -10,14 +10,57 @@
# Node Modules
node_modules/
# Environment varibales
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
.data/
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# TypeScript cache
*.tsbuildinfo
# Optional REPL history
.node_repl_history
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# Environment docker-compose configuration
docker-compose.env.yml
# Built packages
/packages/*/lib
# Built files
dist
build
# Built services
/services/*/dist
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

+ 20
- 20
Dockerfile View File

@ -10,7 +10,7 @@
ARG SERVICE
# The base image to use
ARG BASE=base-alpine
ARG BASE=alpine
# Base Definitions ---------------------------------------------------------------------------------
@ -38,33 +38,31 @@ FROM base-slim AS base-slim-dev
# Development Image --------------------------------------------------------------------------------
# Define the base image
FROM ${BASE}-dev AS dev
FROM base-${BASE}-dev AS dev-base
ARG SERVICE
WORKDIR /opt/app
# Environment configuration
ENV PATH "/app/node_modules/.bin:$PATH"
RUN echo "#!/bin/sh" >> /bin/lerna && \
echo '( cd /opt/app && ./node_modules/.bin/lerna "$@" )' >> /bin/lerna && \
chmod +x /bin/lerna
# Copy over Lerna stuff
COPY lerna.json package.json tsconfig.json ./
WORKDIR /app
ENV PATH "/app/node_modules/.bin:/app/services/${SERVICE}/node_modules/.bin:$PATH"
COPY lerna.json package.json yarn.lock ./
RUN yarn install
COPY tsconfig*.json ./
# Symlink the requested service to /app
RUN ln -s /opt/app/services/${SERVICE} /app
WORKDIR /app
# Define the dev image
FROM dev-base AS dev
ARG SERVICE
# RUN ln -s /opt/app/services/${SERVICE} /app
WORKDIR /app/services/${SERVICE}
CMD [ "yarn", "run", "start:dev" ]
# Build Definitions --------------------------------------------------------------------------------
# Create the builder image with all dependencies
FROM ${BASE}-dev AS builder-base
FROM base-${BASE}-dev AS builder-base
WORKDIR /app
RUN yarn global add lerna typescript rimraf
COPY docker/scripts docker/scripts
COPY lerna.json package.json tsconfig.json ./
COPY lerna.json package.json tsconfig*.json ./
RUN yarn install
COPY api api
COPY packages packages
# Copy service package.json and patch files if they exist
@ -75,18 +73,20 @@ COPY services/${SERVICE}/patches* ./services/${SERVICE}/patches
# Cache an image containing only the prod-dependencies
FROM builder AS prod-deps
ARG BASE
RUN lerna bootstrap -- --production --no-optional
RUN yarn run export:deps
RUN yarn run export:deps ${BASE}
# Build the service
FROM builder AS build
ARG BASE
ARG SERVICE
COPY services/${SERVICE} ./services/${SERVICE}
RUN lerna clean --yes && lerna bootstrap && lerna run clean && lerna run build
RUN yarn run export:builds
RUN yarn run export:builds ${BASE}
# Return to base image with the compiled files and production dependencies
FROM ${BASE} AS prod
FROM base-${BASE} AS prod
ARG SERVICE
WORKDIR /app
COPY --from=prod-deps /app/build /opt


+ 11
- 4
README.md View File

@ -4,7 +4,14 @@ Autoplex is an all-in-one media management utility for Plex.
## Setup
1. Clone this repository with all submodules
2. Configure `.env` files inside each submodule
3. Execute the `setup.sh` script to generate secrets for the containers
4. Deploy using `docker-compose`
1. Clone this repository
2. Configure a `docker-compose.env.yml` file to mount filesystems to the storage manager and torrent client.
3. Generate and configure Docker `secrets` by running `generate_secrets.sh`
4. Load the Docker Buildkit environment by running `source ./env.sh`
5. Deploy using `docker-compose`
## Development
### Architecture
![Architecture Overview](diagrams/architecture.png)

+ 18
- 0
api/interface/package.json View File

@ -0,0 +1,18 @@
{
"name": "@autoplex-api/interface",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings",
"module": "src/index.ts",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"devDependencies": {
"@autoplex-api/search": "^0.0.0"
},
"dependencies": {
"@autoplex/microservice": "^0.0.0"
}
}

+ 3
- 0
api/interface/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./schema";
export * from "./validation";
export * from "./websocket";

+ 71
- 0
api/interface/src/schema.ts View File

@ -0,0 +1,71 @@
import type {
IMovie as IMovieBase,
IMovieDetails as IMovieDetailsBase
} from "@autoplex-api/search";
/**
* Basic user information schema
*/
export interface IUser {
id : number,
name : string,
isAdmin: boolean
}
/**
* The JWT auth token structure
*/
export interface ITokenSchema extends IUser {
iat: number,
exp: number
}
/**
* The general API response structure
*/
export interface IApiResponse {
errors?: any[]
status: string
}
/**
* A generic data response from the API
*/
export interface IApiDataResponse<T> extends IApiResponse {
result: T
}
/**
* A generic data response conatining paginated results
*/
export type IPaginatedResponse<T> = IApiDataResponse<{
page: number,
results: T[]
totalPages: number,
totalResults: number
}>;
/**
* Movie request information schema
*/
interface IMovieRequestInfo {
plexLink: string | null,
ticketId: number | null,
progress: number | null
}
/**
* General movie information schema
*/
export interface IMovie extends IMovieBase, IMovieRequestInfo {}
/**
* Detailed movie information schema
*/
export interface IMovieDetails extends IMovieDetailsBase, IMovieRequestInfo {
requestedBy: null | {
id : number,
isAdmin: boolean,
name : string
}
}

services/request/src/common/validation.ts → api/interface/src/validation.ts View File


+ 18
- 0
api/interface/src/websocket.ts View File

@ -0,0 +1,18 @@
/**
* Available websocket server-side methods to be invoked by the client
*/
export enum WebSocketMethod {
TicketProgress = "ticket_progress"
}
export interface IMovieProgressResponse {
[ticketId: number]: IMovieProgress
}
/**
* The download progress of a movie
*/
export interface IMovieProgress {
progress?: number,
plexLink?: string
}

+ 7
- 0
api/interface/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings"
}
}

+ 92
- 0
api/interface/yarn.lock View File

@ -0,0 +1,92 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^15.0.1":
version "15.0.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a"
integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.3:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
typescript@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

+ 16
- 0
api/manager/package.json View File

@ -0,0 +1,16 @@
{
"name": "@autoplex-api/manager",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"dependencies": {
"@autoplex-api/search": "^0.0.0",
"@autoplex/ipc": "^0.0.0",
"@autoplex/microservice": "^0.0.0"
}
}

+ 76
- 0
api/manager/src/IpcClient.ts View File

@ -0,0 +1,76 @@
import { IMovie } from "@autoplex-api/search";
import { IpcClientService } from "@autoplex/ipc";
import { Microservice } from "@autoplex/microservice";
import { SOCKET_PATH } from "./constants";
/**
* Internal methods
*/
export const enum IpcMethod {
// Movie Requests
ActiveMovieRequests = "movie_requests_active",
ActiveMovieRequestsForUser = "movie_requests_active_for_user",
MapMovieRequests = "movie_requests_map",
MovieRequestStatus = "movie_requests_status",
CreateMovieRequest = "movie_request_create",
CancelMovieRequest = "movie_request_cancel"
}
export class IpcClient<M extends Microservice = Microservice> extends IpcClientService<M>
{
/**
* The service name
*/
public readonly NAME = "Manager";
/**
* The path to the socket file
*/
protected readonly SOCKET_PATH = SOCKET_PATH;
// Movie Requests ------------------------------------------------------------------------------
/**
* Fetch all active movie requests
*/
public async allActiveMovieRequests() {
return await this.request(IpcMethod.ActiveMovieRequests);
}
/**
* Fetch active movie requests for the particular user
*/
public async activeMovieRequestsForUser(userId: number) {
return await this.request(IpcMethod.ActiveMovieRequestsForUser, userId);
}
/**
* Find movie requests for the given movie list if they exist
*/
public async mapActiveMovieRequests(movies: IMovie[]) {
return await this.request(IpcMethod.MapMovieRequests, movies);
}
/**
* Get the status of the given movie requests
*/
public async movieRequestStatus(ticketIds: number[]) {
return await this.request(IpcMethod.MovieRequestStatus, ticketIds);
}
/**
* Create a movie request ticket
*/
public async createMovieRequest(userId: number, tmdbId: number) {
return await this.request<number>(IpcMethod.CreateMovieRequest, {
userId, tmdbId
});
}
/**
* Cancel a movie request ticket
*/
public async cancelMovieRequest(ticketId: number) {
return await this.request(IpcMethod.CancelMovieRequest, ticketId);
}
}

+ 4
- 0
api/manager/src/constants.ts View File

@ -0,0 +1,4 @@
/**
* The path to the socket file
*/
export const SOCKET_PATH = "/var/autoplex/ipc/manager.sock";

+ 3
- 0
api/manager/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./constants";
export * from "./IpcClient";
export * from "./schema";

+ 8
- 0
api/manager/src/schema.ts View File

@ -0,0 +1,8 @@
export enum ErrorType {
MovieTicketConflict = "movie_ticket_conflict",
MovieNotFound = "movie_not_found"
}
export interface ITicketState {
progress: number|null
}

+ 7
- 0
api/manager/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings"
}
}

+ 92
- 0
api/manager/yarn.lock View File

@ -0,0 +1,92 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^15.0.1":
version "15.0.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.2.tgz#51e9c0920d1b45936ea04341aa3e2e58d339fb67"
integrity sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.3:
version "7.1.7"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
typescript@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

+ 15
- 0
api/plex/package.json View File

@ -0,0 +1,15 @@
{
"name": "@autoplex-api/plex",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"dependencies": {
"@autoplex/ipc": "^0.0.0",
"@autoplex/microservice": "^0.0.0"
}
}

+ 30
- 0
api/plex/src/IpcClient.ts View File

@ -0,0 +1,30 @@
import { IpcClientService } from "@autoplex/ipc";
import { Microservice } from "@autoplex/microservice";
import { SOCKET_PATH } from "./constants";
export class IpcClient<M extends Microservice = Microservice> extends IpcClientService<M>
{
/**
* The name of the service
*/
public readonly NAME = "Plex";
/**
* The path to the socket file
*/
protected readonly SOCKET_PATH = SOCKET_PATH;
/**
* Fetch a Plex movie link given the TMDb ID if it exists
*/
public async movieLinks(tmdbIds: (number|string)[]) {
return await this.request<{ [tmdbId: number]: string|null }>("movie_links", tmdbIds);
}
/**
* Check if the given movie is already on Plex
*/
public async hasMovie(tmdbId: number|string) {
return await this.request("has_movie", tmdbId);
}
}

+ 4
- 0
api/plex/src/constants.ts View File

@ -0,0 +1,4 @@
/**
* The path to the socket file
*/
export const SOCKET_PATH = "/var/autoplex/ipc/plex.sock";

+ 3
- 0
api/plex/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./constants";
// export * from "./schema";
export * from "./IpcClient";

+ 0
- 0
api/plex/src/schema.ts View File


+ 7
- 0
api/plex/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings"
}
}

+ 92
- 0
api/plex/yarn.lock View File

@ -0,0 +1,92 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^15.0.1":
version "15.0.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a"
integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.3:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
typescript@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

+ 15
- 0
api/search/package.json View File

@ -0,0 +1,15 @@
{
"name": "@autoplex-api/search",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"dependencies": {
"@autoplex/ipc": "^0.0.0",
"@autoplex/microservice": "^0.0.0"
}
}

+ 65
- 0
api/search/src/IpcClient.ts View File

@ -0,0 +1,65 @@
import { IpcClientService } from "@autoplex/ipc";
import { Microservice } from "@autoplex/microservice";
import { SOCKET_PATH } from "./constants";
import { IMovie, IMovieDetails, IPaginatedResponse } from "./schema";
export class IpcClient<M extends Microservice = Microservice> extends IpcClientService<M>
{
/**
* The name of the service
*/
public readonly NAME = "Search";
/**
* The path to the socket file
*/
protected readonly SOCKET_PATH = SOCKET_PATH;
/**
* Get the details of a movie
*/
public async movieDetails(tmdbId: number) {
let result = await this.request("details", tmdbId);
if (result.error) {
console.error("Failed to fetch movie details:", result.error);
throw new Error("Failed to fetch movie details");
}
return <IMovieDetails>result.data;
}
/**
* Find a movie by its IMDb ID
*/
public async findMovieFromImdb(imdbId: string) {
let result = await this.request("find", imdbId);
if (result.error) {
console.error("Failed to find a movie by its IMDb ID:", result.error);
throw new Error("Failed to find a movie by its IMDb ID");
}
return <IMovie|null>result.data;
}
/**
* Search for a movie
*/
public async searchMovie(query: string, year?: number, page?: number) {
let result = await this.request("search", { query, year, page });
if (result.error) {
console.error("Failed to search for a movie:", result.error);
throw new Error("Failed to search for a movie");
}
return <IPaginatedResponse<IMovie>>result.data;
}
/**
* Verify an IMDb ID
*/
public async verifyImdbId(imdbId: string) {
let result = await this.request("verify_imdb_id", imdbId);
if (result.error) {
console.error("Failed to verify an IMDb ID:", result.error);
throw new Error("Failed to verify an IMDb ID");
}
return <boolean>result.data;
}
}

+ 4
- 0
api/search/src/constants.ts View File

@ -0,0 +1,4 @@
/**
* The path to the socket file
*/
export const SOCKET_PATH = "/var/autoplex/ipc/search.sock";

+ 3
- 0
api/search/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./constants";
export * from "./schema";
export * from "./IpcClient";

+ 39
- 0
api/search/src/schema.ts View File

@ -0,0 +1,39 @@
export enum MovieStatus {
Rumored = "Rumored",
Planned = "Planned",
InProduction = "InProduction",
PostProduction = "PostProduction",
Released = "Released",
Canceled = "Canceled"
}
export interface IMovieLanguage {
iso_639_1: string,
name : string
}
export interface IMovie {
backdropPath : string | null,
originalLanguage: string | null,
originalTitle : string | null,
overview : string | null,
posterPath : string | null,
releaseDate : string | null,
title : string,
tmdbId : number
}
export interface IMovieDetails extends IMovie {
imdbId : string | null,
runtime : number | null,
spokenLanguages: IMovieLanguage[],
status : MovieStatus,
tagline : string | null
}
export interface IPaginatedResponse<T> {
page : number,
results : T[],
totalResults: number,
totalPages : number
}

+ 7
- 0
api/search/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings"
}
}

+ 92
- 0
api/search/yarn.lock View File

@ -0,0 +1,92 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^15.0.1":
version "15.0.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a"
integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.3:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
typescript@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

+ 15
- 0
api/torrent-search/package.json View File

@ -0,0 +1,15 @@
{
"name": "@autoplex-api/torrent-search",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"dependencies": {
"@autoplex/ipc": "^0.0.0",
"@autoplex/microservice": "^0.0.0"
}
}

+ 32
- 0
api/torrent-search/src/IpcClient.ts View File

@ -0,0 +1,32 @@
import { IpcClientService } from "@autoplex/ipc";
import { Microservice } from "@autoplex/microservice";
import { SOCKET_PATH } from "./constants";
import { IMovieSearchInfo, ITorrentLink } from "./schema";
export class IpcClient<M extends Microservice = Microservice> extends IpcClientService<M>
{
/**
* The name of the service
*/
public readonly NAME = "Torrent Search";
/**
* The path to the socket file
*/
protected readonly SOCKET_PATH = SOCKET_PATH;
/**
* Add a torrent to the client
*/
public async searchMovie(title: string, imdbId: string|null, year: number|null,
altTitles: string[] = [], torrentBlacklist: string[] = [])
{
let response = await this.request("search_movie", <IMovieSearchInfo> {
title, imdbId, year, altTitles, torrentBlacklist
});
if (response.error) {
throw new Error("Failed to search for movie torrent");
}
return <ITorrentLink|null>response.data;
}
}

+ 4
- 0
api/torrent-search/src/constants.ts View File

@ -0,0 +1,4 @@
/**
* The path to the socket file
*/
export const SOCKET_PATH = "/var/autoplex/ipc/torrent_search.sock";

+ 3
- 0
api/torrent-search/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./constants";
export * from "./schema";
export * from "./IpcClient";

+ 18
- 0
api/torrent-search/src/schema.ts View File

@ -0,0 +1,18 @@
/**
* The movie search request structure
*/
export interface IMovieSearchInfo {
title : string,
altTitles : string[],
imdbId : string|null,
year : number|null,
torrentBlacklist: string[]
}
/**
* The generated torrent link structure
*/
export interface ITorrentLink {
link: string,
type: "magnet"|"file"
}

+ 7
- 0
api/torrent-search/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings"
}
}

+ 92
- 0
api/torrent-search/yarn.lock View File

@ -0,0 +1,92 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^15.0.1":
version "15.0.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.2.tgz#51e9c0920d1b45936ea04341aa3e2e58d339fb67"
integrity sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.3:
version "7.1.7"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
typescript@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

+ 15
- 0
api/torrent/package.json View File

@ -0,0 +1,15 @@
{
"name": "@autoplex-api/torrent",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"dependencies": {
"@autoplex/ipc": "^0.0.0",
"@autoplex/microservice": "^0.0.0"
}
}

+ 76
- 0
api/torrent/src/IpcClient.ts View File

@ -0,0 +1,76 @@
import { IpcClientService } from "@autoplex/ipc";
import { Microservice } from "@autoplex/microservice";
import { SOCKET_PATH } from "./constants";
import { ISerializedTorrent, ITorrent } from "./schema";
export class IpcClient<M extends Microservice = Microservice> extends IpcClientService<M>
{
/**
* The name of the service
*/
public readonly NAME = "Torrent";
/**
* The path to the socket file
*/
protected readonly SOCKET_PATH = SOCKET_PATH;
/**
* Add a torrent to the client
* @param torrent Magnet URI or file buffer
*/
public async add(torrent: string | Buffer, downloadPath?: string) {
let response = await this.request("add", { torrent, downloadPath });
if (response.error) {
throw new Error("Failed to add torrent");
}
return <string>response.data;
}
/**
* Remove a torrent from the client
* @param torrent Torrent info hash
*/
public async remove(torrentId: string, withData: boolean = false) {
let response = await this.request("remove", { torrentId, withData });
if (response.error) {
throw new Error("Failed to remove torrent");
}
}
/**
* Get a list of all torrents in the client
*/
public async list() {
let response = await this.request("list");
if (response.error) {
console.error(response.error);
throw new Error("Failed to obtain torrent list");
}
return <ITorrent[]>response.data;
}
/**
* Check if the torrent client has the given torrent
*/
public async has(torrentId: string) {
let response = await this.request("has", torrentId);
if (response.error) {
console.error(response.error);
throw new Error("Failed to check if a torrent exists");
}
return <boolean>response.data;
}
/**
* Get full details of each of the provided torrents
*/
public async details(torrentIds: string[] = []) {
let response = await this.request("details", torrentIds);
if (response.error) {
console.error(response.error);
throw new Error("Failed to retrieve torrent details");
}
return <ISerializedTorrent[]>response.data;
}
}

+ 4
- 0
api/torrent/src/constants.ts View File

@ -0,0 +1,4 @@
/**
* The path to the socket file
*/
export const SOCKET_PATH = "/var/autoplex/ipc/torrent.sock";

+ 3
- 0
api/torrent/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./constants";
export * from "./schema";
export * from "./IpcClient";

services/torrent-webui/src/server/common.ts → api/torrent/src/schema.ts View File


+ 7
- 0
api/torrent/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings"
}
}

+ 92
- 0
api/torrent/yarn.lock View File

@ -0,0 +1,92 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^15.0.1":
version "15.0.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a"
integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.3:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
typescript@^4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

+ 1
- 1
bootstrap/database/init/01-databases.sql View File

@ -1,2 +1,2 @@
CREATE DATABASE IF NOT EXISTS `autoplex_request`;
CREATE DATABASE IF NOT EXISTS `autoplex`;
CREATE DATABASE IF NOT EXISTS `autoplex_torrent`;

BIN
diagrams/architecture.png View File

Before After
Width: 1671  |  Height: 841  |  Size: 141 KiB

+ 1
- 0
diagrams/diagrams.drawio View File

@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2021-06-25T16:55:14.477Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.105 Safari/537.36" etag="H9R-f9ZGqernv-JFHs6f" version="14.8.1" type="device"><diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">7V1de9o2FP41uRyPLfmLy5C0Wba0zZY27a72KKCAW4OYLRLYr59sS2BbAgzYlkjXXBQLY2Od9311ztGRuIBX0+VNjOaTD2SEowtgjZYX8PoCAGj3ffZf2rLKW2zou3nLOA5HvG3T8BD+i3mjxVsX4QgnpRMpIREN5+XGIZnN8JCW2lAck9fyac8kKt91jsZYangYokhu/RqO6CRvDYC/af8Vh+OJuLPt9fN3pkiczJ8kmaAReS00wXcX8ComhOavpssrHKW9J/rl6+3qa3T3w7v57Y/kH/Rl8Pvnj4+/5Bd7f8hH1o8Q4xk9+tJ/D8aPKxB9+97//VP0OJmO55d3/CPWC4oWvL+uw2RI4hFr/JLgmD85XYnuJAsahTN8tbaWdQEHz2RGr0hE4uwcyP7ep99hMI7RKMSb92Zkxi4zSGhMfmDVB57DKCq0P2f/WPsIJRM84nd7wTENmYHv0BOO7kkS0pDM2HtPhFIyLZxwGYXj9A1K5qwV8aMh+0LsweBgQqcRO7b5A3Do2kAc84dOb4mSef60z+Ey/R4DhoV5+uZ0OU5500OvidOLcUIW8RDfDtPvM2CH+avyWYsku3tNm3Lbp4+ElwVEcxvfYDLFNF6xU/i7v3gONypnrCvw+7qBv8ebJgXkizbECTdeX3oDKvaC4+oAjLlAQhEeMY7yQw6KmCxmo7WNvy+mc3ECioeihZvIYcckphMyJjOGA5LaN7Pjd0zpip+FFpSUrcx6Ol5943fIDv5KD3quOLxeFt+8XvGjhKKYXqZalKIsIsMfovF9GImLH2bPHCg7Ok1IJYrHmO7qXH5i2qM74RHjCNHwpayKzdva/d/W7dkaGmVrIU2bsePy/pY13CCKX9FKAkLZ6q+TkOKHOcp65pXJY9l+jcsjV0MnkNXQBi3J4d3t8CbCf1gvD4Pl8sv8Cj33/25BDq1mKQIO4sgwQkkSDhUswcuQfiu8LhCQHW2unR6ISysB3iDVgEw1pZGcvk5mAZlZCwZWYD3g+CVkD2gktYDTIbWU/eb0D6dWg8TxGxlc1LQBu3kjC0TDxIE1xyhg1BDlWocDolN3pE3I+HWktnOAmOWvQklpN/HvgAX2ZgmtCPFAjRCvY+X1tSpvIyzaT3wTeOacJc+c4PzxcdTArMn6Zg3DjqSyX/ETd2cVOUYzRdbRLrLQlrqqDRK1kAJpDof8o/ckZPctGMstGwu6FSPkzOIfK2bJq1eC3p4r5dyTrpRZdP1EJxgZdqyUG3H8q6SN5uTH3Jqi5xgleu4W0ftyeyaCB7ULnr21D/+fmsIX5z81pUJYp1NT4GxH1P2ZTqumagqSGSKb4nsXOH+bsmKG5WicXS6cJ7gA+mFEFqP9GsqwTxHTirhtTV1PNwjE2zU1NWgN8s65Qn4vkq2OnM2qUd2azmZTLiKQs1bNU6QzSriWq5sSXieU2OZyr98zyOUGjQ8Kai45lWirOtK3HGwB2cE8HyY5Vrnv7Lr+emtEcvTGrkYSye+GSB7QSyT/jInkeqYRCQRSd34mcfbcwIvY3QdPLP71xumr+5i8hCMcJ+Z3dHXo9z3dHQ2PmCA2wxvuPKXqiuqKk1Oq0pXaTqkeUZRohpH3z7o3nvOsiQan67R4Nz76m7ahG2i2oTwP+IZSO4721A6UnbBPdJJmyq3L+Tzp9Xo7ullXOsDzK90I5W7sK3rRaS2I6SYnXAxiyjNwvf6+coXs6B7HIXviDOgH1zAU6hbWs34N1TDsr01Q5xbqVD9YaiydKIwuYDYAHrRdP+g7PgxKgJT42nJ2zwE/Bf58ffhTh+Qa8eeB3gZ9XgD14k+egPnAIkzMLvb58SIt2kHx0Nxi9C2hZqfF6colBeCIEsl21n0IDhYJuK+KcS0XdlkrGlorsoWRzdXN1a0hyddYdTD5qV52coT2d7o26IzNre5wvXWR8vTDfcT0DVgf0AyNTS2NlCIfS7e22kdMap8jb9YlyD3L8kry7dj93frNDqoeW9ssdOt6ZDkPdImufURt+lmDpwScWvXrJmDkVN/7NIwcsbLwLS3a9YLzVRc3aCVqgwITYhT0W4vT1PFE42sbDYXkiUDa6wPap7r8W/BRmZF3+t3iAxoTbx5ZrrE/y6QvwFCJj9oKWl2b5tc/NzGvVsu/tcsjENyTnlAMQMe6U8Zg5+RNKLYIU78sTFDMj3c0DSieX04wmh32gkq9naM9pSgrvBkraLcTfL+4bA9xvSM0oHUu19324GQn9LTwpfFtucyElzp6CZiVzgE47XinpwHHPCeyDJzDNlDpJMjocuqwGmS4sOMg9KcWllo7fxigIUCrhkDzcmeHrXk3OhCtiwGo1QERPr92DBwx0eKUOA9tbyfp9TkTjQ8ujl+uhIIe7DZQlNc5ZhUoZxUl6t+by5UXkzxQEqf7phvel9JEs/bNW8FOGdvo0btNq769WjbFdsVaO/tg+ep+qFPHIjVdbdCKGFbWsICqo92cFu56+AKH8z1QrGtE0RNK5DK8dd38KgoZ/mK4n8dPOVLvntYNaPhjnOH3U765ihhF+SDsrs0ukbqu4XcIaanDVYvyAgX1m6iuV1N/N/eNc2Fap2PtLWH1pr4UToRYStlKLWvzTKgOg572xPMxm4i0G9JVylKbSgupa2W7q5lpJ5zf4u5XN+YI/PIl6i74lGa+A9DpWOkYh84Dk1KnJBx0Z6p2ILbOlKfWTJViY53NWHEVhXjWyI7Q7Y8Qbt2F9e2NEDt2MLDucQvbFTTfq0G1V7tc4alO4pnig7a8HEQ97OrVMNhZtn1LAFpFY9f1ZKaMqobEP7AdMweV6hxpc7mWnScoj4GP9x/lYW9Cpk+LRJ84S3RQiTPsVJzl1TyirulP/M8CJ/RNp2sqTr9qb9dO8zVQ4YE8/py28HTbwpHTl3yh25afABAWmOAlGmdbFs8L4RBvXUdIYL99st2RxcDToSzpXxvn7ApqRm+VAr7YVVRQQDE8dEsBTzbDBGcDxDXrBSv77cS3wgIDUC/vhfP58e11tP5AX+zlVujoj4SGz+EQZZvfNzrF3H7mpM0fPWCHm18Lz/31zY+uw3f/AQ==</diagram></mxfile>

+ 53
- 17
docker-compose.dev.yml View File

@ -1,42 +1,78 @@
version: "3.9"
services:
request:
webui:
build:
target: dev
ports:
- 3001:3001
- 3201:3201
volumes:
- ./packages:/opt/app/packages
- ./services/request:/opt/app/services/request
entrypoint: "/bin/sh"
- ./api:/app/api
- ./packages:/app/packages
- ./services/webui:/app/services/webui
tty: true
seeker:
interface:
build:
target: dev
volumes:
- ./packages:/opt/app/packages
- ./services/seeker:/opt/app/services/seeker
entrypoint: "/bin/sh"
- ./api:/app/api
- ./packages:/app/packages
- ./services/interface:/app/services/interface
tty: true
torrent_webui:
plex:
build:
target: dev
volumes:
- ./api:/app/api
- ./packages:/app/packages
- ./services/plex:/app/services/plex
tty: true
search:
build:
target: dev
volumes:
- ./api:/app/api
- ./packages:/app/packages
- ./services/search:/app/services/search
tty: true
manager:
build:
target: dev
volumes:
- ./api:/app/api
- ./packages:/app/packages
- ./services/manager:/app/services/manager
tty: true
torrent_rest:
build:
target: dev
ports:
- 3000:3000
volumes:
- ./packages:/opt/app/packages
- ./services/torrent-webui:/opt/app/services/torrent-webui
entrypoint: "/bin/sh"
- ./api:/app/api
- ./packages:/app/packages
- ./services/torrent-rest:/app/services/torrent-rest
tty: true
torrent_search:
build:
target: dev
volumes:
- ./api:/app/api
- ./packages:/app/packages
- ./services/torrent-search:/app/services/torrent-search
tty: true
torrent_client:
torrent:
build:
target: dev
volumes:
- ./packages:/opt/app/packages
- ./services/torrent-client:/opt/app/services/torrent-client
entrypoint: "/bin/sh"
- ./api:/app/api
- ./packages:/app/packages
- ./services/torrent:/app/services/torrent
tty: true

+ 28
- 4
docker-compose.prod.yml View File

@ -1,25 +1,49 @@
version: "3.9"
services:
request:
webui:
build:
target: prod
environment:
NODE_ENV: production
seeker:
interface:
build:
target: prod
environment:
NODE_ENV: production
torrent_webui:
plex:
build:
target: prod
environment:
NODE_ENV: production
torrent_client:
search:
build:
target: prod
environment:
NODE_ENV: production
manager:
build:
target: prod
environment:
NODE_ENV: production
torrent_rest:
build:
target: prod
environment:
NODE_ENV: production
torrent_search:
build:
target: prod
environment:
NODE_ENV: production
torrent:
build:
target: prod
environment:


+ 79
- 29
docker-compose.yml View File

@ -1,86 +1,136 @@
version: "3.9"
services:
request:
webui:
build:
context: .
args:
SERVICE: request
SERVICE: webui
env_file:
./services/webui/.env
restart: unless-stopped
interface:
build:
context: .
args:
SERVICE: interface
depends_on:
- "database"
- "torrent_client"
- "torrent"
- "webui"
env_file:
- ./services/request/.env
- ./services/interface/.env
environment:
DATABASE: "autoplex"
links:
- "database"
- "torrent_client"
- "torrent"
ports:
- 3200:3200
- 3200:3200 # Web server
- 3250:3250 # WebSocket server
restart: unless-stopped
secrets:
- app_key
- discord_bot_key
- mysql_root_password
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex
plex:
build:
context: .
args:
SERVICE: plex
env_file:
- ./services/plex/.env
environment:
DATABASE: "autoplex"
restart: unless-stopped
secrets:
- mysql_root_password
- plex_token
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex
search:
build:
context: .
args:
SERVICE: search
env_file:
- ./services/search/.env
restart: unless-stopped
secrets:
- tmdb_key
- tvdb_key
- tvdb_pin
user: ${UID}:${GID}
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex
seeker:
manager:
build:
context: .
args:
SERVICE: seeker
SERVICE: manager
depends_on:
- "database"
- "torrent_client"
env_file:
- ./services/seeker/.env
- "torrent"
environment:
DATABASE: "autoplex"
links:
- "database"
- "torrent_client"
- "torrent"
restart: unless-stopped
secrets:
- mysql_root_password
user: ${UID}:${GID}
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex
torrent_webui:
torrent_rest:
build:
context: .
args:
SERVICE: torrent-webui
SERVICE: torrent-rest
depends_on:
- "database"
- "torrent_client"
- "torrent"
env_file:
- ./services/torrent-webui/.env
links:
- "database"
- "torrent_client"
- ./services/torrent-rest/.env
restart: unless-stopped
ports:
- 3300:3300
secrets:
- app_key
- mysql_root_password
user: ${UID}:${GID}
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex
torrent_search:
build:
context: .
args:
SERVICE: torrent-search
restart: unless-stopped
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex
torrent_client:
torrent:
build:
context: .
args:
BASE: base-slim
SERVICE: torrent-client
BASE: slim
SERVICE: torrent
depends_on:
- "database"
- "vpn"
env_file:
- ./services/torrent-client/.env
environment:
DATABASE: "autoplex_torrent"
healthcheck:
test: ["CMD", "ping", "-q", "-c1", "google.com"]
interval: 5m
@ -91,7 +141,7 @@ services:
restart: unless-stopped
secrets:
- mysql_root_password
user: ${UID}:${GID}
user: ${USER_ID}:${GROUP_ID}
volumes:
- var:/var/autoplex


+ 9
- 2
docker/scripts/export_builds.sh View File

@ -3,7 +3,14 @@
# Create the exported directory
mkdir -p build
# Locate services/packages and grab only the built files + package.json
for file in $(find . -regex '.\/\(services\|packages\)\/.*\/\(dist\|lib\)'); do
if [ "$1" = "alpine" ]; then
REGEX='\./\(\(api\|packages\)/[^/]\+/dist/lib\|services/[^/]\+/dist\)'
else
REGEX='\./\(\(api\|packages\)/[^/]+/dist/lib\|services/[^/]+/dist\)'
fi
# Locate services/packages and grab only the built files (excluding types if any)
for file in $(find . -regex $REGEX); do
echo $file;
cp --parents -R $file build;
done

+ 9
- 2
docker/scripts/export_deps.sh View File

@ -3,7 +3,14 @@
# Create the exported directory
mkdir -p build
# Locate services/packages and grab only the built files + package.json
for file in $(find . -regex '.\/\(services\|packages\)\/.*\/\(package.json\|node_modules\)'); do
if [ "$1" = "alpine" ]; then
REGEX='\./\(api\|services\|packages\)/[^/]\+/\(package.json\|node_modules\)'
else
REGEX='\./\(api\|services\|packages\)/[^/]+/\(package.json\|node_modules\)'
fi
# Locate services/packages and grab only the dependencies + package.json
for file in $(find . -regex $REGEX); do
echo $file;
cp --parents -R $file build;
done

+ 5
- 0
env.sh View File

@ -0,0 +1,5 @@
#!/bin/bash
# Enable Docker BuildKit
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

+ 196
- 0
jest.config.ts View File

@ -0,0 +1,196 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/en/configuration.html
*/
export default {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/tmp/jest_rs",
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// A set of global variables that need to be available in all test environments
globals: {},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
moduleFileExtensions: [
"js",
"json",
"jsx",
"ts",
"tsx",
"node"
],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
preset: "ts-jest",
// Run tests from one or more projects
// projects: undefined,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state between every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: undefined,
// Automatically restore mock state between every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
// testEnvironment: "node",
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
testRegex: "(test/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
// This option allows use of a custom test runner
// testRunner: "jasmine2",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.tsx?$": "ts-jest"
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
verbose: true,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
};

+ 1
- 0
lerna.json View File

@ -1,5 +1,6 @@
{
"packages": [
"api/*",
"packages/*",
"services/*"
],


+ 15
- 3
package.json View File

@ -3,13 +3,25 @@
"private": true,
"scripts": {
"build": "lerna run build",
"build:packages": "lerna run build --scope=@ldt/package-*",
"build:services": "lerna run build --scope=@ldt/service-*",
"build:api": "lerna run build --scope=@autoplex-api/*",
"build:packages": "lerna run build --scope=@autoplex/*",
"build:services": "lerna run build --scope=@autoplex-service/*",
"export": "rimraf ./build && yarn run export:deps && yarn run export:builds",
"export:deps": "/bin/sh ./docker/scripts/export_deps.sh",
"export:builds": "/bin/sh ./docker/scripts/export_builds.sh"
},
"devDependencies": {
"lerna": "^4.0.0"
"@types/jest": "^26.0.23",
"@types/node": "^15.12.2",
"@zerollup/ts-transform-paths": "^1.7.18",
"jest": "^26.5.3",
"lerna": "^4.0.0",
"nodemon": "^2.0.7",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.9.0",
"ttypescript": "^1.5.12",
"typescript": "^4.3.2"
}
}

+ 21
- 0
packages/database/package.json View File

@ -0,0 +1,21 @@
{
"name": "@autoplex/database",
"version": "0.0.0",
"main": "dist/lib/index.js",
"types": "dist/typings/index.d.ts",
"license": "MIT",
"scripts": {
"build": "yarn run clean && tsc",
"clean": "rimraf ./dist"
},
"dependencies": {
"@autoplex/microservice": "^0.0.0",
"@autoplex/utils": "^0.0.0",
"bcrypt": "^5.0.1",
"mysql": "^2.18.1",
"typeorm": "^0.2.32"
},
"devDependencies": {
"@types/bcrypt": "^3.0.1"
}
}

+ 83
- 0
packages/database/src/DatabaseService.ts View File

@ -0,0 +1,83 @@
import { InternalService, Microservice } from "@autoplex/microservice";
import { env, secret } from "@autoplex/utils";
import { createConnection, Connection, EntitySchema } from "typeorm";
import * as DB from "./constants";
import * as entities from "./entities";
/**
* The type for entity schemas
*/
export type EntitySchemaTypes = string|Function|EntitySchema<any>;
/**
* A convenience database service
*/
export class DatabaseService<M extends Microservice = Microservice> extends InternalService<M>
{
/**
* The name of the service
*/
public readonly NAME = "Database";
/**
* The active database connection
*/
public connection!: Connection;
/**
* The function used to create the connection
* This is important because inheriting this service to provide custom entity types will not get
* the connection stored in the correct connection manager without overriding this explicitly.
*/
protected createConnection = createConnection;
/**
* The database entities
*/
protected entities: EntitySchemaTypes[] = Object.values(entities);
/**
* Boot the database service
*/
public override async boot() {
let password = await secret(DB.DATABASE_PASSWORD_FILE);
let database = env("DATABASE");
this.connection = await this.connectToDatabase(
DB.DATABASE_TYPE,
DB.DATABASE_HOST,
DB.DATABASE_PORT,
DB.DATABASE_USER,
password,
database,
this.entities
);
}
/**
* Shutdown the database service
*/
public override async shutdown() {
await this.connection.close();
}
/**
* A convenience function to connect to the database
*/
protected async connectToDatabase(type: "mysql"|"mariadb", host: string, port: number,
user: string, password: string, database: string,
entities: EntitySchemaTypes[])
{
// Create the database connection
return await this.createConnection({
type : type,
host : host,
port : port,
username : user,
password : password,
database : database,
// synchronize: process.env["NODE_ENV"] != "production",
synchronize: true, // Seems stable enough for my liking
entities
});
}
}

+ 24
- 0
packages/database/src/constants.ts View File

@ -0,0 +1,24 @@
/**
* The type of the database being used
*/
export const DATABASE_TYPE: "mysql"|"mariadb" = "mysql";
/**
* The database host (Docker service name)
*/
export const DATABASE_HOST = "database";
/**
* The databse port
*/
export const DATABASE_PORT = 3306;
/**
* The database username
*/
export const DATABASE_USER = "root";
/**
* The password file for the database
*/
export const DATABASE_PASSWORD_FILE = "/run/secrets/mysql_root_password";

services/request/src/server/database/entities/DiscordAccount.ts → packages/database/src/entities/DiscordAccount.ts View File


services/request/src/server/database/entities/DiscordChannel.ts → packages/database/src/entities/DiscordChannel.ts View File


services/request/src/server/database/entities/DiscordLinkRequest.ts → packages/database/src/entities/DiscordLinkRequest.ts View File


services/request/src/server/database/entities/DiscordRequest.ts → packages/database/src/entities/DiscordRequest.ts View File


services/seeker/src/database/entities/MovieInfo.ts → packages/database/src/entities/MovieInfo.ts View File


services/request/src/server/database/entities/MovieQuota.ts → packages/database/src/entities/MovieQuota.ts View File


services/request/src/server/database/entities/MovieTicket.ts → packages/database/src/entities/MovieTicket.ts View File


services/request/src/server/database/entities/MovieTorrent.ts → packages/database/src/entities/MovieTorrent.ts View File


services/request/src/server/database/entities/PlexMovie.ts → packages/database/src/entities/PlexMovie.ts View File


services/request/src/server/database/entities/RegisterToken.ts → packages/database/src/entities/RegisterToken.ts View File


services/request/src/server/database/entities/User.ts → packages/database/src/entities/User.ts View File


services/request/src/server/database/entities/index.ts → packages/database/src/entities/index.ts View File


+ 3
- 0
packages/database/src/index.ts View File

@ -0,0 +1,3 @@
export * from "./constants";
export * from "./entities";
export * from "./DatabaseService";

+ 10
- 0
packages/database/tsconfig.json View File

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/lib",
"declarationDir": "./dist/typings",
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}

+ 808
- 0
packages/database/yarn.lock View File

@ -0,0 +1,808 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@mapbox/node-pre-gyp@^1.0.0":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.4.tgz#6c76e7a40138eac39e1a4dc869a083e43e236c00"
integrity sha512-M669Qo4nRT7iDmQEjQYC7RU8Z6dpz9UmSbkJ1OFEja3uevCdLKh7IZZki7L1TZj02kRyl82snXFY8QqkyfowrQ==
dependencies:
detect-libc "^1.0.3"
https-proxy-agent "^5.0.0"
make-dir "^3.1.0"
node-fetch "^2.6.1"
nopt "^5.0.0"
npmlog "^4.1.2"
rimraf "^3.0.2"
semver "^7.3.4"
tar "^6.1.0"
"@sqltools/formatter@^1.2.2":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.3.tgz#1185726610acc37317ddab11c3c7f9066966bd20"
integrity sha512-O3uyB/JbkAEMZaP3YqyHH7TMnex7tWyCbCI4EfJdOCoN6HIhqdJBWTM6aCCiWQ/5f5wxjgU735QAIpJbjDvmzg==
"@types/bcrypt@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@types/bcrypt/-/bcrypt-3.0.1.tgz#9c767594e31aa1c4ce78d23aa4351984403ca28f"
integrity sha512-SwBrq5wb6jXP0o3O3jStdPWbKpimTImfdFD/OZE3uW+jhGpds/l5wMX9lfYOTDOa5Bod2QmOgo9ln+tMp2XP/w==
"@types/zen-observable@^0.8.2":
version "0.8.2"
resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.2.tgz#808c9fa7e4517274ed555fa158f2de4b4f468e71"
integrity sha512-HrCIVMLjE1MOozVoD86622S7aunluLb2PJdPfb3nYiEtohm8mIB/vyv0Fd37AdeMFrTUQXEunw78YloMA3Qilg==
abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==
agent-base@6:
version "6.0.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==
dependencies:
debug "4"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8=
ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=
ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
dependencies:
color-convert "^2.0.1"
any-promise@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
integrity sha1-q8av7tzqUugJzcA3au0845Y10X8=
app-root-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.0.0.tgz#210b6f43873227e18a4b810a032283311555d5ad"
integrity sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw==
aproba@^1.0.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"
integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==
are-we-there-yet@~1.1.2:
version "1.1.5"
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21"
integrity sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==
dependencies:
delegates "^1.0.0"
readable-stream "^2.0.6"
argparse@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
bcrypt@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/bcrypt/-/bcrypt-5.0.1.tgz#f1a2c20f208e2ccdceea4433df0c8b2c54ecdf71"
integrity sha512-9BTgmrhZM2t1bNuDtrtIMVSmmxZBrJ71n8Wg+YgdjHuIWYF7SjjmCPZFB+/5i/o/PIeRpwVJR3P+NrpIItUjqw==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.0"
node-addon-api "^3.1.0"
bignumber.js@9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075"
integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
chalk@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=
dependencies:
ansi-styles "^2.2.1"
escape-string-regexp "^1.0.2"
has-ansi "^2.0.0"
strip-ansi "^3.0.0"
supports-color "^2.0.0"
chalk@^4.0.0, chalk@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad"
integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chownr@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece"
integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==
cli-highlight@^2.1.10:
version "2.1.11"
resolved "https://registry.yarnpkg.com/cli-highlight/-/cli-highlight-2.1.11.tgz#49736fa452f0aaf4fae580e30acb26828d2dc1bf"
integrity sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg==
dependencies:
chalk "^4.0.0"
highlight.js "^10.7.1"
mz "^2.4.0"
parse5 "^5.1.1"
parse5-htmlparser2-tree-adapter "^6.0.0"
yargs "^16.0.0"
cliui@^7.0.2:
version "7.0.4"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
dependencies:
color-name "~1.1.4"
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
console-control-strings@^1.0.0, console-control-strings@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
debug@4, debug@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee"
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==
dependencies:
ms "2.1.2"
delegates@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=
detect-libc@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=
dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
escape-string-regexp@^1.0.2:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
figlet@^1.1.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/figlet/-/figlet-1.5.0.tgz#2db4d00a584e5155a96080632db919213c3e003c"
integrity sha512-ZQJM4aifMpz6H19AW1VqvZ7l4pOE9p7i/3LyxgO2kp+PO/VcDYNqIHEMtkccqIhTXMKci4kjueJr/iCQEaT/Ww==
fs-minipass@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb"
integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==
dependencies:
minipass "^3.0.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
gauge@~2.7.3:
version "2.7.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=
dependencies:
aproba "^1.0.3"
console-control-strings "^1.0.0"
has-unicode "^2.0.0"
object-assign "^4.1.0"
signal-exit "^3.0.0"
string-width "^1.0.1"
strip-ansi "^3.0.1"
wide-align "^1.1.0"
get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
glob@^7.1.3, glob@^7.1.6:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=
dependencies:
ansi-regex "^2.0.0"
has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
has-unicode@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9"
integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=
highlight.js@^10.7.1:
version "10.7.2"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.2.tgz#89319b861edc66c48854ed1e6da21ea89f847360"
integrity sha512-oFLl873u4usRM9K63j4ME9u3etNF0PLiJhSQ8rdfuL51Wn3zkD6drf9ZW0dOzjnZI22YYG24z30JcmfCZjMgYg==
https-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
dependencies:
agent-base "6"
debug "4"
ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2, inherits@^2.0.1, inherits@~2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
is-fullwidth-code-point@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb"
integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs=
dependencies:
number-is-nan "^1.0.0"
is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
is-fullwidth-code-point@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
js-yaml@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
argparse "^2.0.1"
lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"
make-dir@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==
dependencies:
semver "^6.0.0"
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
minipass@^3.0.0:
version "3.1.3"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.3.tgz#7d42ff1f39635482e15f9cdb53184deebd5815fd"
integrity sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==
dependencies:
yallist "^4.0.0"
minizlib@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==
dependencies:
minipass "^3.0.0"
yallist "^4.0.0"
mkdirp@^1.0.3, mkdirp@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
ms@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
mysql@^2.18.1:
version "2.18.1"
resolved "https://registry.yarnpkg.com/mysql/-/mysql-2.18.1.tgz#2254143855c5a8c73825e4522baf2ea021766717"
integrity sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==
dependencies:
bignumber.js "9.0.0"
readable-stream "2.3.7"
safe-buffer "5.1.2"
sqlstring "2.3.1"
mz@^2.4.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32"
integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==
dependencies:
any-promise "^1.0.0"
object-assign "^4.0.1"
thenify-all "^1.0.0"
node-addon-api@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.1.0.tgz#98b21931557466c6729e51cb77cd39c965f42239"
integrity sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==
node-fetch@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
nopt@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
integrity sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==
dependencies:
abbrev "1"
npmlog@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b"
integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==
dependencies:
are-we-there-yet "~1.1.2"
console-control-strings "~1.1.0"
gauge "~2.7.3"
set-blocking "~2.0.0"
number-is-nan@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
object-assign@^4.0.1, object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
parent-require@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/parent-require/-/parent-require-1.0.0.tgz#746a167638083a860b0eef6732cb27ed46c32977"
integrity sha1-dGoWdjgIOoYLDu9nMssn7UbDKXc=
parse5-htmlparser2-tree-adapter@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6"
integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==
dependencies:
parse5 "^6.0.1"
parse5@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.1.tgz#f68e4e5ba1852ac2cadc00f4555fff6c2abb6178"
integrity sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==
parse5@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b"
integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
readable-stream@2.3.7, readable-stream@^2.0.6:
version "2.3.7"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57"
integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
reflect-metadata@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
glob "^7.1.3"
safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
safe-buffer@^5.0.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
sax@>=0.6.0:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
semver@^6.0.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
semver@^7.3.4:
version "7.3.5"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
dependencies:
lru-cache "^6.0.0"
set-blocking@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
sha.js@^2.4.11:
version "2.4.11"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7"
integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==
dependencies:
inherits "^2.0.1"
safe-buffer "^5.0.1"
signal-exit@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==
sqlstring@2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.1.tgz#475393ff9e91479aea62dcaf0ca3d14983a7fb40"
integrity sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=
string-width@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=
dependencies:
code-point-at "^1.0.0"
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"
"string-width@^1.0.2 || 2":
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
dependencies:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"
string-width@^4.1.0, string-width@^4.2.0:
version "4.2.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.0"
string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
dependencies:
safe-buffer "~5.1.0"
strip-ansi@^3.0.0, strip-ansi@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=
dependencies:
ansi-regex "^2.0.0"
strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8=
dependencies:
ansi-regex "^3.0.0"
strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
dependencies:
ansi-regex "^5.0.0"
supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=
supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"
tar@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.0.tgz#d1724e9bcc04b977b18d5c573b333a2207229a83"
integrity sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==
dependencies:
chownr "^2.0.0"
fs-minipass "^2.0.0"
minipass "^3.0.0"
minizlib "^2.1.1"
mkdirp "^1.0.3"
yallist "^4.0.0"
thenify-all@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726"
integrity sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=
dependencies:
thenify ">= 3.1.0 < 4"
"thenify@>= 3.1.0 < 4":
version "3.3.1"
resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f"
integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==
dependencies:
any-promise "^1.0.0"
tslib@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==
typeorm@^0.2.32:
version "0.2.32"
resolved "https://registry.yarnpkg.com/typeorm/-/typeorm-0.2.32.tgz#544dbfdfe0cd0887548d9bcbd28527ea4f4b3c9b"
integrity sha512-LOBZKZ9As3f8KRMPCUT2H0JZbZfWfkcUnO3w/1BFAbL/X9+cADTF6bczDGGaKVENJ3P8SaKheKmBgpt5h1x+EQ==
dependencies:
"@sqltools/formatter" "^1.2.2"
app-root-path "^3.0.0"
buffer "^6.0.3"
chalk "^4.1.0"
cli-highlight "^2.1.10"
debug "^4.3.1"
dotenv "^8.2.0"
glob "^7.1.6"
js-yaml "^4.0.0"
mkdirp "^1.0.4"
reflect-metadata "^0.1.13"
sha.js "^2.4.11"
tslib "^2.1.0"
xml2js "^0.4.23"
yargonaut "^1.1.4"
yargs "^16.2.0"
zen-observable-ts "^1.0.0"
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
wide-align@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457"
integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==
dependencies:
string-width "^1.0.2 || 2"
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
xml2js@^0.4.23:
version "0.4.23"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66"
integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==
dependencies:
sax ">=0.6.0"
xmlbuilder "~11.0.0"
xmlbuilder@~11.0.0:
version "11.0.1"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"
integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==
y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yargonaut@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/yargonaut/-/yargonaut-1.1.4.tgz#c64f56432c7465271221f53f5cc517890c3d6e0c"
integrity sha512-rHgFmbgXAAzl+1nngqOcwEljqHGG9uUZoPjsdZEs1w5JW9RXYzrSvH/u70C1JE5qFi0qjsdhnUX/dJRpWqitSA==
dependencies:
chalk "^1.1.1"
figlet "^1.1.1"
parent-require "^1.0.0"
yargs-parser@^20.2.2:
version "20.2.7"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a"
integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==
yargs@^16.0.0, yargs@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
dependencies:
cliui "^7.0.2"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.0"
y18n "^5.0.5"
yargs-parser "^20.2.2"
zen-observable-ts@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/zen-observable-ts/-/zen-observable-ts-1.0.0.tgz#30d1202b81d8ba4c489e3781e8ca09abf0075e70"
integrity sha512-KmWcbz+9kKUeAQ8btY8m1SsEFgBcp7h/Uf3V5quhan7ZWdjGsf0JcGLULQiwOZibbFWnHkYq8Nn2AZbJabovQg==
dependencies:
"@types/zen-observable" "^0.8.2"
zen-observable "^0.8.15"
zen-observable@^0.8.15:
version "0.8.15"
resolved "https://registry.yarnpkg.com/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15"
integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==

+ 11
- 0
packages/ipc/jest.config.ts View File

@ -0,0 +1,11 @@
import base from "../../jest.config";
export default {
...base,
name: "@autoplex/ipc",
displayName: "Package: IPC",
moduleNameMapper: {
'^@src/(.*)$': '<rootDir>/src/$1',
'^@test@/(.*)$': '<rootDir>/test/$1'
}
}

+ 22
- 0
packages/ipc/package.json View File

@ -0,0 +1,22 @@
{
"name": "@autoplex/ipc",
"version": "0.1.0",
"main": "dist/lib/index.js",
"types": "dist/typings/index.d.ts",
"license": "MIT",
"scripts": {
"build": "yarn run clean && ttsc",
"clean": "rimraf ./coverage ./dist",
"coverage": "yarn test --coverage",
"test": "jest --silent",
"test:verbose": "jest"
},
"devDependencies": {
"@types/node-ipc": "^9.1.3"
},
"dependencies": {
"@autoplex/microservice": "^0.1.0",
"cancelable-promise": "^4.2.1",
"node-ipc": "^9.1.4"
}
}

+ 39
- 0
packages/ipc/src/AbstractClient.ts View File

@ -0,0 +1,39 @@
import { AbstractConnection } from "./AbstractConnection";
import { AbstractMethodMap } from "./AbstractMethodMap";
import { IMethodMap } from "./schema";
export abstract class AbstractClient<
LocalMethods extends IMethodMap,
RemoteMethods extends IMethodMap,
Connection extends AbstractConnection<RemoteMethods>
> extends AbstractMethodMap<LocalMethods>
{
/**
* The client connection instance
*/
protected connection?: Connection;
/**
* Connect to the server
*/
public abstract connect(): void;
/**
* Disconnect from the server
*/
public abstract disconnect(): void;
/**
* Invoked when a connection is established
*/
protected onConnect() {
// no-op
}
/**
* Invoked when a connection is dropped
*/
protected onDisconnect() {
// no-op
}
}

+ 151
- 0
packages/ipc/src/AbstractConnection.ts View File

@ -0,0 +1,151 @@
import EventEmitter from "events";
import { AbstractMethodMap } from "./AbstractMethodMap";
import { RequestTimeoutError } from "./errors";
import { IMethodMap, IPacket } from "./schema";
/**
* Declare EventEmitter types
*/
interface Events {
"disconnect": () => void
}
/**
* Torrent IPC events
*/
export declare interface AbstractConnection<RemoteMethods extends IMethodMap> {
on<U extends keyof Events>(event: U, listener: Events[U]): this,
emit<U extends keyof Events>(event: U, ...args: Parameters<Events[U]>): boolean
}
export abstract class AbstractConnection<RemoteMethods extends IMethodMap> extends EventEmitter
{
/**
* Disconnect from the server
*/
protected abstract disconnect(): void;
/**
* Read the received packet
*/
protected abstract read(rawPacket: any): IPacket;
/**
* Write the message
*/
protected abstract write(packet: IPacket): void;
// ---------------------------------------------------------------------------------------------
/**
* Store a reference to the request handler
*/
#requestHandler: AbstractMethodMap<any>;
/**
* The current request ID
*/
#requestId: number = 0;
/**
* Store a map of the requests
*/
#pendingRequests: Map<number, (result: any) => void> = new Map();
/**
* Create a new connection
*/
public constructor(requestHandler: AbstractMethodMap<any>) {
super();
this.#requestHandler = requestHandler;
}
/**
* Get the next request ID
*/
#nextRequestId() {
this.#requestId = (this.#requestId + 1) % Number.MAX_SAFE_INTEGER;
return this.#requestId;
}
/**
* Receive and handle the packet
*/
protected receive(rawPacket: any) {
let packet = this.read(rawPacket);
if (packet.method !== undefined) {
this.fulfillRequest(packet.method, packet.args, packet.requestId);
return;
}
if (packet.requestId !== undefined) {
this.fulfillResponse(packet.requestId, packet.result);
return;
}
}
/**
* Handle the received request
*/
protected async fulfillRequest(method: string, args?: any[], requestId?: number) {
let result = await this.#requestHandler.invoke(method, args ?? []);
if (requestId !== undefined) {
this.write({ requestId, result });
}
}
/**
* Fulfill a response
*/
protected fulfillResponse(requestId: number, result?: any) {
let resolve = this.#pendingRequests.get(requestId);
if (resolve === undefined) {
return;
}
}
// Public Interface ----------------------------------------------------------------------------
/**
* Close the current connection
*/
public close() {
this.disconnect();
this.emit("disconnect");
}
/**
* Send a message
*/
public send<K extends keyof RemoteMethods>(method: K, args: Parameters<RemoteMethods[K]>) {
this.write({
method: method.toString(),
args: args.length > 0 ? args : undefined
});
}
/**
* Create a promise to send a request
*/
public request<K extends keyof RemoteMethods>(method: K, args: Parameters<RemoteMethods[K]>, timeout: number|null = 5000) {
return new Promise<ReturnType<RemoteMethods[K]>>((resolve, reject) => {
let timeoutId: NodeJS.Timeout;
const requestId = this.#nextRequestId();
const cleanup = () => {
clearTimeout(timeoutId);
this.#pendingRequests.delete(requestId);
};
const fulfill = (result: ReturnType<RemoteMethods[K]>) => {
cleanup();
resolve(result);
};
if (timeout !== null) {
timeoutId = setTimeout(() => {
cleanup();
reject(new RequestTimeoutError());
}, timeout);
}
this.#pendingRequests.set(requestId, fulfill);
this.send(method, args);
});
}
}

+ 20
- 0
packages/ipc/src/AbstractMethodMap.ts View File

@ -0,0 +1,20 @@
import { MethodNotFoundError } from "./errors";
import { IMethodMap } from "./schema";
export abstract class AbstractMethodMap<T extends IMethodMap = {}>
{
/**
* The method mapping
*/
protected abstract methodMap: T;
/**
* Invoke a mapped method
*/
public invoke<K extends keyof T>(name: K, args: Parameters<T[K]>) {
if (this.methodMap[name] === undefined) {
throw new MethodNotFoundError(name);
}
return this.methodMap[name].apply(this, args);
}
}

+ 67
- 0
packages/ipc/src/AbstractServer.ts View File

@ -0,0 +1,67 @@
import { AbstractConnection } from "./AbstractConnection";
import { AbstractMethodMap } from "./AbstractMethodMap";
import { IMethodMap } from "./schema";
type PrependConnection<T extends IMethodMap> = {
[K in keyof T]: (connection: string, ...args: Parameters<T[K]>) => ReturnType<T[K]>
};
export abstract class AbstractServer<
Connection extends AbstractConnection<RemoteMethods>,
LocalMethods extends IMethodMap,
RemoteMethods extends IMethodMap
> extends AbstractMethodMap<PrependConnection<LocalMethods>>
{
/**
* The list of active connections
*/
protected connections: Connection[] = [];
/**
* Start accepting new connections
*/
public abstract start(): void;
/**
* Stop accepting new connections
*/
public abstract stop(): void;
/**
* Close all established connections
*/
public close() {
for (let connection of this.connections) {
connection.close();
}
this.connections = [];
}
/**
* Invoked when a client connects to the server
*/
public acceptConnection(connection: Connection) {
connection.on("disconnect", () => this.onDisconnect(connection));
this.connections.push(connection);
}
/**
* Invoked when the client disconnects from the server
*/
protected onDisconnect(connection: Connection) {
let index: number;
while (-1 !== (index = this.connections.indexOf(connection))) {
this.connections[index].removeAllListeners();
this.connections.splice(index, 1);
}
}
/**
* Broadcast a message to all clients
*/
public broadcast<K extends keyof RemoteMethods>(method: K, args: Parameters<RemoteMethods[K]>) {
for (let connection of this.connections) {
connection.send(method, args);
}
}
}

+ 14
- 0
packages/ipc/src/errors.ts View File

@ -0,0 +1,14 @@
export class MethodNotFoundError extends Error {
public constructor(method: string|number|symbol) {
super(`Attempted to invoke undefined method: '${method.toString()}'`);
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
}
}
export class RequestTimeoutError extends Error {
public constructor() {
super("timeout");
Object.setPrototypeOf(this, RequestTimeoutError.prototype);
}
}

+ 5
- 0
packages/ipc/src/index.ts View File

@ -0,0 +1,5 @@
export * from "./AbstractConnection";
export * from "./AbstractClient";
export * from "./AbstractMethodMap";
export * from "./errors";
export * from "./schema";

+ 23
- 0
packages/ipc/src/schema.ts View File

@ -0,0 +1,23 @@
import RawIPC from "node-ipc";
/**
* A generic function/method mapping
*/
export interface IMethodMap {
[name: string]: (...args: any[]) => any
}
/**
* The packet structure
*/
export interface IPacket {
requestId?: number,
method? : string,
args? : any[],
result? : any
}
/**
* HOLY @#$@% WHOEVER MADE THE TYPES FOR `node-ipc` SHOULDB BE HANGED
*/
export type IPC = InstanceType<(typeof RawIPC)["IPC"]>;

+ 45
- 0
packages/ipc/test/unit/AbstractConnection.spec.ts View File

@ -0,0 +1,45 @@
import { AbstractConnection, AbstractMethodMap, IPacket } from "../../src";
type MethodMap = {
sendTest(value: number): void
};
class MockRequestHandler extends AbstractMethodMap {
methodMap = {};
}
class MockConnection extends AbstractConnection<MethodMap> {
public disconnect = () => {};
public read = (rawPacket: any) => <IPacket>rawPacket;
public write = jest.fn();
}
class MockConnectionWithReply extends AbstractConnection<MethodMap> {
public disconnect = () => {};
public read = (rawPacket: any) => <IPacket>rawPacket;
public write(packet: IPacket) {
this.receive({
requestId: packet.requestId,
result: 100
});
}
}
describe("Abstract IPC Connections", () => {
it("Should write complete packet", () => {
let connection = new MockConnection(new MockRequestHandler());
connection.send("sendTest", [10]);
expect(connection.write).toBeCalledWith(expect.objectContaining({
method: "sendTest",
args: [10]
}));
});
it("Request packet should timeout", async () => {
let connection = new MockConnection(new MockRequestHandler());
expect(connection.request("sendTest", [25])).rejects.toMatch("timeout");
});
it("Request should be resolved", async () => {
let connection = new MockConnectionWithReply(new MockRequestHandler());
expect(connection.request("sendTest", [25])).resolves.toEqual(100);
});
});

+ 23
- 0
packages/ipc/test/unit/AbstractMethodMap.spec.ts View File

@ -0,0 +1,23 @@
import { AbstractMethodMap } from "../../src";
class TestMap extends AbstractMethodMap<{ doSomething(a: number, b: number): number }> {
public mockFn = jest.fn();
public methodMap = {
doSomething: this.doSomething
};
public doSomething(a: number, b: number) {
this.mockFn(); // Ensure the correct 'this' context
return a + b;
}
public publicInvoke() {
this.invoke("doSomething", [5, 10]);
}
}
describe("Abstract Method Map", () => {
it("Invoke mapped method", () => {
let map = new TestMap();
map.invoke("doSomething", [5, 10]);
expect(map.mockFn).toHaveBeenCalled()
});
});

+ 7
- 0
packages/ipc/tsconfig.json View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "dist/lib",
"declarationDir": "dist/typings"
}
}

+ 51
- 0
packages/ipc/yarn.lock View File

@ -0,0 +1,51 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node-ipc@^9.1.3":
version "9.1.5"
resolved "https://registry.yarnpkg.com/@types/node-ipc/-/node-ipc-9.1.5.tgz#0f9dac03fe6c96b6ff379725faf20d8a97eb00fa"
integrity sha512-xxYUVj/Y8fNkxQlvndVeWlL99wAF4KwISsRy21RSAAT/SKyrh+X3/BZXHcM/ZJPNri9h1JWw58wDKT1zr2pXVw==
dependencies:
"@types/node" "*"
"@types/node@*":
version "16.3.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.2.tgz#655432817f83b51ac869c2d51dd8305fb8342e16"
integrity sha512-jJs9ErFLP403I+hMLGnqDRWT0RYKSvArxuBVh2veudHV7ifEC1WAmjJADacZ7mRbA2nWgHtn8xyECMAot0SkAw==
cancelable-promise@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/cancelable-promise/-/cancelable-promise-4.2.1.tgz#b02f79c5dde2704acfff1bc1ac2b4090f55541fe"
integrity sha512-PJZ/000ocWhPZQBAuNewAOMA2WEkJ8RhXI6AxeGLiGdW8EYDmumzo9wKyNgjDgxc1q/HbXuTdlcI+wXrOe/jMw==
easy-stack@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/easy-stack/-/easy-stack-1.0.1.tgz#8afe4264626988cabb11f3c704ccd0c835411066"
integrity sha512-wK2sCs4feiiJeFXn3zvY0p41mdU5VUgbgs1rNsc/y5ngFUijdWd+iIN8eoyuZHKB8xN6BL4PdWmzqFmxNg6V2w==
event-pubsub@4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/event-pubsub/-/event-pubsub-4.3.0.tgz#f68d816bc29f1ec02c539dc58c8dd40ce72cb36e"
integrity sha512-z7IyloorXvKbFx9Bpie2+vMJKKx1fH1EN5yiTfp8CiLOTptSYy1g8H4yDpGlEdshL1PBiFtBHepF2cNsqeEeFQ==
js-message@1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/js-message/-/js-message-1.0.7.tgz#fbddd053c7a47021871bb8b2c95397cc17c20e47"
integrity sha512-efJLHhLjIyKRewNS9EGZ4UpI8NguuL6fKkhRxVuMmrGV2xN/0APGdQYwLFky5w9naebSZ0OwAGp0G6/2Cg90rA==
js-queue@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/js-queue/-/js-queue-2.0.2.tgz#0be590338f903b36c73d33c31883a821412cd482"
integrity sha512-pbKLsbCfi7kriM3s1J4DDCo7jQkI58zPLHi0heXPzPlj0hjUsm+FesPUbE0DSbIVIK503A36aUBoCN7eMFedkA==
dependencies:
easy-stack "^1.0.1"
node-ipc@^9.1.4:
version "9.2.1"
resolved "https://registry.yarnpkg.com/node-ipc/-/node-ipc-9.2.1.tgz#b32f66115f9d6ce841dc4ec2009d6a733f98bb6b"
integrity sha512-mJzaM6O3xHf9VT8BULvJSbdVbmHUKRNOH7zDDkCrA1/T+CVjq2WVIDfLt0azZRXpgArJtl3rtmEozrbXPZ9GaQ==
dependencies:
event-pubsub "4.3.0"
js-message "1.0.7"
js-queue "2.0.2"

+ 3
- 0
packages/microservice/README.md View File

@ -0,0 +1,3 @@
# Microservice
A shared package used to quickly assemble and run microservice applications

+ 11
- 0
packages/microservice/jest.config.ts View File

@ -0,0 +1,11 @@
import base from "../../jest.config";
export default {
...base,
name: "@autoplex/microservice",
displayName: "Package: Micoservice",
moduleNameMapper: {
'^@src/(.*)$': '<rootDir>/src/$1',
'^@test@/(.*)$': '<rootDir>/test/$1'
}
}

+ 14
- 0
packages/microservice/package.json View File

@ -0,0 +1,14 @@
{
"name": "@autoplex/microservice",
"version": "0.1.0",
"main": "dist/lib/index.js",
"types": "dist/typings/index.d.ts",
"license": "MIT",
"scripts": {
"build": "yarn run clean && ttsc",
"clean": "rimraf ./coverage ./dist",
"coverage": "yarn test --coverage",
"test": "jest --silent",
"test:verbose": "jest"
}
}

+ 60
- 0
packages/microservice/src/InternalService.ts View File

@ -0,0 +1,60 @@
import EventEmitter from "events";
import { Microservice } from "./Microservice";
/**
* Define the dispatchable methosd available in the internal service
*/
export type IDispatchableMethods = {
[K in "boot"|"start"|"shutdown"]: () => Promise<void>
}
export abstract class InternalService<M extends Microservice = Microservice> extends EventEmitter implements IDispatchableMethods
{
/**
* The name of the service
*/
public abstract readonly NAME: string;
/**
* Store a reference to the owning microservice instance
*/
readonly #microservice: M;
/**
* Create a new internal service instance
*/
public constructor(microservice: M) {
super();
this.#microservice = microservice;
}
/**
* Boot the service
*/
public async boot() {
// NO-OP
}
/**
* Start the service
*/
public async start() {
// NO-OP
}
/**
* Shutdown the service
*/
public async shutdown() {
// NO-OP
}
// Accessors -----------------------------------------------------------------------------------
/**
* Fetch the reference to the owning microservice instance
*/
public get microservice() {
return this.#microservice;
}
}

+ 246
- 0
packages/microservice/src/Microservice.ts View File

@ -0,0 +1,246 @@
import EventEmitter from "events";
import { IDispatchableMethods, InternalService } from "./InternalService";
import { MicroserviceState } from "./schema";
import { InternalServiceConflictError, InternalServiceNotFoundError } from "./errors";
/**
* The InternalService constructor type
*/
type InternalServiceConstructor<T extends Microservice = Microservice> = new (microservice: T) => InternalService<T>;
/**
* Declare EventEmitter types
*/
interface Events {
"ready": () => void,
"finished": () => void
}
/**
* Torrent IPC events
*/
export declare interface Microservice {
on<U extends keyof Events>(event: U, listener: Events[U]): this,
emit<U extends keyof Events>(event: U, ...args: Parameters<Events[U]>): boolean
}
/**
* The main application class
*/
export class Microservice extends EventEmitter
{
/**
* The exec promise used to wait for quit event
*/
#execPromise?: Promise<number>;
/**
* A handler function to quit the microservice application
*/
#quitHandler?: (value: number | PromiseLike<number>) => void;
/**
* All available services
*/
#services = new Map<ThisType<this>, InternalService<any>>();
/**
* The current state of the microservice
*/
#state: MicroserviceState = MicroserviceState.Idling;
// Event Handling ------------------------------------------------------------------------------
/**
* Invoked when the application has finished booting
*/
protected onStateChange(state: MicroserviceState): void|Promise<void> {
switch(state) {
case MicroserviceState.Running:
this.emit("ready");
break;
case MicroserviceState.Finished:
this.emit("finished");
break;
}
}
// Microservice Management ---------------------------------------------------------------------
/**
* Run the application
*/
public async exec() {
// Exit if not in an idling state
if (this.state !== MicroserviceState.Idling) {
console.error("Cannot exec an already-started microservice");
return 1;
}
// Run the microservice application
let exitCode = await (async () => {
// Create the microservice execution promise to listen for quit events
let hasQuit = false;
this.#execPromise = new Promise<number>(resolve => this.#quitHandler = (exitCode) => {
resolve(exitCode);
console.log("Quit has been invoked");
hasQuit = true;
});
// Boot the microservice and internal services
if (!await this.boot()) { // no need to check for hasQuit
console.error("Failed to boot the microservice");
return 1;
}
// Start the internal services
if (!hasQuit && !await this.start()) {
console.error("Failed to start the microservice");
return 2;
}
// If the application has not quit, we can run the app
let exitCode: number;
if (!hasQuit) {
exitCode = await this.run();
} else {
exitCode = await this.#execPromise;
}
// Shutdown the microservice
if (!await this.shutdown()) {
console.error("Failed to shutdown the microservice");
return 3;
}
return exitCode;
})();
this.state = MicroserviceState.Finished;
return exitCode;
}
/**
* Quit the application
*/
public async quit(code: number = 0) {
if (this.state === MicroserviceState.Idling) {
this.state = MicroserviceState.Finished;
return;
}
if (this.state > MicroserviceState.Running || this.#quitHandler === undefined) {
return;
}
this.#quitHandler(code);
}
// Microservice Internal Handling --------------------------------------------------------------
/**
* Dispatch a method call to the services, returning a boolean indicating the result
*/
protected dispatch<T extends Microservice>(this: T, method: keyof IDispatchableMethods,
onFail: (service: InternalService<T>, error: Error|string) => void)
{
return new Promise<boolean>(resolve => {
let services = Array.from(this.#services.values());
Promise.all(services.map(service => (async () => {
try {
await service[method]();
} catch(e) {
onFail(service, e);
throw e;
}
})()))
.then(() => resolve(true))
.catch(() => resolve(false));
});
}
/**
* Boot the application and all of the services
*/
protected boot() {
console.log("Booting...");
this.state = MicroserviceState.Booting;
return this.dispatch("boot", (service, error) => {
console.error(`Failed to boot service: ${service.NAME}\n`, error);
});
}
/**
* Start the application servvices
*/
protected start() {
console.log("Starting...");
this.state = MicroserviceState.Starting;
return this.dispatch("start", (service, error) => {
console.error(`Failed to start service: ${service.NAME}\n`, error);
});
}
/**
* Run the application and wait for shutdown
*/
protected run() {
console.log("Running.");
this.state = MicroserviceState.Running;
process.on("SIGINT", this.quit.bind(this));
return this.#execPromise!;
}
/**
* Shutdown the application
*/
protected shutdown() {
console.log("Shutting down...");
this.state = MicroserviceState.Quitting;
process.off("SIGINT", this.quit.bind(this));
return this.dispatch("shutdown", (service, error) => {
console.error(`Failed to shutdown service: ${service.NAME}\n`, error);
});
}
// Internal Service Management -----------------------------------------------------------------
/**
* Install InternalServices into the application
*/
public installServices<T extends Microservice>(this: T, InternalServices: InternalServiceConstructor<T>[]) {
for (let InternalServiceClass of InternalServices) {
this.installService(InternalServiceClass);
}
}
/**
* Install a InternalService into the application
*/
public installService<T extends Microservice>(this: T, InternalServiceClass: InternalServiceConstructor<T>) {
if (this.#services.has(InternalServiceClass)) {
throw new InternalServiceConflictError(InternalServiceClass);
}
this.#services.set(InternalServiceClass, new InternalServiceClass(this));
}
// Accessors -----------------------------------------------------------------------------------
/**
* Get an application services instance
*/
public service<T extends Microservice, U extends InternalServiceConstructor<T>>(this: T, InternalServiceClass: U) {
if (!this.#services.has(InternalServiceClass)) {
throw new InternalServiceNotFoundError(InternalServiceClass);
}
return <InstanceType<U>>this.#services.get(InternalServiceClass);
}
/**
* Get the current state of the microservice
*/
public get state() {
return this.#state;
}
/**
* Set the current state and invoke an onChange event
*/
protected set state(state: MicroserviceState) {
this.#state = state;
this.onStateChange(state);
}
}

+ 13
- 0
packages/microservice/src/errors.ts View File

@ -0,0 +1,13 @@
export class InternalServiceConflictError extends Error {
public constructor(internalServiceClass: any) {
super(`Unable to register service '${internalServiceClass}' as it conflicts with an already registered service.`);
Object.setPrototypeOf(this, InternalServiceConflictError.prototype);
}
}
export class InternalServiceNotFoundError extends Error {
public constructor(internalServiceClass: any) {
super(`Internal service not found: ${internalServiceClass}.`);
Object.setPrototypeOf(this, InternalServiceNotFoundError.prototype);
}
}

+ 4
- 0
packages/microservice/src/index.ts View File

@ -0,0 +1,4 @@
export * from "./errors";
export * from "./schema";
export * from "./InternalService";
export * from "./Microservice";

+ 21
- 0
packages/microservice/src/schema.ts View File

@ -0,0 +1,21 @@
/**
* Microservice states
*/
export enum MicroserviceState {
Idling,
Booting,
Starting,
Running,
Quitting,
Finished
}
/**
* Microservice exit codes
*/
export enum ExitCode {
Ok,
BootError,
StartupError,
ShutdownError
}

+ 65
- 0
packages/microservice/test/integration/internal-services.test.ts View File

@ -0,0 +1,65 @@
import { ExitCode, InternalService, Microservice, MicroserviceState } from "../../src";
class MockService<M extends Microservice> extends InternalService<M> {
public NAME = "Mock Service";
public override boot = jest.fn();
public override start = jest.fn();
public override shutdown = jest.fn();
}
class MockServiceBootFail<M extends Microservice> extends InternalService<M> {
public NAME = "Boot Fail";
public override async boot() {
throw new Error();
}
}
class MockServiceStartFail<M extends Microservice> extends InternalService<M> {
public NAME = "Start Fail";
public override async start() {
throw new Error();
}
}
class MockServiceShutdownFail<M extends Microservice> extends InternalService<M> {
public NAME = "Shutdown Fail";
public override async shutdown() {
throw new Error();
}
}
describe("Microservice/Internal Service Integration", () => {
test("Check that internal service state methods have been executed", async () => {
let microservice = new Microservice();
microservice.installService(MockService);
let executing = microservice.exec();
microservice.on("ready", () => microservice.quit());
await executing;
expect(microservice.service(MockService).boot).toHaveBeenCalled();
expect(microservice.service(MockService).start).toHaveBeenCalled();
expect(microservice.service(MockService).shutdown).toHaveBeenCalled();
});
test("Trigger boot failure", async () => {
let microservice = new Microservice();
microservice.installService(MockServiceBootFail);
let exitCode = await microservice.exec();
expect(exitCode).toEqual(ExitCode.BootError);
expect(microservice.state).toEqual(MicroserviceState.Finished);
});
test("Trigger start failure", async () => {
let microservice = new Microservice();
microservice.installService(MockServiceStartFail);
let exitCode = await microservice.exec();
expect(exitCode).toEqual(ExitCode.StartupError);
expect(microservice.state).toEqual(MicroserviceState.Finished);
});
test("Trigger shutdown failure", async () => {
let microservice = new Microservice();
microservice.installService(MockServiceShutdownFail);
let execPromise = microservice.exec();
microservice.on("ready", () => microservice.quit());
let exitCode = await execPromise;
expect(exitCode).toEqual(ExitCode.ShutdownError);
expect(microservice.state).toEqual(MicroserviceState.Finished);
});
});

+ 20
- 0
packages/microservice/test/unit/InternalService.spec.ts View File

@ -0,0 +1,20 @@
import { InternalService, Microservice } from "../../src";
class MockMicroservice extends Microservice {
public readonly customProp: string = "Test property";
}
class MockInternalService<M extends Microservice> extends InternalService<M> { NAME = "Test"; }
describe("InternalService", () => {
test("Get owning microservice instance", () => {
let microservice = new Microservice();
let service = new MockInternalService(microservice);
expect(service.microservice).toBeInstanceOf(Microservice);
});
test("Access properties from custom microservices", () => {
let microservice = new MockMicroservice();
let service = new MockInternalService<MockMicroservice>(microservice);
expect(service.microservice.customProp).toEqual("Test property");
});
});

+ 109
- 0
packages/microservice/test/unit/Microservice.spec.ts View File

@ -0,0 +1,109 @@
import { InternalService, Microservice } from "../../src";
import { InternalServiceConflictError, InternalServiceNotFoundError } from "../../src/errors";
import { ExitCode, MicroserviceState } from "../../src/schema";
class MockInternalService1 extends InternalService<Microservice> { NAME = "1"; }
class MockInternalService2 extends InternalService<Microservice> { NAME = "2"; }
class MockedMicroservice extends Microservice {
public readonly quitState: MicroserviceState;
public hasBooted = false;
public hasStarted = false;
public hasRun = false;
public hasShutdown = false;
public constructor(quitState: MicroserviceState) {
super();
this.quitState = quitState;
}
protected override async boot() {
this.hasBooted = true;
let result = await super.boot();
this.quitState === MicroserviceState.Booting && this.quit(25);
return result;
}
protected override async start() {
this.hasStarted = true;
let result = await super.start();
this.quitState === MicroserviceState.Starting && this.quit(50);
return result;
}
protected override async run() {
this.hasRun = true;
return await super.run();
}
protected override async shutdown() {
this.hasShutdown = true;
let result = super.shutdown();
this.quitState === MicroserviceState.Quitting && this.quit(100);
return result;
}
}
describe("Microservice:", () => {
describe("Internal Service Installation", () => {
test("Install an internal service", () => {
let microservice = new Microservice();
microservice.installServices([MockInternalService1, MockInternalService2]);
expect(microservice.service(MockInternalService1)).toBeInstanceOf(MockInternalService1);
expect(microservice.service(MockInternalService2)).toBeInstanceOf(MockInternalService2);
expect(microservice.service(MockInternalService1)).not.toBeInstanceOf(MockInternalService2);
});
test("Prevent installing already-installed services", () => {
let microservice = new Microservice();
expect(() => microservice.installServices([MockInternalService1, MockInternalService1])).toThrowError(InternalServiceConflictError);
});
test("Fail when accessing non-installed services", () => {
let microservice = new Microservice();
expect(() => microservice.service(MockInternalService1)).toThrowError(InternalServiceNotFoundError);
});
});
describe("Microservice State", () => {
// Quitting
test("Quit before executing process", async () => {
let microservice = new Microservice();
microservice.quit();
expect(microservice.state).toEqual(MicroserviceState.Finished);
expect(await microservice.exec()).toEqual(ExitCode.BootError);
});
test("Quit during boot state", async () => {
let microservice = new MockedMicroservice(MicroserviceState.Booting);
let exitCode = await microservice.exec();
expect(microservice.state).toEqual(MicroserviceState.Finished);
expect(microservice.hasBooted).toBe(true);
expect(microservice.hasShutdown).toBe(true);
expect(microservice.hasStarted).toBe(false);
expect(exitCode).toEqual(25);
});
test("Quit during starting state", async () => {
let microservice = new MockedMicroservice(MicroserviceState.Starting);
let exitCode = await microservice.exec();
expect(microservice.state).toEqual(MicroserviceState.Finished);
expect(microservice.hasBooted).toBe(true);
expect(microservice.hasShutdown).toBe(true);
expect(microservice.hasStarted).toBe(true);
expect(exitCode).toEqual(50);
});
test("Quit during running state", async () => {
let microservice = new MockedMicroservice(MicroserviceState.Running);
let runningPromise = microservice.exec();
setImmediate(() => microservice.quit(75));
let exitCode = await runningPromise;
expect(microservice.state).toEqual(MicroserviceState.Finished);
expect(exitCode).toEqual(75);
});
test("Quit during quitting state", async () => {
let microservice = new MockedMicroservice(MicroserviceState.Quitting);
let runningPromise = microservice.exec();
microservice.quit();
let exitCode = await runningPromise;
expect(microservice.state).toEqual(MicroserviceState.Finished);
expect(exitCode).toEqual(0);
});
});
});

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save