@powerhousedao/codegen 5.1.0 → 5.2.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-document-model-module/error.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +1 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/lib.esm.t +9 -0
- package/dist/src/codegen/__tests__/config.d.ts +1 -0
- package/dist/src/codegen/__tests__/config.d.ts.map +1 -1
- package/dist/src/codegen/__tests__/config.js +1 -0
- package/dist/src/codegen/__tests__/config.js.map +1 -1
- package/dist/src/codegen/__tests__/generate-doc-model.test.js +113 -88
- package/dist/src/codegen/__tests__/generate-doc-model.test.js.map +1 -1
- package/dist/src/codegen/__tests__/generate-drive-editor.test.js +6 -3
- package/dist/src/codegen/__tests__/generate-drive-editor.test.js.map +1 -1
- package/dist/src/codegen/__tests__/generate-editor.test.js +8 -7
- package/dist/src/codegen/__tests__/generate-editor.test.js.map +1 -1
- package/dist/src/codegen/__tests__/generate-manifest.test.js.map +1 -1
- package/dist/src/codegen/__tests__/generate-versioned-document-model.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/generate-versioned-document-model.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generate-versioned-document-model.test.js +142 -0
- package/dist/src/codegen/__tests__/generate-versioned-document-model.test.js.map +1 -0
- package/dist/src/codegen/generate.d.ts +42 -6
- package/dist/src/codegen/generate.d.ts.map +1 -1
- package/dist/src/codegen/generate.js +212 -95
- package/dist/src/codegen/generate.js.map +1 -1
- package/dist/src/codegen/graphql.d.ts +20 -17
- package/dist/src/codegen/graphql.d.ts.map +1 -1
- package/dist/src/codegen/graphql.js +105 -78
- package/dist/src/codegen/graphql.js.map +1 -1
- package/dist/src/codegen/hygen.d.ts +1 -8
- package/dist/src/codegen/hygen.d.ts.map +1 -1
- package/dist/src/codegen/hygen.js +11 -68
- package/dist/src/codegen/hygen.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ts-morph-utils/constants.d.ts +18 -0
- package/dist/src/ts-morph-utils/constants.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/constants.js +18 -0
- package/dist/src/ts-morph-utils/constants.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-editor.d.ts +28 -0
- package/dist/src/ts-morph-utils/file-builders/document-editor.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-editor.js +305 -0
- package/dist/src/ts-morph-utils/file-builders/document-editor.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.d.ts +3 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.js +216 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/gen-dir.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.d.ts +3 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.js +55 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/root-dir.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.d.ts +3 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.js +252 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/src-dir.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/types.d.ts +32 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/types.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/types.js +2 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/types.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/upgrades-dir.d.ts +31 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/upgrades-dir.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/upgrades-dir.js +136 -0
- package/dist/src/ts-morph-utils/file-builders/document-model/upgrades-dir.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model.d.ts +8 -0
- package/dist/src/ts-morph-utils/file-builders/document-model.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/document-model.js +250 -0
- package/dist/src/ts-morph-utils/file-builders/document-model.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/drive-editor.d.ts +56 -0
- package/dist/src/ts-morph-utils/file-builders/drive-editor.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/drive-editor.js +341 -0
- package/dist/src/ts-morph-utils/file-builders/drive-editor.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/editor-common.d.ts +3 -0
- package/dist/src/ts-morph-utils/file-builders/editor-common.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/editor-common.js +15 -0
- package/dist/src/ts-morph-utils/file-builders/editor-common.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/index-files.d.ts +18 -0
- package/dist/src/ts-morph-utils/file-builders/index-files.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/index-files.js +25 -0
- package/dist/src/ts-morph-utils/file-builders/index-files.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/module-files.d.ts +25 -0
- package/dist/src/ts-morph-utils/file-builders/module-files.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/module-files.js +104 -0
- package/dist/src/ts-morph-utils/file-builders/module-files.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/subgraphs.d.ts +6 -0
- package/dist/src/ts-morph-utils/file-builders/subgraphs.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/subgraphs.js +53 -0
- package/dist/src/ts-morph-utils/file-builders/subgraphs.js.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/types.d.ts +13 -0
- package/dist/src/ts-morph-utils/file-builders/types.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-builders/types.js +2 -0
- package/dist/src/ts-morph-utils/file-builders/types.js.map +1 -0
- package/dist/src/ts-morph-utils/file-utils.d.ts +28 -0
- package/dist/src/ts-morph-utils/file-utils.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/file-utils.js +102 -0
- package/dist/src/ts-morph-utils/file-utils.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/common-files.d.ts +5 -0
- package/dist/src/ts-morph-utils/name-builders/common-files.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/common-files.js +15 -0
- package/dist/src/ts-morph-utils/name-builders/common-files.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/document-model-files.d.ts +4 -0
- package/dist/src/ts-morph-utils/name-builders/document-model-files.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/document-model-files.js +12 -0
- package/dist/src/ts-morph-utils/name-builders/document-model-files.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/editor-files.d.ts +10 -0
- package/dist/src/ts-morph-utils/name-builders/editor-files.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/editor-files.js +37 -0
- package/dist/src/ts-morph-utils/name-builders/editor-files.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/get-file-paths.d.ts +4 -0
- package/dist/src/ts-morph-utils/name-builders/get-file-paths.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/get-file-paths.js +21 -0
- package/dist/src/ts-morph-utils/name-builders/get-file-paths.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/get-variable-names.d.ts +37 -0
- package/dist/src/ts-morph-utils/name-builders/get-variable-names.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/get-variable-names.js +145 -0
- package/dist/src/ts-morph-utils/name-builders/get-variable-names.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/types.d.ts +18 -0
- package/dist/src/ts-morph-utils/name-builders/types.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/types.js +2 -0
- package/dist/src/ts-morph-utils/name-builders/types.js.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/variables.d.ts +12 -0
- package/dist/src/ts-morph-utils/name-builders/variables.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/name-builders/variables.js +35 -0
- package/dist/src/ts-morph-utils/name-builders/variables.js.map +1 -0
- package/dist/src/ts-morph-utils/syntax-builders.d.ts +72 -0
- package/dist/src/ts-morph-utils/syntax-builders.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/syntax-builders.js +201 -0
- package/dist/src/ts-morph-utils/syntax-builders.js.map +1 -0
- package/dist/src/ts-morph-utils/syntax-getters.d.ts +11 -0
- package/dist/src/ts-morph-utils/syntax-getters.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/syntax-getters.js +45 -0
- package/dist/src/ts-morph-utils/syntax-getters.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/actions.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/actions.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/actions.js +28 -0
- package/dist/src/ts-morph-utils/templates/document-model/actions.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/actions.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/actions.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/actions.js +40 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/actions.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/creators.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/creators.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/creators.js +16 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/creators.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.js +56 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-schema.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.js +5 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/document-type.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/index.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/index.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/index.js +29 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/index.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.d.ts +8 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.js +39 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/actions.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.js +94 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/creators.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.js +73 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/error.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.js +61 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/modules/operations.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.js +93 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/ph-factories.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.js +106 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/reducer.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.d.ts +2 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.js +6 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/schema/index.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/types.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/types.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/types.js +38 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/types.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/utils.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/utils.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/utils.js +77 -0
- package/dist/src/ts-morph-utils/templates/document-model/gen/utils.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/hooks.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/hooks.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/hooks.js +49 -0
- package/dist/src/ts-morph-utils/templates/document-model/hooks.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/index.d.ts +2 -0
- package/dist/src/ts-morph-utils/templates/document-model/index.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/index.js +9 -0
- package/dist/src/ts-morph-utils/templates/document-model/index.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/module.d.ts +8 -0
- package/dist/src/ts-morph-utils/templates/document-model/module.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/module.js +25 -0
- package/dist/src/ts-morph-utils/templates/document-model/module.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/index.d.ts +2 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/index.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/index.js +5 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/index.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.js +121 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.d.ts +6 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.js +87 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/tests/module.test.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/utils.d.ts +2 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/utils.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/utils.js +5 -0
- package/dist/src/ts-morph-utils/templates/document-model/src/utils.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/upgrades/upgrade-transition.d.ts +7 -0
- package/dist/src/ts-morph-utils/templates/document-model/upgrades/upgrade-transition.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/upgrades/upgrade-transition.js +22 -0
- package/dist/src/ts-morph-utils/templates/document-model/upgrades/upgrade-transition.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/utils.d.ts +3 -0
- package/dist/src/ts-morph-utils/templates/document-model/utils.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/document-model/utils.js +11 -0
- package/dist/src/ts-morph-utils/templates/document-model/utils.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/drive-editor.d.ts +5 -0
- package/dist/src/ts-morph-utils/templates/drive-editor.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/drive-editor.js +211 -0
- package/dist/src/ts-morph-utils/templates/drive-editor.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/unsafe-utils.d.ts +8 -0
- package/dist/src/ts-morph-utils/templates/unsafe-utils.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/unsafe-utils.js +23 -0
- package/dist/src/ts-morph-utils/templates/unsafe-utils.js.map +1 -0
- package/dist/src/ts-morph-utils/templates/utils.d.ts +6 -0
- package/dist/src/ts-morph-utils/templates/utils.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/templates/utils.js +16 -0
- package/dist/src/ts-morph-utils/templates/utils.js.map +1 -0
- package/dist/src/ts-morph-utils/ts-morph-project.d.ts +3 -0
- package/dist/src/ts-morph-utils/ts-morph-project.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/ts-morph-project.js +9 -0
- package/dist/src/ts-morph-utils/ts-morph-project.js.map +1 -0
- package/dist/src/ts-morph-utils/types.d.ts +34 -0
- package/dist/src/ts-morph-utils/types.d.ts.map +1 -0
- package/dist/src/ts-morph-utils/types.js +2 -0
- package/dist/src/ts-morph-utils/types.js.map +1 -0
- package/dist/src/utils/mock.d.ts +2 -3
- package/dist/src/utils/mock.d.ts.map +1 -1
- package/dist/src/utils/mock.js +4 -4
- package/dist/src/utils/mock.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -14
- package/dist/src/codegen/__tests__/generate-schemas.test.d.ts +0 -2
- package/dist/src/codegen/__tests__/generate-schemas.test.d.ts.map +0 -1
- package/dist/src/codegen/__tests__/generate-schemas.test.js +0 -143
- package/dist/src/codegen/__tests__/generate-schemas.test.js.map +0 -1
- package/dist/src/ts-morph-utils.d.ts +0 -48
- package/dist/src/ts-morph-utils.d.ts.map +0 -1
- package/dist/src/ts-morph-utils.js +0 -207
- package/dist/src/ts-morph-utils.js.map +0 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
import { camelCase, pascalCase } from "change-case";
|
|
3
|
+
import { getActionTypeName } from "../../../utils.js";
|
|
4
|
+
function getActionTypeNames(actions) {
|
|
5
|
+
return actions.map(getActionTypeName);
|
|
6
|
+
}
|
|
7
|
+
function getActionTypeImports(actions) {
|
|
8
|
+
const actionTypeNames = getActionTypeNames(actions);
|
|
9
|
+
return actionTypeNames.join(",\n");
|
|
10
|
+
}
|
|
11
|
+
function getOperationsInterfaceName(pascalCaseDocumentType, module) {
|
|
12
|
+
const pascalCaseModuleName = pascalCase(module.name);
|
|
13
|
+
return `${pascalCaseDocumentType}${pascalCaseModuleName}Operations`;
|
|
14
|
+
}
|
|
15
|
+
function getActionOperationFieldName(action) {
|
|
16
|
+
const camelCaseActionName = camelCase(action.name);
|
|
17
|
+
return `${camelCaseActionName}Operation`;
|
|
18
|
+
}
|
|
19
|
+
function getActionOperationStateTypeName(action, pascalCaseDocumentType) {
|
|
20
|
+
if (!action.state)
|
|
21
|
+
return `${pascalCaseDocumentType}State`;
|
|
22
|
+
const pascalCaseStateName = pascalCase(action.state);
|
|
23
|
+
return `${pascalCaseDocumentType}_${pascalCaseStateName}_State`;
|
|
24
|
+
}
|
|
25
|
+
function getActionOperationStateTypeImports(actions, pascalCaseDocumentType) {
|
|
26
|
+
const stateTypeNames = actions.map((action) => getActionOperationStateTypeName(action, pascalCaseDocumentType));
|
|
27
|
+
return Array.from(new Set(stateTypeNames)).join(",\n");
|
|
28
|
+
}
|
|
29
|
+
function getActionOperationFunction(action, pascalCaseDocumentType) {
|
|
30
|
+
const actionOperationStateTypeName = getActionOperationStateTypeName(action, pascalCaseDocumentType);
|
|
31
|
+
const actionTypeName = getActionTypeName(action);
|
|
32
|
+
return ts `
|
|
33
|
+
(state: ${actionOperationStateTypeName}, action: ${actionTypeName}, dispatch?: SignalDispatch) => void
|
|
34
|
+
`.raw;
|
|
35
|
+
}
|
|
36
|
+
function getOperationsInterfaceField(action, pascalCaseDocumentType) {
|
|
37
|
+
const actionOperationFieldName = getActionOperationFieldName(action);
|
|
38
|
+
const actionOperationFunction = getActionOperationFunction(action, pascalCaseDocumentType);
|
|
39
|
+
return ts `
|
|
40
|
+
${actionOperationFieldName}: ${actionOperationFunction}
|
|
41
|
+
`.raw;
|
|
42
|
+
}
|
|
43
|
+
function getOperationsInterfaceFields(actions, pascalCaseDocumentType) {
|
|
44
|
+
return actions
|
|
45
|
+
.map((action) => getOperationsInterfaceField(action, pascalCaseDocumentType))
|
|
46
|
+
.join(",");
|
|
47
|
+
}
|
|
48
|
+
export const documentModelOperationsModuleOperationsFileTemplate = (v) => ts `
|
|
49
|
+
import { type SignalDispatch } from 'document-model';
|
|
50
|
+
import type {
|
|
51
|
+
${getActionTypeImports(v.actions)}
|
|
52
|
+
} from './actions.js';
|
|
53
|
+
import type {
|
|
54
|
+
${getActionOperationStateTypeImports(v.actions, v.pascalCaseDocumentType)}
|
|
55
|
+
} from "../types.js";
|
|
56
|
+
|
|
57
|
+
export interface ${getOperationsInterfaceName(v.pascalCaseDocumentType, v.module)} {
|
|
58
|
+
${getOperationsInterfaceFields(v.actions, v.pascalCaseDocumentType)}
|
|
59
|
+
}
|
|
60
|
+
`.raw;
|
|
61
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../../../../src/ts-morph-utils/templates/document-model/gen/modules/operations.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ph-factories.d.ts","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/ph-factories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAEnF,eAAO,MAAM,oCAAoC,GAC/C,GAAG,2BAA2B,WA4F3B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
export const documentModelPhFactoriesFileTemplate = (v) => ts `
|
|
3
|
+
/**
|
|
4
|
+
* Factory methods for creating ${v.phDocumentTypeName} instances
|
|
5
|
+
*/
|
|
6
|
+
import type {
|
|
7
|
+
PHAuthState,
|
|
8
|
+
PHDocumentState,
|
|
9
|
+
PHBaseState,
|
|
10
|
+
} from "document-model";
|
|
11
|
+
import {
|
|
12
|
+
createBaseState,
|
|
13
|
+
defaultBaseState,
|
|
14
|
+
} from "document-model/core";
|
|
15
|
+
import type {
|
|
16
|
+
${v.phDocumentTypeName},
|
|
17
|
+
${v.localStateName},
|
|
18
|
+
${v.globalStateName},
|
|
19
|
+
${v.phStateName},
|
|
20
|
+
} from "./types.js";
|
|
21
|
+
import { createDocument } from "./utils.js";
|
|
22
|
+
|
|
23
|
+
export function defaultGlobalState(): ${v.globalStateName} {
|
|
24
|
+
return ${v.initialGlobalState};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function defaultLocalState(): ${v.localStateName} {
|
|
28
|
+
return ${v.initialLocalState};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function defaultPHState(): ${v.phStateName} {
|
|
32
|
+
return {
|
|
33
|
+
...defaultBaseState(),
|
|
34
|
+
global: defaultGlobalState(),
|
|
35
|
+
local: defaultLocalState(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function createGlobalState(
|
|
40
|
+
state?: Partial<${v.globalStateName}>,
|
|
41
|
+
): ${v.globalStateName} {
|
|
42
|
+
return {
|
|
43
|
+
...defaultGlobalState(),
|
|
44
|
+
...(state || {}),
|
|
45
|
+
} as ${v.globalStateName};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createLocalState(
|
|
49
|
+
state?: Partial<${v.localStateName}>,
|
|
50
|
+
): ${v.localStateName} {
|
|
51
|
+
return {
|
|
52
|
+
...defaultLocalState(),
|
|
53
|
+
...(state || {}),
|
|
54
|
+
} as ${v.localStateName};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createState(
|
|
58
|
+
baseState?: Partial<PHBaseState>,
|
|
59
|
+
globalState?: Partial<${v.globalStateName}>,
|
|
60
|
+
localState?: Partial<${v.localStateName}>,
|
|
61
|
+
): ${v.phStateName} {
|
|
62
|
+
return {
|
|
63
|
+
...createBaseState(baseState?.auth, baseState?.document),
|
|
64
|
+
global: createGlobalState(globalState),
|
|
65
|
+
local: createLocalState(localState),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a ${v.phDocumentTypeName} with custom global and local state
|
|
71
|
+
* This properly handles the PHBaseState requirements while allowing
|
|
72
|
+
* document-specific state to be set.
|
|
73
|
+
*/
|
|
74
|
+
export function create${v.phDocumentTypeName}(
|
|
75
|
+
state?: Partial<{
|
|
76
|
+
auth?: Partial<PHAuthState>;
|
|
77
|
+
document?: Partial<PHDocumentState>;
|
|
78
|
+
global?: Partial<${v.globalStateName}>;
|
|
79
|
+
local?: Partial<${v.localStateName}>;
|
|
80
|
+
}>,
|
|
81
|
+
): ${v.phDocumentTypeName} {
|
|
82
|
+
const document = createDocument(
|
|
83
|
+
state ? createState(
|
|
84
|
+
createBaseState(state.auth, state.document),
|
|
85
|
+
state.global,
|
|
86
|
+
state.local,
|
|
87
|
+
) : undefined
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return document;
|
|
91
|
+
}
|
|
92
|
+
`.raw;
|
|
93
|
+
//# sourceMappingURL=ph-factories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ph-factories.js","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/ph-factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGhC,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAClD,CAA8B,EAC9B,EAAE,CACF,EAAE,CAAA;;kCAE8B,CAAC,CAAC,kBAAkB;;;;;;;;;;;;IAYlD,CAAC,CAAC,kBAAkB;IACpB,CAAC,CAAC,cAAc;IAChB,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,WAAW;;;;wCAIuB,CAAC,CAAC,eAAe;WAC9C,CAAC,CAAC,kBAAkB;;;uCAGQ,CAAC,CAAC,cAAc;WAC5C,CAAC,CAAC,iBAAiB;;;oCAGM,CAAC,CAAC,WAAW;;;;;;;;;oBAS7B,CAAC,CAAC,eAAe;KAChC,CAAC,CAAC,eAAe;;;;SAIb,CAAC,CAAC,eAAe;;;;oBAIN,CAAC,CAAC,cAAc;KAC/B,CAAC,CAAC,cAAc;;;;SAIZ,CAAC,CAAC,cAAc;;;;;0BAKC,CAAC,CAAC,eAAe;yBAClB,CAAC,CAAC,cAAc;KACpC,CAAC,CAAC,WAAW;;;;;;;;;eASH,CAAC,CAAC,kBAAkB;;;;wBAIX,CAAC,CAAC,kBAAkB;;;;uBAIrB,CAAC,CAAC,eAAe;sBAClB,CAAC,CAAC,cAAc;;KAEjC,CAAC,CAAC,kBAAkB;;;;;;;;;;;CAWxB,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/reducer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AA0HnF,eAAO,MAAM,mCAAmC,GAC9C,GAAG,2BAA2B,WA2B3B,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
import { camelCase, constantCase, paramCase, pascalCase } from "change-case";
|
|
3
|
+
function makePascalCaseOperationName(operation) {
|
|
4
|
+
if (!operation.name) {
|
|
5
|
+
throw new Error("Operation is missing name");
|
|
6
|
+
}
|
|
7
|
+
return pascalCase(operation.name);
|
|
8
|
+
}
|
|
9
|
+
function makeCamelCaseOperationName(operation) {
|
|
10
|
+
if (!operation.name) {
|
|
11
|
+
throw new Error("Operation is missing name");
|
|
12
|
+
}
|
|
13
|
+
return camelCase(operation.name);
|
|
14
|
+
}
|
|
15
|
+
function makeConstantCaseOperationName(operation) {
|
|
16
|
+
if (!operation.name) {
|
|
17
|
+
throw new Error("Operation is missing name");
|
|
18
|
+
}
|
|
19
|
+
return constantCase(operation.name);
|
|
20
|
+
}
|
|
21
|
+
function makeOperationInputSchema(operation) {
|
|
22
|
+
const pascalCaseOperationName = makePascalCaseOperationName(operation);
|
|
23
|
+
return `${pascalCaseOperationName}InputSchema`;
|
|
24
|
+
}
|
|
25
|
+
function makeOperationInputSchemaImports(modules) {
|
|
26
|
+
const moduleOperationInputSchemas = modules
|
|
27
|
+
.flatMap((module) => module.operations.map(makeOperationInputSchema))
|
|
28
|
+
.join(",\n");
|
|
29
|
+
return `import { ${moduleOperationInputSchemas} } from "./schema/zod.js";`;
|
|
30
|
+
}
|
|
31
|
+
function makeModuleOperationsImport(module, camelCaseDocumentType) {
|
|
32
|
+
const pascalCaseModuleName = pascalCase(module.name);
|
|
33
|
+
const paramCaseModuleName = paramCase(module.name);
|
|
34
|
+
return `import { ${camelCaseDocumentType}${pascalCaseModuleName}Operations } from "../src/reducers/${paramCaseModuleName}.js";`;
|
|
35
|
+
}
|
|
36
|
+
function makeModulesOperationsImports(modules, camelCaseDocumentType) {
|
|
37
|
+
return modules
|
|
38
|
+
.map((module) => makeModuleOperationsImport(module, camelCaseDocumentType))
|
|
39
|
+
.join("\n");
|
|
40
|
+
}
|
|
41
|
+
function makeOperationInputSchemaInvocation(operation) {
|
|
42
|
+
const operationInputSchema = makeOperationInputSchema(operation);
|
|
43
|
+
const constantCaseOperationName = makeConstantCaseOperationName(operation);
|
|
44
|
+
if (operation.schema === null) {
|
|
45
|
+
return ts `
|
|
46
|
+
if (Object.keys(action.input).length > 0) throw new Error("Expected empty input for action ${constantCaseOperationName}");
|
|
47
|
+
`.raw;
|
|
48
|
+
}
|
|
49
|
+
return ts `${operationInputSchema}().parse(action.input);`.raw;
|
|
50
|
+
}
|
|
51
|
+
function makeOperationsObjectName(module, camelCaseDocumentType) {
|
|
52
|
+
const pascalCaseModuleName = pascalCase(module.name);
|
|
53
|
+
return `${camelCaseDocumentType}${pascalCaseModuleName}Operations`;
|
|
54
|
+
}
|
|
55
|
+
function makeOperationName(operation) {
|
|
56
|
+
const camelCaseOperationName = makeCamelCaseOperationName(operation);
|
|
57
|
+
return `${camelCaseOperationName}Operation`;
|
|
58
|
+
}
|
|
59
|
+
function makeOperationInvocation(module, operation, camelCaseDocumentType) {
|
|
60
|
+
const operationsObjectName = makeOperationsObjectName(module, camelCaseDocumentType);
|
|
61
|
+
const operationName = makeOperationName(operation);
|
|
62
|
+
return ts `
|
|
63
|
+
${operationsObjectName}.${operationName}((state as any)[action.scope], action as any, dispatch);
|
|
64
|
+
`.raw;
|
|
65
|
+
}
|
|
66
|
+
function makeModuleOperationCaseStatement(module, camelCaseDocumentType) {
|
|
67
|
+
return module.operations.map((operation) => ts `
|
|
68
|
+
case "${makeConstantCaseOperationName(operation)}": {
|
|
69
|
+
${makeOperationInputSchemaInvocation(operation)}
|
|
70
|
+
${makeOperationInvocation(module, operation, camelCaseDocumentType)}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
`.raw);
|
|
74
|
+
}
|
|
75
|
+
function makeModuleOperationsCaseStatements(modules, camelCaseDocumentType) {
|
|
76
|
+
return modules
|
|
77
|
+
.map((module) => makeModuleOperationCaseStatement(module, camelCaseDocumentType).join("\n"))
|
|
78
|
+
.join("\n");
|
|
79
|
+
}
|
|
80
|
+
export const documentModelGenReducerFileTemplate = (v) => ts `
|
|
81
|
+
// TODO: remove eslint-disable rules once refactor is done
|
|
82
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
83
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
84
|
+
import type { StateReducer } from "document-model";
|
|
85
|
+
import { isDocumentAction, createReducer } from "document-model/core";
|
|
86
|
+
import type { ${v.phStateName} } from "${v.versionedDocumentModelPackageImportPath}";
|
|
87
|
+
|
|
88
|
+
${makeModulesOperationsImports(v.modules, v.camelCaseDocumentType)}
|
|
89
|
+
|
|
90
|
+
${makeOperationInputSchemaImports(v.modules)}
|
|
91
|
+
|
|
92
|
+
const stateReducer: StateReducer<${v.phStateName}> =
|
|
93
|
+
(state, action, dispatch) => {
|
|
94
|
+
if (isDocumentAction(action)) {
|
|
95
|
+
return state;
|
|
96
|
+
}
|
|
97
|
+
switch (action.type) {
|
|
98
|
+
${makeModuleOperationsCaseStatements(v.modules, v.camelCaseDocumentType)}
|
|
99
|
+
default:
|
|
100
|
+
return state;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const reducer = createReducer<${v.phStateName}>(stateReducer);
|
|
105
|
+
`.raw;
|
|
106
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/reducer.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/ts-morph-utils/templates/document-model/gen/schema/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gCAAgC,QAGxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/ts-morph-utils/templates/document-model/gen/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAA;;;CAGjD,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAkBnF,eAAO,MAAM,6BAA6B,GAAI,GAAG,2BAA2B,WA0BvE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
function buildEmptyLocalStateType(hasLocalSchema, localStateName) {
|
|
3
|
+
if (hasLocalSchema)
|
|
4
|
+
return "";
|
|
5
|
+
return `type ${localStateName} = Record<PropertyKey, never>;`;
|
|
6
|
+
}
|
|
7
|
+
function buildLocalStateTypeImport(hasLocalSchema, localStateName) {
|
|
8
|
+
if (!hasLocalSchema)
|
|
9
|
+
return "";
|
|
10
|
+
return localStateName;
|
|
11
|
+
}
|
|
12
|
+
export const documentModelGenTypesTemplate = (v) => ts `
|
|
13
|
+
import type { PHDocument, PHBaseState } from 'document-model';
|
|
14
|
+
import type { ${v.actionTypeName} } from './actions.js';
|
|
15
|
+
import type {
|
|
16
|
+
${v.stateName} as ${v.globalStateName},
|
|
17
|
+
${buildLocalStateTypeImport(v.hasLocalSchema, v.localStateName)}
|
|
18
|
+
} from './schema/types.js';
|
|
19
|
+
|
|
20
|
+
${buildEmptyLocalStateType(v.hasLocalSchema, v.localStateName)}
|
|
21
|
+
|
|
22
|
+
type ${v.phStateName} = PHBaseState & {
|
|
23
|
+
global: ${v.globalStateName};
|
|
24
|
+
local: ${v.localStateName};
|
|
25
|
+
};
|
|
26
|
+
type ${v.phDocumentTypeName} = PHDocument<${v.phStateName}>;
|
|
27
|
+
|
|
28
|
+
export * from './schema/types.js';
|
|
29
|
+
|
|
30
|
+
export type {
|
|
31
|
+
${v.globalStateName},
|
|
32
|
+
${v.localStateName},
|
|
33
|
+
${v.phStateName},
|
|
34
|
+
${v.actionTypeName},
|
|
35
|
+
${v.phDocumentTypeName},
|
|
36
|
+
};
|
|
37
|
+
`.raw;
|
|
38
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGhC,SAAS,wBAAwB,CAC/B,cAAuB,EACvB,cAAsB;IAEtB,IAAI,cAAc;QAAE,OAAO,EAAE,CAAC;IAE9B,OAAO,QAAQ,cAAc,gCAAgC,CAAC;AAChE,CAAC;AAED,SAAS,yBAAyB,CAChC,cAAuB,EACvB,cAAsB;IAEtB,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AACD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAA8B,EAAE,EAAE,CAC9E,EAAE,CAAA;;gBAEY,CAAC,CAAC,cAAc;;IAE5B,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,eAAe;IACnC,yBAAyB,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,cAAc,CAAC;;;EAG/D,wBAAwB,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,cAAc,CAAC;;OAEvD,CAAC,CAAC,WAAW;YACR,CAAC,CAAC,eAAe;WAClB,CAAC,CAAC,cAAc;;OAEpB,CAAC,CAAC,kBAAkB,iBAAiB,CAAC,CAAC,WAAW;;;;;IAKrD,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,cAAc;IAChB,CAAC,CAAC,WAAW;IACb,CAAC,CAAC,cAAc;IAChB,CAAC,CAAC,kBAAkB;;CAEvB,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAEnF,eAAO,MAAM,6BAA6B,GAAI,GAAG,2BAA2B,WA2EvE,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
export const documentModelGenUtilsTemplate = (v) => ts `
|
|
3
|
+
import type {
|
|
4
|
+
DocumentModelUtils,
|
|
5
|
+
} from "document-model";
|
|
6
|
+
import {
|
|
7
|
+
baseCreateDocument,
|
|
8
|
+
baseSaveToFileHandle,
|
|
9
|
+
baseLoadFromInput,
|
|
10
|
+
defaultBaseState,
|
|
11
|
+
generateId,
|
|
12
|
+
} from 'document-model/core';
|
|
13
|
+
import type {
|
|
14
|
+
${v.globalStateName},
|
|
15
|
+
${v.localStateName}
|
|
16
|
+
} from './types.js';
|
|
17
|
+
import type { ${v.phStateName} } from './types.js';
|
|
18
|
+
import { reducer } from './reducer.js';
|
|
19
|
+
import { ${v.documentTypeVariableName} } from "./document-type.js";
|
|
20
|
+
import {
|
|
21
|
+
${v.isPhDocumentOfTypeFunctionName},
|
|
22
|
+
${v.assertIsPhDocumentOfTypeFunctionName},
|
|
23
|
+
${v.isPhStateOfTypeFunctionName},
|
|
24
|
+
${v.assertIsPhStateOfTypeFunctionName},
|
|
25
|
+
} from "./document-schema.js";
|
|
26
|
+
|
|
27
|
+
export const initialGlobalState: ${v.globalStateName} = ${v.initialGlobalState};
|
|
28
|
+
export const initialLocalState: ${v.localStateName} = ${v.initialLocalState};
|
|
29
|
+
|
|
30
|
+
export const utils: DocumentModelUtils<${v.phStateName}> = {
|
|
31
|
+
fileExtension: "${v.fileExtension}",
|
|
32
|
+
createState(state) {
|
|
33
|
+
return { ...defaultBaseState(), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
34
|
+
},
|
|
35
|
+
createDocument(state) {
|
|
36
|
+
const document = baseCreateDocument(
|
|
37
|
+
utils.createState,
|
|
38
|
+
state
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
document.header.documentType = ${v.documentTypeVariableName};
|
|
42
|
+
|
|
43
|
+
// for backwards compatibility, but this is NOT a valid signed document id
|
|
44
|
+
document.header.id = generateId();
|
|
45
|
+
|
|
46
|
+
return document;
|
|
47
|
+
},
|
|
48
|
+
saveToFileHandle(document, input) {
|
|
49
|
+
return baseSaveToFileHandle(document, input);
|
|
50
|
+
},
|
|
51
|
+
loadFromInput(input) {
|
|
52
|
+
return baseLoadFromInput(input, reducer);
|
|
53
|
+
},
|
|
54
|
+
isStateOfType(state) {
|
|
55
|
+
return ${v.isPhStateOfTypeFunctionName}(state);
|
|
56
|
+
},
|
|
57
|
+
assertIsStateOfType(state) {
|
|
58
|
+
return ${v.assertIsPhStateOfTypeFunctionName}(state);
|
|
59
|
+
},
|
|
60
|
+
isDocumentOfType(document) {
|
|
61
|
+
return ${v.isPhDocumentOfTypeFunctionName}(document);
|
|
62
|
+
},
|
|
63
|
+
assertIsDocumentOfType(document) {
|
|
64
|
+
return ${v.assertIsPhDocumentOfTypeFunctionName}(document);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const createDocument = utils.createDocument;
|
|
69
|
+
export const createState = utils.createState;
|
|
70
|
+
export const saveToFileHandle = utils.saveToFileHandle;
|
|
71
|
+
export const loadFromInput = utils.loadFromInput;
|
|
72
|
+
export const isStateOfType = utils.isStateOfType;
|
|
73
|
+
export const assertIsStateOfType = utils.assertIsStateOfType;
|
|
74
|
+
export const isDocumentOfType = utils.isDocumentOfType;
|
|
75
|
+
export const assertIsDocumentOfType = utils.assertIsDocumentOfType;
|
|
76
|
+
`.raw;
|
|
77
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/gen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGhC,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAA8B,EAAE,EAAE,CAC9E,EAAE,CAAA;;;;;;;;;;;;IAYA,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,cAAc;;gBAEJ,CAAC,CAAC,WAAW;;WAElB,CAAC,CAAC,wBAAwB;;IAEjC,CAAC,CAAC,8BAA8B;IAChC,CAAC,CAAC,oCAAoC;IACtC,CAAC,CAAC,2BAA2B;IAC7B,CAAC,CAAC,iCAAiC;;;mCAGJ,CAAC,CAAC,eAAe,MAAM,CAAC,CAAC,kBAAkB;kCAC5C,CAAC,CAAC,cAAc,MAAM,CAAC,CAAC,iBAAiB;;yCAElC,CAAC,CAAC,WAAW;sBAChC,CAAC,CAAC,aAAa;;;;;;;;;;yCAUI,CAAC,CAAC,wBAAwB;;;;;;;;;;;;;;iBAclD,CAAC,CAAC,2BAA2B;;;iBAG7B,CAAC,CAAC,iCAAiC;;;iBAGnC,CAAC,CAAC,8BAA8B;;;iBAGhC,CAAC,CAAC,oCAAoC;;;;;;;;;;;;CAYtD,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../../src/ts-morph-utils/templates/document-model/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAEhF,eAAO,MAAM,8BAA8B,GACzC,GAAG,2BAA2B,WAgD3B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
export const documentModelHooksFileTemplate = (v) => ts `
|
|
3
|
+
|
|
4
|
+
import type { DocumentDispatch } from "@powerhousedao/reactor-browser";
|
|
5
|
+
import {
|
|
6
|
+
useDocumentsInSelectedDrive,
|
|
7
|
+
useDocumentsInSelectedFolder,
|
|
8
|
+
useDocumentById,
|
|
9
|
+
useSelectedDocument,
|
|
10
|
+
} from "@powerhousedao/reactor-browser";
|
|
11
|
+
import type {
|
|
12
|
+
${v.phDocumentTypeName},
|
|
13
|
+
${v.actionTypeName},
|
|
14
|
+
} from "${v.versionedDocumentModelPackageImportPath}";
|
|
15
|
+
import { ${v.isPhDocumentOfTypeFunctionName} } from "./gen/document-schema.js";
|
|
16
|
+
|
|
17
|
+
/** Hook to get a ${v.pascalCaseDocumentType} document by its id */
|
|
18
|
+
export function ${v.useByIdHookName}(
|
|
19
|
+
documentId: string | null | undefined,
|
|
20
|
+
):
|
|
21
|
+
| [${v.phDocumentTypeName}, DocumentDispatch<${v.actionTypeName}>]
|
|
22
|
+
| [undefined, undefined] {
|
|
23
|
+
const [document, dispatch] = useDocumentById(documentId);
|
|
24
|
+
if (!${v.isPhDocumentOfTypeFunctionName}(document)) return [undefined, undefined];
|
|
25
|
+
return [document, dispatch];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Hook to get the selected ${v.pascalCaseDocumentType} document */
|
|
29
|
+
export function ${v.useSelectedHookName}():
|
|
30
|
+
| [${v.phDocumentTypeName}, DocumentDispatch<${v.actionTypeName}>]
|
|
31
|
+
| [undefined, undefined] {
|
|
32
|
+
const [document, dispatch] = useSelectedDocument();
|
|
33
|
+
if (!${v.isPhDocumentOfTypeFunctionName}(document)) return [undefined, undefined];
|
|
34
|
+
return [document, dispatch];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Hook to get all ${v.pascalCaseDocumentType} documents in the selected drive */
|
|
38
|
+
export function ${v.useInSelectedDriveHookName}() {
|
|
39
|
+
const documentsInSelectedDrive = useDocumentsInSelectedDrive();
|
|
40
|
+
return documentsInSelectedDrive?.filter(${v.isPhDocumentOfTypeFunctionName});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Hook to get all ${v.pascalCaseDocumentType} documents in the selected folder */
|
|
44
|
+
export function ${v.useInSelectedFolderHookName}() {
|
|
45
|
+
const documentsInSelectedFolder = useDocumentsInSelectedFolder();
|
|
46
|
+
return documentsInSelectedFolder?.filter(${v.isPhDocumentOfTypeFunctionName});
|
|
47
|
+
}
|
|
48
|
+
`.raw;
|
|
49
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../../src/ts-morph-utils/templates/document-model/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGhC,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,CAA8B,EAC9B,EAAE,CACF,EAAE,CAAA;;;;;;;;;;IAUA,CAAC,CAAC,kBAAkB;IACpB,CAAC,CAAC,cAAc;UACV,CAAC,CAAC,uCAAuC;WACxC,CAAC,CAAC,8BAA8B;;oBAEvB,CAAC,CAAC,sBAAsB;kBAC1B,CAAC,CAAC,eAAe;;;OAG5B,CAAC,CAAC,kBAAkB,sBAAsB,CAAC,CAAC,cAAc;;;SAGxD,CAAC,CAAC,8BAA8B;;;;+BAIV,CAAC,CAAC,sBAAsB;kBACrC,CAAC,CAAC,mBAAmB;OAChC,CAAC,CAAC,kBAAkB,sBAAsB,CAAC,CAAC,cAAc;;;SAGxD,CAAC,CAAC,8BAA8B;;;;sBAInB,CAAC,CAAC,sBAAsB;kBAC5B,CAAC,CAAC,0BAA0B;;4CAEF,CAAC,CAAC,8BAA8B;;;sBAGtD,CAAC,CAAC,sBAAsB;kBAC5B,CAAC,CAAC,2BAA2B;;6CAEF,CAAC,CAAC,8BAA8B;;CAE5E,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/ts-morph-utils/templates/document-model/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,QAMlC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
export const documentModelIndexTemplate = ts `
|
|
3
|
+
export * from "./gen/index.js";
|
|
4
|
+
export * from "./src/index.js";
|
|
5
|
+
export * from "./hooks.js";
|
|
6
|
+
export { actions } from "./actions.js";
|
|
7
|
+
export { utils } from "./utils.js";
|
|
8
|
+
`.raw;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ts-morph-utils/templates/document-model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAA;;;;;;CAM3C,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type DocumentModelModuleFileTemplateArgs = {
|
|
2
|
+
phStateName: string;
|
|
3
|
+
versionedDocumentModelPackageImportPath: string;
|
|
4
|
+
pascalCaseDocumentType: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function documentModelModuleFileTemplate({ phStateName, versionedDocumentModelPackageImportPath, pascalCaseDocumentType, }: DocumentModelModuleFileTemplateArgs): string;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/ts-morph-utils/templates/document-model/module.ts"],"names":[],"mappings":"AAEA,KAAK,mCAAmC,GAAG;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC,EAAE,MAAM,CAAC;IAChD,sBAAsB,EAAE,MAAM,CAAC;CAChC,CAAC;AACF,wBAAgB,+BAA+B,CAAC,EAC9C,WAAW,EACX,uCAAuC,EACvC,sBAAsB,GACvB,EAAE,mCAAmC,UAuBrC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ts } from "@tmpl/core";
|
|
2
|
+
export function documentModelModuleFileTemplate({ phStateName, versionedDocumentModelPackageImportPath, pascalCaseDocumentType, }) {
|
|
3
|
+
const template = ts `
|
|
4
|
+
import type { DocumentModelModule } from "document-model";
|
|
5
|
+
import { createState } from "document-model";
|
|
6
|
+
import { defaultBaseState } from "document-model/core";
|
|
7
|
+
import type { ${phStateName} } from "${versionedDocumentModelPackageImportPath}";
|
|
8
|
+
import {
|
|
9
|
+
actions,
|
|
10
|
+
documentModel,
|
|
11
|
+
reducer,
|
|
12
|
+
utils,
|
|
13
|
+
} from "${versionedDocumentModelPackageImportPath}";
|
|
14
|
+
|
|
15
|
+
/** Document model module for the Todo List document type */
|
|
16
|
+
export const ${pascalCaseDocumentType}: DocumentModelModule<${phStateName}> = {
|
|
17
|
+
reducer,
|
|
18
|
+
actions,
|
|
19
|
+
utils,
|
|
20
|
+
documentModel: createState(defaultBaseState(), documentModel),
|
|
21
|
+
};
|
|
22
|
+
`;
|
|
23
|
+
return template.raw;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../src/ts-morph-utils/templates/document-model/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAOhC,MAAM,UAAU,+BAA+B,CAAC,EAC9C,WAAW,EACX,uCAAuC,EACvC,sBAAsB,GACc;IACpC,MAAM,QAAQ,GAAG,EAAE,CAAA;;;;kBAIH,WAAW,YAAY,uCAAuC;;;;;;YAMpE,uCAAuC;;;iBAGlC,sBAAsB,yBAAyB,WAAW;;;;;;CAM1E,CAAC;IAEA,OAAO,QAAQ,CAAC,GAAG,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iCAAiC,QAEzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/ts-morph-utils/templates/document-model/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAA;;CAElD,CAAC,GAAG,CAAC"}
|
package/dist/src/ts-morph-utils/templates/document-model/src/tests/document-model.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-model.test.d.ts","sourceRoot":"","sources":["../../../../../../../src/ts-morph-utils/templates/document-model/src/tests/document-model.test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF,eAAO,MAAM,6BAA6B,GAAI,GAAG,2BAA2B,WAuHvE,CAAC"}
|