@machhub-dev/sdk-ts 0.0.2 → 0.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.
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
3
3
  export declare class Auth {
4
4
  private httpService;
5
5
  constructor(httpService: HTTPService);
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
3
  export declare class Collection {
4
4
  protected httpService: HTTPService;
5
5
  protected mqttService: MQTTService | null;
@@ -1,4 +1,4 @@
1
- import { HTTPService } from "../services/http.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
2
  export declare class Flow {
3
3
  private httpService;
4
4
  constructor(httpService: HTTPService);
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { NATSService } from "../services/nats.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { NATSService } from "../services/nats.service.js";
3
3
  export declare class Function {
4
4
  private httpService;
5
5
  private natsService;
@@ -1,6 +1,6 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
3
- import { HistorizedData } from "../types/tag.models";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
+ import { HistorizedData } from "../types/tag.models.js";
4
4
  export declare class Historian {
5
5
  private httpService;
6
6
  private mqttService;
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
3
  export declare class Tag {
4
4
  private httpService;
5
5
  private mqttService;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../index");
4
- let sdk = new index_1.SDK();
3
+ const index_js_1 = require("../index.js");
4
+ let sdk = new index_js_1.SDK();
5
5
  let config = {
6
6
  application_id: "machhub_admin",
7
7
  natsUrl: "nats://localhost:4222",
@@ -1,4 +1,5 @@
1
1
  export { SDK, type SDKConfig } from './sdk-ts.js';
2
+ export { getAppConfig } from './utils/appConfig.js';
2
3
  export type { LoginResponse, PermissionResponse, User, Group, Feature, Permission, ActionResponse, Action, Scope } from './types/auth.models.js';
3
4
  export type { BaseResponse } from './types/response.models.js';
4
5
  export type { RecordID } from './types/recordID.models.js';
package/dist/cjs/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SDK = void 0;
3
+ exports.getAppConfig = exports.SDK = void 0;
4
4
  var sdk_ts_js_1 = require("./sdk-ts.js");
5
5
  Object.defineProperty(exports, "SDK", { enumerable: true, get: function () { return sdk_ts_js_1.SDK; } });
6
+ var appConfig_js_1 = require("./utils/appConfig.js");
7
+ Object.defineProperty(exports, "getAppConfig", { enumerable: true, get: function () { return appConfig_js_1.getAppConfig; } });
@@ -1,9 +1,9 @@
1
- import { Collection } from "./classes/collection";
2
- import { Historian } from "./classes/historian";
3
- import { Tag } from "./classes/tag";
4
- import { Function } from "./classes/function";
5
- import { Flow } from "./classes/flow";
6
- import { Auth } from "./classes/auth";
1
+ import { Collection } from "./classes/collection.js";
2
+ import { Historian } from "./classes/historian.js";
3
+ import { Tag } from "./classes/tag.js";
4
+ import { Function } from "./classes/function.js";
5
+ import { Flow } from "./classes/flow.js";
6
+ import { Auth } from "./classes/auth.js";
7
7
  export interface SDKConfig {
8
8
  application_id: string;
9
9
  httpUrl?: string;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK = void 0;
4
- const http_service_1 = require("./services/http.service");
5
- const mqtt_service_1 = require("./services/mqtt.service");
6
- const nats_service_1 = require("./services/nats.service");
7
- const appConfig_1 = require("./utils/appConfig");
8
- const collection_1 = require("./classes/collection");
9
- const historian_1 = require("./classes/historian");
10
- const tag_1 = require("./classes/tag");
11
- const function_1 = require("./classes/function");
12
- const flow_1 = require("./classes/flow");
13
- const auth_1 = require("./classes/auth");
4
+ const http_service_js_1 = require("./services/http.service.js");
5
+ const mqtt_service_js_1 = require("./services/mqtt.service.js");
6
+ const nats_service_js_1 = require("./services/nats.service.js");
7
+ const appConfig_js_1 = require("./utils/appConfig.js");
8
+ const collection_js_1 = require("./classes/collection.js");
9
+ const historian_js_1 = require("./classes/historian.js");
10
+ const tag_js_1 = require("./classes/tag.js");
11
+ const function_js_1 = require("./classes/function.js");
12
+ const flow_js_1 = require("./classes/flow.js");
13
+ const auth_js_1 = require("./classes/auth.js");
14
14
  const MACHHUB_SDK_PATH = "machhub";
15
15
  // Core HTTP client class
16
16
  class HTTPClient {
@@ -21,7 +21,7 @@ class HTTPClient {
21
21
  */
22
22
  constructor(applicationID, httpUrl = "http://localhost:80") {
23
23
  if (!applicationID) {
24
- const config = (0, appConfig_1.getAppConfig)();
24
+ const config = (0, appConfig_js_1.getAppConfig)();
25
25
  if (config != undefined) {
26
26
  applicationID = config.application_id;
27
27
  }
@@ -32,7 +32,7 @@ class HTTPClient {
32
32
  throw new Error("Application ID is required. Set it via the APP_ID environment variable or pass it as a parameter.");
33
33
  }
34
34
  }
35
- this.httpService = new http_service_1.HTTPService(httpUrl, MACHHUB_SDK_PATH, applicationID);
35
+ this.httpService = new http_service_js_1.HTTPService(httpUrl, MACHHUB_SDK_PATH, applicationID);
36
36
  }
37
37
  /**
38
38
  * Gets server info
@@ -59,7 +59,7 @@ class MQTTClient {
59
59
  // }
60
60
  // }
61
61
  if (!this.instance) {
62
- const mqttService = await mqtt_service_1.MQTTService.getInstance(mqttUrl);
62
+ const mqttService = await mqtt_service_js_1.MQTTService.getInstance(mqttUrl);
63
63
  this.instance = new MQTTClient(mqttService); // Use the constructor to initialize the instance
64
64
  }
65
65
  return this.instance;
@@ -93,7 +93,7 @@ class NATSClient {
93
93
  */
94
94
  static async getInstance(applicationID, natsUrl = "ws://localhost:7500") {
95
95
  if (!this.instance) {
96
- const natsService = await nats_service_1.NATSService.getInstance(natsUrl);
96
+ const natsService = await nats_service_js_1.NATSService.getInstance(natsUrl);
97
97
  this.instance = new NATSClient(natsService);
98
98
  }
99
99
  return this.instance;
@@ -154,11 +154,11 @@ class SDK {
154
154
  this.http = new HTTPClient(application_id, httpUrl);
155
155
  this.mqtt = await MQTTClient.getInstance(application_id, mqttUrl);
156
156
  this.nats = await NATSClient.getInstance(application_id, natsUrl);
157
- this._historian = new historian_1.Historian(this.http["httpService"], this.mqtt["mqttService"]);
158
- this._tag = new tag_1.Tag(this.http["httpService"], this.mqtt["mqttService"]);
159
- this._function = new function_1.Function(this.http["httpService"], this.nats["natsService"]);
160
- this._flow = new flow_1.Flow(this.http["httpService"]);
161
- this._auth = new auth_1.Auth(this.http["httpService"]);
157
+ this._historian = new historian_js_1.Historian(this.http["httpService"], this.mqtt["mqttService"]);
158
+ this._tag = new tag_js_1.Tag(this.http["httpService"], this.mqtt["mqttService"]);
159
+ this._function = new function_js_1.Function(this.http["httpService"], this.nats["natsService"]);
160
+ this._flow = new flow_js_1.Flow(this.http["httpService"]);
161
+ this._auth = new auth_js_1.Auth(this.http["httpService"]);
162
162
  }
163
163
  catch (error) {
164
164
  console.error("Failed to initialize:", error);
@@ -221,7 +221,7 @@ class SDK {
221
221
  if (!this.http) {
222
222
  throw new Error("SDK is not initialized. Call `Initialize` before accessing collection.");
223
223
  }
224
- return new collection_1.Collection(this.http["httpService"], this.mqtt ? this.mqtt["mqttService"] : null, collectionName);
224
+ return new collection_js_1.Collection(this.http["httpService"], this.mqtt ? this.mqtt["mqttService"] : null, collectionName);
225
225
  }
226
226
  }
227
227
  exports.SDK = SDK;
@@ -1,5 +1,5 @@
1
- import { RecordID } from "./recordID.models";
2
- import { BaseResponse } from "./response.models";
1
+ import { RecordID } from "./recordID.models.js";
2
+ import { BaseResponse } from "./response.models.js";
3
3
  export interface LoginResponse extends BaseResponse {
4
4
  tkn: string;
5
5
  }
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
3
3
  export declare class Auth {
4
4
  private httpService;
5
5
  constructor(httpService: HTTPService);
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
3
  export declare class Collection {
4
4
  protected httpService: HTTPService;
5
5
  protected mqttService: MQTTService | null;
@@ -1,4 +1,4 @@
1
- import { HTTPService } from "../services/http.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
2
  export declare class Flow {
3
3
  private httpService;
4
4
  constructor(httpService: HTTPService);
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { NATSService } from "../services/nats.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { NATSService } from "../services/nats.service.js";
3
3
  export declare class Function {
4
4
  private httpService;
5
5
  private natsService;
@@ -1,6 +1,6 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
3
- import { HistorizedData } from "../types/tag.models";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
+ import { HistorizedData } from "../types/tag.models.js";
4
4
  export declare class Historian {
5
5
  private httpService;
6
6
  private mqttService;
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
3
  export declare class Tag {
4
4
  private httpService;
5
5
  private mqttService;
@@ -1,4 +1,4 @@
1
- import { SDK } from "../index";
1
+ import { SDK } from "../index.js";
2
2
  let sdk = new SDK();
3
3
  let config = {
4
4
  application_id: "machhub_admin",
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { SDK, type SDKConfig } from './sdk-ts.js';
2
+ export { getAppConfig } from './utils/appConfig.js';
2
3
  export type { LoginResponse, PermissionResponse, User, Group, Feature, Permission, ActionResponse, Action, Scope } from './types/auth.models.js';
3
4
  export type { BaseResponse } from './types/response.models.js';
4
5
  export type { RecordID } from './types/recordID.models.js';
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { SDK } from './sdk-ts.js';
2
+ export { getAppConfig } from './utils/appConfig.js';
package/dist/sdk-ts.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Collection } from "./classes/collection";
2
- import { Historian } from "./classes/historian";
3
- import { Tag } from "./classes/tag";
4
- import { Function } from "./classes/function";
5
- import { Flow } from "./classes/flow";
6
- import { Auth } from "./classes/auth";
1
+ import { Collection } from "./classes/collection.js";
2
+ import { Historian } from "./classes/historian.js";
3
+ import { Tag } from "./classes/tag.js";
4
+ import { Function } from "./classes/function.js";
5
+ import { Flow } from "./classes/flow.js";
6
+ import { Auth } from "./classes/auth.js";
7
7
  export interface SDKConfig {
8
8
  application_id: string;
9
9
  httpUrl?: string;
package/dist/sdk-ts.js CHANGED
@@ -1,13 +1,13 @@
1
- import { HTTPService } from "./services/http.service";
2
- import { MQTTService } from "./services/mqtt.service";
3
- import { NATSService } from "./services/nats.service";
4
- import { getAppConfig } from "./utils/appConfig";
5
- import { Collection } from "./classes/collection";
6
- import { Historian } from "./classes/historian";
7
- import { Tag } from "./classes/tag";
8
- import { Function } from "./classes/function";
9
- import { Flow } from "./classes/flow";
10
- import { Auth } from "./classes/auth";
1
+ import { HTTPService } from "./services/http.service.js";
2
+ import { MQTTService } from "./services/mqtt.service.js";
3
+ import { NATSService } from "./services/nats.service.js";
4
+ import { getAppConfig } from "./utils/appConfig.js";
5
+ import { Collection } from "./classes/collection.js";
6
+ import { Historian } from "./classes/historian.js";
7
+ import { Tag } from "./classes/tag.js";
8
+ import { Function } from "./classes/function.js";
9
+ import { Flow } from "./classes/flow.js";
10
+ import { Auth } from "./classes/auth.js";
11
11
  const MACHHUB_SDK_PATH = "machhub";
12
12
  // Core HTTP client class
13
13
  class HTTPClient {
@@ -1,5 +1,5 @@
1
- import { RecordID } from "./recordID.models";
2
- import { BaseResponse } from "./response.models";
1
+ import { RecordID } from "./recordID.models.js";
2
+ import { BaseResponse } from "./response.models.js";
3
3
  export interface LoginResponse extends BaseResponse {
4
4
  tkn: string;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machhub-dev/sdk-ts",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "MACHHUB TYPESCRIPT SDK",
5
5
  "keywords": [
6
6
  "machhub",
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { Action, ActionResponse, Feature, Group, LoginResponse, User, ValidateJWTResponse } from "../types/auth.models.js";
3
3
 
4
4
  export class Auth {
5
5
  private httpService: HTTPService;
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
3
 
4
4
  export class Collection {
5
5
  protected httpService: HTTPService;
@@ -1,4 +1,4 @@
1
- import { HTTPService } from "../services/http.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
2
 
3
3
  export class Flow {
4
4
  private httpService: HTTPService;
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { NATSService } from "../services/nats.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { NATSService } from "../services/nats.service.js";
3
3
 
4
4
  export class Function {
5
5
  private httpService: HTTPService;
@@ -1,6 +1,6 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
3
- import { HistorizedData } from "../types/tag.models";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
+ import { HistorizedData } from "../types/tag.models.js";
4
4
 
5
5
  export class Historian {
6
6
  private httpService: HTTPService;
@@ -1,5 +1,5 @@
1
- import { HTTPService } from "../services/http.service";
2
- import { MQTTService } from "../services/mqtt.service";
1
+ import { HTTPService } from "../services/http.service.js";
2
+ import { MQTTService } from "../services/mqtt.service.js";
3
3
 
4
4
  export class Tag {
5
5
  private httpService: HTTPService;
@@ -1,4 +1,4 @@
1
- import { SDK, SDKConfig } from "../index";
1
+ import { SDK, SDKConfig } from "../index.js";
2
2
 
3
3
  let sdk = new SDK();
4
4
  let config: SDKConfig = {
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { SDK, type SDKConfig } from './sdk-ts.js';
2
+ export { getAppConfig } from './utils/appConfig.js';
2
3
 
3
4
  // Export individual types
4
5
  export type { LoginResponse, PermissionResponse, User, Group, Feature, Permission, ActionResponse, Action, Scope } from './types/auth.models.js';
package/src/sdk-ts.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { HTTPService } from "./services/http.service";
2
- import { MQTTService } from "./services/mqtt.service";
3
- import { NATSService } from "./services/nats.service";
4
- import { getAppConfig } from "./utils/appConfig";
5
- import { Collection } from "./classes/collection";
6
- import { Historian } from "./classes/historian";
7
- import { Tag } from "./classes/tag";
8
- import { Function } from "./classes/function";
9
- import { Flow } from "./classes/flow";
10
- import { Auth } from "./classes/auth";
1
+ import { HTTPService } from "./services/http.service.js";
2
+ import { MQTTService } from "./services/mqtt.service.js";
3
+ import { NATSService } from "./services/nats.service.js";
4
+ import { getAppConfig } from "./utils/appConfig.js";
5
+ import { Collection } from "./classes/collection.js";
6
+ import { Historian } from "./classes/historian.js";
7
+ import { Tag } from "./classes/tag.js";
8
+ import { Function } from "./classes/function.js";
9
+ import { Flow } from "./classes/flow.js";
10
+ import { Auth } from "./classes/auth.js";
11
11
 
12
12
  const MACHHUB_SDK_PATH = "machhub";
13
13
 
@@ -1,5 +1,5 @@
1
- import { RecordID } from "./recordID.models";
2
- import { BaseResponse } from "./response.models";
1
+ import { RecordID } from "./recordID.models.js";
2
+ import { BaseResponse } from "./response.models.js";
3
3
 
4
4
  export interface LoginResponse extends BaseResponse {
5
5
  tkn: string;