@ethersphere/bee-js 13.0.0-upcoming.gcfb9756 → 13.0.0

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 (201) hide show
  1. package/README.md +104 -103
  2. package/dist/cjs/api/bytes.js +3 -4
  3. package/dist/cjs/api/bzz.js +5 -6
  4. package/dist/cjs/api/chunk.js +3 -3
  5. package/dist/cjs/api/envelope.js +3 -2
  6. package/dist/cjs/api/feed.js +4 -5
  7. package/dist/cjs/api/pin.js +2 -2
  8. package/dist/cjs/api/soc.js +2 -2
  9. package/dist/cjs/bee.js +18 -19
  10. package/dist/cjs/chunk/soc.js +21 -63
  11. package/dist/cjs/feed/identifier.js +3 -4
  12. package/dist/cjs/feed/index.js +17 -19
  13. package/dist/cjs/feed/retrievable.js +2 -2
  14. package/dist/cjs/index.js +18 -8
  15. package/dist/cjs/manifest/manifest.js +97 -333
  16. package/dist/cjs/modules/balance.js +3 -3
  17. package/dist/cjs/modules/cheque.js +4 -4
  18. package/dist/cjs/modules/chunk.js +8 -8
  19. package/dist/cjs/modules/collection.js +6 -6
  20. package/dist/cjs/modules/connectivity.js +3 -3
  21. package/dist/cjs/modules/data.js +6 -6
  22. package/dist/cjs/modules/feed.js +10 -10
  23. package/dist/cjs/modules/file.js +3 -3
  24. package/dist/cjs/modules/grantee.js +9 -9
  25. package/dist/cjs/modules/messaging.js +15 -17
  26. package/dist/cjs/modules/pin.js +6 -6
  27. package/dist/cjs/modules/settlement.js +2 -2
  28. package/dist/cjs/modules/soc.js +3 -3
  29. package/dist/cjs/modules/stamp.js +7 -7
  30. package/dist/cjs/modules/tag.js +2 -2
  31. package/dist/cjs/modules/transaction.js +4 -4
  32. package/dist/cjs/modules/wallet.js +3 -3
  33. package/dist/cjs/types/schema/chequebook.js +5 -5
  34. package/dist/cjs/types/schema/connectivity.js +5 -5
  35. package/dist/cjs/types/schema/envelope.js +5 -5
  36. package/dist/cjs/types/schema/grantee.js +4 -4
  37. package/dist/cjs/types/schema/stake.js +2 -2
  38. package/dist/cjs/types/schema/stamps.js +4 -4
  39. package/dist/cjs/types/schema/states.js +2 -2
  40. package/dist/cjs/types/schema/transactions.js +3 -3
  41. package/dist/cjs/types/schema/upload.js +2 -2
  42. package/dist/cjs/utils/chunk-stream.browser.js +24 -16
  43. package/dist/cjs/utils/chunk-stream.js +17 -9
  44. package/dist/cjs/utils/constants.js +3 -3
  45. package/dist/cjs/utils/expose.js +4 -4
  46. package/dist/cjs/utils/headers.js +4 -4
  47. package/dist/cjs/utils/http.js +3 -1
  48. package/dist/cjs/utils/pss.js +2 -2
  49. package/dist/cjs/utils/resource-locator.js +2 -2
  50. package/dist/cjs/utils/schema.js +4 -4
  51. package/dist/cjs/utils/stamps.js +15 -130
  52. package/dist/cjs/utils/type.js +2 -2
  53. package/dist/codemod/index.js +141 -0
  54. package/dist/codemod/transforms/v13.js +524 -0
  55. package/dist/index.browser.min.js +2 -1
  56. package/dist/index.browser.min.js.LICENSE.txt +3 -0
  57. package/dist/index.browser.min.js.map +1 -1
  58. package/dist/mjs/api/bytes.js +1 -2
  59. package/dist/mjs/api/bzz.js +1 -2
  60. package/dist/mjs/api/chunk.js +1 -1
  61. package/dist/mjs/api/envelope.js +3 -2
  62. package/dist/mjs/api/feed.js +1 -2
  63. package/dist/mjs/api/pin.js +1 -1
  64. package/dist/mjs/api/soc.js +1 -1
  65. package/dist/mjs/bee.js +13 -14
  66. package/dist/mjs/chunk/soc.js +11 -49
  67. package/dist/mjs/feed/identifier.js +2 -3
  68. package/dist/mjs/feed/index.js +6 -8
  69. package/dist/mjs/feed/retrievable.js +1 -1
  70. package/dist/mjs/index.js +2 -5
  71. package/dist/mjs/manifest/manifest.js +95 -339
  72. package/dist/mjs/modules/balance.js +1 -1
  73. package/dist/mjs/modules/cheque.js +1 -1
  74. package/dist/mjs/modules/chunk.js +1 -1
  75. package/dist/mjs/modules/collection.js +1 -1
  76. package/dist/mjs/modules/connectivity.js +1 -1
  77. package/dist/mjs/modules/data.js +3 -3
  78. package/dist/mjs/modules/feed.js +1 -1
  79. package/dist/mjs/modules/file.js +1 -1
  80. package/dist/mjs/modules/grantee.js +1 -1
  81. package/dist/mjs/modules/messaging.js +3 -5
  82. package/dist/mjs/modules/pin.js +1 -1
  83. package/dist/mjs/modules/settlement.js +1 -1
  84. package/dist/mjs/modules/soc.js +1 -1
  85. package/dist/mjs/modules/stamp.js +1 -1
  86. package/dist/mjs/modules/tag.js +1 -1
  87. package/dist/mjs/modules/transaction.js +1 -1
  88. package/dist/mjs/modules/wallet.js +1 -1
  89. package/dist/mjs/types/schema/chequebook.js +1 -1
  90. package/dist/mjs/types/schema/connectivity.js +1 -1
  91. package/dist/mjs/types/schema/envelope.js +5 -5
  92. package/dist/mjs/types/schema/grantee.js +1 -1
  93. package/dist/mjs/types/schema/stake.js +1 -1
  94. package/dist/mjs/types/schema/stamps.js +1 -1
  95. package/dist/mjs/types/schema/states.js +1 -1
  96. package/dist/mjs/types/schema/transactions.js +1 -1
  97. package/dist/mjs/types/schema/upload.js +1 -1
  98. package/dist/mjs/utils/chunk-stream.browser.js +28 -18
  99. package/dist/mjs/utils/chunk-stream.js +21 -11
  100. package/dist/mjs/utils/constants.js +1 -1
  101. package/dist/mjs/utils/expose.js +1 -1
  102. package/dist/mjs/utils/headers.js +1 -1
  103. package/dist/mjs/utils/http.js +6 -1
  104. package/dist/mjs/utils/pss.js +1 -1
  105. package/dist/mjs/utils/resource-locator.js +1 -1
  106. package/dist/mjs/utils/schema.js +1 -1
  107. package/dist/mjs/utils/stamps.js +5 -99
  108. package/dist/mjs/utils/type.js +2 -2
  109. package/dist/types/api/balance.d.ts +1 -1
  110. package/dist/types/api/batches.d.ts +1 -1
  111. package/dist/types/api/bytes.d.ts +3 -3
  112. package/dist/types/api/bzz.d.ts +1 -2
  113. package/dist/types/api/chequebook.d.ts +1 -1
  114. package/dist/types/api/chunk.d.ts +1 -1
  115. package/dist/types/api/connectivity.d.ts +1 -1
  116. package/dist/types/api/consumed.d.ts +1 -1
  117. package/dist/types/api/envelope.d.ts +1 -1
  118. package/dist/types/api/feed.d.ts +1 -2
  119. package/dist/types/api/grantee.d.ts +1 -1
  120. package/dist/types/api/pin.d.ts +1 -1
  121. package/dist/types/api/pss.d.ts +1 -1
  122. package/dist/types/api/settlement.d.ts +1 -1
  123. package/dist/types/api/soc.d.ts +1 -1
  124. package/dist/types/api/stake.d.ts +1 -1
  125. package/dist/types/api/stamp.d.ts +1 -1
  126. package/dist/types/api/stewardship.d.ts +1 -1
  127. package/dist/types/api/tag.d.ts +1 -1
  128. package/dist/types/api/transaction.d.ts +1 -1
  129. package/dist/types/api/wallet.d.ts +1 -1
  130. package/dist/types/bee.d.ts +11 -13
  131. package/dist/types/chunk/soc.d.ts +3 -48
  132. package/dist/types/feed/identifier.d.ts +1 -1
  133. package/dist/types/feed/index.d.ts +1 -3
  134. package/dist/types/feed/retrievable.d.ts +1 -1
  135. package/dist/types/index.d.ts +17 -20
  136. package/dist/types/manifest/manifest.d.ts +24 -33
  137. package/dist/types/modules/balance.d.ts +1 -1
  138. package/dist/types/modules/cheque.d.ts +1 -1
  139. package/dist/types/modules/chequebook.d.ts +1 -1
  140. package/dist/types/modules/chunk.d.ts +1 -2
  141. package/dist/types/modules/collection.d.ts +2 -2
  142. package/dist/types/modules/connectivity.d.ts +1 -1
  143. package/dist/types/modules/context.d.ts +1 -1
  144. package/dist/types/modules/data.d.ts +3 -3
  145. package/dist/types/modules/feed.d.ts +1 -1
  146. package/dist/types/modules/file.d.ts +1 -2
  147. package/dist/types/modules/grantee.d.ts +1 -1
  148. package/dist/types/modules/messaging.d.ts +1 -2
  149. package/dist/types/modules/pin.d.ts +1 -1
  150. package/dist/types/modules/settlement.d.ts +1 -1
  151. package/dist/types/modules/soc.d.ts +1 -1
  152. package/dist/types/modules/stake.d.ts +1 -1
  153. package/dist/types/modules/stamp.d.ts +1 -1
  154. package/dist/types/modules/storage.d.ts +1 -1
  155. package/dist/types/modules/tag.d.ts +1 -1
  156. package/dist/types/modules/transaction.d.ts +1 -1
  157. package/dist/types/modules/wallet.d.ts +1 -1
  158. package/dist/types/types/debug.d.ts +1 -1
  159. package/dist/types/types/index.d.ts +2 -11
  160. package/dist/types/types/schema/chequebook.d.ts +1 -1
  161. package/dist/types/types/schema/connectivity.d.ts +1 -1
  162. package/dist/types/types/schema/grantee.d.ts +1 -1
  163. package/dist/types/types/schema/stake.d.ts +1 -1
  164. package/dist/types/types/schema/stamps.d.ts +1 -1
  165. package/dist/types/types/schema/states.d.ts +1 -1
  166. package/dist/types/types/schema/transactions.d.ts +1 -1
  167. package/dist/types/types/schema/upload.d.ts +1 -1
  168. package/dist/types/utils/chunk-stream.browser.d.ts +1 -1
  169. package/dist/types/utils/chunk-stream.d.ts +2 -2
  170. package/dist/types/utils/constants.d.ts +1 -1
  171. package/dist/types/utils/expose.d.ts +1 -1
  172. package/dist/types/utils/headers.d.ts +1 -1
  173. package/dist/types/utils/pss.d.ts +1 -1
  174. package/dist/types/utils/resource-locator.d.ts +1 -1
  175. package/dist/types/utils/schema.d.ts +1 -1
  176. package/dist/types/utils/stamps.d.ts +2 -27
  177. package/dist/types/utils/tar-uploader.browser.d.ts +1 -1
  178. package/dist/types/utils/tar-uploader.d.ts +1 -1
  179. package/dist/types/utils/type.d.ts +1 -1
  180. package/package.json +7 -2
  181. package/dist/cjs/chunk/bmt.js +0 -37
  182. package/dist/cjs/chunk/cac.js +0 -43
  183. package/dist/cjs/stamper/stamper.js +0 -44
  184. package/dist/cjs/utils/bytes.js +0 -116
  185. package/dist/cjs/utils/cid.js +0 -37
  186. package/dist/cjs/utils/redundancy.js +0 -133
  187. package/dist/cjs/utils/typed-bytes.js +0 -186
  188. package/dist/mjs/chunk/bmt.js +0 -34
  189. package/dist/mjs/chunk/cac.js +0 -34
  190. package/dist/mjs/stamper/stamper.js +0 -40
  191. package/dist/mjs/utils/bytes.js +0 -102
  192. package/dist/mjs/utils/cid.js +0 -32
  193. package/dist/mjs/utils/redundancy.js +0 -98
  194. package/dist/mjs/utils/typed-bytes.js +0 -167
  195. package/dist/types/chunk/bmt.d.ts +0 -16
  196. package/dist/types/chunk/cac.d.ts +0 -40
  197. package/dist/types/stamper/stamper.d.ts +0 -15
  198. package/dist/types/utils/bytes.d.ts +0 -19
  199. package/dist/types/utils/cid.d.ts +0 -10
  200. package/dist/types/utils/redundancy.d.ts +0 -21
  201. package/dist/types/utils/typed-bytes.d.ts +0 -69
@@ -69,8 +69,8 @@ function isTag(value) {
69
69
  * @throws TypeError if not valid
70
70
  */
71
71
  function assertData(value) {
72
- if (typeof value !== 'string' && !(value instanceof Uint8Array)) {
73
- throw new TypeError('Data must be either string or Uint8Array!');
72
+ if (typeof value !== 'string' && !(value instanceof Uint8Array) && !(value instanceof Blob) && !isReadable(value)) {
73
+ throw new TypeError('Data must be either string, Uint8Array, Blob or Readable!');
74
74
  }
75
75
  }
76
76
  /**
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ let ts;
40
+ try {
41
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
42
+ ts = require('typescript');
43
+ }
44
+ catch {
45
+ console.error("This tool requires 'typescript' to be installed in your project.");
46
+ console.error('Run: npm install --save-dev typescript');
47
+ process.exit(1);
48
+ }
49
+ // TypeScript 7 replaced the classic Compiler API (ts.createProgram, ts.sys, etc.) this tool
50
+ // is built on with a new, explicitly "unstable" native AST API with a different shape -
51
+ // there's no ts.createProgram to fall back to, so fail clearly instead of crashing on it.
52
+ if (typeof ts.createProgram !== 'function') {
53
+ console.error(`This tool needs TypeScript's classic Compiler API, removed in TypeScript 7.0 (found ${ts.version}).`);
54
+ console.error('Install a supported version: npm install --save-dev typescript@^5.9.0');
55
+ process.exit(1);
56
+ }
57
+ const EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
58
+ const SKIP_DIRS = new Set(['node_modules', 'dist', '.git']);
59
+ function walkFiles(dir) {
60
+ const files = [];
61
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
62
+ if (entry.isDirectory()) {
63
+ if (!SKIP_DIRS.has(entry.name)) {
64
+ files.push(...walkFiles(path.join(dir, entry.name)));
65
+ }
66
+ }
67
+ else if (entry.isFile() && EXTENSIONS.some(ext => entry.name.endsWith(ext))) {
68
+ files.push(path.join(dir, entry.name));
69
+ }
70
+ }
71
+ return files;
72
+ }
73
+ function parseVersion(filename) {
74
+ const match = path.basename(filename).match(/^v?(\d+)/);
75
+ return match ? parseInt(match[1], 10) : 0;
76
+ }
77
+ const args = process.argv.slice(2);
78
+ const fromIdx = args.indexOf('--from');
79
+ const fromVersion = fromIdx !== -1 ? parseVersion(args[fromIdx + 1]) : 0;
80
+ const target = args.find((a, i) => !a.startsWith('--') && (fromIdx === -1 || i !== fromIdx + 1));
81
+ if (!target) {
82
+ console.error('Usage: npx bee-js-codemod <path> [--from <version>]');
83
+ console.error('Example: npx bee-js-codemod ./src --from v12');
84
+ process.exit(1);
85
+ }
86
+ const transformsDir = path.join(__dirname, 'transforms');
87
+ const transformFiles = fs
88
+ .readdirSync(transformsDir)
89
+ .filter(f => (f.endsWith('.ts') || f.endsWith('.js')) && !f.endsWith('.d.ts'))
90
+ .sort()
91
+ .filter(f => parseVersion(f) > fromVersion);
92
+ if (transformFiles.length === 0) {
93
+ console.log('No transforms to apply.');
94
+ process.exit(0);
95
+ }
96
+ console.log(`Applying: ${transformFiles.join(', ')}\n`);
97
+ const transforms = transformFiles.map(f => {
98
+ const modulePath = path.join(transformsDir, f.replace(/\.(ts|js)$/, ''));
99
+ return require(modulePath).transform;
100
+ });
101
+ const resolved = path.resolve(target);
102
+ const stat = fs.statSync(resolved);
103
+ const files = (stat.isDirectory() ? walkFiles(resolved) : [resolved]).map(f => path.resolve(f));
104
+ const targetSet = new Set(files);
105
+ // Load the target project's compiler options so imports and the bee-js types resolve; fall
106
+ // back to permissive defaults when no tsconfig is found nearby.
107
+ function loadCompilerOptions(from) {
108
+ const configPath = ts.findConfigFile(from, ts.sys.fileExists, 'tsconfig.json');
109
+ if (configPath) {
110
+ const read = ts.readConfigFile(configPath, ts.sys.readFile);
111
+ const parsed = ts.parseJsonConfigFileContent(read.config ?? {}, ts.sys, path.dirname(configPath));
112
+ return { ...parsed.options, noEmit: true, allowJs: true, checkJs: false };
113
+ }
114
+ return {
115
+ allowJs: true,
116
+ checkJs: false,
117
+ noEmit: true,
118
+ target: ts.ScriptTarget.ESNext,
119
+ module: ts.ModuleKind.NodeNext,
120
+ moduleResolution: ts.ModuleResolutionKind.NodeNext,
121
+ };
122
+ }
123
+ const options = loadCompilerOptions(stat.isDirectory() ? resolved : path.dirname(resolved));
124
+ const changedFiles = new Set();
125
+ // Each transform version gets a freshly built program so it sees edits from the previous one.
126
+ for (const transform of transforms) {
127
+ const program = ts.createProgram(files, options);
128
+ const checker = program.getTypeChecker();
129
+ for (const sourceFile of program.getSourceFiles()) {
130
+ const filePath = path.resolve(sourceFile.fileName);
131
+ if (!targetSet.has(filePath))
132
+ continue;
133
+ const result = transform(sourceFile, checker);
134
+ if (result !== null && result !== sourceFile.text) {
135
+ fs.writeFileSync(filePath, result, 'utf8');
136
+ console.log(`updated: ${filePath}`);
137
+ changedFiles.add(filePath);
138
+ }
139
+ }
140
+ }
141
+ console.log(`\n${changedFiles.size} file(s) updated, ${files.length - changedFiles.size} unchanged.`);