@powerhousedao/codegen 4.1.0-dev.9 → 4.1.0-staging.1
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-custom-subgraph/index.d.ts +14 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts.map +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js +12 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js.map +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/resolvers.esm.t +17 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/schema.esm.t +16 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/object.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t +96 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +3 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/utils.esm.t +11 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t +6 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +4 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +13 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +59 -50
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +38 -24
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +244 -181
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +53 -74
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderTree.esm.t +44 -26
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +22 -58
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.d.ts +16 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.d.ts.map +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.esm.t +2 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.js +12 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.js.map +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +2 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/factory.esm.t +2 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.esm.t +7 -5
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/factory.esm.t +3 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.esm.t +6 -5
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.esm.t +0 -32
- package/dist/src/codegen/hygen.d.ts +6 -4
- package/dist/src/codegen/hygen.d.ts.map +1 -1
- package/dist/src/codegen/hygen.js +35 -8
- package/dist/src/codegen/hygen.js.map +1 -1
- package/dist/src/codegen/index.d.ts +5 -3
- package/dist/src/codegen/index.d.ts.map +1 -1
- package/dist/src/codegen/index.js +72 -5
- package/dist/src/codegen/index.js.map +1 -1
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts +8 -6
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts +1 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js +9 -7
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js.map +1 -1
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts +3 -0
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js +85 -14
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js.map +1 -1
- package/dist/tsconfig.hygen.tsbuildinfo +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +13 -6
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FileItemsGrid.esm.t +0 -44
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderItemsGrid.esm.t +0 -96
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useSelectedFolderChildren.esm.t +0 -35
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useTransformedNodes.esm.t +0 -35
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Args = {
|
|
2
|
+
rootDir: string;
|
|
3
|
+
subgraph: string;
|
|
4
|
+
};
|
|
5
|
+
declare const generateCustomSubgraph: {
|
|
6
|
+
params: ({ args, }: {
|
|
7
|
+
args: Args;
|
|
8
|
+
}) => {
|
|
9
|
+
rootDir: string;
|
|
10
|
+
subgraph: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default generateCustomSubgraph;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,sBAAsB;wBAGvB;QACD,IAAI,EAAE,IAAI,CAAC;KACZ,KAAG;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB;CAMF,CAAC;AACF,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const generateCustomSubgraph = {
|
|
4
|
+
params: ({ args, }) => {
|
|
5
|
+
return {
|
|
6
|
+
rootDir: args.rootDir,
|
|
7
|
+
subgraph: args.subgraph,
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
exports.default = generateCustomSubgraph;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.ts"],"names":[],"mappings":";;AAKA,MAAM,sBAAsB,GAAG;IAC7B,MAAM,EAAE,CAAC,EACP,IAAI,GAGL,EAGC,EAAE;QACF,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF,CAAC;AACF,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= h.changeCase.param(subgraph) %>/resolvers.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { type Subgraph } from "@powerhousedao/reactor-api";
|
|
6
|
+
|
|
7
|
+
export const getResolvers = (subgraph: Subgraph) => {
|
|
8
|
+
const reactor = subgraph.reactor;
|
|
9
|
+
|
|
10
|
+
return ({
|
|
11
|
+
Query: {
|
|
12
|
+
example: async (parent: unknown, args: { driveId: string }) => {
|
|
13
|
+
return "example";
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
"""
|
|
10
|
+
Subgraph definition
|
|
11
|
+
"""
|
|
12
|
+
type Query {
|
|
13
|
+
example(driveId: String!): String
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
`
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/object.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import { BaseDocumentClass, type
|
|
6
|
-
import { <%= 'type ' + h.changeCase.pascal(documentType) %>State, <%= 'type ' + h.changeCase.pascal(documentType) %>LocalState } from './types.js';
|
|
5
|
+
import { BaseDocumentClass, type BaseStateFromDocument, type PartialState, applyMixins, type SignalDispatch } from 'document-model';
|
|
6
|
+
import { <%= 'type ' + h.changeCase.pascal(documentType) %>State, <%= 'type ' + h.changeCase.pascal(documentType) %>LocalState, <%= 'type ' + h.changeCase.pascal(documentType) %>Document } from './types.js';
|
|
7
7
|
import { <%= 'type ' + h.changeCase.pascal(documentType) %>Action } from './actions.js';
|
|
8
8
|
import { reducer } from './reducer.js';
|
|
9
9
|
import utils from './utils.js';
|
|
@@ -23,7 +23,7 @@ interface <%= h.changeCase.pascal(documentType) %> extends
|
|
|
23
23
|
class <%= h.changeCase.pascal(documentType) %> extends BaseDocumentClass<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, <%= h.changeCase.pascal(documentType) %>Action> {
|
|
24
24
|
static fileExtension = '<%= extension %>';
|
|
25
25
|
|
|
26
|
-
constructor(initialState?: Partial<
|
|
26
|
+
constructor(initialState?: Partial<BaseStateFromDocument<<%= h.changeCase.pascal(documentType) %>Document>>, dispatch?: SignalDispatch) {
|
|
27
27
|
super(reducer, utils.createDocument(initialState), dispatch);
|
|
28
28
|
}
|
|
29
29
|
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/ph-factories.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
/**
|
|
6
|
+
* Factory methods for creating <%= h.changeCase.pascal(documentType) %>Document instances
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
createBaseState,
|
|
11
|
+
defaultBaseState,
|
|
12
|
+
type PHAuthState,
|
|
13
|
+
type PHDocumentState,
|
|
14
|
+
type PHBaseState,
|
|
15
|
+
} from "document-model";
|
|
16
|
+
import type {
|
|
17
|
+
<%= h.changeCase.pascal(documentType) %>Document,
|
|
18
|
+
<%= h.changeCase.pascal(documentType) %>LocalState,
|
|
19
|
+
<%= h.changeCase.pascal(documentType) %>State,
|
|
20
|
+
} from "./gen/types.js";
|
|
21
|
+
import { createDocument } from "./gen/utils.js";
|
|
22
|
+
|
|
23
|
+
export function defaultGlobalState(): <%= h.changeCase.pascal(documentType) %>State {
|
|
24
|
+
return <%- initialGlobalState %>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function defaultLocalState(): <%= h.changeCase.pascal(documentType) %>LocalState {
|
|
28
|
+
return <%- initialLocalState %>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function defaultPHState(): <%= h.changeCase.pascal(documentType) %>PHState {
|
|
32
|
+
return {
|
|
33
|
+
...defaultBaseState(),
|
|
34
|
+
global: defaultGlobalState(),
|
|
35
|
+
local: defaultLocalState(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function createGlobalState(
|
|
40
|
+
state?: Partial<<%= h.changeCase.pascal(documentType) %>State>,
|
|
41
|
+
): <%= h.changeCase.pascal(documentType) %>State {
|
|
42
|
+
return {
|
|
43
|
+
...defaultGlobalState(),
|
|
44
|
+
...(state || {}),
|
|
45
|
+
} as <%= h.changeCase.pascal(documentType) %>State;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createLocalState(
|
|
49
|
+
state?: Partial<<%= h.changeCase.pascal(documentType) %>LocalState>,
|
|
50
|
+
): <%= h.changeCase.pascal(documentType) %>LocalState {
|
|
51
|
+
return {
|
|
52
|
+
...defaultLocalState(),
|
|
53
|
+
...(state || {}),
|
|
54
|
+
} as <%= h.changeCase.pascal(documentType) %>LocalState;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createState(
|
|
58
|
+
baseState?: Partial<PHBaseState>,
|
|
59
|
+
globalState?: Partial<<%= h.changeCase.pascal(documentType) %>State>,
|
|
60
|
+
localState?: Partial<<%= h.changeCase.pascal(documentType) %>LocalState>,
|
|
61
|
+
): <%= h.changeCase.pascal(documentType) %>PHState {
|
|
62
|
+
return {
|
|
63
|
+
...createBaseState(baseState?.auth, baseState?.document),
|
|
64
|
+
global: createGlobalState(globalState),
|
|
65
|
+
local: createLocalState(localState),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type <%= h.changeCase.pascal(documentType) %>PHState = PHBaseState & {
|
|
70
|
+
global: <%= h.changeCase.pascal(documentType) %>State;
|
|
71
|
+
local: <%= h.changeCase.pascal(documentType) %>LocalState;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a <%= h.changeCase.pascal(documentType) %>Document with custom global and local state
|
|
76
|
+
* This properly handles the PHBaseState requirements while allowing
|
|
77
|
+
* document-specific state to be set.
|
|
78
|
+
*/
|
|
79
|
+
export function create<%= h.changeCase.pascal(documentType) %>Document(
|
|
80
|
+
state?: Partial<{
|
|
81
|
+
auth?: Partial<PHAuthState>;
|
|
82
|
+
document?: Partial<PHDocumentState>;
|
|
83
|
+
global?: Partial<<%= h.changeCase.pascal(documentType) %>State>;
|
|
84
|
+
local?: Partial<<%= h.changeCase.pascal(documentType) %>LocalState>;
|
|
85
|
+
}>,
|
|
86
|
+
): <%= h.changeCase.pascal(documentType) %>Document {
|
|
87
|
+
const document = createDocument(
|
|
88
|
+
state ? createState(
|
|
89
|
+
createBaseState(state.auth, state.document),
|
|
90
|
+
state.global,
|
|
91
|
+
state.local,
|
|
92
|
+
) : undefined
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return document;
|
|
96
|
+
}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/reducer.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
+
// TODO: remove eslint-disable rules once refactor is done
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
5
8
|
import { type StateReducer, isDocumentAction, createReducer } from "document-model";
|
|
6
9
|
import { <%= 'type ' + h.changeCase.pascal(documentType) %>Document, z } from './types.js';
|
|
7
10
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/types.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import type { PHDocument,
|
|
5
|
+
import type { PHDocument, BaseStateFromDocument } from 'document-model';
|
|
6
6
|
import type { <%= h.changeCase.pascal(documentType) %>State } from './schema/types.js';
|
|
7
7
|
<% if(hasLocalSchema) { -%>
|
|
8
8
|
import type { <%= h.changeCase.pascal(documentType) %>LocalState } from './schema/types.js';
|
|
@@ -14,6 +14,6 @@ export type * from './schema/types.js';
|
|
|
14
14
|
<% if(!hasLocalSchema) { -%>
|
|
15
15
|
<%= 'type ' + h.changeCase.pascal(documentType) %>LocalState = Record<PropertyKey, never>;
|
|
16
16
|
<%} -%>
|
|
17
|
-
export type Extended<%= h.changeCase.pascal(documentType) %>State =
|
|
17
|
+
export type Extended<%= h.changeCase.pascal(documentType) %>State = BaseStateFromDocument<<%= h.changeCase.pascal(documentType) %>Document>;
|
|
18
18
|
export <%= 'type ' + h.changeCase.pascal(documentType) %>Document = PHDocument<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState>;
|
|
19
19
|
export type { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, <%= h.changeCase.pascal(documentType) %>Action };
|
|
@@ -5,11 +5,11 @@ force: true
|
|
|
5
5
|
import {
|
|
6
6
|
type DocumentModelUtils,
|
|
7
7
|
baseCreateDocument,
|
|
8
|
-
baseCreateExtendedState,
|
|
9
8
|
baseSaveToFile,
|
|
10
9
|
baseSaveToFileHandle,
|
|
11
10
|
baseLoadFromFile,
|
|
12
11
|
baseLoadFromInput,
|
|
12
|
+
defaultBaseState,
|
|
13
13
|
generateId,
|
|
14
14
|
} from 'document-model';
|
|
15
15
|
import {
|
|
@@ -25,18 +25,12 @@ export const initialLocalState: <%= h.changeCase.pascal(documentType) %>LocalSta
|
|
|
25
25
|
const utils: DocumentModelUtils<<%= h.changeCase.pascal(documentType) %>Document> = {
|
|
26
26
|
fileExtension: '<%- fileExtension %>',
|
|
27
27
|
createState(state) {
|
|
28
|
-
return { global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
29
|
-
},
|
|
30
|
-
createExtendedState(extendedState) {
|
|
31
|
-
return baseCreateExtendedState(
|
|
32
|
-
{ ...extendedState },
|
|
33
|
-
utils.createState
|
|
34
|
-
);
|
|
28
|
+
return { ...defaultBaseState(), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
35
29
|
},
|
|
36
30
|
createDocument(state) {
|
|
37
31
|
const document = baseCreateDocument(
|
|
38
|
-
utils.
|
|
39
|
-
|
|
32
|
+
utils.createState,
|
|
33
|
+
state
|
|
40
34
|
);
|
|
41
35
|
|
|
42
36
|
document.header.documentType = '<%- documentTypeId %>';
|
|
@@ -60,4 +54,11 @@ const utils: DocumentModelUtils<<%= h.changeCase.pascal(documentType) %>Document
|
|
|
60
54
|
},
|
|
61
55
|
};
|
|
62
56
|
|
|
57
|
+
export const createDocument = utils.createDocument;
|
|
58
|
+
export const createState = utils.createState;
|
|
59
|
+
export const saveToFile = utils.saveToFile;
|
|
60
|
+
export const saveToFileHandle = utils.saveToFileHandle;
|
|
61
|
+
export const loadFromFile = utils.loadFromFile;
|
|
62
|
+
export const loadFromInput = utils.loadFromInput;
|
|
63
|
+
|
|
63
64
|
export default utils;
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t
CHANGED
|
@@ -39,10 +39,10 @@ describe('<%= h.changeCase.pascal(module) %> Operations', () => {
|
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
expect(updatedDocument.operations.<%= action.scope %>).toHaveLength(1);
|
|
42
|
-
expect(updatedDocument.operations.<%= action.scope %>[0].type).toBe(
|
|
42
|
+
expect(updatedDocument.operations.<%= action.scope %>[0].action.type).toBe(
|
|
43
43
|
'<%= h.changeCase.constant(action.name) %>',
|
|
44
44
|
);
|
|
45
|
-
expect(updatedDocument.operations.<%= action.scope %>[0].input).toStrictEqual(input);
|
|
45
|
+
expect(updatedDocument.operations.<%= action.scope %>[0].action.input).toStrictEqual(input);
|
|
46
46
|
expect(updatedDocument.operations.<%= action.scope %>[0].index).toEqual(0);
|
|
47
47
|
});
|
|
48
48
|
<% }); _%>
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t
CHANGED
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/error.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
<% if (
|
|
5
|
+
<% if (errors.length > 0) { _%>
|
|
6
6
|
export type ErrorCode =
|
|
7
|
-
<%
|
|
8
|
-
|
|
9
|
-
| '<%= h.changeCase.pascal(error.name) %>'<% if (actionIndex === actions.length - 1 && errorIndex === action.errors.length - 1) { %>;<% } %>
|
|
10
|
-
<% }); _%>
|
|
7
|
+
<% errors.forEach((error, errorIndex) => { _%>
|
|
8
|
+
| '<%= h.changeCase.pascal(error.name) %>'<% if (errorIndex === errors.length - 1) { %>;<% } %>
|
|
11
9
|
<% }); _%>
|
|
12
10
|
|
|
13
11
|
export interface ReducerError {
|
|
14
12
|
errorCode: ErrorCode;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
<%
|
|
18
|
-
<% action.errors.forEach(error => { _%>
|
|
15
|
+
<% errors.forEach(error => { _%>
|
|
19
16
|
export class <%= h.changeCase.pascal(error.name) %> extends Error implements ReducerError {
|
|
20
17
|
errorCode = '<%= h.changeCase.pascal(error.name) %>' as ErrorCode;
|
|
21
18
|
constructor(message = '<%= h.changeCase.pascal(error.name) %>') {
|
|
@@ -23,7 +20,6 @@ export class <%= h.changeCase.pascal(error.name) %> extends Error implements Red
|
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
<% }); _%>
|
|
27
23
|
<% }); _%>
|
|
28
24
|
|
|
29
25
|
<% } _%>
|
|
@@ -32,9 +28,9 @@ export const errors = {
|
|
|
32
28
|
<% if(action.errors?.length > 0){ -%>
|
|
33
29
|
<%= h.changeCase.pascal(action.name) %>: {
|
|
34
30
|
<% action.errors.forEach(error => { _%>
|
|
35
|
-
|
|
31
|
+
<%= h.changeCase.pascal(error.name) %>,
|
|
36
32
|
<% }); _%>
|
|
37
|
-
},
|
|
33
|
+
},
|
|
38
34
|
<% } -%>
|
|
39
35
|
<% }); _%>
|
|
40
36
|
};
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { type DocumentModelState } from "document-model";
|
|
1
2
|
import { type Args } from "../generate-document-model/index.js";
|
|
2
3
|
type ModuleArgs = Args & {
|
|
3
4
|
module: string;
|
|
4
5
|
};
|
|
6
|
+
type OperationError = DocumentModelState["specifications"][number]["modules"][number]["operations"][number]["errors"][number];
|
|
5
7
|
type Actions = {
|
|
6
8
|
name: string | null;
|
|
7
9
|
hasInput: boolean;
|
|
8
10
|
hasAttachment: boolean | undefined;
|
|
9
11
|
scope: string;
|
|
10
12
|
state: string;
|
|
13
|
+
errors: OperationError[];
|
|
11
14
|
};
|
|
12
15
|
declare const _default: {
|
|
13
16
|
params: ({ args }: {
|
|
@@ -17,6 +20,7 @@ declare const _default: {
|
|
|
17
20
|
documentType: string;
|
|
18
21
|
module: string;
|
|
19
22
|
actions: Actions[];
|
|
23
|
+
errors: import("document-model").DocumentModelOperationError[];
|
|
20
24
|
};
|
|
21
25
|
};
|
|
22
26
|
export default _default;
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAEhE,KAAK,UAAU,GAAG,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5C,KAAK,cAAc,GACjB,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAC1G,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC;;uBAGmB;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE;;;;;;;;AADzC,wBA2CE"}
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js
CHANGED
|
@@ -11,17 +11,29 @@ exports.default = {
|
|
|
11
11
|
name: a.name,
|
|
12
12
|
hasInput: a.schema !== null,
|
|
13
13
|
hasAttachment: a.schema?.includes(": Attachment"),
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
15
14
|
scope: a.scope || "global",
|
|
16
15
|
state: a.scope === "global" ? "" : a.scope, // the state this action affects
|
|
17
16
|
errors: a.errors,
|
|
18
17
|
}))
|
|
19
18
|
: [];
|
|
19
|
+
const errors = actions.reduce((acc, action) => {
|
|
20
|
+
action.errors.forEach((error) => {
|
|
21
|
+
const existingError = acc.find((e) => e.code === error.code);
|
|
22
|
+
if (!existingError) {
|
|
23
|
+
acc.push(error);
|
|
24
|
+
}
|
|
25
|
+
else if (JSON.stringify(existingError) !== JSON.stringify(error)) {
|
|
26
|
+
console.warn(`Warning: Duplicate error code "${error.code}" with different fields found`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return acc;
|
|
30
|
+
}, []);
|
|
20
31
|
return {
|
|
21
32
|
rootDir: args.rootDir,
|
|
22
33
|
documentType: documentModel.name,
|
|
23
34
|
module: (0, change_case_1.paramCase)(args.module),
|
|
24
35
|
actions,
|
|
36
|
+
errors,
|
|
25
37
|
};
|
|
26
38
|
},
|
|
27
39
|
};
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":[],"mappings":";;AAAA,6CAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":[],"mappings":";;AAAA,6CAAwC;AAgBxC,kBAAe;IACb,MAAM,EAAE,CAAC,EAAE,IAAI,EAAwB,EAAE,EAAE;QACzC,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAuB,CAAC;QAC3E,MAAM,UAAU,GACd,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxE,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAC/C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAC9B,CAAC;QAEF,MAAM,OAAO,GACX,eAAe,CAAC,MAAM,GAAG,CAAC;YACxB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,QAAQ,EAAE,CAAC,CAAC,MAAM,KAAK,IAAI;gBAC3B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC;gBACjD,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,QAAQ;gBAC1B,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,gCAAgC;gBAC5E,MAAM,EAAE,CAAC,CAAC,MAAM;aACjB,CAAC,CAAC;YACL,CAAC,CAAC,EAAE,CAAC;QAET,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YAC9D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC9B,MAAM,aAAa,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC7D,IAAI,CAAC,aAAa,EAAE,CAAC;oBACnB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAClB,CAAC;qBAAM,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,OAAO,CAAC,IAAI,CACV,kCAAkC,KAAK,CAAC,IAAI,+BAA+B,CAC5E,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,aAAa,CAAC,IAAI;YAChC,MAAM,EAAE,IAAA,uBAAS,EAAC,IAAI,CAAC,MAAM,CAAC;YAC9B,OAAO;YACP,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -2,49 +2,55 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(subgraph) %>/resolvers.ts"
|
|
3
3
|
force: true
|
|
4
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
5
|
import { type Subgraph } from "@powerhousedao/reactor-api";
|
|
9
6
|
import { addFile } from "document-drive";
|
|
10
|
-
import { actions } from "../../document-models/<%- h.changeCase.param(documentType) %>/index.js";
|
|
11
|
-
import {
|
|
7
|
+
import { actions <% modules.forEach(module => { %><% module.operations.forEach(op => { %>, type <%- h.changeCase.pascal(op.name) %>Input<%_ })}); %> } from "../../document-models/<%- h.changeCase.param(documentType) %>/index.js";
|
|
8
|
+
import { setName } from "document-model";
|
|
12
9
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
export const getResolvers = (subgraph: Subgraph): Record<string, any> => {
|
|
10
|
+
export const getResolvers = (subgraph: Subgraph) => {
|
|
16
11
|
const reactor = subgraph.reactor;
|
|
17
12
|
|
|
18
13
|
return ({
|
|
19
14
|
Query: {
|
|
20
|
-
<%- h.changeCase.pascal(documentType) %>: async (
|
|
15
|
+
<%- h.changeCase.pascal(documentType) %>: async () => {
|
|
21
16
|
return {
|
|
22
|
-
getDocument: async (args:
|
|
23
|
-
const driveId
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
getDocument: async (args: { docId: string, driveId: string }) => {
|
|
18
|
+
const { docId, driveId } = args;
|
|
19
|
+
|
|
20
|
+
if(!docId) {
|
|
21
|
+
throw new Error("Document id is required");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if(driveId) {
|
|
25
|
+
const docIds = await reactor.getDocuments(driveId);
|
|
26
|
+
if(!docIds.includes(docId)) {
|
|
27
|
+
throw new Error(`Document with id ${docId} is not part of ${driveId}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const doc = await reactor.getDocument(docId);
|
|
32
|
+
return {
|
|
27
33
|
driveId: driveId,
|
|
28
34
|
...doc,
|
|
29
35
|
...doc.header,
|
|
30
36
|
state: doc.state.global,
|
|
31
37
|
stateJSON: doc.state.global,
|
|
32
|
-
revision: doc.header
|
|
38
|
+
revision: doc.header?.revision?.global ?? 0,
|
|
33
39
|
};
|
|
34
40
|
},
|
|
35
|
-
getDocuments: async (args:
|
|
36
|
-
const driveId
|
|
41
|
+
getDocuments: async (args: { driveId: string }) => {
|
|
42
|
+
const { driveId } = args;
|
|
37
43
|
const docsIds = await reactor.getDocuments(driveId);
|
|
38
44
|
const docs = await Promise.all(
|
|
39
45
|
docsIds.map(async (docId) => {
|
|
40
|
-
const doc = await reactor.getDocument(
|
|
46
|
+
const doc = await reactor.getDocument(docId);
|
|
41
47
|
return {
|
|
42
48
|
driveId: driveId,
|
|
43
49
|
...doc,
|
|
44
50
|
...doc.header,
|
|
45
51
|
state: doc.state.global,
|
|
46
52
|
stateJSON: doc.state.global,
|
|
47
|
-
revision: doc.header
|
|
53
|
+
revision: doc.header?.revision?.global ?? 0,
|
|
48
54
|
};
|
|
49
55
|
}),
|
|
50
56
|
);
|
|
@@ -57,47 +63,50 @@ export const getResolvers = (subgraph: Subgraph): Record<string, any> => {
|
|
|
57
63
|
},
|
|
58
64
|
},
|
|
59
65
|
Mutation: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const docId = generateId();
|
|
66
|
+
<%- h.changeCase.pascal(documentType) %>_createDocument: async (_: unknown, args: { name: string, driveId?: string }) => {
|
|
67
|
+
const { driveId, name } = args;
|
|
68
|
+
const document = await reactor.addDocument("<%- documentTypeId %>");
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
70
|
+
if(driveId) {
|
|
71
|
+
await reactor.addAction(
|
|
72
|
+
driveId,
|
|
73
|
+
addFile({
|
|
74
|
+
name,
|
|
75
|
+
id: document.header.id,
|
|
76
|
+
documentType: "<%- documentTypeId %>",
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if(name) {
|
|
82
|
+
await reactor.addAction(
|
|
83
|
+
document.header.id,
|
|
84
|
+
setName(name),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
82
87
|
|
|
83
|
-
return
|
|
88
|
+
return document.header.id;
|
|
84
89
|
},
|
|
85
90
|
|
|
86
91
|
<% modules.forEach(module => { _%>
|
|
87
92
|
<% module.operations.forEach(op => { _%>
|
|
88
|
-
<%- h.changeCase.pascal(documentType) + '_' + h.changeCase.camel(op.name)
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
<%- h.changeCase.pascal(documentType) + '_' + h.changeCase.camel(op.name) %>: async (_: unknown, args: { docId: string, input: <%- h.changeCase.pascal(op.name) %>Input}) => {
|
|
94
|
+
const { docId, input } = args;
|
|
95
|
+
const doc = await reactor.getDocument(docId);
|
|
96
|
+
if(!doc) {
|
|
97
|
+
throw new Error("Document not found");
|
|
98
|
+
}
|
|
93
99
|
|
|
94
|
-
await reactor.addAction(
|
|
95
|
-
driveId,
|
|
100
|
+
const result = await reactor.addAction(
|
|
96
101
|
docId,
|
|
97
|
-
actions.<%- h.changeCase.camel(op.name) %>(
|
|
102
|
+
actions.<%- h.changeCase.camel(op.name) %>(input)
|
|
98
103
|
);
|
|
99
104
|
|
|
100
|
-
|
|
105
|
+
if(result.status !== "SUCCESS") {
|
|
106
|
+
throw new Error(result.error?.message ?? "Failed to <%- h.changeCase.camel(op.name) %>");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return true;
|
|
101
110
|
},
|
|
102
111
|
|
|
103
112
|
<%_ })}); %>
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t
CHANGED
|
@@ -17,8 +17,8 @@ Queries: <%= h.changeCase.pascal(documentType) %>
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
type <%- h.changeCase.pascal(documentType) %>Queries {
|
|
20
|
-
getDocument(
|
|
21
|
-
getDocuments(driveId: String): [<%- h.changeCase.pascal(documentType) %>!]
|
|
20
|
+
getDocument(docId: PHID!, driveId: PHID): <%- h.changeCase.pascal(documentType) %>
|
|
21
|
+
getDocuments(driveId: String!): [<%- h.changeCase.pascal(documentType) %>!]
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
type Query {
|
|
@@ -30,7 +30,7 @@ Mutations: <%= h.changeCase.pascal(documentType) %>
|
|
|
30
30
|
"""
|
|
31
31
|
type Mutation {
|
|
32
32
|
|
|
33
|
-
<%- h.changeCase.pascal(documentType) %>_createDocument(
|
|
33
|
+
<%- h.changeCase.pascal(documentType) %>_createDocument(name:String!, driveId:String): String
|
|
34
34
|
|
|
35
35
|
<% modules.forEach(module => { _%>
|
|
36
36
|
<% module.operations.forEach(op => { _%>
|