@edifice.io/audience-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,34 @@
1
+ var g = Object.defineProperty;
2
+ var l = (e, r, t) => r in e ? g(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var a = (e, r, t) => (l(e, typeof r != "symbol" ? r + "" : r, t), t);
4
+ import { Injectable as d, Logger as u } from "@nestjs/common";
5
+ import { firstValueFrom as v } from "rxjs";
6
+ var h = Object.getOwnPropertyDescriptor, m = (e, r, t, s) => {
7
+ for (var n = s > 1 ? void 0 : s ? h(r, t) : r, o = e.length - 1, c; o >= 0; o--)
8
+ (c = e[o]) && (n = c(n) || n);
9
+ return n;
10
+ };
11
+ let i = class {
12
+ constructor(e) {
13
+ a(this, "logger", new u(i.name));
14
+ this.natsClient = e, this.logger.log("Creating events service AudienceNatsServiceClient");
15
+ }
16
+ /**
17
+ * Checks if a user has access to specific resources.
18
+ * The 'module' and 'resourceType' parameters of the subject are provided when the client is instantiated.
19
+ */
20
+ async checkResourceAccess(e, r, t) {
21
+ const s = "audience.check.right." + r + "." + t;
22
+ this.logger.debug({ messageAddress: s }, "Sending request to NATS subject");
23
+ const n = Date.now(), o = await v(this.natsClient.send(s, e)), c = Date.now() - n;
24
+ if (this.logger.debug({ brokerAddress: s, duration: c }, "[nats][mttr]"), !o)
25
+ throw this.logger.warn({ messageAddress: s }, "No reply received for subject"), new Error("No reply received");
26
+ return o;
27
+ }
28
+ };
29
+ i = m([
30
+ d()
31
+ ], i);
32
+ export {
33
+ i as AudienceNatsServiceClient
34
+ };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("@nestjs/common"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@nestjs/common","rxjs"],t):(e=typeof globalThis<"u"?globalThis:e||self,t((e["@edifice"]=e["@edifice"]||{},e["@edifice"]["io/audience-nest-client"]={}),e.NestjsCommon,e.rxjs))})(this,function(e,t,n){"use strict";var v=Object.defineProperty;var h=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var a=(e,t,n)=>(h(e,typeof t!="symbol"?t+"":t,n),n);var l=Object.getOwnPropertyDescriptor,f=(d,i,u,o)=>{for(var s=o>1?void 0:o?l(i,u):i,r=d.length-1,c;r>=0;r--)(c=d[r])&&(s=c(s)||s);return s};e.AudienceNatsServiceClient=class{constructor(i){a(this,"logger",new t.Logger(e.AudienceNatsServiceClient.name));this.natsClient=i,this.logger.log("Creating events service AudienceNatsServiceClient")}async checkResourceAccess(i,u,o){const s="audience.check.right."+u+"."+o;this.logger.debug({messageAddress:s},"Sending request to NATS subject");const r=Date.now(),c=await n.firstValueFrom(this.natsClient.send(s,i)),g=Date.now()-r;if(this.logger.debug({brokerAddress:s,duration:g},"[nats][mttr]"),!c)throw this.logger.warn({messageAddress:s},"No reply received for subject"),new Error("No reply received");return c}},e.AudienceNatsServiceClient=f([t.Injectable()],e.AudienceNatsServiceClient),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,13 @@
1
+ import { ClientProxy } from '@nestjs/microservices';
2
+ import { CheckResourceAccessRequest, CheckResourceAccessResponse } from '@edifice.io/audience-nest-api';
3
+ export declare class AudienceNatsServiceClient {
4
+ private readonly natsClient;
5
+ private readonly logger;
6
+ constructor(natsClient: ClientProxy);
7
+ /**
8
+ * Checks if a user has access to specific resources.
9
+ * The 'module' and 'resourceType' parameters of the subject are provided when the client is instantiated.
10
+ */
11
+ checkResourceAccess(request: CheckResourceAccessRequest, module: string, resourceType: string): Promise<CheckResourceAccessResponse>;
12
+ }
13
+ //# 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,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAGjF,qBACa,yBAAyB;IAIxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;gBAExC,UAAU,EAAE,WAAW;IAMpD;;;OAGG;IACG,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAgB3I"}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@edifice.io/audience-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 audience-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/audience-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.