@edifice.io/resource-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,56 @@
1
+ var d = Object.defineProperty;
2
+ var g = (e, s, t) => s in e ? d(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var i = (e, s, t) => (g(e, typeof s != "symbol" ? s + "" : s, t), t);
4
+ import { Injectable as l, Logger as u } from "@nestjs/common";
5
+ import { firstValueFrom as h } from "rxjs";
6
+ var v = Object.getOwnPropertyDescriptor, m = (e, s, t, o) => {
7
+ for (var r = o > 1 ? void 0 : o ? v(s, t) : s, n = e.length - 1, c; n >= 0; n--)
8
+ (c = e[n]) && (r = c(r) || r);
9
+ return r;
10
+ };
11
+ let a = class {
12
+ constructor(e) {
13
+ i(this, "logger", new u(a.name));
14
+ this.natsClient = e, this.logger.log("Creating events service ResourceNatsServiceClient");
15
+ }
16
+ /**
17
+ * Retrieves detailed information about multiple resources identified by their IDs/UUIDs.
18
+ * This method allows applications to fetch resource metadata without direct access to the resource storage.
19
+ * The 'application' parameter of the subject is provided when the client is instantiated.
20
+ */
21
+ async getResources(e, s) {
22
+ const t = "resource.get." + s;
23
+ this.logger.debug({ messageAddress: t }, "Sending request to NATS subject");
24
+ const o = Date.now(), r = await h(this.natsClient.send(t, e)), n = Date.now() - o;
25
+ if (this.logger.debug({ brokerAddress: t, duration: n }, "[nats][mttr]"), !r)
26
+ throw this.logger.warn({ messageAddress: t }, "No reply received for subject"), new Error("No reply received");
27
+ return r;
28
+ }
29
+ /**
30
+ * Notifies subscribers that the shares for resources have changed.
31
+ */
32
+ async notifyResourceSharesChanged(e, s) {
33
+ const t = "resource." + s + ".shares.changed";
34
+ this.natsClient.emit(t, e);
35
+ }
36
+ /**
37
+ * Notifies subscribers that resources have been deleted.
38
+ */
39
+ async notifyResourcesDeleted(e, s) {
40
+ const t = "resource." + s + ".deleted";
41
+ this.natsClient.emit(t, e);
42
+ }
43
+ /**
44
+ * Notifies subscribers that resources have been trashed.
45
+ */
46
+ async notifyResourcesTrashed(e, s) {
47
+ const t = "resource." + s + ".trashed";
48
+ this.natsClient.emit(t, e);
49
+ }
50
+ };
51
+ a = m([
52
+ l()
53
+ ], a);
54
+ export {
55
+ a as ResourceNatsServiceClient
56
+ };
@@ -0,0 +1 @@
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/resource-nest-client"]={}),e.NestjsCommon,e.rxjs))})(this,function(e,s,i){"use strict";var g=Object.defineProperty;var h=(e,s,i)=>s in e?g(e,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[s]=i;var a=(e,s,i)=>(h(e,typeof s!="symbol"?s+"":s,i),i);var l=Object.getOwnPropertyDescriptor,f=(u,r,n,t)=>{for(var o=t>1?void 0:t?l(r,n):r,c=u.length-1,d;c>=0;c--)(d=u[c])&&(o=d(o)||o);return o};e.ResourceNatsServiceClient=class{constructor(r){a(this,"logger",new s.Logger(e.ResourceNatsServiceClient.name));this.natsClient=r,this.logger.log("Creating events service ResourceNatsServiceClient")}async getResources(r,n){const t="resource.get."+n;this.logger.debug({messageAddress:t},"Sending request to NATS subject");const o=Date.now(),c=await i.firstValueFrom(this.natsClient.send(t,r)),d=Date.now()-o;if(this.logger.debug({brokerAddress:t,duration:d},"[nats][mttr]"),!c)throw this.logger.warn({messageAddress:t},"No reply received for subject"),new Error("No reply received");return c}async notifyResourceSharesChanged(r,n){const t="resource."+n+".shares.changed";this.natsClient.emit(t,r)}async notifyResourcesDeleted(r,n){const t="resource."+n+".deleted";this.natsClient.emit(t,r)}async notifyResourcesTrashed(r,n){const t="resource."+n+".trashed";this.natsClient.emit(t,r)}},e.ResourceNatsServiceClient=f([s.Injectable()],e.ResourceNatsServiceClient),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,26 @@
1
+ import { ClientProxy } from '@nestjs/microservices';
2
+ import { GetResourcesRequest, GetResourcesResponse, ResourceSharesChanged, ResourcesDeleted, ResourcesTrashed } from '@edifice.io/resource-nest-api';
3
+ export declare class ResourceNatsServiceClient {
4
+ private readonly natsClient;
5
+ private readonly logger;
6
+ constructor(natsClient: ClientProxy);
7
+ /**
8
+ * Retrieves detailed information about multiple resources identified by their IDs/UUIDs.
9
+ * This method allows applications to fetch resource metadata without direct access to the resource storage.
10
+ * The 'application' parameter of the subject is provided when the client is instantiated.
11
+ */
12
+ getResources(request: GetResourcesRequest, application: string): Promise<GetResourcesResponse>;
13
+ /**
14
+ * Notifies subscribers that the shares for resources have changed.
15
+ */
16
+ notifyResourceSharesChanged(request: ResourceSharesChanged, application: string): Promise<void>;
17
+ /**
18
+ * Notifies subscribers that resources have been deleted.
19
+ */
20
+ notifyResourcesDeleted(request: ResourcesDeleted, application: string): Promise<void>;
21
+ /**
22
+ * Notifies subscribers that resources have been trashed.
23
+ */
24
+ notifyResourcesTrashed(request: ResourcesTrashed, application: string): Promise<void>;
25
+ }
26
+ //# 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,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,qBACa,yBAAyB;IAIxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;gBAExC,UAAU,EAAE,WAAW;IAMpD;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgBpG;;OAEG;IACG,2BAA2B,CAAC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM;IAOrF;;OAEG;IACG,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM;IAO3E;;OAEG;IACG,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM;CAO5E"}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@edifice.io/resource-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 resource-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/resource-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.