@robosystems/client 0.1.19 → 0.1.20

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.
@@ -1,8 +1,8 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
 
4
- # Create feature branch script using GitHub Actions
5
- # Creates a new feature/bugfix/hotfix branch from specified base
4
+ # Create feature branch script - local Git operations
5
+ # Creates a new feature/bugfix/hotfix branch locally and pushes to remote
6
6
  # Usage: ./bin/create-feature [feature|bugfix|hotfix|chore|refactor] [branch-name] [base-branch]
7
7
 
8
8
  # Default values
@@ -13,79 +13,92 @@ BASE_BRANCH=${3:-main}
13
13
  # Validate branch type
14
14
  if [[ "$BRANCH_TYPE" != "feature" && "$BRANCH_TYPE" != "bugfix" && "$BRANCH_TYPE" != "hotfix" && "$BRANCH_TYPE" != "chore" && "$BRANCH_TYPE" != "refactor" ]]; then
15
15
  echo "❌ Invalid branch type: $BRANCH_TYPE"
16
- echo "Usage: $0 [feature|bugfix|hotfix|chore|refactor] [branch-name] [base-branch]"
16
+ echo "Valid types: feature, bugfix, hotfix, chore, refactor"
17
17
  exit 1
18
18
  fi
19
19
 
20
- # Check if branch name is provided
20
+ # Check if branch name was provided
21
21
  if [ -z "$BRANCH_NAME" ]; then
22
22
  echo "❌ Branch name is required"
23
- echo "Usage: $0 [feature|bugfix|hotfix|chore|refactor] [branch-name] [base-branch]"
23
+ echo "Usage: $0 [type] [name] [base_branch]"
24
+ echo "Example: $0 feature add-user-auth main"
24
25
  exit 1
25
26
  fi
26
27
 
27
28
  # Sanitize branch name
28
- SANITIZED_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//' | tr '[:upper:]' '[:lower:]')
29
- FULL_BRANCH_NAME="$BRANCH_TYPE/$SANITIZED_NAME"
29
+ SANITIZED_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
30
+ FULL_BRANCH="${BRANCH_TYPE}/${SANITIZED_NAME}"
30
31
 
31
- echo "🌿 Creating feature branch..."
32
- echo "📋 Branch Details:"
32
+ echo "🚀 Creating feature branch locally..."
33
+ echo "📋 Details:"
33
34
  echo " Type: $BRANCH_TYPE"
34
35
  echo " Name: $SANITIZED_NAME"
35
- echo " Full Name: $FULL_BRANCH_NAME"
36
+ echo " Full Branch: $FULL_BRANCH"
36
37
  echo " Base Branch: $BASE_BRANCH"
37
38
  echo ""
38
39
 
39
40
  # Check for uncommitted changes
40
41
  if ! git diff --quiet || ! git diff --cached --quiet; then
41
- echo "⚠️ You have uncommitted changes. Please commit or stash them first."
42
- echo ""
43
- echo "Uncommitted files:"
44
- git status --porcelain
42
+ echo "⚠️ You have uncommitted changes."
43
+ read -p "Do you want to stash them? (y/N): " -n 1 -r
44
+ echo
45
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
46
+ git stash push -m "Auto-stash before creating branch $FULL_BRANCH"
47
+ echo "✅ Changes stashed"
48
+ else
49
+ echo "❌ Please commit or stash your changes first"
50
+ exit 1
51
+ fi
52
+ fi
53
+
54
+ # Fetch latest changes from remote
55
+ echo "📥 Fetching latest changes from remote..."
56
+ git fetch origin
57
+
58
+ # Check if branch already exists (local or remote)
59
+ if git show-ref --verify --quiet refs/heads/$FULL_BRANCH; then
60
+ echo "❌ Branch $FULL_BRANCH already exists locally"
45
61
  exit 1
46
62
  fi
47
63
 
48
- echo "🚀 Triggering GitHub Actions workflow..."
49
- gh workflow run create-feature.yml \
50
- --field branch_type="$BRANCH_TYPE" \
51
- --field branch_name="$BRANCH_NAME" \
52
- --field base_branch="$BASE_BRANCH"
64
+ if git show-ref --verify --quiet refs/remotes/origin/$FULL_BRANCH; then
65
+ echo "❌ Branch $FULL_BRANCH already exists on remote"
66
+ echo "💡 To check it out: git checkout -b $FULL_BRANCH origin/$FULL_BRANCH"
67
+ exit 1
68
+ fi
53
69
 
54
- echo "⏳ Waiting for branch to be created..."
70
+ # Check if base branch exists on remote
71
+ if ! git show-ref --verify --quiet refs/remotes/origin/$BASE_BRANCH; then
72
+ echo "❌ Base branch $BASE_BRANCH does not exist on remote"
73
+ echo "💡 Available branches:"
74
+ git branch -r | grep -v HEAD | sed 's/origin\///' | head -10
75
+ exit 1
76
+ fi
77
+
78
+ # Create and checkout the new branch from the base branch
79
+ echo "🔨 Creating branch $FULL_BRANCH from origin/$BASE_BRANCH..."
80
+ git checkout -b $FULL_BRANCH origin/$BASE_BRANCH
81
+
82
+ # Push the new branch to remote with upstream tracking
83
+ echo "📤 Pushing branch to remote..."
84
+ git push -u origin $FULL_BRANCH
55
85
 
56
- # Wait for the branch to be created (check every 5 seconds for up to 1 minute)
57
- MAX_ATTEMPTS=12
58
- ATTEMPT=1
86
+ echo ""
87
+ echo "🎉 Successfully created and checked out $FULL_BRANCH"
88
+ echo ""
89
+ echo "📝 Next steps:"
90
+ echo " 1. Make your changes and commit them"
91
+ echo " 2. Push your changes: git push"
92
+ echo " 3. Create a PR: gh pr create --base $BASE_BRANCH --title \"Your PR title\" --body \"Your PR description\""
93
+ echo " or use: npm run pr:create"
59
94
 
60
- while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
61
- echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Checking if branch exists..."
62
-
63
- # Fetch latest changes from remote
64
- git fetch origin --quiet
65
-
66
- # Check if the branch exists on remote
67
- if git show-ref --verify --quiet refs/remotes/origin/$FULL_BRANCH_NAME; then
68
- echo "✅ Branch $FULL_BRANCH_NAME found! Checking it out..."
69
- git checkout -b $FULL_BRANCH_NAME origin/$FULL_BRANCH_NAME 2>/dev/null || git checkout $FULL_BRANCH_NAME
70
-
71
- echo "🎉 Successfully created and switched to $FULL_BRANCH_NAME"
72
- echo ""
73
- echo "📝 Next steps:"
74
- echo " 1. Make your changes and commit them"
75
- echo " 2. Push your changes: git push"
76
- echo " 3. Create a PR when ready: npm run pr:create"
77
-
78
- exit 0
79
- fi
80
-
81
- if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
82
- echo "❌ Timeout: Branch $FULL_BRANCH_NAME was not created after 1 minute"
83
- echo "Check the GitHub Actions workflow status:"
84
- echo " gh run list --workflow=create-feature.yml"
85
- exit 1
86
- fi
87
-
88
- echo "Branch not yet available, waiting 5 seconds..."
89
- sleep 5
90
- ATTEMPT=$((ATTEMPT + 1))
91
- done
95
+ # Check if we had stashed changes
96
+ if git stash list | grep -q "Auto-stash before creating branch $FULL_BRANCH"; then
97
+ echo ""
98
+ read -p "Do you want to apply your stashed changes? (y/N): " -n 1 -r
99
+ echo
100
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
101
+ git stash pop
102
+ echo "✅ Stashed changes applied"
103
+ fi
104
+ fi
@@ -135,8 +135,22 @@ const getParseAs = (contentType) => {
135
135
  return;
136
136
  };
137
137
  exports.getParseAs = getParseAs;
138
+ const checkForExistence = (options, name) => {
139
+ if (!name) {
140
+ return false;
141
+ }
142
+ if (options.headers.has(name) ||
143
+ options.query?.[name] ||
144
+ options.headers.get('Cookie')?.includes(`${name}=`)) {
145
+ return true;
146
+ }
147
+ return false;
148
+ };
138
149
  const setAuthParams = async ({ security, ...options }) => {
139
150
  for (const auth of security) {
151
+ if (checkForExistence(options, auth.name)) {
152
+ continue;
153
+ }
140
154
  const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
141
155
  if (!token) {
142
156
  continue;
@@ -157,7 +171,6 @@ const setAuthParams = async ({ security, ...options }) => {
157
171
  options.headers.set(name, token);
158
172
  break;
159
173
  }
160
- return;
161
174
  }
162
175
  };
163
176
  exports.setAuthParams = setAuthParams;
@@ -188,6 +188,25 @@ export const getParseAs = (
188
188
  return;
189
189
  };
190
190
 
191
+ const checkForExistence = (
192
+ options: Pick<RequestOptions, 'auth' | 'query'> & {
193
+ headers: Headers;
194
+ },
195
+ name?: string,
196
+ ): boolean => {
197
+ if (!name) {
198
+ return false;
199
+ }
200
+ if (
201
+ options.headers.has(name) ||
202
+ options.query?.[name] ||
203
+ options.headers.get('Cookie')?.includes(`${name}=`)
204
+ ) {
205
+ return true;
206
+ }
207
+ return false;
208
+ };
209
+
191
210
  export const setAuthParams = async ({
192
211
  security,
193
212
  ...options
@@ -196,6 +215,10 @@ export const setAuthParams = async ({
196
215
  headers: Headers;
197
216
  }) => {
198
217
  for (const auth of security) {
218
+ if (checkForExistence(options, auth.name)) {
219
+ continue;
220
+ }
221
+
199
222
  const token = await getAuthToken(auth, options.auth);
200
223
 
201
224
  if (!token) {
@@ -219,8 +242,6 @@ export const setAuthParams = async ({
219
242
  options.headers.set(name, token);
220
243
  break;
221
244
  }
222
-
223
- return;
224
245
  }
225
246
  };
226
247
 
@@ -6,6 +6,9 @@ const serializeFormDataPair = (data, key, value) => {
6
6
  if (typeof value === 'string' || value instanceof Blob) {
7
7
  data.append(key, value);
8
8
  }
9
+ else if (value instanceof Date) {
10
+ data.append(key, value.toISOString());
11
+ }
9
12
  else {
10
13
  data.append(key, JSON.stringify(value));
11
14
  }
@@ -23,6 +23,8 @@ const serializeFormDataPair = (
23
23
  ): void => {
24
24
  if (typeof value === 'string' || value instanceof Blob) {
25
25
  data.append(key, value);
26
+ } else if (value instanceof Date) {
27
+ data.append(key, value.toISOString());
26
28
  } else {
27
29
  data.append(key, JSON.stringify(value));
28
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/client",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "TypeScript client library for RoboSystems Financial Knowledge Graph API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -114,7 +114,7 @@
114
114
  "eslint-plugin-prettier": "^5.0.0",
115
115
  "prettier": "^3.0.0",
116
116
  "prettier-plugin-organize-imports": "^4.0.0",
117
- "typescript": "^5.7.3"
117
+ "typescript": "5.5.4"
118
118
  },
119
119
  "publishConfig": {
120
120
  "access": "public",
@@ -135,8 +135,22 @@ const getParseAs = (contentType) => {
135
135
  return;
136
136
  };
137
137
  exports.getParseAs = getParseAs;
138
+ const checkForExistence = (options, name) => {
139
+ if (!name) {
140
+ return false;
141
+ }
142
+ if (options.headers.has(name) ||
143
+ options.query?.[name] ||
144
+ options.headers.get('Cookie')?.includes(`${name}=`)) {
145
+ return true;
146
+ }
147
+ return false;
148
+ };
138
149
  const setAuthParams = async ({ security, ...options }) => {
139
150
  for (const auth of security) {
151
+ if (checkForExistence(options, auth.name)) {
152
+ continue;
153
+ }
140
154
  const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
141
155
  if (!token) {
142
156
  continue;
@@ -157,7 +171,6 @@ const setAuthParams = async ({ security, ...options }) => {
157
171
  options.headers.set(name, token);
158
172
  break;
159
173
  }
160
- return;
161
174
  }
162
175
  };
163
176
  exports.setAuthParams = setAuthParams;
@@ -188,6 +188,25 @@ export const getParseAs = (
188
188
  return;
189
189
  };
190
190
 
191
+ const checkForExistence = (
192
+ options: Pick<RequestOptions, 'auth' | 'query'> & {
193
+ headers: Headers;
194
+ },
195
+ name?: string,
196
+ ): boolean => {
197
+ if (!name) {
198
+ return false;
199
+ }
200
+ if (
201
+ options.headers.has(name) ||
202
+ options.query?.[name] ||
203
+ options.headers.get('Cookie')?.includes(`${name}=`)
204
+ ) {
205
+ return true;
206
+ }
207
+ return false;
208
+ };
209
+
191
210
  export const setAuthParams = async ({
192
211
  security,
193
212
  ...options
@@ -196,6 +215,10 @@ export const setAuthParams = async ({
196
215
  headers: Headers;
197
216
  }) => {
198
217
  for (const auth of security) {
218
+ if (checkForExistence(options, auth.name)) {
219
+ continue;
220
+ }
221
+
199
222
  const token = await getAuthToken(auth, options.auth);
200
223
 
201
224
  if (!token) {
@@ -219,8 +242,6 @@ export const setAuthParams = async ({
219
242
  options.headers.set(name, token);
220
243
  break;
221
244
  }
222
-
223
- return;
224
245
  }
225
246
  };
226
247
 
@@ -6,6 +6,9 @@ const serializeFormDataPair = (data, key, value) => {
6
6
  if (typeof value === 'string' || value instanceof Blob) {
7
7
  data.append(key, value);
8
8
  }
9
+ else if (value instanceof Date) {
10
+ data.append(key, value.toISOString());
11
+ }
9
12
  else {
10
13
  data.append(key, JSON.stringify(value));
11
14
  }
@@ -23,6 +23,8 @@ const serializeFormDataPair = (
23
23
  ): void => {
24
24
  if (typeof value === 'string' || value instanceof Blob) {
25
25
  data.append(key, value);
26
+ } else if (value instanceof Date) {
27
+ data.append(key, value.toISOString());
26
28
  } else {
27
29
  data.append(key, JSON.stringify(value));
28
30
  }