@powerhousedao/codegen 0.49.2-dev.5 → 0.49.2-dev.6
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/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t +9 -23
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.esm.t +16 -0
- package/dist/src/codegen/graphql.d.ts +13 -0
- package/dist/src/codegen/graphql.d.ts.map +1 -1
- package/dist/src/codegen/graphql.js +29 -26
- package/dist/{tsconfig.tsbuildinfo → tsconfig.lib.tsbuildinfo} +1 -1
- package/package.json +3 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.inject_export.esm.t +0 -7
|
@@ -17,15 +17,15 @@ export const getResolvers = (subgraph: Subgraph) => {
|
|
|
17
17
|
|
|
18
18
|
return ({
|
|
19
19
|
Query: {
|
|
20
|
-
<%- h.changeCase.pascal(documentType) %>: async (_: any, args: any) => {
|
|
20
|
+
<%- h.changeCase.pascal(documentType) %>: async (_: any, args: any, ctx: any) => {
|
|
21
21
|
return {
|
|
22
|
-
getDocument: async (
|
|
22
|
+
getDocument: async (args: any) => {
|
|
23
23
|
const driveId: string = args.driveId || DEFAULT_DRIVE_ID;
|
|
24
24
|
const docId: string = args.docId || "";
|
|
25
25
|
const doc = await reactor.getDocument(driveId, docId);
|
|
26
26
|
return doc;
|
|
27
27
|
},
|
|
28
|
-
getDocuments: async (
|
|
28
|
+
getDocuments: async (args: any) => {
|
|
29
29
|
const driveId: string = args.driveId || DEFAULT_DRIVE_ID;
|
|
30
30
|
const docsIds = await reactor.getDocuments(driveId);
|
|
31
31
|
const docs = await Promise.all(
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t
CHANGED
|
@@ -2,35 +2,21 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/index.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ProcessorUpdate,
|
|
10
|
-
AnalyticsPath
|
|
11
|
-
} from "@powerhousedao/reactor-api";
|
|
5
|
+
import type { PHDocument } from "document-model";
|
|
6
|
+
import { AnalyticsPath, IAnalyticsStore, IProcessor } from "@powerhousedao/reactor-api";
|
|
7
|
+
import { InternalTransmitterUpdate } from "document-drive";
|
|
8
|
+
|
|
12
9
|
<% documentTypes.forEach(type => { _%>
|
|
13
10
|
import type { <%= documentTypesMap[type].name %>Document } from "<%= documentTypesMap[type].importPath %>/index.js";
|
|
14
11
|
%><% }); _%>
|
|
15
|
-
<% if(documentTypes.length === 0) { %>import type { PHDocument } from "document-model";<% } %>
|
|
16
|
-
type DocumentType = <% if(documentTypes.length) { %><%= documentTypes.map(type => `${documentTypesMap[type].name}Document`).join(" | ") %> <% } else { %>PHDocument<% } %>;
|
|
17
12
|
|
|
18
|
-
export class <%= pascalName %>Processor
|
|
13
|
+
export class <%= pascalName %>Processor implements IProcessor {
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
branch: ["main"],
|
|
24
|
-
documentId: ["*"],
|
|
25
|
-
documentType: [<% if(documentTypes.length) { %><%- documentTypes.map(type => `"${type}"`).join(", ") %><% } else { %>"*"<% } %>],
|
|
26
|
-
scope: ["global"],
|
|
27
|
-
},
|
|
28
|
-
block: false,
|
|
29
|
-
label: "<%= name %>",
|
|
30
|
-
system: true,
|
|
31
|
-
};
|
|
15
|
+
constructor(private readonly analyticsStore: IAnalyticsStore) {
|
|
16
|
+
//
|
|
17
|
+
}
|
|
32
18
|
|
|
33
|
-
async onStrands(strands:
|
|
19
|
+
async onStrands<TDocument extends PHDocument>(strands: InternalTransmitterUpdate<TDocument>[]): Promise<void> {
|
|
34
20
|
if (strands.length === 0) {
|
|
35
21
|
return;
|
|
36
22
|
}
|
|
@@ -7,3 +7,19 @@ unless_exists: true
|
|
|
7
7
|
* Delete the file and run the code generator again to have it reset
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { ProcessorFactory, ReactorModule, ProcessorRecord } from "@powerhousedao/reactor-api";
|
|
11
|
+
import { <%= pascalName %>Processor } from "./<%= h.changeCase.param(name) %>/index.js";
|
|
12
|
+
|
|
13
|
+
export const processorFactory: ProcessorFactory = (driveId: string, module: ReactorModule):ProcessorRecord[] => {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
processor: new <%= pascalName %>Processor(module.analyticsStore),
|
|
17
|
+
filter: {
|
|
18
|
+
branch: ["main"],
|
|
19
|
+
documentId: ["*"],
|
|
20
|
+
scope: ["*"],
|
|
21
|
+
documentType: ["*"],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { type CodegenConfig } from "@graphql-codegen/cli";
|
|
2
2
|
import { type TypeScriptPluginConfig } from "@graphql-codegen/typescript";
|
|
3
|
+
export declare const scalars: {
|
|
4
|
+
Unknown: string;
|
|
5
|
+
DateTime: string;
|
|
6
|
+
Attachment: string;
|
|
7
|
+
Address: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const scalarsValidation: {
|
|
10
|
+
Unknown: string;
|
|
11
|
+
DateTime: string;
|
|
12
|
+
Attachment: string;
|
|
13
|
+
Address: string;
|
|
14
|
+
};
|
|
3
15
|
export declare const tsConfig: TypeScriptPluginConfig;
|
|
16
|
+
export declare const zodConfig: Record<string, unknown>;
|
|
4
17
|
export declare function schemaConfig(name: string, dir: string): CodegenConfig["generates"];
|
|
5
18
|
export declare const generateSchema: (model: string, dir: string, { watch, skipFormat }?: {
|
|
6
19
|
watch?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/codegen/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAU1E,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/codegen/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAU1E,eAAO,MAAM,OAAO;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;CAO7B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,sBAWtB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAYpC,CAAC;AAEX,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,aAAa,CAAC,WAAW,CAAC,CAmB5B;AAED,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,KAAK,MAAM,EACX;;;CAA0C,iBAa3C,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,KAAK,MAAM,EACX;;;CAA0C,iBAoB3C,CAAC"}
|
|
@@ -5,15 +5,23 @@ import { formatWithPrettierBeforeWrite } from "./utils.js";
|
|
|
5
5
|
const getDirectories = (source) => readdirSync(source, { withFileTypes: true })
|
|
6
6
|
.filter((dirent) => dirent.isDirectory())
|
|
7
7
|
.map((dirent) => dirent.name);
|
|
8
|
+
export const scalars = {
|
|
9
|
+
Unknown: "unknown",
|
|
10
|
+
DateTime: "string",
|
|
11
|
+
Attachment: "string",
|
|
12
|
+
Address: "`${string}:0x${string}`",
|
|
13
|
+
...generatorTypeDefs,
|
|
14
|
+
};
|
|
15
|
+
export const scalarsValidation = {
|
|
16
|
+
Unknown: "z.unknown()",
|
|
17
|
+
DateTime: "z.string().datetime()",
|
|
18
|
+
Attachment: "z.string()",
|
|
19
|
+
Address: "z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))",
|
|
20
|
+
...validationSchema,
|
|
21
|
+
};
|
|
8
22
|
export const tsConfig = {
|
|
9
23
|
strictScalars: true,
|
|
10
|
-
scalars
|
|
11
|
-
Unknown: "unknown",
|
|
12
|
-
DateTime: "string",
|
|
13
|
-
Attachment: "string",
|
|
14
|
-
Address: "`${string}:0x${string}`",
|
|
15
|
-
...generatorTypeDefs,
|
|
16
|
-
},
|
|
24
|
+
scalars,
|
|
17
25
|
enumsAsTypes: true,
|
|
18
26
|
allowEnumStringTypes: true,
|
|
19
27
|
avoidOptionals: {
|
|
@@ -23,6 +31,19 @@ export const tsConfig = {
|
|
|
23
31
|
// maybeValue: "T | null | undefined",
|
|
24
32
|
inputMaybeValue: "T | null | undefined",
|
|
25
33
|
};
|
|
34
|
+
export const zodConfig = {
|
|
35
|
+
...tsConfig,
|
|
36
|
+
importFrom: `./types.js`,
|
|
37
|
+
schema: "zod",
|
|
38
|
+
useTypeImports: true,
|
|
39
|
+
scalarSchemas: scalarsValidation,
|
|
40
|
+
directives: {
|
|
41
|
+
equals: {
|
|
42
|
+
value: ["regex", "/^$1$/"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
withObjectType: true,
|
|
46
|
+
};
|
|
26
47
|
export function schemaConfig(name, dir) {
|
|
27
48
|
return {
|
|
28
49
|
[`${dir}/${name}/gen/schema/types.ts`]: {
|
|
@@ -39,25 +60,7 @@ export function schemaConfig(name, dir) {
|
|
|
39
60
|
[`${dir}/${name}/gen/schema/zod.ts`]: {
|
|
40
61
|
schema: `${dir}/${name}/schema.graphql`,
|
|
41
62
|
plugins: ["@acaldas/graphql-codegen-typescript-validation-schema"],
|
|
42
|
-
config:
|
|
43
|
-
...tsConfig,
|
|
44
|
-
importFrom: `./types.js`,
|
|
45
|
-
schema: "zod",
|
|
46
|
-
useTypeImports: true,
|
|
47
|
-
scalarSchemas: {
|
|
48
|
-
Unknown: "z.unknown()",
|
|
49
|
-
DateTime: "z.string().datetime()",
|
|
50
|
-
Attachment: "z.string()",
|
|
51
|
-
Address: "z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))",
|
|
52
|
-
...validationSchema,
|
|
53
|
-
},
|
|
54
|
-
directives: {
|
|
55
|
-
equals: {
|
|
56
|
-
value: ["regex", "/^$1$/"],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
withObjectType: true,
|
|
60
|
-
},
|
|
63
|
+
config: zodConfig,
|
|
61
64
|
},
|
|
62
65
|
};
|
|
63
66
|
}
|