@edifice.io/communication-nest-client 0.0.0-stage → 0.1.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.
@@ -0,0 +1,2 @@
1
+ export * from './nats/client';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ var g = Object.defineProperty;
2
+ var u = (r, e, t) => e in r ? g(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var c = (r, e, t) => (u(r, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { Injectable as l, Logger as m } from "@nestjs/common";
5
+ import { firstValueFrom as o } from "rxjs";
6
+ var w = Object.getOwnPropertyDescriptor, h = (r, e, t, s) => {
7
+ for (var n = s > 1 ? void 0 : s ? w(e, t) : e, i = r.length - 1, d; i >= 0; i--)
8
+ (d = r[i]) && (n = d(n) || n);
9
+ return n;
10
+ };
11
+ let a = class {
12
+ constructor(r) {
13
+ c(this, "logger", new m(a.name));
14
+ this.natsClient = r, this.logger.log("Creating events service CommunicationNatsServiceClient");
15
+ }
16
+ /**
17
+ * Adds communication links between a group and its users.
18
+ * This defines how group members can communicate with each other.
19
+ */
20
+ async addCommunicationLinks(r) {
21
+ const e = "communication.link.users.add";
22
+ this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
23
+ const t = Date.now(), s = await o(this.natsClient.send(e, r)), n = Date.now() - t;
24
+ if (this.logger.debug({ brokerAddress: e, duration: n }, "[nats][mttr]"), !s)
25
+ throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
26
+ return s;
27
+ }
28
+ /**
29
+ * Creates a communication link between two groups.
30
+ * This allows members of each group to communicate with the members of the other group.
31
+ */
32
+ async addLinkBetweenGroups(r) {
33
+ const e = "communication.link.groups.add";
34
+ this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
35
+ const t = Date.now(), s = await o(this.natsClient.send(e, r)), n = Date.now() - t;
36
+ if (this.logger.debug({ brokerAddress: e, duration: n }, "[nats][mttr]"), !s)
37
+ throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
38
+ return s;
39
+ }
40
+ /**
41
+ * Recreates communication links between a group and its users.
42
+ * This is useful when membership changes and links need to be updated.
43
+ * It involves removing existing links and then adding them back.
44
+ */
45
+ async recreateCommunicationLinks(r) {
46
+ const e = "communication.link.users.recreate";
47
+ this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
48
+ const t = Date.now(), s = await o(this.natsClient.send(e, r)), n = Date.now() - t;
49
+ if (this.logger.debug({ brokerAddress: e, duration: n }, "[nats][mttr]"), !s)
50
+ throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
51
+ return s;
52
+ }
53
+ /**
54
+ * Removes communication links between a group and its users.
55
+ */
56
+ async removeCommunicationLinks(r) {
57
+ const e = "communication.link.users.remove";
58
+ this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
59
+ const t = Date.now(), s = await o(this.natsClient.send(e, r)), n = Date.now() - t;
60
+ if (this.logger.debug({ brokerAddress: e, duration: n }, "[nats][mttr]"), !s)
61
+ throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
62
+ return s;
63
+ }
64
+ };
65
+ a = h([
66
+ l()
67
+ ], a);
68
+ export {
69
+ a as CommunicationNatsServiceClient
70
+ };
@@ -0,0 +1 @@
1
+ (function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@nestjs/common"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@nestjs/common","rxjs"],r):(t=typeof globalThis<"u"?globalThis:t||self,r((t["@edifice"]=t["@edifice"]||{},t["@edifice"]["io/communication-nest-client"]={}),t.NestjsCommon,t.rxjs))})(this,function(t,r,o){"use strict";var l=Object.defineProperty;var f=(t,r,o)=>r in t?l(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var u=(t,r,o)=>(f(t,typeof r!="symbol"?r+"":r,o),o);var m=Object.getOwnPropertyDescriptor,g=(d,n,e,a)=>{for(var s=a>1?void 0:a?m(n,e):n,i=d.length-1,c;i>=0;i--)(c=d[i])&&(s=c(s)||s);return s};t.CommunicationNatsServiceClient=class{constructor(n){u(this,"logger",new r.Logger(t.CommunicationNatsServiceClient.name));this.natsClient=n,this.logger.log("Creating events service CommunicationNatsServiceClient")}async addCommunicationLinks(n){const e="communication.link.users.add";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const a=Date.now(),s=await o.firstValueFrom(this.natsClient.send(e,n)),i=Date.now()-a;if(this.logger.debug({brokerAddress:e,duration:i},"[nats][mttr]"),!s)throw this.logger.warn({messageAddress:e},"No reply received for subject"),new Error("No reply received");return s}async addLinkBetweenGroups(n){const e="communication.link.groups.add";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const a=Date.now(),s=await o.firstValueFrom(this.natsClient.send(e,n)),i=Date.now()-a;if(this.logger.debug({brokerAddress:e,duration:i},"[nats][mttr]"),!s)throw this.logger.warn({messageAddress:e},"No reply received for subject"),new Error("No reply received");return s}async recreateCommunicationLinks(n){const e="communication.link.users.recreate";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const a=Date.now(),s=await o.firstValueFrom(this.natsClient.send(e,n)),i=Date.now()-a;if(this.logger.debug({brokerAddress:e,duration:i},"[nats][mttr]"),!s)throw this.logger.warn({messageAddress:e},"No reply received for subject"),new Error("No reply received");return s}async removeCommunicationLinks(n){const e="communication.link.users.remove";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const a=Date.now(),s=await o.firstValueFrom(this.natsClient.send(e,n)),i=Date.now()-a;if(this.logger.debug({brokerAddress:e,duration:i},"[nats][mttr]"),!s)throw this.logger.warn({messageAddress:e},"No reply received for subject"),new Error("No reply received");return s}},t.CommunicationNatsServiceClient=g([r.Injectable()],t.CommunicationNatsServiceClient),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,28 @@
1
+ import { ClientProxy } from '@nestjs/microservices';
2
+ import { AddCommunicationLinksRequest, AddCommunicationLinksResponse, AddLinkBetweenGroupsRequest, AddLinkBetweenGroupsResponse, RecreateCommunicationLinksRequest, RecreateCommunicationLinksResponse, RemoveCommunicationLinksRequest, RemoveCommunicationLinksResponse } from '@edifice.io/communication-nest-api';
3
+ export declare class CommunicationNatsServiceClient {
4
+ private readonly natsClient;
5
+ private readonly logger;
6
+ constructor(natsClient: ClientProxy);
7
+ /**
8
+ * Adds communication links between a group and its users.
9
+ * This defines how group members can communicate with each other.
10
+ */
11
+ addCommunicationLinks(request: AddCommunicationLinksRequest): Promise<AddCommunicationLinksResponse>;
12
+ /**
13
+ * Creates a communication link between two groups.
14
+ * This allows members of each group to communicate with the members of the other group.
15
+ */
16
+ addLinkBetweenGroups(request: AddLinkBetweenGroupsRequest): Promise<AddLinkBetweenGroupsResponse>;
17
+ /**
18
+ * Recreates communication links between a group and its users.
19
+ * This is useful when membership changes and links need to be updated.
20
+ * It involves removing existing links and then adding them back.
21
+ */
22
+ recreateCommunicationLinks(request: RecreateCommunicationLinksRequest): Promise<RecreateCommunicationLinksResponse>;
23
+ /**
24
+ * Removes communication links between a group and its users.
25
+ */
26
+ removeCommunicationLinks(request: RemoveCommunicationLinksRequest): Promise<RemoveCommunicationLinksResponse>;
27
+ }
28
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/nats/client.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAEvF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAExF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAEvF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AAE5F,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AAE1F,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAG3F,qBACa,8BAA8B;IAI7B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;gBAE7C,UAAU,EAAE,WAAW;IAMpD;;;OAGG;IACG,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAgB1G;;;OAGG;IACG,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAgBvG;;;;OAIG;IACG,0BAA0B,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,kCAAkC,CAAC;IAgBzH;;OAEG;IACG,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC;CAgBpH"}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@edifice.io/communication-nest-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Clients to interact with communication-nats-service",
5
+ "private": false,
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "keywords": [],
10
+ "author": "Edifice",
11
+ "license": "AGPL-3.0",
12
+ "engines": {
13
+ "node": "22"
14
+ },
15
+ "engineStrict": true,
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "require": "./dist/index.umd.cjs",
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "main": "dist/index.umd.cjs",
25
+ "module": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "dependencies": {
31
+ "@edifice.io/communication-nest-api": "0.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "husky": "9.0.11",
35
+ "prettier": "3.2.5",
36
+ "semantic-release": "23.0.2",
37
+ "typescript": "5.2.2",
38
+ "vite": "5.1.4",
39
+ "vite-plugin-dts": "4.3.0",
40
+ "rxjs": "7.8.1",
41
+ "@nestjs/common": "11.0.20",
42
+ "@nestjs/microservices": "11.0.20"
43
+ },
44
+ "lint-staged": {
45
+ "*.{js,ts,jsx,tsx,json,css,md}": "pnpm format"
46
+ },
47
+ "scripts": {
48
+ "dev": "vite",
49
+ "build": "tsc && vite build",
50
+ "build:types": "tsc --build",
51
+ "preview": "vite preview",
52
+ "clean": "rm -Rf dist",
53
+ "format": "pnpm run format:write && pnpm run format:check",
54
+ "format:check": "npx prettier --check \"src/**/*.ts\"",
55
+ "format:write": "npx prettier --write \"src/**/*.ts\"",
56
+ "pre-commit": "pnpm run format"
57
+ }
6
58
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.