sonamu 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc.project-default +18 -0
- package/bin/cli.js +24 -0
- package/dist/ai/agents/agent.d.ts +11 -0
- package/dist/ai/agents/agent.d.ts.map +1 -0
- package/dist/ai/agents/agent.js +65 -0
- package/dist/ai/agents/index.d.ts +3 -0
- package/dist/ai/agents/index.d.ts.map +1 -0
- package/dist/ai/agents/index.js +4 -0
- package/dist/ai/agents/types.d.ts +43 -0
- package/dist/ai/agents/types.d.ts.map +1 -0
- package/dist/ai/agents/types.js +3 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +3 -0
- package/dist/ai/providers/rtzr/api.d.ts +22 -0
- package/dist/ai/providers/rtzr/api.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/api.js +28 -0
- package/dist/ai/providers/rtzr/error.d.ts +18 -0
- package/dist/ai/providers/rtzr/error.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/error.js +29 -0
- package/dist/ai/providers/rtzr/index.d.ts +5 -0
- package/dist/ai/providers/rtzr/index.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/index.js +6 -0
- package/dist/ai/providers/rtzr/model.d.ts +52 -0
- package/dist/ai/providers/rtzr/model.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/model.js +137 -0
- package/dist/ai/providers/rtzr/options.d.ts +7 -0
- package/dist/ai/providers/rtzr/options.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/options.js +47 -0
- package/dist/ai/providers/rtzr/provider.d.ts +18 -0
- package/dist/ai/providers/rtzr/provider.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/provider.js +54 -0
- package/dist/ai/providers/rtzr/utils.d.ts +19 -0
- package/dist/ai/providers/rtzr/utils.d.ts.map +1 -0
- package/dist/ai/providers/rtzr/utils.js +88 -0
- package/dist/api/base-frame.d.ts +2 -2
- package/dist/api/base-frame.d.ts.map +1 -1
- package/dist/api/base-frame.js +2 -1
- package/dist/api/caster.d.ts.map +1 -1
- package/dist/api/caster.js +6 -1
- package/dist/api/code-converters.d.ts +58 -14
- package/dist/api/code-converters.d.ts.map +1 -1
- package/dist/api/code-converters.js +178 -409
- package/dist/api/config.d.ts +27 -13
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +19 -26
- package/dist/api/context.d.ts +4 -3
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +1 -1
- package/dist/api/decorators.d.ts +20 -6
- package/dist/api/decorators.d.ts.map +1 -1
- package/dist/api/decorators.js +111 -18
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -3
- package/dist/api/sonamu.d.ts +7 -7
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +83 -51
- package/dist/api/validator.d.ts +6 -0
- package/dist/api/validator.d.ts.map +1 -0
- package/dist/api/validator.js +81 -0
- package/dist/bin/build-config.d.ts +5 -1
- package/dist/bin/build-config.d.ts.map +1 -1
- package/dist/bin/build-config.js +5 -2
- package/dist/bin/cli.js +165 -64
- package/dist/bin/loader-register.d.ts +2 -0
- package/dist/bin/loader-register.d.ts.map +1 -0
- package/dist/bin/loader-register.js +34 -0
- package/dist/database/_batch_update.d.ts +5 -3
- package/dist/database/_batch_update.d.ts.map +1 -1
- package/dist/database/_batch_update.js +30 -13
- package/dist/database/base-model.d.ts +96 -10
- package/dist/database/base-model.d.ts.map +1 -1
- package/dist/database/base-model.js +232 -89
- package/dist/database/base-model.types.d.ts +93 -0
- package/dist/database/base-model.types.d.ts.map +1 -0
- package/dist/database/base-model.types.js +10 -0
- package/dist/database/code-generator.d.ts +1 -1
- package/dist/database/code-generator.d.ts.map +1 -1
- package/dist/database/code-generator.js +11 -10
- package/dist/database/db.d.ts +5 -6
- package/dist/database/db.d.ts.map +1 -1
- package/dist/database/db.js +22 -25
- package/dist/database/puri-subset.test-d.js +81 -0
- package/dist/database/puri-subset.types.d.ts +123 -0
- package/dist/database/puri-subset.types.d.ts.map +1 -0
- package/dist/database/puri-subset.types.js +16 -0
- package/dist/database/puri-wrapper.d.ts +13 -11
- package/dist/database/puri-wrapper.d.ts.map +1 -1
- package/dist/database/puri-wrapper.js +2 -2
- package/dist/database/puri.d.ts +25 -14
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +83 -21
- package/dist/database/puri.types.d.ts +21 -7
- package/dist/database/puri.types.d.ts.map +1 -1
- package/dist/database/puri.types.js +4 -1
- package/dist/database/transaction-context.d.ts +1 -1
- package/dist/database/transaction-context.d.ts.map +1 -1
- package/dist/database/transaction-context.js +1 -1
- package/dist/database/upsert-builder.d.ts +9 -3
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +228 -78
- package/dist/entity/entity-manager.d.ts +165 -2
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +26 -10
- package/dist/entity/entity.d.ts +5 -3
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +153 -54
- package/dist/exceptions/error-handler.d.ts +1 -1
- package/dist/exceptions/error-handler.d.ts.map +1 -1
- package/dist/exceptions/error-handler.js +1 -1
- package/dist/exceptions/so-exceptions.d.ts +1 -1
- package/dist/exceptions/so-exceptions.d.ts.map +1 -1
- package/dist/exceptions/so-exceptions.js +1 -1
- package/dist/file-storage/driver.d.ts +1 -1
- package/dist/file-storage/driver.d.ts.map +1 -1
- package/dist/file-storage/driver.js +1 -1
- package/dist/file-storage/file-storage.js +2 -2
- package/dist/index.d.ts +18 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -13
- package/dist/migration/code-generation.d.ts +1 -1
- package/dist/migration/code-generation.d.ts.map +1 -1
- package/dist/migration/code-generation.js +123 -67
- package/dist/migration/migration-set.d.ts +2 -10
- package/dist/migration/migration-set.d.ts.map +1 -1
- package/dist/migration/migration-set.js +67 -218
- package/dist/migration/migrator.d.ts +24 -73
- package/dist/migration/migrator.d.ts.map +1 -1
- package/dist/migration/migrator.js +121 -301
- package/dist/migration/postgresql-schema-reader.d.ts +51 -0
- package/dist/migration/postgresql-schema-reader.d.ts.map +1 -0
- package/dist/migration/postgresql-schema-reader.js +245 -0
- package/dist/migration/types.d.ts +6 -38
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/migration/types.js +1 -1
- package/dist/naite/messaging-types.d.ts +43 -0
- package/dist/naite/messaging-types.d.ts.map +1 -0
- package/dist/naite/messaging-types.js +7 -0
- package/dist/naite/naite-reporter.d.ts +41 -0
- package/dist/naite/naite-reporter.d.ts.map +1 -0
- package/dist/naite/naite-reporter.js +102 -0
- package/dist/naite/naite.d.ts +91 -8
- package/dist/naite/naite.d.ts.map +1 -1
- package/dist/naite/naite.js +285 -41
- package/dist/stream/sse.d.ts +2 -2
- package/dist/stream/sse.d.ts.map +1 -1
- package/dist/stream/sse.js +1 -1
- package/dist/syncer/api-parser.d.ts +3 -13
- package/dist/syncer/api-parser.d.ts.map +1 -1
- package/dist/syncer/api-parser.js +67 -56
- package/dist/syncer/checksum.d.ts +2 -2
- package/dist/syncer/checksum.d.ts.map +1 -1
- package/dist/syncer/checksum.js +11 -11
- package/dist/syncer/code-generator.d.ts +3 -3
- package/dist/syncer/code-generator.d.ts.map +1 -1
- package/dist/syncer/code-generator.js +37 -17
- package/dist/syncer/entity-operations.d.ts +2 -2
- package/dist/syncer/entity-operations.d.ts.map +1 -1
- package/dist/syncer/entity-operations.js +9 -8
- package/dist/syncer/file-patterns.d.ts +1 -1
- package/dist/syncer/file-patterns.d.ts.map +1 -1
- package/dist/syncer/file-patterns.js +1 -1
- package/dist/syncer/index.d.ts +4 -4
- package/dist/syncer/index.d.ts.map +1 -1
- package/dist/syncer/index.js +5 -5
- package/dist/syncer/module-loader.d.ts +4 -4
- package/dist/syncer/module-loader.d.ts.map +1 -1
- package/dist/syncer/module-loader.js +17 -12
- package/dist/syncer/syncer.d.ts +31 -24
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +92 -45
- package/dist/template/entity-converter.d.ts +1 -1
- package/dist/template/entity-converter.d.ts.map +1 -1
- package/dist/template/entity-converter.js +15 -8
- package/dist/template/helpers.d.ts +2 -2
- package/dist/template/helpers.d.ts.map +1 -1
- package/dist/template/helpers.js +3 -3
- package/dist/template/implementations/entity.template.d.ts +2 -2
- package/dist/template/implementations/entity.template.d.ts.map +1 -1
- package/dist/template/implementations/entity.template.js +4 -5
- package/dist/template/implementations/generated.template.d.ts +2 -3
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +46 -29
- package/dist/template/implementations/generated_http.template.d.ts +2 -3
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_http.template.js +9 -9
- package/dist/template/implementations/generated_sso.template.d.ts +3 -4
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +54 -25
- package/dist/template/implementations/init_types.template.d.ts +2 -2
- package/dist/template/implementations/init_types.template.d.ts.map +1 -1
- package/dist/template/implementations/init_types.template.js +2 -2
- package/dist/template/implementations/model.template.d.ts +2 -2
- package/dist/template/implementations/model.template.d.ts.map +1 -1
- package/dist/template/implementations/model.template.js +47 -37
- package/dist/template/implementations/model_test.template.d.ts +2 -2
- package/dist/template/implementations/model_test.template.d.ts.map +1 -1
- package/dist/template/implementations/model_test.template.js +2 -2
- package/dist/template/implementations/service.template.d.ts +4 -4
- package/dist/template/implementations/service.template.d.ts.map +1 -1
- package/dist/template/implementations/service.template.js +24 -16
- package/dist/template/implementations/view_enums_buttonset.template.d.ts +2 -2
- package/dist/template/implementations/view_enums_buttonset.template.d.ts.map +1 -1
- package/dist/template/implementations/view_enums_buttonset.template.js +1 -1
- package/dist/template/implementations/view_enums_dropdown.template.d.ts +2 -2
- package/dist/template/implementations/view_enums_dropdown.template.d.ts.map +1 -1
- package/dist/template/implementations/view_enums_dropdown.template.js +2 -2
- package/dist/template/implementations/view_enums_select.template.d.ts +2 -2
- package/dist/template/implementations/view_enums_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_enums_select.template.js +2 -2
- package/dist/template/implementations/view_form.template.d.ts +2 -2
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +4 -4
- package/dist/template/implementations/view_id_all_select.template.d.ts +2 -2
- package/dist/template/implementations/view_id_all_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_id_all_select.template.js +1 -1
- package/dist/template/implementations/view_id_async_select.template.d.ts +2 -2
- package/dist/template/implementations/view_id_async_select.template.d.ts.map +1 -1
- package/dist/template/implementations/view_id_async_select.template.js +1 -1
- package/dist/template/implementations/view_list.template.d.ts +2 -2
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +29 -19
- package/dist/template/implementations/view_list_columns.template.d.ts +3 -3
- package/dist/template/implementations/view_list_columns.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list_columns.template.js +1 -1
- package/dist/template/implementations/view_search_input.template.d.ts +2 -2
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
- package/dist/template/implementations/view_search_input.template.js +1 -1
- package/dist/template/index.d.ts +4 -2
- package/dist/template/index.d.ts.map +1 -1
- package/dist/template/index.js +5 -3
- package/dist/template/template-manager.d.ts +56 -0
- package/dist/template/template-manager.d.ts.map +1 -0
- package/dist/template/template-manager.js +125 -0
- package/dist/template/template-types.d.ts +16 -0
- package/dist/template/template-types.d.ts.map +1 -0
- package/dist/template/template-types.js +7 -0
- package/dist/template/template.d.ts +12 -2
- package/dist/template/template.d.ts.map +1 -1
- package/dist/template/template.js +19 -6
- package/dist/template/zod-converter.d.ts +40 -7
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +341 -58
- package/dist/testing/_relation-graph.d.ts +1 -1
- package/dist/testing/_relation-graph.d.ts.map +1 -1
- package/dist/testing/_relation-graph.js +12 -3
- package/dist/testing/fixture-manager.d.ts +42 -11
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +338 -236
- package/dist/types/types.d.ts +709 -104
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +309 -52
- package/dist/typings/knex.d.js +2 -2
- package/dist/utils/async-utils.d.ts.map +1 -1
- package/dist/utils/async-utils.js +3 -3
- package/dist/utils/console-util.js +1 -1
- package/dist/utils/controller.d.ts +1 -0
- package/dist/utils/controller.d.ts.map +1 -1
- package/dist/utils/controller.js +4 -1
- package/dist/utils/esm-utils.d.ts +0 -6
- package/dist/utils/esm-utils.d.ts.map +1 -1
- package/dist/utils/esm-utils.js +2 -9
- package/dist/utils/formatter.d.ts +3 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +110 -0
- package/dist/utils/fs-utils.d.ts +1 -1
- package/dist/utils/fs-utils.d.ts.map +1 -1
- package/dist/utils/fs-utils.js +1 -1
- package/dist/utils/lodash-able.d.ts.map +1 -1
- package/dist/utils/lodash-able.js +1 -1
- package/dist/utils/object-utils.d.ts +44 -0
- package/dist/utils/object-utils.d.ts.map +1 -0
- package/dist/utils/object-utils.js +191 -0
- package/dist/utils/path-utils.d.ts +1 -1
- package/dist/utils/path-utils.d.ts.map +1 -1
- package/dist/utils/path-utils.js +3 -3
- package/dist/utils/process-utils.js +1 -1
- package/dist/utils/sql-parser.d.ts +5 -1
- package/dist/utils/sql-parser.d.ts.map +1 -1
- package/dist/utils/sql-parser.js +14 -3
- package/dist/utils/type-utils.d.ts +23 -0
- package/dist/utils/type-utils.d.ts.map +1 -0
- package/dist/utils/type-utils.js +45 -0
- package/dist/utils/utils.d.ts +7 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +44 -5
- package/dist/utils/zod-error.d.ts +1 -1
- package/dist/utils/zod-error.d.ts.map +1 -1
- package/dist/utils/zod-error.js +1 -1
- package/package.json +54 -29
- package/src/ai/agents/agent.ts +87 -0
- package/src/ai/agents/index.ts +2 -0
- package/src/ai/agents/types.ts +47 -0
- package/src/ai/index.ts +1 -0
- package/src/ai/providers/rtzr/api.ts +37 -0
- package/src/ai/providers/rtzr/error.ts +34 -0
- package/src/ai/providers/rtzr/index.ts +4 -0
- package/src/ai/providers/rtzr/model.ts +201 -0
- package/src/ai/providers/rtzr/options.ts +49 -0
- package/src/ai/providers/rtzr/provider.ts +91 -0
- package/src/ai/providers/rtzr/utils.ts +127 -0
- package/src/api/base-frame.ts +4 -2
- package/src/api/caster.ts +17 -23
- package/src/api/code-converters.ts +176 -533
- package/src/api/config.ts +39 -56
- package/src/api/context.ts +7 -18
- package/src/api/decorators.ts +175 -46
- package/src/api/index.ts +2 -2
- package/src/api/sonamu.ts +133 -124
- package/src/api/validator.ts +83 -0
- package/src/bin/build-config.ts +7 -1
- package/src/bin/cli.ts +192 -110
- package/src/bin/loader-register.ts +38 -0
- package/src/database/_batch_update.ts +46 -31
- package/src/database/base-model.ts +390 -182
- package/src/database/base-model.types.ts +155 -0
- package/src/database/code-generator.ts +13 -32
- package/src/database/db.ts +36 -50
- package/src/database/puri-subset.test-d.ts +471 -0
- package/src/database/puri-subset.types.ts +195 -0
- package/src/database/puri-wrapper.ts +58 -67
- package/src/database/puri.ts +182 -126
- package/src/database/puri.types.ts +64 -31
- package/src/database/transaction-context.ts +1 -1
- package/src/database/upsert-builder.ts +262 -132
- package/src/entity/entity-manager.ts +36 -28
- package/src/entity/entity.ts +330 -249
- package/src/exceptions/error-handler.ts +3 -3
- package/src/exceptions/so-exceptions.ts +11 -11
- package/src/file-storage/driver.ts +5 -5
- package/src/file-storage/file-storage.ts +2 -2
- package/src/index.ts +18 -12
- package/src/migration/code-generation.ts +185 -172
- package/src/migration/migration-set.ts +80 -293
- package/src/migration/migrator.ts +182 -425
- package/src/migration/mysql-schema-reader.ts.txt +272 -0
- package/src/migration/postgresql-schema-reader.ts +310 -0
- package/src/migration/types.ts +6 -39
- package/src/naite/messaging-types.ts +51 -0
- package/src/naite/naite-reporter.ts +128 -0
- package/src/naite/naite.ts +378 -33
- package/src/shared/web.shared.ts.txt +20 -24
- package/src/stream/sse.ts +5 -5
- package/src/syncer/api-parser.ts +52 -69
- package/src/syncer/checksum.ts +25 -37
- package/src/syncer/code-generator.ts +58 -62
- package/src/syncer/entity-operations.ts +12 -15
- package/src/syncer/file-patterns.ts +2 -2
- package/src/syncer/index.ts +4 -4
- package/src/syncer/module-loader.ts +28 -25
- package/src/syncer/syncer.ts +155 -162
- package/src/template/entity-converter.ts +18 -27
- package/src/template/helpers.ts +8 -11
- package/src/template/implementations/entity.template.ts +6 -6
- package/src/template/implementations/generated.template.ts +99 -99
- package/src/template/implementations/generated_http.template.ts +21 -54
- package/src/template/implementations/generated_sso.template.ts +78 -65
- package/src/template/implementations/init_types.template.ts +4 -6
- package/src/template/implementations/model.template.ts +47 -38
- package/src/template/implementations/model_test.template.ts +3 -3
- package/src/template/implementations/service.template.ts +56 -80
- package/src/template/implementations/view_enums_buttonset.template.ts +2 -2
- package/src/template/implementations/view_enums_dropdown.template.ts +4 -4
- package/src/template/implementations/view_enums_select.template.ts +3 -3
- package/src/template/implementations/view_form.template.ts +34 -75
- package/src/template/implementations/view_id_all_select.template.ts +2 -2
- package/src/template/implementations/view_id_async_select.template.ts +9 -23
- package/src/template/implementations/view_list.template.ts +54 -95
- package/src/template/implementations/view_list_columns.template.ts +4 -10
- package/src/template/implementations/view_search_input.template.ts +2 -2
- package/src/template/index.ts +4 -2
- package/src/template/template-manager.ts +166 -0
- package/src/template/template-types.ts +16 -0
- package/src/template/template.ts +29 -10
- package/src/template/zod-converter.ts +407 -101
- package/src/testing/_relation-graph.ts +18 -11
- package/src/testing/fixture-manager.ts +468 -362
- package/src/types/types.ts +516 -248
- package/src/typings/knex.d.ts +7 -9
- package/src/utils/async-utils.ts +8 -12
- package/src/utils/console-util.ts +1 -1
- package/src/utils/controller.ts +3 -0
- package/src/utils/esm-utils.ts +8 -18
- package/src/utils/formatter.ts +109 -0
- package/src/utils/fs-utils.ts +1 -1
- package/src/utils/lodash-able.ts +1 -4
- package/src/utils/object-utils.ts +217 -0
- package/src/utils/path-utils.ts +3 -6
- package/src/utils/process-utils.ts +1 -1
- package/src/utils/sql-parser.ts +23 -5
- package/src/utils/type-utils.ts +83 -0
- package/src/utils/utils.ts +58 -9
- package/src/utils/zod-error.ts +3 -3
- package/dist/bin/cli-wrapper.d.ts +0 -3
- package/dist/bin/cli-wrapper.d.ts.map +0 -1
- package/dist/bin/cli-wrapper.js +0 -72
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts +0 -2
- package/dist/database/knex-plugins/knex-on-duplicate-update.d.ts.map +0 -1
- package/dist/database/knex-plugins/knex-on-duplicate-update.js +0 -39
- package/dist/entity/entity-utils.d.ts +0 -61
- package/dist/entity/entity-utils.d.ts.map +0 -1
- package/dist/entity/entity-utils.js +0 -210
- package/src/bin/cli-wrapper.ts +0 -82
- package/src/database/knex-plugins/knex-on-duplicate-update.ts +0 -45
- package/src/entity/entity-utils.ts +0 -291
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
/** biome-ignore-all lint/correctness/useExhaustiveDependencies: shared */
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: shared */
|
|
3
|
+
|
|
1
4
|
/*
|
|
2
5
|
fetch
|
|
3
6
|
*/
|
|
4
7
|
import type { AxiosRequestConfig } from "axios";
|
|
5
8
|
import axios from "axios";
|
|
6
|
-
import { z, ZodIssue } from "zod";
|
|
7
9
|
import qs from "qs";
|
|
10
|
+
import { type ZodIssue, z } from "zod";
|
|
8
11
|
|
|
9
12
|
// ISO 8601 및 타임존 포맷의 날짜 문자열을 Date 객체로 변환하는 reviver
|
|
10
|
-
function dateReviver(
|
|
13
|
+
function dateReviver(_key: string, value: any): any {
|
|
11
14
|
if (typeof value === "string") {
|
|
12
15
|
// ISO 8601 형식: 2024-01-15T09:30:00.000Z 또는 2024-01-15T09:30:00+09:00
|
|
13
|
-
const isoRegex =
|
|
14
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
16
|
+
const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
15
17
|
|
|
16
18
|
// Timezone 포맷: 2024-01-15 09:30:00+09:00
|
|
17
19
|
const timezoneRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}$/;
|
|
18
20
|
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
+
if (
|
|
22
|
+
(isoRegex.test(value) || timezoneRegex.test(value)) &&
|
|
23
|
+
new Date(value).toString() !== "Invalid Date"
|
|
24
|
+
) {
|
|
21
25
|
return new Date(value);
|
|
22
26
|
}
|
|
23
27
|
}
|
|
@@ -29,7 +33,7 @@ axios.defaults.transformResponse = [
|
|
|
29
33
|
if (typeof data === "string") {
|
|
30
34
|
try {
|
|
31
35
|
return JSON.parse(data, dateReviver);
|
|
32
|
-
} catch
|
|
36
|
+
} catch {
|
|
33
37
|
return data;
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -61,7 +65,7 @@ export class SonamuError extends Error {
|
|
|
61
65
|
constructor(
|
|
62
66
|
public code: number,
|
|
63
67
|
public message: string,
|
|
64
|
-
public issues: z.ZodIssue[]
|
|
68
|
+
public issues: z.ZodIssue[],
|
|
65
69
|
) {
|
|
66
70
|
super(message);
|
|
67
71
|
this.isSonamuError = true;
|
|
@@ -106,9 +110,7 @@ export async function swrFetcher(args: [string, object]): Promise<any> {
|
|
|
106
110
|
const res = await axios.get(`${url}?${qs.stringify(params)}`);
|
|
107
111
|
return res.data;
|
|
108
112
|
} catch (e: any) {
|
|
109
|
-
const error: any = new Error(
|
|
110
|
-
e.response.data.message ?? e.response.message ?? "Unknown"
|
|
111
|
-
);
|
|
113
|
+
const error: any = new Error(e.response.data.message ?? e.response.message ?? "Unknown");
|
|
112
114
|
error.statusCode = e.response?.data.statusCode ?? e.response.status;
|
|
113
115
|
throw error;
|
|
114
116
|
}
|
|
@@ -119,16 +121,14 @@ export async function swrPostFetcher(args: [string, object]): Promise<any> {
|
|
|
119
121
|
const res = await axios.post(url, params);
|
|
120
122
|
return res.data;
|
|
121
123
|
} catch (e: any) {
|
|
122
|
-
const error: any = new Error(
|
|
123
|
-
e.response.data.message ?? e.response.message ?? "Unknown"
|
|
124
|
-
);
|
|
124
|
+
const error: any = new Error(e.response.data.message ?? e.response.message ?? "Unknown");
|
|
125
125
|
error.statusCode = e.response?.data.statusCode ?? e.response.status;
|
|
126
126
|
throw error;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
export function handleConditional(
|
|
130
130
|
args: [string, object],
|
|
131
|
-
conditional?: () => boolean
|
|
131
|
+
conditional?: () => boolean,
|
|
132
132
|
): [string, object] | null {
|
|
133
133
|
if (conditional) {
|
|
134
134
|
return conditional() ? args : null;
|
|
@@ -139,9 +139,7 @@ export function handleConditional(
|
|
|
139
139
|
/*
|
|
140
140
|
Utils
|
|
141
141
|
*/
|
|
142
|
-
export function zArrayable<T extends z.ZodTypeAny>(
|
|
143
|
-
shape: T
|
|
144
|
-
): z.ZodUnion<[T, z.ZodArray<T>]> {
|
|
142
|
+
export function zArrayable<T extends z.ZodTypeAny>(shape: T): z.ZodUnion<[T, z.ZodArray<T>]> {
|
|
145
143
|
return z.union([shape, shape.array()]);
|
|
146
144
|
}
|
|
147
145
|
|
|
@@ -175,6 +173,7 @@ export type SSEStreamState = {
|
|
|
175
173
|
export type EventHandlers<T> = {
|
|
176
174
|
[K in keyof T]: (data: T[K]) => void;
|
|
177
175
|
};
|
|
176
|
+
|
|
178
177
|
import { useEffect, useRef, useState } from "react";
|
|
179
178
|
|
|
180
179
|
export function useSSEStream<T extends Record<string, any>>(
|
|
@@ -183,7 +182,7 @@ export function useSSEStream<T extends Record<string, any>>(
|
|
|
183
182
|
handlers: {
|
|
184
183
|
[K in keyof T]?: (data: T[K]) => void;
|
|
185
184
|
},
|
|
186
|
-
options: SSEStreamOptions = {}
|
|
185
|
+
options: SSEStreamOptions = {},
|
|
187
186
|
): SSEStreamState {
|
|
188
187
|
const { enabled = true, retry = 3, retryInterval = 3000 } = options;
|
|
189
188
|
|
|
@@ -245,7 +244,7 @@ export function useSSEStream<T extends Record<string, any>>(
|
|
|
245
244
|
}));
|
|
246
245
|
};
|
|
247
246
|
|
|
248
|
-
eventSource.onerror = (
|
|
247
|
+
eventSource.onerror = (_event) => {
|
|
249
248
|
// 이미 다른 연결로 교체되었는지 확인
|
|
250
249
|
if (eventSourceRef.current !== eventSource) {
|
|
251
250
|
return; // 이미 새로운 연결이 있으면 무시
|
|
@@ -313,10 +312,7 @@ export function useSSEStream<T extends Record<string, any>>(
|
|
|
313
312
|
const data = JSON.parse(event.data);
|
|
314
313
|
handler(data);
|
|
315
314
|
} catch (error) {
|
|
316
|
-
console.error(
|
|
317
|
-
`Failed to parse SSE data for event ${eventType}:`,
|
|
318
|
-
error
|
|
319
|
-
);
|
|
315
|
+
console.error(`Failed to parse SSE data for event ${eventType}:`, error);
|
|
320
316
|
}
|
|
321
317
|
setState((prev) => ({
|
|
322
318
|
...prev,
|
package/src/stream/sse.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
+
import type { z } from "zod";
|
|
3
3
|
|
|
4
4
|
// NOTE(Haze, 251106): context provider에서 인자를 채워주면 createSSE(events)만으로 사용 가능
|
|
5
5
|
export function createSSEFactory<T extends z.ZodObject>(
|
|
6
6
|
socket: FastifyRequest["socket"],
|
|
7
7
|
reply: FastifyReply,
|
|
8
|
-
_events: T
|
|
8
|
+
_events: T,
|
|
9
9
|
) {
|
|
10
10
|
return new SSEConnection<T>(socket, reply);
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ class SSEConnection<T extends z.ZodObject> {
|
|
|
15
15
|
|
|
16
16
|
constructor(
|
|
17
17
|
private readonly socket: FastifyRequest["socket"],
|
|
18
|
-
private readonly reply: FastifyReply
|
|
18
|
+
private readonly reply: FastifyReply,
|
|
19
19
|
) {
|
|
20
20
|
this.socket.on("close", () => {
|
|
21
21
|
this._closed = true;
|
|
@@ -42,7 +42,7 @@ class SSEConnection<T extends z.ZodObject> {
|
|
|
42
42
|
event: "end",
|
|
43
43
|
data: "END",
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
47
47
|
this.reply.raw.end();
|
|
48
48
|
}
|
package/src/syncer/api-parser.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from "assert";
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
|
-
import * as _ from "lodash-es";
|
|
4
|
-
import ts from "typescript";
|
|
5
|
-
import { ExtendedApi, registeredApis } from "../api/decorators";
|
|
6
3
|
import inflection from "inflection";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { type ExtendedApi, registeredApis } from "../api/decorators";
|
|
6
|
+
import { validateMethodName } from "../api/validator";
|
|
7
|
+
import type { ApiParam, ApiParamType } from "../types/types";
|
|
8
|
+
import type { AbsolutePath } from "../utils/path-utils";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* TypeScript 파일을 파싱하여 API 메소드 정보를 추출합니다.
|
|
@@ -13,15 +13,17 @@ import { AbsolutePath } from "../utils/path-utils";
|
|
|
13
13
|
* @param filePath - 파싱할 TypeScript 파일의 절대 경로
|
|
14
14
|
* @returns API 메소드 정보 배열 (타입 파라미터, 파라미터, 리턴 타입 등)
|
|
15
15
|
*/
|
|
16
|
-
export async function readApisFromFile(filePath: AbsolutePath) {
|
|
17
|
-
if (!filePath.endsWith(".ts")) {
|
|
18
|
-
throw new Error(
|
|
16
|
+
export async function readApisFromFile(filePath: AbsolutePath): Promise<ExtendedApi[]> {
|
|
17
|
+
if (!filePath.endsWith(".ts")) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`${filePath} does not seem to be a TypeScript file. Please check the file path. We only support parsing TypeScript files.`,
|
|
20
|
+
);
|
|
19
21
|
}
|
|
20
|
-
|
|
22
|
+
|
|
21
23
|
const sourceFile = ts.createSourceFile(
|
|
22
24
|
filePath,
|
|
23
25
|
(await readFile(filePath)).toString(),
|
|
24
|
-
ts.ScriptTarget.Latest
|
|
26
|
+
ts.ScriptTarget.Latest,
|
|
25
27
|
);
|
|
26
28
|
|
|
27
29
|
const methods: Omit<ExtendedApi, "path" | "options">[] = [];
|
|
@@ -36,21 +38,20 @@ export async function readApisFromFile(filePath: AbsolutePath) {
|
|
|
36
38
|
if (ts.isMethodDeclaration(node)) {
|
|
37
39
|
if (ts.isIdentifier(node.name)) {
|
|
38
40
|
methodName = node.name.escapedText.toString();
|
|
41
|
+
validateMethodName(methodName);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
const typeParameters: ApiParamType.TypeParam[] = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const tp = typeParam as ts.TypeParameterDeclaration;
|
|
44
|
+
const typeParameters: ApiParamType.TypeParam[] = (node.typeParameters ?? []).map(
|
|
45
|
+
(typeParam) => {
|
|
46
|
+
const tp = typeParam as ts.TypeParameterDeclaration;
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
48
|
+
return {
|
|
49
|
+
t: "type-param",
|
|
50
|
+
id: tp.name.escapedText.toString(),
|
|
51
|
+
constraint: tp.constraint ? resolveTypeNode(tp.constraint) : undefined,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
);
|
|
54
55
|
const parameters: ApiParam[] = node.parameters.map((paramDec, index) => {
|
|
55
56
|
const defaultDef = printNode(paramDec.initializer, sourceFile);
|
|
56
57
|
|
|
@@ -60,20 +61,16 @@ export async function readApisFromFile(filePath: AbsolutePath) {
|
|
|
60
61
|
{
|
|
61
62
|
name: paramDec.name,
|
|
62
63
|
type: paramDec.type as ts.TypeNode,
|
|
63
|
-
optional:
|
|
64
|
-
paramDec.questionToken !== undefined ||
|
|
65
|
-
paramDec.initializer !== undefined,
|
|
64
|
+
optional: paramDec.questionToken !== undefined || paramDec.initializer !== undefined,
|
|
66
65
|
defaultDef,
|
|
67
66
|
},
|
|
68
|
-
index
|
|
67
|
+
index,
|
|
69
68
|
);
|
|
70
69
|
});
|
|
71
70
|
if (node.type === undefined) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`리턴 타입이 기재되지 않은 메소드 ${modelName}.${methodName}`
|
|
74
|
-
);
|
|
71
|
+
throw new Error(`리턴 타입이 기재되지 않은 메소드 ${modelName}.${methodName}`);
|
|
75
72
|
}
|
|
76
|
-
const returnType = resolveTypeNode(node.type
|
|
73
|
+
const returnType = resolveTypeNode(node.type);
|
|
77
74
|
|
|
78
75
|
methods.push({
|
|
79
76
|
modelName,
|
|
@@ -94,9 +91,7 @@ export async function readApisFromFile(filePath: AbsolutePath) {
|
|
|
94
91
|
// 현재 파일의 등록된 API 필터
|
|
95
92
|
const currentModelApis = registeredApis.filter((api) => {
|
|
96
93
|
return methods.find(
|
|
97
|
-
(method) =>
|
|
98
|
-
method.modelName === api.modelName &&
|
|
99
|
-
method.methodName === api.methodName
|
|
94
|
+
(method) => method.modelName === api.modelName && method.methodName === api.methodName,
|
|
100
95
|
);
|
|
101
96
|
});
|
|
102
97
|
if (currentModelApis.length === 0) {
|
|
@@ -109,15 +104,16 @@ export async function readApisFromFile(filePath: AbsolutePath) {
|
|
|
109
104
|
// 등록된 API에 현재 메소드 타입 정보 확장
|
|
110
105
|
const extendedApis = currentModelApis.map((api) => {
|
|
111
106
|
const foundMethod = methods.find(
|
|
112
|
-
(method) =>
|
|
113
|
-
method.modelName === api.modelName &&
|
|
114
|
-
method.methodName === api.methodName
|
|
107
|
+
(method) => method.modelName === api.modelName && method.methodName === api.methodName,
|
|
115
108
|
);
|
|
109
|
+
if (!foundMethod) {
|
|
110
|
+
throw new Error(`API ${api.modelName}.${api.methodName} not found in ${filePath}`);
|
|
111
|
+
}
|
|
116
112
|
return {
|
|
117
113
|
...api,
|
|
118
|
-
typeParameters: foundMethod
|
|
119
|
-
parameters: foundMethod
|
|
120
|
-
returnType: foundMethod
|
|
114
|
+
typeParameters: foundMethod?.typeParameters,
|
|
115
|
+
parameters: foundMethod?.parameters,
|
|
116
|
+
returnType: foundMethod?.returnType,
|
|
121
117
|
};
|
|
122
118
|
});
|
|
123
119
|
return extendedApis;
|
|
@@ -141,7 +137,7 @@ function resolveTypeNode(typeNode: ts.TypeNode): ApiParamType {
|
|
|
141
137
|
return "null";
|
|
142
138
|
case ts.SyntaxKind.VoidKeyword:
|
|
143
139
|
return "void";
|
|
144
|
-
case ts.SyntaxKind.LiteralType:
|
|
140
|
+
case ts.SyntaxKind.LiteralType: {
|
|
145
141
|
const literal = (typeNode as ts.LiteralTypeNode).literal;
|
|
146
142
|
if (ts.isStringLiteral(literal)) {
|
|
147
143
|
return {
|
|
@@ -165,13 +161,15 @@ function resolveTypeNode(typeNode: ts.TypeNode): ApiParamType {
|
|
|
165
161
|
}
|
|
166
162
|
throw new Error("알 수 없는 리터럴");
|
|
167
163
|
}
|
|
168
|
-
|
|
164
|
+
}
|
|
165
|
+
case ts.SyntaxKind.ArrayType: {
|
|
169
166
|
const arrNode = typeNode as ts.ArrayTypeNode;
|
|
170
167
|
return {
|
|
171
168
|
t: "array",
|
|
172
169
|
elementsType: resolveTypeNode(arrNode.elementType),
|
|
173
170
|
};
|
|
174
|
-
|
|
171
|
+
}
|
|
172
|
+
case ts.SyntaxKind.TypeLiteral: {
|
|
175
173
|
const literalNode = typeNode as ts.TypeLiteralNode;
|
|
176
174
|
return {
|
|
177
175
|
t: "object",
|
|
@@ -185,9 +183,7 @@ function resolveTypeNode(typeNode: ts.TypeNode): ApiParamType {
|
|
|
185
183
|
|
|
186
184
|
return resolveParamDec({
|
|
187
185
|
name: {
|
|
188
|
-
escapedText: `[${res.name}${res.optional ? "?" : ""}: ${
|
|
189
|
-
res.type
|
|
190
|
-
}]`,
|
|
186
|
+
escapedText: `[${res.name}${res.optional ? "?" : ""}: ${res.type}]`,
|
|
191
187
|
} as ts.Identifier,
|
|
192
188
|
type: member.type as ts.TypeNode,
|
|
193
189
|
});
|
|
@@ -195,45 +191,35 @@ function resolveTypeNode(typeNode: ts.TypeNode): ApiParamType {
|
|
|
195
191
|
return resolveParamDec({
|
|
196
192
|
name: (member as ts.PropertySignature).name as ts.Identifier,
|
|
197
193
|
type: (member as ts.PropertySignature).type as ts.TypeNode,
|
|
198
|
-
optional:
|
|
199
|
-
(member as ts.PropertySignature).questionToken !== undefined,
|
|
194
|
+
optional: (member as ts.PropertySignature).questionToken !== undefined,
|
|
200
195
|
});
|
|
201
196
|
}
|
|
202
197
|
}),
|
|
203
198
|
};
|
|
199
|
+
}
|
|
204
200
|
case ts.SyntaxKind.TypeReference:
|
|
205
201
|
return {
|
|
206
202
|
t: "ref",
|
|
207
|
-
id: (
|
|
208
|
-
(typeNode as ts.TypeReferenceNode).typeName as ts.Identifier
|
|
209
|
-
).escapedText.toString(),
|
|
203
|
+
id: ((typeNode as ts.TypeReferenceNode).typeName as ts.Identifier).escapedText.toString(),
|
|
210
204
|
args: (typeNode as ts.TypeReferenceNode).typeArguments?.map((typeArg) =>
|
|
211
|
-
resolveTypeNode(typeArg)
|
|
205
|
+
resolveTypeNode(typeArg),
|
|
212
206
|
),
|
|
213
207
|
};
|
|
214
208
|
case ts.SyntaxKind.UnionType:
|
|
215
209
|
return {
|
|
216
210
|
t: "union",
|
|
217
|
-
types: (typeNode as ts.UnionTypeNode).types.map((type) =>
|
|
218
|
-
resolveTypeNode(type)
|
|
219
|
-
),
|
|
211
|
+
types: (typeNode as ts.UnionTypeNode).types.map((type) => resolveTypeNode(type)),
|
|
220
212
|
};
|
|
221
213
|
case ts.SyntaxKind.IntersectionType:
|
|
222
214
|
return {
|
|
223
215
|
t: "intersection",
|
|
224
|
-
types: (typeNode as ts.IntersectionTypeNode).types.map((type) =>
|
|
225
|
-
resolveTypeNode(type)
|
|
226
|
-
),
|
|
216
|
+
types: (typeNode as ts.IntersectionTypeNode).types.map((type) => resolveTypeNode(type)),
|
|
227
217
|
};
|
|
228
218
|
case ts.SyntaxKind.IndexedAccessType:
|
|
229
219
|
return {
|
|
230
220
|
t: "indexed-access",
|
|
231
|
-
object: resolveTypeNode(
|
|
232
|
-
|
|
233
|
-
),
|
|
234
|
-
index: resolveTypeNode(
|
|
235
|
-
(typeNode as ts.IndexedAccessTypeNode).indexType
|
|
236
|
-
),
|
|
221
|
+
object: resolveTypeNode((typeNode as ts.IndexedAccessTypeNode).objectType),
|
|
222
|
+
index: resolveTypeNode((typeNode as ts.IndexedAccessTypeNode).indexType),
|
|
237
223
|
};
|
|
238
224
|
case ts.SyntaxKind.TupleType:
|
|
239
225
|
if (ts.isTupleTypeNode(typeNode)) {
|
|
@@ -258,7 +244,7 @@ function resolveParamDec(
|
|
|
258
244
|
optional?: boolean;
|
|
259
245
|
defaultDef?: string;
|
|
260
246
|
},
|
|
261
|
-
index: number = 0
|
|
247
|
+
index: number = 0,
|
|
262
248
|
): ApiParam {
|
|
263
249
|
const name = paramDec.name as ts.Identifier;
|
|
264
250
|
const type = resolveTypeNode(paramDec.type);
|
|
@@ -286,10 +272,7 @@ function resolveParamDec(
|
|
|
286
272
|
return result;
|
|
287
273
|
}
|
|
288
274
|
|
|
289
|
-
function printNode(
|
|
290
|
-
node: ts.Node | undefined,
|
|
291
|
-
sourceFile: ts.SourceFile
|
|
292
|
-
): string | undefined {
|
|
275
|
+
function printNode(node: ts.Node | undefined, sourceFile: ts.SourceFile): string | undefined {
|
|
293
276
|
if (node === undefined) {
|
|
294
277
|
return undefined;
|
|
295
278
|
}
|
package/src/syncer/checksum.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
+
import crypto, { type BinaryLike } from "crypto";
|
|
2
|
+
import equal from "fast-deep-equal";
|
|
3
|
+
import { createReadStream, type PathLike } from "fs";
|
|
4
|
+
import { readFile, writeFile } from "fs/promises";
|
|
1
5
|
import path from "path";
|
|
6
|
+
import { isEqual } from "radashi";
|
|
7
|
+
import { Sonamu } from "../api/sonamu";
|
|
2
8
|
import { globAsync } from "../utils/async-utils";
|
|
3
|
-
import { createReadStream, PathLike } from "fs";
|
|
4
|
-
import { readFile, writeFile } from "fs/promises";
|
|
5
9
|
import { exists } from "../utils/fs-utils";
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import equal from "fast-deep-equal";
|
|
9
|
-
import * as _ from "lodash-es";
|
|
10
|
-
import { Sonamu } from "../api/sonamu";
|
|
11
|
-
import {
|
|
12
|
-
AbsolutePath,
|
|
13
|
-
ApiRelativePath,
|
|
14
|
-
} from "../utils/path-utils";
|
|
10
|
+
import type { AbsolutePath, ApiRelativePath } from "../utils/path-utils";
|
|
11
|
+
import { differenceWith } from "../utils/utils";
|
|
15
12
|
import { getChecksumPatternGroupInAbsolutePath } from "./file-patterns";
|
|
16
13
|
|
|
17
14
|
type PathAndChecksum = {
|
|
@@ -23,9 +20,7 @@ type PathAndChecksum = {
|
|
|
23
20
|
* 체크섬 파일에 저장된 내용과 현재 실제 파일의 체크섬을 비교하여 변경된 파일을 찾습니다.
|
|
24
21
|
* @returns 변경된 파일 경로 배열. 프로젝트 루트부터 슬래시로 시작합니다. 예시: "/src/application/user/user.model.ts"
|
|
25
22
|
*/
|
|
26
|
-
export async function findChangedFilesUsingChecksums(): Promise<
|
|
27
|
-
AbsolutePath[]
|
|
28
|
-
> {
|
|
23
|
+
export async function findChangedFilesUsingChecksums(): Promise<AbsolutePath[]> {
|
|
29
24
|
const calculatedChecksums = await getCurrentChecksums();
|
|
30
25
|
const savedChecksums = await getPreviousChecksums();
|
|
31
26
|
|
|
@@ -34,9 +29,7 @@ export async function findChangedFilesUsingChecksums(): Promise<
|
|
|
34
29
|
return [];
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return diff.map((r) => r.path);
|
|
32
|
+
return differenceWith(calculatedChecksums, savedChecksums, isEqual).map((r) => r.path);
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
/**
|
|
@@ -62,10 +55,7 @@ export async function renewChecksums(): Promise<void> {
|
|
|
62
55
|
* @param two 파일 경로
|
|
63
56
|
* @returns boolean
|
|
64
57
|
*/
|
|
65
|
-
export async function areFilesSame(
|
|
66
|
-
one: PathLike,
|
|
67
|
-
two: PathLike
|
|
68
|
-
): Promise<boolean> {
|
|
58
|
+
export async function areFilesSame(one: PathLike, two: PathLike): Promise<boolean> {
|
|
69
59
|
if (!(await exists(one)) || !(await exists(two))) {
|
|
70
60
|
return false;
|
|
71
61
|
}
|
|
@@ -79,11 +69,9 @@ export async function areFilesSame(
|
|
|
79
69
|
async function getCurrentChecksums(): Promise<PathAndChecksum[]> {
|
|
80
70
|
const filePaths = (
|
|
81
71
|
await Promise.all(
|
|
82
|
-
Object.entries(getChecksumPatternGroupInAbsolutePath()).map(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
)
|
|
72
|
+
Object.entries(getChecksumPatternGroupInAbsolutePath()).map(async ([_fileType, pattern]) => {
|
|
73
|
+
return globAsync(pattern) as Promise<AbsolutePath[]>;
|
|
74
|
+
}),
|
|
87
75
|
)
|
|
88
76
|
)
|
|
89
77
|
.flat()
|
|
@@ -95,7 +83,7 @@ async function getCurrentChecksums(): Promise<PathAndChecksum[]> {
|
|
|
95
83
|
path: filePath,
|
|
96
84
|
checksum: await getChecksumOfFile(filePath),
|
|
97
85
|
};
|
|
98
|
-
})
|
|
86
|
+
}),
|
|
99
87
|
);
|
|
100
88
|
|
|
101
89
|
return fileChecksums;
|
|
@@ -107,12 +95,12 @@ async function getPreviousChecksums(): Promise<PathAndChecksum[]> {
|
|
|
107
95
|
return [];
|
|
108
96
|
}
|
|
109
97
|
|
|
110
|
-
const previousChecksums = JSON.parse(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
98
|
+
const previousChecksums = JSON.parse(await readFile(checksumFilePath, "utf-8")).map(
|
|
99
|
+
(r: { path: ApiRelativePath; checksum: string }) => ({
|
|
100
|
+
path: path.join(Sonamu.apiRootPath, r.path), // 체크섬 파일에서 읽을 때: API 상대 경로 → 절대 경로
|
|
101
|
+
checksum: r.checksum,
|
|
102
|
+
}),
|
|
103
|
+
) as PathAndChecksum[];
|
|
116
104
|
return previousChecksums;
|
|
117
105
|
}
|
|
118
106
|
|
|
@@ -130,9 +118,9 @@ async function saveChecksums(checksums: PathAndChecksum[]): Promise<void> {
|
|
|
130
118
|
checksum: r.checksum,
|
|
131
119
|
})),
|
|
132
120
|
null,
|
|
133
|
-
2
|
|
121
|
+
2,
|
|
134
122
|
),
|
|
135
|
-
"utf-8"
|
|
123
|
+
"utf-8",
|
|
136
124
|
);
|
|
137
125
|
console.log("checksum saved", checksumFilePath);
|
|
138
126
|
}
|
|
@@ -142,10 +130,10 @@ async function getChecksumOfFile(filePath: PathLike): Promise<string> {
|
|
|
142
130
|
const hash = crypto.createHash("sha1");
|
|
143
131
|
const input = createReadStream(filePath);
|
|
144
132
|
input.on("error", reject);
|
|
145
|
-
input.on("data",
|
|
133
|
+
input.on("data", (chunk: BinaryLike) => {
|
|
146
134
|
hash.update(chunk);
|
|
147
135
|
});
|
|
148
|
-
input.on("close",
|
|
136
|
+
input.on("close", () => {
|
|
149
137
|
resolve(hash.digest("hex"));
|
|
150
138
|
});
|
|
151
139
|
});
|