@aerostack/sdk-node 0.3.5 → 0.4.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.
@@ -3,4 +3,6 @@ export * as files from "./lib/files.js";
3
3
  export { HTTPClient } from "./lib/http.js";
4
4
  export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
5
5
  export * from "./sdk/sdk.js";
6
+ export { AerocallClient } from "@aerostack/core";
7
+ export type { AerocallConfig } from "@aerostack/core";
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
@@ -39,10 +39,12 @@ var __importStar = (this && this.__importStar) || (function () {
39
39
  };
40
40
  })();
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.HTTPClient = exports.files = void 0;
42
+ exports.AerocallClient = exports.HTTPClient = exports.files = void 0;
43
43
  __exportStar(require("./lib/config.js"), exports);
44
44
  exports.files = __importStar(require("./lib/files.js"));
45
45
  var http_js_1 = require("./lib/http.js");
46
46
  Object.defineProperty(exports, "HTTPClient", { enumerable: true, get: function () { return http_js_1.HTTPClient; } });
47
47
  __exportStar(require("./sdk/sdk.js"), exports);
48
+ var core_1 = require("@aerostack/core");
49
+ Object.defineProperty(exports, "AerocallClient", { enumerable: true, get: function () { return core_1.AerocallClient; } });
48
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,wDAAwC;AACxC,yCAA2C;AAAlC,qGAAA,UAAU,OAAA;AAEnB,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,wDAAwC;AACxC,yCAA2C;AAAlC,qGAAA,UAAU,OAAA;AAEnB,+CAA6B;AAC7B,wCAAiD;AAAxC,sGAAA,cAAc,OAAA"}
@@ -3,4 +3,6 @@ export * as files from "./lib/files.js";
3
3
  export { HTTPClient } from "./lib/http.js";
4
4
  export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
5
5
  export * from "./sdk/sdk.js";
6
+ export { AerocallClient } from "@aerostack/core";
7
+ export type { AerocallConfig } from "@aerostack/core";
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -5,4 +5,5 @@ export * from "./lib/config.js";
5
5
  export * as files from "./lib/files.js";
6
6
  export { HTTPClient } from "./lib/http.js";
7
7
  export * from "./sdk/sdk.js";
8
+ export { AerocallClient } from "@aerostack/core";
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import express, { Request, Response, NextFunction } from 'express';
2
+ import { Aerostack } from '@aerostack/node';
3
+
4
+ /**
5
+ * Express Integration Example
6
+ *
7
+ * Demonstrates how to use the Aerostack Node.js SDK with Express.
8
+ */
9
+
10
+ const app = express();
11
+ const port = 3000;
12
+
13
+ // Initialize SDK
14
+ const sdk = new Aerostack({
15
+ // security: { apiKeyAuth: process.env.AEROSTACK_API_KEY } // Optional for public endpoints
16
+ });
17
+
18
+ // Middleware to add SDK to request
19
+ const withAerostack = (req: Request, res: Response, next: NextFunction) => {
20
+ (req as any).aerostack = sdk;
21
+ next();
22
+ };
23
+
24
+ app.use(express.json());
25
+ app.use(withAerostack);
26
+
27
+ // Endpoint to signup a user
28
+ app.post('/signup', async (req: Request, res: Response) => {
29
+ const { email, password, name } = req.body;
30
+
31
+ try {
32
+ const result = await sdk.authentication.authSignup({
33
+ email,
34
+ password,
35
+ name
36
+ });
37
+
38
+ if (result.ok) {
39
+ res.status(201).json(result.value);
40
+ } else {
41
+ res.status(400).json({ error: result.error });
42
+ }
43
+ } catch (error: any) {
44
+ res.status(500).json({ error: error.message });
45
+ }
46
+ });
47
+
48
+ // Endpoint to query database
49
+ app.get('/users', async (req: Request, res: Response) => {
50
+ try {
51
+ const result = await sdk.database.dbQuery({
52
+ query: "SELECT * FROM users LIMIT 10"
53
+ });
54
+
55
+ if (result.ok) {
56
+ res.json(result.value);
57
+ } else {
58
+ res.status(500).json({ error: result.error });
59
+ }
60
+ } catch (error: any) {
61
+ res.status(500).json({ error: error.message });
62
+ }
63
+ });
64
+
65
+ app.listen(port, () => {
66
+ console.log(`Example app listening on port ${port}`);
67
+ });
@@ -0,0 +1,46 @@
1
+ import { Aerostack } from '@aerostack/node';
2
+ import type { NextApiRequest, NextApiResponse } from 'next';
3
+
4
+ /**
5
+ * Next.js API Route Example
6
+ *
7
+ * Demonstrates how to use the Aerostack Node.js SDK in a Next.js API route.
8
+ * (Pages Router style, but concepts apply to App Router too)
9
+ */
10
+
11
+ const sdk = new Aerostack({
12
+ // security: { apiKeyAuth: process.env.AEROSTACK_API_KEY }
13
+ });
14
+
15
+ export default async function handler(
16
+ req: NextApiRequest,
17
+ res: NextApiResponse
18
+ ) {
19
+ if (req.method === 'POST') {
20
+ // Handle Signup
21
+ const { email, password } = req.body;
22
+
23
+ const result = await sdk.authentication.authSignup({
24
+ email,
25
+ password,
26
+ name: email.split('@')[0]
27
+ });
28
+
29
+ if (!result.ok) {
30
+ return res.status(400).json({ error: result.error });
31
+ }
32
+
33
+ return res.status(200).json(result.value);
34
+ } else {
35
+ // Handle GET - e.g. list some data
36
+ const result = await sdk.database.dbQuery({
37
+ query: "SELECT count(*) as count FROM users"
38
+ });
39
+
40
+ if (!result.ok) {
41
+ return res.status(500).json({ error: result.error });
42
+ }
43
+
44
+ return res.status(200).json(result.value);
45
+ }
46
+ }
@@ -0,0 +1,44 @@
1
+ import { Aerostack } from '@aerostack/node';
2
+
3
+ /**
4
+ * Standalone Auth Example
5
+ *
6
+ * Simple script to demonstrate authentication flow.
7
+ */
8
+
9
+ const sdk = new Aerostack();
10
+
11
+ async function main() {
12
+ const email = `node-user-${Date.now()}@example.com`;
13
+ const password = 'Password123!';
14
+
15
+ console.log(`Attempting to register ${email}...`);
16
+
17
+ const signupRes = await sdk.authentication.authSignup({
18
+ email,
19
+ password,
20
+ name: "NodeJS User"
21
+ });
22
+
23
+ if (!signupRes.ok) {
24
+ console.error("Signup failed:", signupRes.error);
25
+ return;
26
+ }
27
+
28
+ console.log("Signup success:", signupRes.value);
29
+
30
+ console.log("Attempting to login...");
31
+ const loginRes = await sdk.authentication.authSignin({
32
+ email,
33
+ password
34
+ });
35
+
36
+ if (!loginRes.ok) {
37
+ console.error("Login failed:", loginRes.error);
38
+ return;
39
+ }
40
+
41
+ console.log("Login success. Token:", loginRes.value.token);
42
+ }
43
+
44
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerostack/sdk-node",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "author": "Aerostack",
5
5
  "type": "module",
6
6
  "repository": {
@@ -12,6 +12,9 @@
12
12
  "url": "https://github.com/aerostackdev/sdks/issues"
13
13
  },
14
14
  "homepage": "https://docs.aerostack.dev",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
15
18
  "tshy": {
16
19
  "sourceDialects": [
17
20
  "@aerostack/sdk-node/source"
@@ -45,7 +48,8 @@
45
48
  },
46
49
  "dependencies": {
47
50
  "zod": "^3.25.0 || ^4.0.0",
48
- "ws": "^8.16.0"
51
+ "ws": "^8.16.0",
52
+ "@aerostack/core": "file:../core"
49
53
  },
50
54
  "exports": {
51
55
  ".": {
package/src/index.ts CHANGED
@@ -7,3 +7,5 @@ export * as files from "./lib/files.js";
7
7
  export { HTTPClient } from "./lib/http.js";
8
8
  export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
9
9
  export * from "./sdk/sdk.js";
10
+ export { AerocallClient } from "@aerostack/core";
11
+ export type { AerocallConfig } from "@aerostack/core";