Skip to content

Commit 933da83

Browse files
wangshijunclaude
andcommitted
chore: drop lodash.* deps from sdk-util and bump graphql/debug/p-retry
- Inline lodash.get/set in doBatchQuery; lodash.isnull in formatArgs - Remove lodash.get/lodash.set/lodash.isnull from sdk-util dependencies (paths were hard-coded literals with no prototype-pollution surface) - Bump graphql 16.5.0 -> ^16.13.2 across sdk-util/ocap-js/ocap-schema - Bump debug ^4.3.4 -> ^4.4.3 - Tighten p-retry "4" -> "^4.6.2" (stay on v4.x; v5+ is ESM-only) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0742e37 commit 933da83

6 files changed

Lines changed: 39 additions & 41 deletions

File tree

packages/ocap-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"eslint": "^5.16.0",
3131
"eslint-config-prettier": "latest",
3232
"eslint-plugin-prettier": "latest",
33-
"graphql": "16.5.0",
33+
"graphql": "^16.13.2",
3434
"jest": "^24.9.0",
3535
"prettier": "^1.19.1",
3636
"rimraf": "^2.7.1",

packages/ocap-schema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"eslint": "^5.16.0",
1818
"eslint-config-prettier": "latest",
1919
"eslint-plugin-prettier": "latest",
20-
"graphql": "16.5.0",
20+
"graphql": "^16.13.2",
2121
"graphql-request": "^4.3.0",
2222
"prettier": "^1.19.1"
2323
},

packages/sdk-util/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
"wangshijun <shijun@arcblock.io> (https://ocap.arcblock.io)"
1515
],
1616
"dependencies": {
17-
"debug": "^4.3.4",
18-
"graphql": "16.5.0",
19-
"lodash.get": "^4.4.2",
20-
"lodash.isnull": "^3.0.0",
21-
"lodash.set": "^4.3.2",
22-
"p-retry": "4"
17+
"debug": "^4.4.3",
18+
"graphql": "^16.13.2",
19+
"p-retry": "^4.6.2"
2320
},
2421
"devDependencies": {
2522
"@babel/cli": "^7.22.9",

packages/sdk-util/src/index.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const pRetry = require('p-retry');
2-
const set = require('lodash.set');
3-
const get = require('lodash.get');
42
const { parse } = require('graphql/language/parser');
53
const { print } = require('graphql/language/printer');
64
const { getQueryBuilders, getMutationBuilders, getSubscriptionBuilders } = require('./util');
@@ -126,22 +124,22 @@ class BaseClient {
126124
});
127125

128126
const base = documents.shift();
127+
const baseOp = base.definitions[0];
129128

130-
let variableDefinitions = get(base, 'definitions[0].variableDefinitions');
131-
let directives = get(base, 'definitions[0].directives');
132-
let selections = get(base, 'definitions[0].selectionSet.selections');
129+
let variableDefinitions = baseOp.variableDefinitions || [];
130+
let directives = baseOp.directives || [];
131+
let selections = baseOp.selectionSet.selections || [];
133132

134133
documents.forEach(x => {
135-
variableDefinitions = variableDefinitions.concat(
136-
get(x, 'definitions[0].variableDefinitions', [])
137-
);
138-
directives = directives.concat(get(x, 'definitions[0].directives', []));
139-
selections = selections.concat(get(x, 'definitions[0].selectionSet.selections', []));
134+
const op = x.definitions[0];
135+
variableDefinitions = variableDefinitions.concat(op.variableDefinitions || []);
136+
directives = directives.concat(op.directives || []);
137+
selections = selections.concat(op.selectionSet.selections || []);
140138
});
141139

142-
set(base, 'definitions[0].variableDefinitions', variableDefinitions);
143-
set(base, 'definitions[0].directives', directives);
144-
set(base, 'definitions[0].selectionSet.selections', selections);
140+
baseOp.variableDefinitions = variableDefinitions;
141+
baseOp.directives = directives;
142+
baseOp.selectionSet.selections = selections;
145143

146144
return this._doRequestWithRetry(print(base), requestOptions);
147145
}

packages/sdk-util/src/util.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const isNull = require('lodash.isnull');
21
const { parse } = require('graphql/language/parser');
32
const { print } = require('graphql/language/printer');
43

@@ -139,11 +138,13 @@ const makeQuery = (fields, ignoreFields, argValues = {}) => `
139138
.map(x => {
140139
const subQueryStr = `${x.name} {
141140
__typename
142-
${x.possibleTypes.filter(t => !ignoreFields.includes(t.name)).map(
143-
t => `... on ${t.name} {
141+
${x.possibleTypes
142+
.filter(t => !ignoreFields.includes(t.name))
143+
.map(
144+
t => `... on ${t.name} {
144145
${makeQuery(t.fields, ignoreFields, argValues).trim()}
145146
}`
146-
)}
147+
)}
147148
}`;
148149
149150
return subQueryStr;
@@ -190,23 +191,23 @@ const formatArgs = (values, specs = {}) => {
190191

191192
// escape slash(\) and double quotes (")
192193
if ('String' === type) {
193-
const container = isNull(value) ? null : String(value).includes('\n') ? '"""' : '"';
194-
195-
return isNull(value) ? null : `${container}${value
194+
if (value === null) return null;
195+
const container = String(value).includes('\n') ? '"""' : '"';
196+
return `${container}${value
196197
.toString()
197198
.replace(/\\/g, '\\\\')
198199
.replace(/"/g, '\\"')}${container}`;
199200
}
200201

201202
if (['DateTime', 'ID', 'HexString'].includes(type)) {
202-
return isNull(value) ? null : `"${value.toString()}"`;
203+
return value === null ? null : `"${value.toString()}"`;
203204
}
204205

205206
if (['BigNumber', 'Int', 'Float', 'Long', 'Boolean'].includes(type)) {
206207
return value;
207208
}
208209

209-
return isNull(value) ? value : value.toString();
210+
return value === null ? value : value.toString();
210211
};
211212

212213
const ensureList = v => (Array.isArray(v) ? v : [v]);

yarn.lock

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,13 +3764,20 @@ debug@^3.1.0:
37643764
dependencies:
37653765
ms "^2.1.1"
37663766

3767-
debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.4:
3767+
debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
37683768
version "4.4.1"
37693769
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b"
37703770
integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==
37713771
dependencies:
37723772
ms "^2.1.3"
37733773

3774+
debug@^4.4.3:
3775+
version "4.4.3"
3776+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
3777+
integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==
3778+
dependencies:
3779+
ms "^2.1.3"
3780+
37743781
debuglog@^1.0.1:
37753782
version "1.0.1"
37763783
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
@@ -5065,10 +5072,10 @@ graphql-request@^4.3.0:
50655072
extract-files "^9.0.0"
50665073
form-data "^3.0.0"
50675074

5068-
graphql@16.5.0:
5069-
version "16.5.0"
5070-
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.5.0.tgz#41b5c1182eaac7f3d47164fb247f61e4dfb69c85"
5071-
integrity sha512-qbHgh8Ix+j/qY+a/ZcJnFQ+j8ezakqPiHwPiZhV/3PgGlgf96QMBB5/f2rkiC9sgLoy/xvT6TSiaf2nTHJh5iA==
5075+
graphql@^16.13.2:
5076+
version "16.13.2"
5077+
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.13.2.tgz#4d2b73df5796b201f1bc2765f5d7067f689cb55f"
5078+
integrity sha512-5bJ+nf/UCpAjHM8i06fl7eLyVC9iuNAjm9qzkiu2ZGhM0VscSvS6WDPfAwkdkBuoXGM9FJSbKl6wylMwP9Ktig==
50725079

50735080
growly@^1.3.0:
50745081
version "1.3.0"
@@ -6744,11 +6751,6 @@ lodash.ismatch@^4.4.0:
67446751
resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"
67456752
integrity sha512-fPMfXjGQEV9Xsq/8MTSgUf255gawYRbjwMyDbcvDhXgV7enSZA0hynz6vMPnpAb5iONEzBHBPsT+0zes5Z301g==
67466753

6747-
lodash.isnull@^3.0.0:
6748-
version "3.0.0"
6749-
resolved "https://registry.yarnpkg.com/lodash.isnull/-/lodash.isnull-3.0.0.tgz#fafbe59ea1dca27eed786534039dd84c2e07c56e"
6750-
integrity sha512-9D6/H5PSHfhyPwZerI9J5hKBaXayxhVy7gt6OBAsXv8XBm+i107KqG99AoeIJObC6uCnVwp1LM7Ww1DKYYIKog==
6751-
67526754
lodash.set@^4.3.2:
67536755
version "4.3.2"
67546756
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
@@ -7838,7 +7840,7 @@ p-reduce@^1.0.0:
78387840
resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa"
78397841
integrity sha512-3Tx1T3oM1xO/Y8Gj0sWyE78EIJZ+t+aEmXUdvQgvGmSMri7aPTHoovbXEreWKkL5j21Er60XAWLTzKbAKYOujQ==
78407842

7841-
p-retry@4:
7843+
p-retry@^4.6.2:
78427844
version "4.6.2"
78437845
resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-4.6.2.tgz#9baae7184057edd4e17231cee04264106e092a16"
78447846
integrity sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==

0 commit comments

Comments
 (0)