@powerhousedao/codegen 0.0.10 → 0.0.12

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.
@@ -2,4 +2,4 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/src/utils.ts"
3
3
  unless_exists: true
4
4
  ---
5
- export {};
5
+ export {};
@@ -3,7 +3,7 @@ to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/reducer.ts"
3
3
  force: true
4
4
  ---
5
5
  import { ImmutableStateReducer, utils } from "document-model/document";
6
- import { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, z } from './schema';
6
+ import { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, z } from './types';
7
7
  import { <%= h.changeCase.pascal(documentType) %>Action } from './actions';
8
8
 
9
9
  <% modules.forEach(m => { _%>
@@ -1,7 +1,15 @@
1
+ import { Maybe, OperationScope } from 'document-model/document';
1
2
  import { Args } from '../generate-document-model';
2
3
  type ModuleArgs = Args & {
3
4
  module: string;
4
5
  };
6
+ type Actions = {
7
+ name: Maybe<string>;
8
+ hasInput: boolean;
9
+ hasAttachment: boolean | undefined;
10
+ scope: OperationScope;
11
+ state: string;
12
+ };
5
13
  declare const _default: {
6
14
  params: ({ args }: {
7
15
  args: ModuleArgs;
@@ -9,13 +17,7 @@ declare const _default: {
9
17
  rootDir: string;
10
18
  documentType: string;
11
19
  module: string;
12
- actions: {
13
- name: import("document-model/document-model").Maybe<string>;
14
- hasInput: boolean;
15
- hasAttachment: boolean | undefined;
16
- scope: import("document-model/document").OperationScope;
17
- state: string;
18
- }[];
20
+ actions: Actions[];
19
21
  };
20
22
  };
21
23
  export default _default;
@@ -6,19 +6,20 @@ exports.default = {
6
6
  const documentModel = JSON.parse(args.documentModel);
7
7
  const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
8
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
+ scope: a.scope || 'global',
15
+ state: a.scope === 'global' ? '' : a.scope, // the state this action affects
16
+ }))
17
+ : [];
9
18
  return {
10
19
  rootDir: args.rootDir,
11
20
  documentType: documentModel.name,
12
21
  module: (0, change_case_1.paramCase)(args.module),
13
- actions: filteredModules.length > 0
14
- ? filteredModules[0].operations.map(a => ({
15
- name: a.name,
16
- hasInput: a.schema !== null,
17
- hasAttachment: a.schema?.includes(': Attachment'),
18
- scope: a.scope || 'global',
19
- state: a.scope === 'global' ? '' : a.scope, // the state this action affects
20
- }))
21
- : [],
22
+ actions,
22
23
  };
23
24
  },
24
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/codegen",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "@types/node": "^20.11.2",
34
34
  "arg": "^5.0.2",
35
35
  "change-case": "^4.1.2",
36
- "document-model": "^1.0.20",
36
+ "document-model": "^1.0.25",
37
37
  "enquirer": "^2.4.1",
38
38
  "execa": "^8.0.1",
39
39
  "hygen": "^6.2.11",