@powerhousedao/codegen 5.0.0-staging.9 → 5.0.1-staging.10
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/README.md +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js +8 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/resolvers.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/schema.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/actions.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/creators.esm.t +3 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/customUtils.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-models.esm.t +14 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-schema.esm.t +56 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-type.esm.t +6 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModel.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModelTest.esm.t +110 -15
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/hooks.esm.t +49 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.esm.t +12 -6
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.js +128 -54
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/lib.esm.t +4 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/module.esm.t +22 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t +29 -32
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +18 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/root-utils.esm.t +11 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootActions.esm.t +13 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootIndex.esm.t +6 -25
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/schema.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/src-index.esm.t +5 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +21 -11
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/utils.esm.t +59 -52
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/creators.esm.t +11 -6
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +13 -18
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +67 -39
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.js +117 -21
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +23 -12
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t +5 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +33 -39
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveContents.esm.t +23 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +10 -279
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EmptyState.esm.t +19 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/Files.esm.t +29 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderTree.esm.t +92 -87
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/Folders.esm.t +28 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/NavigationBreadcrumbs.esm.t +14 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/config.esm.t +11 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +10 -35
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editors.esm.t +14 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.js +29 -11
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/lib.esm.t +4 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/module.esm.t +15 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/edit-name.esm.t +78 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/editor.esm.t +9 -21
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/editors.esm.t +14 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +97 -16
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/lib.esm.t +4 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/module.esm.t +16 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.js +8 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/factory.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t +3 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.js +11 -15
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.root.inject.esm.t +12 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/factory.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.esm.t +3 -4
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.js +11 -15
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.root.inject.esm.t +12 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/migrations.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.js +9 -11
- package/dist/src/codegen/.hygen/templates/powerhouse/utils.js +43 -0
- package/dist/src/codegen/__tests__/config.d.ts +2 -0
- package/dist/src/codegen/__tests__/config.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/config.js +2 -0
- package/dist/src/codegen/__tests__/config.js.map +1 -0
- package/dist/src/codegen/__tests__/constants.d.ts +16 -0
- package/dist/src/codegen/__tests__/constants.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/constants.js +16 -0
- package/dist/src/codegen/__tests__/constants.js.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.d.ts +2 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.js +9 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content-v3.js.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.d.ts +3 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.js +33 -0
- package/dist/src/codegen/__tests__/fixtures/expected-reducer-content.js.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/run-generated-tests.d.ts +2 -0
- package/dist/src/codegen/__tests__/fixtures/run-generated-tests.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/run-generated-tests.js +23 -0
- package/dist/src/codegen/__tests__/fixtures/run-generated-tests.js.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/typecheck.d.ts +2 -0
- package/dist/src/codegen/__tests__/fixtures/typecheck.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/fixtures/typecheck.js +23 -0
- package/dist/src/codegen/__tests__/fixtures/typecheck.js.map +1 -0
- package/dist/src/codegen/__tests__/generate-doc-model.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/generate-doc-model.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generate-doc-model.test.js +206 -0
- package/dist/src/codegen/__tests__/generate-doc-model.test.js.map +1 -0
- package/dist/src/codegen/__tests__/generate-drive-editor.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/generate-drive-editor.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generate-drive-editor.test.js +153 -0
- package/dist/src/codegen/__tests__/generate-drive-editor.test.js.map +1 -0
- package/dist/src/codegen/__tests__/generate-editor.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/generate-editor.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generate-editor.test.js +94 -0
- package/dist/src/codegen/__tests__/generate-editor.test.js.map +1 -0
- package/dist/src/codegen/__tests__/generate-manifest.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/generate-manifest.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generate-manifest.test.js +192 -0
- package/dist/src/codegen/__tests__/generate-manifest.test.js.map +1 -0
- package/dist/src/codegen/__tests__/generate-schemas.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/generate-schemas.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generate-schemas.test.js +143 -0
- package/dist/src/codegen/__tests__/generate-schemas.test.js.map +1 -0
- package/dist/src/codegen/__tests__/global-setup.d.ts +2 -0
- package/dist/src/codegen/__tests__/global-setup.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/global-setup.js +21 -0
- package/dist/src/codegen/__tests__/global-setup.js.map +1 -0
- package/dist/src/codegen/__tests__/ts-morph-generator.test.d.ts +2 -0
- package/dist/src/codegen/__tests__/ts-morph-generator.test.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/ts-morph-generator.test.js +72 -0
- package/dist/src/codegen/__tests__/ts-morph-generator.test.js.map +1 -0
- package/dist/src/codegen/__tests__/utils.d.ts +7 -0
- package/dist/src/codegen/__tests__/utils.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/utils.js +52 -0
- package/dist/src/codegen/__tests__/utils.js.map +1 -0
- package/dist/src/codegen/generate.d.ts +33 -0
- package/dist/src/codegen/generate.d.ts.map +1 -0
- package/dist/src/codegen/generate.js +205 -0
- package/dist/src/codegen/generate.js.map +1 -0
- package/dist/src/codegen/graphql.d.ts +2 -2
- package/dist/src/codegen/graphql.d.ts.map +1 -1
- package/dist/src/codegen/graphql.js.map +1 -1
- package/dist/src/codegen/hygen.d.ts +15 -12
- package/dist/src/codegen/hygen.d.ts.map +1 -1
- package/dist/src/codegen/hygen.js +72 -27
- package/dist/src/codegen/hygen.js.map +1 -1
- package/dist/src/codegen/index.d.ts +6 -34
- package/dist/src/codegen/index.d.ts.map +1 -1
- package/dist/src/codegen/index.js +6 -249
- package/dist/src/codegen/index.js.map +1 -1
- package/dist/src/codegen/types.d.ts +9 -0
- package/dist/src/codegen/types.d.ts.map +1 -0
- package/dist/src/codegen/types.js +2 -0
- package/dist/src/codegen/types.js.map +1 -0
- package/dist/src/codegen/utils.d.ts +5 -2
- package/dist/src/codegen/utils.d.ts.map +1 -1
- package/dist/src/codegen/utils.js +42 -4
- package/dist/src/codegen/utils.js.map +1 -1
- package/dist/src/create-lib/checkout-project.d.ts +13 -0
- package/dist/src/create-lib/checkout-project.d.ts.map +1 -0
- package/dist/src/create-lib/checkout-project.js +47 -0
- package/dist/src/create-lib/checkout-project.js.map +1 -0
- package/dist/src/create-lib/create-project.d.ts +9 -5
- package/dist/src/create-lib/create-project.d.ts.map +1 -1
- package/dist/src/create-lib/create-project.js +37 -30
- package/dist/src/create-lib/create-project.js.map +1 -1
- package/dist/src/create-lib/feature-flags.d.ts +4 -0
- package/dist/src/create-lib/feature-flags.d.ts.map +1 -0
- package/dist/src/create-lib/feature-flags.js +4 -0
- package/dist/src/create-lib/feature-flags.js.map +1 -0
- package/dist/src/create-lib/index.d.ts +1 -0
- package/dist/src/create-lib/index.d.ts.map +1 -1
- package/dist/src/create-lib/index.js +1 -0
- package/dist/src/create-lib/index.js.map +1 -1
- package/dist/src/{utils/package-manager.d.ts → create-lib/utils.d.ts} +3 -1
- package/dist/src/create-lib/utils.d.ts.map +1 -0
- package/dist/src/{utils/package-manager.js → create-lib/utils.js} +12 -1
- package/dist/src/create-lib/utils.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.d.ts +2 -0
- package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.js +491 -0
- package/dist/src/ts-morph-generator/__tests__/ReducerGenerator.test.js.map +1 -0
- package/dist/src/ts-morph-generator/core/FileGenerator.d.ts +5 -4
- package/dist/src/ts-morph-generator/core/FileGenerator.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/FileGenerator.js +3 -1
- package/dist/src/ts-morph-generator/core/FileGenerator.js.map +1 -1
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts +18 -9
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/{file-generators → core}/ReducerGenerator.d.ts +2 -2
- package/dist/src/ts-morph-generator/core/ReducerGenerator.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/{file-generators → core}/ReducerGenerator.js +17 -10
- package/dist/src/ts-morph-generator/core/ReducerGenerator.js.map +1 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts +4 -3
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js +9 -3
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js.map +1 -1
- package/dist/src/ts-morph-generator/index.d.ts +2 -2
- package/dist/src/ts-morph-generator/index.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/index.js +2 -2
- package/dist/src/ts-morph-generator/index.js.map +1 -1
- package/dist/src/ts-morph-generator/utilities/DeclarationManager.d.ts +5 -0
- package/dist/src/ts-morph-generator/utilities/DeclarationManager.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/utilities/DeclarationManager.js +10 -0
- package/dist/src/ts-morph-generator/utilities/DeclarationManager.js.map +1 -0
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts +2 -2
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts +2 -1
- package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/utilities/ImportManager.js +13 -3
- package/dist/src/ts-morph-generator/utilities/ImportManager.js.map +1 -1
- package/dist/src/ts-morph-generator/utilities/index.d.ts +1 -0
- package/dist/src/ts-morph-generator/utilities/index.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/utilities/index.js +1 -0
- package/dist/src/ts-morph-generator/utilities/index.js.map +1 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +0 -1
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/validation.d.ts +6 -6
- package/dist/src/utils/validation.d.ts.map +1 -1
- package/dist/src/utils/validation.js +5 -6
- package/dist/src/utils/validation.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +16 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +27 -35
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts +0 -14
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts +0 -25
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/lib.inject_export.esm.t +0 -7
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/object.esm.t +0 -49
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +0 -27
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/object.esm.t +0 -32
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.d.ts +0 -22
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +0 -103
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.d.ts +0 -16
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.esm.t +0 -19
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/lib.inject_export.esm.t +0 -7
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/types/css.d.esm.t +0 -8
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +0 -22
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.esm.t +0 -19
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/lib.inject_export.esm.t +0 -7
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.d.ts +0 -14
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.d.ts +0 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.d.ts +0 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.d.ts +0 -16
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.js.map +0 -1
- package/dist/src/ts-morph-generator/core/index.d.ts +0 -4
- package/dist/src/ts-morph-generator/core/index.d.ts.map +0 -1
- package/dist/src/ts-morph-generator/core/index.js +0 -4
- package/dist/src/ts-morph-generator/core/index.js.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/index.d.ts +0 -2
- package/dist/src/ts-morph-generator/file-generators/index.d.ts.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/index.js +0 -2
- package/dist/src/ts-morph-generator/file-generators/index.js.map +0 -1
- package/dist/src/utils/package-manager.d.ts.map +0 -1
- package/dist/src/utils/package-manager.js.map +0 -1
- package/dist/tsconfig.hygen.tsbuildinfo +0 -1
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t
CHANGED
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/ph-factories.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
/**
|
|
6
|
-
* Factory methods for creating <%=
|
|
6
|
+
* Factory methods for creating <%= phDocumentTypeName %> instances
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import type {
|
|
9
|
+
PHAuthState,
|
|
10
|
+
PHDocumentState,
|
|
11
|
+
PHBaseState,
|
|
12
|
+
} from "document-model";
|
|
9
13
|
import {
|
|
10
14
|
createBaseState,
|
|
11
15
|
defaultBaseState,
|
|
12
|
-
|
|
13
|
-
type PHDocumentState,
|
|
14
|
-
type PHBaseState,
|
|
15
|
-
} from "document-model";
|
|
16
|
+
} from "document-model/core";
|
|
16
17
|
import type {
|
|
17
|
-
<%=
|
|
18
|
-
<%=
|
|
19
|
-
<%=
|
|
18
|
+
<%= phDocumentTypeName %>,
|
|
19
|
+
<%= localStateName %>,
|
|
20
|
+
<%= globalStateName %>,
|
|
21
|
+
<%= phStateName %>,
|
|
20
22
|
} from "./types.js";
|
|
21
23
|
import { createDocument } from "./utils.js";
|
|
22
24
|
|
|
23
|
-
export
|
|
24
|
-
global: <%= h.changeCase.pascal(documentType) %>State;
|
|
25
|
-
local: <%= h.changeCase.pascal(documentType) %>LocalState;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function defaultGlobalState(): <%= h.changeCase.pascal(documentType) %>State {
|
|
25
|
+
export function defaultGlobalState(): <%= globalStateName %> {
|
|
29
26
|
return <%- initialGlobalState %>;
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
export function defaultLocalState(): <%=
|
|
29
|
+
export function defaultLocalState(): <%= localStateName %> {
|
|
33
30
|
return <%- initialLocalState %>;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
export function defaultPHState(): <%=
|
|
33
|
+
export function defaultPHState(): <%= phStateName %> {
|
|
37
34
|
return {
|
|
38
35
|
...defaultBaseState(),
|
|
39
36
|
global: defaultGlobalState(),
|
|
@@ -42,28 +39,28 @@ export function defaultPHState(): <%= h.changeCase.pascal(documentType) %>PHStat
|
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
export function createGlobalState(
|
|
45
|
-
state?: Partial<<%=
|
|
46
|
-
): <%=
|
|
42
|
+
state?: Partial<<%= globalStateName %>>,
|
|
43
|
+
): <%= globalStateName %> {
|
|
47
44
|
return {
|
|
48
45
|
...defaultGlobalState(),
|
|
49
46
|
...(state || {}),
|
|
50
|
-
} as <%=
|
|
47
|
+
} as <%= globalStateName %>;
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
export function createLocalState(
|
|
54
|
-
state?: Partial<<%=
|
|
55
|
-
): <%=
|
|
51
|
+
state?: Partial<<%= localStateName %>>,
|
|
52
|
+
): <%= localStateName %> {
|
|
56
53
|
return {
|
|
57
54
|
...defaultLocalState(),
|
|
58
55
|
...(state || {}),
|
|
59
|
-
} as <%=
|
|
56
|
+
} as <%= localStateName %>;
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
export function createState(
|
|
63
60
|
baseState?: Partial<PHBaseState>,
|
|
64
|
-
globalState?: Partial<<%=
|
|
65
|
-
localState?: Partial<<%=
|
|
66
|
-
): <%=
|
|
61
|
+
globalState?: Partial<<%= globalStateName %>>,
|
|
62
|
+
localState?: Partial<<%= localStateName %>>,
|
|
63
|
+
): <%= phStateName %> {
|
|
67
64
|
return {
|
|
68
65
|
...createBaseState(baseState?.auth, baseState?.document),
|
|
69
66
|
global: createGlobalState(globalState),
|
|
@@ -72,18 +69,18 @@ export function createState(
|
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
/**
|
|
75
|
-
* Creates a <%=
|
|
72
|
+
* Creates a <%= phDocumentTypeName %> with custom global and local state
|
|
76
73
|
* This properly handles the PHBaseState requirements while allowing
|
|
77
74
|
* document-specific state to be set.
|
|
78
75
|
*/
|
|
79
|
-
export function create<%=
|
|
76
|
+
export function create<%= phDocumentTypeName %>(
|
|
80
77
|
state?: Partial<{
|
|
81
78
|
auth?: Partial<PHAuthState>;
|
|
82
79
|
document?: Partial<PHDocumentState>;
|
|
83
|
-
global?: Partial<<%=
|
|
84
|
-
local?: Partial<<%=
|
|
80
|
+
global?: Partial<<%= globalStateName %>>;
|
|
81
|
+
local?: Partial<<%= localStateName %>>;
|
|
85
82
|
}>,
|
|
86
|
-
): <%=
|
|
83
|
+
): <%= phDocumentTypeName %> {
|
|
87
84
|
const document = createDocument(
|
|
88
85
|
state ? createState(
|
|
89
86
|
createBaseState(state.auth, state.document),
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/reducer.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
// TODO: remove eslint-disable rules once refactor is done
|
|
6
6
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import type { StateReducer } from "document-model";
|
|
9
|
+
import { isDocumentAction, createReducer } from "document-model/core";
|
|
10
|
+
import type { <%= phStateName %> } from "<%= documentModelDir %>";
|
|
11
11
|
|
|
12
|
-
<% modules.forEach(
|
|
13
|
-
import {
|
|
12
|
+
<% modules.forEach(module => { _%>
|
|
13
|
+
import { <%= camelCaseDocumentType %><%= h.changeCase.pascal(module.name) %>Operations } from "../src/reducers/<%= h.changeCase.param(module.name) %>.js";
|
|
14
14
|
<%_ }); %>
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
<% const schemas = modules.flatMap(m =>
|
|
17
|
+
m.operations.map(o => `${h.changeCase.pascalCase(o.name)}InputSchema`)
|
|
18
|
+
);
|
|
19
|
+
%>
|
|
20
|
+
import {
|
|
21
|
+
<%= schemas.join(',\n ') %>
|
|
22
|
+
} from "./schema/zod.js";
|
|
23
|
+
|
|
24
|
+
const stateReducer: StateReducer<<%= phStateName %>> =
|
|
17
25
|
(state, action, dispatch) => {
|
|
18
26
|
if (isDocumentAction(action)) {
|
|
19
27
|
return state;
|
|
@@ -24,9 +32,9 @@ export const stateReducer: StateReducer<<%= h.changeCase.pascal(documentType) %>
|
|
|
24
32
|
modules.map(m => m.operations.map(o =>
|
|
25
33
|
' case "' + h.changeCase.constant(o.name) + '":\n' +
|
|
26
34
|
' ' + (o.schema !== null ?
|
|
27
|
-
|
|
35
|
+
h.changeCase.pascalCase(o.name) + 'InputSchema().parse(action.input);\n' :
|
|
28
36
|
'if (Object.keys(action.input).length > 0) throw new Error("Expected empty input for action ' + h.changeCase.constant(o.name) + '");\n') +
|
|
29
|
-
' ' + h.changeCase.pascal(m.name)
|
|
37
|
+
' ' + camelCaseDocumentType + h.changeCase.pascal(m.name) + 'Operations.' + h.changeCase.camel(o.name) + 'Operation((state as any)[action.scope], action as any, dispatch);\n' +
|
|
30
38
|
' break;\n'
|
|
31
39
|
).join('\n')).join('\n')
|
|
32
40
|
%>
|
|
@@ -35,4 +43,4 @@ export const stateReducer: StateReducer<<%= h.changeCase.pascal(documentType) %>
|
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
export const reducer = createReducer<<%=
|
|
46
|
+
export const reducer = createReducer<<%= phStateName %>>(stateReducer);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/utils.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import type { DocumentModelUtils } from "document-model";
|
|
6
|
+
import type { <%= phStateName %> } from "./gen/types.js";
|
|
7
|
+
import { utils as genUtils } from "./gen/utils.js";
|
|
8
|
+
import * as customUtils from "./src/utils.js";
|
|
9
|
+
|
|
10
|
+
/** Utils for the <%= pascalCaseDocumentType %> document model */
|
|
11
|
+
export const utils = { ...genUtils, ...customUtils } satisfies DocumentModelUtils<<%= phStateName %>>;
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootActions.esm.t
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/actions.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { baseActions } from "document-model";
|
|
6
|
+
import { <% modules.forEach(module => { _%>
|
|
7
|
+
<%= h.changeCase.camel(module.name) %>Actions,
|
|
8
|
+
<% }); _%> } from "./gen/creators.js";
|
|
9
|
+
|
|
10
|
+
/** Actions for the <%= pascalCaseDocumentType %> document model */
|
|
11
|
+
export const actions = { ...baseActions, <% modules.forEach(module => { _%>
|
|
12
|
+
...<%= h.changeCase.camel(module.name) %>Actions,
|
|
13
|
+
<% }); _%> };
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootIndex.esm.t
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/index.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
/**
|
|
@@ -7,27 +7,8 @@ force: true
|
|
|
7
7
|
* Delete the file and run the code generator again to have it reset
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import * as customUtils from './src/utils.js';
|
|
16
|
-
import type { <%= h.changeCase.pascal(documentType) %>PHState } from './gen/ph-factories.js';
|
|
17
|
-
|
|
18
|
-
const utils = { ...genUtils, ...customUtils };
|
|
19
|
-
const actions = { ...BaseActions, ...<%= h.changeCase.pascal(documentType) %>Actions };
|
|
20
|
-
|
|
21
|
-
export const module: DocumentModelModule<
|
|
22
|
-
<%= h.changeCase.pascal(documentType) %>PHState
|
|
23
|
-
> = {
|
|
24
|
-
reducer,
|
|
25
|
-
actions,
|
|
26
|
-
utils,
|
|
27
|
-
documentModel,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { reducer, actions, utils, documentModel };
|
|
31
|
-
|
|
32
|
-
export * from './gen/types.js';
|
|
33
|
-
export * from './src/utils.js';
|
|
10
|
+
export * from "./gen/index.js";
|
|
11
|
+
export * from "./src/index.js";
|
|
12
|
+
export * from "./hooks.js";
|
|
13
|
+
export { actions } from "./actions.js";
|
|
14
|
+
export { utils } from "./utils.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/schema/index.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
export * from "./types.js";
|
|
6
|
-
export *
|
|
6
|
+
export * from "./zod.js";
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/types.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import type { PHDocument } from 'document-model';
|
|
6
|
-
import type { <%=
|
|
7
|
-
import type { <%= h.changeCase.pascal(documentType) %>PHState } from './ph-factories.js';
|
|
5
|
+
import type { PHDocument, PHBaseState } from 'document-model';
|
|
6
|
+
import type { <%= actionTypeName %> } from './actions.js';
|
|
8
7
|
import type {
|
|
9
|
-
<%=
|
|
8
|
+
<%= stateName %> as <%= globalStateName %>,
|
|
10
9
|
<% if(hasLocalSchema) { -%>
|
|
11
|
-
<%=
|
|
10
|
+
<%= localStateName %>,
|
|
12
11
|
<%} -%>
|
|
13
12
|
} from './schema/types.js';
|
|
14
13
|
|
|
15
|
-
export { z } from './schema/index.js';
|
|
16
|
-
export type * from './schema/types.js';
|
|
17
14
|
<% if(!hasLocalSchema) { -%>
|
|
18
|
-
<%= 'type ' +
|
|
15
|
+
<%= 'type ' + localStateName %> = Record<PropertyKey, never>;
|
|
19
16
|
<%} -%>
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
type <%= phStateName %> = PHBaseState & {
|
|
18
|
+
global: <%= globalStateName %>;
|
|
19
|
+
local: <%= localStateName %>;
|
|
20
|
+
};
|
|
21
|
+
type <%= phDocumentTypeName %> = PHDocument<<%= phStateName %>>;
|
|
22
|
+
|
|
23
|
+
export * from './schema/types.js';
|
|
24
|
+
|
|
25
|
+
export type {
|
|
26
|
+
<%= globalStateName %>,
|
|
27
|
+
<%= localStateName %>,
|
|
28
|
+
<%= phStateName %>,
|
|
29
|
+
<%= actionTypeName %>,
|
|
30
|
+
<%= phDocumentTypeName %>,
|
|
31
|
+
};
|
|
@@ -1,70 +1,77 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/utils.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
+
import type {
|
|
6
|
+
DocumentModelUtils,
|
|
7
|
+
} from "document-model";
|
|
5
8
|
import {
|
|
6
|
-
type CreateDocument,
|
|
7
|
-
type CreateState,
|
|
8
|
-
type LoadFromFile,
|
|
9
|
-
type LoadFromInput,
|
|
10
9
|
baseCreateDocument,
|
|
11
|
-
baseSaveToFile,
|
|
12
10
|
baseSaveToFileHandle,
|
|
13
|
-
baseLoadFromFile,
|
|
14
11
|
baseLoadFromInput,
|
|
15
12
|
defaultBaseState,
|
|
16
13
|
generateId,
|
|
17
|
-
} from 'document-model';
|
|
18
|
-
import {
|
|
19
|
-
<%=
|
|
20
|
-
<%=
|
|
14
|
+
} from 'document-model/core';
|
|
15
|
+
import type {
|
|
16
|
+
<%= globalStateName %>,
|
|
17
|
+
<%= localStateName %>
|
|
21
18
|
} from './types.js';
|
|
22
|
-
import { <%=
|
|
19
|
+
import type { <%= phStateName %> } from './types.js';
|
|
23
20
|
import { reducer } from './reducer.js';
|
|
21
|
+
import { <%= documentTypeVariableName %> } from "./document-type.js";
|
|
22
|
+
import {
|
|
23
|
+
<%= isPhDocumentOfTypeFunctionName %>,
|
|
24
|
+
<%= assertIsPhDocumentOfTypeFunctionName %>,
|
|
25
|
+
<%= isPhStateOfTypeFunctionName %>,
|
|
26
|
+
<%= assertIsPhStateOfTypeFunctionName %>,
|
|
27
|
+
} from "./document-schema.js";
|
|
24
28
|
|
|
25
|
-
export const initialGlobalState: <%=
|
|
26
|
-
export const initialLocalState: <%=
|
|
27
|
-
|
|
28
|
-
export const createState: CreateState<<%= h.changeCase.pascal(documentType) %>PHState> = (state) => {
|
|
29
|
-
return {
|
|
30
|
-
...defaultBaseState(),
|
|
31
|
-
global: { ...initialGlobalState, ...(state?.global ?? {}) },
|
|
32
|
-
local: { ...initialLocalState, ...(state?.local ?? {}) }
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const createDocument: CreateDocument<<%= h.changeCase.pascal(documentType) %>PHState> = (state) => {
|
|
37
|
-
const document = baseCreateDocument(createState, state);
|
|
38
|
-
document.header.documentType = '<%- documentTypeId %>';
|
|
39
|
-
// for backwards compatibility, but this is NOT a valid signed document id
|
|
40
|
-
document.header.id = generateId();
|
|
41
|
-
return document;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const saveToFile = (document: any, path: string, name?: string) => {
|
|
45
|
-
return baseSaveToFile(document, path, '<%- fileExtension %>', name);
|
|
46
|
-
};
|
|
29
|
+
export const initialGlobalState: <%= globalStateName %> = <%- initialGlobalState %>;
|
|
30
|
+
export const initialLocalState: <%= localStateName %> = <%- initialLocalState %>;
|
|
47
31
|
|
|
48
|
-
export const
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
export const utils: DocumentModelUtils<<%= phStateName %>> = {
|
|
33
|
+
fileExtension: '<%- fileExtension %>',
|
|
34
|
+
createState(state) {
|
|
35
|
+
return { ...defaultBaseState(), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
36
|
+
},
|
|
37
|
+
createDocument(state) {
|
|
38
|
+
const document = baseCreateDocument(
|
|
39
|
+
utils.createState,
|
|
40
|
+
state
|
|
41
|
+
);
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
return baseLoadFromFile(path, reducer);
|
|
54
|
-
};
|
|
43
|
+
document.header.documentType = <%= documentTypeVariableName %>;
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
45
|
+
// for backwards compatibility, but this is NOT a valid signed document id
|
|
46
|
+
document.header.id = generateId();
|
|
59
47
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
return document;
|
|
49
|
+
},
|
|
50
|
+
saveToFileHandle(document, input) {
|
|
51
|
+
return baseSaveToFileHandle(document, input);
|
|
52
|
+
},
|
|
53
|
+
loadFromInput(input) {
|
|
54
|
+
return baseLoadFromInput(input, reducer);
|
|
55
|
+
},
|
|
56
|
+
isStateOfType(state) {
|
|
57
|
+
return <%= isPhStateOfTypeFunctionName %>(state);
|
|
58
|
+
},
|
|
59
|
+
assertIsStateOfType(state) {
|
|
60
|
+
return <%= assertIsPhStateOfTypeFunctionName %>(state);
|
|
61
|
+
},
|
|
62
|
+
isDocumentOfType(document) {
|
|
63
|
+
return <%= isPhDocumentOfTypeFunctionName %>(document);
|
|
64
|
+
},
|
|
65
|
+
assertIsDocumentOfType(document) {
|
|
66
|
+
return <%= assertIsPhDocumentOfTypeFunctionName %>(document);
|
|
67
|
+
},
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export
|
|
70
|
+
export const createDocument = utils.createDocument;
|
|
71
|
+
export const createState = utils.createState;
|
|
72
|
+
export const saveToFileHandle = utils.saveToFileHandle;
|
|
73
|
+
export const loadFromInput = utils.loadFromInput;
|
|
74
|
+
export const isStateOfType = utils.isStateOfType;
|
|
75
|
+
export const assertIsStateOfType = utils.assertIsStateOfType;
|
|
76
|
+
export const isDocumentOfType = utils.isDocumentOfType;
|
|
77
|
+
export const assertIsDocumentOfType = utils.assertIsDocumentOfType;
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/creators.esm.t
CHANGED
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/<%= module %>/creators.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import { createAction<% if (actions.find(a => a.hasAttachment)) {%>, AttachmentInput<%}%> } from 'document-model';
|
|
6
|
-
import {
|
|
5
|
+
import { createAction<% if (actions.find(a => a.hasAttachment)) {%>, AttachmentInput<%}%> } from 'document-model/core';
|
|
6
|
+
import {
|
|
7
|
+
<% actions.filter(a => a.hasInput).forEach(action => { _%>
|
|
8
|
+
<%= h.changeCase.pascal(action.name) %>InputSchema,
|
|
9
|
+
<% }); _%>
|
|
10
|
+
} from '../schema/zod.js';
|
|
11
|
+
import type {
|
|
7
12
|
<% actions.filter(a => a.hasInput).forEach(action => { _%>
|
|
8
|
-
<%=
|
|
13
|
+
<%= h.changeCase.pascal(action.name) %>Input,
|
|
9
14
|
<% }); _%>
|
|
10
15
|
} from '../types.js';
|
|
11
|
-
import {
|
|
16
|
+
import type {
|
|
12
17
|
<% actions.forEach(action => { _%>
|
|
13
|
-
<%=
|
|
18
|
+
<%= h.changeCase.pascal(action.name) %>Action,
|
|
14
19
|
<% }); _%>
|
|
15
20
|
} from './actions.js';
|
|
16
21
|
|
|
@@ -20,7 +25,7 @@ export const <%= h.changeCase.camel(action.name) %> = (input: <%= h.changeCase.p
|
|
|
20
25
|
'<%= h.changeCase.constantCase(action.name) %>',
|
|
21
26
|
{...input},
|
|
22
27
|
<%if(action.hasAttachment){ %>attachments<% } else { %>undefined<% } %>,
|
|
23
|
-
|
|
28
|
+
<%= h.changeCase.pascalCase(action.name) %>InputSchema,
|
|
24
29
|
'<%= action.scope %>'
|
|
25
30
|
);
|
|
26
31
|
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t
CHANGED
|
@@ -7,37 +7,32 @@ unless_exists: true
|
|
|
7
7
|
* - change it by adding new tests or modifying the existing ones
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { describe, it, expect
|
|
10
|
+
import { describe, it, expect } from 'vitest';
|
|
11
11
|
import { generateMock } from '@powerhousedao/codegen';
|
|
12
|
-
import utils from '../../gen/utils.js';
|
|
13
12
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
reducer,
|
|
14
|
+
utils,
|
|
15
|
+
<%= isPhDocumentOfTypeFunctionName %>,
|
|
16
|
+
<% actions.forEach(action => { _%>
|
|
17
|
+
<%= h.changeCase.camel(action.name) %>,
|
|
18
|
+
<%= h.changeCase.pascal(action.name) %>InputSchema,
|
|
17
19
|
<% }); _%>
|
|
18
|
-
} from
|
|
19
|
-
import { reducer } from '../../gen/reducer.js';
|
|
20
|
-
import * as creators from '../../gen/<%= module %>/creators.js';
|
|
21
|
-
import type { <%= h.changeCase.pascal(documentType) %>Document } from '../../gen/types.js';
|
|
20
|
+
} from "<%= documentModelDir %>";
|
|
22
21
|
|
|
23
22
|
describe('<%= h.changeCase.pascal(module) %> Operations', () => {
|
|
24
|
-
let document: <%= h.changeCase.pascal(documentType) %>Document;
|
|
25
|
-
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
document = utils.createDocument();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
23
|
<% actions.forEach(action => { _%>
|
|
31
24
|
it('should handle <%= h.changeCase.camel(action.name) %> operation', () => {
|
|
32
|
-
const
|
|
33
|
-
|
|
25
|
+
const document = utils.createDocument();
|
|
26
|
+
const input = generateMock(
|
|
27
|
+
<%= h.changeCase.pascal(action.name) %>InputSchema(),
|
|
34
28
|
);
|
|
35
29
|
|
|
36
30
|
const updatedDocument = reducer(
|
|
37
31
|
document,
|
|
38
|
-
|
|
32
|
+
<%= h.changeCase.camel(action.name) %>(input),
|
|
39
33
|
);
|
|
40
34
|
|
|
35
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(updatedDocument)).toBe(true);
|
|
41
36
|
expect(updatedDocument.operations.<%= action.scope %>).toHaveLength(1);
|
|
42
37
|
expect(updatedDocument.operations.<%= action.scope %>[0].action.type).toBe(
|
|
43
38
|
'<%= h.changeCase.constant(action.name) %>',
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js
CHANGED
|
@@ -1,40 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { paramCase, pascalCase } = require("change-case");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
params: ({ args }) => {
|
|
6
|
+
const documentModel = JSON.parse(args.documentModel);
|
|
7
|
+
const latestSpec =
|
|
8
|
+
documentModel.specifications[documentModel.specifications.length - 1];
|
|
9
|
+
const filteredModules = latestSpec.modules.filter(
|
|
10
|
+
(m) => m.name === args.module,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const actions =
|
|
14
|
+
filteredModules.length > 0
|
|
15
|
+
? filteredModules[0].operations.map((a) => ({
|
|
16
|
+
name: a.name,
|
|
17
|
+
hasInput: a.schema !== null,
|
|
18
|
+
hasAttachment: a.schema?.includes(": Attachment"),
|
|
19
|
+
scope: a.scope || "global",
|
|
20
|
+
state: a.scope === "global" ? "" : a.scope, // the state this action affects
|
|
21
|
+
errors: a.errors,
|
|
22
|
+
}))
|
|
23
|
+
: [];
|
|
24
|
+
|
|
25
|
+
const errors = actions.reduce((acc, action) => {
|
|
26
|
+
action.errors.forEach((error) => {
|
|
27
|
+
// Fallback: If error code is empty, generate it from the error name in PascalCase
|
|
28
|
+
const errorCode = error.code || pascalCase(error.name || "");
|
|
29
|
+
const normalizedError = { ...error, code: errorCode };
|
|
30
|
+
|
|
31
|
+
const existingError = acc.find((e) => e.code === errorCode);
|
|
32
|
+
if (!existingError) {
|
|
33
|
+
acc.push(normalizedError);
|
|
34
|
+
} else if (
|
|
35
|
+
JSON.stringify(existingError) !== JSON.stringify(normalizedError)
|
|
36
|
+
) {
|
|
37
|
+
console.warn(
|
|
38
|
+
`Warning: Duplicate error code "${errorCode}" with different fields found`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return acc;
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
const documentType = documentModel.name;
|
|
46
|
+
const pascalCaseDocumentType = pascalCase(documentType);
|
|
47
|
+
const phDocumentTypeName = `${pascalCaseDocumentType}Document`;
|
|
48
|
+
const isPhDocumentOfTypeFunctionName = `is${phDocumentTypeName}`;
|
|
49
|
+
const assertIsPhDocumentOfTypeFunctionName = `assertIs${phDocumentTypeName}`;
|
|
50
|
+
const paramCaseDocumentType = paramCase(documentType);
|
|
51
|
+
const packageName = args.packageName;
|
|
52
|
+
const documentModelDir = `${packageName}/document-models/${paramCaseDocumentType}`;
|
|
53
|
+
return {
|
|
54
|
+
rootDir: args.rootDir,
|
|
55
|
+
documentType: documentModel.name,
|
|
56
|
+
module: paramCase(args.module),
|
|
57
|
+
actions,
|
|
58
|
+
errors,
|
|
59
|
+
pascalCaseDocumentType,
|
|
60
|
+
paramCaseDocumentType,
|
|
61
|
+
packageName,
|
|
62
|
+
documentModelDir,
|
|
63
|
+
phDocumentTypeName,
|
|
64
|
+
isPhDocumentOfTypeFunctionName,
|
|
65
|
+
assertIsPhDocumentOfTypeFunctionName,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
39
68
|
};
|
|
40
|
-
//# sourceMappingURL=index.js.map
|