@science-corporation/synapse 2.3.0 → 2.3.2

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/package.json CHANGED
@@ -1,70 +1,70 @@
1
- {
2
- "name": "@science-corporation/synapse",
3
- "version": "2.3.0",
4
- "description": "Client library and CLI for the Synapse API",
5
- "license": "Apache-2.0",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
12
- },
13
- "./browser": {
14
- "types": "./dist/browser.d.ts",
15
- "default": "./dist/browser.js"
16
- }
17
- },
18
- "files": [
19
- "dist",
20
- "scripts",
21
- "src",
22
- "synapse-api"
23
- ],
24
- "scripts": {
25
- "build": "bash ./scripts/build.sh",
26
- "clean": "rimraf dist src/api",
27
- "dist": "npm run generate && npm run build",
28
- "generate": "bash ./scripts/generate.sh",
29
- "lint": "tsc --noEmit && eslint .",
30
- "postinstall": "bash ./scripts/postinstall.sh && npm run dist",
31
- "test": "tsc --noEmit && jest"
32
- },
33
- "repository": {
34
- "type": "git",
35
- "url": "git+https://github.com/sciencecorp/synapse-typescript.git"
36
- },
37
- "author": {
38
- "name": "Science Corporation",
39
- "email": "team@science.xyz"
40
- },
41
- "bugs": {
42
- "url": "https://github.com/sciencecorp/synapse-typescript/issues"
43
- },
44
- "homepage": "https://github.com/sciencecorp/synapse-typescript#readme",
45
- "engines": {
46
- "node": ">=18"
47
- },
48
- "devDependencies": {
49
- "@eslint/compat": "^1.2.6",
50
- "@types/jest": "^29.5.14",
51
- "@typescript-eslint/eslint-plugin": "^8.23.0",
52
- "@typescript-eslint/parser": "^8.23.0",
53
- "eslint": "^9.5.0",
54
- "eslint-import-resolver-typescript": "^3.7.0",
55
- "eslint-plugin-import": "^2.31.0",
56
- "jest": "^29.7.0",
57
- "rimraf": "^5.0.5",
58
- "ts-jest": "^29.2.5",
59
- "typescript": "^5.5.2"
60
- },
61
- "dependencies": {
62
- "@grpc/grpc-js": "^1.10.10",
63
- "@grpc/proto-loader": "^0.7.13",
64
- "google-protobuf": "^3.21.2",
65
- "long": "^5.3.1",
66
- "protobufjs-cli": "^1.1.3",
67
- "tmp": "^0.2.5",
68
- "yargs": "^17.7.2"
69
- }
70
- }
1
+ {
2
+ "name": "@science-corporation/synapse",
3
+ "version": "2.3.2",
4
+ "description": "Client library and CLI for the Synapse API",
5
+ "license": "Apache-2.0",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./browser": {
14
+ "types": "./dist/browser.d.ts",
15
+ "default": "./dist/browser.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "scripts",
21
+ "src",
22
+ "synapse-api"
23
+ ],
24
+ "scripts": {
25
+ "build": "bash ./scripts/build.sh",
26
+ "clean": "rimraf dist src/api",
27
+ "dist": "npm run generate && npm run build",
28
+ "generate": "bash ./scripts/generate.sh",
29
+ "lint": "tsc --noEmit && eslint .",
30
+ "postinstall": "bash ./scripts/postinstall.sh && npm run dist",
31
+ "test": "tsc --noEmit && jest"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/sciencecorp/synapse-typescript.git"
36
+ },
37
+ "author": {
38
+ "name": "Science Corporation",
39
+ "email": "team@science.xyz"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/sciencecorp/synapse-typescript/issues"
43
+ },
44
+ "homepage": "https://github.com/sciencecorp/synapse-typescript#readme",
45
+ "engines": {
46
+ "node": ">=18"
47
+ },
48
+ "devDependencies": {
49
+ "@eslint/compat": "^1.2.6",
50
+ "@types/jest": "^29.5.14",
51
+ "@typescript-eslint/eslint-plugin": "^8.23.0",
52
+ "@typescript-eslint/parser": "^8.23.0",
53
+ "eslint": "^9.5.0",
54
+ "eslint-import-resolver-typescript": "^3.7.0",
55
+ "eslint-plugin-import": "^2.31.0",
56
+ "jest": "^29.7.0",
57
+ "rimraf": "^5.0.5",
58
+ "ts-jest": "^29.2.5",
59
+ "typescript": "^5.5.2"
60
+ },
61
+ "dependencies": {
62
+ "@grpc/grpc-js": "^1.10.10",
63
+ "@grpc/proto-loader": "^0.7.13",
64
+ "google-protobuf": "^3.21.2",
65
+ "long": "^5.3.1",
66
+ "protobufjs-cli": "^1.1.3",
67
+ "tmp": "^0.2.5",
68
+ "yargs": "^17.7.2"
69
+ }
70
+ }
@@ -5,6 +5,16 @@ PROTOS=$(find ${PROTO_DIR} -name '*.proto' | sed "s|${PROTO_DIR}/||")
5
5
 
6
6
  mkdir -p ${PROTO_OUT_DIR}
7
7
 
8
+ # Mirror synapse-api/VERSION into src/api_version.ts so the protocol
9
+ # version is available as a constant in both node and browser builds.
10
+ if [ -f "${PROTO_DIR}/VERSION" ]; then
11
+ SYNAPSE_API_VERSION=$(tr -d '[:space:]' < ${PROTO_DIR}/VERSION)
12
+ cat > ./src/api_version.ts <<EOF
13
+ // Generated from synapse-api/VERSION by scripts/generate.sh. Do not edit.
14
+ export const SYNAPSE_API_VERSION = "${SYNAPSE_API_VERSION}";
15
+ EOF
16
+ fi
17
+
8
18
  pbjs \
9
19
  -t json \
10
20
  -w es6 \
@@ -1,185 +1,185 @@
1
- #!/bin/bash
2
-
3
- # Platform detection
4
- IS_WINDOWS=false
5
- if [ "$OS" = "Windows_NT" ] || [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
6
- IS_WINDOWS=true
7
- fi
8
-
9
- # If running on Windows, ensure we're using bash
10
- if [ "$IS_WINDOWS" = true ]; then
11
- if ! command -v bash >/dev/null 2>&1; then
12
- echo "Error: bash is required to run this script on Windows"
13
- exit 1
14
- fi
15
- fi
16
-
17
- echo "Postinstall - downloading synapse-api"
18
-
19
- # If synapse-api directory already exists, skip download
20
- if [ -d "synapse-api" ]; then
21
- echo " - synapse-api directory already exists, skipping download"
22
- exit 0
23
- fi
24
-
25
- # If we have git, try to update the submodule
26
- HAS_GIT=false
27
- if command -v git >/dev/null 2>&1 && git rev-parse --git-dir >/dev/null 2>&1; then
28
- HAS_GIT=true
29
- echo " - Git detected, attempting to update submodule..."
30
-
31
- if git submodule update --init synapse-api; then
32
- echo " - Successfully updated synapse-api submodule"
33
- exit 0
34
- else
35
- echo " - Failed to update submodule, falling back to download..."
36
- fi
37
- fi
38
-
39
- # Else, fallback to downloading from github
40
- echo "Downloading synapse-api..."
41
-
42
- # Resolve which synapse-typescript ref to ask the GitHub API about, in order
43
- # of decreasing fidelity:
44
- # 1. git HEAD when there's a real working tree (most accurate).
45
- # 2. The SHA in $npm_package_resolved — npm exports this during install
46
- # lifecycle scripts as `git+ssh://...#<sha>`. This is the one that
47
- # makes `npm install git://...#<sha>` actually work, since during
48
- # pacote's prepare phase the .git dir has been moved away and the
49
- # package.json gitHead field has not yet been injected.
50
- # 3. package.json#gitHead — npm writes this after prepare completes, so
51
- # it's available for downstream consumers reading an already-installed
52
- # package, just not during the prepare phase itself.
53
- # 4. v$version tag, as a last resort for vanilla tarball installs after a
54
- # release has tagged the version.
55
- REF_LIB=""
56
- if [ "$HAS_GIT" = true ]; then
57
- REF_LIB=$(git rev-parse HEAD)
58
- fi
59
-
60
- if [ -z "$REF_LIB" ] && [ -n "$npm_package_resolved" ]; then
61
- # Strip everything up to and including the last '#' to get the SHA.
62
- CANDIDATE="${npm_package_resolved##*#}"
63
- # Only accept if it looks like a SHA (40 hex chars). Anything else is
64
- # probably a URL with no fragment, which would leave the var untouched.
65
- if [ "${#CANDIDATE}" = 40 ] && [ -z "${CANDIDATE//[0-9a-f]/}" ]; then
66
- REF_LIB="$CANDIDATE"
67
- echo " - Using npm_package_resolved SHA for ref lookup"
68
- fi
69
- fi
70
-
71
- if [ -z "$REF_LIB" ]; then
72
- REF_LIB=$(node -e "const p=require('./package.json'); if (p.gitHead) process.stdout.write(p.gitHead);" 2>/dev/null)
73
- if [ -n "$REF_LIB" ]; then
74
- echo " - Using package.json gitHead for ref lookup"
75
- fi
76
- fi
77
-
78
- if [ -z "$REF_LIB" ]; then
79
- PKG_VERSION=$(node -p "require('./package.json').version")
80
- if [ -z "$PKG_VERSION" ]; then
81
- echo " - Failed to get version from package.json"
82
- exit 1
83
- fi
84
- REF_LIB=v$PKG_VERSION
85
- fi
86
-
87
- echo "- Looking up synapse-api ref for synapse-typescript ref $REF_LIB"
88
-
89
- CURL_OPTS=()
90
- CURL_OPTS+=(-H "Accept: application/vnd.github+json")
91
- CURL_OPTS+=(-H "X-GitHub-Api-Version: 2022-11-28")
92
- if [ -n "$SCIENCE_CORPORATION_SYNAPSE_TOKEN" ]; then
93
- echo " - Using GitHub token for authentication"
94
- CURL_OPTS+=(-H "Authorization: Bearer $SCIENCE_CORPORATION_SYNAPSE_TOKEN")
95
- fi
96
-
97
- fetch_synapse_api_sha() {
98
- local use_auth="$1"
99
- local opts=(-H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28")
100
- if [ "$use_auth" = "true" ] && [ -n "$SCIENCE_CORPORATION_SYNAPSE_TOKEN" ]; then
101
- opts+=(-H "Authorization: Bearer $SCIENCE_CORPORATION_SYNAPSE_TOKEN")
102
- fi
103
- curl -s "${opts[@]}" "https://api.github.com/repos/sciencecorp/synapse-typescript/contents/synapse-api?ref=$REF_LIB"
104
- }
105
-
106
- echo " - Fetching synapse-api submodule info..."
107
- CURL_RESULT=$(fetch_synapse_api_sha "true")
108
-
109
- # Check for auth failure and retry without auth
110
- if echo "$CURL_RESULT" | grep -q '"Bad credentials"'; then
111
- echo " - Auth failed, retrying without authentication..."
112
- CURL_RESULT=$(fetch_synapse_api_sha "false")
113
- fi
114
-
115
- if [ -z "$CURL_RESULT" ]; then
116
- echo " - Failed to fetch from GitHub API"
117
- exit 1
118
- fi
119
-
120
- echo " - Parsing SHA from response..."
121
- GREP_RESULT=$(echo "$CURL_RESULT" | grep -o '"sha":\s*"[^"]*"')
122
- if [ -z "$GREP_RESULT" ]; then
123
- echo " - Failed to find SHA in API response"
124
- echo " - API response: $CURL_RESULT"
125
- exit 1
126
- fi
127
-
128
- REF_API=$(echo "${GREP_RESULT#*:}" | tr -d '[:space:]"')
129
- if [ -z "$REF_API" ]; then
130
- echo " - Failed to parse SHA from API response"
131
- echo " - API response: $CURL_RESULT"
132
- exit 1
133
- fi
134
-
135
- echo "- Found synapse-api ref \"$REF_API\""
136
-
137
- # Create temp directory in a cross-platform way
138
- if [ "$IS_WINDOWS" = true ]; then
139
- # Use a more reliable temp directory path on Windows
140
- TMP_DIR="C:\\Users\\$USERNAME\\AppData\\Local\\Temp\\synapse-api-temp"
141
- mkdir -p "$TMP_DIR"
142
- else
143
- TMP_DIR=$(mktemp -d)
144
- fi
145
-
146
- # Download using curl or fallback to PowerShell on Windows if curl fails
147
- if ! curl -s -L "https://github.com/sciencecorp/synapse-api/archive/${REF_API}.zip" -o "$TMP_DIR/synapse-api.zip"; then
148
- if [ "$IS_WINDOWS" = true ]; then
149
- echo " - Curl failed, attempting download with PowerShell..."
150
- powershell -Command "Invoke-WebRequest -Uri 'https://github.com/sciencecorp/synapse-api/archive/${REF_API}.zip' -OutFile '$TMP_DIR\\synapse-api.zip'"
151
- else
152
- echo " - Failed to download synapse-api"
153
- exit 1
154
- fi
155
- fi
156
-
157
- # Unzip in a cross-platform way
158
- if [ "$IS_WINDOWS" = true ]; then
159
- if ! unzip -q "$TMP_DIR/synapse-api.zip" -d "$TMP_DIR" 2>/dev/null; then
160
- echo " - Unzip failed, attempting with PowerShell..."
161
- powershell -Command "Expand-Archive -Path '$TMP_DIR\\synapse-api.zip' -DestinationPath '$TMP_DIR' -Force"
162
- fi
163
- else
164
- if ! unzip -q "$TMP_DIR/synapse-api.zip" -d "$TMP_DIR"; then
165
- echo " - Failed to unzip synapse-api"
166
- exit 1
167
- fi
168
- fi
169
-
170
- # Create directory and copy files in a cross-platform way
171
- mkdir -p synapse-api
172
- if [ "$IS_WINDOWS" = true ]; then
173
- powershell -Command "Copy-Item -Path \"$TMP_DIR\\synapse-api-${REF_API}\\*\" -Destination \"synapse-api\\\" -Recurse -Force"
174
- else
175
- cp -r "$TMP_DIR/synapse-api-${REF_API}/"* synapse-api/
176
- fi
177
-
178
- # Clean up temp files
179
- rm -rf "$TMP_DIR"
180
-
181
- if [ ! -f "synapse-api/README.md" ] || [ ! -f "synapse-api/COPYRIGHT" ] || [ ! -d "synapse-api/api" ]; then
182
- echo " - Failed to download synapse-api - missing required files"
183
- exit 1
184
- fi
185
- echo " - Successfully downloaded synapse-api ref \"$REF_API\""
1
+ #!/bin/bash
2
+
3
+ # Platform detection
4
+ IS_WINDOWS=false
5
+ if [ "$OS" = "Windows_NT" ] || [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
6
+ IS_WINDOWS=true
7
+ fi
8
+
9
+ # If running on Windows, ensure we're using bash
10
+ if [ "$IS_WINDOWS" = true ]; then
11
+ if ! command -v bash >/dev/null 2>&1; then
12
+ echo "Error: bash is required to run this script on Windows"
13
+ exit 1
14
+ fi
15
+ fi
16
+
17
+ echo "Postinstall - downloading synapse-api"
18
+
19
+ # If synapse-api directory already exists, skip download
20
+ if [ -d "synapse-api" ]; then
21
+ echo " - synapse-api directory already exists, skipping download"
22
+ exit 0
23
+ fi
24
+
25
+ # If we have git, try to update the submodule
26
+ HAS_GIT=false
27
+ if command -v git >/dev/null 2>&1 && git rev-parse --git-dir >/dev/null 2>&1; then
28
+ HAS_GIT=true
29
+ echo " - Git detected, attempting to update submodule..."
30
+
31
+ if git submodule update --init synapse-api; then
32
+ echo " - Successfully updated synapse-api submodule"
33
+ exit 0
34
+ else
35
+ echo " - Failed to update submodule, falling back to download..."
36
+ fi
37
+ fi
38
+
39
+ # Else, fallback to downloading from github
40
+ echo "Downloading synapse-api..."
41
+
42
+ # Resolve which synapse-typescript ref to ask the GitHub API about, in order
43
+ # of decreasing fidelity:
44
+ # 1. git HEAD when there's a real working tree (most accurate).
45
+ # 2. The SHA in $npm_package_resolved — npm exports this during install
46
+ # lifecycle scripts as `git+ssh://...#<sha>`. This is the one that
47
+ # makes `npm install git://...#<sha>` actually work, since during
48
+ # pacote's prepare phase the .git dir has been moved away and the
49
+ # package.json gitHead field has not yet been injected.
50
+ # 3. package.json#gitHead — npm writes this after prepare completes, so
51
+ # it's available for downstream consumers reading an already-installed
52
+ # package, just not during the prepare phase itself.
53
+ # 4. v$version tag, as a last resort for vanilla tarball installs after a
54
+ # release has tagged the version.
55
+ REF_LIB=""
56
+ if [ "$HAS_GIT" = true ]; then
57
+ REF_LIB=$(git rev-parse HEAD)
58
+ fi
59
+
60
+ if [ -z "$REF_LIB" ] && [ -n "$npm_package_resolved" ]; then
61
+ # Strip everything up to and including the last '#' to get the SHA.
62
+ CANDIDATE="${npm_package_resolved##*#}"
63
+ # Only accept if it looks like a SHA (40 hex chars). Anything else is
64
+ # probably a URL with no fragment, which would leave the var untouched.
65
+ if [ "${#CANDIDATE}" = 40 ] && [ -z "${CANDIDATE//[0-9a-f]/}" ]; then
66
+ REF_LIB="$CANDIDATE"
67
+ echo " - Using npm_package_resolved SHA for ref lookup"
68
+ fi
69
+ fi
70
+
71
+ if [ -z "$REF_LIB" ]; then
72
+ REF_LIB=$(node -e "const p=require('./package.json'); if (p.gitHead) process.stdout.write(p.gitHead);" 2>/dev/null)
73
+ if [ -n "$REF_LIB" ]; then
74
+ echo " - Using package.json gitHead for ref lookup"
75
+ fi
76
+ fi
77
+
78
+ if [ -z "$REF_LIB" ]; then
79
+ PKG_VERSION=$(node -p "require('./package.json').version")
80
+ if [ -z "$PKG_VERSION" ]; then
81
+ echo " - Failed to get version from package.json"
82
+ exit 1
83
+ fi
84
+ REF_LIB=v$PKG_VERSION
85
+ fi
86
+
87
+ echo "- Looking up synapse-api ref for synapse-typescript ref $REF_LIB"
88
+
89
+ CURL_OPTS=()
90
+ CURL_OPTS+=(-H "Accept: application/vnd.github+json")
91
+ CURL_OPTS+=(-H "X-GitHub-Api-Version: 2022-11-28")
92
+ if [ -n "$SCIENCE_CORPORATION_SYNAPSE_TOKEN" ]; then
93
+ echo " - Using GitHub token for authentication"
94
+ CURL_OPTS+=(-H "Authorization: Bearer $SCIENCE_CORPORATION_SYNAPSE_TOKEN")
95
+ fi
96
+
97
+ fetch_synapse_api_sha() {
98
+ local use_auth="$1"
99
+ local opts=(-H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28")
100
+ if [ "$use_auth" = "true" ] && [ -n "$SCIENCE_CORPORATION_SYNAPSE_TOKEN" ]; then
101
+ opts+=(-H "Authorization: Bearer $SCIENCE_CORPORATION_SYNAPSE_TOKEN")
102
+ fi
103
+ curl -s "${opts[@]}" "https://api.github.com/repos/sciencecorp/synapse-typescript/contents/synapse-api?ref=$REF_LIB"
104
+ }
105
+
106
+ echo " - Fetching synapse-api submodule info..."
107
+ CURL_RESULT=$(fetch_synapse_api_sha "true")
108
+
109
+ # Check for auth failure and retry without auth
110
+ if echo "$CURL_RESULT" | grep -q '"Bad credentials"'; then
111
+ echo " - Auth failed, retrying without authentication..."
112
+ CURL_RESULT=$(fetch_synapse_api_sha "false")
113
+ fi
114
+
115
+ if [ -z "$CURL_RESULT" ]; then
116
+ echo " - Failed to fetch from GitHub API"
117
+ exit 1
118
+ fi
119
+
120
+ echo " - Parsing SHA from response..."
121
+ GREP_RESULT=$(echo "$CURL_RESULT" | grep -o '"sha":\s*"[^"]*"')
122
+ if [ -z "$GREP_RESULT" ]; then
123
+ echo " - Failed to find SHA in API response"
124
+ echo " - API response: $CURL_RESULT"
125
+ exit 1
126
+ fi
127
+
128
+ REF_API=$(echo "${GREP_RESULT#*:}" | tr -d '[:space:]"')
129
+ if [ -z "$REF_API" ]; then
130
+ echo " - Failed to parse SHA from API response"
131
+ echo " - API response: $CURL_RESULT"
132
+ exit 1
133
+ fi
134
+
135
+ echo "- Found synapse-api ref \"$REF_API\""
136
+
137
+ # Create temp directory in a cross-platform way
138
+ if [ "$IS_WINDOWS" = true ]; then
139
+ # Use a more reliable temp directory path on Windows
140
+ TMP_DIR="C:\\Users\\$USERNAME\\AppData\\Local\\Temp\\synapse-api-temp"
141
+ mkdir -p "$TMP_DIR"
142
+ else
143
+ TMP_DIR=$(mktemp -d)
144
+ fi
145
+
146
+ # Download using curl or fallback to PowerShell on Windows if curl fails
147
+ if ! curl -s -L "https://github.com/sciencecorp/synapse-api/archive/${REF_API}.zip" -o "$TMP_DIR/synapse-api.zip"; then
148
+ if [ "$IS_WINDOWS" = true ]; then
149
+ echo " - Curl failed, attempting download with PowerShell..."
150
+ powershell -Command "Invoke-WebRequest -Uri 'https://github.com/sciencecorp/synapse-api/archive/${REF_API}.zip' -OutFile '$TMP_DIR\\synapse-api.zip'"
151
+ else
152
+ echo " - Failed to download synapse-api"
153
+ exit 1
154
+ fi
155
+ fi
156
+
157
+ # Unzip in a cross-platform way
158
+ if [ "$IS_WINDOWS" = true ]; then
159
+ if ! unzip -q "$TMP_DIR/synapse-api.zip" -d "$TMP_DIR" 2>/dev/null; then
160
+ echo " - Unzip failed, attempting with PowerShell..."
161
+ powershell -Command "Expand-Archive -Path '$TMP_DIR\\synapse-api.zip' -DestinationPath '$TMP_DIR' -Force"
162
+ fi
163
+ else
164
+ if ! unzip -q "$TMP_DIR/synapse-api.zip" -d "$TMP_DIR"; then
165
+ echo " - Failed to unzip synapse-api"
166
+ exit 1
167
+ fi
168
+ fi
169
+
170
+ # Create directory and copy files in a cross-platform way
171
+ mkdir -p synapse-api
172
+ if [ "$IS_WINDOWS" = true ]; then
173
+ powershell -Command "Copy-Item -Path \"$TMP_DIR\\synapse-api-${REF_API}\\*\" -Destination \"synapse-api\\\" -Recurse -Force"
174
+ else
175
+ cp -r "$TMP_DIR/synapse-api-${REF_API}/"* synapse-api/
176
+ fi
177
+
178
+ # Clean up temp files
179
+ rm -rf "$TMP_DIR"
180
+
181
+ if [ ! -f "synapse-api/README.md" ] || [ ! -f "synapse-api/COPYRIGHT" ] || [ ! -d "synapse-api/api" ]; then
182
+ echo " - Failed to download synapse-api - missing required files"
183
+ exit 1
184
+ fi
185
+ echo " - Successfully downloaded synapse-api ref \"$REF_API\""
@@ -0,0 +1,2 @@
1
+ // Generated from synapse-api/VERSION by scripts/generate.sh. Do not edit.
2
+ export const SYNAPSE_API_VERSION = "2.4.1";
package/src/browser.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  // Browser-safe exports (types and enums only)
2
2
  export type { CallOptions } from "./utils/client";
3
3
  export { IStatus, Status, StatusCode } from "./utils/status";
4
+ export { SYNAPSE_API_VERSION } from "./api_version";
5
+ export { decodeSynapseVersion } from "./utils/version";
4
6
  export * from "./api/api";
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@ export { default as Config } from "./config";
2
2
  export { default as Device } from "./device";
3
3
  export * from "./nodes";
4
4
  export { IStatus, Status, StatusCode } from "./utils/status";
5
+ export { SYNAPSE_API_VERSION } from "./api_version";
6
+ export { decodeSynapseVersion } from "./utils/version";
5
7
 
6
8
  export type { CallOptions } from "./utils/client";
7
9
  export * from "./api/api";
@@ -0,0 +1,12 @@
1
+ // Decode a Synapse API version uint32 into a "major.minor.patch" string.
2
+ //
3
+ // Encoding (see synapse-api device.proto, DeviceInfo.synapse_version):
4
+ // bits [31:24] major (0-255)
5
+ // bits [23:16] minor (0-255)
6
+ // bits [15:0] patch (0-65535)
7
+ export function decodeSynapseVersion(v: number): string {
8
+ const major = (v >>> 24) & 0xff;
9
+ const minor = (v >>> 16) & 0xff;
10
+ const patch = v & 0xffff;
11
+ return `${major}.${minor}.${patch}`;
12
+ }
@@ -1,4 +1,4 @@
1
- # Synapse API 2.1.0
1
+ # Synapse API
2
2
 
3
3
  The Synapse Protocol defines a standard interface for interacting with a wide range of possible neural interface devices.
4
4
 
@@ -0,0 +1 @@
1
+ 2.4.1
@@ -14,6 +14,7 @@ message SampleQuery {
14
14
 
15
15
  message ImpedanceQuery {
16
16
  repeated uint32 electrode_ids = 1;
17
+ uint32 peripheral_id = 2;
17
18
  }
18
19
 
19
20
  message SelfTestQuery {