@senhainfo/shared-utils 1.2.0 → 1.2.2

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,25 +1,16 @@
1
- import { ServiceConfig, User } from "node-windows";
2
- type WindowsServiceOptions = ServiceConfig & {
3
- logOnAs?: User;
4
- };
1
+ import { Service, ServiceConfig } from "node-windows";
5
2
  export declare class WindowsService {
6
3
  private options;
7
- private service;
4
+ service: Service;
8
5
  /**
9
6
  * Constructor
10
- * @param {WindowsServiceOptions} options - Options for the Windows service
7
+ * @param {ServiceConfig} config - Configuration for the Windows service
11
8
  *
12
9
  * @default { name: "Senha API - Service", script: "dist/server.js" }
13
10
  *
14
11
  * @example
15
12
  * const service = new WindowsService({ name: "My Service", script: "path/to/service" });
16
13
  */
17
- constructor(options?: WindowsServiceOptions);
18
- install(): void;
19
- uninstall(): void;
20
- start(): void;
21
- stop(): void;
22
- restart(): void;
14
+ constructor(config?: ServiceConfig);
23
15
  }
24
- export {};
25
16
  //# sourceMappingURL=windows-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"windows-service.d.ts","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAG5D,KAAK,qBAAqB,GAAG,aAAa,GAAG;IAC3C,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAwB;IAEvC,OAAO,CAAC,OAAO,CAIZ;IAEH;;;;;;;;OAQG;gBACS,OAAO,CAAC,EAAE,qBAAqB;IA6BpC,OAAO;IAIP,SAAS;IAIT,KAAK;IAIL,IAAI;IAIJ,OAAO;CAGf"}
1
+ {"version":3,"file":"windows-service.d.ts","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGtD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAIb;IAEK,OAAO,EAAE,OAAO,CAA6B;IAEpD;;;;;;;;OAQG;gBACS,MAAM,CAAC,EAAE,aAAa;CAuBnC"}
@@ -9,59 +9,41 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  class WindowsService {
10
10
  /**
11
11
  * Constructor
12
- * @param {WindowsServiceOptions} options - Options for the Windows service
12
+ * @param {ServiceConfig} config - Configuration for the Windows service
13
13
  *
14
14
  * @default { name: "Senha API - Service", script: "dist/server.js" }
15
15
  *
16
16
  * @example
17
17
  * const service = new WindowsService({ name: "My Service", script: "path/to/service" });
18
18
  */
19
- constructor(options) {
20
- this.service = new node_windows_1.Service({
19
+ constructor(config) {
20
+ this.options = {
21
21
  name: "Senha API - Service",
22
22
  description: "Senha API - Service",
23
23
  script: node_path_1.default.join("dist", "server.js"),
24
- });
25
- if (options === null || options === void 0 ? void 0 : options.logOnAs) {
26
- this.service.logOnAs = options.logOnAs;
27
- delete options.logOnAs;
28
- }
29
- if (options) {
30
- Object.assign(this.options, options);
24
+ };
25
+ this.service = new node_windows_1.Service(this.options);
26
+ if (config) {
27
+ Object.assign(this.options, config);
31
28
  }
32
29
  this.service
33
30
  .on("install", () => {
34
31
  this.service.start();
35
- console.log(`\nService "${this.options.name}" installed\n`);
32
+ console.log(`Service "${this.options.name}" installed`);
36
33
  })
37
34
  .on("alreadyinstalled", () => {
38
- console.log(`\nService "${this.options.name}" is already installed\n`);
35
+ console.log(`Service "${this.options.name}" is already installed`);
39
36
  })
40
37
  .on("uninstall", () => {
41
- console.log(`\nService "${this.options.name}" uninstalled\n`);
38
+ console.log(`Service "${this.options.name}" uninstalled`);
42
39
  })
43
40
  .on("start", () => {
44
- console.log(`\nService started\n`);
41
+ console.log("Service started");
45
42
  })
46
43
  .on("stop", () => {
47
- console.log(`\nService stopped\n`);
44
+ console.log("Service stopped");
48
45
  });
49
46
  }
50
- install() {
51
- this.service.install();
52
- }
53
- uninstall() {
54
- this.service.uninstall();
55
- }
56
- start() {
57
- this.service.start();
58
- }
59
- stop() {
60
- this.service.stop();
61
- }
62
- restart() {
63
- this.service.restart();
64
- }
65
47
  }
66
48
  exports.WindowsService = WindowsService;
67
49
  //# sourceMappingURL=windows-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"windows-service.js","sourceRoot":"","sources":["../src/windows-service.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA4D;AAC5D,0DAA6B;AAM7B,MAAa,cAAc;IASzB;;;;;;;;OAQG;IACH,YAAY,OAA+B;QAfnC,YAAO,GAAY,IAAI,sBAAO,CAAC;YACrC,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,qBAAqB;YAClC,MAAM,EAAE,mBAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC;SACvC,CAAC,CAAC;QAYD,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YACvC,OAAO,OAAO,CAAC,OAAO,CAAC;QACzB,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,OAAO;aACT,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,CAAC;QAC9D,CAAC,CAAC;aACD,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,IAAI,0BAA0B,CAAC,CAAC;QACzE,CAAC,CAAC;aACD,EAAE,CAAC,WAAW,EAAE,GAA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IAAI,CAAC,OAAO;aACT,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC;QAC1D,CAAC,CAAC;aACD,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,wBAAwB,CAAC,CAAC;QACrE,CAAC,CAAC;aACD,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,CAAC;QAC5D,CAAC,CAAC;aACD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC,CAAC;aACD,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACf,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AAzCD,wCAyCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senhainfo/shared-utils",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "repository": "https://github.com/senha-info/senha-shared-utils.git",
5
5
  "author": "Bruno Gaspar <bruninhoogaspar@gmail.com>",
6
6
  "license": "MIT",
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.14.0",
27
- "@types/node-windows": "^0.1.6",
28
27
  "tsx": "^4.19.3",
29
28
  "typescript": "^5.8.2"
30
29
  },
31
30
  "dependencies": {
32
31
  "axios": "^1.8.4",
33
32
  "date-fns": "^4.1.0",
34
- "node-windows": "^1.0.0-beta.8"
33
+ "node-windows": "^1.0.0-beta.8",
34
+ "@types/node-windows": "^0.1.6"
35
35
  }
36
36
  }