@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/README.md
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
// @ts-check
|
|
3
2
|
const generateCustomSubgraph = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
params: ({ args }) => {
|
|
4
|
+
return {
|
|
5
|
+
rootDir: args.rootDir,
|
|
6
|
+
subgraph: args.subgraph,
|
|
7
|
+
};
|
|
8
|
+
},
|
|
10
9
|
};
|
|
11
|
-
exports
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
10
|
+
module.exports = generateCustomSubgraph;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/actions.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
<% modules.forEach(module => { _%>
|
|
6
|
-
import type { <%= h.changeCase.pascal(documentType) %><%= h.changeCase.pascal(module.name) %>Action } from './<%= module.name %>/actions.js';
|
|
6
|
+
import type { <%= h.changeCase.pascal(documentType) %><%= h.changeCase.pascal(module.name) %>Action } from './<%= h.changeCase.param(module.name) %>/actions.js';
|
|
7
7
|
<% }); _%>
|
|
8
8
|
|
|
9
9
|
<% modules.forEach(module => { _%>
|
|
10
|
-
export * from './<%= module.name %>/actions.js';
|
|
10
|
+
export * from './<%= h.changeCase.param(module.name) %>/actions.js';
|
|
11
11
|
<% }); _%>
|
|
12
12
|
|
|
13
13
|
export <%= 'type ' + h.changeCase.pascal(documentType) %>Action =
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/creators.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<% modules.forEach(module => { _%>
|
|
7
|
-
export * from
|
|
7
|
+
export * from "./<%= h.changeCase.param(module.name) %>/creators.js";
|
|
8
|
+
export * as <%= h.changeCase.camel(module.name) %>Actions from "./<%= h.changeCase.param(module.name) %>/creators.js";
|
|
8
9
|
<% }); _%>
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-models.esm.t
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
force: true
|
|
3
|
+
to: "<%= rootDir %>/document-models.ts"
|
|
4
|
+
---
|
|
5
|
+
import type { DocumentModelModule } from "document-model";
|
|
6
|
+
<% moduleExports.forEach(me => { _%>
|
|
7
|
+
import { <%= me.pascalCaseName %> } from "./<%= me.paramCaseName %>/module.js";
|
|
8
|
+
<% }); _%>
|
|
9
|
+
|
|
10
|
+
export const documentModels: DocumentModelModule<any>[] = [
|
|
11
|
+
<% moduleExports.forEach(me => { _%>
|
|
12
|
+
<%= me.pascalCaseName %>,
|
|
13
|
+
<% }); _%>
|
|
14
|
+
]
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/document-schema.esm.t
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/document-schema.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import {
|
|
6
|
+
BaseDocumentHeaderSchema,
|
|
7
|
+
BaseDocumentStateSchema,
|
|
8
|
+
} from "document-model";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { <%= documentTypeVariableName %> } from "./document-type.js";
|
|
11
|
+
import { <%= stateSchemaName %> } from "./schema/zod.js";
|
|
12
|
+
import type { <%= phDocumentTypeName %>, <%= phStateName %> } from "./types.js";
|
|
13
|
+
|
|
14
|
+
/** Schema for validating the header object of a <%= pascalCaseDocumentType %> document */
|
|
15
|
+
export const <%= phDocumentTypeName %>HeaderSchema = BaseDocumentHeaderSchema.extend({
|
|
16
|
+
documentType: z.literal(<%= documentTypeVariableName %>),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/** Schema for validating the state object of a <%= pascalCaseDocumentType %> document */
|
|
20
|
+
export const <%= phStateName %>Schema = BaseDocumentStateSchema.extend({
|
|
21
|
+
global: <%= stateSchemaName %>(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const <%= phDocumentSchemaName %> = z.object({
|
|
25
|
+
header: <%= phDocumentTypeName %>HeaderSchema,
|
|
26
|
+
state: <%= phStateName %>Schema,
|
|
27
|
+
initialState: <%= phStateName %>Schema,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/** Simple helper function to check if a state object is a <%= pascalCaseDocumentType %> document state object */
|
|
31
|
+
export function <%= isPhStateOfTypeFunctionName %>(
|
|
32
|
+
state: unknown,
|
|
33
|
+
): state is <%= phStateName %> {
|
|
34
|
+
return <%= phStateName %>Schema.safeParse(state).success;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Simple helper function to assert that a document state object is a <%= pascalCaseDocumentType %> document state object */
|
|
38
|
+
export function <%= assertIsPhStateOfTypeFunctionName %>(
|
|
39
|
+
state: unknown,
|
|
40
|
+
): asserts state is <%= phStateName %> {
|
|
41
|
+
<%= phStateName %>Schema.parse(state);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Simple helper function to check if a document is a <%= pascalCaseDocumentType %> document */
|
|
45
|
+
export function <%= isPhDocumentOfTypeFunctionName %>(
|
|
46
|
+
document: unknown,
|
|
47
|
+
): document is <%= phDocumentTypeName %> {
|
|
48
|
+
return <%= phDocumentSchemaName %>.safeParse(document).success;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Simple helper function to assert that a document is a <%= pascalCaseDocumentType %> document */
|
|
52
|
+
export function <%= assertIsPhDocumentOfTypeFunctionName %>(
|
|
53
|
+
document: unknown,
|
|
54
|
+
): asserts document is <%= phDocumentTypeName %> {
|
|
55
|
+
<%= phDocumentSchemaName %>.parse(document);
|
|
56
|
+
}
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModel.esm.t
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/document-model.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import type {
|
|
5
|
+
import type { DocumentModelGlobalState } from "document-model";
|
|
6
6
|
|
|
7
|
-
export const documentModel:
|
|
7
|
+
export const documentModel: DocumentModelGlobalState = <%- documentModel %>;
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModelTest.esm.t
CHANGED
|
@@ -1,26 +1,121 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/src/tests/document-model.test.ts"
|
|
3
3
|
unless_exists: true
|
|
4
4
|
---
|
|
5
5
|
/**
|
|
6
6
|
* This is a scaffold file meant for customization:
|
|
7
7
|
* - change it by adding new tests or modifying the existing ones
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* This is a scaffold file meant for customization:
|
|
11
|
+
* - change it by adding new tests or modifying the existing ones
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, it, expect } from "vitest";
|
|
15
|
+
import {
|
|
16
|
+
utils,
|
|
17
|
+
initialGlobalState,
|
|
18
|
+
initialLocalState,
|
|
19
|
+
<%= documentTypeVariableName %>,
|
|
20
|
+
<%= isPhDocumentOfTypeFunctionName %>,
|
|
21
|
+
<%= assertIsPhDocumentOfTypeFunctionName %>,
|
|
22
|
+
<%= isPhStateOfTypeFunctionName %>,
|
|
23
|
+
<%= assertIsPhStateOfTypeFunctionName %>,
|
|
24
|
+
} from "<%= documentModelDir %>";
|
|
25
|
+
import { ZodError } from "zod";
|
|
26
|
+
|
|
27
|
+
describe("<%= pascalCaseDocumentType %> Document Model", () => {
|
|
28
|
+
it("should create a new <%= pascalCaseDocumentType %> document", () => {
|
|
29
|
+
const document = utils.createDocument();
|
|
30
|
+
|
|
31
|
+
expect(document).toBeDefined();
|
|
32
|
+
expect(document.header.documentType).toBe(<%= documentTypeVariableName %>);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should create a new <%= pascalCaseDocumentType %> document with a valid initial state", () => {
|
|
36
|
+
const document = utils.createDocument();
|
|
37
|
+
expect(document.state.global).toStrictEqual(initialGlobalState);
|
|
38
|
+
expect(document.state.local).toStrictEqual(initialLocalState);
|
|
39
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(document)).toBe(true);
|
|
40
|
+
expect(<%= isPhStateOfTypeFunctionName %>(document.state)).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
it("should reject a document that is not a <%= pascalCaseDocumentType %> document", () => {
|
|
43
|
+
const wrongDocumentType = utils.createDocument();
|
|
44
|
+
wrongDocumentType.header.documentType = "the-wrong-thing-1234";
|
|
45
|
+
try {
|
|
46
|
+
expect(<%= assertIsPhDocumentOfTypeFunctionName %>(wrongDocumentType)).toThrow();
|
|
47
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(wrongDocumentType)).toBe(false);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const wrongState = utils.createDocument();
|
|
53
|
+
// @ts-expect-error - we are testing the error case
|
|
54
|
+
wrongState.state.global = {
|
|
55
|
+
...{ notWhat: "you want" },
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
expect(<%= isPhStateOfTypeFunctionName %>(wrongState.state)).toBe(false);
|
|
59
|
+
expect(<%= assertIsPhStateOfTypeFunctionName %>(wrongState.state)).toThrow();
|
|
60
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(wrongState)).toBe(false);
|
|
61
|
+
expect(<%= assertIsPhDocumentOfTypeFunctionName %>(wrongState)).toThrow();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const wrongInitialState = utils.createDocument();
|
|
67
|
+
// @ts-expect-error - we are testing the error case
|
|
68
|
+
wrongInitialState.initialState.global = {
|
|
69
|
+
...{ notWhat: "you want" },
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
expect(<%= isPhStateOfTypeFunctionName %>(wrongInitialState.state)).toBe(false);
|
|
73
|
+
expect(<%= assertIsPhStateOfTypeFunctionName %>(wrongInitialState.state)).toThrow();
|
|
74
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(wrongInitialState)).toBe(false);
|
|
75
|
+
expect(<%= assertIsPhDocumentOfTypeFunctionName %>(wrongInitialState)).toThrow();
|
|
76
|
+
} catch (error) {
|
|
77
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
78
|
+
}
|
|
9
79
|
|
|
10
|
-
|
|
11
|
-
|
|
80
|
+
const missingIdInHeader = utils.createDocument();
|
|
81
|
+
// @ts-expect-error - we are testing the error case
|
|
82
|
+
delete missingIdInHeader.header.id;
|
|
83
|
+
try {
|
|
84
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(missingIdInHeader)).toBe(false);
|
|
85
|
+
expect(<%= assertIsPhDocumentOfTypeFunctionName %>(missingIdInHeader)).toThrow();
|
|
86
|
+
} catch (error) {
|
|
87
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
88
|
+
}
|
|
12
89
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
90
|
+
const missingNameInHeader = utils.createDocument();
|
|
91
|
+
// @ts-expect-error - we are testing the error case
|
|
92
|
+
delete missingNameInHeader.header.name;
|
|
93
|
+
try {
|
|
94
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(missingNameInHeader)).toBe(false);
|
|
95
|
+
expect(<%= assertIsPhDocumentOfTypeFunctionName %>(missingNameInHeader)).toThrow();
|
|
96
|
+
} catch (error) {
|
|
97
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
98
|
+
}
|
|
16
99
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
100
|
+
const missingCreatedAtUtcIsoInHeader = utils.createDocument();
|
|
101
|
+
// @ts-expect-error - we are testing the error case
|
|
102
|
+
delete missingCreatedAtUtcIsoInHeader.header.createdAtUtcIso;
|
|
103
|
+
try {
|
|
104
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(missingCreatedAtUtcIsoInHeader)).toBe(false);
|
|
105
|
+
expect(<%= assertIsPhDocumentOfTypeFunctionName %>(missingCreatedAtUtcIsoInHeader)).toThrow();
|
|
106
|
+
} catch (error) {
|
|
107
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
108
|
+
}
|
|
20
109
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
110
|
+
const missingLastModifiedAtUtcIsoInHeader = utils.createDocument();
|
|
111
|
+
// @ts-expect-error - we are testing the error case
|
|
112
|
+
delete missingLastModifiedAtUtcIsoInHeader.header.lastModifiedAtUtcIso;
|
|
113
|
+
try {
|
|
114
|
+
expect(<%= isPhDocumentOfTypeFunctionName %>(missingLastModifiedAtUtcIsoInHeader)).toBe(false);
|
|
115
|
+
expect(
|
|
116
|
+
<%= assertIsPhDocumentOfTypeFunctionName %>(missingLastModifiedAtUtcIsoInHeader),
|
|
117
|
+
).toThrow();
|
|
118
|
+
} catch (error) {
|
|
119
|
+
expect(error).toBeInstanceOf(ZodError);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/hooks.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import type { DocumentDispatch } from "@powerhousedao/reactor-browser";
|
|
7
|
+
import {
|
|
8
|
+
useDocumentsInSelectedDrive,
|
|
9
|
+
useDocumentsInSelectedFolder,
|
|
10
|
+
useDocumentById,
|
|
11
|
+
useSelectedDocument,
|
|
12
|
+
} from "@powerhousedao/reactor-browser";
|
|
13
|
+
import type {
|
|
14
|
+
<%= phDocumentTypeName %>,
|
|
15
|
+
<%= actionTypeName %>,
|
|
16
|
+
} from "<%= documentModelDir %>";
|
|
17
|
+
import { <%= isPhDocumentOfTypeFunctionName %> } from "./gen/document-schema.js";
|
|
18
|
+
|
|
19
|
+
/** Hook to get a <%= pascalCaseDocumentType %> document by its id */
|
|
20
|
+
export function <%= useByIdHookName %>(
|
|
21
|
+
documentId: string | null | undefined,
|
|
22
|
+
):
|
|
23
|
+
| [<%= phDocumentTypeName %>, DocumentDispatch<<%= actionTypeName %>>]
|
|
24
|
+
| [undefined, undefined] {
|
|
25
|
+
const [document, dispatch] = useDocumentById(documentId);
|
|
26
|
+
if (!<%= isPhDocumentOfTypeFunctionName %>(document)) return [undefined, undefined];
|
|
27
|
+
return [document, dispatch];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Hook to get the selected <%= pascalCaseDocumentType %> document */
|
|
31
|
+
export function <%= useSelectedHookName %>():
|
|
32
|
+
| [<%= phDocumentTypeName %>, DocumentDispatch<<%= actionTypeName %>>]
|
|
33
|
+
| [undefined, undefined] {
|
|
34
|
+
const [document, dispatch] = useSelectedDocument();
|
|
35
|
+
if (!<%= isPhDocumentOfTypeFunctionName %>(document)) return [undefined, undefined];
|
|
36
|
+
return [document, dispatch];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Hook to get all <%= pascalCaseDocumentType %> documents in the selected drive */
|
|
40
|
+
export function <%= useInSelectedDriveHookName %>() {
|
|
41
|
+
const documentsInSelectedDrive = useDocumentsInSelectedDrive();
|
|
42
|
+
return documentsInSelectedDrive?.filter(<%= isPhDocumentOfTypeFunctionName %>);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Hook to get all <%= pascalCaseDocumentType %> documents in the selected folder */
|
|
46
|
+
export function <%= useInSelectedFolderHookName %>() {
|
|
47
|
+
const documentsInSelectedFolder = useDocumentsInSelectedFolder();
|
|
48
|
+
return documentsInSelectedFolder?.filter(<%= isPhDocumentOfTypeFunctionName %>);
|
|
49
|
+
}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
---
|
|
2
|
-
to: "<%= rootDir %>/<%=
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/gen/index.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
5
|
export * from './actions.js';
|
|
6
6
|
export * from './document-model.js';
|
|
7
|
-
export * from './object.js';
|
|
8
7
|
export * from './types.js';
|
|
9
|
-
export *
|
|
10
|
-
export type { <%= h.changeCase.pascal(documentType) %>PHState } from './ph-factories.js';
|
|
8
|
+
export * from './creators.js';
|
|
11
9
|
export {
|
|
12
|
-
create<%=
|
|
10
|
+
create<%= phDocumentTypeName %>,
|
|
13
11
|
createState,
|
|
14
12
|
defaultPHState,
|
|
15
13
|
defaultGlobalState,
|
|
16
14
|
defaultLocalState,
|
|
17
|
-
} from './ph-factories.js';
|
|
15
|
+
} from './ph-factories.js';
|
|
16
|
+
export * from "./utils.js";
|
|
17
|
+
export * from "./reducer.js";
|
|
18
|
+
export * from "./schema/index.js";
|
|
19
|
+
export * from "./document-type.js";
|
|
20
|
+
export * from "./document-schema.js";
|
|
21
|
+
<% modules.forEach(module => { _%>
|
|
22
|
+
export * from './<%= h.changeCase.param(module.name) %>/operations.js';
|
|
23
|
+
<% }); _%>
|
|
@@ -1,63 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { paramCase, pascalCase, camelCase } = require("change-case");
|
|
3
|
+
const { getModuleExports } = require("../utils.js");
|
|
4
4
|
function documentModelToString(documentModel) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
exports.default = {
|
|
25
|
-
params: ({ args, }) => {
|
|
26
|
-
const documentModel = JSON.parse(args.documentModel);
|
|
27
|
-
const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
28
|
-
return {
|
|
29
|
-
rootDir: args.rootDir,
|
|
30
|
-
documentModel: documentModelToString(documentModel),
|
|
31
|
-
documentTypeId: documentModel.id,
|
|
32
|
-
documentType: documentModel.name,
|
|
33
|
-
extension: documentModel.extension,
|
|
34
|
-
modules: latestSpec.modules.map((m) => ({
|
|
35
|
-
...m,
|
|
36
|
-
name: (0, change_case_1.paramCase)(m.name),
|
|
37
|
-
})),
|
|
38
|
-
fileExtension: documentModel.extension,
|
|
39
|
-
hasLocalSchema: latestSpec.state.local.schema !== "",
|
|
40
|
-
...getInitialStates(latestSpec.state),
|
|
41
|
-
};
|
|
5
|
+
return JSON.stringify(
|
|
6
|
+
{
|
|
7
|
+
...documentModel,
|
|
8
|
+
specifications: documentModel.specifications.map((s) => ({
|
|
9
|
+
...s,
|
|
10
|
+
state: Object.keys(s.state).reduce((values, scope) => {
|
|
11
|
+
const state = s.state[scope];
|
|
12
|
+
return {
|
|
13
|
+
...values,
|
|
14
|
+
[scope]: {
|
|
15
|
+
...state,
|
|
16
|
+
// initial value has to be stringified twice
|
|
17
|
+
// as it is expected to be a string
|
|
18
|
+
initialValue: JSON.stringify(state.initialValue),
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}, {}),
|
|
22
|
+
})),
|
|
42
23
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
null,
|
|
25
|
+
2,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
params: ({ args }) => {
|
|
31
|
+
const documentModel = JSON.parse(args.documentModel);
|
|
32
|
+
const latestSpec =
|
|
33
|
+
documentModel.specifications[documentModel.specifications.length - 1];
|
|
34
|
+
const documentType = documentModel.name;
|
|
35
|
+
const documentTypeId = documentModel.id;
|
|
36
|
+
const rootDir = args.rootDir;
|
|
37
|
+
const paramCaseDocumentType = paramCase(documentType);
|
|
38
|
+
const pascalCaseDocumentType = pascalCase(documentType);
|
|
39
|
+
const camelCaseDocumentType = camelCase(documentType);
|
|
40
|
+
const documentTypeVariableName = `${camelCaseDocumentType}DocumentType`;
|
|
41
|
+
const stateName = `${pascalCaseDocumentType}State`;
|
|
42
|
+
const globalStateName = `${pascalCaseDocumentType}GlobalState`;
|
|
43
|
+
const localStateName = `${pascalCaseDocumentType}LocalState`;
|
|
44
|
+
const phStateName = `${pascalCaseDocumentType}PHState`;
|
|
45
|
+
const phDocumentTypeName = `${pascalCaseDocumentType}Document`;
|
|
46
|
+
const actionTypeName = `${pascalCaseDocumentType}Action`;
|
|
47
|
+
const actionsTypeName = `${actionTypeName}s`;
|
|
48
|
+
const actionsName = camelCase(actionsTypeName);
|
|
49
|
+
const packageName = args.packageName;
|
|
50
|
+
const documentModelDir = `${packageName}/document-models/${paramCaseDocumentType}`;
|
|
51
|
+
const stateSchemaName = `${stateName}Schema`;
|
|
52
|
+
const phDocumentSchemaName = `${phDocumentTypeName}Schema`;
|
|
53
|
+
const isPhStateOfTypeFunctionName = `is${stateName}`;
|
|
54
|
+
const assertIsPhStateOfTypeFunctionName = `assertIs${stateName}`;
|
|
55
|
+
const isPhDocumentOfTypeFunctionName = `is${phDocumentTypeName}`;
|
|
56
|
+
const assertIsPhDocumentOfTypeFunctionName = `assertIs${phDocumentTypeName}`;
|
|
57
|
+
const useByIdHookName = `use${phDocumentTypeName}ById`;
|
|
58
|
+
const useSelectedHookName = `useSelected${phDocumentTypeName}`;
|
|
59
|
+
const useInSelectedDriveHookName = `use${phDocumentTypeName}sInSelectedDrive`;
|
|
60
|
+
const useInSelectedFolderHookName = `use${phDocumentTypeName}sInSelectedFolder`;
|
|
61
|
+
const moduleExports = getModuleExports(
|
|
62
|
+
rootDir,
|
|
63
|
+
/export\s+const\s+(\w+)\s*:\s*DocumentModelModule\s*<[^>]*>\s*=/,
|
|
64
|
+
{
|
|
65
|
+
paramCaseName: paramCaseDocumentType,
|
|
66
|
+
pascalCaseName: pascalCaseDocumentType,
|
|
67
|
+
},
|
|
68
|
+
);
|
|
52
69
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
rootDir,
|
|
71
|
+
packageName,
|
|
72
|
+
useByIdHookName,
|
|
73
|
+
useSelectedHookName,
|
|
74
|
+
useInSelectedDriveHookName,
|
|
75
|
+
useInSelectedFolderHookName,
|
|
76
|
+
documentModel: documentModelToString(documentModel),
|
|
77
|
+
documentTypeVariableName,
|
|
78
|
+
documentTypeId,
|
|
79
|
+
documentType,
|
|
80
|
+
camelCaseDocumentType,
|
|
81
|
+
paramCaseDocumentType,
|
|
82
|
+
pascalCaseDocumentType,
|
|
83
|
+
stateName,
|
|
84
|
+
globalStateName,
|
|
85
|
+
localStateName,
|
|
86
|
+
phDocumentTypeName,
|
|
87
|
+
phStateName,
|
|
88
|
+
actionTypeName,
|
|
89
|
+
actionsTypeName,
|
|
90
|
+
actionsName,
|
|
91
|
+
stateSchemaName,
|
|
92
|
+
phDocumentSchemaName,
|
|
93
|
+
isPhDocumentOfTypeFunctionName,
|
|
94
|
+
assertIsPhDocumentOfTypeFunctionName,
|
|
95
|
+
isPhStateOfTypeFunctionName,
|
|
96
|
+
assertIsPhStateOfTypeFunctionName,
|
|
97
|
+
documentModelDir,
|
|
98
|
+
extension: documentModel.extension,
|
|
99
|
+
modules: latestSpec.modules.map((m) => ({
|
|
100
|
+
...m,
|
|
101
|
+
name: paramCase(m.name),
|
|
102
|
+
})),
|
|
103
|
+
moduleExports,
|
|
104
|
+
fileExtension: documentModel.extension || "",
|
|
105
|
+
hasLocalSchema: latestSpec.state.local.schema !== "",
|
|
106
|
+
...getInitialStates(latestSpec.state),
|
|
55
107
|
};
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
function getInitialStates(scopeState) {
|
|
112
|
+
const { global, local } = scopeState;
|
|
113
|
+
const scopes = { global, local };
|
|
114
|
+
|
|
115
|
+
Object.entries(scopes).forEach(([scope, state]) => {
|
|
116
|
+
if (!isEmptyStateSchema(state.schema) && state.initialValue === "") {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`${
|
|
119
|
+
scope.charAt(0).toLocaleUpperCase() + scope.slice(1)
|
|
120
|
+
} scope has a defined schema but is missing an initial value.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
initialGlobalState: handleEmptyState(global.initialValue),
|
|
127
|
+
initialLocalState: handleEmptyState(local.initialValue),
|
|
128
|
+
};
|
|
56
129
|
}
|
|
130
|
+
|
|
57
131
|
function isEmptyStateSchema(schema) {
|
|
58
|
-
|
|
132
|
+
return schema === "" || !schema.includes("{");
|
|
59
133
|
}
|
|
134
|
+
|
|
60
135
|
function handleEmptyState(state) {
|
|
61
|
-
|
|
136
|
+
return state === "" ? "{}" : state;
|
|
62
137
|
}
|
|
63
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
to: "<%= rootDir %>/index.ts"
|
|
3
|
-
|
|
3
|
+
force: true
|
|
4
4
|
---
|
|
5
5
|
/**
|
|
6
6
|
* This is a scaffold file meant for customization.
|
|
7
7
|
* Delete the file and run the code generator again to have it reset
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
<% moduleExports.forEach(me => { _%>
|
|
10
|
+
export { <%= me.pascalCaseName %> } from "./<%= me.paramCaseName %>/module.js";
|
|
11
|
+
<% }); _%>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= paramCaseDocumentType %>/module.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import type { DocumentModelModule } from "document-model";
|
|
6
|
+
import { createState } from "document-model";
|
|
7
|
+
import { defaultBaseState } from "document-model/core";
|
|
8
|
+
import type { <%= phStateName %> } from "<%= documentModelDir %>";
|
|
9
|
+
import {
|
|
10
|
+
actions,
|
|
11
|
+
documentModel,
|
|
12
|
+
reducer,
|
|
13
|
+
utils,
|
|
14
|
+
} from "<%= documentModelDir %>";
|
|
15
|
+
|
|
16
|
+
/** Document model module for the Todo List document type */
|
|
17
|
+
export const <%= pascalCaseDocumentType %>: DocumentModelModule<<%= phStateName %>> = {
|
|
18
|
+
reducer,
|
|
19
|
+
actions,
|
|
20
|
+
utils,
|
|
21
|
+
documentModel: createState(defaultBaseState(), documentModel),
|
|
22
|
+
};
|