@edifice.io/aiwiki-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 CHANGED
@@ -1,38 +1,78 @@
1
1
  var c = Object.defineProperty;
2
- var l = (t, e, r) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var d = (t, e, r) => (l(t, typeof e != "symbol" ? e + "" : e, r), r);
2
+ var l = (r, e, t) => e in r ? c(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var g = (r, e, t) => (l(r, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import { Injectable as u, Logger as w } from "@nestjs/common";
5
- import { firstValueFrom as g } from "rxjs";
6
- var p = Object.getOwnPropertyDescriptor, v = (t, e, r, s) => {
7
- for (var n = s > 1 ? void 0 : s ? p(e, r) : e, i = t.length - 1, a; i >= 0; i--)
8
- (a = t[i]) && (n = a(n) || n);
9
- return n;
5
+ import { firstValueFrom as i } from "rxjs";
6
+ var h = Object.getOwnPropertyDescriptor, b = (r, e, t, n) => {
7
+ for (var s = n > 1 ? void 0 : n ? h(e, t) : e, o = r.length - 1, d; o >= 0; o--)
8
+ (d = r[o]) && (s = d(s) || s);
9
+ return s;
10
10
  };
11
- let o = class {
12
- constructor(t) {
13
- d(this, "logger", new w(o.name));
14
- this.natsClient = t, this.logger.log("Creating events service AiwikiNatsServiceClient");
11
+ let a = class {
12
+ constructor(r) {
13
+ g(this, "logger", new w(a.name));
14
+ this.natsClient = r, this.logger.log("Creating events service AiwikiNatsServiceClient");
15
15
  }
16
- async updateWikiContent(t) {
17
- const e = "ai.wiki.content.updated";
16
+ /**
17
+ * Tells whether a PDF can be turned into a wiki, before any generation.
18
+ */
19
+ async checkFile(r) {
20
+ const e = "ia.wiki.transform.check";
18
21
  this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
19
- const r = Date.now(), s = await g(this.natsClient.send(e, t)), n = Date.now() - r;
20
- if (this.logger.debug({ brokerAddress: e, duration: n }, "[nats][mttr]"), !s)
22
+ const t = Date.now(), n = await i(this.natsClient.send(e, r)), s = Date.now() - t;
23
+ if (this.logger.debug({ brokerAddress: e, duration: s }, "[nats][mttr]"), !n)
21
24
  throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
22
- return s;
25
+ return n;
26
+ }
27
+ /**
28
+ * Starts the generation of a wiki from a description of its subject.
29
+ */
30
+ async createWiki(r) {
31
+ const e = "ia.wiki.create";
32
+ this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
33
+ const t = Date.now(), n = await i(this.natsClient.send(e, r)), s = Date.now() - t;
34
+ if (this.logger.debug({ brokerAddress: e, duration: s }, "[nats][mttr]"), !n)
35
+ throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
36
+ return n;
23
37
  }
24
- async updateWikiStructure(t) {
25
- const e = "ai.wiki.structure.updated";
38
+ /**
39
+ * Starts the generation of a wiki from a PDF. The PDF is checked first : the job is refused, with a reason, when it
40
+ * cannot be used.
41
+ */
42
+ async transformWiki(r) {
43
+ const e = "ia.wiki.transform";
26
44
  this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
27
- const r = Date.now(), s = await g(this.natsClient.send(e, t)), n = Date.now() - r;
28
- if (this.logger.debug({ brokerAddress: e, duration: n }, "[nats][mttr]"), !s)
45
+ const t = Date.now(), n = await i(this.natsClient.send(e, r)), s = Date.now() - t;
46
+ if (this.logger.debug({ brokerAddress: e, duration: s }, "[nats][mttr]"), !n)
29
47
  throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
48
+ return n;
49
+ }
50
+ /**
51
+ * Receives the content of one generated page of a wiki.
52
+ */
53
+ async updateWikiContent(r, e) {
54
+ const t = "ia.wiki." + e + ".content.updated";
55
+ this.logger.debug({ messageAddress: t }, "Sending request to NATS subject");
56
+ const n = Date.now(), s = await i(this.natsClient.send(t, r)), o = Date.now() - n;
57
+ if (this.logger.debug({ brokerAddress: t, duration: o }, "[nats][mttr]"), !s)
58
+ throw this.logger.warn({ messageAddress: t }, "No reply received for subject"), new Error("No reply received");
59
+ return s;
60
+ }
61
+ /**
62
+ * Receives the structure of a generated wiki : its pages, without their content.
63
+ */
64
+ async updateWikiStructure(r, e) {
65
+ const t = "ia.wiki." + e + ".structure.updated";
66
+ this.logger.debug({ messageAddress: t }, "Sending request to NATS subject");
67
+ const n = Date.now(), s = await i(this.natsClient.send(t, r)), o = Date.now() - n;
68
+ if (this.logger.debug({ brokerAddress: t, duration: o }, "[nats][mttr]"), !s)
69
+ throw this.logger.warn({ messageAddress: t }, "No reply received for subject"), new Error("No reply received");
30
70
  return s;
31
71
  }
32
72
  };
33
- o = v([
73
+ a = b([
34
74
  u()
35
- ], o);
75
+ ], a);
36
76
  export {
37
- o as AiwikiNatsServiceClient
77
+ a as AiwikiNatsServiceClient
38
78
  };
@@ -1 +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/aiwiki-nest-client"]={}),e.NestjsCommon,e.rxjs))})(this,function(e,t,r){"use strict";var w=Object.defineProperty;var f=(e,t,r)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var u=(e,t,r)=>(f(e,typeof t!="symbol"?t+"":t,r),r);var g=Object.getOwnPropertyDescriptor,l=(a,n,i,d)=>{for(var s=d>1?void 0:d?g(n,i):n,o=a.length-1,c;o>=0;o--)(c=a[o])&&(s=c(s)||s);return s};e.AiwikiNatsServiceClient=class{constructor(n){u(this,"logger",new t.Logger(e.AiwikiNatsServiceClient.name));this.natsClient=n,this.logger.log("Creating events service AiwikiNatsServiceClient")}async updateWikiContent(n){const i="ai.wiki.content.updated";this.logger.debug({messageAddress:i},"Sending request to NATS subject");const d=Date.now(),s=await r.firstValueFrom(this.natsClient.send(i,n)),o=Date.now()-d;if(this.logger.debug({brokerAddress:i,duration:o},"[nats][mttr]"),!s)throw this.logger.warn({messageAddress:i},"No reply received for subject"),new Error("No reply received");return s}async updateWikiStructure(n){const i="ai.wiki.structure.updated";this.logger.debug({messageAddress:i},"Sending request to NATS subject");const d=Date.now(),s=await r.firstValueFrom(this.natsClient.send(i,n)),o=Date.now()-d;if(this.logger.debug({brokerAddress:i,duration:o},"[nats][mttr]"),!s)throw this.logger.warn({messageAddress:i},"No reply received for subject"),new Error("No reply received");return s}},e.AiwikiNatsServiceClient=l([t.Injectable()],e.AiwikiNatsServiceClient),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ (function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@nestjs/common"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@nestjs/common","rxjs"],n):(t=typeof globalThis<"u"?globalThis:t||self,n((t["@edifice"]=t["@edifice"]||{},t["@edifice"]["io/aiwiki-nest-client"]={}),t.NestjsCommon,t.rxjs))})(this,function(t,n,d){"use strict";var w=Object.defineProperty;var f=(t,n,d)=>n in t?w(t,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):t[n]=d;var g=(t,n,d)=>(f(t,typeof n!="symbol"?n+"":n,d),d);var u=Object.getOwnPropertyDescriptor,l=(c,o,e,r)=>{for(var s=r>1?void 0:r?u(o,e):o,i=c.length-1,a;i>=0;i--)(a=c[i])&&(s=a(s)||s);return s};t.AiwikiNatsServiceClient=class{constructor(o){g(this,"logger",new n.Logger(t.AiwikiNatsServiceClient.name));this.natsClient=o,this.logger.log("Creating events service AiwikiNatsServiceClient")}async checkFile(o){const e="ia.wiki.transform.check";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const r=Date.now(),s=await d.firstValueFrom(this.natsClient.send(e,o)),i=Date.now()-r;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 createWiki(o){const e="ia.wiki.create";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const r=Date.now(),s=await d.firstValueFrom(this.natsClient.send(e,o)),i=Date.now()-r;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 transformWiki(o){const e="ia.wiki.transform";this.logger.debug({messageAddress:e},"Sending request to NATS subject");const r=Date.now(),s=await d.firstValueFrom(this.natsClient.send(e,o)),i=Date.now()-r;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 updateWikiContent(o,e){const r="ia.wiki."+e+".content.updated";this.logger.debug({messageAddress:r},"Sending request to NATS subject");const s=Date.now(),i=await d.firstValueFrom(this.natsClient.send(r,o)),a=Date.now()-s;if(this.logger.debug({brokerAddress:r,duration:a},"[nats][mttr]"),!i)throw this.logger.warn({messageAddress:r},"No reply received for subject"),new Error("No reply received");return i}async updateWikiStructure(o,e){const r="ia.wiki."+e+".structure.updated";this.logger.debug({messageAddress:r},"Sending request to NATS subject");const s=Date.now(),i=await d.firstValueFrom(this.natsClient.send(r,o)),a=Date.now()-s;if(this.logger.debug({brokerAddress:r,duration:a},"[nats][mttr]"),!i)throw this.logger.warn({messageAddress:r},"No reply received for subject"),new Error("No reply received");return i}},t.AiwikiNatsServiceClient=l([n.Injectable()],t.AiwikiNatsServiceClient),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -1,10 +1,29 @@
1
1
  import { ClientProxy } from '@nestjs/microservices';
2
- import { BaseResponse } from '@edifice.io/aiwiki-nest-api';
2
+ import { ContentRequest, ContentTransformRequest, CourseHierarchy, CourseResponse, FileCheckRequest, FileCheckResponse, JobAccepted, MessageReceived } from '@edifice.io/aiwiki-nest-api';
3
3
  export declare class AiwikiNatsServiceClient {
4
4
  private readonly natsClient;
5
5
  private readonly logger;
6
6
  constructor(natsClient: ClientProxy);
7
- updateWikiContent(request: BaseResponse): Promise<BaseResponse>;
8
- updateWikiStructure(request: BaseResponse): Promise<BaseResponse>;
7
+ /**
8
+ * Tells whether a PDF can be turned into a wiki, before any generation.
9
+ */
10
+ checkFile(request: FileCheckRequest): Promise<FileCheckResponse>;
11
+ /**
12
+ * Starts the generation of a wiki from a description of its subject.
13
+ */
14
+ createWiki(request: ContentRequest): Promise<JobAccepted>;
15
+ /**
16
+ * Starts the generation of a wiki from a PDF. The PDF is checked first : the job is refused, with a reason, when it
17
+ * cannot be used.
18
+ */
19
+ transformWiki(request: ContentTransformRequest): Promise<JobAccepted>;
20
+ /**
21
+ * Receives the content of one generated page of a wiki.
22
+ */
23
+ updateWikiContent(request: CourseResponse, pfId: string): Promise<MessageReceived>;
24
+ /**
25
+ * Receives the structure of a generated wiki : its pages, without their content.
26
+ */
27
+ updateWikiStructure(request: CourseHierarchy, pfId: string): Promise<MessageReceived>;
9
28
  }
10
29
  //# sourceMappingURL=client.d.ts.map
@@ -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,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,qBACa,uBAAuB;IAItB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;gBAEtC,UAAU,EAAE,WAAW;IAM9C,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAgB/D,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;CAgBxE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/nats/client.ts"],"names":[],"mappings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",
4
4
  "description": "Clients to interact with aiwiki-nats-service",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -28,8 +28,7 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@edifice.io/aiwiki-nest-api": "0.1.0",
32
- "@edifice.io/common-nest": "0.1.0"
31
+ "@edifice.io/aiwiki-nest-api": "0.2.1"
33
32
  },
34
33
  "devDependencies": {
35
34
  "husky": "9.0.11",