@powerhousedao/reactor-api 1.29.17-dev.2 → 1.29.17-dev.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"graphql-manager.d.ts","sourceRoot":"","sources":["../../../src/graphql/graphql-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAG5E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAMnC,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG/D,qBAAa,cAAc;;IAKvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAT5B,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,aAAa,CAA2B;gBAG7B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,EAAE,EAAE,EACpB,cAAc,EAAE,eAAe,EAC/B,SAAS,GAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAa;IAS3D,IAAI;IAmBJ,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,UAAU,SAAK,EAAE,IAAI,SAAK;IAsBpE,YAAY;IAQlB,0BAA0B,4BAExB;IAEF,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;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AE;CAyIxD"}
@@ -28,10 +28,11 @@ export class GraphQLManager {
28
28
  this.analyticsStore = analyticsStore;
29
29
  this.subgraphs = subgraphs;
30
30
  // Setup Default subgraphs
31
- this.registerSubgraph(AuthSubgraph);
32
- this.registerSubgraph(SystemSubgraph);
31
+ this.registerSubgraph(AuthSubgraph, "graphql");
32
+ this.registerSubgraph(SystemSubgraph, "graphql");
33
+ this.registerSubgraph(AnalyticsSubgraph, "graphql");
34
+ // special case for drive
33
35
  this.registerSubgraph(DriveSubgraph);
34
- this.registerSubgraph(AnalyticsSubgraph);
35
36
  }
36
37
  async init() {
37
38
  console.log(`> Initializing Subgraph Manager...`);
@@ -129,6 +130,7 @@ export class GraphQLManager {
129
130
  }
130
131
  }
131
132
  if (Object.keys(supergraphEndpoints).length > 0) {
133
+ await this.#sleep(1000);
132
134
  const supergraphServer = await this.#createApolloGateway(supergraphEndpoints);
133
135
  if (supergraphServer) {
134
136
  const path = `/${supergraph}`;
@@ -137,13 +139,21 @@ export class GraphQLManager {
137
139
  }
138
140
  }
139
141
  }
142
+ #sleep(ms) {
143
+ return new Promise((resolve) => {
144
+ setTimeout(resolve, ms);
145
+ });
146
+ }
140
147
  async #createApolloGateway(endpoints) {
141
148
  try {
149
+ const herokuOrLocal = process.env.HEROKU_APP_DEFAULT_DOMAIN_NAME
150
+ ? `https://${process.env.HEROKU_APP_DEFAULT_DOMAIN_NAME}`
151
+ : `http://localhost:${process.env.PORT ?? 4001}`;
142
152
  const gateway = new ApolloGateway({
143
153
  supergraphSdl: new IntrospectAndCompose({
144
154
  subgraphs: Object.keys(endpoints).map((path) => ({
145
155
  name: path.replaceAll("/", ""),
146
- url: `http://localhost:${process.env.PORT ?? 4001}${path}`,
156
+ url: `${herokuOrLocal}${process.env.BASE_PATH && process.env.BASE_PATH !== "/" ? process.env.BASE_PATH : ""}${path}`,
147
157
  })),
148
158
  }),
149
159
  });
@@ -54,7 +54,7 @@ async function initializePackageManager(options) {
54
54
  * Sets up the subgraph manager and registers subgraphs
55
55
  */
56
56
  async function setupGraphQLManager(app, reactor, db, analyticsStore, result) {
57
- const graphqlManager = new GraphQLManager("/", app, reactor, db, analyticsStore);
57
+ const graphqlManager = new GraphQLManager(process.env.BASE_PATH ?? "/", app, reactor, db, analyticsStore);
58
58
  await graphqlManager.init();
59
59
  if (result.subgraphs) {
60
60
  for (const [supergraph, subgraphs] of result.subgraphs.entries()) {
@@ -1,8 +1,8 @@
1
- import { IAnalyticsStore } from "@powerhousedao/analytics-engine-core";
2
- import { IProcessorManager } from "document-drive/processors/types";
1
+ import { type IAnalyticsStore } from "@powerhousedao/analytics-engine-core";
2
+ import { type IProcessorManager } from "document-drive/processors/types";
3
3
  import { type Express } from "express";
4
4
  import { type GraphQLManager } from "./graphql/graphql-manager.js";
5
- import { Db } from "./utils/db.js";
5
+ import { type Db } from "./utils/db.js";
6
6
  export type { Db } from "./utils/db.js";
7
7
  export type API = {
8
8
  app: Express;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAG,GAAG;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,iBAAiB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,eAAe,CAAC;IAChC,gBAAgB,EAAE,EAAE,CAAC;CACtB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAG,GAAG;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,iBAAiB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,eAAe,CAAC;IAChC,gBAAgB,EAAE,EAAE,CAAC;CACtB,CAAC"}