sonamu 0.4.14 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +19 -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 +84 -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/bin/build-config.d.ts +9 -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 +48 -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/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 +48 -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 +23 -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/stream/index.d.ts +2 -0
- package/dist/stream/index.d.ts.map +1 -0
- package/dist/stream/index.js +2 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/sse.d.ts +13 -0
- package/dist/stream/sse.d.ts.map +1 -0
- package/dist/stream/sse.js +2 -0
- package/dist/stream/sse.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 +611 -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 +32 -45
- 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 +15 -3
- package/src/api/decorators.ts +144 -20
- package/src/api/index.ts +2 -0
- package/src/api/sonamu.ts +408 -165
- package/src/bin/build-config.ts +10 -0
- package/src/bin/cli-wrapper.ts +35 -32
- package/src/bin/cli.ts +141 -204
- package/src/database/_batch_update.ts +10 -15
- package/src/database/base-model.ts +326 -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 +131 -0
- package/src/file-storage/file-storage.ts +100 -0
- package/src/index.ts +15 -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/stream/index.ts +1 -0
- package/src/stream/sse.ts +49 -0
- 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 +108 -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 +6 -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/dist/base-model-CEB0H0aO.d.mts +0 -43
- package/dist/base-model-CrqDMYhI.d.ts +0 -43
- package/dist/bin/cli-wrapper.d.mts +0 -1
- package/dist/bin/cli-wrapper.mjs +0 -43
- package/dist/bin/cli-wrapper.mjs.map +0 -1
- package/dist/bin/cli.d.mts +0 -2
- package/dist/bin/cli.mjs +0 -907
- package/dist/bin/cli.mjs.map +0 -1
- package/dist/chunk-2WAC2GER.js +0 -7625
- package/dist/chunk-2WAC2GER.js.map +0 -1
- package/dist/chunk-C3IPIF6O.mjs +0 -1581
- package/dist/chunk-C3IPIF6O.mjs.map +0 -1
- package/dist/chunk-EXHKSVTE.js +0 -280
- package/dist/chunk-EXHKSVTE.js.map +0 -1
- package/dist/chunk-FCERKIIF.mjs +0 -7623
- package/dist/chunk-FCERKIIF.mjs.map +0 -1
- package/dist/chunk-HGIBJYOU.mjs +0 -231
- package/dist/chunk-HGIBJYOU.mjs.map +0 -1
- package/dist/chunk-JKSOJRQA.mjs +0 -280
- package/dist/chunk-JKSOJRQA.mjs.map +0 -1
- package/dist/chunk-OTKKFP3Y.js +0 -1581
- package/dist/chunk-OTKKFP3Y.js.map +0 -1
- package/dist/chunk-PTFDTOJU.mjs +0 -19
- package/dist/chunk-PTFDTOJU.mjs.map +0 -1
- package/dist/chunk-UZ2IY5VE.js +0 -231
- package/dist/chunk-UZ2IY5VE.js.map +0 -1
- package/dist/database/drivers/knex/base-model.d.mts +0 -16
- package/dist/database/drivers/knex/base-model.d.ts +0 -16
- package/dist/database/drivers/knex/base-model.js +0 -55
- package/dist/database/drivers/knex/base-model.js.map +0 -1
- package/dist/database/drivers/knex/base-model.mjs +0 -56
- package/dist/database/drivers/knex/base-model.mjs.map +0 -1
- package/dist/database/drivers/kysely/base-model.d.mts +0 -22
- package/dist/database/drivers/kysely/base-model.d.ts +0 -22
- package/dist/database/drivers/kysely/base-model.js +0 -64
- package/dist/database/drivers/kysely/base-model.js.map +0 -1
- package/dist/database/drivers/kysely/base-model.mjs +0 -65
- package/dist/database/drivers/kysely/base-model.mjs.map +0 -1
- package/dist/index.d.mts +0 -813
- package/dist/index.mjs +0 -435
- package/dist/index.mjs.map +0 -1
- package/dist/model-aFgomcdc.d.mts +0 -1112
- package/dist/model-aFgomcdc.d.ts +0 -1112
- 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/entity.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__entity extends Template {\n constructor() {\n super(\"entity\");\n }\n\n getTargetAndPath(names: EntityNamesRecord, parentNames?: EntityNamesRecord) {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `${(parentNames ?? names).fs}/${names.fs}.entity.json`,\n };\n }\n\n render(options: TemplateOptions[\"entity\"]) {\n const { entityId, title, parentId, table } = options;\n const names = EntityManager.getNamesFromId(entityId);\n\n const parent = (() => {\n if (parentId) {\n return {\n names: EntityManager.getNamesFromId(parentId),\n entity: EntityManager.get(parentId),\n };\n } else {\n return null;\n }\n })();\n\n return {\n ...this.getTargetAndPath(names, parent?.names ?? names),\n body: JSON.stringify({\n id: entityId,\n title: title ?? entityId,\n parentId,\n table: table ?? names.fsPlural.replace(/\\-/g, \"_\"),\n props: options.props?.length\n ? options.props\n : [\n { name: \"id\", type: \"integer\", unsigned: true, desc: \"ID\" },\n ...(parent\n ? [\n {\n type: \"relation\",\n name: parent.names.camel,\n relationType: \"BelongsToOne\",\n with: parentId,\n onUpdate: \"CASCADE\",\n onDelete: \"CASCADE\",\n desc: parent.entity.title,\n },\n ]\n : []),\n {\n name: \"created_at\",\n type: \"timestamp\",\n desc: \"등록일시\",\n dbDefault: \"CURRENT_TIMESTAMP\",\n },\n ],\n indexes: [...(options.indexes ?? [])],\n subsets: options.subsets ?? {\n ...(parentId\n ? {}\n : {\n A: [\"id\", \"created_at\"],\n }),\n },\n enums: options.enums ?? {\n ...(parentId\n ? {}\n : {\n [`${names.capital}OrderBy`]: {\n \"id-desc\": \"ID최신순\",\n },\n [`${names.capital}SearchField`]: { id: \"ID\" },\n }),\n },\n }).trim(),\n importKeys: [],\n };\n }\n}\n"],"names":["Template__entity","getTargetAndPath","names","parentNames","dir","Sonamu","config","api","target","path","fs","render","options","entityId","title","parentId","table","EntityManager","getNamesFromId","parent","entity","get","body","JSON","stringify","id","fsPlural","replace","props","length","name","type","unsigned","desc","camel","relationType","with","onUpdate","onDelete","dbDefault","indexes","subsets","A","enums","capital","trim","importKeys","Template"],"mappings":"oGAKaA,0DAAAA,+CAJoC,sDACxB,oCACF,ugJAEhB,IAAA,AAAMA,8BAAN,0CAAMA,oCAAAA,0CAAAA,kBAET,OAAA,iBAFSA,kBAEH,yBAFGA,mBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,CAAEC,WAA+B,EACxE,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,AAAC,GAA+BP,OAA7B,AAACC,CAAAA,oBAAAA,qBAAAA,YAAeD,KAAI,EAAGQ,EAAE,CAAC,KAAY,OAATR,MAAMQ,EAAE,CAAC,eACjD,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAOC,OAAkC,MAsB5BA,eArBX,IAAQC,SAAqCD,QAArCC,SAAUC,MAA2BF,QAA3BE,MAAOC,SAAoBH,QAApBG,SAAUC,MAAUJ,QAAVI,MACnC,IAAMd,MAAQe,4BAAa,CAACC,cAAc,CAACL,UAE3C,IAAMM,OAAS,AAAC,WACd,GAAIJ,SAAU,CACZ,MAAO,CACLb,MAAOe,4BAAa,CAACC,cAAc,CAACH,UACpCK,OAAQH,4BAAa,CAACI,GAAG,CAACN,SAC5B,CACF,KAAO,CACL,OAAO,IACT,CACF,QAGkCI,cA8BhBP,iBACLA,iBAOFA,mBAGD,KA1CV,OAAO,uCACF,IAAI,CAACX,gBAAgB,CAACC,MAAOiB,CAAAA,cAAAA,eAAAA,uBAAAA,OAAQjB,KAAK,UAAbiB,uBAAAA,cAAiBjB,SACjDoB,KAAMC,KAAKC,SAAS,CAAC,CACnBC,GAAIZ,SACJC,MAAOA,cAAAA,eAAAA,MAASD,SAChBE,SAAAA,SACAC,MAAOA,cAAAA,eAAAA,MAASd,MAAMwB,QAAQ,CAACC,OAAO,CAAC,MAAO,KAC9CC,MAAOhB,EAAAA,eAAAA,QAAQgB,KAAK,UAAbhB,+BAAAA,eAAeiB,MAAM,EACxBjB,QAAQgB,KAAK,CACb,CACE,CAAEE,KAAM,KAAMC,KAAM,UAAWC,SAAU,KAAMC,KAAM,IAAK,EAoB3D,CArBD,OAEE,qBAAId,OACA,CACE,CACEY,KAAM,WACND,KAAMX,OAAOjB,KAAK,CAACgC,KAAK,CACxBC,aAAc,eACdC,KAAMrB,SACNsB,SAAU,UACVC,SAAU,UACVL,KAAMd,OAAOC,MAAM,CAACN,KAAK,AAC3B,EACD,CACD,EAAE,EAdR,CAeE,CACEgB,KAAM,aACNC,KAAM,YACNE,KAAM,OACNM,UAAW,mBACb,EACD,EACLC,QAAU,qBAAI5B,CAAAA,iBAAAA,QAAQ4B,OAAO,UAAf5B,0BAAAA,iBAAmB,EAAE,EACnC6B,QAAS7B,CAAAA,iBAAAA,QAAQ6B,OAAO,UAAf7B,0BAAAA,iBAAmB,kBACtBG,SACA,CAAC,EACD,CACE2B,EAAG,CAAC,KAAM,aAAa,AACzB,GAENC,MAAO/B,CAAAA,eAAAA,QAAQ+B,KAAK,UAAb/B,wBAAAA,eAAiB,kBAClBG,SACA,CAAC,GACD,QACE,iBADF,KACG,AAAC,GAAgB,OAAdb,MAAM0C,OAAO,CAAC,WAAW,CAC3B,UAAW,OACb,GACA,iBAJF,KAIG,AAAC,GAAgB,OAAd1C,MAAM0C,OAAO,CAAC,eAAe,CAAEnB,GAAI,IAAK,GAJ9C,MAOR,GAAGoB,IAAI,GACPC,WAAY,EAAE,EAElB,YAjFW9C,kBAAyB+C,sBAAQ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { Entity } from "../entity/entity";
|
|
3
|
+
import { Template } from "./base-template";
|
|
4
|
+
export type SourceCode = {
|
|
5
|
+
label: string;
|
|
6
|
+
lines: string[];
|
|
7
|
+
importKeys: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare class Template__generated extends Template {
|
|
10
|
+
constructor();
|
|
11
|
+
getTargetAndPath(): {
|
|
12
|
+
target: string;
|
|
13
|
+
path: string;
|
|
14
|
+
};
|
|
15
|
+
render({}: TemplateOptions["generated"]): {
|
|
16
|
+
body: string;
|
|
17
|
+
importKeys: string[];
|
|
18
|
+
customHeaders: string[];
|
|
19
|
+
target: string;
|
|
20
|
+
path: string;
|
|
21
|
+
};
|
|
22
|
+
getEnumsSourceCode(entity: Entity): SourceCode | null;
|
|
23
|
+
getBaseSchemaSourceCode(entity: Entity, importKeys?: string[]): SourceCode;
|
|
24
|
+
getBaseListParamsSourceCode(entity: Entity): SourceCode | null;
|
|
25
|
+
getSubsetSourceCode(entity: Entity): SourceCode | null;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=generated.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated.template.d.ts","sourceRoot":"","sources":["../../src/templates/generated.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,qBAAa,mBAAoB,SAAQ,QAAQ;;IAK/C,gBAAgB;;;;IAShB,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,WAAW,CAAC;;;;;;;IAyGvC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAsBrD,uBAAuB,CACrB,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,MAAM,EAAO,GACxB,UAAU;IAsCb,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAiD9D,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;CAmDvD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__generated",{enumerable:true,get:function(){return Template__generated}});var _lodash=/*#__PURE__*/_interop_require_default(require("lodash"));var _entitymanager=require("../entity/entity-manager");var _codeconverters=require("../api/code-converters");var _basetemplate=require("./base-template");var _utils=require("../utils/utils");var _api=require("../api");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_with_holes(arr){if(Array.isArray(arr))return arr}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 _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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_destructuring_empty(o){if(o===null||o===void 0)throw new TypeError("Cannot destructure "+o);return o}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 _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}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__generated=/*#__PURE__*/function(Template){"use strict";_inherits(Template__generated,Template);function Template__generated(){_class_call_check(this,Template__generated);return _call_super(this,Template__generated,["generated"])}_create_class(Template__generated,[{key:"getTargetAndPath",value:function getTargetAndPath(){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"sonamu.generated.ts"}}},{key:"render",value:function render(param){var _this=this;var ref=_object_destructuring_empty(param);var entityIds=_entitymanager.EntityManager.getAllIds();var entities=entityIds.map(function(id){return _entitymanager.EntityManager.get(id)});var sourceCodes=entities.map(function(entity){return[_this.getEnumsSourceCode(entity),_this.getBaseSchemaSourceCode(entity),_this.getBaseListParamsSourceCode(entity),_this.getSubsetSourceCode(entity)].filter(_utils.nonNullable)}).flat();var LABEL_KEY_ORDER=["Enums","BaseSchema","BaseListParams","Subsets","SubsetQueries"];sourceCodes.sort(function(a,b){var _a_label_split=_sliced_to_array(a.label.split(":"),1),aKey=_a_label_split[0];var _b_label_split=_sliced_to_array(b.label.split(":"),1),bKey=_b_label_split[0];var aIndex=LABEL_KEY_ORDER.indexOf(aKey);var bIndex=LABEL_KEY_ORDER.indexOf(bKey);if(aIndex>bIndex){return 1}else if(aIndex<bIndex){return-1}else{return 0}});var sourceCode=sourceCodes.reduce(function(result,ts){if(ts===null){return result}return{lines:_to_consumable_array(result.lines).concat(["// ".concat(ts.label)],_to_consumable_array(ts.lines),[""]),importKeys:_lodash.default.uniq(_to_consumable_array(result.importKeys).concat(_to_consumable_array(ts.importKeys)).sort())}},{lines:[],importKeys:[]});var allTypeKeys=entities.map(function(entity){return Object.keys(entity.types)}).flat();var cdImportKeys=sourceCode.importKeys.filter(function(importKey){return allTypeKeys.includes(importKey)});if(cdImportKeys.length>0){var customScalarLines=cdImportKeys.map(function(importKey){var entity=entities.find(function(entity){return entity.types[importKey]});if(!entity){throw new Error("ZodType not found ".concat(importKey))}var zodType=entity.types[importKey];return["// CustomScalar: ".concat(importKey),"const ".concat(importKey," = ").concat((0,_codeconverters.zodTypeToZodCode)(zodType),";"),"type ".concat(importKey," = z.infer<typeof ").concat(importKey,">"),""]}).flat();sourceCode.lines=_to_consumable_array(customScalarLines).concat(_to_consumable_array(sourceCode.lines));sourceCode.importKeys=sourceCode.importKeys.filter(function(importKey){return!cdImportKeys.includes(importKey)})}var body=sourceCode.lines.join("\n");var sonamuImports=["zArrayable","SQLDateTimeString","SubsetQuery","SonamuQueryMode"].filter(function(mod){return body.includes(mod)});return _object_spread_props(_object_spread({},this.getTargetAndPath()),{body:body,importKeys:sourceCode.importKeys,customHeaders:["import { z } from 'zod';","import { ".concat(sonamuImports.join(","),' } from "sonamu";')]})}},{key:"getEnumsSourceCode",value:function getEnumsSourceCode(entity){if(Object.keys(entity.enumLabels).length===0){return null}return{label:"Enums: ".concat(entity.id),lines:_to_consumable_array(Object.entries(entity.enumLabels).filter(function(param){var _param=_sliced_to_array(param,2),_=_param[0],enumLabel=_param[1];return Object.keys(enumLabel).length>0}).map(function(param){var _param=_sliced_to_array(param,2),enumId=_param[0],enumLabel=_param[1];return["export const ".concat(enumId," = z.enum([").concat(Object.keys(enumLabel).map(function(el){return'"'.concat(el,'"')}),']).describe("').concat(enumId,'");'),"export type ".concat(enumId," = z.infer<typeof ").concat(enumId,">"),"export const ".concat(enumId,"Label = ").concat(JSON.stringify(enumLabel))]}).flat()),importKeys:[]}}},{key:"getBaseSchemaSourceCode",value:function getBaseSchemaSourceCode(entity){var importKeys=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];var schemaName="".concat(entity.names.module,"BaseSchema");var propNode={nodeType:"object",children:entity.props.map(function(prop){return{nodeType:"plain",prop:prop}})};var schemaBody=(0,_codeconverters.propNodeToZodTypeDef)(propNode,importKeys);var fulltextColumns=_lodash.default.uniq(entity.indexes.filter(function(index){return index.type==="fulltext"}).flatMap(function(index){return index.columns}));var lines=["export const ".concat(schemaName," = ").concat(schemaBody),"export type ".concat(schemaName," = z.infer<typeof ").concat(schemaName,">")+(fulltextColumns.length>0?" & { readonly __fulltext__: readonly [".concat(fulltextColumns.map(function(col){return'"'.concat(col,'"')}).join(", "),"] }"):"")];return{label:"BaseSchema: ".concat(entity.id),importKeys:importKeys,lines:lines}}},{key:"getBaseListParamsSourceCode",value:function getBaseListParamsSourceCode(entity){if(entity.props.length===0){return null}else if(entity.parentId!==undefined){return null}var schemaName="".concat(entity.names.module,"BaseListParams");var filterProps=entity.props.filter(function(prop){return prop.toFilter===true});var propNodes=filterProps.map(function(prop){return{nodeType:"plain",prop:prop,children:[]}});var importKeys=[];var filterBody=propNodes.map(function(propNode){return(0,_codeconverters.propNodeToZodTypeDef)(propNode,importKeys)}).join("\n");var schemaBody="\nz.object({\n num: z.number().int().nonnegative(),\n page: z.number().int().min(1),\n search: ".concat(entity.id,"SearchField,\n keyword: z.string(),\n orderBy: ").concat(entity.id,"OrderBy,\n queryMode: SonamuQueryMode,\n id: zArrayable(z.number().int().positive()),").concat(filterBody,"\n}).partial();\n").trim();var lines=["export const ".concat(schemaName," = ").concat(schemaBody),"export type ".concat(schemaName," = z.infer<typeof ").concat(schemaName,">")];return{label:"BaseListParams: ".concat(entity.id),importKeys:importKeys,lines:lines}}},{key:"getSubsetSourceCode",value:function getSubsetSourceCode(entity){if(Object.keys(entity.subsets).length==0){return null}else if(entity.parentId!==undefined){return null}var subsetKeys=Object.keys(entity.subsets);var importKeys=[];var lines=_to_consumable_array(subsetKeys.map(function(subsetKey){var fieldExprs=entity.subsets[subsetKey];var propNodes=entity.fieldExprsToPropNodes(fieldExprs);var schemaName="".concat(entity.names.module,"Subset").concat(subsetKey);var propNode={nodeType:"object",children:propNodes};var body=(0,_codeconverters.propNodeToZodTypeDef)(propNode,importKeys);return["export const ".concat(schemaName," = ").concat(body),"export type ".concat(schemaName," = z.infer<typeof ").concat(schemaName,">")]}).flat()).concat(["export type ".concat(entity.names.module,"SubsetMapping = {")],_to_consumable_array(subsetKeys.map(function(subsetKey){return" ".concat(subsetKey,": ").concat(entity.names.module,"Subset").concat(subsetKey,";")})),["}","export const ".concat(entity.names.module,"SubsetKey = z.enum([").concat(subsetKeys.map(function(k){return'"'.concat(k,'"')}).join(","),"]);"),"export type ".concat(entity.names.module,"SubsetKey = z.infer<typeof ").concat(entity.names.module,"SubsetKey>"),""]);return{label:"Subsets: ".concat(entity.id),lines:lines,importKeys:_lodash.default.uniq(importKeys)}}}]);return Template__generated}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=generated.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/generated.template.ts"],"sourcesContent":["import _ from \"lodash\";\nimport { TemplateOptions } from \"../types/types\";\nimport { EntityManager } from \"../entity/entity-manager\";\nimport { Entity } from \"../entity/entity\";\nimport { EntityPropNode } from \"../types/types\";\nimport { propNodeToZodTypeDef, zodTypeToZodCode } from \"../api/code-converters\";\nimport { Template } from \"./base-template\";\nimport { nonNullable } from \"../utils/utils\";\nimport { Sonamu } from \"../api\";\n\nexport type SourceCode = {\n label: string;\n lines: string[];\n importKeys: string[];\n};\nexport class Template__generated extends Template {\n constructor() {\n super(\"generated\");\n }\n\n getTargetAndPath() {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `sonamu.generated.ts`,\n };\n }\n\n render({}: TemplateOptions[\"generated\"]) {\n const entityIds = EntityManager.getAllIds();\n const entities = entityIds.map((id) => EntityManager.get(id));\n\n // 전체 SourceCode 생성\n const sourceCodes = entities\n .map((entity) => {\n return [\n this.getEnumsSourceCode(entity),\n this.getBaseSchemaSourceCode(entity),\n this.getBaseListParamsSourceCode(entity),\n this.getSubsetSourceCode(entity),\n ].filter(nonNullable);\n })\n .flat();\n\n // Sort\n const LABEL_KEY_ORDER = [\n \"Enums\",\n \"BaseSchema\",\n \"BaseListParams\",\n \"Subsets\",\n \"SubsetQueries\",\n ];\n sourceCodes.sort((a, b) => {\n const [aKey] = a.label.split(\":\");\n const [bKey] = b.label.split(\":\");\n const aIndex = LABEL_KEY_ORDER.indexOf(aKey);\n const bIndex = LABEL_KEY_ORDER.indexOf(bKey);\n if (aIndex > bIndex) {\n return 1;\n } else if (aIndex < bIndex) {\n return -1;\n } else {\n return 0;\n }\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].sort()),\n };\n },\n {\n lines: [],\n importKeys: [],\n } as Omit<SourceCode, \"label\">\n );\n\n // .types.ts의 타입을 참조하는 경우 순환참조(상호참조)가 발생하므로 타입을 가져와 인라인 처리\n const allTypeKeys = entities\n .map((entity) => Object.keys(entity.types))\n .flat();\n const cdImportKeys = sourceCode.importKeys.filter((importKey) =>\n allTypeKeys.includes(importKey)\n );\n if (cdImportKeys.length > 0) {\n const customScalarLines = cdImportKeys\n .map((importKey) => {\n const entity = entities.find((entity) => entity.types[importKey]);\n if (!entity) {\n throw new Error(`ZodType not found ${importKey}`);\n }\n const zodType = entity.types[importKey]!;\n\n return [\n `// CustomScalar: ${importKey}`,\n `const ${importKey} = ${zodTypeToZodCode(zodType)};`,\n `type ${importKey} = z.infer<typeof ${importKey}>`,\n \"\",\n ];\n })\n .flat();\n sourceCode.lines = [...customScalarLines, ...sourceCode.lines];\n sourceCode.importKeys = sourceCode.importKeys.filter(\n (importKey) => !cdImportKeys.includes(importKey)\n );\n }\n\n const body = sourceCode.lines.join(\"\\n\");\n\n // import\n const sonamuImports = [\n \"zArrayable\",\n \"SQLDateTimeString\",\n \"SubsetQuery\",\n \"SonamuQueryMode\",\n ].filter((mod) => body.includes(mod));\n\n return {\n ...this.getTargetAndPath(),\n body,\n importKeys: sourceCode.importKeys,\n customHeaders: [\n `import { z } from 'zod';`,\n `import { ${sonamuImports.join(\",\")} } from \"sonamu\";`,\n ],\n };\n }\n\n getEnumsSourceCode(entity: Entity): SourceCode | null {\n if (Object.keys(entity.enumLabels).length === 0) {\n return null;\n }\n return {\n label: `Enums: ${entity.id}`,\n lines: [\n ...Object.entries(entity.enumLabels)\n .filter(([_, enumLabel]) => Object.keys(enumLabel).length > 0)\n .map(([enumId, enumLabel]) => [\n `export const ${enumId} = z.enum([${Object.keys(enumLabel).map(\n (el) => `\"${el}\"`\n )}]).describe(\"${enumId}\");`,\n `export type ${enumId} = z.infer<typeof ${enumId}>`,\n `export const ${enumId}Label = ${JSON.stringify(enumLabel)}`,\n ])\n .flat(),\n ],\n importKeys: [],\n };\n }\n\n getBaseSchemaSourceCode(\n entity: Entity,\n importKeys: string[] = []\n ): SourceCode {\n const schemaName = `${entity.names.module}BaseSchema`;\n const propNode: EntityPropNode = {\n nodeType: \"object\",\n children: entity.props.map((prop) => {\n return {\n nodeType: \"plain\",\n prop,\n };\n }),\n };\n\n const schemaBody = propNodeToZodTypeDef(propNode, importKeys);\n\n // fulltext index에 포함된 컬럼들 추출\n const fulltextColumns = _.uniq(\n entity.indexes\n .filter((index) => index.type === \"fulltext\")\n .flatMap((index) => index.columns)\n );\n\n const lines = [\n `export const ${schemaName} = ${schemaBody}`,\n `export type ${schemaName} = z.infer<typeof ${schemaName}>` +\n (fulltextColumns.length > 0\n ? ` & { readonly __fulltext__: readonly [${fulltextColumns\n .map((col) => `\"${col}\"`)\n .join(\", \")}] }`\n : \"\"),\n ];\n\n return {\n label: `BaseSchema: ${entity.id}`,\n importKeys,\n lines,\n };\n }\n\n getBaseListParamsSourceCode(entity: Entity): SourceCode | null {\n // Prop 없는 MD인 경우 생성 제외\n if (entity.props.length === 0) {\n return null;\n } else if (entity.parentId !== undefined) {\n return null;\n }\n\n const schemaName = `${entity.names.module}BaseListParams`;\n\n const filterProps = entity.props.filter((prop) => prop.toFilter === true);\n\n const propNodes: EntityPropNode[] = filterProps.map((prop) => {\n return {\n nodeType: \"plain\" as const,\n prop,\n children: [],\n };\n });\n\n const importKeys: string[] = [];\n const filterBody = propNodes\n .map((propNode) => propNodeToZodTypeDef(propNode, importKeys))\n .join(\"\\n\");\n\n const schemaBody = `\nz.object({\n num: z.number().int().nonnegative(),\n page: z.number().int().min(1),\n search: ${entity.id}SearchField,\n keyword: z.string(),\n orderBy: ${entity.id}OrderBy,\n queryMode: SonamuQueryMode,\n id: zArrayable(z.number().int().positive()),${filterBody}\n}).partial();\n`.trim();\n\n const lines = [\n `export const ${schemaName} = ${schemaBody}`,\n `export type ${schemaName} = z.infer<typeof ${schemaName}>`,\n ];\n\n return {\n label: `BaseListParams: ${entity.id}`,\n importKeys,\n lines,\n };\n }\n\n getSubsetSourceCode(entity: Entity): SourceCode | null {\n if (Object.keys(entity.subsets).length == 0) {\n return null;\n } else if (entity.parentId !== undefined) {\n return null;\n }\n\n const subsetKeys = Object.keys(entity.subsets);\n const importKeys: string[] = [];\n const lines: string[] = [\n ...subsetKeys\n .map((subsetKey) => {\n // 서브셋에서 FieldExpr[] 가져옴\n const fieldExprs = entity.subsets[subsetKey];\n\n // FieldExpr[]로 EntityPropNode[] 가져옴\n const propNodes = entity.fieldExprsToPropNodes(fieldExprs);\n const schemaName = `${entity.names.module}Subset${subsetKey}`;\n const propNode: EntityPropNode = {\n nodeType: \"object\",\n children: propNodes,\n };\n\n // EntityPropNode[]로 ZodTypeDef(string)을 가져옴\n const body = propNodeToZodTypeDef(propNode, importKeys);\n\n return [\n `export const ${schemaName} = ${body}`,\n `export type ${schemaName} = z.infer<typeof ${schemaName}>`,\n ];\n })\n .flat(),\n `export type ${entity.names.module}SubsetMapping = {`,\n ...subsetKeys.map(\n (subsetKey) =>\n ` ${subsetKey}: ${entity.names.module}Subset${subsetKey};`\n ),\n \"}\",\n `export const ${entity.names.module}SubsetKey = z.enum([${subsetKeys\n .map((k) => `\"${k}\"`)\n .join(\",\")}]);`,\n `export type ${entity.names.module}SubsetKey = z.infer<typeof ${entity.names.module}SubsetKey>`,\n \"\",\n ];\n\n return {\n label: `Subsets: ${entity.id}`,\n lines,\n importKeys: _.uniq(importKeys),\n };\n }\n}\n"],"names":["Template__generated","getTargetAndPath","dir","Sonamu","config","api","target","path","render","entityIds","EntityManager","getAllIds","entities","map","id","get","sourceCodes","entity","getEnumsSourceCode","getBaseSchemaSourceCode","getBaseListParamsSourceCode","getSubsetSourceCode","filter","nonNullable","flat","LABEL_KEY_ORDER","sort","a","b","label","split","aKey","bKey","aIndex","indexOf","bIndex","sourceCode","reduce","result","ts","lines","importKeys","_","uniq","allTypeKeys","Object","keys","types","cdImportKeys","importKey","includes","length","customScalarLines","find","Error","zodType","zodTypeToZodCode","body","join","sonamuImports","mod","customHeaders","enumLabels","entries","enumLabel","enumId","el","JSON","stringify","schemaName","names","module","propNode","nodeType","children","props","prop","schemaBody","propNodeToZodTypeDef","fulltextColumns","indexes","index","type","flatMap","columns","col","parentId","undefined","filterProps","toFilter","propNodes","filterBody","trim","subsets","subsetKeys","subsetKey","fieldExprs","fieldExprsToPropNodes","k","Template"],"mappings":"oGAeaA,6DAAAA,iFAfC,sCAEgB,wDAGyB,oDAC9B,sCACG,mCACL,qhLAOhB,IAAA,AAAMA,iCAAN,0CAAMA,uCAAAA,6CAAAA,qBAET,OAAA,iBAFSA,qBAEH,4BAFGA,sBAKXC,IAAAA,yBAAAA,SAAAA,mBACE,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,qBACR,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAAgC,qBAAhC,gCAAA,OACL,IAAMC,UAAYC,4BAAa,CAACC,SAAS,GACzC,IAAMC,SAAWH,UAAUI,GAAG,CAAC,SAACC,WAAOJ,4BAAa,CAACK,GAAG,CAACD,MAGzD,IAAME,YAAcJ,SACjBC,GAAG,CAAC,SAACI,QACJ,MAAO,CACL,MAAKC,kBAAkB,CAACD,QACxB,MAAKE,uBAAuB,CAACF,QAC7B,MAAKG,2BAA2B,CAACH,QACjC,MAAKI,mBAAmB,CAACJ,QAC1B,CAACK,MAAM,CAACC,kBAAW,CACtB,GACCC,IAAI,GAGP,IAAMC,gBAAkB,CACtB,QACA,aACA,iBACA,UACA,gBACD,CACDT,YAAYU,IAAI,CAAC,SAACC,EAAGC,GACnB,IAAeD,gCAAAA,EAAEE,KAAK,CAACC,KAAK,CAAC,QAAtBC,KAAQJ,kBACf,IAAeC,gCAAAA,EAAEC,KAAK,CAACC,KAAK,CAAC,QAAtBE,KAAQJ,kBACf,IAAM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AA8B0B,OAA5B9E,OAAOqD,KAAK,CAACC,MAAM,CAAC,UAAkB,OAAVwB,WAClD,IAAMvB,SAA2B,CAC/BC,SAAU,SACVC,SAAUgB,SACZ,EAGA,IAAMjC,KAAOqB,GAAAA,oCAAoB,EAACN,SAAU/B,YAE5C,MAAO,CACL,AAAC,gBAA+BgB,OAAhBY,WAAW,OAAU,OAALZ,MAChC,AAAC,eAA6CY,OAA/BA,WAAW,sBAA+B,OAAXA,WAAW,KAC1D,AACH,GACC7C,IAAI,WAtBe,CAuBtB,AAAC,eAAkC,OAApBP,OAAOqD,KAAK,CAACC,MAAM,CAAC,qBAWpC,CAVC,qBAAGuB,WAAWjF,GAAG,CACf,SAACkF,iBACC,AAAC,KAAkB9E,OAAd8E,UAAU,MAAgCA,OAA5B9E,OAAOqD,KAAK,CAACC,MAAM,CAAC,UAAkB,OAAVwB,UAAU,QA1BvC,CA4BtB,IACA,AAAC,gBAAyDD,OAA1C7E,OAAOqD,KAAK,CAACC,MAAM,CAAC,wBAEvB,OAF6CuB,WACvDjF,GAAG,CAAC,SAACqF,SAAM,AAAC,IAAK,OAAFA,EAAE,OACjBxC,IAAI,CAAC,KAAK,OACb,AAAC,eAA+DzC,OAAjDA,OAAOqD,KAAK,CAACC,MAAM,CAAC,+BAAiD,OAApBtD,OAAOqD,KAAK,CAACC,MAAM,CAAC,cACpF,GACD,EAED,MAAO,CACL1C,MAAO,AAAC,YAAqB,OAAVZ,OAAOH,EAAE,EAC5B0B,MAAAA,MACAC,WAAYC,eAAC,CAACC,IAAI,CAACF,WACrB,CACF,YAzRWzC,qBAA4BmG,sBAAQ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TemplateOptions } from "../types/types";
|
|
3
|
+
import { ExtendedApi } from "../api/decorators";
|
|
4
|
+
import { Template } from "./base-template";
|
|
5
|
+
export declare class Template__generated_http extends Template {
|
|
6
|
+
constructor();
|
|
7
|
+
getTargetAndPath(): {
|
|
8
|
+
target: string;
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
render({}: TemplateOptions["generated_http"]): Promise<{
|
|
12
|
+
body: string;
|
|
13
|
+
importKeys: never[];
|
|
14
|
+
target: string;
|
|
15
|
+
path: string;
|
|
16
|
+
}>;
|
|
17
|
+
zodTypeToReqDefault(zodType: z.ZodType<unknown>, name: string): unknown;
|
|
18
|
+
resolveApiParams(api: ExtendedApi, references: {
|
|
19
|
+
[typeName: string]: z.ZodObject<any>;
|
|
20
|
+
}): {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=generated_http.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated_http.template.d.ts","sourceRoot":"","sources":["../../src/templates/generated_http.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,qBAAa,wBAAyB,SAAQ,QAAQ;;IAKpD,gBAAgB;;;;IASV,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,gBAAgB,CAAC;;;;;;IAsDlD,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IA4DvE,gBAAgB,CACd,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KAAE,GACnD;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE;CAM9B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__generated_http",{enumerable:true,get:function(){return Template__generated_http}});var _qs=/*#__PURE__*/_interop_require_default(require("qs"));var _zod=require("zod");var _codeconverters=require("../api/code-converters");var _basetemplate=require("./base-template");var _prettier=/*#__PURE__*/_interop_require_default(require("prettier"));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 asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}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 _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_destructuring_empty(o){if(o===null||o===void 0)throw new TypeError("Cannot destructure "+o);return o}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})()}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}var Template__generated_http=/*#__PURE__*/function(Template){"use strict";_inherits(Template__generated_http,Template);function Template__generated_http(){_class_call_check(this,Template__generated_http);return _call_super(this,Template__generated_http,["generated_http"])}_create_class(Template__generated_http,[{key:"getTargetAndPath",value:function getTargetAndPath(){var dir=_sonamu.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"sonamu.generated.http"}}},{key:"render",value:function render(_0){return _async_to_generator(function(param){var _this,ref,_Sonamu_syncer,types,apis,_Sonamu_config,prefix,lines;return _ts_generator(this,function(_state){switch(_state.label){case 0:_this=this;ref=_object_destructuring_empty(param);_Sonamu_syncer=_sonamu.Sonamu.syncer,types=_Sonamu_syncer.types,apis=_Sonamu_syncer.apis,_Sonamu_config=_sonamu.Sonamu.config,prefix=_Sonamu_config.route.prefix;return[4,Promise.all(apis.map(function(api){return _async_to_generator(function(){var reqObject,dataLines,_api_options_httpMethod,_api_options_contentType;return _ts_generator(this,function(_state){switch(_state.label){case 0:reqObject=this.resolveApiParams(api,types);return[4,function(){return _async_to_generator(function(){var _api_options_httpMethod,_tmp,_tmp1;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!(((_api_options_httpMethod=api.options.httpMethod)!==null&&_api_options_httpMethod!==void 0?_api_options_httpMethod:"GET")==="GET"))return[3,1];return[2,{querystring:[_qs.default.stringify(reqObject,{encode:false}).split("&").join("\n &")],body:[]}];case 1:_tmp={querystring:[]};_tmp1=[""];return[4,_prettier.default.format(JSON.stringify(reqObject),{parser:"json"})];case 2:return[2,(_tmp.body=_tmp1.concat([_state.sent()]),_tmp)];case 3:return[2]}})})()}()];case 1:dataLines=_state.sent();return[2,[["".concat((_api_options_httpMethod=api.options.httpMethod)!==null&&_api_options_httpMethod!==void 0?_api_options_httpMethod:"GET"," {{baseUrl}}").concat(prefix).concat(api.path)].concat(_to_consumable_array(dataLines.querystring)).join("\n ?"),"Content-Type: ".concat((_api_options_contentType=api.options.contentType)!==null&&_api_options_contentType!==void 0?_api_options_contentType:"application/json")].concat(_to_consumable_array(dataLines.body)).join("\n")]}})}).call(_this)}))];case 1:lines=_state.sent();return[2,_object_spread_props(_object_spread({},this.getTargetAndPath()),{body:lines.join("\n\n###\n\n"),importKeys:[]})]}})}).apply(this,arguments)}},{key:"zodTypeToReqDefault",value:function zodTypeToReqDefault(zodType,name){var _this=this;if(_instanceof(zodType,_zod.z.ZodObject)){return Object.fromEntries(Object.keys(zodType.shape).map(function(key){return[key,_this.zodTypeToReqDefault(zodType.shape[key],key)]}))}else if(_instanceof(zodType,_zod.z.ZodArray)){return[this.zodTypeToReqDefault(zodType.element,name)]}else if(_instanceof(zodType,_zod.z.ZodString)){if(name.endsWith("_at")||name.endsWith("_date")||name==="range"){return"2000-01-01"}else{return name.toUpperCase()}}else if(_instanceof(zodType,_zod.z.ZodNumber)){if(name==="num"){return 24}var _zodType_minValue;var minValue=(_zodType_minValue=zodType.minValue)!==null&&_zodType_minValue!==void 0?_zodType_minValue:0;return minValue>Number.MIN_SAFE_INTEGER?minValue:0}else if(_instanceof(zodType,_zod.z.ZodBoolean)){return false}else if(_instanceof(zodType,_zod.z.ZodEnum)){return zodType.options[0]}else if(_instanceof(zodType,_zod.z.ZodOptional)){return this.zodTypeToReqDefault(zodType.def.innerType,name)}else if(_instanceof(zodType,_zod.z.ZodNullable)){return null}else if(_instanceof(zodType,_zod.z.ZodUnion)){return this.zodTypeToReqDefault(zodType.def.options[0],name)}else if(_instanceof(zodType,_zod.z.ZodUnknown)){return"unknown"}else if(_instanceof(zodType,_zod.z.ZodTuple)){return zodType.def.items.map(function(item){return _this.zodTypeToReqDefault(item,name)})}else if(_instanceof(zodType,_zod.z.ZodDate)){return"2000-01-01"}else if(_instanceof(zodType,_zod.z.ZodLiteral)){return zodType.value}else if(_instanceof(zodType,_zod.z.ZodRecord)||_instanceof(zodType,_zod.z.ZodMap)){var kvDef=zodType.def;var key=this.zodTypeToReqDefault(kvDef.keyType,name);var value=this.zodTypeToReqDefault(kvDef.valueType,name);return _define_property({},key,value)}else if(_instanceof(zodType,_zod.z.ZodSet)){return[this.zodTypeToReqDefault(zodType.def.valueType,name)]}else if(_instanceof(zodType,_zod.z.ZodIntersection)){return this.zodTypeToReqDefault(zodType.def.right,name)}else if(_instanceof(zodType,_zod.z.ZodDefault)){return this.zodTypeToReqDefault(zodType.def.innerType,name)}else{return"unknown-".concat(zodType.type)}}},{key:"resolveApiParams",value:function resolveApiParams(api,references){var reqType=(0,_codeconverters.getZodObjectFromApi)(api,references);return this.zodTypeToReqDefault(reqType,"unknownName")}}]);return Template__generated_http}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=generated_http.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/templates/generated_http.template.ts"],"sourcesContent":["import qs from \"qs\";\nimport { z } from \"zod\";\nimport { TemplateOptions } from \"../types/types\";\nimport { getZodObjectFromApi } from \"../api/code-converters\";\nimport { ExtendedApi } from \"../api/decorators\";\nimport { Template } from \"./base-template\";\nimport prettier from \"prettier\";\nimport { Sonamu } from \"../api/sonamu\";\n\nexport class Template__generated_http extends Template {\n constructor() {\n super(\"generated_http\");\n }\n\n getTargetAndPath() {\n const { dir } = Sonamu.config.api;\n\n return {\n target: `${dir}/src/application`,\n path: `sonamu.generated.http`,\n };\n }\n\n async render({}: TemplateOptions[\"generated_http\"]) {\n const {\n syncer: { types, apis },\n config: {\n route: { prefix },\n },\n } = Sonamu;\n\n const lines = await Promise.all(\n apis.map(async (api) => {\n const reqObject = this.resolveApiParams(api, types);\n\n const dataLines = await (async () => {\n if ((api.options.httpMethod ?? \"GET\") === \"GET\") {\n return {\n querystring: [\n qs\n .stringify(reqObject, { encode: false })\n .split(\"&\")\n .join(\"\\n\\t&\"),\n ],\n body: [],\n };\n } else {\n return {\n querystring: [],\n body: [\n \"\",\n await prettier.format(JSON.stringify(reqObject), {\n parser: \"json\",\n }),\n ],\n };\n }\n })();\n\n return [\n [\n `${api.options.httpMethod ?? \"GET\"} {{baseUrl}}${prefix}${api.path}`,\n ...dataLines.querystring,\n ].join(\"\\n\\t?\"),\n `Content-Type: ${api.options.contentType ?? \"application/json\"}`,\n ...dataLines.body,\n ].join(\"\\n\");\n })\n );\n\n return {\n ...this.getTargetAndPath(),\n body: lines.join(\"\\n\\n###\\n\\n\"),\n importKeys: [],\n };\n }\n\n zodTypeToReqDefault(zodType: z.ZodType<unknown>, name: string): unknown {\n if (zodType instanceof z.ZodObject) {\n return Object.fromEntries(\n Object.keys(zodType.shape).map((key) => [\n key,\n this.zodTypeToReqDefault(zodType.shape[key], key),\n ])\n );\n } else if (zodType instanceof z.ZodArray) {\n return [this.zodTypeToReqDefault((zodType as z.ZodArray<z.ZodType>).element, name)];\n } else if (zodType instanceof z.ZodString) {\n if (name.endsWith(\"_at\") || name.endsWith(\"_date\") || name === \"range\") {\n return \"2000-01-01\";\n } else {\n return name.toUpperCase();\n }\n } else if (zodType instanceof z.ZodNumber) {\n if (name === \"num\") {\n return 24;\n }\n\n const minValue = zodType.minValue ?? 0;\n return minValue > Number.MIN_SAFE_INTEGER ? minValue : 0;\n } else if (zodType instanceof z.ZodBoolean) {\n return false;\n } else if (zodType instanceof z.ZodEnum) {\n return zodType.options[0];\n } else if (zodType instanceof z.ZodOptional) {\n return this.zodTypeToReqDefault((zodType as z.ZodOptional<z.ZodType>).def.innerType, name);\n } else if (zodType instanceof z.ZodNullable) {\n return null;\n } else if (zodType instanceof z.ZodUnion) {\n return this.zodTypeToReqDefault((zodType as z.ZodUnion<z.ZodType[]>).def.options[0], name);\n } else if (zodType instanceof z.ZodUnknown) {\n return \"unknown\";\n } else if (zodType instanceof z.ZodTuple) {\n return zodType.def.items.map((item: any) =>\n this.zodTypeToReqDefault(item, name)\n );\n } else if (zodType instanceof z.ZodDate) {\n return \"2000-01-01\";\n } else if (zodType instanceof z.ZodLiteral) {\n return zodType.value;\n } else if (zodType instanceof z.ZodRecord || zodType instanceof z.ZodMap) {\n const kvDef = (zodType as z.ZodRecord<any, z.ZodType> | z.ZodMap<z.ZodType, z.ZodType>).def\n const key = this.zodTypeToReqDefault(kvDef.keyType, name) as any;\n const value = this.zodTypeToReqDefault(kvDef.valueType, name);\n return { [key]: value };\n } else if (zodType instanceof z.ZodSet) {\n return [this.zodTypeToReqDefault((zodType as z.ZodSet<z.ZodType>).def.valueType, name)];\n } else if (zodType instanceof z.ZodIntersection) {\n return this.zodTypeToReqDefault((zodType as z.ZodIntersection<z.ZodType, z.ZodType>).def.right, name);\n } else if (zodType instanceof z.ZodDefault) {\n return this.zodTypeToReqDefault((zodType as z.ZodDefault<z.ZodType>).def.innerType, name);\n } else {\n // console.log(zodType);\n return `unknown-${zodType.type}`;\n }\n }\n\n resolveApiParams(\n api: ExtendedApi,\n references: { [typeName: string]: z.ZodObject<any> }\n ): { [key: string]: unknown } {\n const reqType = getZodObjectFromApi(api, references);\n return this.zodTypeToReqDefault(reqType, \"unknownName\") as {\n [key: string]: unknown;\n };\n }\n}\n"],"names":["Template__generated_http","getTargetAndPath","dir","Sonamu","config","api","target","path","render","types","apis","prefix","lines","syncer","route","Promise","all","map","reqObject","dataLines","resolveApiParams","options","httpMethod","querystring","qs","stringify","encode","split","join","body","prettier","format","JSON","parser","contentType","importKeys","zodTypeToReqDefault","zodType","name","z","ZodObject","Object","fromEntries","keys","shape","key","ZodArray","element","ZodString","endsWith","toUpperCase","ZodNumber","minValue","Number","MIN_SAFE_INTEGER","ZodBoolean","ZodEnum","ZodOptional","def","innerType","ZodNullable","ZodUnion","ZodUnknown","ZodTuple","items","item","ZodDate","ZodLiteral","value","ZodRecord","ZodMap","kvDef","keyType","valueType","ZodSet","ZodIntersection","right","ZodDefault","type","references","reqType","getZodObjectFromApi","Template"],"mappings":"oGASaA,kEAAAA,kFATE,wBACG,mCAEkB,oDAEX,+EACJ,iCACE,krNAEhB,IAAA,AAAMA,sCAAN,0CAAMA,4CAAAA,kDAAAA,0BAET,OAAA,iBAFSA,0BAEH,iCAFGA,2BAKXC,IAAAA,yBAAAA,SAAAA,mBACE,IAAM,AAAEC,IAAQC,cAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,uBACR,CACF,IAEMC,IAAAA,eAAN,SAAMA,+CAAO,KAAqC,YAArC,mBAECC,MAAOC,oBAENC,OAIPC,wFARK,gCAAA,sBAMPT,cAAM,CAJRU,OAAUJ,qBAAAA,MAAOC,oBAAAA,oBAIfP,cAAM,CAHRC,OACWO,sBAATG,MAASH,OAIC,SAAMI,QAAQC,GAAG,CAC7BN,KAAKO,GAAG,CAAC,SAAOZ,+CACRa,UAEAC,UA0BCd,wBAGYA,gGA/Bba,UAAY,IAAI,CAACE,gBAAgB,CAACf,IAAKI,OAE3B,SAAM,AAAC,qDAClBJ,8GAAD,CAAA,AAACA,CAAAA,CAAAA,wBAAAA,IAAIgB,OAAO,CAACC,UAAU,UAAtBjB,iCAAAA,wBAA0B,KAAI,IAAO,KAAI,EAA1C,YACF,SAAO,CACLkB,WAAW,EACTC,WAAE,CACCC,SAAS,CAACP,UAAW,CAAEQ,OAAQ,KAAM,GACrCC,KAAK,CAAC,KACNC,IAAI,CAAC,SAEVC,IAAI,GACN,gBAGEN,WAAW,YAET,IACA,SAAMO,iBAAQ,CAACC,MAAM,CAACC,KAAKP,SAAS,CAACP,WAAY,CAC/Ce,OAAQ,MACV,WANJ,eAEEJ,mBAEE,0CAMR,gBAtBMV,UAAY,cAwBlB,SAAO,CACL,CACE,AAAC,GAAgDR,OAA9CN,CAAAA,wBAAAA,IAAIgB,OAAO,CAACC,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IAAMb,IAAM,IAAI,CAACT,mBAAmB,CAACmC,MAAMC,OAAO,CAAElC,MACpD,IAAM8B,MAAQ,IAAI,CAAChC,mBAAmB,CAACmC,MAAME,SAAS,CAAEnC,MACxD,OAAS,oBAACO,IAAMuB,MAClB,MAAO,GAAI/B,AAAO,YAAPA,QAAmBE,MAAC,CAACmC,MAAM,EAAE,CACtC,MAAO,CAAC,IAAI,CAACtC,mBAAmB,CAAC,AAACC,QAAgCqB,GAAG,CAACe,SAAS,CAAEnC,MAAM,AACzF,MAAO,GAAID,AAAO,YAAPA,QAAmBE,MAAC,CAACoC,eAAe,EAAE,CAC/C,OAAO,IAAI,CAACvC,mBAAmB,CAAC,AAACC,QAAoDqB,GAAG,CAACkB,KAAK,CAAEtC,KAClG,MAAO,GAAID,AAAO,YAAPA,QAAmBE,MAAC,CAACsC,UAAU,EAAE,CAC1C,OAAO,IAAI,CAACzC,mBAAmB,CAAC,AAACC,QAAoCqB,GAAG,CAACC,SAAS,CAAErB,KACtF,KAAO,CAEL,MAAO,AAAC,WAAuB,OAAbD,QAAQyC,IAAI,CAChC,CACF,IAEA1D,IAAAA,yBAAAA,SAAAA,iBACEf,GAAgB,CAChB0E,UAAoD,EAEpD,IAAMC,QAAUC,GAAAA,mCAAmB,EAAC5E,IAAK0E,YACzC,OAAO,IAAI,CAAC3C,mBAAmB,CAAC4C,QAAS,cAG3C,YAxIWhF,0BAAiCkF,sBAAQ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TemplateOptions } from "../types/types";
|
|
2
|
+
import { Template } from "./base-template";
|
|
3
|
+
import { SourceCode } from "./generated.template";
|
|
4
|
+
import { Entity } from "../entity/entity";
|
|
5
|
+
export declare class Template__generated_sso extends Template {
|
|
6
|
+
constructor();
|
|
7
|
+
getTargetAndPath(): {
|
|
8
|
+
target: string;
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
render({}: TemplateOptions["generated_sso"]): {
|
|
12
|
+
body: string;
|
|
13
|
+
importKeys: string[];
|
|
14
|
+
customHeaders: string[];
|
|
15
|
+
target: string;
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
getDatabaseSchemaSourceCode(entities: Entity[]): SourceCode | null;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=generated_sso.template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated_sso.template.d.ts","sourceRoot":"","sources":["../../src/templates/generated_sso.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,qBAAa,uBAAwB,SAAQ,QAAQ;;IAKnD,gBAAgB;;;;IAShB,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,eAAe,CAAC;;;;;;;IAyE3C,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG,IAAI;CAkCnE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"Template__generated_sso",{enumerable:true,get:function(){return Template__generated_sso}});var _types=require("../types/types");var _entitymanager=require("../entity/entity-manager");var _basetemplate=require("./base-template");var _inflection=/*#__PURE__*/_interop_require_default(require("inflection"));var _lodash=/*#__PURE__*/_interop_require_default(require("lodash"));var _utils=require("../utils/utils");var _api=require("../api");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_destructuring_empty(o){if(o===null||o===void 0)throw new TypeError("Cannot destructure "+o);return o}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__generated_sso=/*#__PURE__*/function(Template){"use strict";_inherits(Template__generated_sso,Template);function Template__generated_sso(){_class_call_check(this,Template__generated_sso);return _call_super(this,Template__generated_sso,["generated_sso"])}_create_class(Template__generated_sso,[{key:"getTargetAndPath",value:function getTargetAndPath(){var dir=_api.Sonamu.config.api.dir;return{target:"".concat(dir,"/src/application"),path:"sonamu.generated.sso.ts"}}},{key:"render",value:function render(param){var ref=_object_destructuring_empty(param);var entityIds=_entitymanager.EntityManager.getAllIds();var entities=entityIds.map(function(id){return _entitymanager.EntityManager.get(id)});var sourceCodes=entities.map(function(entity){if(entity.parentId!==undefined||Object.keys(entity.subsets).length===0){return null}var subsetKeys=Object.keys(entity.subsets);var subsetQueryObject=subsetKeys.reduce(function(r,subsetKey){var subsetQuery=entity.getSubsetQuery(subsetKey);r[subsetKey]=subsetQuery;return r},{});var subsetKeyTypeName="".concat(entity.names.module,"SubsetKey");return{label:"SubsetQuery: ".concat(entity.id),lines:["export const ".concat(_inflection.default.camelize(entity.id,true),"SubsetQueries:{ [key in ").concat(subsetKeyTypeName,"]: SubsetQuery} = ").concat(JSON.stringify(subsetQueryObject),";"),""],importKeys:[subsetKeyTypeName]}}).filter(_utils.nonNullable);var dbSchemaSourceCode=this.getDatabaseSchemaSourceCode(entities);if(dbSchemaSourceCode){sourceCodes.push(dbSchemaSourceCode)}var sourceCode=sourceCodes.reduce(function(result,ts){if(ts===null){return result}return{lines:_to_consumable_array(result.lines).concat(["// ".concat(ts.label)],_to_consumable_array(ts.lines),[""]),importKeys:_lodash.default.uniq(_to_consumable_array(result.importKeys).concat(_to_consumable_array(ts.importKeys)))}},{lines:[],importKeys:[]});return _object_spread_props(_object_spread({},this.getTargetAndPath()),{body:sourceCode.lines.join("\n"),importKeys:sourceCode.importKeys,customHeaders:['import { SubsetQuery, ManyToManyBaseSchema } from "sonamu";']})}},{key:"getDatabaseSchemaSourceCode",value:function getDatabaseSchemaSourceCode(entities){if(entities.length===0){return null}var entitySchemaLines=entities.map(function(entity){return"".concat(entity.table,": ").concat(entity.id,"BaseSchema;")});var joinTableSchemaLines=_lodash.default.uniq(entities.flatMap(function(entity){return entity.props.filter(_types.isManyToManyRelationProp).map(function(prop){var fromTableKey=_inflection.default.singularize(entity.table);var toTableKey=_inflection.default.singularize(_entitymanager.EntityManager.get(prop.with).table);return"".concat(prop.joinTable,': ManyToManyBaseSchema<"').concat(fromTableKey,'", "').concat(toTableKey,'">;')})}));return{label:"DatabaseSchema",lines:['declare module "sonamu" {'," export interface DatabaseSchemaExtend {"].concat(_to_consumable_array(entitySchemaLines),_to_consumable_array(joinTableSchemaLines),[" }","}"]),importKeys:entities.map(function(entity){return"".concat(entity.id,"BaseSchema")})}}}]);return Template__generated_sso}(_basetemplate.Template);
|
|
2
|
+
//# sourceMappingURL=generated_sso.template.js.map
|
|
@@ -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":"oGAcaA,iEAAAA,8CAVN,6CACuB,sDACL,iFACF,yEAET,8BACc,mCACL,itJAGhB,IAAA,AAAMA,qCAAN,0CAAMA,2CAAAA,iDAAAA,yBAET,OAAA,iBAFSA,yBAEH,gCAFGA,0BAKXC,IAAAA,yBAAAA,SAAAA,mBACE,IAAM,AAAEC,IAAQC,WAAM,CAACC,MAAM,CAACC,GAAG,CAAzBH,IAER,MAAO,CACLI,OAAQ,AAAC,GAAM,OAAJJ,IAAI,oBACfK,KAAM,yBACR,CACF,IAEAC,IAAAA,eAAAA,SAAAA,OAAO,KAAoC,MAApC,gCAAA,OACL,IAAMC,UAAYC,4BAAa,CAACC,SAAS,GACzC,IAAMC,SAAWH,UAAUI,GAAG,CAAC,SAACC,WAAOJ,4BAAa,CAACK,GAAG,CAACD,MAEzD,IAAME,YAA4BJ,SAC/BC,GAAG,CAAC,SAACI,QACJ,GACEA,OAAOC,QAAQ,GAAKC,WACpBC,OAAOC,IAAI,CAACJ,OAAOK,OAAO,EAAEC,MAAM,GAAK,EACvC,CACA,OAAO,IACT,CACA,IAAMC,WAAaJ,OAAOC,IAAI,CAACJ,OAAOK,OAAO,EAC7C,IAAMG,kBAAoBD,WAAWE,MAAM,CACzC,SAACC,EAAGC,WACF,IAAMC,YAAcZ,OAAOa,cAAc,CAACF,UAC1CD,CAAAA,CAAC,CAACC,UAAU,CAAGC,YACf,OAAOF,CACT,EACA,CAAC,GAKH,IAAMI,kBAAoB,AAAC,GAAsB,OAApBd,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iBAG5C,IAAM0C,qBAAuBP,eAAC,CAACC,IAAI,CACjCtC,SAAS6C,OAAO,CAAC,SAACxC,eAChBA,OAAOyC,KAAK,CAACjB,MAAM,CAACkB,+BAAwB,EAAE9C,GAAG,CAAC,SAAC+C,MACjD,IAAMC,aAAezB,mBAAU,CAAC0B,WAAW,CAAC7C,OAAOsC,KAAK,EACxD,IAAMQ,WAAa3B,mBAAU,CAAC0B,WAAW,CACvCpD,4BAAa,CAACK,GAAG,CAAC6C,KAAKI,IAAI,EAAET,KAAK,EAEpC,MAAO,AAAC,GAA2CM,OAAzCD,KAAKK,SAAS,CAAC,4BAA6CF,OAAnBF,aAAa,QAAiB,OAAXE,WAAW,MACnF,MAIJ,MAAO,CACL7B,MAAO,iBACPC,MAAO,CACL,4BACA,4CAKD,CAPM,OAGL,qBAAGmB,mBACH,qBAAGE,sBAJE,CAKL,MACA,IACD,EACDhB,WAAY5B,SAASC,GAAG,CAAC,SAACI,cAAW,AAAC,GAAY,OAAVA,OAAOH,EAAE,CAAC,eACpD,CACF,YAxHWd,yBAAgCkE,sBAAQ"}
|
|
@@ -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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|
|
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":"oGAgBaA,2DAAAA,mFAhBU,yEACT,8BAGyB,8CAOhC,oDAEkB,uCACF,kmJAEhB,IAAA,AAAMA,+BAAN,0CAAMA,qCAAAA,2CAAAA,mBAET,OAAA,iBAFSA,mBAEH,0BAFGA,oBAKXC,IAAAA,yBAAAA,SAAAA,iBAAiBC,KAAwB,EACvC,MAAO,CACLC,O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