@edifice.io/share-nest-client 0.1.0 → 0.2.1
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.
- package/dist/index.js +25 -12
- package/dist/index.umd.cjs +1 -1
- package/dist/nats/client.d.ts +7 -1
- package/dist/nats/client.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
var c = Object.defineProperty;
|
|
2
2
|
var l = (r, s, e) => s in r ? c(r, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[s] = e;
|
|
3
|
-
var
|
|
3
|
+
var d = (r, s, e) => (l(r, typeof s != "symbol" ? s + "" : s, e), e);
|
|
4
4
|
import { Injectable as u, Logger as h } from "@nestjs/common";
|
|
5
|
-
import { firstValueFrom as
|
|
6
|
-
var p = Object.getOwnPropertyDescriptor,
|
|
7
|
-
for (var t = n > 1 ? void 0 : n ? p(s, e) : s, o = r.length - 1,
|
|
8
|
-
(
|
|
5
|
+
import { firstValueFrom as a } from "rxjs";
|
|
6
|
+
var p = Object.getOwnPropertyDescriptor, w = (r, s, e, n) => {
|
|
7
|
+
for (var t = n > 1 ? void 0 : n ? p(s, e) : s, o = r.length - 1, i; o >= 0; o--)
|
|
8
|
+
(i = r[o]) && (t = i(t) || t);
|
|
9
9
|
return t;
|
|
10
10
|
};
|
|
11
|
-
let
|
|
11
|
+
let g = class {
|
|
12
12
|
constructor(r) {
|
|
13
|
-
|
|
13
|
+
d(this, "logger", new h(g.name));
|
|
14
14
|
this.natsClient = r, this.logger.log("Creating events service ShareNatsServiceClient");
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether a user holds a share role on a resource, directly or through one of his groups.
|
|
18
|
+
* Resource ownership is not checked.
|
|
19
|
+
* The 'application' parameter of the subject is provided when the client is instantiated.
|
|
20
|
+
*/
|
|
21
|
+
async checkResourceRight(r, s) {
|
|
22
|
+
const e = "share.check." + s;
|
|
23
|
+
this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
|
|
24
|
+
const n = Date.now(), t = await a(this.natsClient.send(e, r)), o = Date.now() - n;
|
|
25
|
+
if (this.logger.debug({ brokerAddress: e, duration: o }, "[nats][mttr]"), !t)
|
|
26
|
+
throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
16
29
|
/**
|
|
17
30
|
* Removes shares of a group.
|
|
18
31
|
* The 'application' parameter of the subject is provided when the client is instantiated.
|
|
@@ -20,7 +33,7 @@ let a = class {
|
|
|
20
33
|
async removeGroupShares(r, s) {
|
|
21
34
|
const e = "share.group.remove." + s;
|
|
22
35
|
this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
|
|
23
|
-
const n = Date.now(), t = await
|
|
36
|
+
const n = Date.now(), t = await a(this.natsClient.send(e, r)), o = Date.now() - n;
|
|
24
37
|
if (this.logger.debug({ brokerAddress: e, duration: o }, "[nats][mttr]"), !t)
|
|
25
38
|
throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
|
|
26
39
|
return t;
|
|
@@ -32,15 +45,15 @@ let a = class {
|
|
|
32
45
|
async upsertGroupShares(r, s) {
|
|
33
46
|
const e = "share.group.upsert." + s;
|
|
34
47
|
this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
|
|
35
|
-
const n = Date.now(), t = await
|
|
48
|
+
const n = Date.now(), t = await a(this.natsClient.send(e, r)), o = Date.now() - n;
|
|
36
49
|
if (this.logger.debug({ brokerAddress: e, duration: o }, "[nats][mttr]"), !t)
|
|
37
50
|
throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
|
|
38
51
|
return t;
|
|
39
52
|
}
|
|
40
53
|
};
|
|
41
|
-
|
|
54
|
+
g = w([
|
|
42
55
|
u()
|
|
43
|
-
],
|
|
56
|
+
], g);
|
|
44
57
|
export {
|
|
45
|
-
|
|
58
|
+
g as ShareNatsServiceClient
|
|
46
59
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@nestjs/common"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@nestjs/common","rxjs"],s):(e=typeof globalThis<"u"?globalThis:e||self,s((e["@edifice"]=e["@edifice"]||{},e["@edifice"]["io/share-nest-client"]={}),e.NestjsCommon,e.rxjs))})(this,function(e,s,i){"use strict";var h=Object.defineProperty;var f=(e,s,i)=>s in e?h(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i;var u=(e,s,i)=>(f(e,typeof s!="symbol"?s+"":s,i),i);var g=Object.getOwnPropertyDescriptor,l=(c,n,d,r)=>{for(var o=r>1?void 0:r?g(n,d):n,t=c.length-1,a;t>=0;t--)(a=c[t])&&(o=a(o)||o);return o};e.ShareNatsServiceClient=class{constructor(n){u(this,"logger",new s.Logger(e.ShareNatsServiceClient.name));this.natsClient=n,this.logger.log("Creating events service ShareNatsServiceClient")}async checkResourceRight(n,d){const r="share.check."+d;this.logger.debug({messageAddress:r},"Sending request to NATS subject");const o=Date.now(),t=await i.firstValueFrom(this.natsClient.send(r,n)),a=Date.now()-o;if(this.logger.debug({brokerAddress:r,duration:a},"[nats][mttr]"),!t)throw this.logger.warn({messageAddress:r},"No reply received for subject"),new Error("No reply received");return t}async removeGroupShares(n,d){const r="share.group.remove."+d;this.logger.debug({messageAddress:r},"Sending request to NATS subject");const o=Date.now(),t=await i.firstValueFrom(this.natsClient.send(r,n)),a=Date.now()-o;if(this.logger.debug({brokerAddress:r,duration:a},"[nats][mttr]"),!t)throw this.logger.warn({messageAddress:r},"No reply received for subject"),new Error("No reply received");return t}async upsertGroupShares(n,d){const r="share.group.upsert."+d;this.logger.debug({messageAddress:r},"Sending request to NATS subject");const o=Date.now(),t=await i.firstValueFrom(this.natsClient.send(r,n)),a=Date.now()-o;if(this.logger.debug({brokerAddress:r,duration:a},"[nats][mttr]"),!t)throw this.logger.warn({messageAddress:r},"No reply received for subject"),new Error("No reply received");return t}},e.ShareNatsServiceClient=l([s.Injectable()],e.ShareNatsServiceClient),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/dist/nats/client.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { ClientProxy } from '@nestjs/microservices';
|
|
2
|
-
import { RemoveGroupSharesRequest, RemoveGroupSharesResponse, UpsertGroupSharesRequest, UpsertGroupSharesResponse } from '@edifice.io/share-nest-api';
|
|
2
|
+
import { CheckResourceRightRequest, CheckResourceRightResponse, RemoveGroupSharesRequest, RemoveGroupSharesResponse, UpsertGroupSharesRequest, UpsertGroupSharesResponse } from '@edifice.io/share-nest-api';
|
|
3
3
|
export declare class ShareNatsServiceClient {
|
|
4
4
|
private readonly natsClient;
|
|
5
5
|
private readonly logger;
|
|
6
6
|
constructor(natsClient: ClientProxy);
|
|
7
|
+
/**
|
|
8
|
+
* Checks whether a user holds a share role on a resource, directly or through one of his groups.
|
|
9
|
+
* Resource ownership is not checked.
|
|
10
|
+
* The 'application' parameter of the subject is provided when the client is instantiated.
|
|
11
|
+
*/
|
|
12
|
+
checkResourceRight(request: CheckResourceRightRequest, application: string): Promise<CheckResourceRightResponse>;
|
|
7
13
|
/**
|
|
8
14
|
* Removes shares of a group.
|
|
9
15
|
* The 'application' parameter of the subject is provided when the client is instantiated.
|
|
@@ -1 +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,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA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,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgBnH;;;OAGG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAgBpH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/share-nest-client",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Clients to interact with share-nats-service",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@edifice.io/share-nest-api": "0.1
|
|
31
|
+
"@edifice.io/share-nest-api": "0.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"husky": "9.0.11",
|