@powerhousedao/codegen 0.14.1 → 0.16.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.
@@ -0,0 +1,40 @@
1
+ ---
2
+ to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/error.ts"
3
+ force: true
4
+ ---
5
+ <% if (actions.some(action => action.errors?.length > 0)) { _%>
6
+ export type ErrorCode =
7
+ <% actions.forEach((action, actionIndex) => { _%>
8
+ <% action.errors.forEach((error, errorIndex) => { _%>
9
+ | '<%= h.changeCase.pascal(error.name) %>'<% if (actionIndex === actions.length - 1 && errorIndex === action.errors.length - 1) { %>;<% } %>
10
+ <% }); _%>
11
+ <% }); _%>
12
+
13
+ export interface ReducerError {
14
+ errorCode: ErrorCode;
15
+ }
16
+
17
+ <% actions.forEach(action => { _%>
18
+ <% action.errors.forEach(error => { _%>
19
+ export class <%= h.changeCase.pascal(error.name) %> extends Error implements ReducerError {
20
+ errorCode = '<%= h.changeCase.pascal(error.name) %>' as ErrorCode;
21
+ constructor(message = '<%= h.changeCase.pascal(error.name) %>') {
22
+ super(message);
23
+ }
24
+ }
25
+
26
+ <% }); _%>
27
+ <% }); _%>
28
+
29
+ <% } _%>
30
+ export const errors = {
31
+ <% actions.forEach(action => { _%>
32
+ <% if(action.errors?.length > 0){ -%>
33
+ <%= h.changeCase.pascal(action.name) %>: {
34
+ <% action.errors.forEach(error => { _%>
35
+ <%= h.changeCase.pascal(error.name) %>,
36
+ <% }); _%>
37
+ },
38
+ <% } -%>
39
+ <% }); _%>
40
+ };
@@ -15,8 +15,9 @@ var generate_document_model_module_default = {
15
15
  hasAttachment: a.schema?.includes(": Attachment"),
16
16
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
17
17
  scope: a.scope || "global",
18
- state: a.scope === "global" ? "" : a.scope
18
+ state: a.scope === "global" ? "" : a.scope,
19
19
  // the state this action affects
20
+ errors: a.errors
20
21
  })) : [];
21
22
  return {
22
23
  rootDir: args.rootDir,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":["paramCase"],"mappings":";;;;AAcA,IAAO,sCAAQ,GAAA;AAAA,EACb,MAAQ,EAAA,CAAC,EAAE,IAAA,EAAiC,KAAA;AAC1C,IAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,KAAM,CAAA,IAAA,CAAK,aAAa,CAAA;AACnD,IAAA,MAAM,aACJ,aAAc,CAAA,cAAA,CAAe,aAAc,CAAA,cAAA,CAAe,SAAS,CAAC,CAAA;AACtE,IAAM,MAAA,eAAA,GAAkB,WAAW,OAAQ,CAAA,MAAA;AAAA,MACzC,CAAC,CAAA,KAAM,CAAE,CAAA,IAAA,KAAS,IAAK,CAAA;AAAA,KACzB;AAEA,IAAM,MAAA,OAAA,GACJ,eAAgB,CAAA,MAAA,GAAS,CACrB,GAAA,eAAA,CAAgB,CAAC,CAAE,CAAA,UAAA,CAAW,GAAI,CAAA,CAAC,CAAO,MAAA;AAAA,MACxC,MAAM,CAAE,CAAA,IAAA;AAAA,MACR,QAAA,EAAU,EAAE,MAAW,KAAA,IAAA;AAAA,MACvB,aAAe,EAAA,CAAA,CAAE,MAAQ,EAAA,QAAA,CAAS,cAAc,CAAA;AAAA;AAAA,MAEhD,KAAA,EAAO,EAAE,KAAS,IAAA,QAAA;AAAA,MAClB,KAAO,EAAA,CAAA,CAAE,KAAU,KAAA,QAAA,GAAW,KAAK,CAAE,CAAA;AAAA;AAAA,KACvC,CAAE,IACF,EAAC;AAEP,IAAO,OAAA;AAAA,MACL,SAAS,IAAK,CAAA,OAAA;AAAA,MACd,cAAc,aAAc,CAAA,IAAA;AAAA,MAC5B,MAAA,EAAQA,oBAAU,CAAA,IAAA,CAAK,MAAM,CAAA;AAAA,MAC7B;AAAA,KACF;AAAA;AAEJ","file":"index.js","sourcesContent":["import { DocumentModelState } from \"document-model/document-model\";\nimport { paramCase } from \"change-case\";\nimport { Maybe, OperationScope } from \"document-model/document\";\nimport { Args } from \"../generate-document-model\";\n\ntype ModuleArgs = Args & { module: string };\ntype Actions = {\n name: Maybe<string>;\n hasInput: boolean;\n hasAttachment: boolean | undefined;\n scope: OperationScope;\n state: string;\n};\n\nexport default {\n params: ({ args }: { args: ModuleArgs }) => {\n const documentModel = JSON.parse(args.documentModel) as DocumentModelState;\n const latestSpec =\n documentModel.specifications[documentModel.specifications.length - 1];\n const filteredModules = latestSpec.modules.filter(\n (m) => m.name === args.module,\n );\n\n const actions: Actions[] =\n filteredModules.length > 0\n ? filteredModules[0].operations.map((a) => ({\n name: a.name,\n hasInput: a.schema !== null,\n hasAttachment: a.schema?.includes(\": Attachment\"),\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n scope: a.scope || \"global\",\n state: a.scope === \"global\" ? \"\" : a.scope, // the state this action affects\n }))\n : [];\n\n return {\n rootDir: args.rootDir,\n documentType: documentModel.name,\n module: paramCase(args.module),\n actions,\n };\n },\n};\n"]}
1
+ {"version":3,"sources":["../../../../../../src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts"],"names":["paramCase"],"mappings":";;;;AAcA,IAAO,sCAAQ,GAAA;AAAA,EACb,MAAQ,EAAA,CAAC,EAAE,IAAA,EAAiC,KAAA;AAC1C,IAAA,MAAM,aAAgB,GAAA,IAAA,CAAK,KAAM,CAAA,IAAA,CAAK,aAAa,CAAA;AACnD,IAAA,MAAM,aACJ,aAAc,CAAA,cAAA,CAAe,aAAc,CAAA,cAAA,CAAe,SAAS,CAAC,CAAA;AACtE,IAAM,MAAA,eAAA,GAAkB,WAAW,OAAQ,CAAA,MAAA;AAAA,MACzC,CAAC,CAAA,KAAM,CAAE,CAAA,IAAA,KAAS,IAAK,CAAA;AAAA,KACzB;AAEA,IAAM,MAAA,OAAA,GACJ,eAAgB,CAAA,MAAA,GAAS,CACrB,GAAA,eAAA,CAAgB,CAAC,CAAE,CAAA,UAAA,CAAW,GAAI,CAAA,CAAC,CAAO,MAAA;AAAA,MACxC,MAAM,CAAE,CAAA,IAAA;AAAA,MACR,QAAA,EAAU,EAAE,MAAW,KAAA,IAAA;AAAA,MACvB,aAAe,EAAA,CAAA,CAAE,MAAQ,EAAA,QAAA,CAAS,cAAc,CAAA;AAAA;AAAA,MAEhD,KAAA,EAAO,EAAE,KAAS,IAAA,QAAA;AAAA,MAClB,KAAO,EAAA,CAAA,CAAE,KAAU,KAAA,QAAA,GAAW,KAAK,CAAE,CAAA,KAAA;AAAA;AAAA,MACrC,QAAQ,CAAE,CAAA;AAAA,KACZ,CAAE,IACF,EAAC;AAEP,IAAO,OAAA;AAAA,MACL,SAAS,IAAK,CAAA,OAAA;AAAA,MACd,cAAc,aAAc,CAAA,IAAA;AAAA,MAC5B,MAAA,EAAQA,oBAAU,CAAA,IAAA,CAAK,MAAM,CAAA;AAAA,MAC7B;AAAA,KACF;AAAA;AAEJ","file":"index.js","sourcesContent":["import { DocumentModelState } from \"document-model/document-model\";\nimport { paramCase } from \"change-case\";\nimport { Maybe, OperationScope } from \"document-model/document\";\nimport { Args } from \"../generate-document-model\";\n\ntype ModuleArgs = Args & { module: string };\ntype Actions = {\n name: Maybe<string>;\n hasInput: boolean;\n hasAttachment: boolean | undefined;\n scope: OperationScope;\n state: string;\n};\n\nexport default {\n params: ({ args }: { args: ModuleArgs }) => {\n const documentModel = JSON.parse(args.documentModel) as DocumentModelState;\n const latestSpec =\n documentModel.specifications[documentModel.specifications.length - 1];\n const filteredModules = latestSpec.modules.filter(\n (m) => m.name === args.module,\n );\n\n const actions: Actions[] =\n filteredModules.length > 0\n ? filteredModules[0].operations.map((a) => ({\n name: a.name,\n hasInput: a.schema !== null,\n hasAttachment: a.schema?.includes(\": Attachment\"),\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n scope: a.scope || \"global\",\n state: a.scope === \"global\" ? \"\" : a.scope, // the state this action affects\n errors: a.errors,\n }))\n : [];\n\n return {\n rootDir: args.rootDir,\n documentType: documentModel.name,\n module: paramCase(args.module),\n actions,\n };\n },\n};\n"]}
@@ -15,6 +15,7 @@ export const module: <% if(!documentTypes.length){ %>ExtendedEditor<unknown, Act
15
15
  id: 'editor-id',
16
16
  disableExternalControls: true,
17
17
  documentToolbarEnabled: true,
18
+ showSwitchboardLink: true,
18
19
  },
19
20
  };
20
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/codegen",
3
- "version": "0.14.1",
3
+ "version": "0.16.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "@types/node": "^20.11.2",
30
30
  "arg": "^5.0.2",
31
31
  "change-case": "^4.1.2",
32
- "document-model": "^2.6.0",
32
+ "document-model": "^2.7.1",
33
33
  "enquirer": "^2.4.1",
34
34
  "execa": "^8.0.1",
35
35
  "hygen": "^6.2.11"
@@ -41,8 +41,8 @@
41
41
  "graphql": "^16.8.1",
42
42
  "husky": "^8.0.3",
43
43
  "rimraf": "^5.0.5",
44
- "ts-node": "^10.9.2",
45
- "tsup": "^8.3.0"
44
+ "tsup": "^8.3.0",
45
+ "tsx": "^4.19.1"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@powerhousedao/scalars": "latest",
@@ -57,7 +57,7 @@
57
57
  "build": "tsup",
58
58
  "build:create-lib": "tsc --project src/create-lib/tsconfig.json",
59
59
  "publish:create-lib": "npm publish --cwd ./src/create-lib/",
60
- "start": "ts-node src/cli.ts",
60
+ "start": "tsx src/cli.ts",
61
61
  "clean:node_modules": "rimraf node_modules"
62
62
  }
63
63
  }