Saga Documentation 0.9.434-4

NPM Packages

NPM packages can be added to Saga and will be available to scripts and jobs. After installing or updating a package, Saga restarts automatically. NPM packages cannot be removed or updated in a VM without restarting. For the Script and Job container to become operational all packages need to be installed, the HTTP Server however will be operational already since it doesn't invoke Scripts and Jobs.

Do not install clientside packages.

See also the real time socket resources for NPM Packages.

HTTP Resources

GET /npm_packages

Lists the installed npm packages. Each package has the following

  • package_name - has to be unique. permitted naming:
    • [@scope/]name
    • [@scope/]name@tag
    • [@scope/]name@version
    • [@scope/]name@version range
    • alias@npm:name
    • git-host:git-user/repo-name
    • git repo url
    • tarball url
  • name - the name you can use in require(...). requires for the package to be already installed.
  • package_json - the package.json
  • error_message - contains error message if install fails
  • failed_install_attempts - amount of failed install attempts

POST

[
   {
      "_id":"5e9306970b2a0d01bb9815cd",
      "name":"@turf/turf",
      "package_name":"@turf/turf",
      "package_json":{ },
      "error_message":null,
      "failed_install_attempts":0,
      "createdAt":"2020-04-12T12:16:23.593Z",
      "updatedAt":"2021-06-08T11:07:58.527Z"
   }
   {
      "_id":"5e3acff40041180067b9e3f1",
      "name":"twilio",
      "package_name":"twilio@3.37.1",
      "package_json":{
         "_from":"twilio@3.37.1",
         "_id":"twilio@3.37.1",
         "_inBundle":false,
         "_integrity":"sha512-BdLOmO2WsQuVh8J8h44mKUE72FTVCFnv60wvEsJqhHgEOi5m2f9Lq7gPE9KFmVLohvPukNrlxhhc4ZSPH+HLyg==",
         "_location":"...",
         "version":"3.37.1"
      },
      "error_message":null,
      "failed_install_attempts":0,
      "createdAt":"2020-02-05T14:23:48.631Z",
      "updatedAt":"2021-06-08T11:07:57.601Z"
   },
   {
      "_id":"5e3ad0382d398e0349e963c9",
      "name":"twitter",
      "package_name":"twitter@1.7.1",
      "package_json":{
         "version":"1.7.1"
      },
      "error_message":null,
      "failed_install_attempts":0,
      "createdAt":"2020-02-05T14:24:56.627Z",
      "updatedAt":"2021-06-08T11:07:58.071Z"
   }
]

POST /npm_packages

Create a new package

POST

{"package_name": "twilio"}

RESPONSE

{
  "_id":"60f75920bfbf860419597581",
  "package_name":"twilio",
  "failed_install_attempts":0,
  "createdAt":"2021-07-20T23:15:44.060Z",
  "updatedAt":"2021-07-20T23:15:44.060Z"
}

PUT /npm_packages/:id

Update a package. Useful to change versions etc.

POST

{"package_name": "twilio@3.37.1"}

RESPONSE

{
  "_id":"60f75920bfbf860419597581",
  "package_name":"twilio@3.37.1",
  "failed_install_attempts":0,
  "createdAt":"2021-07-20T23:15:44.060Z",
  "updatedAt":"2021-07-20T23:15:44.060Z"
}

DELETE /npm_packages/:id

Delete a package.