@edifice.io/aiwiki-v2-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.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.umd.cjs +1 -0
- package/dist/nats/client.d.ts +29 -0
- package/dist/nats/client.d.ts.map +1 -0
- package/package.json +55 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -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,78 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
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
|
+
import { Injectable as u, Logger as w } from "@nestjs/common";
|
|
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
|
+
};
|
|
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 AiwikiV2NatsServiceClient");
|
|
15
|
+
}
|
|
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";
|
|
21
|
+
this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
|
|
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)
|
|
24
|
+
throw this.logger.warn({ messageAddress: e }, "No reply received for subject"), new Error("No reply received");
|
|
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;
|
|
37
|
+
}
|
|
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";
|
|
44
|
+
this.logger.debug({ messageAddress: e }, "Sending request to NATS subject");
|
|
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)
|
|
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");
|
|
70
|
+
return s;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
a = b([
|
|
74
|
+
u()
|
|
75
|
+
], a);
|
|
76
|
+
export {
|
|
77
|
+
a as AiwikiV2NatsServiceClient
|
|
78
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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-v2-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.AiwikiV2NatsServiceClient=class{constructor(o){g(this,"logger",new n.Logger(t.AiwikiV2NatsServiceClient.name));this.natsClient=o,this.logger.log("Creating events service AiwikiV2NatsServiceClient")}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.AiwikiV2NatsServiceClient=l([n.Injectable()],t.AiwikiV2NatsServiceClient),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ClientProxy } from '@nestjs/microservices';
|
|
2
|
+
import { ContentRequest, ContentTransformRequest, CourseHierarchy, CourseResponse, FileCheckRequest, FileCheckResponse, JobAccepted, MessageReceived } from '@edifice.io/aiwiki-v2-nest-api';
|
|
3
|
+
export declare class AiwikiV2NatsServiceClient {
|
|
4
|
+
private readonly natsClient;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(natsClient: ClientProxy);
|
|
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>;
|
|
28
|
+
}
|
|
29
|
+
//# 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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version": "0.1.0",
|
|
4
|
+
"description": "Clients to interact with aiwiki-v2-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/aiwiki-v2-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