npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@topcoder-platform/topcoder-submission-api-wrapper

v1.2.0

Published

Wrapper for Topcoder Submission API

Downloads

9

Readme

Topcoder Submission API Wrapper

Wrapper library for Topcoder Submission API

How to use this Wrapper

  1. Include the wrapper in package.json as follows

    "topcoder-submission-api-wrapper": "topcoder-platform/topcoder-submission-api-wrapper.git"
  2. Create an instance of this wrapper with any one of the approaches listed below, depending on your use case

    M2M Authentication Configuration:

    const submissionApi = require('topcoder-submission-api-wrapper')
    const submissionApiM2MClient = submissionApi(_.pick(config,
          ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
            'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL',
            'AUTH0_PROXY_SERVER_URL']))
    • AUTH0_URL - the auth0 url
    • AUTH0_AUDIENCE - the auth0 audience
    • TOKEN_CACHE_TIME - (optional) the token cache time
    • AUTH0_CLIENT_ID - the auth0 client id, used as credential
    • AUTH0_CLIENT_SECRET - the auth0 client secret, used as credential
    • AUTH0_PROXY_SERVER_URL - (optional) the auth0 proxy server url
    • SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. https://api.topcoder-dev.com/v5
    • PAGE - the page number
    • PER_PAGE - the page size
    • MAX_PAGE_SIZE - the max number of page size

    User Credentials Authentication Configuration:

    const submissionApiUserCredentialsClient = submissionApi(_.pick(config,
          ['USERNAME', 'PASSWORD', 'TC_AUTHN_URL', 'TC_AUTHZ_URL', 'TC_CLIENT_ID',
           'TC_CLIENT_V2CONNECTION', 'SUBMISSION_API_URL']))
    • USERNAME - Topcoder handle
    • PASSWORD - Topcoder password
    • TC_AUTHN_URL - OAUTH2 token URL, e.g. https://topcoder.auth0.com/oauth/ro or for dev https://topcoder-dev.auth0.com/oauth/ro
    • TC_AUTHZ_URL - Topcoder API token URL, e.g. https://api.topcoder.com/v3/authorizations or for dev https://api.topcoder-dev.com/v3/authorizations
    • TC_CLIENT_ID - OAUTH2 Client ID, e.g. 6ZwZEUo2ZK4c50aLPpgupeg5v2Ffxp9P or for dev JFDo7HMkf0q2CkVFHojy3zHWafziprhT
    • TC_CLIENT_V2CONNECTION - The OAUTH2 Client data source, e.g. LDAP or for dev TC-User-Database
    • SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. https://api.topcoder.com/v5 or for dev https://api.topcoder-dev.com/v5

    JWT Method Argument Authentication Configuration:

    const submissionJwtMethodArgClient = submissionApi(_.pick(config,
          ['SUBMISSION_API_URL']))
    • SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. https://api.topcoder.com/v5 or for dev https://api.topcoder-dev.com/v5
  3. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments

E.g.

const reviewTypeId = '8f4e8b6a-0ad2-4ff6-ab19-afeb102ff3b4'

submissionApiClient
  .createReviewType({ name: 'test-for-create', isActive: true })
  .then(result => console.log(result.body, result.status))
  .catch(err => console.log(err))

await submissionApiClient.deleteReviewType(reviewTypeId)

const result = await submissionApiClient.searchReviews({ page: 2, perPage: 30 })

Refer index.js for the list of available wrapper functions

Documentation for wrapper methods

All URIs are relative to SUBMISSION_API_URL configuration variable.

Review Types wrapper methods

Method | HTTP request | Description ------------- | ------------- | ------------- searchReviewTypes | GET /reviewTypes | Search review types. headReviewTypes | HEAD /reviewTypes | Same to search review types, but only response status and headers information return. createReviewType | POST /reviewTypes | Create a review type. getReviewType | GET /reviewTypes/{reviewTypeId} | Get the review type. headReviewType | HEAD /reviewTypes/{reviewTypeId} | Same to get review type, but only response status and headers information return. updateReviewType | PUT /reviewTypes/{reviewTypeId} | Fully update review type. patchReviewType | PATCH /reviewTypes/{reviewTypeId} | Partially update review type. deleteReviewType | DELETE /reviewTypes/{reviewTypeId} | Delete the review type.

Reviews wrapper methods

Method | HTTP request | Description ------------- | ------------- | ------------- searchReviews | GET /reviews | Search reviews. headReviews | HEAD /reviews | Same to search reviews, but only response status and headers information return. createReview | POST /reviews | Create a review. getReview | GET /reviews/{reviewId} | Get the review. headReview | HEAD /reviews/{reviewId} | Same to get review, but only response status and headers information return. updateReview | PUT /reviews/{reviewId} | Fully update review. patchReview | PATCH /reviews/{reviewId} | Partially update review. deleteReview | DELETE /reviews/{reviewId} | Delete the review.

Review Summations wrapper methods

Method | HTTP request | Description ------------- | ------------- | ------------- searchReviewSummations | GET /reviewSummations | Search review summations. headReviewSummations | HEAD /reviewSummations | Same to search review summations, but only response status and headers information return. createReviewSummation | POST /reviewSummations | Create a review summation. getReviewSummation | GET /reviewSummations/{reviewSummationId} | Get the review summation. headReviewSummation | HEAD /reviewSummations/{reviewSummationId} | Same to get review summation, but only response status and headers information return. updateReviewSummation | PUT /reviewSummations/{reviewSummationId} | Fully update review summation. patchReviewSummation | PATCH /reviewSummations/{reviewSummationId} | Partially update review summation. deleteReviewSummation | DELETE /reviewSummations/{reviewSummationId} | Delete the review summation.

Submissions wrapper methods

Method | HTTP request | Description ------------- | ------------- | ------------- searchSubmissions | GET /submissions | Search submissions. headSubmissions | HEAD /submissions | Same to search submissions, but only response status and headers information return. createSubmission | POST /submissions | Create a submission. getSubmission | GET /submissions/{submissionId} | Get the submission. headSubmission | HEAD /submissions/{submissionId} | Same to get submission, but only response status and headers information return. updateSubmission | PUT /submissions/{submissionId} | Fully update submission. patchSubmission | PATCH /submissions/{submissionId} | Partially update submission. deleteSubmission | DELETE /submissions/{submissionId} | Delete the submission. downloadSubmission | GET /submissions/{submissionId}/download | Download the submission. createArtifact | POST /submissions/{submissionId}/artifacts | Create artifact for submission. listArtifacts | GET /submissions/{submissionId}/artifacts | List artifacts of specified submission. downloadArtifact | GET /submissions/{submissionId}/artifacts/{artifactId}/download | Download artifact deleteArtifact | DELETE /submissions/{submissionId}/artifacts/{artifactId} | Delete artifact

Authorization

The wrapper internally generates the JWT token based on the method used when initialising the wrapper (m2m v/s user) or uses the jwt passed during method invocation and passes it in the Authorization header.

Running tests

Following environment variables need to be set up before running the tests

- TEST_AUTH0_URL
- TEST_AUTH0_AUDIENCE
- TEST_AUTH0_CLIENT_ID
- TEST_AUTH0_CLIENT_SECRET
- TEST_SUBMISSION_API_URL
- TEST_JWT
- TEST_USERNAME
- TEST_PASSWORD
- TEST_TC_AUTHN_URL
- TEST_TC_AUTHZ_URL
- TEST_TC_CLIENT_ID
- TEST_TC_CLIENT_V2CONNECTION

Refer to Step # 2 in this section to learn more about the configuration variables.

To run the tests alone, execute the command

npm run test

To run tests with coverage report, execute the command

npm run cov