silgi 0.43.28 → 0.50.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/README.md +103 -1
- package/dist/_virtual/_rolldown/runtime.mjs +5 -0
- package/dist/adapters/_fetch-adapter.d.mts +18 -0
- package/dist/adapters/_fetch-adapter.mjs +53 -0
- package/dist/adapters/astro.d.mts +15 -0
- package/dist/adapters/astro.mjs +31 -0
- package/dist/adapters/aws-lambda.d.mts +42 -0
- package/dist/adapters/aws-lambda.mjs +92 -0
- package/dist/adapters/express.d.mts +16 -0
- package/dist/adapters/express.mjs +110 -0
- package/dist/adapters/message-port.d.mts +42 -0
- package/dist/adapters/message-port.mjs +132 -0
- package/dist/adapters/nestjs.d.mts +25 -0
- package/dist/adapters/nestjs.mjs +83 -0
- package/dist/adapters/nextjs.d.mts +14 -0
- package/dist/adapters/nextjs.mjs +29 -0
- package/dist/adapters/peer.d.mts +27 -0
- package/dist/adapters/peer.mjs +36 -0
- package/dist/adapters/remix.d.mts +15 -0
- package/dist/adapters/remix.mjs +30 -0
- package/dist/adapters/solidstart.d.mts +12 -0
- package/dist/adapters/solidstart.mjs +29 -0
- package/dist/adapters/sveltekit.d.mts +14 -0
- package/dist/adapters/sveltekit.mjs +30 -0
- package/dist/broker/index.d.mts +62 -0
- package/dist/broker/index.mjs +153 -0
- package/dist/broker/nats.d.mts +33 -0
- package/dist/broker/nats.mjs +31 -0
- package/dist/broker/redis.d.mts +51 -0
- package/dist/broker/redis.mjs +92 -0
- package/dist/builder.d.mts +55 -0
- package/dist/builder.mjs +70 -0
- package/dist/callable.d.mts +19 -0
- package/dist/callable.mjs +42 -0
- package/dist/caller.mjs +90 -0
- package/dist/client/adapters/fetch/index.d.mts +15 -0
- package/dist/client/adapters/fetch/index.mjs +57 -0
- package/dist/client/adapters/ofetch/index.d.mts +55 -0
- package/dist/client/adapters/ofetch/index.mjs +91 -0
- package/dist/client/adapters/websocket/index.d.mts +20 -0
- package/dist/client/adapters/websocket/index.mjs +101 -0
- package/dist/client/client.d.mts +37 -0
- package/dist/client/client.mjs +80 -0
- package/dist/client/consume.d.mts +50 -0
- package/dist/client/consume.mjs +66 -0
- package/dist/client/dynamic-link.d.mts +16 -0
- package/dist/client/dynamic-link.mjs +19 -0
- package/dist/client/index.d.mts +6 -0
- package/dist/client/index.mjs +5 -0
- package/dist/client/interceptor.d.mts +31 -0
- package/dist/client/interceptor.mjs +34 -0
- package/dist/client/openapi.d.mts +29 -0
- package/dist/client/openapi.mjs +89 -0
- package/dist/client/plugins/batch.d.mts +26 -0
- package/dist/client/plugins/batch.mjs +64 -0
- package/dist/client/plugins/circuit-breaker.d.mts +24 -0
- package/dist/client/plugins/circuit-breaker.mjs +60 -0
- package/dist/client/plugins/csrf.d.mts +13 -0
- package/dist/client/plugins/csrf.mjs +20 -0
- package/dist/client/plugins/dedupe.d.mts +10 -0
- package/dist/client/plugins/dedupe.mjs +28 -0
- package/dist/client/plugins/index.d.mts +8 -0
- package/dist/client/plugins/index.mjs +8 -0
- package/dist/client/plugins/otel.d.mts +12 -0
- package/dist/client/plugins/otel.mjs +27 -0
- package/dist/client/plugins/retry.d.mts +34 -0
- package/dist/client/plugins/retry.mjs +79 -0
- package/dist/client/plugins/timeout.d.mts +10 -0
- package/dist/client/plugins/timeout.mjs +14 -0
- package/dist/client/server.d.mts +16 -0
- package/dist/client/server.mjs +59 -0
- package/dist/client/types.d.mts +29 -0
- package/dist/codec/devalue.d.mts +21 -0
- package/dist/codec/devalue.mjs +33 -0
- package/dist/codec/msgpack.d.mts +18 -0
- package/dist/codec/msgpack.mjs +45 -0
- package/dist/codec/sanitize.mjs +38 -0
- package/dist/codegen/emitters.d.mts +51 -0
- package/dist/codegen/emitters.mjs +143 -0
- package/dist/codegen/generate.d.mts +25 -0
- package/dist/codegen/generate.mjs +224 -0
- package/dist/codegen/index.d.mts +44 -0
- package/dist/codegen/index.mjs +103 -0
- package/dist/codegen/parse.d.mts +124 -0
- package/dist/codegen/parse.mjs +135 -0
- package/dist/codegen/preserve.d.mts +21 -0
- package/dist/codegen/preserve.mjs +62 -0
- package/dist/codegen/schema-to-code.d.mts +57 -0
- package/dist/codegen/schema-to-code.mjs +167 -0
- package/dist/compile.d.mts +46 -0
- package/dist/compile.mjs +332 -0
- package/dist/core/codec.mjs +67 -0
- package/dist/core/context-bridge.mjs +11 -0
- package/dist/core/dispatch.mjs +62 -0
- package/dist/core/error.d.mts +99 -60
- package/dist/core/error.mjs +125 -92
- package/dist/core/handler.d.mts +6 -0
- package/dist/core/handler.mjs +153 -0
- package/dist/core/input.mjs +49 -0
- package/dist/core/iterator.d.mts +17 -0
- package/dist/core/iterator.mjs +79 -0
- package/dist/core/router-utils.mjs +22 -0
- package/dist/core/schema.d.mts +20 -0
- package/dist/core/schema.mjs +33 -0
- package/dist/core/serve.d.mts +51 -0
- package/dist/core/serve.mjs +76 -0
- package/dist/core/sse.d.mts +18 -0
- package/dist/core/sse.mjs +110 -0
- package/dist/core/storage.d.mts +17 -4
- package/dist/core/storage.mjs +60 -13
- package/dist/core/task.d.mts +62 -0
- package/dist/core/task.mjs +165 -0
- package/dist/core/trace-map.d.mts +13 -0
- package/dist/core/trace-map.mjs +13 -0
- package/dist/core/url.mjs +28 -0
- package/dist/core/utils.mjs +24 -0
- package/dist/index.d.mts +17 -21
- package/dist/index.mjs +14 -22
- package/dist/integrations/ai/index.d.mts +25 -0
- package/dist/integrations/ai/index.mjs +117 -0
- package/dist/integrations/better-auth/index.d.mts +41 -0
- package/dist/integrations/better-auth/index.mjs +331 -0
- package/dist/integrations/drizzle/index.d.mts +27 -0
- package/dist/integrations/drizzle/index.mjs +285 -0
- package/dist/integrations/hey-api/index.d.mts +2 -0
- package/dist/integrations/hey-api/index.mjs +2 -0
- package/dist/integrations/hey-api/to-client.d.mts +20 -0
- package/dist/integrations/hey-api/to-client.mjs +39 -0
- package/dist/integrations/pinia-colada/general-utils.d.mts +13 -0
- package/dist/integrations/pinia-colada/general-utils.mjs +9 -0
- package/dist/integrations/pinia-colada/index.d.mts +6 -0
- package/dist/integrations/pinia-colada/index.mjs +5 -0
- package/dist/integrations/pinia-colada/key.d.mts +11 -0
- package/dist/integrations/pinia-colada/key.mjs +11 -0
- package/dist/integrations/pinia-colada/procedure-utils.d.mts +25 -0
- package/dist/integrations/pinia-colada/procedure-utils.mjs +33 -0
- package/dist/integrations/pinia-colada/router-utils.d.mts +17 -0
- package/dist/integrations/pinia-colada/router-utils.mjs +30 -0
- package/dist/integrations/pinia-colada/types.d.mts +25 -0
- package/dist/integrations/react/index.d.mts +83 -0
- package/dist/integrations/react/index.mjs +196 -0
- package/dist/integrations/tanstack-query/index.d.mts +120 -0
- package/dist/integrations/tanstack-query/index.mjs +100 -0
- package/dist/integrations/tanstack-query/ssr.d.mts +60 -0
- package/dist/integrations/tanstack-query/ssr.mjs +102 -0
- package/dist/integrations/zod/converter.d.mts +75 -0
- package/dist/integrations/zod/converter.mjs +345 -0
- package/dist/integrations/zod/index.d.mts +2 -0
- package/dist/integrations/zod/index.mjs +2 -0
- package/dist/lazy.d.mts +22 -0
- package/dist/lazy.mjs +34 -0
- package/dist/lifecycle.d.mts +36 -0
- package/dist/lifecycle.mjs +46 -0
- package/dist/map-input.d.mts +17 -0
- package/dist/map-input.mjs +47 -0
- package/dist/plugins/analytics/accumulator.d.mts +24 -0
- package/dist/plugins/analytics/accumulator.mjs +91 -0
- package/dist/plugins/analytics/alerts.d.mts +59 -0
- package/dist/plugins/analytics/alerts.mjs +140 -0
- package/dist/plugins/analytics/collector.d.mts +38 -0
- package/dist/plugins/analytics/collector.mjs +275 -0
- package/dist/plugins/analytics/cost.d.mts +61 -0
- package/dist/plugins/analytics/cost.mjs +97 -0
- package/dist/plugins/analytics/export.d.mts +7 -0
- package/dist/plugins/analytics/export.mjs +86 -0
- package/dist/plugins/analytics/normalize.mjs +144 -0
- package/dist/plugins/analytics/query.mjs +164 -0
- package/dist/plugins/analytics/request-id.mjs +34 -0
- package/dist/plugins/analytics/routes.d.mts +11 -0
- package/dist/plugins/analytics/routes.mjs +211 -0
- package/dist/plugins/analytics/sse.d.mts +31 -0
- package/dist/plugins/analytics/sse.mjs +74 -0
- package/dist/plugins/analytics/store.mjs +103 -0
- package/dist/plugins/analytics/timeseries.d.mts +50 -0
- package/dist/plugins/analytics/timeseries.mjs +169 -0
- package/dist/plugins/analytics/trace.d.mts +48 -0
- package/dist/plugins/analytics/trace.mjs +83 -0
- package/dist/plugins/analytics/types.d.mts +145 -0
- package/dist/plugins/analytics/types.mjs +40 -0
- package/dist/plugins/analytics/utils.d.mts +4 -0
- package/dist/plugins/analytics/utils.mjs +56 -0
- package/dist/plugins/analytics.d.mts +18 -0
- package/dist/plugins/analytics.mjs +188 -0
- package/dist/plugins/batch-server.d.mts +20 -0
- package/dist/plugins/batch-server.mjs +91 -0
- package/dist/plugins/body-limit.d.mts +19 -0
- package/dist/plugins/body-limit.mjs +49 -0
- package/dist/plugins/cache.d.mts +170 -0
- package/dist/plugins/cache.mjs +212 -0
- package/dist/plugins/coerce.d.mts +24 -0
- package/dist/plugins/coerce.mjs +70 -0
- package/dist/plugins/cookies.d.mts +14 -0
- package/dist/plugins/cookies.mjs +48 -0
- package/dist/plugins/cors.d.mts +43 -0
- package/dist/plugins/cors.mjs +62 -0
- package/dist/plugins/file-upload.d.mts +38 -0
- package/dist/plugins/file-upload.mjs +102 -0
- package/dist/plugins/index.d.mts +18 -0
- package/dist/plugins/index.mjs +17 -0
- package/dist/plugins/otel.d.mts +35 -0
- package/dist/plugins/otel.mjs +40 -0
- package/dist/plugins/pino.d.mts +60 -0
- package/dist/plugins/pino.mjs +42 -0
- package/dist/plugins/pubsub.d.mts +50 -0
- package/dist/plugins/pubsub.mjs +53 -0
- package/dist/plugins/ratelimit.d.mts +53 -0
- package/dist/plugins/ratelimit.mjs +92 -0
- package/dist/plugins/signing.d.mts +41 -0
- package/dist/plugins/signing.mjs +118 -0
- package/dist/plugins/strict-get.d.mts +10 -0
- package/dist/plugins/strict-get.mjs +33 -0
- package/dist/scalar.d.mts +49 -0
- package/dist/scalar.mjs +311 -0
- package/dist/silgi.d.mts +144 -0
- package/dist/silgi.mjs +164 -0
- package/dist/trpc-interop.d.mts +22 -0
- package/dist/trpc-interop.mjs +68 -0
- package/dist/types.d.mts +108 -0
- package/dist/ws.d.mts +88 -0
- package/dist/ws.mjs +205 -0
- package/lib/dashboard/index.html +120 -0
- package/lib/ocache.d.mts +1 -0
- package/lib/ocache.mjs +1 -0
- package/lib/ofetch.d.mts +1 -0
- package/lib/ofetch.mjs +1 -0
- package/lib/srvx.d.mts +1 -0
- package/lib/srvx.mjs +1 -0
- package/lib/unstorage.d.mts +1 -0
- package/lib/unstorage.mjs +1 -0
- package/package.json +314 -150
- package/dist/build.d.mts +0 -3
- package/dist/build.mjs +0 -4
- package/dist/cli/build/build.mjs +0 -15
- package/dist/cli/build/dev.d.mts +0 -10
- package/dist/cli/build/dev.mjs +0 -91
- package/dist/cli/build/prepare.d.mts +0 -6
- package/dist/cli/build/prepare.mjs +0 -15
- package/dist/cli/commands/commands.mjs +0 -90
- package/dist/cli/commands/env.mjs +0 -53
- package/dist/cli/commands/init.mjs +0 -84
- package/dist/cli/commands/install.mjs +0 -52
- package/dist/cli/commands/prepare.mjs +0 -65
- package/dist/cli/commands/reset.mjs +0 -46
- package/dist/cli/commands/run.mjs +0 -31
- package/dist/cli/commands/watch.mjs +0 -153
- package/dist/cli/config/defaults.mjs +0 -117
- package/dist/cli/config/index.d.mts +0 -3
- package/dist/cli/config/index.mjs +0 -4
- package/dist/cli/config/loader.d.mts +0 -6
- package/dist/cli/config/loader.mjs +0 -71
- package/dist/cli/config/resolvers/compatibility.mjs +0 -71
- package/dist/cli/config/resolvers/imports.mjs +0 -35
- package/dist/cli/config/resolvers/paths.mjs +0 -98
- package/dist/cli/config/resolvers/storage.mjs +0 -23
- package/dist/cli/config/resolvers/url.mjs +0 -9
- package/dist/cli/config/types.d.mts +0 -14
- package/dist/cli/config/types.mjs +0 -147
- package/dist/cli/core/apiful.mjs +0 -36
- package/dist/cli/core/devServer.mjs +0 -10
- package/dist/cli/core/env.mjs +0 -68
- package/dist/cli/core/installPackage.mjs +0 -60
- package/dist/cli/core/runtimeConfig.mjs +0 -70
- package/dist/cli/core/scan.mjs +0 -35
- package/dist/cli/core/silgi.mjs +0 -111
- package/dist/cli/framework/emptyFramework.mjs +0 -7
- package/dist/cli/framework/h3.mjs +0 -55
- package/dist/cli/framework/index.mjs +0 -15
- package/dist/cli/framework/nitro.mjs +0 -24
- package/dist/cli/framework/nuxt.mjs +0 -10
- package/dist/cli/index.d.mts +0 -1
- package/dist/cli/index.mjs +0 -29
- package/dist/cli/module/exportScan.mjs +0 -180
- package/dist/cli/module/install.mjs +0 -49
- package/dist/cli/module/scan.mjs +0 -193
- package/dist/cli/scan/prepareCommands.mjs +0 -40
- package/dist/cli/scan/prepareConfigs.mjs +0 -33
- package/dist/cli/scan/prepareCoreFile.mjs +0 -118
- package/dist/cli/scan/prepareScanFile.mjs +0 -59
- package/dist/cli/scan/prepareSchema.mjs +0 -128
- package/dist/cli/scan/scanExportFile.mjs +0 -288
- package/dist/cli/scan/writeCoreFile.mjs +0 -22
- package/dist/cli/scan/writeTypesAndFiles.mjs +0 -72
- package/dist/cli/utils/cancel.mjs +0 -14
- package/dist/cli/utils/common.mjs +0 -15
- package/dist/cli/utils/compatibility.mjs +0 -33
- package/dist/cli/utils/debug.mjs +0 -11
- package/dist/cli/utils/ignore.mjs +0 -56
- package/dist/cli/utils/processManager.mjs +0 -170
- package/dist/cli/utils/readScanFile.mjs +0 -58
- package/dist/cli/utils/storage.mjs +0 -23
- package/dist/core/context.d.mts +0 -30
- package/dist/core/context.mjs +0 -32
- package/dist/core/createSilgi.d.mts +0 -6
- package/dist/core/createSilgi.mjs +0 -153
- package/dist/core/event.d.mts +0 -26
- package/dist/core/event.mjs +0 -44
- package/dist/core/index.d.mts +0 -25
- package/dist/core/index.mjs +0 -30
- package/dist/core/orchestrate.mjs +0 -115
- package/dist/core/response.d.mts +0 -20
- package/dist/core/response.mjs +0 -105
- package/dist/core/silgi.d.mts +0 -19
- package/dist/core/silgi.mjs +0 -141
- package/dist/core/silgiApp.d.mts +0 -9
- package/dist/core/silgiApp.mjs +0 -23
- package/dist/core/unctx.d.mts +0 -21
- package/dist/core/unctx.mjs +0 -35
- package/dist/core/utils/event-stream.d.mts +0 -53
- package/dist/core/utils/event-stream.mjs +0 -38
- package/dist/core/utils/event.d.mts +0 -8
- package/dist/core/utils/event.mjs +0 -12
- package/dist/core/utils/internal/event-stream.d.mts +0 -45
- package/dist/core/utils/internal/event-stream.mjs +0 -137
- package/dist/core/utils/internal/obj.mjs +0 -9
- package/dist/core/utils/internal/object.mjs +0 -29
- package/dist/core/utils/internal/query.mjs +0 -73
- package/dist/core/utils/internal/req.mjs +0 -35
- package/dist/core/utils/merge.d.mts +0 -14
- package/dist/core/utils/merge.mjs +0 -27
- package/dist/core/utils/middleware.d.mts +0 -14
- package/dist/core/utils/middleware.mjs +0 -12
- package/dist/core/utils/request.mjs +0 -35
- package/dist/core/utils/resolver.d.mts +0 -7
- package/dist/core/utils/resolver.mjs +0 -29
- package/dist/core/utils/runtime.d.mts +0 -7
- package/dist/core/utils/runtime.mjs +0 -20
- package/dist/core/utils/sanitize.mjs +0 -22
- package/dist/core/utils/schema.d.mts +0 -34
- package/dist/core/utils/schema.mjs +0 -33
- package/dist/core/utils/service.d.mts +0 -13
- package/dist/core/utils/service.mjs +0 -19
- package/dist/core/utils/shared.d.mts +0 -6
- package/dist/core/utils/shared.mjs +0 -7
- package/dist/core/utils/storage.d.mts +0 -24
- package/dist/core/utils/storage.mjs +0 -54
- package/dist/kit/add/add-commands.d.mts +0 -6
- package/dist/kit/add/add-commands.mjs +0 -12
- package/dist/kit/add/add-core-file.d.mts +0 -9
- package/dist/kit/add/add-core-file.mjs +0 -11
- package/dist/kit/add/add-imports.d.mts +0 -14
- package/dist/kit/add/add-imports.mjs +0 -56
- package/dist/kit/add/add-npm.d.mts +0 -14
- package/dist/kit/add/add-npm.mjs +0 -23
- package/dist/kit/define.d.mts +0 -28
- package/dist/kit/define.mjs +0 -25
- package/dist/kit/errors.d.mts +0 -6
- package/dist/kit/errors.mjs +0 -11
- package/dist/kit/esm.d.mts +0 -11
- package/dist/kit/esm.mjs +0 -21
- package/dist/kit/fs.d.mts +0 -4
- package/dist/kit/fs.mjs +0 -13
- package/dist/kit/function-utils.d.mts +0 -27
- package/dist/kit/function-utils.mjs +0 -75
- package/dist/kit/gen.d.mts +0 -5
- package/dist/kit/gen.mjs +0 -26
- package/dist/kit/hash.d.mts +0 -4
- package/dist/kit/hash.mjs +0 -10
- package/dist/kit/index.d.mts +0 -22
- package/dist/kit/index.mjs +0 -23
- package/dist/kit/isFramework.d.mts +0 -6
- package/dist/kit/isFramework.mjs +0 -21
- package/dist/kit/logger.d.mts +0 -6
- package/dist/kit/logger.mjs +0 -10
- package/dist/kit/migration.d.mts +0 -113
- package/dist/kit/migration.mjs +0 -301
- package/dist/kit/module.d.mts +0 -14
- package/dist/kit/module.mjs +0 -53
- package/dist/kit/path.d.mts +0 -7
- package/dist/kit/path.mjs +0 -26
- package/dist/kit/preset.d.mts +0 -8
- package/dist/kit/preset.mjs +0 -11
- package/dist/kit/resolve.d.mts +0 -37
- package/dist/kit/resolve.mjs +0 -82
- package/dist/kit/template.d.mts +0 -19
- package/dist/kit/template.mjs +0 -91
- package/dist/kit/useRequest.d.mts +0 -19
- package/dist/kit/useRequest.mjs +0 -63
- package/dist/kit/utils.d.mts +0 -34
- package/dist/kit/utils.mjs +0 -91
- package/dist/package.mjs +0 -176
- package/dist/presets/_all.gen.d.mts +0 -6
- package/dist/presets/_all.gen.mjs +0 -18
- package/dist/presets/_resolve.d.mts +0 -12
- package/dist/presets/_resolve.mjs +0 -57
- package/dist/presets/_types.gen.d.mts +0 -8
- package/dist/presets/_types.gen.mjs +0 -5
- package/dist/presets/h3/preset.d.mts +0 -6
- package/dist/presets/h3/preset.mjs +0 -35
- package/dist/presets/hono/preset.d.mts +0 -6
- package/dist/presets/hono/preset.mjs +0 -30
- package/dist/presets/index.d.mts +0 -3
- package/dist/presets/index.mjs +0 -3
- package/dist/presets/nitro/preset.d.mts +0 -6
- package/dist/presets/nitro/preset.mjs +0 -37
- package/dist/presets/npmpackage/preset.d.mts +0 -6
- package/dist/presets/npmpackage/preset.mjs +0 -29
- package/dist/presets/nuxt/preset.d.mts +0 -6
- package/dist/presets/nuxt/preset.mjs +0 -41
- package/dist/runtime/index.d.mts +0 -4
- package/dist/runtime/index.mjs +0 -5
- package/dist/runtime/internal/config.d.mts +0 -11
- package/dist/runtime/internal/config.mjs +0 -97
- package/dist/runtime/internal/debug.d.mts +0 -6
- package/dist/runtime/internal/debug.mjs +0 -11
- package/dist/runtime/internal/defu.d.mts +0 -4
- package/dist/runtime/internal/defu.mjs +0 -9
- package/dist/runtime/internal/index.d.mts +0 -7
- package/dist/runtime/internal/index.mjs +0 -8
- package/dist/runtime/internal/nitro.d.mts +0 -6
- package/dist/runtime/internal/nitro.mjs +0 -36
- package/dist/runtime/internal/nuxt.d.mts +0 -12
- package/dist/runtime/internal/nuxt.mjs +0 -16
- package/dist/runtime/internal/ofetch.d.mts +0 -8
- package/dist/runtime/internal/ofetch.mjs +0 -39
- package/dist/runtime/internal/plugin.d.mts +0 -7
- package/dist/runtime/internal/plugin.mjs +0 -8
- package/dist/types/cliConfig.d.mts +0 -288
- package/dist/types/cliConfig.mjs +0 -0
- package/dist/types/cliHooks.d.mts +0 -142
- package/dist/types/cliHooks.mjs +0 -0
- package/dist/types/compatibility.d.mts +0 -13
- package/dist/types/compatibility.mjs +0 -0
- package/dist/types/config.d.mts +0 -46
- package/dist/types/config.mjs +0 -0
- package/dist/types/dotenv.d.mts +0 -29
- package/dist/types/dotenv.mjs +0 -0
- package/dist/types/event.d.mts +0 -63
- package/dist/types/event.mjs +0 -0
- package/dist/types/global.d.mts +0 -24
- package/dist/types/global.mjs +0 -0
- package/dist/types/helper.d.mts +0 -25
- package/dist/types/helper.mjs +0 -0
- package/dist/types/hooks.d.mts +0 -37
- package/dist/types/hooks.mjs +0 -0
- package/dist/types/index.d.mts +0 -26
- package/dist/types/index.mjs +0 -0
- package/dist/types/kits.d.mts +0 -32
- package/dist/types/kits.mjs +0 -0
- package/dist/types/middleware.d.mts +0 -31
- package/dist/types/middleware.mjs +0 -0
- package/dist/types/module.d.mts +0 -102
- package/dist/types/module.mjs +0 -0
- package/dist/types/preset.d.mts +0 -20
- package/dist/types/preset.mjs +0 -0
- package/dist/types/route.d.mts +0 -59
- package/dist/types/route.mjs +0 -0
- package/dist/types/runtime/index.d.mts +0 -5
- package/dist/types/runtime/index.mjs +0 -0
- package/dist/types/runtime/nuxt.d.mts +0 -13
- package/dist/types/runtime/nuxt.mjs +0 -0
- package/dist/types/runtime/ofetch.d.mts +0 -14
- package/dist/types/runtime/ofetch.mjs +0 -0
- package/dist/types/runtime/plugin.d.mts +0 -8
- package/dist/types/runtime/plugin.mjs +0 -0
- package/dist/types/runtime/silgi.d.mts +0 -11
- package/dist/types/runtime/silgi.mjs +0 -0
- package/dist/types/schema.d.mts +0 -86
- package/dist/types/schema.mjs +0 -0
- package/dist/types/service.d.mts +0 -102
- package/dist/types/service.mjs +0 -0
- package/dist/types/shared.d.mts +0 -19
- package/dist/types/shared.mjs +0 -0
- package/dist/types/silgi.d.mts +0 -71
- package/dist/types/silgi.mjs +0 -0
- package/dist/types/silgiCLI.d.mts +0 -118
- package/dist/types/silgiCLI.mjs +0 -0
- package/dist/types/standard-schema.d.mts +0 -61
- package/dist/types/standard-schema.mjs +0 -0
- package/dist/types/storage.d.mts +0 -30
- package/dist/types/storage.mjs +0 -0
- package/dist/types/tree-kill.d.mts +0 -18
- package/dist/types/tree-kill.mjs +0 -0
- package/lib/config.d.mts +0 -7
- package/lib/config.mjs +0 -5
- package/lib/meta.d.mts +0 -4
- package/lib/meta.mjs +0 -6
- package/lib/runtime-meta.d.mts +0 -4
- package/lib/runtime-meta.mjs +0 -32
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { isIgnored } from "../utils/ignore.mjs";
|
|
2
|
-
import { consola as consola$1 } from "consola";
|
|
3
|
-
import micromatch from "micromatch";
|
|
4
|
-
import { basename, dirname, extname, join, relative, resolve } from "pathe";
|
|
5
|
-
import { useSilgiCLI } from "silgi";
|
|
6
|
-
import { hash, relativeWithDot, removeExtension } from "silgi/kit";
|
|
7
|
-
import { withTrailingSlash } from "ufo";
|
|
8
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
9
|
-
import { parseAsync } from "oxc-parser";
|
|
10
|
-
import { glob } from "tinyglobby";
|
|
11
|
-
|
|
12
|
-
//#region src/cli/scan/scanExportFile.ts
|
|
13
|
-
const DEFAULT_FUNCTION_EXPORT_NAMES = [
|
|
14
|
-
"createSchema",
|
|
15
|
-
"createService",
|
|
16
|
-
"createWebSocket",
|
|
17
|
-
"createResolver",
|
|
18
|
-
"createShared",
|
|
19
|
-
"createMiddleware"
|
|
20
|
-
];
|
|
21
|
-
const DEFAULT_INTERFACE_EXTENDS_NAMES = ["ExtendShared", "ExtendContext"];
|
|
22
|
-
function generateUniqueIdentifier(filePath, exportName) {
|
|
23
|
-
const fileBaseName = basename(filePath);
|
|
24
|
-
const uniqueString = `${fileBaseName}${exportName}`;
|
|
25
|
-
return hash(uniqueString);
|
|
26
|
-
}
|
|
27
|
-
function categorizeExports(exportedEntities, filePath, functionExportCategories = {
|
|
28
|
-
createService: "service",
|
|
29
|
-
createWebSocket: "websocket",
|
|
30
|
-
createSchema: "schema",
|
|
31
|
-
createShared: "shared",
|
|
32
|
-
createResolver: "resolver",
|
|
33
|
-
createMiddleware: "middleware"
|
|
34
|
-
}, interfaceExportCategories = {
|
|
35
|
-
ExtendShared: "shared",
|
|
36
|
-
ExtendContext: "context"
|
|
37
|
-
}) {
|
|
38
|
-
const runtimeExports = [];
|
|
39
|
-
const typeExports = [];
|
|
40
|
-
for (const [functionName, category] of Object.entries(functionExportCategories)) {
|
|
41
|
-
const matchingExports = exportedEntities.filter((entity) => entity.funcName === functionName);
|
|
42
|
-
for (const exportEntity of matchingExports) {
|
|
43
|
-
if (!exportEntity.name) continue;
|
|
44
|
-
runtimeExports.push({
|
|
45
|
-
exportName: exportEntity.name,
|
|
46
|
-
path: filePath,
|
|
47
|
-
uniqueId: generateUniqueIdentifier(filePath, exportEntity.name),
|
|
48
|
-
category
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
for (const [extensionName, category] of Object.entries(interfaceExportCategories)) {
|
|
53
|
-
const matchingExports = exportedEntities.filter((entity) => entity.declaration === "interface" && entity.extends?.includes(extensionName));
|
|
54
|
-
for (const exportEntity of matchingExports) {
|
|
55
|
-
if (!exportEntity.name) continue;
|
|
56
|
-
typeExports.push({
|
|
57
|
-
exportName: exportEntity.name,
|
|
58
|
-
path: filePath,
|
|
59
|
-
uniqueId: generateUniqueIdentifier(filePath, exportEntity.name),
|
|
60
|
-
category
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
runtimeExports,
|
|
66
|
-
typeExports
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function transformImportPath(path, packageName, relativeTo) {
|
|
70
|
-
let importPath = path;
|
|
71
|
-
if (packageName) {
|
|
72
|
-
const distMatch = importPath.match(/.*?(\/dist\/.*)/);
|
|
73
|
-
if (distMatch && distMatch[1]) {
|
|
74
|
-
importPath = packageName + distMatch[1].substring(5);
|
|
75
|
-
importPath = removeExtension(importPath, true);
|
|
76
|
-
}
|
|
77
|
-
} else if (relativeTo) importPath = removeExtension(relativeWithDot(relativeTo, path));
|
|
78
|
-
return importPath;
|
|
79
|
-
}
|
|
80
|
-
function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName) {
|
|
81
|
-
silgiInstance.hook("before:scan.ts", (options) => {
|
|
82
|
-
const ignored = Array.isArray(silgiInstance.options.watchOptions?.ignored) ? silgiInstance.options.watchOptions.ignored : [];
|
|
83
|
-
for (const { exportName, path, uniqueId, category } of runtimeExports) {
|
|
84
|
-
if (!isWatchedPath(path, ignored)) silgiInstance.options.devServer.watch.push(path);
|
|
85
|
-
switch (category) {
|
|
86
|
-
case "service":
|
|
87
|
-
options.services.push(uniqueId);
|
|
88
|
-
break;
|
|
89
|
-
case "websocket":
|
|
90
|
-
options.services?.push?.(uniqueId);
|
|
91
|
-
break;
|
|
92
|
-
case "shared":
|
|
93
|
-
options.shareds.push(uniqueId);
|
|
94
|
-
break;
|
|
95
|
-
case "schema":
|
|
96
|
-
options.schemas.push(uniqueId);
|
|
97
|
-
break;
|
|
98
|
-
case "resolver":
|
|
99
|
-
options.resolvers.push(uniqueId);
|
|
100
|
-
break;
|
|
101
|
-
case "middleware":
|
|
102
|
-
options.middlewares?.push?.(uniqueId);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
options.addImportItem({
|
|
106
|
-
specifier: transformImportPath(path, packageName, silgiInstance.options.silgi.serverDir),
|
|
107
|
-
imports: [{
|
|
108
|
-
name: exportName,
|
|
109
|
-
as: uniqueId
|
|
110
|
-
}]
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
silgiInstance.hook("before:schema.ts", (options) => {
|
|
115
|
-
const ignored = Array.isArray(silgiInstance.options.watchOptions?.ignored) ? silgiInstance.options.watchOptions.ignored : [];
|
|
116
|
-
for (const { exportName, path, uniqueId, category } of typeExports) {
|
|
117
|
-
if (!isWatchedPath(path, ignored)) silgiInstance.options.devServer.watch.push(path);
|
|
118
|
-
if (category === "shared" || category === "context") {
|
|
119
|
-
const targetCollection = category === "shared" ? options.shareds : options.contexts;
|
|
120
|
-
targetCollection.push({
|
|
121
|
-
key: uniqueId,
|
|
122
|
-
value: uniqueId
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
options.addImportItem({
|
|
126
|
-
imports: [{
|
|
127
|
-
name: exportName,
|
|
128
|
-
as: uniqueId
|
|
129
|
-
}],
|
|
130
|
-
specifier: transformImportPath(path, packageName, silgiInstance.options.build.typesDir)
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
async function verifyDirectoryCaseSensitivity(directoryPath, rootDirectory) {
|
|
136
|
-
const directoryName = basename(directoryPath);
|
|
137
|
-
const parentDirectory = dirname(directoryPath);
|
|
138
|
-
try {
|
|
139
|
-
const siblingEntries = await readdir(parentDirectory);
|
|
140
|
-
if (!siblingEntries.includes(directoryName)) {
|
|
141
|
-
const directoryNameLowerCase = directoryName.toLowerCase();
|
|
142
|
-
const caseInsensitiveMatch = siblingEntries.find((sibling) => sibling.toLowerCase() === directoryNameLowerCase);
|
|
143
|
-
if (caseInsensitiveMatch) {
|
|
144
|
-
const originalRelative = relative(rootDirectory, directoryPath);
|
|
145
|
-
const correctedRelative = relative(rootDirectory, join(parentDirectory, caseInsensitiveMatch));
|
|
146
|
-
consola$1.warn(`Components not scanned from \`~/${correctedRelative}\`. Did you mean to name the directory \`~/${originalRelative}\` instead?`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
} catch {}
|
|
150
|
-
}
|
|
151
|
-
async function extractExportEntitiesFromFile(absoluteFilePath, functionExportNames = DEFAULT_FUNCTION_EXPORT_NAMES, interfaceExtendsNames = DEFAULT_INTERFACE_EXTENDS_NAMES) {
|
|
152
|
-
const exportEntities = [];
|
|
153
|
-
const fileContent = await readFile(absoluteFilePath, "utf-8");
|
|
154
|
-
const parsed = await parseAsync(absoluteFilePath, fileContent);
|
|
155
|
-
const variableDeclarations = new Map();
|
|
156
|
-
for (const node of parsed.program.body) {
|
|
157
|
-
if (node.type === "VariableDeclaration" && Array.isArray(node.declarations)) {
|
|
158
|
-
for (const decl of node.declarations) if (decl.type === "VariableDeclarator" && decl.id.type === "Identifier") variableDeclarations.set(decl.id.name, decl);
|
|
159
|
-
}
|
|
160
|
-
if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
|
|
161
|
-
for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.id.type === "Identifier") variableDeclarations.set(decl.id.name, decl);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
for (const node of parsed.program.body) if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "TSInterfaceDeclaration") {
|
|
165
|
-
const decl = node.declaration;
|
|
166
|
-
if (Array.isArray(decl.extends) && decl.extends.some((dec) => dec.type === "TSInterfaceHeritage" && dec.expression.type === "Identifier" && interfaceExtendsNames.includes(dec.expression.name))) exportEntities.push({
|
|
167
|
-
name: decl.id?.name,
|
|
168
|
-
type: "interface",
|
|
169
|
-
declaration: "interface",
|
|
170
|
-
extends: decl.extends.filter((e) => e.type === "TSInterfaceHeritage" && e.expression.type === "Identifier").map((e) => e.expression.type === "Identifier" ? e.expression.name : false).filter((name) => Boolean(name))
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
for (const node of parsed.program.body) if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
|
|
174
|
-
const decls = node.declaration.declarations;
|
|
175
|
-
if (Array.isArray(decls)) {
|
|
176
|
-
for (const decl of decls) if (decl.type === "VariableDeclarator" && decl.id.type === "Identifier" && decl.init && decl.init.type === "CallExpression" && decl.init.callee.type === "Identifier" && functionExportNames.includes(decl.init.callee.name)) {
|
|
177
|
-
let servicePath;
|
|
178
|
-
let serviceMethod;
|
|
179
|
-
if (decl.init.callee.name === "createService" || decl.init.callee.name === "createWebSocket") {
|
|
180
|
-
const firstArg = decl.init.arguments?.[0];
|
|
181
|
-
if (firstArg && firstArg.type === "ObjectExpression" && Array.isArray(firstArg.properties)) {
|
|
182
|
-
for (const prop of firstArg.properties) if (prop.type === "Property" && prop.key.type === "Identifier") {
|
|
183
|
-
if (prop.key.name === "path" && prop.value.type === "Literal" && typeof prop.value.value === "string") servicePath = prop.value.value;
|
|
184
|
-
if (prop.key.name === "method" && prop.value.type === "Literal" && typeof prop.value.value === "string") serviceMethod = prop.value.value;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exportEntities.push({
|
|
189
|
-
name: decl.id.name,
|
|
190
|
-
type: "function",
|
|
191
|
-
funcName: decl.init.callee.name,
|
|
192
|
-
servicePath,
|
|
193
|
-
serviceMethod
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
for (const node of parsed.program.body) if (node.type === "ExportNamedDeclaration" && Array.isArray(node.specifiers) && node.specifiers.length > 0) {
|
|
199
|
-
for (const spec of node.specifiers) if (spec.type === "ExportSpecifier" && spec.local.type === "Identifier") {
|
|
200
|
-
const varName = spec.local.name;
|
|
201
|
-
const decl = variableDeclarations.get(varName);
|
|
202
|
-
if (decl && decl.init && decl.init.type === "CallExpression" && decl.init.callee.type === "Identifier" && functionExportNames.includes(decl.init.callee.name)) {
|
|
203
|
-
let servicePath;
|
|
204
|
-
let serviceMethod;
|
|
205
|
-
if (decl.init.callee.name === "createService" || decl.init.callee.name === "createWebSocket") {
|
|
206
|
-
const firstArg = decl.init.arguments?.[0];
|
|
207
|
-
if (firstArg && firstArg.type === "ObjectExpression" && Array.isArray(firstArg.properties)) {
|
|
208
|
-
for (const prop of firstArg.properties) if (prop.type === "Property" && prop.key.type === "Identifier") {
|
|
209
|
-
if (prop.key.name === "path" && prop.value.type === "Literal" && typeof prop.value.value === "string") servicePath = prop.value.value;
|
|
210
|
-
if (prop.key.name === "method" && prop.value.type === "Literal" && typeof prop.value.value === "string") serviceMethod = prop.value.value;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exportEntities.push({
|
|
215
|
-
name: varName,
|
|
216
|
-
type: "function",
|
|
217
|
-
funcName: decl.init.callee.name,
|
|
218
|
-
servicePath,
|
|
219
|
-
serviceMethod
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return exportEntities;
|
|
225
|
-
}
|
|
226
|
-
async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI(), scanOptions = {}) {
|
|
227
|
-
const processedFilePaths = new Set();
|
|
228
|
-
const alreadyScannedPaths = [];
|
|
229
|
-
const serverDirectory = path || silgiInstance.options.serverDir;
|
|
230
|
-
const functionExportNames = scanOptions.functionExportNames ?? DEFAULT_FUNCTION_EXPORT_NAMES;
|
|
231
|
-
const interfaceExtendsNames = scanOptions.interfaceExtendsNames ?? DEFAULT_INTERFACE_EXTENDS_NAMES;
|
|
232
|
-
const functionExportCategories = {};
|
|
233
|
-
functionExportNames.forEach((name) => {
|
|
234
|
-
if (name === "createService") functionExportCategories[name] = "service";
|
|
235
|
-
else if (name === "createWebSocket") functionExportCategories[name] = "websocket";
|
|
236
|
-
else if (name === "createSchema") functionExportCategories[name] = "schema";
|
|
237
|
-
else if (name === "createShared") functionExportCategories[name] = "shared";
|
|
238
|
-
else if (name === "createResolver") functionExportCategories[name] = "resolver";
|
|
239
|
-
else if (name === "createMiddleware") functionExportCategories[name] = "middleware";
|
|
240
|
-
else functionExportCategories[name] = name;
|
|
241
|
-
});
|
|
242
|
-
const interfaceExportCategories = {};
|
|
243
|
-
interfaceExtendsNames.forEach((name) => {
|
|
244
|
-
if (name === "ExtendShared") interfaceExportCategories[name] = "shared";
|
|
245
|
-
else if (name === "ExtendContext") interfaceExportCategories[name] = "context";
|
|
246
|
-
else interfaceExportCategories[name] = name;
|
|
247
|
-
});
|
|
248
|
-
if (!serverDirectory) {
|
|
249
|
-
consola$1.warn("No server directory specified for scanning");
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
try {
|
|
253
|
-
const matchedFiles = await glob(serverDirectory, {
|
|
254
|
-
cwd: silgiInstance.options.rootDir,
|
|
255
|
-
ignore: silgiInstance.options.ignore
|
|
256
|
-
});
|
|
257
|
-
if (matchedFiles.length) await verifyDirectoryCaseSensitivity(serverDirectory, silgiInstance.options.rootDir);
|
|
258
|
-
for (const relativeFilePath of matchedFiles.sort()) {
|
|
259
|
-
const absoluteFilePath = resolve(silgiInstance.options.rootDir, relativeFilePath);
|
|
260
|
-
if (alreadyScannedPaths.find((path$1) => absoluteFilePath.startsWith(withTrailingSlash(path$1))) || isIgnored(absoluteFilePath, silgiInstance) || processedFilePaths.has(absoluteFilePath)) continue;
|
|
261
|
-
processedFilePaths.add(absoluteFilePath);
|
|
262
|
-
const fileExtension = extname(absoluteFilePath);
|
|
263
|
-
if (!silgiInstance.options.extensions?.includes(fileExtension)) continue;
|
|
264
|
-
try {
|
|
265
|
-
const exportEntities = await extractExportEntitiesFromFile(absoluteFilePath, functionExportNames, interfaceExtendsNames);
|
|
266
|
-
const seenServiceSignatures = new Map();
|
|
267
|
-
for (const entity of exportEntities) if ((entity.funcName === "createService" || entity.funcName === "createWebSocket") && entity.servicePath && entity.serviceMethod) {
|
|
268
|
-
const key = `${entity.serviceMethod}:${entity.servicePath}`;
|
|
269
|
-
if (seenServiceSignatures.has(key)) throw new Error(`Duplicate ${entity.funcName} detected for path "${entity.servicePath}" and method "${entity.serviceMethod}".\nFirst found in: ${seenServiceSignatures.get(key)}\nDuplicate in: ${absoluteFilePath}\nPlease ensure each service path/method combination is unique.`);
|
|
270
|
-
seenServiceSignatures.set(key, absoluteFilePath);
|
|
271
|
-
}
|
|
272
|
-
const allExportedEntities = exportEntities;
|
|
273
|
-
const { runtimeExports, typeExports } = categorizeExports(allExportedEntities, absoluteFilePath, functionExportCategories, interfaceExportCategories);
|
|
274
|
-
registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName);
|
|
275
|
-
} catch (error) {
|
|
276
|
-
consola$1.error(`Error processing file ${absoluteFilePath}:`, error);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
} catch (error) {
|
|
280
|
-
consola$1.error("Error scanning export files:", error);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
function isWatchedPath(path, ignoredPatterns) {
|
|
284
|
-
return micromatch.isMatch(path, ignoredPatterns);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
//#endregion
|
|
288
|
-
export { scanSilgiExports };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { prepareCoreFile } from "./prepareCoreFile.mjs";
|
|
2
|
-
import { join, resolve } from "pathe";
|
|
3
|
-
import { writeFile } from "silgi/kit";
|
|
4
|
-
|
|
5
|
-
//#region src/cli/scan/writeCoreFile.ts
|
|
6
|
-
async function writeCoreFile(silgi) {
|
|
7
|
-
const coreContent = await prepareCoreFile(silgi);
|
|
8
|
-
const silgiDir = resolve(silgi.options.silgi.serverDir);
|
|
9
|
-
const buildFiles = [];
|
|
10
|
-
buildFiles.push({
|
|
11
|
-
path: join(silgiDir, "core.ts"),
|
|
12
|
-
contents: coreContent.join("\n")
|
|
13
|
-
});
|
|
14
|
-
buildFiles.push({
|
|
15
|
-
path: join(silgiDir, "meta.ts"),
|
|
16
|
-
contents: `export const meta = ${JSON.stringify(silgi.meta, null, 2)}`
|
|
17
|
-
});
|
|
18
|
-
for await (const file of buildFiles) if (!silgi.errors.length) await writeFile(resolve(silgi.options.build.dir, file.path), file.contents);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { writeCoreFile };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { silgiGenerateType } from "../config/types.mjs";
|
|
2
|
-
import { prepareSchema } from "./prepareSchema.mjs";
|
|
3
|
-
import { isAbsolute, join, relative, resolve } from "pathe";
|
|
4
|
-
import { isDirectory, writeFile } from "silgi/kit";
|
|
5
|
-
import { runtimeDir } from "silgi/runtime/meta";
|
|
6
|
-
import { toExports } from "unimport";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
8
|
-
import { lookupNodeModuleSubpath, parseNodeModulePath, resolvePath } from "mlly";
|
|
9
|
-
import { resolveAlias as resolveAlias$1 } from "pathe/utils";
|
|
10
|
-
|
|
11
|
-
//#region src/cli/scan/writeTypesAndFiles.ts
|
|
12
|
-
async function writeTypesAndFiles(silgi) {
|
|
13
|
-
silgi.hook("prepare:types", (opts) => {
|
|
14
|
-
opts.references.push({ path: "./schema.d.ts" });
|
|
15
|
-
opts.references.push({ path: "./silgi-routes.d.ts" });
|
|
16
|
-
});
|
|
17
|
-
const schemaContent = await prepareSchema(silgi);
|
|
18
|
-
const { declarations, tsConfig } = await silgiGenerateType(silgi);
|
|
19
|
-
const tsConfigPath = resolve(silgi.options.rootDir, silgi.options.typescript.tsconfigPath);
|
|
20
|
-
const typesDir = resolve(silgi.options.build.typesDir);
|
|
21
|
-
let autoImportedTypes = [];
|
|
22
|
-
let autoImportExports = "";
|
|
23
|
-
if (silgi.unimport) {
|
|
24
|
-
await silgi.unimport.init();
|
|
25
|
-
const allImports = await silgi.unimport.getImports();
|
|
26
|
-
autoImportExports = toExports(allImports).replace(/#internal\/nitro/g, relative(typesDir, runtimeDir));
|
|
27
|
-
const resolvedImportPathMap = new Map();
|
|
28
|
-
for (const i of allImports.filter((i$1) => !i$1.type)) {
|
|
29
|
-
if (resolvedImportPathMap.has(i.from)) continue;
|
|
30
|
-
let path = resolveAlias$1(i.from, silgi.options.alias);
|
|
31
|
-
if (isAbsolute(path)) {
|
|
32
|
-
const resolvedPath = await resolvePath(i.from, { url: silgi.options.nodeModulesDirs }).catch(() => null);
|
|
33
|
-
if (resolvedPath) {
|
|
34
|
-
const { dir, name } = parseNodeModulePath(resolvedPath);
|
|
35
|
-
if (!dir || !name) path = resolvedPath;
|
|
36
|
-
else {
|
|
37
|
-
const subpath = await lookupNodeModuleSubpath(resolvedPath);
|
|
38
|
-
path = join(dir, name, subpath || "");
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (existsSync(path) && !await isDirectory(path)) path = path.replace(/\.[a-z]+$/, "");
|
|
43
|
-
if (isAbsolute(path)) path = relative(typesDir, path);
|
|
44
|
-
resolvedImportPathMap.set(i.from, path);
|
|
45
|
-
}
|
|
46
|
-
autoImportedTypes = [silgi.options.imports && silgi.options.imports.autoImport !== false ? (await silgi.unimport.generateTypeDeclarations({
|
|
47
|
-
exportHelper: false,
|
|
48
|
-
resolvePath: (i) => resolvedImportPathMap.get(i.from) ?? i.from
|
|
49
|
-
})).trim() : ""];
|
|
50
|
-
}
|
|
51
|
-
const buildFiles = [];
|
|
52
|
-
buildFiles.push({
|
|
53
|
-
path: join(typesDir, "silgi-imports.d.ts"),
|
|
54
|
-
contents: [...autoImportedTypes, autoImportExports || "export {}"].join("\n")
|
|
55
|
-
});
|
|
56
|
-
buildFiles.push({
|
|
57
|
-
path: join(typesDir, "schema.d.ts"),
|
|
58
|
-
contents: schemaContent.join("\n")
|
|
59
|
-
});
|
|
60
|
-
buildFiles.push({
|
|
61
|
-
path: join(typesDir, "silgi-config.d.ts"),
|
|
62
|
-
contents: declarations.join("\n")
|
|
63
|
-
});
|
|
64
|
-
buildFiles.push({
|
|
65
|
-
path: tsConfigPath,
|
|
66
|
-
contents: JSON.stringify(tsConfig, null, 2)
|
|
67
|
-
});
|
|
68
|
-
for await (const file of buildFiles) if (!silgi.errors.length) await writeFile(resolve(silgi.options.build.dir, file.path), file.contents);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { writeTypesAndFiles };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { cancel, isCancel } from "@clack/prompts";
|
|
2
|
-
|
|
3
|
-
//#region src/cli/utils/cancel.ts
|
|
4
|
-
function cancelOnCancel({ value, message = "Cancelled", onBeforeExit, exitCode = 0 } = {}) {
|
|
5
|
-
const handleCancel = () => {
|
|
6
|
-
cancel(message);
|
|
7
|
-
onBeforeExit?.();
|
|
8
|
-
process.exit(exitCode);
|
|
9
|
-
};
|
|
10
|
-
if (!value || isCancel(value)) handleCancel();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { cancelOnCancel };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/cli/utils/common.ts
|
|
2
|
-
const commonArgs = {
|
|
3
|
-
dir: {
|
|
4
|
-
type: "string",
|
|
5
|
-
description: "project root directory"
|
|
6
|
-
},
|
|
7
|
-
_dir: {
|
|
8
|
-
type: "positional",
|
|
9
|
-
default: ".",
|
|
10
|
-
description: "project root directory (prefer using `--dir`)"
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { commonArgs };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useSilgiCLI } from "silgi";
|
|
2
|
-
import satisfies from "semver/functions/satisfies.js";
|
|
3
|
-
import { version } from "silgi/meta";
|
|
4
|
-
|
|
5
|
-
//#region src/cli/utils/compatibility.ts
|
|
6
|
-
const SEMANTIC_VERSION_RE = /-\d+\.[0-9a-f]+/;
|
|
7
|
-
function normalizeSemanticVersion(version$1) {
|
|
8
|
-
return version$1.replace(SEMANTIC_VERSION_RE, "");
|
|
9
|
-
}
|
|
10
|
-
const SILGI_VERSION_RE = /^v/g;
|
|
11
|
-
/**
|
|
12
|
-
* Check version constraints and return incompatibility issues as an array
|
|
13
|
-
*/
|
|
14
|
-
async function checkSilgiCompatibility(constraints, silgi = useSilgiCLI()) {
|
|
15
|
-
const issues = [];
|
|
16
|
-
if (constraints.silgi) {
|
|
17
|
-
const _silgiVersion = version.replace(SILGI_VERSION_RE, "");
|
|
18
|
-
if (!satisfies(normalizeSemanticVersion(_silgiVersion), constraints.silgi, { includePrerelease: true })) issues.push({
|
|
19
|
-
name: "silgi",
|
|
20
|
-
message: `Silgi version \`${constraints.silgi}\` is required but currently using \`${version}\``
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
await silgi.callHook("kit:compatibility", constraints, issues);
|
|
24
|
-
issues.toString = () => issues.map((issue) => ` - [${issue.name}] ${issue.message}`).join("\n");
|
|
25
|
-
return issues;
|
|
26
|
-
}
|
|
27
|
-
function hasInstalledModule(moduleKey, silgi = useSilgiCLI()) {
|
|
28
|
-
const find = silgi.scanModules.find(({ meta }) => meta.configKey === moduleKey);
|
|
29
|
-
return find?.installed ?? false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
export { checkSilgiCompatibility, hasInstalledModule as hasInstalledModule$1 };
|
package/dist/cli/utils/debug.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useSilgiCLI } from "../../core/silgiApp.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/cli/utils/debug.ts
|
|
4
|
-
function debugMode(name) {
|
|
5
|
-
const silgi = useSilgiCLI();
|
|
6
|
-
if (silgi.options.debug === true || typeof silgi.options.debug === "object" && silgi.options.debug[name]) return true;
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { debugMode };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { join, relative, resolve } from "pathe";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import ignore from "ignore";
|
|
4
|
-
|
|
5
|
-
//#region src/cli/utils/ignore.ts
|
|
6
|
-
const NEGATION_RE = /^(!?)(.*)$/;
|
|
7
|
-
function resolveIgnorePatterns(silgi, relativePath) {
|
|
8
|
-
if (!silgi) return [];
|
|
9
|
-
const ignorePatterns = silgi.options.ignore.flatMap((s) => resolveGroupSyntax(s));
|
|
10
|
-
const nuxtignoreFile = join(silgi.options.rootDir, ".nuxtignore");
|
|
11
|
-
if (existsSync(nuxtignoreFile)) {
|
|
12
|
-
const contents = readFileSync(nuxtignoreFile, "utf-8");
|
|
13
|
-
ignorePatterns.push(...contents.trim().split(/\r?\n/));
|
|
14
|
-
}
|
|
15
|
-
if (relativePath) return ignorePatterns.map((p) => {
|
|
16
|
-
const [_, negation = "", pattern] = p.match(NEGATION_RE) || [];
|
|
17
|
-
if (pattern && pattern[0] === "*") return p;
|
|
18
|
-
return negation + relative(relativePath, resolve(silgi.options.rootDir, pattern || p));
|
|
19
|
-
});
|
|
20
|
-
return ignorePatterns;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Return a filter function to filter an array of paths
|
|
24
|
-
*/
|
|
25
|
-
function isIgnored(pathname, silgi, _stats) {
|
|
26
|
-
if (!silgi) return false;
|
|
27
|
-
if (!silgi._ignore) {
|
|
28
|
-
silgi._ignore = ignore(silgi.options.ignoreOptions);
|
|
29
|
-
silgi._ignore.add(resolveIgnorePatterns(silgi));
|
|
30
|
-
}
|
|
31
|
-
const relativePath = relative(silgi.options.rootDir, pathname);
|
|
32
|
-
if (relativePath[0] === "." && relativePath[1] === ".") return false;
|
|
33
|
-
return !!(relativePath && silgi._ignore.ignores(relativePath));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* This function turns string containing groups '**\/*.{spec,test}.{js,ts}' into an array of strings.
|
|
37
|
-
* For example will '**\/*.{spec,test}.{js,ts}' be resolved to:
|
|
38
|
-
* ['**\/*.spec.js', '**\/*.spec.ts', '**\/*.test.js', '**\/*.test.ts']
|
|
39
|
-
* @param group string containing the group syntax
|
|
40
|
-
* @returns {string[]} array of strings without the group syntax
|
|
41
|
-
*/
|
|
42
|
-
function resolveGroupSyntax(group) {
|
|
43
|
-
let groups = [group];
|
|
44
|
-
while (groups.some((group$1) => group$1.includes("{"))) groups = groups.flatMap((group$1) => {
|
|
45
|
-
const [head, ...tail] = group$1.split("{");
|
|
46
|
-
if (tail.length) {
|
|
47
|
-
const [body = "", ...rest] = tail.join("{").split("}");
|
|
48
|
-
return body.split(",").map((part) => `${head}${part}${rest.join("")}`);
|
|
49
|
-
}
|
|
50
|
-
return group$1;
|
|
51
|
-
});
|
|
52
|
-
return groups;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { isIgnored };
|