@pbvision/partner-sdk 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,24 +4,43 @@ The easiest way to use the PB Vision AI Engine is to simply share a link to
4
4
  your video file. Our AI usually works on each video for about an hour for a
5
5
  standard length game, so we'll notify your servers when the results are ready.
6
6
 
7
- - [Using the API](#using-the-api)
7
+ - [Installation](#installation)
8
8
  - [Step 1: Get API Access](#step-1-get-api-access)
9
- - [Step 2: Webhook Setup](#step-2-webhook-setup)
10
- - [Step 3: Send Videos](#step-3-send-videos)
9
+ - [Step 2: SDK Setup](#step-2-sdk-setup)
10
+ - [Using the API](#using-the-api)
11
+ - [Webhook Setup](#webhook-setup)
12
+ - [Send Videos](#send-videos)
11
13
  - [Option 1: PBV Downloads your video from a URL](#option-1-pbv-downloads-your-video-from-a-url)
12
14
  - [Option 2: Upload your video](#option-2-upload-your-video)
13
- - [Step 4: Video Processing Done](#step-4-video-processing-done)
14
- - [SDK Setup](#sdk-setup)
15
+ - [After Video Processing is Done](#after-video-processing-is-done)
15
16
  - [Video Guidelines](#video-guidelines)
17
+ - [Reference Guide](#reference-guide)
16
18
 
17
- ## Using the API
19
+ ## Installation
18
20
 
19
21
  ### Step 1: Get API Access
20
22
 
21
23
  Email **[dev@pb.vision](mailto:dev@pb.vision)** to request API access for your
22
24
  account. We'll send you an API Key.
23
25
 
24
- ### Step 2: Webhook Setup
26
+ ### Step 2: SDK Setup
27
+
28
+ 1. Install [node](https://nodejs.org/en/download)
29
+ 2. Install the SDK: `npm i @pbvision/partner-sdk`
30
+ 3. In your package.json, make sure you're configured to use ESM (modules): `"type": "module"`
31
+ 4. Initialize the SDK:
32
+
33
+ ```javascript
34
+ import { PBVision } from '@pbvision/partner-sdk'
35
+ const pbv = new PBVision(YOUR_API_KEY)
36
+ ```
37
+
38
+ 5. Use its methods as described to [send us video URLs](#send-videos) to
39
+ to process, or [tell us your webhook's URL](#webhook-setup).
40
+
41
+ ## Using the API
42
+
43
+ ### Webhook Setup
25
44
 
26
45
  Each time our AI finishes processing a video, it will notify your servers via
27
46
  an HTTP POST request to a URL ("webhook") of your choice. You can use our SDK
@@ -44,7 +63,7 @@ curl -X POST \
44
63
  https://api-ko3kowqi6a-uc.a.run.app/partner/webhook/set
45
64
  ```
46
65
 
47
- ### Step 3: Send Videos
66
+ ### Send Videos
48
67
 
49
68
  #### Option 1: PBV Downloads your video from a URL
50
69
 
@@ -89,12 +108,12 @@ const optionalMetadata = {
89
108
  await pbv.uploadVideo(YOUR_VIDEO_FILENAME, optionalMetadata)
90
109
  ```
91
110
 
92
- ### Step 4: Video Processing Done
111
+ ## After Video Processing is Done
93
112
 
94
113
  When our AI is done processing your video, we will email the players in the
95
114
  game (_if_ their email addresses were provided).
96
115
 
97
- If you provided a webhook in [step 2](#step-2-webhook-setup), then we'll send
116
+ If you [provided a webhook](#webhook-setup), then we'll send
98
117
  an HTTP POST request to your server. Your server should acknowledge this
99
118
  callback with a standard 200 (OK) response. If it does not, we will attempt to
100
119
  retry sending this request later (up to some maximum number of attempts).
@@ -113,7 +132,7 @@ The HTTP POST body will contain JSON which looks like this:
113
132
  }
114
133
  ```
115
134
 
116
- - `from_url` is the video url you sent us in [step 3](#step-3-send-videos)
135
+ - `from_url` is the video url you sent us in [step 3](#send-videos)
117
136
  - `webpage` is a link to our web app where the stats can be explored
118
137
  - `error` is only present if your video could not be processed
119
138
  - `events` - describes the pickleball game in detailed, low-level events
@@ -123,21 +142,6 @@ The HTTP POST body will contain JSON which looks like this:
123
142
  - Explore the _insights_ schema at <https://pbv-public.github.io/insights/dev>
124
143
  - Schema changes and diffs are in our [`pbv-public/insights` repo](https://github.com/pbv-public/insights/blob/dev/CHANGELOG.md)
125
144
 
126
- ## SDK Setup
127
-
128
- 1. Install [node](https://nodejs.org/en/download)
129
- 2. Install the SDK: `npm i @pbvision/partner-sdk`
130
- 3. In your package.json, make sure you're configured to use ESM (modules): `"type": "module"`
131
- 4. Initialize the SDK:
132
-
133
- ```javascript
134
- import { PBVision } from '@pbvision/partner-sdk'
135
- const pbv = new PBVision(YOUR_API_KEY)
136
- ```
137
-
138
- 5. Use its methods as described to [send us video URLs](#step-3-send-videos) to
139
- to process, or [tell us your webhook's URL](#step-2-webhook-setup).
140
-
141
145
  ## Video Guidelines
142
146
 
143
147
  Requirements:
@@ -154,3 +158,7 @@ For best results, we also recommend:
154
158
  - Max bitrate: 2 Mbps
155
159
  - Max file size: 1GB
156
160
  - Max duration: 30 minutes
161
+
162
+ ## Reference Guide
163
+
164
+ - [JSDocs](https://pbv-public.github.io/partner-sdk-nodejs/)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pbvision/partner-sdk",
3
3
  "description": "SDK for interacting with the PB Vision pickleball AI engine.",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "engines": {
@@ -18,5 +18,8 @@
18
18
  "dependencies": {
19
19
  "node-fetch": "^3.3.2"
20
20
  },
21
- "devDependencies": {}
21
+ "devDependencies": {
22
+ "jsdoc": "3.6.4",
23
+ "tui-jsdoc-template": "^1.2.2"
24
+ }
22
25
  }
@@ -16,7 +16,7 @@ import crypto from 'node:crypto'
16
16
  * @param {string} [opts.fileExt] the video's file extension
17
17
  * @param {string} [opts.bucket] the GCS bucket to upload to
18
18
  * @returns {string} the signed GCS object filename
19
- * @public
19
+ * @protected
20
20
  */
21
21
  export function makeSignedGoogleCloudStorageVideoObjectName ({
22
22
  uploaderUID,
@@ -37,6 +37,7 @@ export function makeSignedGoogleCloudStorageVideoObjectName ({
37
37
  *
38
38
  * The hash includes all elements of the file's unique path (including the
39
39
  * bucket) except for the hash itself.
40
+ * @private
40
41
  */
41
42
  function getHash (uploaderUID, signingKey, uploadId, fileExt, bucket) {
42
43
  const nameWithEmptyHash = makeObjectNameGivenHash(
@@ -48,6 +49,7 @@ function getHash (uploaderUID, signingKey, uploadId, fileExt, bucket) {
48
49
 
49
50
  /**
50
51
  * Returns the full GCS object name (including hash) for the given parameters.
52
+ * @private
51
53
  */
52
54
  function makeObjectName (uploaderUID, signingKey, uploadId, fileExt, bucket) {
53
55
  const hash = getHash(uploaderUID, signingKey, uploadId, fileExt, bucket)
@@ -58,6 +60,7 @@ function makeObjectName (uploaderUID, signingKey, uploadId, fileExt, bucket) {
58
60
 
59
61
  /**
60
62
  * Returns the full GCS object name using the specified hash string.
63
+ * @private
61
64
  */
62
65
  function makeObjectNameGivenHash (uploaderUID, uploadId, fileExt, hash) {
63
66
  assert(uploaderUID.indexOf('/') === -1)