@powerhousedao/codegen 0.49.2-dev.2 → 0.49.2-dev.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/codegen",
3
- "version": "0.49.2-dev.2",
3
+ "version": "0.49.2-dev.3",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,15 +0,0 @@
1
- export type Args = {
2
- documentModel: string;
3
- rootDir: string;
4
- subgraph: string;
5
- };
6
- declare const generateDocumentsSubgraph: {
7
- params: ({ args, }: {
8
- args: Args;
9
- }) => {
10
- rootDir: string;
11
- subgraph: string;
12
- };
13
- };
14
- export default generateDocumentsSubgraph;
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-documents-subgraph/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,yBAAyB;wBAG1B;QACD,IAAI,EAAE,IAAI,CAAC;KACZ,KAAG;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB;CAMF,CAAC;AACF,eAAe,yBAAyB,CAAC"}
@@ -1,15 +0,0 @@
1
- ---
2
- to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/index.ts"
3
- force: true
4
- ---
5
- import { Subgraph } from "@powerhousedao/reactor-api";
6
- import { schema } from "./schema.js";
7
- import { getResolvers } from "./resolvers.js";
8
- export class <%= pascalName %>Subgraph extends Subgraph {
9
- name = "<%= h.changeCase.param(name) %>";
10
- typeDefs = schema;
11
- resolvers = getResolvers(this);
12
- additionalContextFields = {};
13
- async onSetup() {}
14
- async onDisconnect() {}
15
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const generateDocumentsSubgraph = {
4
- params: ({ args, }) => {
5
- return {
6
- rootDir: args.rootDir,
7
- subgraph: args.subgraph,
8
- };
9
- },
10
- };
11
- exports.default = generateDocumentsSubgraph;
@@ -1,9 +0,0 @@
1
- ---
2
- to: "<%= rootDir %>/index.ts"
3
- unless_exists: true
4
- ---
5
- /**
6
- * This is a scaffold file meant for customization.
7
- * Delete the file and run the code generator again to have it reset
8
- */
9
-
@@ -1,7 +0,0 @@
1
- ---
2
- inject: true
3
- append: true
4
- to: "<%= rootDir %>/index.ts"
5
- skip_if: "<%= h.changeCase.pascal(name) %>"
6
- ---
7
- export * as <%= h.changeCase.pascal(name) %>Subgraph from "./<%= h.changeCase.param(name) %>/index.js";
@@ -1,40 +0,0 @@
1
- ---
2
- to: "<%= rootDir %>/<%= h.changeCase.param(subgraph) %>/resolvers.ts"
3
- force: true
4
- ---
5
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
7
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
8
- import { type Subgraph } from "@powerhousedao/reactor-api";
9
- import { toPascalCase } from "document-drive/utils/misc";
10
-
11
- const DEFAULT_DRIVE_ID = "powerhouse";
12
-
13
- export const getResolvers = (subgraph: Subgraph) => {
14
- const reactor = subgraph.reactor;
15
-
16
- return ({
17
- Query: {
18
- document: async (_: any, args: any) => {
19
- const driveId: string = args.driveId || DEFAULT_DRIVE_ID;
20
- const docId: string = args.docId || "";
21
- const doc = await reactor.getDocument(driveId, docId);
22
- if (!doc) {
23
- throw new Error("Document not found");
24
- }
25
- const parts = doc.documentType.split("/");
26
- const typeName = toPascalCase(parts[parts.length - 1]);
27
-
28
- const response = {
29
- id: docId,
30
- ...doc,
31
- state: doc.state.global,
32
- stateJSON: doc.state.global,
33
- __typename: typeName,
34
- };
35
-
36
- return response;
37
- },
38
- },
39
- });
40
- };
@@ -1,12 +0,0 @@
1
- ---
2
- to: "<%= rootDir %>/<%= h.changeCase.param(subgraph) %>/schema.ts"
3
- force: true
4
- ---
5
- import { gql } from "graphql-tag";
6
- import type { DocumentNode } from "graphql";
7
-
8
- export const schema: DocumentNode = gql`
9
- type Query {
10
- document(driveId: String, docId: PHID): IDocument
11
- }
12
- `;