@carlonicora/nestjs-neo4jsonapi 3.2.4 → 3.3.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.
@@ -14,6 +14,21 @@ export declare class DiscordUserRepository extends AbstractRepository<DiscordUse
14
14
  }>;
15
15
  constructor(neo4j: Neo4jService, securityService: SecurityService, clsService: ClsService);
16
16
  protected buildReturnStatement(): string;
17
+ /**
18
+ * The Discord account linked to a platform user, if there is one.
19
+ *
20
+ * The inverse of {@link findByDiscordId}, for the paths that start from an
21
+ * authenticated web user rather than from a Discord interaction (listing the
22
+ * servers that user shares with the bot, resolving a recording's game master
23
+ * when it was started from the web). Undefined when the user has never
24
+ * linked Discord — callers degrade rather than fail.
25
+ *
26
+ * A DiscordUser's `id` is NOT reliably the user's id (only accounts created
27
+ * through the Discord OAuth path share one), so this traverses the edge.
28
+ */
29
+ findByUserId(params: {
30
+ userId: string;
31
+ }): Promise<DiscordUser | undefined>;
17
32
  findByDiscordId(params: {
18
33
  discordId: string;
19
34
  }): Promise<DiscordUser>;
@@ -1 +1 @@
1
- {"version":3,"file":"discord-user.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/discord-user/repositories/discord-user.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,qBACa,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,EAAE,OAAO,qBAAqB,CAAC,aAAa,CAAC;IACpH,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAAyB;gBAC1C,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF,SAAS,CAAC,oBAAoB,IAAI,MAAM;IAelC,eAAe,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;CAc3E"}
1
+ {"version":3,"file":"discord-user.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/discord-user/repositories/discord-user.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,qBACa,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,EAAE,OAAO,qBAAqB,CAAC,aAAa,CAAC;IACpH,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;OAAyB;gBAC1C,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAIzF,SAAS,CAAC,oBAAoB,IAAI,MAAM;IAexC;;;;;;;;;;;OAWG;IACG,YAAY,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAiB1E,eAAe,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;CAc3E"}
@@ -35,6 +35,31 @@ let DiscordUserRepository = class DiscordUserRepository extends core_1.AbstractR
35
35
  RETURN discorduser, discorduser_company, discorduser_user, discorduser_company as discorduser_user_company, discorduser_${user_1.userMeta.nodeName}_${role_1.roleMeta.nodeName}
36
36
  `;
37
37
  }
38
+ /**
39
+ * The Discord account linked to a platform user, if there is one.
40
+ *
41
+ * The inverse of {@link findByDiscordId}, for the paths that start from an
42
+ * authenticated web user rather than from a Discord interaction (listing the
43
+ * servers that user shares with the bot, resolving a recording's game master
44
+ * when it was started from the web). Undefined when the user has never
45
+ * linked Discord — callers degrade rather than fail.
46
+ *
47
+ * A DiscordUser's `id` is NOT reliably the user's id (only accounts created
48
+ * through the Discord OAuth path share one), so this traverses the edge.
49
+ */
50
+ async findByUserId(params) {
51
+ const query = this.neo4j.initQuery({ serialiser: this.descriptor.model });
52
+ query.queryParams = {
53
+ userId: params.userId,
54
+ };
55
+ query.query = `
56
+ MATCH (:${user_1.userMeta.labelName} { id: $userId })-[:HAS_DISCORD]->(${discord_user_1.DiscordUserDescriptor.model.nodeName}:${discord_user_1.DiscordUserDescriptor.model.labelName})
57
+ ${this.buildReturnStatement()}
58
+ LIMIT 1
59
+ `;
60
+ const users = await this.neo4j.readMany(query);
61
+ return users[0];
62
+ }
38
63
  async findByDiscordId(params) {
39
64
  const query = this.neo4j.initQuery({ serialiser: this.descriptor.model });
40
65
  query.queryParams = {
@@ -1 +1 @@
1
- {"version":3,"file":"discord-user.repository.js","sourceRoot":"","sources":["../../../../src/foundations/discord-user/repositories/discord-user.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,wCAAkF;AAClF,qCAAsC;AACtC,qCAAsC;AACtC,2DAA8E;AAGvE,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,yBAA2E;IAEpH,YAAY,KAAmB,EAAE,eAAgC,EAAE,UAAsB;QACvF,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAFzB,eAAU,GAAG,oCAAqB,CAAC;IAGtD,CAAC;IAES,oBAAoB;QAC5B,OAAO;;;;;oCAKyB,eAAQ,CAAC,QAAQ,qCAAqC,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,QAAQ;2BACrG,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,QAAQ;+BAClC,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,QAAQ;oCACjC,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,QAAQ,kCAAkC,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,SAAS;;gIAExC,eAAQ,CAAC,QAAQ,IAAI,eAAQ,CAAC,QAAQ;KACjK,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;QAE1E,KAAK,CAAC,WAAW,GAAG;YAClB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC;QAEF,KAAK,CAAC,KAAK,GAAG;eACH,oCAAqB,CAAC,KAAK,CAAC,QAAQ,IAAI,oCAAqB,CAAC,KAAK,CAAC,SAAS;QACpF,IAAI,CAAC,oBAAoB,EAAE;KAC9B,CAAC;QAEF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF,CAAA;AAnCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGQ,mBAAY,EAAmB,sBAAe,EAAc,uBAAU;GAF9E,qBAAqB,CAmCjC"}
1
+ {"version":3,"file":"discord-user.repository.js","sourceRoot":"","sources":["../../../../src/foundations/discord-user/repositories/discord-user.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,wCAAkF;AAClF,qCAAsC;AACtC,qCAAsC;AACtC,2DAA8E;AAGvE,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,yBAA2E;IAEpH,YAAY,KAAmB,EAAE,eAAgC,EAAE,UAAsB;QACvF,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAFzB,eAAU,GAAG,oCAAqB,CAAC;IAGtD,CAAC;IAES,oBAAoB;QAC5B,OAAO;;;;;oCAKyB,eAAQ,CAAC,QAAQ,qC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,GAAG;eACH,oCAAqB,CAAC,KAAK,CAAC,QAAQ,IAAI,oCAAqB,CAAC,KAAK,CAAC,SAAS;QACpF,IAAI,CAAC,oBAAoB,EAAE;KAC9B,CAAC;QAEF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF,CAAA;AAhEY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGQ,mBAAY,EAAmB,sBAAe,EAAc,uBAAU;GAF9E,qBAAqB,CAgEjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carlonicora/nestjs-neo4jsonapi",
3
- "version": "3.2.4",
3
+ "version": "3.3.0",
4
4
  "description": "NestJS foundation package with JSON:API, Neo4j, Redis, LangChain agents, and common utilities",
5
5
  "author": "Carlo Nicora",
6
6
  "license": "GPL-3.0-or-later",