@powerhousedao/codegen 0.37.3 → 0.38.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.
Files changed (46) hide show
  1. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModel.esm.t +1 -1
  2. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts +25 -0
  3. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts.map +1 -0
  4. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.js +62 -0
  5. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/object.esm.t +2 -2
  6. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +5 -6
  7. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootIndex.esm.t +6 -12
  8. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +2 -2
  9. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/utils.esm.t +16 -9
  10. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/actions.esm.t +3 -3
  11. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/creators.esm.t +1 -3
  12. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +1 -1
  13. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +24 -0
  14. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map +1 -0
  15. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +27 -0
  16. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/object.esm.t +4 -4
  17. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/operations.esm.t +1 -1
  18. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-mutations/index.d.ts +22 -0
  19. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-mutations/index.d.ts.map +1 -0
  20. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-mutations/index.js +21 -0
  21. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-mutations/resolvers.esm.t +1 -1
  22. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/editor.esm.t +3 -7
  23. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +20 -0
  24. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts.map +1 -0
  25. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +15 -0
  26. package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/story.esm.t +1 -1
  27. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.d.ts +14 -0
  28. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.d.ts.map +1 -0
  29. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.js +10 -0
  30. package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/utils.esm.t +1 -1
  31. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.d.ts +20 -0
  32. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.d.ts.map +1 -0
  33. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t +1 -1
  34. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.js +15 -0
  35. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/index.d.ts +20 -0
  36. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/index.d.ts.map +1 -0
  37. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/index.esm.t +1 -1
  38. package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/index.js +15 -0
  39. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.d.ts +16 -0
  40. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.d.ts.map +1 -0
  41. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.js +11 -0
  42. package/dist/src/create-lib/create-project.d.ts.map +1 -1
  43. package/dist/src/create-lib/create-project.js +6 -2
  44. package/dist/tsconfig.hygen.tsbuildinfo +1 -1
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +6 -7
@@ -4,4 +4,4 @@ force: true
4
4
  ---
5
5
  import type { DocumentModelState } from "document-model";
6
6
 
7
- export const documentModelState: DocumentModelState = <%- documentModel %>;
7
+ export const documentModel: DocumentModelState = <%- documentModel %>;
@@ -0,0 +1,25 @@
1
+ export type Args = {
2
+ documentModel: string;
3
+ rootDir: string;
4
+ };
5
+ declare const _default: {
6
+ params: ({ args, }: {
7
+ args: Args;
8
+ }) => {
9
+ rootDir: string;
10
+ documentModel: string;
11
+ documentTypeId: string;
12
+ documentType: string;
13
+ extension: string;
14
+ modules: Array<{
15
+ name: string;
16
+ [key: string]: any;
17
+ }>;
18
+ fileExtension: string;
19
+ hasLocalSchema: boolean;
20
+ initialGlobalState: string;
21
+ initialLocalState: string;
22
+ };
23
+ };
24
+ export default _default;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model/index.ts"],"names":[],"mappings":"AA4BA,MAAM,MAAM,IAAI,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;;wBAKG;QACD,IAAI,EAAE,IAAI,CAAC;KACZ,KAAG;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC,CAAC;QACrD,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,OAAO,CAAC;QACxB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,iBAAiB,EAAE,MAAM,CAAC;KAC3B;;AAhBH,wBAoCE"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const change_case_1 = require("change-case");
4
+ function documentModelToString(documentModel) {
5
+ return JSON.stringify({
6
+ ...documentModel,
7
+ specifications: documentModel.specifications.map((s) => ({
8
+ ...s,
9
+ state: Object.keys(s.state).reduce((values, scope) => {
10
+ const state = s.state[scope];
11
+ return {
12
+ ...values,
13
+ [scope]: {
14
+ ...state,
15
+ // initial value has to be stringified twice
16
+ // as it is expected to be a string
17
+ initialValue: JSON.stringify(state.initialValue),
18
+ },
19
+ };
20
+ }, {}),
21
+ })),
22
+ }, null, 2);
23
+ }
24
+ exports.default = {
25
+ params: ({ args, }) => {
26
+ const documentModel = JSON.parse(args.documentModel);
27
+ const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
28
+ return {
29
+ rootDir: args.rootDir,
30
+ documentModel: documentModelToString(documentModel),
31
+ documentTypeId: documentModel.id,
32
+ documentType: documentModel.name,
33
+ extension: documentModel.extension,
34
+ modules: latestSpec.modules.map((m) => ({
35
+ ...m,
36
+ name: (0, change_case_1.paramCase)(m.name),
37
+ })),
38
+ fileExtension: documentModel.extension,
39
+ hasLocalSchema: latestSpec.state.local.schema !== "",
40
+ ...getInitialStates(latestSpec.state),
41
+ };
42
+ },
43
+ };
44
+ function getInitialStates(scopeState) {
45
+ const { global, local } = scopeState;
46
+ const scopes = { global, local };
47
+ Object.entries(scopes).forEach(([scope, state]) => {
48
+ if (!isEmptyStateSchema(state.schema) && state.initialValue === "") {
49
+ throw new Error(`${scope.charAt(0).toLocaleUpperCase() + scope.slice(1)} scope has a defined schema but is missing an initial value.`);
50
+ }
51
+ });
52
+ return {
53
+ initialGlobalState: handleEmptyState(global.initialValue),
54
+ initialLocalState: handleEmptyState(local.initialValue),
55
+ };
56
+ }
57
+ function isEmptyStateSchema(schema) {
58
+ return schema === "" || !schema.includes("{");
59
+ }
60
+ function handleEmptyState(state) {
61
+ return state === "" ? "{}" : state;
62
+ }
@@ -2,7 +2,7 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/object.ts"
3
3
  force: true
4
4
  ---
5
- import { BaseDocument, ExtendedState, PartialState, applyMixins, SignalDispatch } from 'document-model/document';
5
+ import { BaseDocumentClass, ExtendedState, PartialState, applyMixins, SignalDispatch } from 'document-model';
6
6
  import { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState } from './types';
7
7
  import { <%= h.changeCase.pascal(documentType) %>Action } from './actions';
8
8
  import { reducer } from './reducer';
@@ -20,7 +20,7 @@ interface <%= h.changeCase.pascal(documentType) %> extends
20
20
  <%= modules.map(m => ' ' + h.changeCase.pascal(documentType) + '_' + h.changeCase.pascal(m.name)).join(',\n') %> {}
21
21
 
22
22
  // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
23
- class <%= h.changeCase.pascal(documentType) %> extends BaseDocument<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>Action, <%= h.changeCase.pascal(documentType) %>LocalState> {
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
26
  constructor(initialState?: Partial<ExtendedState<PartialState<<%= h.changeCase.pascal(documentType) %>State>, PartialState<<%= h.changeCase.pascal(documentType) %>LocalState>>>, dispatch?: SignalDispatch) {
@@ -2,17 +2,16 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/reducer.ts"
3
3
  force: true
4
4
  ---
5
- import { ImmutableStateReducer, utils } from "document-model/document";
6
- import { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, z } from './types';
7
- import { <%= h.changeCase.pascal(documentType) %>Action } from './actions';
5
+ import { StateReducer, isDocumentAction, createReducer } from "document-model";
6
+ import { <%= h.changeCase.pascal(documentType) %>Document, z } from './types';
8
7
 
9
8
  <% modules.forEach(m => { _%>
10
9
  import { reducer as <%= h.changeCase.pascal(m.name) %>Reducer } from '../src/reducers/<%= h.changeCase.param(m.name) %>';
11
10
  <%_ }); %>
12
11
 
13
- const stateReducer: ImmutableStateReducer<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>Action, <%= h.changeCase.pascal(documentType) %>LocalState> =
12
+ const stateReducer: StateReducer<<%= h.changeCase.pascal(documentType) %>Document> =
14
13
  (state, action, dispatch) => {
15
- if (utils.isBaseAction(action)) {
14
+ if (isDocumentAction(action)) {
16
15
  return state;
17
16
  }
18
17
 
@@ -32,4 +31,4 @@ const stateReducer: ImmutableStateReducer<<%= h.changeCase.pascal(documentType)
32
31
  }
33
32
  }
34
33
 
35
- export const reducer = utils.createReducer<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>Action, <%= h.changeCase.pascal(documentType) %>LocalState>(stateReducer);
34
+ export const reducer = createReducer<<%= h.changeCase.pascal(documentType) %>Document>(stateReducer);
@@ -7,35 +7,29 @@ force: true
7
7
  * Delete the file and run the code generator again to have it reset
8
8
  */
9
9
 
10
- import { actions as BaseActions, DocumentModel } from 'document-model/document';
11
- import { actions as <%= h.changeCase.pascal(documentType) %>Actions, <%= h.changeCase.pascal(documentType) %> } from './gen';
10
+ import { actions as BaseActions, DocumentModelModule } from 'document-model';
11
+ import { actions as <%= h.changeCase.pascal(documentType) %>Actions } from './gen';
12
12
  import { reducer } from './gen/reducer';
13
13
  import { documentModel } from './gen/document-model';
14
14
  import genUtils from './gen/utils';
15
15
  import * as customUtils from './src/utils';
16
16
  import {
17
- <%= h.changeCase.pascal(documentType) %>State,
18
- <%= h.changeCase.pascal(documentType) %>Action,
19
- <%= h.changeCase.pascal(documentType) %>LocalState,
17
+ <%= h.changeCase.pascal(documentType) %>Document,
20
18
  } from './gen/types';
21
19
 
22
- const Document = <%= h.changeCase.pascal(documentType) %>;
23
20
  const utils = { ...genUtils, ...customUtils };
24
21
  const actions = { ...BaseActions, ...<%= h.changeCase.pascal(documentType) %>Actions };
25
22
 
26
- export const module: DocumentModel<
27
- <%= h.changeCase.pascal(documentType) %>State,
28
- <%= h.changeCase.pascal(documentType) %>Action,
29
- <%= h.changeCase.pascal(documentType) %>LocalState
23
+ export const module: DocumentModelModule<
24
+ <%= h.changeCase.pascal(documentType) %>Document
30
25
  > = {
31
- Document,
32
26
  reducer,
33
27
  actions,
34
28
  utils,
35
29
  documentModel,
36
30
  };
37
31
 
38
- export { <%= h.changeCase.pascal(documentType) %>, Document, reducer, actions, utils, documentModel };
32
+ export { reducer, actions, utils, documentModel };
39
33
 
40
34
  export * from './gen/types';
41
35
  export * from './src/utils';
@@ -2,7 +2,7 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/types.ts"
3
3
  force: true
4
4
  ---
5
- import type { Document, ExtendedState } from 'document-model/document';
5
+ import type { PHDocument, ExtendedState } from 'document-model';
6
6
  import type { <%= h.changeCase.pascal(documentType) %>State } from './schema/types';
7
7
  <% if(hasLocalSchema) { -%>
8
8
  import type { <%= h.changeCase.pascal(documentType) %>LocalState } from './schema/types';
@@ -15,5 +15,5 @@ export type * from './schema/types';
15
15
  type <%= h.changeCase.pascal(documentType) %>LocalState = Record<PropertyKey, never>;
16
16
  <%} -%>
17
17
  export type Extended<%= h.changeCase.pascal(documentType) %>State = ExtendedState<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState>;
18
- export type <%= h.changeCase.pascal(documentType) %>Document = Document<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>Action, <%= h.changeCase.pascal(documentType) %>LocalState>;
18
+ export type <%= h.changeCase.pascal(documentType) %>Document = PHDocument<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, <%= h.changeCase.pascal(documentType) %>Action>;
19
19
  export { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, <%= h.changeCase.pascal(documentType) %>Action };
@@ -2,41 +2,48 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/utils.ts"
3
3
  force: true
4
4
  ---
5
- import { DocumentModelUtils, utils as base } from 'document-model/document';
6
- import { <%= h.changeCase.pascal(documentType) %>Action, <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState } from './types';
5
+ import { DocumentModelUtils,
6
+ baseCreateDocument,
7
+ baseCreateExtendedState,
8
+ baseSaveToFile,
9
+ baseSaveToFileHandle,
10
+ baseLoadFromFile,
11
+ baseLoadFromInput
12
+ } from 'document-model';
13
+ import { <%= h.changeCase.pascal(documentType) %>Document, <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState} from './types';
7
14
  import { reducer } from './reducer';
8
15
 
9
16
  export const initialGlobalState: <%= h.changeCase.pascal(documentType) %>State = <%- initialGlobalState %>;
10
17
  export const initialLocalState: <%= h.changeCase.pascal(documentType) %>LocalState = <%- initialLocalState %>;
11
18
 
12
- const utils: DocumentModelUtils<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>Action, <%= h.changeCase.pascal(documentType) %>LocalState> = {
19
+ const utils: DocumentModelUtils<<%= h.changeCase.pascal(documentType) %>Document> = {
13
20
  fileExtension: '<%- fileExtension %>',
14
21
  createState(state) {
15
22
  return { global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
16
23
  },
17
24
  createExtendedState(extendedState) {
18
- return base.createExtendedState(
25
+ return baseCreateExtendedState(
19
26
  { ...extendedState, documentType: '<%- documentTypeId %>' },
20
27
  utils.createState
21
28
  );
22
29
  },
23
30
  createDocument(state) {
24
- return base.createDocument(
31
+ return baseCreateDocument(
25
32
  utils.createExtendedState(state),
26
33
  utils.createState
27
34
  );
28
35
  },
29
36
  saveToFile(document, path, name) {
30
- return base.saveToFile(document, path, '<%- fileExtension %>', name);
37
+ return baseSaveToFile(document, path, '<%- fileExtension %>', name);
31
38
  },
32
39
  saveToFileHandle(document, input) {
33
- return base.saveToFileHandle(document, input);
40
+ return baseSaveToFileHandle(document, input);
34
41
  },
35
42
  loadFromFile(path) {
36
- return base.loadFromFile(path, reducer);
43
+ return baseLoadFromFile(path, reducer);
37
44
  },
38
45
  loadFromInput(input) {
39
- return base.loadFromInput(input, reducer);
46
+ return baseLoadFromInput(input, reducer);
40
47
  },
41
48
  };
42
49
 
@@ -2,7 +2,7 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/actions.ts"
3
3
  force: true
4
4
  ---
5
- import { Action<% if (actions.find(a => a.hasAttachment)) {%>, ActionWithAttachment<%}%> } from 'document-model/document';
5
+ import { BaseAction<% if (actions.find(a => a.hasAttachment)) {%>, BaseActionWithAttachment<%}%> } from 'document-model';
6
6
  import {
7
7
  <% actions.filter(a => a.hasInput).forEach(action => { _%>
8
8
  <%= h.changeCase.pascal(action.name) %>Input,
@@ -10,10 +10,10 @@ import {
10
10
  } from '../types';
11
11
 
12
12
  <% actions.filter(a => a.hasInput).forEach(actionType => { _%>
13
- export type <%= h.changeCase.pascal(actionType.name) %>Action = Action<%if(actionType.hasAttachment){ %>WithAttachment<% } %><'<%= h.changeCase.constantCase(actionType.name) %>', <%= h.changeCase.pascal(actionType.name) %>Input, '<%= actionType.scope %>'>;
13
+ export type <%= h.changeCase.pascal(actionType.name) %>Action = BaseAction<%if(actionType.hasAttachment){ %>WithAttachment<% } %><'<%= h.changeCase.constantCase(actionType.name) %>', <%= h.changeCase.pascal(actionType.name) %>Input, '<%= actionType.scope %>'>;
14
14
  <% }); _%>
15
15
  <% actions.filter(a => !a.hasInput).forEach(actionType => { _%>
16
- export type <%= h.changeCase.pascal(actionType.name) %>Action = Action<'<%= h.changeCase.constantCase(actionType.name) %>', never, '<%= actionType.scope %>'>;
16
+ export type <%= h.changeCase.pascal(actionType.name) %>Action = BaseAction<'<%= h.changeCase.constantCase(actionType.name) %>', never, '<%= actionType.scope %>'>;
17
17
  <% }); _%>
18
18
 
19
19
  export type <%= h.changeCase.pascal(documentType) %><%= h.changeCase.pascal(module) %>Action =
@@ -2,7 +2,7 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/creators.ts"
3
3
  force: true
4
4
  ---
5
- import { utils<% if (actions.find(a => a.hasAttachment)) {%>, AttachmentInput<%}%> } from 'document-model/document';
5
+ import { createAction<% if (actions.find(a => a.hasAttachment)) {%>, AttachmentInput<%}%> } from 'document-model';
6
6
  import { z,
7
7
  <% actions.filter(a => a.hasInput).forEach(action => { _%>
8
8
  <%= h.changeCase.pascal(action.name) %>Input,
@@ -14,8 +14,6 @@ import {
14
14
  <% }); _%>
15
15
  } from './actions';
16
16
 
17
- const { createAction } = utils;
18
-
19
17
  <% actions.filter(a => a.hasInput).forEach(action => { _%>
20
18
  export const <%= h.changeCase.camel(action.name) %> = (input: <%= h.changeCase.pascal(action.name) %>Input<%if(action.hasAttachment){ %>, attachments: AttachmentInput[] <% } %>) =>
21
19
  createAction<<%= h.changeCase.pascal(action.name) %>Action>(
@@ -8,7 +8,7 @@ unless_exists: true
8
8
  */
9
9
 
10
10
  import { generateMock } from '@powerhousedao/codegen';
11
- import { utils as documentModelUtils } from 'document-model/document';
11
+ import { utils as documentModelUtils } from 'document-model';
12
12
 
13
13
  import utils from '../../gen/utils';
14
14
  import {
@@ -0,0 +1,24 @@
1
+ import { OperationScope } from "document-model";
2
+ import { Args } from "../generate-document-model/index.js";
3
+ type ModuleArgs = Args & {
4
+ module: string;
5
+ };
6
+ type Actions = {
7
+ name: string | null;
8
+ hasInput: boolean;
9
+ hasAttachment: boolean | undefined;
10
+ scope: OperationScope;
11
+ state: string;
12
+ };
13
+ declare const _default: {
14
+ params: ({ args }: {
15
+ args: ModuleArgs;
16
+ }) => {
17
+ rootDir: string;
18
+ documentType: string;
19
+ module: string;
20
+ actions: Actions[];
21
+ };
22
+ };
23
+ export default _default;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,KAAK,UAAU,GAAG,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5C,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,cAAc,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;;uBAGmB;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE;;;;;;;AADzC,wBA6BE"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const change_case_1 = require("change-case");
4
+ exports.default = {
5
+ params: ({ args }) => {
6
+ const documentModel = JSON.parse(args.documentModel);
7
+ const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
8
+ const filteredModules = latestSpec.modules.filter((m) => m.name === args.module);
9
+ const actions = filteredModules.length > 0
10
+ ? filteredModules[0].operations.map((a) => ({
11
+ name: a.name,
12
+ hasInput: a.schema !== null,
13
+ hasAttachment: a.schema?.includes(": Attachment"),
14
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
15
+ scope: a.scope || "global",
16
+ state: a.scope === "global" ? "" : a.scope, // the state this action affects
17
+ errors: a.errors,
18
+ }))
19
+ : [];
20
+ return {
21
+ rootDir: args.rootDir,
22
+ documentType: documentModel.name,
23
+ module: (0, change_case_1.paramCase)(args.module),
24
+ actions,
25
+ };
26
+ },
27
+ };
@@ -2,7 +2,7 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/object.ts"
3
3
  force: true
4
4
  ---
5
- import { BaseDocument<% if (actions.find(a => a.hasAttachment)) {%>, AttachmentInput<%}%> } from 'document-model/document';
5
+ import { BaseDocumentClass<% if (actions.find(a => a.hasAttachment)) {%>, AttachmentInput<%}%> } from 'document-model';
6
6
  import {
7
7
  <% actions.filter(action => action.hasInput).forEach(action => { _%>
8
8
  <%= h.changeCase.pascal(action.name) %>Input,
@@ -17,10 +17,10 @@ import {
17
17
  } from './creators';
18
18
  import { <%= h.changeCase.pascal(documentType) %>Action } from '../actions';
19
19
 
20
- export default class <%= h.changeCase.pascal(documentType) %>_<%= h.changeCase.pascal(module) %> extends BaseDocument<
20
+ export default class <%= h.changeCase.pascal(documentType) %>_<%= h.changeCase.pascal(module) %> extends BaseDocumentClass<
21
21
  <%= h.changeCase.pascal(documentType) %>State,
22
- <%= h.changeCase.pascal(documentType) %>Action,
23
- <%= h.changeCase.pascal(documentType) %>LocalState
22
+ <%= h.changeCase.pascal(documentType) %>LocalState,
23
+ <%= h.changeCase.pascal(documentType) %>Action
24
24
  > {
25
25
  <% actions.filter(action => action.hasInput).forEach(action => { _%>
26
26
  public <%= h.changeCase.camel(action.name) %>(input: <%= h.changeCase.pascal(action.name) %>Input<%if(action.hasAttachment){ %>, attachments: AttachmentInput[] <% } %>) {
@@ -2,7 +2,7 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/operations.ts"
3
3
  force: true
4
4
  ---
5
- import { SignalDispatch } from 'document-model/document';
5
+ import { SignalDispatch } from 'document-model';
6
6
  import {
7
7
  <% actions.forEach(action => { _%>
8
8
  <%= h.changeCase.pascal(action.name) %>Action,
@@ -0,0 +1,22 @@
1
+ export type Args = {
2
+ documentModel: string;
3
+ rootDir: string;
4
+ subgraph: string;
5
+ };
6
+ declare const generateDocumentModelMutations: {
7
+ params: ({ args, }: {
8
+ args: Args;
9
+ }) => {
10
+ rootDir: string;
11
+ subgraph: string;
12
+ documentTypeId: string;
13
+ documentType: string;
14
+ schema: any;
15
+ modules: Array<{
16
+ name: string;
17
+ [key: string]: any;
18
+ }>;
19
+ };
20
+ };
21
+ export default generateDocumentModelMutations;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-mutations/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,IAAI,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,8BAA8B;wBAG/B;QACD,IAAI,EAAE,IAAI,CAAC;KACZ,KAAG;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,GAAG,CAAC;QACZ,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC,CAAC;KACtD;CAiBF,CAAC;AACF,eAAe,8BAA8B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const change_case_1 = require("change-case");
4
+ const generateDocumentModelMutations = {
5
+ params: ({ args, }) => {
6
+ const documentModel = JSON.parse(args.documentModel);
7
+ const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
8
+ return {
9
+ rootDir: args.rootDir,
10
+ subgraph: args.subgraph,
11
+ documentTypeId: documentModel.id,
12
+ documentType: documentModel.name,
13
+ schema: latestSpec.state.global.schema,
14
+ modules: latestSpec.modules.map((m) => ({
15
+ ...m,
16
+ name: (0, change_case_1.paramCase)(m.name),
17
+ })),
18
+ };
19
+ },
20
+ };
21
+ exports.default = generateDocumentModelMutations;
@@ -8,7 +8,7 @@ force: true
8
8
  import { Subgraph } from "@powerhousedao/reactor-api";
9
9
  import { actions } from "../../document-models/<%- h.changeCase.param(documentType) %>";
10
10
  import { actions as driveActions } from "document-model-libs/document-drive";
11
- import { utils as docUtils } from "document-model/document";
11
+ import { utils as docUtils } from "document-model";
12
12
 
13
13
  export const getResolvers = (subgraph: Subgraph, driveId: string) => {
14
14
  const reactor = subgraph.reactor;
@@ -2,19 +2,15 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/editor.tsx"
3
3
  unless_exists: true
4
4
  ---
5
- <% if(!documentTypes.length){ %>import { Action, EditorProps } from 'document-model/document';<% } else { %>import { EditorProps } from 'document-model/document';<% } %>
5
+ <% if(!documentTypes.length){ %>import { Action, EditorProps } from 'document-model';<% } else { %>import { EditorProps } from 'document-model';<% } %>
6
6
  <% documentTypes.forEach(type => { _%>
7
- import { <%= documentTypesMap[type].name %>State, <%= documentTypesMap[type].name %>Action, <%= documentTypesMap[type].name %>LocalState, actions } from "<%= documentTypesMap[type].importPath %>";
7
+ import { <%= documentTypesMap[type].name %>Document, actions } from "<%= documentTypesMap[type].importPath %>";
8
8
  %><% }); _%>
9
- import { utils as documentModelUtils } from 'document-model/document';
10
9
  import { Button } from '@powerhousedao/design-system';
11
10
 
12
- export type IProps = <% if(!documentTypes.length){ %>EditorProps<unknown, Action><% } else { %><% documentTypes.forEach((type, index) => { _%>EditorProps<<%= documentTypesMap[type].name %>State, <%= documentTypesMap[type].name %>Action, <%= documentTypesMap[type].name %>LocalState%>%>><% if(index < documentTypes.length - 1){ %> | <% }%><% }); _%> <% } %>;
11
+ export type IProps = <% if(!documentTypes.length){ %>EditorProps<unknown, Action><% } else { %><% documentTypes.forEach((type, index) => { _%>EditorProps<<%= documentTypesMap[type].name %>Document%>%>><% if(index < documentTypes.length - 1){ %> | <% }%><% }); _%> <% } %>;
13
12
 
14
13
  export default function Editor(props: IProps) {
15
- // generate a random id
16
- // const id = documentModelUtils.hashKey();
17
-
18
14
  return (
19
15
  <div>
20
16
  <Button onClick={() => console.log('Hello world!')}>My Button</Button>
@@ -0,0 +1,20 @@
1
+ export type Args = {
2
+ name: string;
3
+ rootDir: string;
4
+ documentModelsDir: string;
5
+ documentTypes: string;
6
+ documentTypesMap: string;
7
+ };
8
+ declare const _default: {
9
+ params: ({ args }: {
10
+ args: Args;
11
+ }) => {
12
+ rootDir: string;
13
+ documentModelsDir: string;
14
+ name: string;
15
+ documentTypes: string[];
16
+ documentTypesMap: JSON;
17
+ };
18
+ };
19
+ export default _default;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-editor/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;;uBAGmB;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;;;;;0BAQ0B,IAAI;;;AATjE,wBAYE"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ params: ({ args }) => {
5
+ return {
6
+ rootDir: args.rootDir,
7
+ documentModelsDir: args.documentModelsDir,
8
+ name: args.name,
9
+ documentTypes: args.documentTypes
10
+ .split(",")
11
+ .filter((type) => type !== ""),
12
+ documentTypesMap: JSON.parse(args.documentTypesMap),
13
+ };
14
+ },
15
+ };
@@ -4,7 +4,7 @@ unless_exists: true
4
4
  ---
5
5
  import Editor from './editor';
6
6
  import { createDocumentStory } from 'document-model-libs/utils';
7
- <% if(!documentTypes.length){ %>import { baseReducer, utils } from 'document-model/document';<% } %>
7
+ <% if(!documentTypes.length){ %>import { baseReducer, utils } from 'document-model';<% } %>
8
8
  <% documentTypes.forEach(type => { _%>
9
9
  import * as <%= documentTypesMap[type].name %>Module from "<%= documentTypesMap[type].importPath %>";
10
10
  %><% }); _%>
@@ -0,0 +1,14 @@
1
+ export type Args = {
2
+ name: string;
3
+ rootDir: string;
4
+ };
5
+ declare const _default: {
6
+ params: ({ args }: {
7
+ args: Args;
8
+ }) => {
9
+ rootDir: string;
10
+ name: string;
11
+ };
12
+ };
13
+ export default _default;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-import-script/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;;uBAGmB;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;;;;;AADnC,wBAOE"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ params: ({ args }) => {
5
+ return {
6
+ rootDir: args.rootDir,
7
+ name: args.name,
8
+ };
9
+ },
10
+ };
@@ -9,7 +9,7 @@ import {
9
9
  generateSynchronizationUnits
10
10
  } from "document-model-libs/document-drive";
11
11
  import * as DocumentModelsLibs from "document-model-libs/document-models";
12
- import { DocumentModel } from "document-model/document";
12
+ import { DocumentModel } from "document-model";
13
13
  import { module as DocumentModelLib } from "document-model";
14
14
  import * as LocalDocumentModels from "../../document-models";
15
15
 
@@ -0,0 +1,20 @@
1
+ export type Args = {
2
+ name: string;
3
+ rootDir: string;
4
+ documentModelsDir: string;
5
+ documentTypes: string;
6
+ documentTypesMap: string;
7
+ };
8
+ declare const _default: {
9
+ params: ({ args }: {
10
+ args: Args;
11
+ }) => {
12
+ rootDir: string;
13
+ documentModelsDir: string;
14
+ name: string;
15
+ documentTypes: string[];
16
+ documentTypesMap: JSON;
17
+ };
18
+ };
19
+ export default _default;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;;uBAGmB;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;;;;;0BAQ0B,IAAI;;;AATjE,wBAYE"}
@@ -12,7 +12,7 @@ import {
12
12
  <% documentTypes.forEach(type => { _%>
13
13
  import { <%= documentTypesMap[type].name %>Document } from "<%= documentTypesMap[type].importPath %>";
14
14
  %><% }); _%>
15
- <% if(documentTypes.length === 0) { %>import { Document } from "document-model/document";<% } %>
15
+ <% if(documentTypes.length === 0) { %>import { Document } from "document-model";<% } %>
16
16
  type DocumentType = <% if(documentTypes.length) { %><%= documentTypes.map(type => `${documentTypesMap[type].name}Document`).join(" | ") %> <% } else { %>Document<% } %>;
17
17
 
18
18
  export class <%= pascalName %>Processor extends AnalyticsProcessor<% if(documentTypes.length) { %><DocumentType><% } %> {