@graphprotocol/graph-cli 0.24.1 → 0.25.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.
Files changed (105) hide show
  1. package/examples/basic-event-handlers/node_modules/chalk/node_modules/supports-color/index.js +50 -0
  2. package/examples/basic-event-handlers/node_modules/chalk/node_modules/supports-color/license +21 -0
  3. package/examples/basic-event-handlers/node_modules/chalk/node_modules/supports-color/package.json +49 -0
  4. package/examples/basic-event-handlers/node_modules/chalk/node_modules/supports-color/readme.md +36 -0
  5. package/examples/basic-event-handlers/node_modules/cliui/node_modules/ansi-regex/index.js +10 -0
  6. package/examples/basic-event-handlers/node_modules/cliui/node_modules/ansi-regex/license +9 -0
  7. package/examples/basic-event-handlers/node_modules/cliui/node_modules/ansi-regex/package.json +53 -0
  8. package/examples/basic-event-handlers/node_modules/cliui/node_modules/ansi-regex/readme.md +46 -0
  9. package/examples/basic-event-handlers/node_modules/cliui/node_modules/strip-ansi/index.js +4 -0
  10. package/examples/basic-event-handlers/node_modules/cliui/node_modules/strip-ansi/license +9 -0
  11. package/examples/basic-event-handlers/node_modules/cliui/node_modules/strip-ansi/package.json +52 -0
  12. package/examples/basic-event-handlers/node_modules/cliui/node_modules/strip-ansi/readme.md +39 -0
  13. package/examples/basic-event-handlers/node_modules/keccak/build/Makefile +342 -0
  14. package/examples/basic-event-handlers/node_modules/keccak/build/Release/.deps/Release/obj.target/keccak/src/addon.o.d.raw +27 -0
  15. package/examples/basic-event-handlers/node_modules/keccak/build/binding.Makefile +6 -0
  16. package/examples/basic-event-handlers/node_modules/keccak/build/config.gypi +207 -0
  17. package/examples/basic-event-handlers/node_modules/keccak/build/gyp-mac-tool +615 -0
  18. package/examples/basic-event-handlers/node_modules/keccak/build/keccak.target.mk +209 -0
  19. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/.coveralls.yml +1 -0
  20. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/.eslintrc +14 -0
  21. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/.travis.yml +20 -0
  22. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/CHANGELOG.md +395 -0
  23. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/LICENSE +19 -0
  24. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/Makefile +58 -0
  25. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/README.md +368 -0
  26. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/karma.conf.js +70 -0
  27. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/node.js +1 -0
  28. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/package.json +43 -0
  29. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/src/browser.js +195 -0
  30. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/src/debug.js +225 -0
  31. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/src/index.js +10 -0
  32. package/examples/basic-event-handlers/node_modules/mocha/node_modules/debug/src/node.js +186 -0
  33. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/LICENSE +15 -0
  34. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/README.md +368 -0
  35. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/changelog.md +67 -0
  36. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/common.js +240 -0
  37. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/glob.js +790 -0
  38. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/package.json +43 -0
  39. package/examples/basic-event-handlers/node_modules/rimraf/node_modules/glob/sync.js +486 -0
  40. package/examples/basic-event-handlers/node_modules/string-width/node_modules/ansi-regex/index.js +10 -0
  41. package/examples/basic-event-handlers/node_modules/string-width/node_modules/ansi-regex/license +9 -0
  42. package/examples/basic-event-handlers/node_modules/string-width/node_modules/ansi-regex/package.json +53 -0
  43. package/examples/basic-event-handlers/node_modules/string-width/node_modules/ansi-regex/readme.md +46 -0
  44. package/examples/basic-event-handlers/node_modules/string-width/node_modules/strip-ansi/index.js +4 -0
  45. package/examples/basic-event-handlers/node_modules/string-width/node_modules/strip-ansi/license +9 -0
  46. package/examples/basic-event-handlers/node_modules/string-width/node_modules/strip-ansi/package.json +52 -0
  47. package/examples/basic-event-handlers/node_modules/string-width/node_modules/strip-ansi/readme.md +39 -0
  48. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/index.js +46 -0
  49. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/license +21 -0
  50. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/package.json +45 -0
  51. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/readme.md +39 -0
  52. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/string-width/index.js +37 -0
  53. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/string-width/license +21 -0
  54. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/string-width/package.json +56 -0
  55. package/examples/basic-event-handlers/node_modules/wrap-ansi/node_modules/string-width/readme.md +42 -0
  56. package/package.json +2 -2
  57. package/src/codegen/schema.js +15 -5
  58. package/src/codegen/schema.test.js +368 -0
  59. package/src/codegen/types/defaults.js +34 -0
  60. package/src/codegen/types/index.js +8 -1
  61. package/src/codegen/typescript.js +7 -11
  62. package/src/command-helpers/scaffold.js +66 -0
  63. package/src/command-helpers/version.js +1 -1
  64. package/src/command-helpers/version.test.js +1 -1
  65. package/src/commands/init.js +129 -92
  66. package/src/commands/test.js +210 -27
  67. package/src/protocols/ethereum/contract.js +22 -0
  68. package/src/protocols/ethereum/scaffold/manifest.js +32 -0
  69. package/src/protocols/ethereum/scaffold/mapping.js +76 -0
  70. package/src/protocols/ethereum/subgraph.js +0 -14
  71. package/src/protocols/index.js +94 -12
  72. package/src/protocols/near/contract.js +46 -0
  73. package/src/protocols/near/scaffold/manifest.js +16 -0
  74. package/src/protocols/near/scaffold/mapping.js +39 -0
  75. package/src/protocols/near/subgraph.js +1 -23
  76. package/src/{scaffold.test.js → scaffold/ethereum.test.js} +27 -19
  77. package/src/scaffold/index.js +149 -0
  78. package/src/scaffold/mapping.js +49 -0
  79. package/src/scaffold/near.test.js +89 -0
  80. package/src/scaffold/schema.js +62 -0
  81. package/src/subgraph.js +8 -0
  82. package/src/validation/contract.js +56 -0
  83. package/src/validation/index.js +2 -1
  84. package/src/validation/manifest.js +0 -29
  85. package/tests/cli/init/{abis → ethereum/abis}/Marketplace.json +0 -0
  86. package/tests/cli/init/{abis → ethereum/abis}/OverloadedElements.json +0 -0
  87. package/tests/cli/init/{abis → ethereum/abis}/SoloMargin.json +0 -0
  88. package/tests/cli/init/{from-contract-with-abi-and-structs.stderr → ethereum/from-contract-with-abi-and-structs.stderr} +1 -1
  89. package/tests/cli/init/{from-contract-with-abi-and-structs.stdout → ethereum/from-contract-with-abi-and-structs.stdout} +0 -0
  90. package/tests/cli/init/{from-contract-with-abi.stderr → ethereum/from-contract-with-abi.stderr} +1 -1
  91. package/tests/cli/init/{from-contract-with-abi.stdout → ethereum/from-contract-with-abi.stdout} +0 -0
  92. package/tests/cli/init/{from-contract-with-overloaded-elements.stderr → ethereum/from-contract-with-overloaded-elements.stderr} +1 -1
  93. package/tests/cli/init/{from-contract-with-overloaded-elements.stdout → ethereum/from-contract-with-overloaded-elements.stdout} +0 -0
  94. package/tests/cli/init/{from-contract.stderr → ethereum/from-contract.stderr} +1 -1
  95. package/tests/cli/init/{from-contract.stdout → ethereum/from-contract.stdout} +0 -0
  96. package/tests/cli/init/{from-example.stderr → ethereum/from-example.stderr} +0 -0
  97. package/tests/cli/init/{from-example.stdout → ethereum/from-example.stdout} +0 -0
  98. package/tests/cli/init/near/from-contract.stderr +12 -0
  99. package/tests/cli/init/near/from-contract.stdout +12 -0
  100. package/tests/cli/init.test.js +143 -112
  101. package/tests/cli/util.js +56 -41
  102. package/tests/cli/validation/near-is-valid/subgraph.yaml +1 -0
  103. package/examples/basic-event-handlers/node_modules/mocha/lib/reporters/base.js.orig +0 -498
  104. package/examples/basic-event-handlers/node_modules/node-fetch/lib/index.js +0 -1416
  105. package/src/scaffold.js +0 -364
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "strip-ansi",
3
+ "version": "4.0.0",
4
+ "description": "Strip ANSI escape codes",
5
+ "license": "MIT",
6
+ "repository": "chalk/strip-ansi",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=4"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava"
17
+ },
18
+ "files": [
19
+ "index.js"
20
+ ],
21
+ "keywords": [
22
+ "strip",
23
+ "trim",
24
+ "remove",
25
+ "ansi",
26
+ "styles",
27
+ "color",
28
+ "colour",
29
+ "colors",
30
+ "terminal",
31
+ "console",
32
+ "string",
33
+ "tty",
34
+ "escape",
35
+ "formatting",
36
+ "rgb",
37
+ "256",
38
+ "shell",
39
+ "xterm",
40
+ "log",
41
+ "logging",
42
+ "command-line",
43
+ "text"
44
+ ],
45
+ "dependencies": {
46
+ "ansi-regex": "^3.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "ava": "*",
50
+ "xo": "*"
51
+ }
52
+ }
@@ -0,0 +1,39 @@
1
+ # strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi)
2
+
3
+ > Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
4
+
5
+
6
+ ## Install
7
+
8
+ ```
9
+ $ npm install strip-ansi
10
+ ```
11
+
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ const stripAnsi = require('strip-ansi');
17
+
18
+ stripAnsi('\u001B[4mUnicorn\u001B[0m');
19
+ //=> 'Unicorn'
20
+ ```
21
+
22
+
23
+ ## Related
24
+
25
+ - [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
26
+ - [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
27
+ - [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
28
+ - [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
29
+
30
+
31
+ ## Maintainers
32
+
33
+ - [Sindre Sorhus](https://github.com/sindresorhus)
34
+ - [Josh Junon](https://github.com/qix-)
35
+
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ var numberIsNan = require('number-is-nan');
3
+
4
+ module.exports = function (x) {
5
+ if (numberIsNan(x)) {
6
+ return false;
7
+ }
8
+
9
+ // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369
10
+
11
+ // code points are derived from:
12
+ // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
13
+ if (x >= 0x1100 && (
14
+ x <= 0x115f || // Hangul Jamo
15
+ 0x2329 === x || // LEFT-POINTING ANGLE BRACKET
16
+ 0x232a === x || // RIGHT-POINTING ANGLE BRACKET
17
+ // CJK Radicals Supplement .. Enclosed CJK Letters and Months
18
+ (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) ||
19
+ // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
20
+ 0x3250 <= x && x <= 0x4dbf ||
21
+ // CJK Unified Ideographs .. Yi Radicals
22
+ 0x4e00 <= x && x <= 0xa4c6 ||
23
+ // Hangul Jamo Extended-A
24
+ 0xa960 <= x && x <= 0xa97c ||
25
+ // Hangul Syllables
26
+ 0xac00 <= x && x <= 0xd7a3 ||
27
+ // CJK Compatibility Ideographs
28
+ 0xf900 <= x && x <= 0xfaff ||
29
+ // Vertical Forms
30
+ 0xfe10 <= x && x <= 0xfe19 ||
31
+ // CJK Compatibility Forms .. Small Form Variants
32
+ 0xfe30 <= x && x <= 0xfe6b ||
33
+ // Halfwidth and Fullwidth Forms
34
+ 0xff01 <= x && x <= 0xff60 ||
35
+ 0xffe0 <= x && x <= 0xffe6 ||
36
+ // Kana Supplement
37
+ 0x1b000 <= x && x <= 0x1b001 ||
38
+ // Enclosed Ideographic Supplement
39
+ 0x1f200 <= x && x <= 0x1f251 ||
40
+ // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
41
+ 0x20000 <= x && x <= 0x3fffd)) {
42
+ return true;
43
+ }
44
+
45
+ return false;
46
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "is-fullwidth-code-point",
3
+ "version": "1.0.0",
4
+ "description": "Check if the character represented by a given Unicode code point is fullwidth",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/is-fullwidth-code-point",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=0.10.0"
14
+ },
15
+ "scripts": {
16
+ "test": "node test.js"
17
+ },
18
+ "files": [
19
+ "index.js"
20
+ ],
21
+ "keywords": [
22
+ "fullwidth",
23
+ "full-width",
24
+ "full",
25
+ "width",
26
+ "unicode",
27
+ "character",
28
+ "char",
29
+ "string",
30
+ "str",
31
+ "codepoint",
32
+ "code",
33
+ "point",
34
+ "is",
35
+ "detect",
36
+ "check"
37
+ ],
38
+ "dependencies": {
39
+ "number-is-nan": "^1.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "ava": "0.0.4",
43
+ "code-point-at": "^1.0.0"
44
+ }
45
+ }
@@ -0,0 +1,39 @@
1
+ # is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point)
2
+
3
+ > Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms)
4
+
5
+
6
+ ## Install
7
+
8
+ ```
9
+ $ npm install --save is-fullwidth-code-point
10
+ ```
11
+
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ var isFullwidthCodePoint = require('is-fullwidth-code-point');
17
+
18
+ isFullwidthCodePoint('谢'.codePointAt());
19
+ //=> true
20
+
21
+ isFullwidthCodePoint('a'.codePointAt());
22
+ //=> false
23
+ ```
24
+
25
+
26
+ ## API
27
+
28
+ ### isFullwidthCodePoint(input)
29
+
30
+ #### input
31
+
32
+ Type: `number`
33
+
34
+ [Code point](https://en.wikipedia.org/wiki/Code_point) of a character.
35
+
36
+
37
+ ## License
38
+
39
+ MIT © [Sindre Sorhus](http://sindresorhus.com)
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ var stripAnsi = require('strip-ansi');
3
+ var codePointAt = require('code-point-at');
4
+ var isFullwidthCodePoint = require('is-fullwidth-code-point');
5
+
6
+ // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345
7
+ module.exports = function (str) {
8
+ if (typeof str !== 'string' || str.length === 0) {
9
+ return 0;
10
+ }
11
+
12
+ var width = 0;
13
+
14
+ str = stripAnsi(str);
15
+
16
+ for (var i = 0; i < str.length; i++) {
17
+ var code = codePointAt(str, i);
18
+
19
+ // ignore control characters
20
+ if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
21
+ continue;
22
+ }
23
+
24
+ // surrogates
25
+ if (code >= 0x10000) {
26
+ i++;
27
+ }
28
+
29
+ if (isFullwidthCodePoint(code)) {
30
+ width += 2;
31
+ } else {
32
+ width++;
33
+ }
34
+ }
35
+
36
+ return width;
37
+ };
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "string-width",
3
+ "version": "1.0.2",
4
+ "description": "Get the visual width of a string - the number of columns required to display it",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/string-width",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=0.10.0"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava"
17
+ },
18
+ "files": [
19
+ "index.js"
20
+ ],
21
+ "keywords": [
22
+ "string",
23
+ "str",
24
+ "character",
25
+ "char",
26
+ "unicode",
27
+ "width",
28
+ "visual",
29
+ "column",
30
+ "columns",
31
+ "fullwidth",
32
+ "full-width",
33
+ "full",
34
+ "ansi",
35
+ "escape",
36
+ "codes",
37
+ "cli",
38
+ "command-line",
39
+ "terminal",
40
+ "console",
41
+ "cjk",
42
+ "chinese",
43
+ "japanese",
44
+ "korean",
45
+ "fixed-width"
46
+ ],
47
+ "dependencies": {
48
+ "code-point-at": "^1.0.0",
49
+ "is-fullwidth-code-point": "^1.0.0",
50
+ "strip-ansi": "^3.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "ava": "*",
54
+ "xo": "*"
55
+ }
56
+ }
@@ -0,0 +1,42 @@
1
+ # string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width)
2
+
3
+ > Get the visual width of a string - the number of columns required to display it
4
+
5
+ Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
6
+
7
+ Useful to be able to measure the actual width of command-line output.
8
+
9
+
10
+ ## Install
11
+
12
+ ```
13
+ $ npm install --save string-width
14
+ ```
15
+
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ const stringWidth = require('string-width');
21
+
22
+ stringWidth('古');
23
+ //=> 2
24
+
25
+ stringWidth('\u001b[1m古\u001b[22m');
26
+ //=> 2
27
+
28
+ stringWidth('a');
29
+ //=> 1
30
+ ```
31
+
32
+
33
+ ## Related
34
+
35
+ - [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
36
+ - [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
37
+ - [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
38
+
39
+
40
+ ## License
41
+
42
+ MIT © [Sindre Sorhus](https://sindresorhus.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.24.1",
3
+ "version": "0.25.3",
4
4
  "description": "CLI for building for and deploying to The Graph",
5
5
  "dependencies": {
6
6
  "assemblyscript": "0.19.10",
@@ -12,7 +12,7 @@
12
12
  "dockerode": "^2.5.8",
13
13
  "fs-extra": "^9.0.0",
14
14
  "glob": "^7.1.2",
15
- "gluegun": "^4.3.1",
15
+ "gluegun": "https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep",
16
16
  "graphql": "^15.5.0",
17
17
  "immutable": "^3.8.2",
18
18
  "ipfs-http-client": "^34.0.0",
@@ -79,7 +79,8 @@ module.exports = class SchemaCodeGenerator {
79
79
  const fieldsSetCalls = fieldsWithoutId
80
80
  .map(field => {
81
81
  const name = field.getIn(['name', 'value'])
82
- const type = this._typeFromGraphQl(field.get('type'))
82
+ const type = this._typeFromGraphQl(field.get('type'), true, true)
83
+
83
84
  const isNullable = type instanceof tsCodegen.NullableType
84
85
 
85
86
  const directives = field.get('directives')
@@ -89,8 +90,12 @@ module.exports = class SchemaCodeGenerator {
89
90
  })
90
91
  // We only call the setter with the default value in the constructor for fields that are:
91
92
  // - Not nullable, so that AS doesn't break when subgraph developers try to access them before a `set`
93
+ // - It doesn't matter if it's primitive or not
92
94
  // - Not tagged as `derivedFrom`, because they only exist in query time
93
- .filter(({ isNullable, isDerivedFrom }) => !isNullable && !isDerivedFrom)
95
+ .filter(({
96
+ isNullable,
97
+ isDerivedFrom,
98
+ }) => !isNullable && !isDerivedFrom)
94
99
  .map(({ name, type, isNullable }) => {
95
100
  const fieldTypeString = isNullable ? type.inner.toString() : type.toString()
96
101
 
@@ -229,7 +234,7 @@ Suggestion: add an '!' to the member type of the List, change from '${fieldValue
229
234
  : gqlType.getIn(['name', 'value'])
230
235
  }
231
236
 
232
- _typeFromGraphQl(gqlType, nullable = true) {
237
+ _typeFromGraphQl(gqlType, nullable = true, nullablePrimitive = false) {
233
238
  if (gqlType.get('kind') === 'NonNullType') {
234
239
  return this._typeFromGraphQl(gqlType.get('type'), false)
235
240
  } else if (gqlType.get('kind') === 'ListType') {
@@ -240,8 +245,13 @@ Suggestion: add an '!' to the member type of the List, change from '${fieldValue
240
245
  let type = tsCodegen.namedType(
241
246
  typesCodegen.ascTypeForValue(gqlType.getIn(['name', 'value'])),
242
247
  )
243
- // In AssemblyScript, primitives cannot be nullable.
244
- return nullable && !type.isPrimitive() ? tsCodegen.nullableType(type) : type
248
+
249
+ // Will not wrap primitives into NullableType by default.
250
+ if (!nullablePrimitive && type.isPrimitive()) {
251
+ return type
252
+ }
253
+
254
+ return nullable ? tsCodegen.nullableType(type) : type
245
255
  }
246
256
  }
247
257
  }