sonamu 0.4.14 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +15 -0
- package/dist/api/base-frame.d.ts +8 -0
- package/dist/api/base-frame.d.ts.map +1 -0
- package/dist/api/base-frame.js +2 -0
- package/dist/api/base-frame.js.map +1 -0
- package/dist/api/caster.d.ts +5 -0
- package/dist/api/caster.d.ts.map +1 -0
- package/dist/api/caster.js +2 -0
- package/dist/api/caster.js.map +1 -0
- package/dist/api/code-converters.d.ts +23 -0
- package/dist/api/code-converters.d.ts.map +1 -0
- package/dist/api/code-converters.js +2 -0
- package/dist/api/code-converters.js.map +1 -0
- package/dist/api/context.d.ts +16 -0
- package/dist/api/context.d.ts.map +1 -0
- package/dist/api/context.js +2 -0
- package/dist/api/context.js.map +1 -0
- package/dist/api/decorators.d.ts +50 -0
- package/dist/api/decorators.d.ts.map +1 -0
- package/dist/api/decorators.js +2 -0
- package/dist/api/decorators.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/sonamu.d.ts +83 -0
- package/dist/api/sonamu.d.ts.map +1 -0
- package/dist/api/sonamu.js +2 -0
- package/dist/api/sonamu.js.map +1 -0
- package/dist/api/sonamu.types.d.ts +30 -0
- package/dist/api/sonamu.types.d.ts.map +1 -0
- package/dist/api/sonamu.types.js +2 -0
- package/dist/api/sonamu.types.js.map +1 -0
- package/dist/bin/build-config.d.ts +5 -0
- package/dist/bin/build-config.d.ts.map +1 -0
- package/dist/bin/build-config.js +2 -0
- package/dist/bin/build-config.js.map +1 -0
- package/dist/bin/cli-wrapper.d.ts +2 -0
- package/dist/bin/cli-wrapper.d.ts.map +1 -0
- package/dist/bin/cli-wrapper.js +1 -38
- package/dist/bin/cli-wrapper.js.map +1 -1
- package/dist/bin/cli.d.ts +2 -2
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +1 -903
- package/dist/bin/cli.js.map +1 -1
- package/dist/database/_batch_update.d.ts +15 -0
- package/dist/database/_batch_update.d.ts.map +1 -0
- package/dist/database/_batch_update.js +2 -0
- package/dist/database/_batch_update.js.map +1 -0
- package/dist/database/base-model.d.ts +41 -0
- package/dist/database/base-model.d.ts.map +1 -0
- package/dist/database/base-model.js +2 -0
- package/dist/database/base-model.js.map +1 -0
- package/dist/database/code-generator.d.ts +13 -0
- package/dist/database/code-generator.d.ts.map +1 -0
- package/dist/database/code-generator.js +2 -0
- package/dist/database/code-generator.js.map +1 -0
- package/dist/database/db.d.ts +40 -0
- package/dist/database/db.d.ts.map +1 -0
- package/dist/database/db.js +2 -0
- package/dist/database/db.js.map +1 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts +2 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts.map +1 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.js +2 -0
- package/dist/database/knex-plugins/knex-on-duplicate-update.js.map +1 -0
- package/dist/database/puri-wrapper.d.ts +34 -0
- package/dist/database/puri-wrapper.d.ts.map +1 -0
- package/dist/database/puri-wrapper.js +2 -0
- package/dist/database/puri-wrapper.js.map +1 -0
- package/dist/database/puri.d.ts +83 -0
- package/dist/database/puri.d.ts.map +1 -0
- package/dist/database/puri.js +2 -0
- package/dist/database/puri.js.map +1 -0
- package/dist/database/puri.types.d.ts +60 -0
- package/dist/database/puri.types.d.ts.map +1 -0
- package/dist/database/puri.types.js +2 -0
- package/dist/database/puri.types.js.map +1 -0
- package/dist/database/transaction-context.d.ts +9 -0
- package/dist/database/transaction-context.d.ts.map +1 -0
- package/dist/database/transaction-context.js +2 -0
- package/dist/database/transaction-context.js.map +1 -0
- package/dist/database/types.d.ts +39 -0
- package/dist/database/types.d.ts.map +1 -0
- package/dist/database/types.js +2 -0
- package/dist/database/types.js.map +1 -0
- package/dist/database/upsert-builder.d.ts +34 -0
- package/dist/database/upsert-builder.d.ts.map +1 -0
- package/dist/database/upsert-builder.js +2 -0
- package/dist/database/upsert-builder.js.map +1 -0
- package/dist/entity/entity-manager.d.ts +32 -0
- package/dist/entity/entity-manager.d.ts.map +1 -0
- package/dist/entity/entity-manager.js +2 -0
- package/dist/entity/entity-manager.js.map +1 -0
- package/dist/entity/entity-utils.d.ts +61 -0
- package/dist/entity/entity-utils.d.ts.map +1 -0
- package/dist/entity/entity-utils.js +2 -0
- package/dist/entity/entity-utils.js.map +1 -0
- package/dist/entity/entity.d.ts +62 -0
- package/dist/entity/entity.d.ts.map +1 -0
- package/dist/entity/entity.js +2 -0
- package/dist/entity/entity.js.map +1 -0
- package/dist/entity/migrator.d.ts +135 -0
- package/dist/entity/migrator.d.ts.map +1 -0
- package/dist/entity/migrator.js +2 -0
- package/dist/entity/migrator.js.map +1 -0
- package/dist/exceptions/error-handler.d.ts +3 -0
- package/dist/exceptions/error-handler.d.ts.map +1 -0
- package/dist/exceptions/error-handler.js +2 -0
- package/dist/exceptions/error-handler.js.map +1 -0
- package/dist/exceptions/so-exceptions.d.ts +48 -0
- package/dist/exceptions/so-exceptions.d.ts.map +1 -0
- package/dist/exceptions/so-exceptions.js +2 -0
- package/dist/exceptions/so-exceptions.js.map +1 -0
- package/dist/file-storage/driver.d.ts +45 -0
- package/dist/file-storage/driver.d.ts.map +1 -0
- package/dist/file-storage/driver.js +2 -0
- package/dist/file-storage/driver.js.map +1 -0
- package/dist/file-storage/file-storage.d.ts +50 -0
- package/dist/file-storage/file-storage.d.ts.map +1 -0
- package/dist/file-storage/file-storage.js +2 -0
- package/dist/file-storage/file-storage.js.map +1 -0
- package/dist/index.d.ts +22 -813
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -433
- package/dist/index.js.map +1 -1
- package/dist/migration/code-generation.d.ts +15 -0
- package/dist/migration/code-generation.d.ts.map +1 -0
- package/dist/migration/code-generation.js +2 -0
- package/dist/migration/code-generation.js.map +1 -0
- package/dist/migration/migration-set.d.ts +17 -0
- package/dist/migration/migration-set.d.ts.map +1 -0
- package/dist/migration/migration-set.js +2 -0
- package/dist/migration/migration-set.js.map +1 -0
- package/dist/migration/migrator.d.ts +130 -0
- package/dist/migration/migrator.d.ts.map +1 -0
- package/dist/migration/migrator.js +2 -0
- package/dist/migration/migrator.js.map +1 -0
- package/dist/migration/types.d.ts +52 -0
- package/dist/migration/types.d.ts.map +1 -0
- package/dist/migration/types.js +2 -0
- package/dist/migration/types.js.map +1 -0
- package/dist/smd/smd-manager.d.ts +28 -0
- package/dist/smd/smd-manager.d.ts.map +1 -0
- package/dist/smd/smd-manager.js +2 -0
- package/dist/smd/smd-manager.js.map +1 -0
- package/dist/smd/smd.d.ts +40 -0
- package/dist/smd/smd.d.ts.map +1 -0
- package/dist/smd/smd.js +2 -0
- package/dist/smd/smd.js.map +1 -0
- package/dist/syncer/index.d.ts +2 -0
- package/dist/syncer/index.d.ts.map +1 -0
- package/dist/syncer/index.js +2 -0
- package/dist/syncer/index.js.map +1 -0
- package/dist/syncer/syncer.d.ts +127 -0
- package/dist/syncer/syncer.d.ts.map +1 -0
- package/dist/syncer/syncer.js +2 -0
- package/dist/syncer/syncer.js.map +1 -0
- package/dist/templates/base-template.d.ts +13 -0
- package/dist/templates/base-template.d.ts.map +1 -0
- package/dist/templates/base-template.js +2 -0
- package/dist/templates/base-template.js.map +1 -0
- package/dist/templates/entity.template.d.ts +17 -0
- package/dist/templates/entity.template.d.ts.map +1 -0
- package/dist/templates/entity.template.js +2 -0
- package/dist/templates/entity.template.js.map +1 -0
- package/dist/templates/generated.template.d.ts +27 -0
- package/dist/templates/generated.template.d.ts.map +1 -0
- package/dist/templates/generated.template.js +2 -0
- package/dist/templates/generated.template.js.map +1 -0
- package/dist/templates/generated_http.template.d.ts +24 -0
- package/dist/templates/generated_http.template.d.ts.map +1 -0
- package/dist/templates/generated_http.template.js +2 -0
- package/dist/templates/generated_http.template.js.map +1 -0
- package/dist/templates/generated_sso.template.d.ts +20 -0
- package/dist/templates/generated_sso.template.d.ts.map +1 -0
- package/dist/templates/generated_sso.template.js +2 -0
- package/dist/templates/generated_sso.template.js.map +1 -0
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +2 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/init_types.template.d.ts +17 -0
- package/dist/templates/init_types.template.d.ts.map +1 -0
- package/dist/templates/init_types.template.js +2 -0
- package/dist/templates/init_types.template.js.map +1 -0
- package/dist/templates/model.template.d.ts +17 -0
- package/dist/templates/model.template.d.ts.map +1 -0
- package/dist/templates/model.template.js +2 -0
- package/dist/templates/model.template.js.map +1 -0
- package/dist/templates/model_test.template.d.ts +17 -0
- package/dist/templates/model_test.template.d.ts.map +1 -0
- package/dist/templates/model_test.template.js +2 -0
- package/dist/templates/model_test.template.js.map +1 -0
- package/dist/templates/service.template.d.ts +29 -0
- package/dist/templates/service.template.d.ts.map +1 -0
- package/dist/templates/service.template.js +2 -0
- package/dist/templates/service.template.js.map +1 -0
- package/dist/templates/view_enums_buttonset.template.d.ts +17 -0
- package/dist/templates/view_enums_buttonset.template.d.ts.map +1 -0
- package/dist/templates/view_enums_buttonset.template.js +2 -0
- package/dist/templates/view_enums_buttonset.template.js.map +1 -0
- package/dist/templates/view_enums_dropdown.template.d.ts +18 -0
- package/dist/templates/view_enums_dropdown.template.d.ts.map +1 -0
- package/dist/templates/view_enums_dropdown.template.js +2 -0
- package/dist/templates/view_enums_dropdown.template.js.map +1 -0
- package/dist/templates/view_enums_select.template.d.ts +17 -0
- package/dist/templates/view_enums_select.template.d.ts.map +1 -0
- package/dist/templates/view_enums_select.template.js +2 -0
- package/dist/templates/view_enums_select.template.js.map +1 -0
- package/dist/templates/view_form.template.d.ts +26 -0
- package/dist/templates/view_form.template.d.ts.map +1 -0
- package/dist/templates/view_form.template.js +2 -0
- package/dist/templates/view_form.template.js.map +1 -0
- package/dist/templates/view_id_all_select.template.d.ts +17 -0
- package/dist/templates/view_id_all_select.template.d.ts.map +1 -0
- package/dist/templates/view_id_all_select.template.js +2 -0
- package/dist/templates/view_id_all_select.template.js.map +1 -0
- package/dist/templates/view_id_async_select.template.d.ts +17 -0
- package/dist/templates/view_id_async_select.template.d.ts.map +1 -0
- package/dist/templates/view_id_async_select.template.js +2 -0
- package/dist/templates/view_id_async_select.template.js.map +1 -0
- package/dist/templates/view_list.template.d.ts +38 -0
- package/dist/templates/view_list.template.d.ts.map +1 -0
- package/dist/templates/view_list.template.js +2 -0
- package/dist/templates/view_list.template.js.map +1 -0
- package/dist/templates/view_list_columns.template.d.ts +17 -0
- package/dist/templates/view_list_columns.template.d.ts.map +1 -0
- package/dist/templates/view_list_columns.template.js +2 -0
- package/dist/templates/view_list_columns.template.js.map +1 -0
- package/dist/templates/view_search_input.template.d.ts +17 -0
- package/dist/templates/view_search_input.template.d.ts.map +1 -0
- package/dist/templates/view_search_input.template.js +2 -0
- package/dist/templates/view_search_input.template.js.map +1 -0
- package/dist/testing/_relation-graph.d.ts +7 -0
- package/dist/testing/_relation-graph.d.ts.map +1 -0
- package/dist/testing/_relation-graph.js +2 -0
- package/dist/testing/_relation-graph.js.map +1 -0
- package/dist/testing/fixture-manager.d.ts +35 -0
- package/dist/testing/fixture-manager.d.ts.map +1 -0
- package/dist/testing/fixture-manager.js +2 -0
- package/dist/testing/fixture-manager.js.map +1 -0
- package/dist/types/types.d.ts +609 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/typings/knex.d.js +2 -0
- package/dist/typings/knex.d.js.map +1 -0
- package/dist/utils/async-utils.d.ts +25 -0
- package/dist/utils/async-utils.d.ts.map +1 -0
- package/dist/utils/async-utils.js +2 -0
- package/dist/utils/async-utils.js.map +1 -0
- package/dist/utils/controller.d.ts +9 -0
- package/dist/utils/controller.d.ts.map +1 -0
- package/dist/utils/controller.js +2 -0
- package/dist/utils/controller.js.map +1 -0
- package/dist/utils/fs-utils.d.ts +9 -0
- package/dist/utils/fs-utils.d.ts.map +1 -0
- package/dist/utils/fs-utils.js +2 -0
- package/dist/utils/fs-utils.js.map +1 -0
- package/dist/utils/lodash-able.d.ts +2 -0
- package/dist/utils/lodash-able.d.ts.map +1 -0
- package/dist/utils/lodash-able.js +2 -0
- package/dist/utils/lodash-able.js.map +1 -0
- package/dist/utils/model.d.ts +17 -0
- package/dist/utils/model.d.ts.map +1 -0
- package/dist/utils/model.js +2 -0
- package/dist/utils/model.js.map +1 -0
- package/dist/utils/sql-parser.d.ts +4 -0
- package/dist/utils/sql-parser.d.ts.map +1 -0
- package/dist/utils/sql-parser.js +2 -0
- package/dist/utils/sql-parser.js.map +1 -0
- package/dist/utils/utils.d.ts +9 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +2 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist/utils/zod-error.d.ts +8 -0
- package/dist/utils/zod-error.d.ts.map +1 -0
- package/dist/utils/zod-error.js +2 -0
- package/dist/utils/zod-error.js.map +1 -0
- package/nodemon.json +6 -0
- package/package.json +29 -44
- package/src/api/base-frame.ts +3 -4
- package/src/api/caster.ts +22 -23
- package/src/api/code-converters.ts +170 -134
- package/src/api/context.ts +13 -6
- package/src/api/decorators.ts +146 -20
- package/src/api/index.ts +2 -0
- package/src/api/sonamu.ts +374 -165
- package/src/bin/build-config.ts +5 -0
- package/src/bin/cli-wrapper.ts +29 -40
- package/src/bin/cli.ts +132 -190
- package/src/database/_batch_update.ts +10 -15
- package/src/database/base-model.ts +300 -216
- package/src/database/db.ts +191 -21
- package/src/database/{drivers/knex/plugins → knex-plugins}/knex-on-duplicate-update.ts +1 -1
- package/src/database/puri-wrapper.ts +129 -0
- package/src/database/puri.ts +808 -0
- package/src/database/puri.types.ts +222 -0
- package/src/database/transaction-context.ts +18 -0
- package/src/database/upsert-builder.ts +32 -35
- package/src/entity/entity-manager.ts +7 -15
- package/src/entity/entity.ts +9 -31
- package/src/entity/migrator-/354/235/264/354/202/254/352/260/224/354/226/264/354/232/224.md +1 -0
- package/src/file-storage/driver.ts +121 -0
- package/src/file-storage/file-storage.ts +100 -0
- package/src/index.ts +14 -11
- package/src/migration/code-generation.ts +777 -0
- package/src/migration/migration-set.ts +453 -0
- package/src/migration/migrator.ts +823 -0
- package/src/migration/types.ts +53 -0
- package/src/shared/web.shared.ts.txt +33 -2
- package/src/syncer/syncer.ts +294 -127
- package/src/templates/generated.template.ts +13 -1
- package/src/templates/generated_http.template.ts +15 -12
- package/src/templates/generated_sso.template.ts +50 -2
- package/src/templates/model.template.ts +138 -2
- package/src/templates/service.template.ts +0 -1
- package/src/templates/view_form.template.ts +11 -7
- package/src/templates/view_list.template.ts +12 -4
- package/src/testing/fixture-manager.ts +229 -174
- package/src/types/types.ts +102 -14
- package/src/utils/async-utils.ts +64 -0
- package/src/utils/fs-utils.ts +17 -0
- package/src/utils/model.ts +0 -2
- package/src/utils/utils.ts +14 -58
- package/src/utils/zod-error.ts +12 -176
- package/tsconfig.json +2 -0
- package/tsup.config.js +4 -2
- package/.pnp.cjs +0 -14363
- package/.pnp.loader.mjs +0 -2047
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -9
- package/.yarnrc.yml +0 -5
- package/src/database/base-model.abstract.ts +0 -97
- package/src/database/db.abstract.ts +0 -75
- package/src/database/drivers/knex/base-model.ts +0 -55
- package/src/database/drivers/knex/client.ts +0 -209
- package/src/database/drivers/knex/db.ts +0 -232
- package/src/database/drivers/knex/generator.ts +0 -659
- package/src/database/drivers/kysely/base-model.ts +0 -89
- package/src/database/drivers/kysely/client.ts +0 -309
- package/src/database/drivers/kysely/db.ts +0 -238
- package/src/database/drivers/kysely/generator.ts +0 -714
- package/src/database/types.ts +0 -118
- package/src/entity/migrator.ts +0 -1400
- package/src/smd/smd-manager.ts +0 -139
- package/src/smd/smd.ts +0 -571
- package/src/templates/kysely_types.template.ts +0 -205
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/generated_sso.template.ts"],"sourcesContent":["import {\n isManyToManyRelationProp,\n SubsetQuery,\n TemplateOptions,\n} from \"../types/types\";\nimport { EntityManager } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport inflection from \"inflection\";\nimport { SourceCode } from \"./generated.template\";\nimport _ from \"lodash\";\nimport { nonNullable } from \"../utils/utils\";\nimport { Sonamu } from \"../api\";\nimport { Entity } from \"../entity/entity\";\n\nexport class Template__generated_sso extends Template {\n constructor() {\n super(\"generated_sso\");\n }\n\n getTargetAndPath() {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `sonamu.generated.sso.ts`,\n };\n }\n\n render({}: TemplateOptions[\"generated_sso\"]) {\n const entityIds = EntityManager.getAllIds();\n const entities = entityIds.map((id) => EntityManager.get(id));\n\n const sourceCodes: SourceCode[] = entities\n .map((entity) => {\n if (\n entity.parentId !== undefined ||\n Object.keys(entity.subsets).length === 0\n ) {\n return null;\n }\n const subsetKeys = Object.keys(entity.subsets);\n const subsetQueryObject = subsetKeys.reduce(\n (r, subsetKey) => {\n const subsetQuery = entity.getSubsetQuery(subsetKey);\n r[subsetKey] = subsetQuery;\n return r;\n },\n {} as {\n [key: string]: SubsetQuery;\n }\n );\n\n const subsetKeyTypeName = `${entity.names.module}SubsetKey`;\n return {\n label: `SubsetQuery: ${entity.id}`,\n lines: [\n `export const ${inflection.camelize(\n entity.id,\n true\n )}SubsetQueries:{ [key in ${subsetKeyTypeName}]: SubsetQuery} = ${JSON.stringify(\n subsetQueryObject\n )};`,\n \"\",\n ],\n importKeys: [subsetKeyTypeName],\n };\n })\n .filter(nonNullable);\n\n // DatabaseSchema 생성\n const dbSchemaSourceCode = this.getDatabaseSchemaSourceCode(entities);\n if (dbSchemaSourceCode) {\n sourceCodes.push(dbSchemaSourceCode);\n }\n\n const sourceCode = sourceCodes.reduce(\n (result, ts) => {\n if (ts === null) {\n return result;\n }\n return {\n lines: [...result!.lines, `// ${ts.label}`, ...ts.lines, \"\"],\n importKeys: _.uniq([...result!.importKeys, ...ts.importKeys]),\n };\n },\n {\n lines: [],\n importKeys: [],\n } as Omit<SourceCode, \"label\">\n );\n\n return {\n ...this.getTargetAndPath(),\n body: sourceCode.lines.join(\"\\n\"),\n importKeys: sourceCode.importKeys,\n customHeaders: [\n `import { SubsetQuery, ManyToManyBaseSchema } from \"sonamu\";`,\n ],\n };\n }\n\n getDatabaseSchemaSourceCode(entities: Entity[]): SourceCode | null {\n if (entities.length === 0) {\n return null;\n }\n\n const entitySchemaLines = entities.map(\n (entity) => `${entity.table}: ${entity.id}BaseSchema;`\n );\n\n const joinTableSchemaLines = _.uniq(\n entities.flatMap((entity) =>\n entity.props.filter(isManyToManyRelationProp).map((prop) => {\n const fromTableKey = inflection.singularize(entity.table);\n const toTableKey = inflection.singularize(\n EntityManager.get(prop.with).table\n );\n return `${prop.joinTable}: ManyToManyBaseSchema<\"${fromTableKey}\", \"${toTableKey}\">;`;\n })\n )\n );\n\n return {\n label: `DatabaseSchema`,\n lines: [\n `declare module \"sonamu\" {`,\n ` export interface DatabaseSchemaExtend {`,\n ...entitySchemaLines,\n ...joinTableSchemaLines,\n ` }`,\n `}`,\n ],\n importKeys: entities.map((entity) => `${entity.id}BaseSchema`),\n };\n }\n}\n"],"names":["Template__generated_sso","getTargetAndPath","dir","Sonamu","config","api","target","path","render","entityIds","EntityManager","getAllIds","entities","map","id","get","sourceCodes","entity","parentId","undefined","Object","keys","subsets","length","subsetKeys","subsetQueryObject","reduce","r","subsetKey","subsetQuery","getSubsetQuery","subsetKeyTypeName","names","module","label","lines","inflection","camelize","JSON","stringify","importKeys","filter","nonNullable","dbSchemaSourceCode","getDatabaseSchemaSourceCode","push","sourceCode","result","ts","_","uniq","body","join","customHeaders","entitySchemaLines","table","joinTableSchemaLines","flatMap","props","isManyToManyRelationProp","prop","fromTableKey","singularize","toTableKey","with","joinTable","Template"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./base-template"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/index.ts"],"sourcesContent":["export * from \"./base-template\";\n"],"names":[],"mappings":"2FAAc"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__init_types extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
render({ entityId }: TemplateOptions["init_types"]): {
|
|
11
|
+
body: string;
|
|
12
|
+
importKeys: never[];
|
|
13
|
+
target: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=init_types.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init_types.template.d.ts","sourceRoot":"","sources":["../../src/templates/init_types.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,oBAAqB,SAAQ,QAAQ;;IAKhD,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IASzC,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,CAAC,YAAY,CAAC;;;;;;CA4BnD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__init_types",{enumerable:true,get:function(){return Template__init_types}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _api=require("../api");function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__init_types=/*#__PURE__*/function(Template){"use strict";_inherits(Template__init_types,Template);function Template__init_types(){_class_call_check(this,Template__init_types);return _call_super(this,Template__init_types,["init_types"])}_create_class(Template__init_types,[{key:"getTargetAndPath",value:function getTargetAndPath(names){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"".concat(names.fs,"/").concat(names.fs,".types.ts")}}},{key:"render",value:function render(param){var entityId=param.entityId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);var hasCreatedAt=_entitymanager.EntityManager.get(entityId).props.find(function(prop){return prop.name==="created_at"})!==undefined;return _object_spread_props(_object_spread({},this.getTargetAndPath(names)),{body:'\nimport { z } from "zod";\nimport { '.concat(entityId,"BaseSchema, ").concat(entityId,'BaseListParams } from "../sonamu.generated";\n\n// ').concat(entityId," - ListParams\nexport const ").concat(entityId,"ListParams = ").concat(entityId,"BaseListParams;\nexport type ").concat(entityId,"ListParams = z.infer<typeof ").concat(entityId,"ListParams>;\n\n// ").concat(entityId," - SaveParams\nexport const ").concat(entityId,"SaveParams = ").concat(entityId,"BaseSchema.partial({ id: true").concat(hasCreatedAt?", created_at: true":""," });\nexport type ").concat(entityId,"SaveParams = z.infer<typeof ").concat(entityId,"SaveParams>;\n\n ").trim(),importKeys:[]})}}]);return Template__init_types}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=init_types.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/init_types.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport { Sonamu } from \"../api\";\n\nexport class Template__init_types extends Template {\n constructor() {\n super(\"init_types\");\n }\n\n getTargetAndPath(names: EntityNamesRecord) {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `${names.fs}/${names.fs}.types.ts`,\n };\n }\n\n render({ entityId }: TemplateOptions[\"init_types\"]) {\n const names = EntityManager.getNamesFromId(entityId);\n\n const hasCreatedAt =\n EntityManager.get(entityId).props.find(\n (prop) => prop.name === \"created_at\"\n ) !== undefined;\n\n return {\n ...this.getTargetAndPath(names),\n body: `\nimport { z } from \"zod\";\nimport { ${entityId}BaseSchema, ${entityId}BaseListParams } from \"../sonamu.generated\";\n\n// ${entityId} - ListParams\nexport const ${entityId}ListParams = ${entityId}BaseListParams;\nexport type ${entityId}ListParams = z.infer<typeof ${entityId}ListParams>;\n\n// ${entityId} - SaveParams\nexport const ${entityId}SaveParams = ${entityId}BaseSchema.partial({ id: true${\n hasCreatedAt ? \", created_at: true\" : \"\"\n } });\nexport type ${entityId}SaveParams = z.infer<typeof ${entityId}SaveParams>;\n\n `.trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__init_types","getTargetAndPath","names","dir","Sonamu","config","api","target","path","fs","render","entityId","EntityManager","getNamesFromId","hasCreatedAt","get","props","find","prop","name","undefined","body","trim","importKeys","Template"],"mappings":"oGAKaA,8DAAAA,mDAJoC,sDACxB,oCACF,g7GAEhB,IAAA,AAAMA,kCAAN,0CAAMA,wCAAAA,8CAAAA,sBAET,OAAA,iBAFSA,sBAEH,6BAFGA,uBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,EACvC,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,AAAC,GAAcN,OAAZA,MAAMO,EAAE,CAAC,KAAY,OAATP,MAAMO,EAAE,CAAC,YAChC,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAA2C,MAA3C,AAAEC,SAAF,MAAEA,SACP,IAAMT,MAAQU,4BAAa,CAACC,cAAc,CAACF,UAE3C,IAAMG,aACJF,4BAAa,CAACG,GAAG,CAACJ,UAAUK,KAAK,CAACC,IAAI,CACpC,SAACC,aAASA,KAAKC,IAAI,GAAK,iBACpBC,UAER,OAAO,uCACF,IAAI,CAACnB,gBAAgB,CAACC,SACzBmB,KAAM,AAAC,wCAEqBV,OAAvBA,SAAS,gBAEfA,OAF6BA,SAAS,uDAG5BA,OADVA,SAAS,gCACyBA,OAAxBA,SAAS,iBACVA,OADyBA,SAAS,iCACKA,OAAvCA,SAAS,gCAElBA,OAFgDA,SAAS,uBAG/CA,OADVA,SAAS,gCACyBA,OAAxBA,SAAS,iBAChBG,OAD+BH,SAAS,iCAGlCA,OAFNG,aAAe,qBAAuB,GACvC,sBAC8CH,OAAvCA,SAAS,gCAAuC,OAATA,SAAS,0BAEtDW,IAAI,GACNC,WAAY,EAAE,EAElB,YAzCWvB,sBAA6BwB,sBAAQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RenderingNode, TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__model extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
render({ entityId }: TemplateOptions["model"], _columnsNode: RenderingNode, listParamsNode: RenderingNode): {
|
|
11
|
+
body: string;
|
|
12
|
+
importKeys: never[];
|
|
13
|
+
target: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=model.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.template.d.ts","sourceRoot":"","sources":["../../src/templates/model.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,qBAAa,eAAgB,SAAQ,QAAQ;;IAK3C,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IASzC,MAAM,CACJ,EAAE,QAAQ,EAAE,EAAE,eAAe,CAAC,OAAO,CAAC,EACtC,YAAY,EAAE,aAAa,EAC3B,cAAc,EAAE,aAAa;;;;;;CAyJhC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__model",{enumerable:true,get:function(){return Template__model}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _view_listtemplate=require("./view_list.template");var _api=require("../api");function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__model=/*#__PURE__*/function(Template){"use strict";_inherits(Template__model,Template);function Template__model(){_class_call_check(this,Template__model);return _call_super(this,Template__model,["model"])}_create_class(Template__model,[{key:"getTargetAndPath",value:function getTargetAndPath(names){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"".concat(names.fs,"/").concat(names.fs,".model.ts")}}},{key:"render",value:function render(param,_columnsNode,listParamsNode){var entityId=param.entityId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);var entity=_entitymanager.EntityManager.get(entityId);var vlTpl=new _view_listtemplate.Template__view_list;if((listParamsNode===null||listParamsNode===void 0?void 0:listParamsNode.children)===undefined){throw new Error("listParamsNode가 없습니다. ".concat(entityId))}var def=vlTpl.getDefault(listParamsNode.children);return _object_spread_props(_object_spread({},this.getTargetAndPath(names)),{body:"\nimport { BaseModelClass, ListResult, asArray, NotFoundException, BadRequestException, api } from 'sonamu';\nimport {\n ".concat(entityId,"SubsetKey,\n ").concat(entityId,'SubsetMapping,\n} from "../sonamu.generated";\nimport {\n ').concat(names.camel,'SubsetQueries,\n} from "../sonamu.generated.sso";\nimport { ').concat(entityId,"ListParams, ").concat(entityId,'SaveParams } from "./').concat(names.fs,'.types";\n\n/*\n ').concat(entityId," Model\n*/\nclass ").concat(entityId,'ModelClass extends BaseModelClass {\n modelName = "').concat(entityId,'";\n\n @api({ httpMethod: "GET", clients: ["axios", "swr"], resourceName: "').concat(entityId,'" })\n async findById<T extends ').concat(entityId,"SubsetKey>(\n subset: T,\n id: number\n ): Promise<").concat(entityId,"SubsetMapping[T]> {\n const { rows } = await this.findMany(subset, {\n id,\n num: 1,\n page: 1,\n });\n if (!rows[0]) {\n throw new NotFoundException(`존재하지 않는 ").concat(names.capital," ID ${id}`);\n }\n\n return rows[0];\n }\n\n async findOne<T extends ").concat(entityId,"SubsetKey>(\n subset: T,\n listParams: ").concat(entityId,"ListParams\n ): Promise<").concat(entityId,'SubsetMapping[T] | null> {\n const { rows } = await this.findMany(subset, {\n ...listParams,\n num: 1,\n page: 1,\n });\n\n return rows[0] ?? null;\n }\n\n @api({ httpMethod: "GET", clients: ["axios", "swr"], resourceName: "').concat(names.capitalPlural,'" })\n async findMany<T extends ').concat(entityId,"SubsetKey>(\n subset: T,\n params: ").concat(entityId,"ListParams = {}\n ): Promise<ListResult<").concat(entityId,'SubsetMapping[T]>> {\n // params with defaults\n params = {\n num: 24,\n page: 1,\n search: "').concat(def.search,'",\n orderBy: "').concat(def.orderBy,'",\n ...params,\n };\n\n // build queries\n let { rows, total } = await this.runSubsetQuery({\n subset,\n params,\n subsetQuery: ').concat(names.camel,'SubsetQueries[subset],\n build: ({ qb }) => {\n // id\n if (params.id) {\n qb.whereIn("').concat(entity.table,'.id", asArray(params.id));\n }\n\n // search-keyword\n if (params.search && params.keyword && params.keyword.length > 0) {\n if (params.search === "id") {\n qb.where("').concat(entity.table,'.id", params.keyword);\n // } else if (params.search === "field") {\n // qb.where("').concat(entity.table,'.field", "like", `%${params.keyword}%`);\n } else {\n throw new BadRequestException(\n `구현되지 않은 검색 필드 ${params.search}`\n );\n }\n }\n\n // orderBy\n if (params.orderBy) {\n // default orderBy\n const [orderByField, orderByDirec] = params.orderBy.split("-");\n qb.orderBy("').concat(entity.table,'." + orderByField, orderByDirec);\n }\n\n return qb;\n },\n debug: false,\n });\n\n return {\n rows,\n total,\n };\n }\n\n @api({ httpMethod: "POST" })\n async save(\n spa: ').concat(entityId,'SaveParams[]\n ): Promise<number[]> {\n const wdb = this.getPuri("w");\n\n // register\n spa.map((sp) => {\n wdb.ubRegister("').concat(entity.table,'", sp);\n });\n\n // transaction\n return wdb.transaction(async (trx) => {\n const ids = await trx.ubUpsert("').concat(entity.table,'");\n\n return ids;\n });\n }\n\n @api({ httpMethod: "POST", guards: [ "admin" ] })\n async del(ids: number[]): Promise<number> {\n const wdb = this.getPuri("w");\n\n // transaction\n await wdb.transaction(async (trx) => {\n return trx.table("').concat(entity.table,'").whereIn("').concat(entity.table,'.id", ids).delete();\n });\n\n return ids.length;\n }\n}\n\nexport const ').concat(entityId,"Model = new ").concat(entityId,"ModelClass();\n ").trim(),importKeys:[]})}}]);return Template__model}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=model.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/model.template.ts"],"sourcesContent":["import { RenderingNode, TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport { Template__view_list } from \"./view_list.template\";\nimport { Sonamu } from \"../api\";\n\nexport class Template__model extends Template {\n constructor() {\n super(\"model\");\n }\n\n getTargetAndPath(names: EntityNamesRecord) {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `${names.fs}/${names.fs}.model.ts`,\n };\n }\n\n render(\n { entityId }: TemplateOptions[\"model\"],\n _columnsNode: RenderingNode,\n listParamsNode: RenderingNode\n ) {\n const names = EntityManager.getNamesFromId(entityId);\n const entity = EntityManager.get(entityId);\n\n const vlTpl = new Template__view_list();\n if (listParamsNode?.children === undefined) {\n throw new Error(`listParamsNode가 없습니다. ${entityId}`);\n }\n const def = vlTpl.getDefault(listParamsNode.children);\n\n return {\n ...this.getTargetAndPath(names),\n body: `\nimport { BaseModelClass, ListResult, asArray, NotFoundException, BadRequestException, api } from 'sonamu';\nimport {\n ${entityId}SubsetKey,\n ${entityId}SubsetMapping,\n} from \"../sonamu.generated\";\nimport {\n ${names.camel}SubsetQueries,\n} from \"../sonamu.generated.sso\";\nimport { ${entityId}ListParams, ${entityId}SaveParams } from \"./${names.fs}.types\";\n\n/*\n ${entityId} Model\n*/\nclass ${entityId}ModelClass extends BaseModelClass {\n modelName = \"${entityId}\";\n\n @api({ httpMethod: \"GET\", clients: [\"axios\", \"swr\"], resourceName: \"${entityId}\" })\n async findById<T extends ${entityId}SubsetKey>(\n subset: T,\n id: number\n ): Promise<${entityId}SubsetMapping[T]> {\n const { rows } = await this.findMany(subset, {\n id,\n num: 1,\n page: 1,\n });\n if (!rows[0]) {\n throw new NotFoundException(\\`존재하지 않는 ${names.capital} ID \\${id}\\`);\n }\n\n return rows[0];\n }\n\n async findOne<T extends ${entityId}SubsetKey>(\n subset: T,\n listParams: ${entityId}ListParams\n ): Promise<${entityId}SubsetMapping[T] | null> {\n const { rows } = await this.findMany(subset, {\n ...listParams,\n num: 1,\n page: 1,\n });\n\n return rows[0] ?? null;\n }\n\n @api({ httpMethod: \"GET\", clients: [\"axios\", \"swr\"], resourceName: \"${names.capitalPlural}\" })\n async findMany<T extends ${entityId}SubsetKey>(\n subset: T,\n params: ${entityId}ListParams = {}\n ): Promise<ListResult<${entityId}SubsetMapping[T]>> {\n // params with defaults\n params = {\n num: 24,\n page: 1,\n search: \"${def.search}\",\n orderBy: \"${def.orderBy}\",\n ...params,\n };\n\n // build queries\n let { rows, total } = await this.runSubsetQuery({\n subset,\n params,\n subsetQuery: ${names.camel}SubsetQueries[subset],\n build: ({ qb }) => {\n // id\n if (params.id) {\n qb.whereIn(\"${entity.table}.id\", asArray(params.id));\n }\n\n // search-keyword\n if (params.search && params.keyword && params.keyword.length > 0) {\n if (params.search === \"id\") {\n qb.where(\"${entity.table}.id\", params.keyword);\n // } else if (params.search === \"field\") {\n // qb.where(\"${entity.table}.field\", \"like\", \\`%\\${params.keyword}%\\`);\n } else {\n throw new BadRequestException(\n \\`구현되지 않은 검색 필드 \\${params.search}\\`\n );\n }\n }\n\n // orderBy\n if (params.orderBy) {\n // default orderBy\n const [orderByField, orderByDirec] = params.orderBy.split(\"-\");\n qb.orderBy(\"${entity.table}.\" + orderByField, orderByDirec);\n }\n\n return qb;\n },\n debug: false,\n });\n\n return {\n rows,\n total,\n };\n }\n\n @api({ httpMethod: \"POST\" })\n async save(\n spa: ${entityId}SaveParams[]\n ): Promise<number[]> {\n const wdb = this.getPuri(\"w\");\n\n // register\n spa.map((sp) => {\n wdb.ubRegister(\"${entity.table}\", sp);\n });\n\n // transaction\n return wdb.transaction(async (trx) => {\n const ids = await trx.ubUpsert(\"${entity.table}\");\n\n return ids;\n });\n }\n\n @api({ httpMethod: \"POST\", guards: [ \"admin\" ] })\n async del(ids: number[]): Promise<number> {\n const wdb = this.getPuri(\"w\");\n\n // transaction\n await wdb.transaction(async (trx) => {\n return trx.table(\"${entity.table}\").whereIn(\"${entity.table}.id\", ids).delete();\n });\n\n return ids.length;\n }\n}\n\nexport const ${entityId}Model = new ${entityId}ModelClass();\n `.trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__model","getTargetAndPath","names","dir","Sonamu","config","api","target","path","fs","render","_columnsNode","listParamsNode","entityId","EntityManager","getNamesFromId","entity","get","vlTpl","Template__view_list","children","undefined","Error","def","getDefault","body","camel","capital","capitalPlural","search","orderBy","table","trim","importKeys","Template"],"mappings":"oGAMaA,yDAAAA,8CALoC,sDACxB,kDACW,yCACb,g7GAEhB,IAAA,AAAMA,6BAAN,0CAAMA,mCAAAA,yCAAAA,iBAET,OAAA,iBAFSA,iBAEH,wBAFGA,kBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,EACvC,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,AAAC,GAAcN,OAAZA,MAAMO,EAAE,CAAC,KAAY,OAATP,MAAMO,EAAE,CAAC,YAChC,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OACE,KAAsC,CACtCC,YAA2B,CAC3BC,cAA6B,MAF7B,AAAEC,SAAF,MAAEA,SAIF,IAAMX,MAAQY,4BAAa,CAACC,cAAc,CAACF,UAC3C,IAAMG,OAASF,4BAAa,CAACG,GAAG,CAACJ,UAEjC,IAAMK,MAAQ,IAAIC,sCAAmB,CACrC,GAAIP,CAAAA,uBAAAA,+BAAAA,eAAgBQ,QAAQ,IAAKC,UAAW,CAC1C,MAAM,IAAIC,MAAM,AAAC,yBAAiC,OAATT,UAC3C,CACA,IAAMU,IAAML,MAAMM,UAAU,CAACZ,eAAeQ,QAAQ,EAEpD,OAAO,uCACF,IAAI,CAACnB,gBAAgB,CAACC,SACzBuB,KAAM,AAAC,6HAITZ,OADAA,SAAS,kBAITX,OAHAW,SAAS,+DAKFA,OAFPX,MAAMwB,KAAK,CAAC,gEAEkBb,OAAvBA,SAAS,gBAA8CX,OAAhCW,SAAS,yBAGvCA,OAH8DX,MAAMO,EAAE,CAAC,sBAKnEI,OAFJA,SAAS,sBAGIA,OADTA,SAAS,wDAGuDA,OAFvDA,SAAS,gFAGGA,OAD2CA,SAAS,qCAIlEA,OAHcA,SAAS,8DAUQX,OAP/BW,SAAS,gMAaIA,OANkBX,MAAMyB,OAAO,CAAC,iFAQ1Cd,OAFUA,SAAS,iDAGtBA,OADGA,SAAS,6BAW6CX,OAVzDW,SAAS,8PAWKA,OAD2CX,MAAM0B,aAAa,CAAC,qCAG9Ef,OAFeA,SAAS,6CAGZA,OADZA,SAAS,6CAMNU,OALSV,SAAS,sHAMjBU,OADDA,IAAIM,MAAM,CAAC,wBASP3B,OARHqB,IAAIO,OAAO,CAAC,kKAYNd,OAJHd,MAAMwB,KAAK,CAAC,uHAUTV,OANAA,OAAOe,KAAK,CAAC,oNAQVf,OAFHA,OAAOe,KAAK,CAAC,2GAcbf,OAZGA,OAAOe,KAAK,CAAC,0XA4B7BlB,OAhBaG,OAAOe,KAAK,CAAC,kOAsBbf,OANbH,SAAS,gJAWoBG,OALhBA,OAAOe,KAAK,CAAC,+HAiBXf,OAZcA,OAAOe,KAAK,CAAC,gRAYAf,OAA3BA,OAAOe,KAAK,CAAC,gBAOxBlB,OAPsCG,OAAOe,KAAK,CAAC,oFAO5BlB,OAAvBA,SAAS,gBAAuB,OAATA,SAAS,yBACvCmB,IAAI,GACNC,WAAY,EAAE,EAElB,YAzKWjC,iBAAwBkC,sBAAQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__model_test extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
render({ entityId }: TemplateOptions["model_test"]): {
|
|
11
|
+
body: string;
|
|
12
|
+
importKeys: never[];
|
|
13
|
+
target: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=model_test.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model_test.template.d.ts","sourceRoot":"","sources":["../../src/templates/model_test.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,oBAAqB,SAAQ,QAAQ;;IAKhD,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IASzC,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,CAAC,YAAY,CAAC;;;;;;CAmBnD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__model_test",{enumerable:true,get:function(){return Template__model_test}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _api=require("../api");function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__model_test=/*#__PURE__*/function(Template){"use strict";_inherits(Template__model_test,Template);function Template__model_test(){_class_call_check(this,Template__model_test);return _call_super(this,Template__model_test,["model_test"])}_create_class(Template__model_test,[{key:"getTargetAndPath",value:function getTargetAndPath(names){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"".concat(names.fs,"/").concat(names.fs,".model.test.ts")}}},{key:"render",value:function render(param){var entityId=param.entityId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);return _object_spread_props(_object_spread({},this.getTargetAndPath(names)),{body:'\nimport { describe, test, expect } from "vitest";\nimport { bootstrap } from \'../../testing/bootstrap\';\n\nbootstrap([]);\ndescribe.skip("'.concat(entityId,'ModelTest", () => {\n test("Query", async () => {\n expect(true).toBe(true);\n });\n});\n ').trim(),importKeys:[]})}}]);return Template__model_test}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=model_test.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/model_test.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport { Sonamu } from \"../api\";\n\nexport class Template__model_test extends Template {\n constructor() {\n super(\"model_test\");\n }\n\n getTargetAndPath(names: EntityNamesRecord) {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `${names.fs}/${names.fs}.model.test.ts`,\n };\n }\n\n render({ entityId }: TemplateOptions[\"model_test\"]) {\n const names = EntityManager.getNamesFromId(entityId);\n\n return {\n ...this.getTargetAndPath(names),\n body: `\nimport { describe, test, expect } from \"vitest\";\nimport { bootstrap } from '../../testing/bootstrap';\n\nbootstrap([]);\ndescribe.skip(\"${entityId}ModelTest\", () => {\n test(\"Query\", async () => {\n expect(true).toBe(true);\n });\n});\n `.trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__model_test","getTargetAndPath","names","dir","Sonamu","config","api","target","path","fs","render","entityId","EntityManager","getNamesFromId","body","trim","importKeys","Template"],"mappings":"oGAKaA,8DAAAA,mDAJoC,sDACxB,oCACF,g7GAEhB,IAAA,AAAMA,kCAAN,0CAAMA,wCAAAA,8CAAAA,sBAET,OAAA,iBAFSA,sBAEH,6BAFGA,uBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,EACvC,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,AAAC,GAAcN,OAAZA,MAAMO,EAAE,CAAC,KAAY,OAATP,MAAMO,EAAE,CAAC,iBAChC,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAA2C,MAA3C,AAAEC,SAAF,MAAEA,SACP,IAAMT,MAAQU,4BAAa,CAACC,cAAc,CAACF,UAE3C,OAAO,uCACF,IAAI,CAACV,gBAAgB,CAACC,SACzBY,KAAM,AAAC,gJAKa,OAATH,SAAS,wGAKlBI,IAAI,GACNC,WAAY,EAAE,EAElB,YAhCWhB,sBAA6BiB,sBAAQ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { ApiParam } from "../types/types";
|
|
4
|
+
import { ExtendedApi } from "../api/decorators";
|
|
5
|
+
import { Template } from "./base-template";
|
|
6
|
+
export declare class Template__service extends Template {
|
|
7
|
+
constructor();
|
|
8
|
+
getTargetAndPath(names: EntityNamesRecord): {
|
|
9
|
+
target: string;
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
render({ namesRecord }: TemplateOptions["service"], apis: ExtendedApi[]): {
|
|
13
|
+
body: string;
|
|
14
|
+
importKeys: string[];
|
|
15
|
+
customHeaders: string[];
|
|
16
|
+
target: string;
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
getTypeSource(apis: ExtendedApi[]): {
|
|
20
|
+
lines: string[];
|
|
21
|
+
importKeys: string[];
|
|
22
|
+
};
|
|
23
|
+
renderAxios(api: ExtendedApi, apiBaseUrl: string, typeParamsDef: string, paramsDef: string, returnTypeDef: string, payloadDef: string): string;
|
|
24
|
+
renderAxiosMultipart(api: ExtendedApi, apiBaseUrl: string, typeParamsDef: string, paramsDef: string, returnTypeDef: string, paramsWithoutContext: ApiParam[]): string;
|
|
25
|
+
renderSwr(api: ExtendedApi, apiBaseUrl: string, typeParamsDef: string, paramsDef: string, returnTypeDef: string, payloadDef: string): string;
|
|
26
|
+
renderWindowFetch(api: ExtendedApi, apiBaseUrl: string, typeParamsDef: string, paramsDef: string, payloadDef: string): string;
|
|
27
|
+
renderStream(api: ExtendedApi, apiBaseUrl: string, paramsDefAsObject: string): string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=service.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.template.d.ts","sourceRoot":"","sources":["../../src/templates/service.template.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAgB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAQxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,iBAAkB,SAAQ,QAAQ;;IAK7C,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IAOzC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,eAAe,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE;;;;;;;IA2BvE,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG;QAClC,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,UAAU,EAAE,MAAM,EAAE,CAAC;KACtB;IAyHD,WAAW,CACT,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM;IA4BpB,oBAAoB,CAClB,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,QAAQ,EAAE;IA+BlC,SAAS,CACP,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM;IAoBpB,iBAAiB,CACf,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM;IASpB,YAAY,CACV,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM;CAuB5B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__service",{enumerable:true,get:function(){return Template__service}});var _inflection=/*#__PURE__*/_interop_require_default(require("inflection"));var _lodash=/*#__PURE__*/_interop_require_default(require("lodash"));var _types=require("../types/types");var _codeconverters=require("../api/code-converters");var _basetemplate=require("./base-template");var _sonamu=require("../api/sonamu");function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}function _iterable_to_array(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__service=/*#__PURE__*/function(Template){"use strict";_inherits(Template__service,Template);function Template__service(){_class_call_check(this,Template__service);return _call_super(this,Template__service,["service"])}_create_class(Template__service,[{key:"getTargetAndPath",value:function getTargetAndPath(names){return{target:":target/src/services",path:"".concat(names.fs,"/").concat(names.fs,".service.ts")}}},{key:"render",value:function render(param,apis){var namesRecord=param.namesRecord;var _this_getTypeSource=this.getTypeSource(apis),lines=_this_getTypeSource.lines,importKeys=_this_getTypeSource.importKeys;var hasAxiosProgressEvent=apis.find(function(api){var _api_options_clients;return((_api_options_clients=api.options.clients)!==null&&_api_options_clients!==void 0?_api_options_clients:[]).includes("axios-multipart")});return _object_spread_props(_object_spread({},this.getTargetAndPath(namesRecord)),{body:lines.join("\n"),importKeys:importKeys.filter(function(key){return["ListResult"].includes(key)===false}),customHeaders:["import { z } from 'zod';",'import qs from "qs";','import useSWR, { SWRResponse } from "swr";',"import { fetch, ListResult, SWRError, SwrOptions, handleConditional, swrPostFetcher, EventHandlers, SSEStreamOptions, useSSEStream } from '../sonamu.shared';"].concat(_to_consumable_array(hasAxiosProgressEvent?["import { AxiosProgressEvent } from 'axios';"]:[]))})}},{key:"getTypeSource",value:function getTypeSource(apis){var _this=this;var importKeys=[];var typeParamNames=[];var groups=_lodash.default.groupBy(apis,function(api){return api.modelName});var body=Object.keys(groups).map(function(modelName){var methods=groups[modelName];var methodCodes=methods.map(function(api){var paramsWithoutContext=api.parameters.filter(function(param){return!_types.ApiParamType.isContext(param.type)&&!_types.ApiParamType.isRefKnex(param.type)&&!(param.optional===true&¶m.name.startsWith("_"))});var typeParamsDef=api.typeParameters.map(function(typeParam){return(0,_codeconverters.apiParamTypeToTsType)(typeParam,importKeys)}).join(", ");typeParamNames=typeParamNames.concat(api.typeParameters.map(function(typeParam){return typeParam.id}));var paramsDef=(0,_codeconverters.apiParamToTsCode)(paramsWithoutContext,importKeys);var paramsDefAsObject=(0,_codeconverters.apiParamToTsCodeAsObject)(paramsWithoutContext,importKeys);var returnTypeDef=(0,_codeconverters.apiParamTypeToTsType)((0,_codeconverters.unwrapPromiseOnce)(api.returnType),importKeys);var payloadDef="{ ".concat(paramsWithoutContext.map(function(param){return param.name}).join(", ")," }");var apiBaseUrl="".concat(_sonamu.Sonamu.config.route.prefix).concat(api.path);return _to_consumable_array(_lodash.default.sortBy(api.options.clients,function(client){return client==="swr"?0:1}).map(function(client){switch(client){case"axios":return _this.renderAxios(api,apiBaseUrl,typeParamsDef,paramsDef,returnTypeDef,payloadDef);case"axios-multipart":return _this.renderAxiosMultipart(api,apiBaseUrl,typeParamsDef,paramsDef,returnTypeDef,paramsWithoutContext);case"swr":return _this.renderSwr(api,apiBaseUrl,typeParamsDef,paramsDef,returnTypeDef,payloadDef);case"window-fetch":return _this.renderWindowFetch(api,apiBaseUrl,typeParamsDef,paramsDef,payloadDef);default:return"// Not supported ".concat(_inflection.default.camelize(client,true)," yet.")}})).concat(_to_consumable_array(api.streamOptions?[_this.renderStream(api,apiBaseUrl,paramsDefAsObject)]:[])).join("\n")}).join("\n\n");return"export namespace ".concat(modelName.replace(/Model$/,"Service").replace(/Frame$/,"Service")," {\n").concat(methodCodes,"\n}")}).join("\n\n");return{lines:[body],importKeys:_lodash.default.difference(_lodash.default.uniq(importKeys),typeParamNames)}}},{key:"renderAxios",value:function renderAxios(api,apiBaseUrl,typeParamsDef,paramsDef,returnTypeDef,payloadDef){var methodNameAxios=api.options.resourceName?"get"+_inflection.default.camelize(api.options.resourceName):api.methodName;if(api.options.httpMethod==="GET"){return"\nexport async function ".concat(methodNameAxios).concat(typeParamsDef,"(").concat(paramsDef,"): Promise<").concat(returnTypeDef,'> {\n return fetch({\n method: "GET",\n url: `').concat(apiBaseUrl,"?${qs.stringify(").concat(payloadDef,")}`,\n });\n}\n ").trim()}else{return"\nexport async function ".concat(methodNameAxios).concat(typeParamsDef,"(").concat(paramsDef,"): Promise<").concat(returnTypeDef,"> {\n return fetch({\n method: '").concat(api.options.httpMethod,"',\n url: `").concat(apiBaseUrl,"`,\n data: ").concat(payloadDef,",\n });\n}\n ").trim()}}},{key:"renderAxiosMultipart",value:function renderAxiosMultipart(api,apiBaseUrl,typeParamsDef,paramsDef,returnTypeDef,paramsWithoutContext){var formDataDef=['formData.append("file", file);'].concat(_to_consumable_array(paramsWithoutContext.map(function(param){return"formData.append('".concat(param.name,"', String(").concat(param.name,"));")}))).join("\n");var paramsDefComma=paramsDef!==""?", ":"";return"\nexport async function ".concat(api.methodName).concat(typeParamsDef,"(\n ").concat(paramsDef).concat(paramsDefComma,"\n file: File,\n onUploadProgress?: (pe:AxiosProgressEvent) => void\n ): Promise<").concat(returnTypeDef,"> {\n const formData = new FormData();\n ").concat(formDataDef,"\n return fetch({\n method: 'POST',\n url: `").concat(apiBaseUrl,'`,\n headers: {\n "Content-Type": "multipart/form-data",\n },\n onUploadProgress,\n data: formData,\n });\n }\n ').trim()}},{key:"renderSwr",value:function renderSwr(api,apiBaseUrl,typeParamsDef,paramsDef,returnTypeDef,payloadDef){var methodNameSwr=api.options.resourceName?"use"+_inflection.default.camelize(api.options.resourceName):"use"+_inflection.default.camelize(api.methodName);return" export function ".concat(_inflection.default.camelize(methodNameSwr,true)).concat(typeParamsDef,"(").concat([paramsDef,"swrOptions?: SwrOptions"].filter(function(p){return p!==""}).join(","),", ): SWRResponse<").concat(returnTypeDef,", SWRError> {\n return useSWR(handleConditional([\n `").concat(apiBaseUrl,"`,\n ").concat(payloadDef,",\n ], swrOptions?.conditional)").concat(api.options.httpMethod==="POST"?", swrPostFetcher":"",");\n }")}},{key:"renderWindowFetch",value:function renderWindowFetch(api,apiBaseUrl,typeParamsDef,paramsDef,payloadDef){return"\nexport async function ".concat(api.methodName).concat(typeParamsDef,"(").concat(paramsDef,"): Promise<Response> {\n return window.fetch(`").concat(apiBaseUrl,"?${qs.stringify(").concat(payloadDef,")}`);\n}\n ").trim()}},{key:"renderStream",value:function renderStream(api,apiBaseUrl,paramsDefAsObject){if(!api.streamOptions){return"// streamOptions not found"}var methodNameStream=api.options.resourceName?"use"+_inflection.default.camelize(api.options.resourceName):"use"+_inflection.default.camelize(api.methodName);var methodNameStreamCamelized=_inflection.default.camelize(methodNameStream,true);var eventsTypeDef=(0,_codeconverters.zodTypeToTsTypeDef)(api.streamOptions.events);return" export function ".concat(methodNameStreamCamelized,"(\n params: ").concat(paramsDefAsObject,",\n handlers: EventHandlers<").concat(eventsTypeDef," & { end?: () => void }>,\n options: SSEStreamOptions) {\n return useSSEStream<").concat(eventsTypeDef,">(`").concat(apiBaseUrl,"`, params, handlers, options);\n }")}}]);return Template__service}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=service.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/service.template.ts"],"sourcesContent":["import inflection from \"inflection\";\nimport _ from \"lodash\";\nimport { TemplateOptions } from \"../types/types\";\nimport { EntityNamesRecord } from \"../entity/entity-manager\";\nimport { ApiParamType, ApiParam } from \"../types/types\";\nimport {\n apiParamTypeToTsType,\n apiParamToTsCode,\n unwrapPromiseOnce,\n zodTypeToTsTypeDef,\n apiParamToTsCodeAsObject,\n} from \"../api/code-converters\";\nimport { ExtendedApi } from \"../api/decorators\";\nimport { Template } from \"./base-template\";\nimport { Sonamu } from \"../api/sonamu\";\n\nexport class Template__service extends Template {\n constructor() {\n super(\"service\");\n }\n\n getTargetAndPath(names: EntityNamesRecord) {\n return {\n target: \":target/src/services\",\n path: `${names.fs}/${names.fs}.service.ts`,\n };\n }\n\n render({ namesRecord }: TemplateOptions[\"service\"], apis: ExtendedApi[]) {\n // 서비스 TypeSource\n const { lines, importKeys } = this.getTypeSource(apis);\n\n // AxiosProgressEvent 있는지 확인\n const hasAxiosProgressEvent = apis.find((api) =>\n (api.options.clients ?? []).includes(\"axios-multipart\")\n );\n\n return {\n ...this.getTargetAndPath(namesRecord),\n body: lines.join(\"\\n\"),\n importKeys: importKeys.filter(\n (key) => [\"ListResult\"].includes(key) === false\n ),\n customHeaders: [\n `import { z } from 'zod';`,\n `import qs from \"qs\";`,\n `import useSWR, { SWRResponse } from \"swr\";`,\n `import { fetch, ListResult, SWRError, SwrOptions, handleConditional, swrPostFetcher, EventHandlers, SSEStreamOptions, useSSEStream } from '../sonamu.shared';`,\n ...(hasAxiosProgressEvent\n ? [`import { AxiosProgressEvent } from 'axios';`]\n : []),\n ],\n };\n }\n\n getTypeSource(apis: ExtendedApi[]): {\n lines: string[];\n importKeys: string[];\n } {\n const importKeys: string[] = [];\n\n // 제네릭에서 선언한 타입, importKeys에서 제외 필요\n let typeParamNames: string[] = [];\n\n const groups = _.groupBy(apis, (api) => api.modelName);\n const body = Object.keys(groups)\n .map((modelName) => {\n const methods = groups[modelName];\n const methodCodes = methods\n .map((api) => {\n // 컨텍스트 제외된 파라미터 리스트\n const paramsWithoutContext = api.parameters.filter(\n (param) =>\n !ApiParamType.isContext(param.type) &&\n !ApiParamType.isRefKnex(param.type) &&\n !(param.optional === true && param.name.startsWith(\"_\")) // _로 시작하는 파라미터는 제외\n );\n\n // 파라미터 타입 정의\n const typeParamsDef = api.typeParameters\n .map((typeParam) => {\n return apiParamTypeToTsType(typeParam, importKeys);\n })\n .join(\", \");\n typeParamNames = typeParamNames.concat(\n api.typeParameters.map((typeParam) => typeParam.id)\n );\n\n // 파라미터 정의\n const paramsDef = apiParamToTsCode(\n paramsWithoutContext,\n importKeys\n );\n\n // 파라미터 정의 (객체 형태)\n const paramsDefAsObject = apiParamToTsCodeAsObject(\n paramsWithoutContext,\n importKeys\n );\n\n // 리턴 타입 정의\n const returnTypeDef = apiParamTypeToTsType(\n unwrapPromiseOnce(api.returnType),\n importKeys\n );\n\n // 페이로드 데이터 정의\n const payloadDef = `{ ${paramsWithoutContext\n .map((param) => param.name)\n .join(\", \")} }`;\n\n // 기본 URL\n const apiBaseUrl = `${Sonamu.config.route.prefix}${api.path}`;\n\n return [\n // 클라이언트별로 생성\n ..._.sortBy(api.options.clients, (client) =>\n client === \"swr\" ? 0 : 1\n ).map((client) => {\n switch (client) {\n case \"axios\":\n return this.renderAxios(\n api,\n apiBaseUrl,\n typeParamsDef,\n paramsDef,\n returnTypeDef,\n payloadDef\n );\n case \"axios-multipart\":\n return this.renderAxiosMultipart(\n api,\n apiBaseUrl,\n typeParamsDef,\n paramsDef,\n returnTypeDef,\n paramsWithoutContext\n );\n case \"swr\":\n return this.renderSwr(\n api,\n apiBaseUrl,\n typeParamsDef,\n paramsDef,\n returnTypeDef,\n payloadDef\n );\n case \"window-fetch\":\n return this.renderWindowFetch(\n api,\n apiBaseUrl,\n typeParamsDef,\n paramsDef,\n payloadDef\n );\n default:\n return `// Not supported ${inflection.camelize(client, true)} yet.`;\n }\n }),\n // 스트리밍인 경우\n ...(api.streamOptions\n ? [this.renderStream(api, apiBaseUrl, paramsDefAsObject)]\n : []),\n ].join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return `export namespace ${modelName.replace(/Model$/, \"Service\").replace(/Frame$/, \"Service\")} {\n${methodCodes}\n}`;\n })\n .join(\"\\n\\n\");\n\n return {\n lines: [body],\n importKeys: _.difference(_.uniq(importKeys), typeParamNames),\n };\n }\n\n renderAxios(\n api: ExtendedApi,\n apiBaseUrl: string,\n typeParamsDef: string,\n paramsDef: string,\n returnTypeDef: string,\n payloadDef: string\n ) {\n const methodNameAxios = api.options.resourceName\n ? \"get\" + inflection.camelize(api.options.resourceName)\n : api.methodName;\n\n if (api.options.httpMethod === \"GET\") {\n return `\nexport async function ${methodNameAxios}${typeParamsDef}(${paramsDef}): Promise<${returnTypeDef}> {\n return fetch({\n method: \"GET\",\n url: \\`${apiBaseUrl}?\\${qs.stringify(${payloadDef})}\\`,\n });\n}\n `.trim();\n } else {\n return `\nexport async function ${methodNameAxios}${typeParamsDef}(${paramsDef}): Promise<${returnTypeDef}> {\n return fetch({\n method: '${api.options.httpMethod}',\n url: \\`${apiBaseUrl}\\`,\n data: ${payloadDef},\n });\n}\n `.trim();\n }\n }\n\n renderAxiosMultipart(\n api: ExtendedApi,\n apiBaseUrl: string,\n typeParamsDef: string,\n paramsDef: string,\n returnTypeDef: string,\n paramsWithoutContext: ApiParam[]\n ) {\n const formDataDef = [\n 'formData.append(\"file\", file);',\n ...paramsWithoutContext.map(\n (param) => `formData.append('${param.name}', String(${param.name}));`\n ),\n ].join(\"\\n\");\n\n const paramsDefComma = paramsDef !== \"\" ? \", \" : \"\";\n return `\nexport async function ${api.methodName}${typeParamsDef}(\n ${paramsDef}${paramsDefComma}\n file: File,\n onUploadProgress?: (pe:AxiosProgressEvent) => void\n ): Promise<${returnTypeDef}> {\n const formData = new FormData();\n ${formDataDef}\n return fetch({\n method: 'POST',\n url: \\`${apiBaseUrl}\\`,\n headers: {\n \"Content-Type\": \"multipart/form-data\",\n },\n onUploadProgress,\n data: formData,\n });\n }\n `.trim();\n }\n\n renderSwr(\n api: ExtendedApi,\n apiBaseUrl: string,\n typeParamsDef: string,\n paramsDef: string,\n returnTypeDef: string,\n payloadDef: string\n ) {\n const methodNameSwr = api.options.resourceName\n ? \"use\" + inflection.camelize(api.options.resourceName)\n : \"use\" + inflection.camelize(api.methodName);\n return ` export function ${inflection.camelize(\n methodNameSwr,\n true\n )}${typeParamsDef}(${[paramsDef, \"swrOptions?: SwrOptions\"]\n .filter((p) => p !== \"\")\n .join(\",\")}, ): SWRResponse<${returnTypeDef}, SWRError> {\n return useSWR(handleConditional([\n \\`${apiBaseUrl}\\`,\n ${payloadDef},\n ], swrOptions?.conditional)${\n api.options.httpMethod === \"POST\" ? \", swrPostFetcher\" : \"\"\n });\n }`;\n }\n\n renderWindowFetch(\n api: ExtendedApi,\n apiBaseUrl: string,\n typeParamsDef: string,\n paramsDef: string,\n payloadDef: string\n ) {\n return `\nexport async function ${api.methodName}${typeParamsDef}(${paramsDef}): Promise<Response> {\n return window.fetch(\\`${apiBaseUrl}?\\${qs.stringify(${payloadDef})}\\`);\n}\n `.trim();\n }\n\n renderStream(\n api: ExtendedApi,\n apiBaseUrl: string,\n paramsDefAsObject: string\n ) {\n if (!api.streamOptions) {\n return \"// streamOptions not found\";\n }\n\n const methodNameStream = api.options.resourceName\n ? \"use\" + inflection.camelize(api.options.resourceName)\n : \"use\" + inflection.camelize(api.methodName);\n const methodNameStreamCamelized = inflection.camelize(\n methodNameStream,\n true\n );\n\n const eventsTypeDef = zodTypeToTsTypeDef(api.streamOptions.events);\n\n return ` export function ${methodNameStreamCamelized}(\n params: ${paramsDefAsObject},\n handlers: EventHandlers<${eventsTypeDef} & { end?: () => void }>,\n options: SSEStreamOptions) {\n return useSSEStream<${eventsTypeDef}>(\\`${apiBaseUrl}\\`, params, handlers, options);\n }`;\n }\n}\n"],"names":["Template__service","getTargetAndPath","names","target","path","fs","render","apis","namesRecord","getTypeSource","lines","importKeys","hasAxiosProgressEvent","find","api","options","clients","includes","body","join","filter","key","customHeaders","typeParamNames","groups","_","groupBy","modelName","Object","keys","map","methods","methodCodes","paramsWithoutContext","parameters","param","ApiParamType","isContext","type","isRefKnex","optional","name","startsWith","typeParamsDef","typeParameters","typeParam","apiParamTypeToTsType","concat","id","paramsDef","apiParamToTsCode","paramsDefAsObject","apiParamToTsCodeAsObject","returnTypeDef","unwrapPromiseOnce","returnType","payloadDef","apiBaseUrl","Sonamu","config","route","prefix","sortBy","client","renderAxios","renderAxiosMultipart","renderSwr","renderWindowFetch","inflection","camelize","streamOptions","renderStream","replace","difference","uniq","methodNameAxios","resourceName","methodName","httpMethod","trim","formDataDef","paramsDefComma","methodNameSwr","p","methodNameStream","methodNameStreamCamelized","eventsTypeDef","zodTypeToTsTypeDef","events","Template"],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__view_enums_buttonset extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord, componentId: string): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
render({ entityId, enumId }: TemplateOptions["view_enums_buttonset"]): {
|
|
11
|
+
body: string;
|
|
12
|
+
importKeys: never[];
|
|
13
|
+
target: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=view_enums_buttonset.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view_enums_buttonset.template.d.ts","sourceRoot":"","sources":["../../src/templates/view_enums_buttonset.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBAAa,8BAA+B,SAAQ,QAAQ;;IAK1D,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM;;;;IAO9D,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,sBAAsB,CAAC;;;;;;CAiBrE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__view_enums_buttonset",{enumerable:true,get:function(){return Template__view_enums_buttonset}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__view_enums_buttonset=/*#__PURE__*/function(Template){"use strict";_inherits(Template__view_enums_buttonset,Template);function Template__view_enums_buttonset(){_class_call_check(this,Template__view_enums_buttonset);return _call_super(this,Template__view_enums_buttonset,["view_enums_buttonset"])}_create_class(Template__view_enums_buttonset,[{key:"getTargetAndPath",value:function getTargetAndPath(names,componentId){return{target:"web/src/components",path:"".concat(names.fs,"/").concat(componentId,"ButtonSet.tsx")}}},{key:"render",value:function render(param){var entityId=param.entityId,enumId=param.enumId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);return _object_spread_props(_object_spread({},this.getTargetAndPath(names,enumId)),{body:"\n/*\nview_enums_buttonset\n".concat(JSON.stringify({key:this.key,options:entityId}),"\n*/\n ").trim(),importKeys:[]})}}]);return Template__view_enums_buttonset}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=view_enums_buttonset.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/view_enums_buttonset.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\n\nexport class Template__view_enums_buttonset extends Template {\n constructor() {\n super(\"view_enums_buttonset\");\n }\n\n getTargetAndPath(names: EntityNamesRecord, componentId: string) {\n return {\n target: \"web/src/components\",\n path: `${names.fs}/${componentId}ButtonSet.tsx`,\n };\n }\n\n render({ entityId, enumId }: TemplateOptions[\"view_enums_buttonset\"]) {\n const names = EntityManager.getNamesFromId(entityId);\n\n return {\n ...this.getTargetAndPath(names, enumId),\n body: `\n/*\nview_enums_buttonset\n${JSON.stringify({\n key: this.key,\n options: entityId,\n})}\n*/\n `.trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__view_enums_buttonset","getTargetAndPath","names","componentId","target","path","fs","render","entityId","enumId","EntityManager","getNamesFromId","body","JSON","stringify","key","options","trim","importKeys","Template"],"mappings":"oGAIaA,wEAAAA,6DAHoC,sDACxB,y7GAElB,IAAA,AAAMA,4CAAN,0CAAMA,kDAAAA,wDAAAA,gCAET,OAAA,iBAFSA,gCAEH,uCAFGA,iCAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,CAAEC,WAAmB,EAC5D,MAAO,CACLC,OAAQ,qBACRC,KAAM,AAAC,GAAcF,OAAZD,MAAMI,EAAE,CAAC,KAAe,OAAZH,YAAY,gBACnC,CACF,IAEAI,IAAAA,eAAAA,SAAAA,OAAO,KAA6D,MAA3DC,SAAF,MAAEA,SAAUC,OAAZ,MAAYA,OACjB,IAAMP,MAAQQ,4BAAa,CAACC,cAAc,CAACH,UAE3C,OAAO,uCACF,IAAI,CAACP,gBAAgB,CAACC,MAAOO,UAChCG,KAAM,AAAC,+BAMV,OAHDC,KAAKC,SAAS,CAAC,CACfC,IAAK,IAAI,CAACA,GAAG,CACbC,QAASR,QACX,GAAG,gBAEKS,IAAI,GACNC,WAAY,EAAE,EAElB,YA5BWlB,gCAAuCmB,sBAAQ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__view_enums_dropdown extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord, enumId: string): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
render({ entityId, enumId }: TemplateOptions["view_enums_dropdown"]): {
|
|
11
|
+
body: string;
|
|
12
|
+
importKeys: never[];
|
|
13
|
+
target: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function getLabel(entityId: string, enumId: string): string;
|
|
18
|
+
//# sourceMappingURL=view_enums_dropdown.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view_enums_dropdown.template.d.ts","sourceRoot":"","sources":["../../src/templates/view_enums_dropdown.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,6BAA8B,SAAQ,QAAQ;;IAKzD,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM;;;;IAOzD,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,qBAAqB,CAAC;;;;;;CAmCpE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAcjE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get Template__view_enums_dropdown(){return Template__view_enums_dropdown},get getLabel(){return getLabel}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _inflection=/*#__PURE__*/_interop_require_default(require("inflection"));function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__view_enums_dropdown=/*#__PURE__*/function(Template){"use strict";_inherits(Template__view_enums_dropdown,Template);function Template__view_enums_dropdown(){_class_call_check(this,Template__view_enums_dropdown);return _call_super(this,Template__view_enums_dropdown,["view_enums_dropdown"])}_create_class(Template__view_enums_dropdown,[{key:"getTargetAndPath",value:function getTargetAndPath(names,enumId){return{target:"web/src/components",path:"".concat(names.fs,"/").concat(enumId,"Dropdown.tsx")}}},{key:"render",value:function render(param){var entityId=param.entityId,enumId=param.enumId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);var label=getLabel(entityId,enumId);return _object_spread_props(_object_spread({},this.getTargetAndPath(names,enumId)),{body:"\nimport React from 'react';\nimport {\n Dropdown,\n DropdownProps,\n} from 'semantic-ui-react';\n\nimport { ".concat(enumId,"Label } from 'src/services/sonamu.generated';\n\nexport function ").concat(enumId,"Dropdown(props: DropdownProps) {\n const options = Object.entries(").concat(enumId,'Label).map(([key, label]) => {\n return {\n key,\n value: key,\n text: "').concat(label,': " + label,\n };\n });\n return (\n <Dropdown\n className="label"\n options={options}\n {...props}\n />\n );\n}\n ').trim(),importKeys:[]})}}]);return Template__view_enums_dropdown}(_basetemplate.Template);function getLabel(entityId,enumId){if(enumId.endsWith("OrderBy")){return"정렬"}else if(enumId.endsWith("SearchField")){return"검색"}else{var enumProp=_entitymanager.EntityManager.get(entityId).props.find(function(prop){return"".concat(entityId).concat(_inflection.default.camelize(prop.name))===enumId});if(enumProp&&enumProp.desc){return enumProp.desc}return enumId}}
|
|
2
|
+
//# sourceMappingURL=view_enums_dropdown.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/view_enums_dropdown.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport inflection from \"inflection\";\n\nexport class Template__view_enums_dropdown extends Template {\n constructor() {\n super(\"view_enums_dropdown\");\n }\n\n getTargetAndPath(names: EntityNamesRecord, enumId: string) {\n return {\n target: \"web/src/components\",\n path: `${names.fs}/${enumId}Dropdown.tsx`,\n };\n }\n\n render({ entityId, enumId }: TemplateOptions[\"view_enums_dropdown\"]) {\n const names = EntityManager.getNamesFromId(entityId);\n const label = getLabel(entityId, enumId);\n\n return {\n ...this.getTargetAndPath(names, enumId),\n body: `\nimport React from 'react';\nimport {\n Dropdown,\n DropdownProps,\n} from 'semantic-ui-react';\n\nimport { ${enumId}Label } from 'src/services/sonamu.generated';\n\nexport function ${enumId}Dropdown(props: DropdownProps) {\n const options = Object.entries(${enumId}Label).map(([key, label]) => {\n return {\n key,\n value: key,\n text: \"${label}: \" + label,\n };\n });\n return (\n <Dropdown\n className=\"label\"\n options={options}\n {...props}\n />\n );\n}\n `.trim(),\n importKeys: [],\n };\n }\n}\n\nexport function getLabel(entityId: string, enumId: string): string {\n if (enumId.endsWith(\"OrderBy\")) {\n return \"정렬\";\n } else if (enumId.endsWith(\"SearchField\")) {\n return \"검색\";\n } else {\n const enumProp = EntityManager.get(entityId).props.find(\n (prop) => `${entityId}${inflection.camelize(prop.name)}` === enumId\n );\n if (enumProp && enumProp.desc) {\n return enumProp.desc;\n }\n return enumId;\n }\n}\n"],"names":["Template__view_enums_dropdown","getLabel","getTargetAndPath","names","enumId","target","path","fs","render","entityId","EntityManager","getNamesFromId","label","body","trim","importKeys","Template","endsWith","enumProp","get","props","find","prop","inflection","camelize","name","desc"],"mappings":"mPAKaA,uCAAAA,mCAiDGC,kBAAAA,uCArDiC,sDACxB,iFACF,ygHAEhB,IAAA,AAAMD,2CAAN,0CAAMA,iDAAAA,uDAAAA,+BAET,OAAA,iBAFSA,+BAEH,sCAFGA,gCAKXE,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,CAAEC,MAAc,EACvD,MAAO,CACLC,OAAQ,qBACRC,KAAM,AAAC,GAAcF,OAAZD,MAAMI,EAAE,CAAC,KAAU,OAAPH,OAAO,eAC9B,CACF,IAEAI,IAAAA,eAAAA,SAAAA,OAAO,KAA4D,MAA1DC,SAAF,MAAEA,SAAUL,OAAZ,MAAYA,OACjB,IAAMD,MAAQO,4BAAa,CAACC,cAAc,CAACF,UAC3C,IAAMG,MAAQX,SAASQ,SAAUL,QAEjC,OAAO,uCACF,IAAI,CAACF,gBAAgB,CAACC,MAAOC,UAChCS,KAAM,AAAC,kHASKT,OAFPA,OAAO,qEAGiBA,OADjBA,OAAO,uEAKVQ,OAJoBR,OAAO,8FAIrB,OAANQ,MAAM,uJAWbE,IAAI,GACNC,WAAY,EAAE,EAElB,YA9CWf,+BAAsCgB,sBAAQ,EAiDpD,SAASf,SAASQ,QAAgB,CAAEL,MAAc,EACvD,GAAIA,OAAOa,QAAQ,CAAC,WAAY,CAC9B,MAAO,IACT,MAAO,GAAIb,OAAOa,QAAQ,CAAC,eAAgB,CACzC,MAAO,IACT,KAAO,CACL,IAAMC,SAAWR,4BAAa,CAACS,GAAG,CAACV,UAAUW,KAAK,CAACC,IAAI,CACrD,SAACC,YAAS,AAAC,GAAaC,OAAXd,UAA0C,OAA/Bc,mBAAU,CAACC,QAAQ,CAACF,KAAKG,IAAI,KAAQrB,SAE/D,GAAIc,UAAYA,SAASQ,IAAI,CAAE,CAC7B,OAAOR,SAASQ,IAAI,AACtB,CACA,OAAOtB,MACT,CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__view_enums_select extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord, enumId: string): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
render({ entityId, enumId }: TemplateOptions["view_enums_select"]): {
|
|
11
|
+
body: string;
|
|
12
|
+
importKeys: never[];
|
|
13
|
+
target: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=view_enums_select.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view_enums_select.template.d.ts","sourceRoot":"","sources":["../../src/templates/view_enums_select.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,2BAA4B,SAAQ,QAAQ;;IAKvD,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM;;;;IAOzD,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,mBAAmB,CAAC;;;;;;CAwClE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__view_enums_select",{enumerable:true,get:function(){return Template__view_enums_select}});var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _view_enums_dropdowntemplate=require("./view_enums_dropdown.template");function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__view_enums_select=/*#__PURE__*/function(Template){"use strict";_inherits(Template__view_enums_select,Template);function Template__view_enums_select(){_class_call_check(this,Template__view_enums_select);return _call_super(this,Template__view_enums_select,["view_enums_select"])}_create_class(Template__view_enums_select,[{key:"getTargetAndPath",value:function getTargetAndPath(names,enumId){return{target:"web/src/components",path:"".concat(names.fs,"/").concat(enumId,"Select.tsx")}}},{key:"render",value:function render(param){var entityId=param.entityId,enumId=param.enumId;var names=_entitymanager.EntityManager.getNamesFromId(entityId);var label=(0,_view_enums_dropdowntemplate.getLabel)(entityId,enumId);return _object_spread_props(_object_spread({},this.getTargetAndPath(names,enumId)),{body:"\nimport React from 'react';\nimport {\n Dropdown,\n DropdownProps,\n} from 'semantic-ui-react';\n\nimport { ".concat(enumId,", ").concat(enumId,"Label } from 'src/services/sonamu.generated';\n\nexport type ").concat(enumId,"SelectProps = {\n placeholder?: string;\n textPrefix?: string;\n} & DropdownProps;\nexport function ").concat(enumId,"Select({placeholder, textPrefix, ...props}: ").concat(enumId,"SelectProps) {\n const typeOptions = ").concat(enumId,".options.map((key) => ({\n key,\n value: key,\n text: (textPrefix ?? '").concat(label,": ') + ").concat(enumId,'Label[key],\n }));\n\n return (\n <Dropdown\n placeholder={placeholder ?? "').concat(label,'"}\n selection\n options={typeOptions}\n selectOnBlur={false}\n {...props}\n />\n );\n}\n ').trim(),importKeys:[]})}}]);return Template__view_enums_select}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=view_enums_select.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/view_enums_select.template.ts"],"sourcesContent":["import { TemplateOptions } from \"../types/types\";\nimport { EntityManager, EntityNamesRecord } from \"../entity/entity-manager\";\nimport { Template } from \"./base-template\";\nimport { getLabel } from \"./view_enums_dropdown.template\";\n\nexport class Template__view_enums_select extends Template {\n constructor() {\n super(\"view_enums_select\");\n }\n\n getTargetAndPath(names: EntityNamesRecord, enumId: string) {\n return {\n target: \"web/src/components\",\n path: `${names.fs}/${enumId}Select.tsx`,\n };\n }\n\n render({ entityId, enumId }: TemplateOptions[\"view_enums_select\"]) {\n const names = EntityManager.getNamesFromId(entityId);\n const label = getLabel(entityId, enumId);\n\n return {\n ...this.getTargetAndPath(names, enumId),\n body: `\nimport React from 'react';\nimport {\n Dropdown,\n DropdownProps,\n} from 'semantic-ui-react';\n\nimport { ${enumId}, ${enumId}Label } from 'src/services/sonamu.generated';\n\nexport type ${enumId}SelectProps = {\n placeholder?: string;\n textPrefix?: string;\n} & DropdownProps;\nexport function ${enumId}Select({placeholder, textPrefix, ...props}: ${enumId}SelectProps) {\n const typeOptions = ${enumId}.options.map((key) => ({\n key,\n value: key,\n text: (textPrefix ?? '${label}: ') + ${enumId}Label[key],\n }));\n\n return (\n <Dropdown\n placeholder={placeholder ?? \"${label}\"}\n selection\n options={typeOptions}\n selectOnBlur={false}\n {...props}\n />\n );\n}\n `.trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__view_enums_select","getTargetAndPath","names","enumId","target","path","fs","render","entityId","EntityManager","getNamesFromId","label","getLabel","body","trim","importKeys","Template"],"mappings":"oGAKaA,qEAAAA,0DAJoC,sDACxB,4DACA,w8GAElB,IAAA,AAAMA,yCAAN,0CAAMA,+CAAAA,qDAAAA,6BAET,OAAA,iBAFSA,6BAEH,oCAFGA,8BAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,CAAEC,MAAc,EACvD,MAAO,CACLC,OAAQ,qBACRC,KAAM,AAAC,GAAcF,OAAZD,MAAMI,EAAE,CAAC,KAAU,OAAPH,OAAO,aAC9B,CACF,IAEAI,IAAAA,eAAAA,SAAAA,OAAO,KAA0D,MAAxDC,SAAF,MAAEA,SAAUL,OAAZ,MAAYA,OACjB,IAAMD,MAAQO,4BAAa,CAACC,cAAc,CAACF,UAC3C,IAAMG,MAAQC,GAAAA,qCAAQ,EAACJ,SAAUL,QAEjC,OAAO,uCACF,IAAI,CAACF,gBAAgB,CAACC,MAAOC,UAChCU,KAAM,AAAC,kHAOSV,OAAXA,OAAO,MAEJA,OAFQA,OAAO,iEAMXA,OAJJA,OAAO,0GAIkDA,OAArDA,OAAO,gDACDA,OAD+CA,OAAO,0CAIlDQ,OAHJR,OAAO,mFAGYA,OAAfQ,MAAM,WAKGA,OALMR,OAAO,yFAKP,OAANQ,MAAM,2HAQnCG,IAAI,GACNC,WAAY,EAAE,EAElB,YAnDWf,6BAAoCgB,sBAAQ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RenderingNode, TemplateKey, TemplateOptions } from "../types/types";
|
|
2
|
+
import { EntityNamesRecord } from "../entity/entity-manager";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export declare class Template__view_form extends Template {
|
|
5
|
+
constructor();
|
|
6
|
+
getTargetAndPath(names: EntityNamesRecord): {
|
|
7
|
+
target: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
wrapFC(body: string, label?: string): string;
|
|
11
|
+
wrapFG(body: string, label?: string): string;
|
|
12
|
+
renderColumnImport(entityId: string, col: RenderingNode): string;
|
|
13
|
+
renderColumn(entityId: string, col: RenderingNode, names: EntityNamesRecord, parent?: string): string;
|
|
14
|
+
resolveDefaultValue(columns: RenderingNode[]): object;
|
|
15
|
+
render({ entityId }: TemplateOptions["view_form"], saveParamsNode: RenderingNode): {
|
|
16
|
+
body: string;
|
|
17
|
+
importKeys: never[];
|
|
18
|
+
preTemplates: {
|
|
19
|
+
key: TemplateKey;
|
|
20
|
+
options: TemplateOptions[TemplateKey];
|
|
21
|
+
}[];
|
|
22
|
+
target: string;
|
|
23
|
+
path: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=view_form.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view_form.template.d.ts","sourceRoot":"","sources":["../../src/templates/view_form.template.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAiB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAO3C,qBAAa,mBAAoB,SAAQ,QAAQ;;IAK/C,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IAOzC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAO5C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAQ5C,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa;IAyBvD,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,iBAAiB,EACxB,MAAM,GAAE,MAAW,GAClB,MAAM;IAqET,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM;IAqCrD,MAAM,CACJ,EAAE,QAAQ,EAAE,EAAE,eAAe,CAAC,WAAW,CAAC,EAC1C,cAAc,EAAE,aAAa;;;;;;;;;;CAyPhC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__view_form",{enumerable:true,get:function(){return Template__view_form}});var _inflection=/*#__PURE__*/_interop_require_default(require("inflection"));var _zod=require("zod");var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _view_listtemplate=require("./view_list.template");var _lodash=/*#__PURE__*/_interop_require_default(require("lodash"));function _assert_this_initialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _call_super(_this,derived,args){derived=_get_prototype_of(derived);return _possible_constructor_return(_this,_is_native_reflect_construct()?Reflect.construct(derived,args||[],_get_prototype_of(_this).constructor):derived.apply(_this,args))}function _class_call_check(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _instanceof(left,right){if(right!=null&&typeof Symbol!=="undefined"&&right[Symbol.hasInstance]){return!!right[Symbol.hasInstance](left)}else{return left instanceof right}}function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _object_spread_props(target,source){source=source!=null?source:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _possible_constructor_return(self,call){if(call&&(_type_of(call)==="object"||typeof call==="function")){return call}return _assert_this_initialized(self)}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}var Template__view_form=/*#__PURE__*/function(Template){"use strict";_inherits(Template__view_form,Template);function Template__view_form(){_class_call_check(this,Template__view_form);return _call_super(this,Template__view_form,["view_form"])}_create_class(Template__view_form,[{key:"getTargetAndPath",value:function getTargetAndPath(names){return{target:"web/src/pages/admin",path:"".concat(names.fsPlural,"/form.tsx")}}},{key:"wrapFC",value:function wrapFC(body,label){return["<Form.Field>".concat(label?"\n <label>".concat(label,"</label>"):""),body,"</Form.Field>"].join("\n")}},{key:"wrapFG",value:function wrapFG(body,label){return['<Form.Group widths="equal">',this.wrapFC(body,label),"</Form.Group>"].join("\n")}},{key:"renderColumnImport",value:function renderColumnImport(entityId,col){if(col.renderType==="enums"){var _getEnumInfoFromColName=(0,_view_listtemplate.getEnumInfoFromColName)(entityId,col.name),id=_getEnumInfoFromColName.id,targetEntityNames=_getEnumInfoFromColName.targetEntityNames;var componentId="".concat(id,"Select");return"import { ".concat(componentId,' } from "src/components/').concat(targetEntityNames.fs,"/").concat(componentId,'";')}else if(col.renderType==="number-fk_id"){try{var relProp=(0,_view_listtemplate.getRelationPropFromColName)(entityId,col.name.replace("_id",""));var targetNames=_entitymanager.EntityManager.getNamesFromId(relProp.with);var componentId1="".concat(relProp.with,"IdAsyncSelect");return"import { ".concat(componentId1,' } from "src/components/').concat(targetNames.fs,"/").concat(componentId1,'";')}catch(e){return""}}else{throw new Error("렌더 불가능한 임포트 ".concat(col.name," ").concat(col.renderType))}}},{key:"renderColumn",value:function renderColumn(entityId,col,names){var parent=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"";var regExpr="";regExpr="{...register(`".concat(parent).concat(col.name,"`)}");switch(col.renderType){case"string-plain":var _col_zodType_maxLength;if(_instanceof(col.zodType,_zod.z.ZodString)&&((_col_zodType_maxLength=col.zodType.maxLength)!==null&&_col_zodType_maxLength!==void 0?_col_zodType_maxLength:0)<=512){return'<Input placeholder="'.concat(col.label,'" ').concat(regExpr," />")}else{return'<TextArea rows={8} placeholder="'.concat(col.label,'" ').concat(regExpr," />")}case"datetime":return'<Input type="datetime-local" '.concat(regExpr," />");case"string-datetime":return"<SQLDateTimeInput ".concat(regExpr," />");case"string-date":return"<SQLDateInput ".concat(regExpr," />");case"number-id":return'<input type="hidden" '.concat(regExpr," />");case"number-plain":return'<NumberInput placeholder="'.concat(col.label,'" ').concat(regExpr," />");case"boolean":return"<BooleanToggle ".concat(regExpr," />");case"string-image":return"<ImageUploader multiple={false} ".concat(regExpr," />");case"array-images":return"<ImageUploader multiple={true} ".concat(regExpr," maxSize={5} />");case"enums":try{var enumId;if(col.name==="orderBy"){enumId="".concat(names.capital).concat(_inflection.default.camelize(col.name),"Select")}else{var id=(0,_view_listtemplate.getEnumInfoFromColName)(entityId,col.name).id;enumId="".concat(id,"Select")}return"<".concat(enumId," ").concat(regExpr," ").concat(col.optional||col.nullable?"clearable":"",' textPrefix="" />')}catch(e){return"<>찾을 수 없는 Enum ".concat(col.name,"</>")}case"number-fk_id":try{var relProp=(0,_view_listtemplate.getRelationPropFromColName)(entityId,col.name.replace("_id",""));var fkId="".concat(relProp.with,"IdAsyncSelect");return"<".concat(fkId," {...register('").concat(col.name,"')} ").concat(col.optional||col.nullable?"clearable":"",' subset="A" />')}catch(e){return"<Input ".concat(regExpr," />")}case"array":return"<>".concat(col.name," array</>");case"object":return"<>".concat(col.name," object</>");default:throw new Error("대응 불가능한 렌더 타입 ".concat(col.renderType," on ").concat(col.name))}}},{key:"resolveDefaultValue",value:function resolveDefaultValue(columns){return columns.reduce(function(result,col){if(col.optional){return result}var value;if(col.nullable===true){value=null}else if(_instanceof(col.zodType,_zod.z.ZodNumber)){value=0}else if(_instanceof(col.zodType,_zod.z.ZodEnum)){value=Object.keys(col.zodType.options)[0]}else if(_instanceof(col.zodType,_zod.z.ZodBoolean)){value=false}else if(_instanceof(col.zodType,_zod.z.ZodDate)){value=new Date}else if(_instanceof(col.zodType,_zod.z.ZodString)){if(col.renderType==="string-datetime"){value="now()"}else{value=""}}else if(_instanceof(col.zodType,_zod.z.ZodArray)){value=[]}else if(_instanceof(col.zodType,_zod.z.ZodObject)){value={}}result[col.name]=value;return result},{})}},{key:"render",value:function render(param,saveParamsNode){var _this=this;var entityId=param.entityId;var entity=_entitymanager.EntityManager.get(entityId);var names=_entitymanager.EntityManager.getNamesFromId(entityId);var columns=saveParamsNode.children.filter(function(col){return col.name!=="id"}).map(function(col){var propCandidate=entity.props.find(function(prop){return prop.name===col.name});var _propCandidate_desc;col.label=(_propCandidate_desc=propCandidate===null||propCandidate===void 0?void 0:propCandidate.desc)!==null&&_propCandidate_desc!==void 0?_propCandidate_desc:col.label;return col});var defaultValue=this.resolveDefaultValue(columns);var preTemplates=columns.filter(function(col){if(col.name==="id"){return false}else if(col.name.endsWith("_id")||col.renderType==="number-id"){try{(0,_view_listtemplate.getRelationPropFromColName)(entityId,col.name.replace("_id",""));return true}catch(e){return false}}else if(col.renderType==="enums"){try{(0,_view_listtemplate.getEnumInfoFromColName)(entityId,col.name);return true}catch(e){return false}}return false}).map(function(col){var key;var targetMdId=entityId;var enumId;if(col.renderType==="enums"){key="view_enums_select";var _getEnumInfoFromColName=(0,_view_listtemplate.getEnumInfoFromColName)(entityId,col.name),targetMDNames=_getEnumInfoFromColName.targetEntityNames,id=_getEnumInfoFromColName.id;targetMdId=targetMDNames.capital;enumId=id}else{key="view_id_async_select";var relProp=(0,_view_listtemplate.getRelationPropFromColName)(entityId,col.name.replace("_id",""));targetMdId=relProp.with}return{key:key,options:{entityId:targetMdId,node:col,enumId:enumId}}}).filter(function(preTemplate){if(preTemplate.key==="view_id_async_select"){try{_entitymanager.EntityManager.get(preTemplate.options.entityId);return true}catch(e){return false}}return true});var _entity_title;return _object_spread_props(_object_spread({},this.getTargetAndPath(names)),{body:"\nimport React, { useEffect, useState, Dispatch, SetStateAction, forwardRef, Ref, useImperativeHandle, useCallback } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport {\n Button,\n Checkbox,\n Form,\n Header,\n Input,\n Segment,\n TextArea,\n Label,\n} from 'semantic-ui-react';\nimport { DateTime } from \"luxon\";\n\nimport { BackLink, LinkInput, NumberInput, BooleanToggle, SQLDateTimeInput, SQLDateInput, useTypeForm, useGoBack, formatDateTime } from \"@sonamu-kit/react-sui\";\nimport { defaultCatch } from 'src/services/sonamu.shared';\n// import { ImageUploader } from 'src/admin-common/ImageUploader';\n// import { useCommonModal } from \"src/admin-common/CommonModal\";\n\nimport { ".concat(names.capital,"SaveParams } from 'src/services/").concat(names.fs,"/").concat(names.fs,".types';\nimport { ").concat(names.capital,"Service } from 'src/services/").concat(names.fs,"/").concat(names.fs,".service';\nimport { ").concat(names.capital,"SubsetA } from 'src/services/sonamu.generated';\n").concat(_lodash.default.uniq(columns.filter(function(col){return["number-fk_id","enums"].includes(col.renderType)}).map(function(col){return _this.renderColumnImport(entityId,col)})).join("\n"),"\n\nexport default function ").concat(names.capitalPlural,"FormPage() {\n // 라우팅 searchParams\n const [searchParams] = useSearchParams();\n const query = {\n id: searchParams.get('id') ?? undefined,\n };\n\n return <").concat(names.capitalPlural,"Form id={query?.id ? Number(query.id) : undefined} />;\n}\ntype ").concat(names.capitalPlural,"FormProps = {\n id?: number;\n mode?: 'page' | 'modal';\n};\nexport function ").concat(names.capitalPlural,"Form({ id, mode }: ").concat(names.capitalPlural,"FormProps) {\n // 편집시 기존 row\n const [row, setRow] = useState<").concat(names.capital,"SubsetA | undefined>();\n\n // ").concat(names.capital,"SaveParams 폼\n const { form, setForm, register } = useTypeForm(").concat(names.capital,"SaveParams, ").concat(JSON.stringify(defaultValue).replace(/"now\(\)"/g,"DateTime.local().toSQL()!.slice(0, 19)"),");\n\n // 수정일 때 기존 row 콜\n useEffect(() => {\n if (id) {\n ").concat(names.capital,"Service.get").concat(names.capital,"('A', id).then((row) => {\n setRow(row);\n setForm({\n ...row,\n ").concat(columns.filter(function(col){return col.renderType==="number-fk_id"}).map(function(col){if(col.nullable){return"".concat(col.name,": row.").concat(col.name.replace("_id","?.id")," ?? null")}else{return"".concat(col.name,": row.").concat(col.name.replace("_id",".id"))}}).join(",\n"),"\n });\n });\n }\n }, [id]);\n\n // CommonModal\n // const { doneModal, closeModal } = useCommonModal();\n\n // 저장\n const { goBack } = useGoBack();\n const handleSubmit = useCallback(() => {\n ").concat(names.capital,"Service.save([form]).then(([id]) => {\n if( mode === 'modal' ) {\n // doneModal();\n } else {\n goBack('/admin/").concat(names.fsPlural,"');\n }\n }).catch(defaultCatch);\n }, [ form, mode, id ]);\n\n // 페이지\n const PAGE = {\n title: `").concat((_entity_title=entity.title)!==null&&_entity_title!==void 0?_entity_title:names.capital,'${id ? `#${id} 수정` : \' 등록\'}`,\n }\n\n return (\n <div className="form">\n <Segment padded basic>\n <Segment padded color="grey">\n <div className="header-row">\n <Header>\n {PAGE.title}\n </Header>\n { mode !== \'modal\' && <div className="buttons">\n <BackLink primary size="tiny" to="/admin/').concat(names.fsPlural,'" content="목록" icon="list" />\n </div>}\n </div>\n <Form>\n ').concat(columns.map(function(col){if(col.name==="created_at"){return"{form.id && (".concat(_this.wrapFG('<div className="p-8px">{formatDateTime(form.'.concat(col.name,")}</div>"),"등록일시"),")}")}else{return _this.wrapFG(_this.renderColumn(entityId,col,names),function(){if(col.label.endsWith("Id")){try{var entity=_entitymanager.EntityManager.get(col.label.replace("Id",""));var _entity_title;return(_entity_title=entity.title)!==null&&_entity_title!==void 0?_entity_title:col.label}catch(e){return col.label}}return col.label}())}}).join("\n"),'\n <Segment basic textAlign="center">\n <Button type="submit" primary onClick={handleSubmit} content="저장" icon="save" />\n </Segment>\n </Form>\n </Segment>\n </Segment>\n </div>\n );\n};\n ').trim(),importKeys:[],preTemplates:preTemplates})}}]);return Template__view_form}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=view_form.template.js.map
|