@shivam995364/uplink-nodejs-test 0.1.0-beta.6 → 0.1.0-beta.8

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 (86) hide show
  1. package/Makefile +97 -8
  2. package/README.md +62 -53
  3. package/binding.gyp +6 -0
  4. package/dist/debug/index.d.ts +23 -0
  5. package/dist/debug/index.d.ts.map +1 -1
  6. package/dist/debug/index.js +26 -0
  7. package/dist/debug/index.js.map +1 -1
  8. package/dist/download/index.js +2 -2
  9. package/dist/download/index.js.map +1 -1
  10. package/dist/errors/exceptions.d.ts +104 -110
  11. package/dist/errors/exceptions.d.ts.map +1 -1
  12. package/dist/errors/exceptions.js +32 -179
  13. package/dist/errors/exceptions.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/multipart/index.d.ts.map +1 -1
  19. package/dist/multipart/index.js +32 -2
  20. package/dist/multipart/index.js.map +1 -1
  21. package/dist/native/index.d.ts +81 -4
  22. package/dist/native/index.d.ts.map +1 -1
  23. package/dist/native/index.js +13 -1
  24. package/dist/native/index.js.map +1 -1
  25. package/dist/project/index.d.ts.map +1 -1
  26. package/dist/project/index.js +32 -2
  27. package/dist/project/index.js.map +1 -1
  28. package/dist/types/index.d.ts +6 -6
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/native/include/uplink.h +93 -91
  31. package/native/include/uplink_definitions.h +0 -1
  32. package/native/prebuilds/darwin-arm64/uplink_native.node +0 -0
  33. package/native/src/access/access_complete.c +48 -80
  34. package/native/src/access/access_ops.c +45 -4
  35. package/native/src/addon.c +34 -6
  36. package/native/src/bucket/bucket_complete.c +99 -79
  37. package/native/src/bucket/bucket_complete.h +5 -1
  38. package/native/src/bucket/bucket_execute.c +53 -37
  39. package/native/src/bucket/bucket_execute.h +5 -1
  40. package/native/src/bucket/bucket_ops.c +207 -12
  41. package/native/src/bucket/bucket_ops.h +27 -7
  42. package/native/src/bucket/bucket_types.h +46 -5
  43. package/native/src/common/cancel_helpers.h +49 -0
  44. package/native/src/common/error_registry.c +407 -0
  45. package/native/src/common/error_registry.h +83 -0
  46. package/native/src/common/object_converter.c +78 -0
  47. package/native/src/common/object_converter.h +34 -0
  48. package/native/src/common/result_helpers.c +2 -6
  49. package/native/src/common/type_converters.c +6 -4
  50. package/native/src/debug/debug_ops.c +112 -0
  51. package/native/src/debug/debug_ops.h +12 -0
  52. package/native/src/download/download_complete.c +13 -94
  53. package/native/src/download/download_complete.h +0 -3
  54. package/native/src/download/download_ops.c +6 -0
  55. package/native/src/edge/edge_complete.c +97 -0
  56. package/native/src/edge/edge_complete.h +24 -0
  57. package/native/src/edge/edge_execute.c +56 -0
  58. package/native/src/edge/edge_execute.h +23 -0
  59. package/native/src/edge/edge_ops.c +13 -168
  60. package/native/src/edge/edge_types.h +51 -0
  61. package/native/src/encryption/encryption_complete.c +52 -0
  62. package/native/src/encryption/encryption_complete.h +19 -0
  63. package/native/src/encryption/encryption_execute.c +36 -0
  64. package/native/src/encryption/encryption_execute.h +18 -0
  65. package/native/src/encryption/encryption_ops.c +14 -78
  66. package/native/src/encryption/encryption_types.h +34 -0
  67. package/native/src/multipart/multipart_complete.c +219 -245
  68. package/native/src/multipart/multipart_complete.h +12 -4
  69. package/native/src/multipart/multipart_execute.c +122 -94
  70. package/native/src/multipart/multipart_execute.h +12 -4
  71. package/native/src/multipart/multipart_ops.c +423 -14
  72. package/native/src/multipart/multipart_ops.h +28 -18
  73. package/native/src/multipart/multipart_types.h +82 -10
  74. package/native/src/object/object_complete.c +107 -148
  75. package/native/src/object/object_complete.h +22 -2
  76. package/native/src/object/object_execute.c +55 -37
  77. package/native/src/object/object_execute.h +22 -2
  78. package/native/src/object/object_ops.c +194 -16
  79. package/native/src/object/object_ops.h +27 -7
  80. package/native/src/object/object_types.h +41 -5
  81. package/native/src/project/project_complete.c +10 -43
  82. package/native/src/upload/upload_complete.c +16 -92
  83. package/native/src/upload/upload_complete.h +0 -3
  84. package/native/src/upload/upload_ops.c +11 -0
  85. package/package.json +3 -3
  86. package/scripts/postinstall-fallback.js +43 -0
package/Makefile CHANGED
@@ -128,6 +128,37 @@ GO_ARCH_x64 := amd64
128
128
  GO_ARCH_arm64 := arm64
129
129
  GO_ARCH := $(GO_ARCH_$(EFFECTIVE_ARCH))
130
130
 
131
+ # ─── Persistent install method (.uplinkrc) ───────────────────────────────────
132
+ # If UPLINK_INSTALL is not set, check for a saved method in .uplinkrc.
133
+ # The .uplinkrc file lives in the consumer's project root (INIT_CWD), NOT inside
134
+ # node_modules, so it survives `rm -rf node_modules && npm install`.
135
+ #
136
+ # Priority: UPLINK_INSTALL env var > .uplinkrc file > auto-detect
137
+ #
138
+ # INIT_CWD is set by npm/yarn/pnpm to the directory where the user ran npm install.
139
+ # When running make directly (not via npm), INIT_CWD won't be set, so we skip.
140
+ UPLINKRC_DIR := $(or $(INIT_CWD),$(CURDIR))
141
+ UPLINKRC_FILE := $(UPLINKRC_DIR)/.uplinkrc
142
+
143
+ ifndef UPLINK_INSTALL
144
+ # Try to read saved method from .uplinkrc
145
+ _SAVED_METHOD := $(shell cat "$(UPLINKRC_FILE)" 2>/dev/null | tr -d '[:space:]')
146
+ ifneq ($(_SAVED_METHOD),)
147
+ # Validate: only accept known values
148
+ ifneq ($(filter $(_SAVED_METHOD),prebuilt hybrid source skip),)
149
+ UPLINK_INSTALL := $(_SAVED_METHOD)
150
+ _UPLINK_FROM_RC := 1
151
+ $(info [uplink-nodejs] .uplinkrc found at $(UPLINKRC_FILE) → method="$(_SAVED_METHOD)")
152
+ else
153
+ $(info [uplink-nodejs] .uplinkrc found but contains invalid value "$(_SAVED_METHOD)" — ignoring)
154
+ endif
155
+ else
156
+ $(info [uplink-nodejs] No .uplinkrc found at $(UPLINKRC_FILE) — will auto-detect)
157
+ endif
158
+ else
159
+ $(info [uplink-nodejs] UPLINK_INSTALL="$(UPLINK_INSTALL)" set via env — .uplinkrc skipped)
160
+ endif
161
+
131
162
  # Default target
132
163
  .PHONY: all
133
164
  all: prebuild build
@@ -375,15 +406,58 @@ npm-install:
375
406
  # UPLINK_INSTALL=source npm install pkg # source build
376
407
  .PHONY: install
377
408
  install:
409
+ @echo ""
410
+ @echo "╔══════════════════════════════════════════════════════════════╗"
411
+ @echo "║ uplink-nodejs — Native Module Installer ║"
412
+ @echo "╚══════════════════════════════════════════════════════════════╝"
413
+ @echo ""
414
+ @echo " Package version : $(ADDON_VERSION)"
415
+ @echo " Uplink-C version: $(UPLINK_C_VERSION)"
416
+ @echo " Platform : $(PLATFORM)"
417
+ @echo " OS : $(DETECTED_OS)"
418
+ @echo " Architecture : $(DETECTED_ARCH)"
419
+ @echo " Node.js : $$(node --version 2>/dev/null || echo 'not found')"
420
+ ifdef _UPLINK_FROM_RC
421
+ @echo " Install method : $(UPLINK_INSTALL) (from $(UPLINKRC_FILE))"
422
+ else
423
+ @echo " Install method : $(or $(UPLINK_INSTALL),auto)"
424
+ endif
425
+ @echo " Prebuilds dir : $(PLATFORM_DIR)"
426
+ @echo ""
378
427
  ifeq ($(UPLINK_INSTALL),prebuilt)
428
+ @echo "[uplink-nodejs] Method: prebuilt (using shipped binaries)"
429
+ @echo ""
379
430
  @$(MAKE) install-prebuilt-shipped
431
+ ifndef _UPLINK_FROM_RC
432
+ @echo "$(UPLINK_INSTALL)" > "$(UPLINKRC_FILE)" 2>/dev/null && \
433
+ echo "[uplink-nodejs] ✔ Saved install method to $(UPLINKRC_FILE)" || true
434
+ endif
380
435
  else ifeq ($(UPLINK_INSTALL),hybrid)
436
+ @echo "[uplink-nodejs] Method: hybrid (download lib + compile addon)"
437
+ @echo ""
381
438
  @$(MAKE) install-hybrid
439
+ ifndef _UPLINK_FROM_RC
440
+ @echo "$(UPLINK_INSTALL)" > "$(UPLINKRC_FILE)" 2>/dev/null && \
441
+ echo "[uplink-nodejs] ✔ Saved install method to $(UPLINKRC_FILE)" || true
442
+ endif
382
443
  else ifeq ($(UPLINK_INSTALL),source)
444
+ @echo "[uplink-nodejs] Method: source (full build from source)"
445
+ @echo ""
383
446
  @$(MAKE) install-source
447
+ ifndef _UPLINK_FROM_RC
448
+ @echo "$(UPLINK_INSTALL)" > "$(UPLINKRC_FILE)" 2>/dev/null && \
449
+ echo "[uplink-nodejs] ✔ Saved install method to $(UPLINKRC_FILE)" || true
450
+ endif
384
451
  else ifeq ($(UPLINK_INSTALL),skip)
385
- $(Q)echo "[uplink-nodejs] Skipping native build (UPLINK_INSTALL=skip)"
452
+ @echo "[uplink-nodejs] Method: skip — skipping native build"
453
+ @echo ""
454
+ ifndef _UPLINK_FROM_RC
455
+ @echo "$(UPLINK_INSTALL)" > "$(UPLINKRC_FILE)" 2>/dev/null && \
456
+ echo "[uplink-nodejs] ✔ Saved install method to $(UPLINKRC_FILE)" || true
457
+ endif
386
458
  else
459
+ @echo "[uplink-nodejs] Method: auto-detect (prebuilt → hybrid → source)"
460
+ @echo ""
387
461
  @$(MAKE) install-auto
388
462
  endif
389
463
 
@@ -860,14 +934,29 @@ endif
860
934
  # Order: prebuilt-shipped → hybrid → source
861
935
  .PHONY: install-auto
862
936
  install-auto:
863
- $(Q)echo ""
864
- $(Q)echo "╔══════════════════════════════════════════════════════════════╗"
865
- $(Q)echo "║ Auto-detecting best installation method... ║"
866
- $(Q)echo "╚══════════════════════════════════════════════════════════════╝"
867
- $(Q)echo ""
937
+ @echo ""
938
+ @echo "╔══════════════════════════════════════════════════════════════╗"
939
+ @echo "║ Auto-detecting best installation method... ║"
940
+ @echo "╚══════════════════════════════════════════════════════════════╝"
941
+ @echo ""
942
+ @echo "[uplink-nodejs] Step 1: Trying prebuilt shipped binaries..."
868
943
  @$(MAKE) install-prebuilt-shipped 2>/dev/null \
869
- || $(MAKE) install-hybrid 2>/dev/null \
870
- || $(MAKE) install-source
944
+ && echo "" \
945
+ && echo "[uplink-nodejs] ✓ Prebuilt shipped binaries — success" \
946
+ || ( \
947
+ echo "[uplink-nodejs] ✗ Prebuilt shipped binaries not available"; \
948
+ echo ""; \
949
+ echo "[uplink-nodejs] Step 2: Trying hybrid build (download lib + compile addon)..."; \
950
+ $(MAKE) install-hybrid 2>&1 \
951
+ && echo "" \
952
+ && echo "[uplink-nodejs] ✓ Hybrid build — success" \
953
+ || ( \
954
+ echo "[uplink-nodejs] ✗ Hybrid build failed"; \
955
+ echo ""; \
956
+ echo "[uplink-nodejs] Step 3: Trying full source build..."; \
957
+ $(MAKE) install-source \
958
+ ) \
959
+ )
871
960
 
872
961
  # ------------------------------------------------------------------------------
873
962
  # Verification
package/README.md CHANGED
@@ -4,86 +4,82 @@ Node.js native bindings for [Storj's](https://www.storj.io) uplink-c library —
4
4
 
5
5
  ## Installation
6
6
 
7
+ ### Quick Install (auto-detect)
8
+
7
9
  ```bash
8
10
  npm install @shivam995364/uplink-nodejs-test
9
11
  ```
10
12
 
11
- After `npm install`, the package automatically tries to build the native addon. If it can't (e.g. no C compiler or no `make`), it exits gracefully — you can build later using one of the methods below.
12
-
13
- ### Installation Methods
14
-
15
- There are **3 ways** to install the native binaries, depending on your environment:
13
+ By default, `npm install` **auto-detects** the best installation method:
14
+ **prebuilt** (shipped binaries) → **hybrid** (compile addon) → **source** (full build).
16
15
 
17
- | # | Method | Command | Requirements | Speed |
18
- |---|--------|---------|-------------|-------|
19
- | 1 | **Prebuilt** | `make install-prebuilt` | Node.js, curl | ⚡ Fastest |
20
- | 2 | **Hybrid** *(default)* | `make install-hybrid` | Node.js, C compiler, curl | 🔧 Recommended |
21
- | 3 | **Source** | `make install-source` | Node.js, Go, C compiler, Git | 🛠️ Full control |
16
+ If prebuilt binaries are shipped for your platform (macOS arm64, Windows x64), it completes instantly with **zero compilation**.
22
17
 
23
- #### Option 1: Prebuilt (no compilation)
18
+ ---
24
19
 
25
- Downloads both the `libuplink` shared library **and** the prebuilt `.node` addon from GitHub Releases. No compiler needed.
26
-
27
- ```bash
28
- npm install @shivam995364/uplink-nodejs-test
29
- cd node_modules/@shivam995364/uplink-nodejs-test
30
- make install-prebuilt
31
- ```
20
+ ### Choose Installation Method
32
21
 
33
- Or via npm script:
22
+ Set the `UPLINK_INSTALL` environment variable to pick a specific method — **all in one command**:
34
23
 
35
24
  ```bash
36
- npm run install:prebuilt
37
- ```
25
+ # Use shipped prebuilt binaries (no compiler needed)
26
+ UPLINK_INSTALL=prebuilt npm install @shivam995364/uplink-nodejs-test
38
27
 
39
- #### Option 2: Hybrid (recommended)
28
+ # Compile the Node.js addon from C source (uses shipped libuplink)
29
+ UPLINK_INSTALL=hybrid npm install @shivam995364/uplink-nodejs-test
40
30
 
41
- Downloads the prebuilt `libuplink` shared library, then compiles the Node.js native addon locally with `node-gyp`. This is the default method used by `make install`.
31
+ # Build everything from source including libuplink (Go + C)
32
+ UPLINK_INSTALL=source npm install @shivam995364/uplink-nodejs-test
42
33
 
43
- ```bash
44
- npm install @shivam995364/uplink-nodejs-test
45
- cd node_modules/@shivam995364/uplink-nodejs-test
46
- make install-hybrid
34
+ # Skip native build entirely (install JS only, build later)
35
+ UPLINK_INSTALL=skip npm install @shivam995364/uplink-nodejs-test
47
36
  ```
48
37
 
49
- Or via npm script:
50
-
51
- ```bash
52
- npm run install:hybrid
53
- ```
38
+ > **Windows (PowerShell):**
39
+ > ```powershell
40
+ > $env:UPLINK_INSTALL="prebuilt"; npm install @shivam995364/uplink-nodejs-test
41
+ > ```
54
42
 
55
- **Requirements:** C compiler (`gcc`, `clang`, or MSVC), Python 3.x (for node-gyp)
43
+ > **Windows (CMD):**
44
+ > ```cmd
45
+ > set UPLINK_INSTALL=prebuilt && npm install @shivam995364/uplink-nodejs-test
46
+ > ```
56
47
 
57
- #### Option 3: Source (full build)
48
+ ### UPLINK_INSTALL Values
58
49
 
59
- Builds everything from source clones (or uses a local copy of) `uplink-c`, compiles the Go shared library, and then compiles the Node.js addon.
50
+ | Value | What it does | Requirements | Speed |
51
+ |-------|-------------|-------------|-------|
52
+ | *(unset)* | Auto-detect: prebuilt → hybrid → source | Varies | ⚡ → 🛠️ |
53
+ | `prebuilt` | Use binaries shipped in the npm package | Node.js only | ⚡ Instant |
54
+ | `hybrid` | Compile `.node` addon from shipped C source | C compiler | 🔧 ~30s |
55
+ | `source` | Build `libuplink` from Go + compile addon | Go + C compiler + Git | 🛠️ ~2min |
56
+ | `skip` | Skip native build entirely | None | ⚡ Instant |
60
57
 
61
- ```bash
62
- npm install @shivam995364/uplink-nodejs-test
63
- cd node_modules/@shivam995364/uplink-nodejs-test
64
- make install-source
65
- ```
58
+ ### Using Make Directly
66
59
 
67
- Or with a local uplink-c checkout:
60
+ You can also use Make targets directly (equivalent to the env var approach):
68
61
 
69
62
  ```bash
70
- make install-source UPLINK_C_DIR=/path/to/uplink-c
63
+ make install # auto-detect
64
+ UPLINK_INSTALL=prebuilt make install # prebuilt
65
+ UPLINK_INSTALL=hybrid make install # hybrid
66
+ UPLINK_INSTALL=source make install # source
71
67
  ```
72
68
 
73
- Or via npm script:
69
+ Or the dedicated targets:
74
70
 
75
71
  ```bash
76
- npm run install:source
72
+ make install-prebuilt # Download everything (no compiler)
73
+ make install-hybrid # Download lib, compile addon
74
+ make install-source # Build everything from source
77
75
  ```
78
76
 
79
- **Requirements:** Go 1.21+, Git, C compiler, Python 3.x
80
-
81
- #### Auto-detect
82
-
83
- Let the Makefile choose the best available method (tries hybrid first, falls back to source):
77
+ With a local uplink-c checkout:
84
78
 
85
79
  ```bash
86
- make install
80
+ UPLINK_INSTALL=source UPLINK_C_DIR=/path/to/uplink-c npm install @shivam995364/uplink-nodejs-test
81
+ # or
82
+ make install-source UPLINK_C_DIR=/path/to/uplink-c
87
83
  ```
88
84
 
89
85
  ### Verify Installation
@@ -107,6 +103,9 @@ make verify-full
107
103
  You can customise the build with environment variables:
108
104
 
109
105
  ```bash
106
+ # Select installation method
107
+ UPLINK_INSTALL=prebuilt make install
108
+
110
109
  # Use a specific uplink-c version
111
110
  make install-hybrid UPLINK_C_VERSION=v1.13.0
112
111
 
@@ -120,6 +119,15 @@ make download-lib FORCE_DOWNLOAD=1
120
119
  make install-hybrid VERBOSE=1
121
120
  ```
122
121
 
122
+ | Variable | Description | Default |
123
+ |----------|-------------|---------|
124
+ | `UPLINK_INSTALL` | Installation method: `prebuilt`, `hybrid`, `source`, `skip` | auto-detect |
125
+ | `UPLINK_C_DIR` | Path to uplink-c source | `../uplink-c` |
126
+ | `UPLINK_C_VERSION` | uplink-c version to download/clone | `v1.14.0` |
127
+ | `PLATFORM` | Target platform override | auto-detect |
128
+ | `FORCE_DOWNLOAD` | Force re-download (`1` to enable) | `0` |
129
+ | `VERBOSE` | Verbose output (`1` to enable) | `0` |
130
+
123
131
  ### Installing Make on Windows
124
132
 
125
133
  ```powershell
@@ -216,6 +224,7 @@ make test-c
216
224
 
217
225
  | Variable | Description | Default |
218
226
  |----------|-------------|---------|
227
+ | `UPLINK_INSTALL` | Installation method: `prebuilt`, `hybrid`, `source`, `skip`, or auto | auto-detect |
219
228
  | `UPLINK_LOG_LEVEL` | Log level: `none`, `error`, `warn`, `info`, `debug`, `trace` | `info` |
220
229
  | `UPLINK_LOG_FILE` | Path to log file | none (stdout) |
221
230
  | `UPLINK_LIBRARY_PATH` | Custom path to uplink-c library | auto-detect |
@@ -227,9 +236,9 @@ Run `make help` for the full list. Highlights:
227
236
  | Command | Description |
228
237
  |---------|-------------|
229
238
  | `make install` | Auto-detect best installation method |
230
- | `make install-prebuilt` | Download everything (no compiler) |
231
- | `make install-hybrid` | Download lib, build addon locally |
232
- | `make install-source` | Build everything from source |
239
+ | `UPLINK_INSTALL=prebuilt make install` | Use shipped prebuilt binaries |
240
+ | `UPLINK_INSTALL=hybrid make install` | Compile addon only |
241
+ | `UPLINK_INSTALL=source make install` | Full source build |
233
242
  | `make build` | Build TypeScript + native addon |
234
243
  | `make test` | Run all tests |
235
244
  | `make verify-full` | Verify library + addon installed |
package/binding.gyp CHANGED
@@ -11,6 +11,8 @@
11
11
  "native/src/common/result_helpers.c",
12
12
  "native/src/common/type_converters.c",
13
13
  "native/src/common/library_loader.c",
14
+ "native/src/common/error_registry.c",
15
+ "native/src/common/object_converter.c",
14
16
  "native/src/access/access_ops.c",
15
17
  "native/src/access/access_execute.c",
16
18
  "native/src/access/access_complete.c",
@@ -30,10 +32,14 @@
30
32
  "native/src/download/download_execute.c",
31
33
  "native/src/download/download_complete.c",
32
34
  "native/src/encryption/encryption_ops.c",
35
+ "native/src/encryption/encryption_execute.c",
36
+ "native/src/encryption/encryption_complete.c",
33
37
  "native/src/multipart/multipart_ops.c",
34
38
  "native/src/multipart/multipart_execute.c",
35
39
  "native/src/multipart/multipart_complete.c",
36
40
  "native/src/edge/edge_ops.c",
41
+ "native/src/edge/edge_execute.c",
42
+ "native/src/edge/edge_complete.c",
37
43
  "native/src/debug/debug_ops.c"
38
44
  ],
39
45
  "include_dirs": [
@@ -51,4 +51,27 @@ export declare function internalUniverseIsEmpty(): Promise<boolean>;
51
51
  * @see internalUniverseIsEmpty
52
52
  */
53
53
  export declare const uplinkInternalUniverseIsEmpty: typeof internalUniverseIsEmpty;
54
+ /**
55
+ * Test function: throws a typed StorjError from native code.
56
+ *
57
+ * Always returns a rejected promise with a properly-typed StorjError
58
+ * subclass instance. This is used to verify that `instanceof` checks
59
+ * work on errors originating from native async operations.
60
+ *
61
+ * @param code - Error code (e.g. 0x13 for BUCKET_NOT_FOUND)
62
+ * @param message - Error message / details string
63
+ * @returns Promise that always rejects with a typed StorjError
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { testThrowTypedError, BucketNotFoundError } from 'uplink-nodejs';
68
+ *
69
+ * try {
70
+ * await testThrowTypedError(0x13, 'bucket "test" not found');
71
+ * } catch (error) {
72
+ * console.log(error instanceof BucketNotFoundError); // true
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function testThrowTypedError(code: number, message: string): Promise<never>;
54
77
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEhE;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,gCAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAEhE;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,gCAA0B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAEvF"}
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.uplinkInternalUniverseIsEmpty = void 0;
10
10
  exports.internalUniverseIsEmpty = internalUniverseIsEmpty;
11
+ exports.testThrowTypedError = testThrowTypedError;
11
12
  const native_1 = require("../native");
12
13
  /**
13
14
  * Check if the internal handle universe is empty.
@@ -58,4 +59,29 @@ async function internalUniverseIsEmpty() {
58
59
  * @see internalUniverseIsEmpty
59
60
  */
60
61
  exports.uplinkInternalUniverseIsEmpty = internalUniverseIsEmpty;
62
+ /**
63
+ * Test function: throws a typed StorjError from native code.
64
+ *
65
+ * Always returns a rejected promise with a properly-typed StorjError
66
+ * subclass instance. This is used to verify that `instanceof` checks
67
+ * work on errors originating from native async operations.
68
+ *
69
+ * @param code - Error code (e.g. 0x13 for BUCKET_NOT_FOUND)
70
+ * @param message - Error message / details string
71
+ * @returns Promise that always rejects with a typed StorjError
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * import { testThrowTypedError, BucketNotFoundError } from 'uplink-nodejs';
76
+ *
77
+ * try {
78
+ * await testThrowTypedError(0x13, 'bucket "test" not found');
79
+ * } catch (error) {
80
+ * console.log(error instanceof BucketNotFoundError); // true
81
+ * }
82
+ * ```
83
+ */
84
+ async function testThrowTypedError(code, message) {
85
+ return native_1.native.testThrowTypedError(code, message);
86
+ }
61
87
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA6CH,0DAEC;AA7CD,sCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACI,KAAK,UAAU,uBAAuB;IAC3C,OAAO,eAAM,CAAC,uBAAuB,EAAE,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACU,QAAA,6BAA6B,GAAG,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA6CH,0DAEC;AA8BD,kDAEC;AA7ED,sCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACI,KAAK,UAAU,uBAAuB;IAC3C,OAAO,eAAM,CAAC,uBAAuB,EAAE,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACU,QAAA,6BAA6B,GAAG,uBAAuB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,mBAAmB,CAAC,IAAY,EAAE,OAAe;IACrE,OAAO,eAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}
@@ -116,8 +116,8 @@ class DownloadResultStruct {
116
116
  key: result.key,
117
117
  isPrefix: result.isPrefix,
118
118
  system: {
119
- created: new Date(result.system.created * 1000),
120
- expires: result.system.expires > 0 ? new Date(result.system.expires * 1000) : null,
119
+ created: result.system.created,
120
+ expires: result.system.expires > 0 ? result.system.expires : null,
121
121
  contentLength: result.system.contentLength,
122
122
  },
123
123
  custom: result.custom ?? {},
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/download/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,sCAAmC;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAa,oBAAoB;IACvB,eAAe,CAAU;IACzB,OAAO,GAAY,KAAK,CAAC;IAEjC;;;;;OAKG;IACH,YAAY,cAAuB;QACjC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAc;QACvC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,IAAI,UAAU,CAAC,4BAA4B,CAAC,CAAC;QACrD,CAAC;QAED,mDAAmD;QACnD,kDAAkD;QAClD,4EAA4E;QAC5E,MAAM,MAAM,GAAG,CAAC,MAAM,eAAM,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,CAE9E,CA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