@neonwilderness/ecjsonstorage 1.0.1 → 1.0.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.
package/CHANGELOG.md CHANGED
@@ -10,3 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
  ## [1.0.1] - 2026-09-30
11
11
  - Fix package.json main,exports,types
12
12
  - Enhance readme
13
+
14
+ ## [1.0.2] - 2026-09-30
15
+ - Also generate types for ESM version
16
+ - Fix exports import|require in package.json
17
+
18
+ ## [1.0.3] - 2026-09-30
19
+ - Change package name to @neonwilderness/ecjsonstorage
20
+ - Adapt installation
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  # Installation
12
12
 
13
- - `npm i ecjsonstorage -S` to install the module, which is then both available as CommonJs and ESM version.
13
+ - `npm i @neonwilderness/ecjsonstorage -S` to install the module, which is then both available as CommonJs and ESM version.
14
14
 
15
15
  - Create an .env file in your project directory root and add the following keys:
16
16
 
@@ -27,7 +27,7 @@
27
27
  ## Constructor
28
28
 
29
29
  ```
30
- import { ECJsonStorage } from 'ecjsonstorage';
30
+ import { ECJsonStorage } from '@neonwilderness/ecjsonstorage';
31
31
  import { config } from 'dotenv-safe';
32
32
  config();
33
33
 
@@ -35,7 +35,7 @@
35
35
  ...
36
36
  ```
37
37
 
38
- ## Create a bin
38
+ ## Create a new bin
39
39
 
40
40
  `createBin(payload: object, keepPrivate: boolean)`
41
41
 
@@ -46,4 +46,4 @@
46
46
  console.log(res);
47
47
  ```
48
48
 
49
- Further Documentation/Usage details will follow swiftly; for now you may wanna consult the [TS types file](dist/index.d.cts).
49
+ Further Documentation/Usage details will follow swiftly; for now you may wanna consult the [TS types file](dist/index.d.ts).
@@ -0,0 +1,87 @@
1
+ /**
2
+ * ESJsonStorage class is a wrapper to the ExtendsClass JSON-Storage API
3
+ */
4
+ type resGetBins = {
5
+ status: 'ok';
6
+ callsDone: number;
7
+ callsRemaining: number;
8
+ bins?: string[];
9
+ };
10
+ type resGetStats = Omit<resGetBins, 'bins'>;
11
+ type resGetBin = {
12
+ status: 'ok';
13
+ data: object;
14
+ };
15
+ type resUpdateBin = {
16
+ status: 'ok';
17
+ data: string;
18
+ };
19
+ type resPatchBin = resUpdateBin;
20
+ type resCreateBin = {
21
+ status: 'ok';
22
+ uri: string;
23
+ bin: string;
24
+ };
25
+ type resDeleteBin = Omit<resGetBin, 'data'>;
26
+ type resError = {
27
+ status: 'error';
28
+ statusText: string;
29
+ };
30
+ declare class ECJsonStorage {
31
+ url: string;
32
+ apiKey: string;
33
+ securityKey: string;
34
+ monthlyLimit: number;
35
+ constructor(apiKey: string, securityKey?: string, url?: string);
36
+ /**
37
+ * Utility function to validate the response after the class function call
38
+ * @param response
39
+ */
40
+ validateResponse: (response: Response) => Promise<void>;
41
+ /**
42
+ * Get all bin IDs for a certain Api-key
43
+ * @returns {object} <resGetBins | resError>
44
+ */
45
+ getBins: () => Promise<resGetBins | resError>;
46
+ /**
47
+ * Syntactic sugar function for getBins to only return limit counter
48
+ * @returns {object} <resGetStats | resError>
49
+ */
50
+ getStats: () => Promise<resGetStats | resError>;
51
+ /**
52
+ * Reads the content of a certain bin ID
53
+ * @param bin string Bin ID to read
54
+ * @returns {object} <resGetBin | resError>
55
+ */
56
+ getBin: (bin: string) => Promise<resGetBin | resError>;
57
+ /**
58
+ * Creates a new bin and saves the given JSON payload to it
59
+ * @param payload {object} JSON object to create the bin with
60
+ * @param keepPrivate {boolean} TRUE=bin shall be kept private
61
+ * @returns {object} <resCreateBin | resError>
62
+ */
63
+ createBin: (payload: object, keepPrivate: boolean) => Promise<resCreateBin | resError>;
64
+ /**
65
+ * Updates a certain bin with the given JSON object
66
+ * @param payload {object} JSON object to update the bin with
67
+ * @param bin string Bin ID to be updated
68
+ * @returns {object} <resUpdateBin | resError>
69
+ */
70
+ updateBin: (payload: object, bin: string) => Promise<resUpdateBin | resError>;
71
+ /**
72
+ * Patches/inserts/changes a certain bin with the given JSON payload
73
+ * ref: "Partially update JSON" at https://extendsclass.com/json-storage.html#apiDocumentation
74
+ * @param payload {object} JSON object to patch the bin with
75
+ * @param bin string Bin ID to be patched
76
+ * @returns {object} <resPatchBin | resError>
77
+ */
78
+ patchBin: (payload: object, bin: string) => Promise<resPatchBin | resError>;
79
+ /**
80
+ * Deletes a certain bin
81
+ * @param bin string Bin ID to be deleted
82
+ * @returns {object} <resDeleteBin | resError>
83
+ */
84
+ deleteBin: (bin: string) => Promise<resDeleteBin | resError>;
85
+ }
86
+
87
+ export { ECJsonStorage, type resCreateBin, type resDeleteBin, type resError, type resGetBin, type resGetBins, type resGetStats, type resPatchBin, type resUpdateBin };
package/package.json CHANGED
@@ -1,15 +1,25 @@
1
1
  {
2
2
  "name": "@neonwilderness/ecjsonstorage",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
- "exports": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.cts",
8
+ "exports": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
8
18
  "scripts": {
9
19
  "update": "ncu -u -x typescript && npm i",
10
20
  "build": "npm run build:js && npm run build:dts",
11
21
  "build:js": "tsup src/*.ts --format esm,cjs --minify",
12
- "build:dts": "tsup src/index.ts --dts-only",
22
+ "build:dts": "tsup src/index.ts --format esm,cjs --dts-only",
13
23
  "deleteAllBins": "node dist/deleteAllBins.cjs",
14
24
  "test": "vitest"
15
25
  },