@slopware/sloppy-linux-x64 0.1.0-alpha.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/LICENSE +201 -0
- package/README.md +5 -0
- package/bin/sloppy +0 -0
- package/bin/sloppyc +0 -0
- package/docs/KNOWN_LIMITATIONS.md +16 -0
- package/docs/LICENSES.md +6 -0
- package/docs/NOTICE.md +8 -0
- package/examples/README.md +140 -0
- package/examples/auth-api/README.md +20 -0
- package/examples/auth-api/app.js +61 -0
- package/examples/auth-api/appsettings.json +7 -0
- package/examples/auth-api/sloppy.json +5 -0
- package/examples/cache-basic/README.md +9 -0
- package/examples/cache-basic/app.js +32 -0
- package/examples/cache-hybrid-postgres/README.md +10 -0
- package/examples/cache-hybrid-postgres/app.js +27 -0
- package/examples/cache-output-api/README.md +10 -0
- package/examples/cache-output-api/app.js +35 -0
- package/examples/codec-base64-hex/README.md +14 -0
- package/examples/codec-base64-hex/app.js +15 -0
- package/examples/codec-checksums/README.md +15 -0
- package/examples/codec-checksums/app.js +8 -0
- package/examples/codec-compression/README.md +13 -0
- package/examples/codec-compression/app.js +9 -0
- package/examples/codec-streaming-compression/README.md +19 -0
- package/examples/codec-streaming-compression/app.js +16 -0
- package/examples/codec-text-binary/README.md +16 -0
- package/examples/codec-text-binary/app.js +17 -0
- package/examples/compiler-hello/README.md +71 -0
- package/examples/compiler-hello/app.js +7 -0
- package/examples/compiler-hello/expected/app.js +8 -0
- package/examples/compiler-hello/expected/app.js.map +53 -0
- package/examples/compiler-hello/expected/app.plan.json +229 -0
- package/examples/compiler-hello/expected/routes.slrt +0 -0
- package/examples/config-basic/README.md +13 -0
- package/examples/config-basic/app.js +13 -0
- package/examples/config-basic/appsettings.json +7 -0
- package/examples/config-secrets-redaction/README.md +9 -0
- package/examples/config-secrets-redaction/app.js +9 -0
- package/examples/config-secrets-redaction/appsettings.json +5 -0
- package/examples/config-strict-mode/README.md +7 -0
- package/examples/config-strict-mode/app.js +10 -0
- package/examples/config-strict-mode/appsettings.json +7 -0
- package/examples/configured-api/README.md +38 -0
- package/examples/configured-api/app.js +12 -0
- package/examples/configured-api/appsettings.Development.json +5 -0
- package/examples/configured-api/appsettings.json +6 -0
- package/examples/configured-api/sloppy.json +5 -0
- package/examples/core-config-secrets/README.md +10 -0
- package/examples/core-config-secrets/app.js +15 -0
- package/examples/core-fs-time-codec/README.md +9 -0
- package/examples/core-fs-time-codec/app.js +8 -0
- package/examples/core-network-time-codec/README.md +11 -0
- package/examples/core-network-time-codec/app.js +20 -0
- package/examples/core-policy-audit/README.md +7 -0
- package/examples/core-policy-audit/app.js +22 -0
- package/examples/core-process-time-codec/README.md +8 -0
- package/examples/core-process-time-codec/app.js +28 -0
- package/examples/core-worker-time/README.md +8 -0
- package/examples/core-worker-time/app.js +17 -0
- package/examples/crypto-hash-hmac/README.md +17 -0
- package/examples/crypto-hash-hmac/app.js +29 -0
- package/examples/crypto-password/README.md +21 -0
- package/examples/crypto-password/app.js +12 -0
- package/examples/crypto-random-token/README.md +16 -0
- package/examples/crypto-random-token/app.js +12 -0
- package/examples/crypto-secret-constant-time/README.md +21 -0
- package/examples/crypto-secret-constant-time/app.js +15 -0
- package/examples/data-foundation/README.md +39 -0
- package/examples/data-foundation/app.js +63 -0
- package/examples/dependency-graph/README.md +19 -0
- package/examples/dependency-graph/fixtures/graph-helper/index.js +3 -0
- package/examples/dependency-graph/fixtures/graph-helper/package.json +6 -0
- package/examples/dependency-graph/package.json +7 -0
- package/examples/dependency-graph/public/message.txt +1 -0
- package/examples/dependency-graph/sloppy.json +9 -0
- package/examples/dependency-graph/src/main.ts +8 -0
- package/examples/dogfood/README.md +23 -0
- package/examples/dogfood/dogfood.json +136 -0
- package/examples/dynamic-module-include/README.md +20 -0
- package/examples/dynamic-module-include/public/readme.txt +1 -0
- package/examples/dynamic-module-include/sloppy.json +12 -0
- package/examples/dynamic-module-include/src/main.ts +6 -0
- package/examples/dynamic-module-include/src/plugins/alpha.js +3 -0
- package/examples/dynamic-module-include/src/plugins/beta.js +3 -0
- package/examples/ergonomics/README.md +42 -0
- package/examples/ergonomics/app.js +38 -0
- package/examples/framework-controller/README.md +12 -0
- package/examples/framework-controller/app.js +31 -0
- package/examples/framework-di-services/README.md +17 -0
- package/examples/framework-di-services/app.ts +40 -0
- package/examples/framework-explicit-binding/README.md +12 -0
- package/examples/framework-explicit-binding/app.ts +34 -0
- package/examples/framework-hello/README.md +16 -0
- package/examples/framework-hello/app.ts +16 -0
- package/examples/framework-postgres-crud/README.md +73 -0
- package/examples/framework-postgres-crud/app.ts +64 -0
- package/examples/framework-sqlite-crud/README.md +52 -0
- package/examples/framework-sqlite-crud/app.ts +90 -0
- package/examples/framework-sqlite-crud/appsettings.json +11 -0
- package/examples/framework-sqlserver-crud/README.md +73 -0
- package/examples/framework-sqlserver-crud/app.ts +64 -0
- package/examples/framework-validation-errors/README.md +12 -0
- package/examples/framework-validation-errors/app.ts +16 -0
- package/examples/fs-basic/README.md +24 -0
- package/examples/fs-basic/app.js +12 -0
- package/examples/fs-roots-policy/README.md +14 -0
- package/examples/fs-roots-policy/app.js +4 -0
- package/examples/fs-streams/README.md +18 -0
- package/examples/fs-streams/app.js +11 -0
- package/examples/fs-watch/README.md +19 -0
- package/examples/fs-watch/app.js +11 -0
- package/examples/hello/README.md +63 -0
- package/examples/hello/app.js +19 -0
- package/examples/hello-minimal/README.md +51 -0
- package/examples/hello-minimal/sloppy.json +5 -0
- package/examples/hello-minimal/src/main.ts +9 -0
- package/examples/http-client-basic/README.md +11 -0
- package/examples/http-client-basic/app.js +46 -0
- package/examples/http-client-generated/README.md +22 -0
- package/examples/http-client-generated/openapi.json +45 -0
- package/examples/http-client-resilience/README.md +4 -0
- package/examples/http-client-resilience/app.js +38 -0
- package/examples/http-client-runtime-loopback/README.md +24 -0
- package/examples/http-client-testhost/README.md +4 -0
- package/examples/http-client-testhost/app.js +27 -0
- package/examples/http-client-testhost-package-mock/README.md +26 -0
- package/examples/http-client-typed/README.md +5 -0
- package/examples/http-client-typed/app.js +33 -0
- package/examples/modules-api/README.md +30 -0
- package/examples/modules-api/app.js +9 -0
- package/examples/modules-api/modules/routes.js +16 -0
- package/examples/modules-api/sloppy.json +5 -0
- package/examples/modules-basic/README.md +32 -0
- package/examples/modules-basic/app.js +41 -0
- package/examples/net-deadline-cancel/README.md +13 -0
- package/examples/net-deadline-cancel/app.js +34 -0
- package/examples/net-local-ipc/README.md +12 -0
- package/examples/net-local-ipc/app.js +46 -0
- package/examples/net-policy-strict/README.md +12 -0
- package/examples/net-policy-strict/app.js +34 -0
- package/examples/net-tcp-client/README.md +10 -0
- package/examples/net-tcp-client/app.js +23 -0
- package/examples/net-tcp-echo/README.md +11 -0
- package/examples/net-tcp-echo/app.js +45 -0
- package/examples/net-tcp-server/README.md +10 -0
- package/examples/net-tcp-server/app.js +28 -0
- package/examples/node-compat-path-events/README.md +15 -0
- package/examples/node-compat-path-events/sloppy.json +6 -0
- package/examples/node-compat-path-events/src/main.ts +15 -0
- package/examples/ops-compiler/README.md +9 -0
- package/examples/ops-compiler/app.js +26 -0
- package/examples/ops-health-metrics-management/README.md +14 -0
- package/examples/ops-health-metrics-management/app.js +24 -0
- package/examples/orm-basic/README.md +17 -0
- package/examples/orm-basic/app.js +82 -0
- package/examples/orm-cursor-export/README.md +16 -0
- package/examples/orm-cursor-export/app.js +28 -0
- package/examples/orm-migrations/README.md +14 -0
- package/examples/orm-migrations/migrations/.gitkeep +1 -0
- package/examples/orm-migrations/sloppy.json +9 -0
- package/examples/orm-migrations/src/app.ts +34 -0
- package/examples/orm-relations-includes/README.md +10 -0
- package/examples/orm-relations-includes/app.js +47 -0
- package/examples/orm-testservices/README.md +37 -0
- package/examples/orm-testservices/test.mjs +32 -0
- package/examples/os-runtime-api/README.md +11 -0
- package/examples/os-runtime-api/app.js +44 -0
- package/examples/package-zod-like/README.md +28 -0
- package/examples/package-zod-like/fixtures/zod-like/index.js +48 -0
- package/examples/package-zod-like/fixtures/zod-like/package.json +12 -0
- package/examples/package-zod-like/package.json +7 -0
- package/examples/package-zod-like/sloppy.json +6 -0
- package/examples/package-zod-like/src/main.ts +16 -0
- package/examples/postgres-basic/README.md +31 -0
- package/examples/postgres-basic/app.js +50 -0
- package/examples/prealpha-control-plane/README.md +50 -0
- package/examples/prealpha-control-plane/appsettings.Development.json +11 -0
- package/examples/prealpha-control-plane/appsettings.json +15 -0
- package/examples/prealpha-control-plane/sloppy.json +5 -0
- package/examples/prealpha-control-plane/src/db/schema.js +7 -0
- package/examples/prealpha-control-plane/src/db/seed.js +6 -0
- package/examples/prealpha-control-plane/src/main.js +21 -0
- package/examples/prealpha-control-plane/src/routes/apps.js +34 -0
- package/examples/prealpha-control-plane/src/routes/builds.js +25 -0
- package/examples/prealpha-control-plane/src/routes/deployments.js +19 -0
- package/examples/prealpha-control-plane/src/routes/diagnostics.js +11 -0
- package/examples/prealpha-control-plane/src/routes/health.js +27 -0
- package/examples/prealpha-control-plane/src/routes/projects.js +38 -0
- package/examples/prealpha-control-plane/src/services/diagnosticsSink.js +11 -0
- package/examples/prealpha-control-plane/src/services/repositories.js +9 -0
- package/examples/prealpha-control-plane/src/validation/schemas.js +6 -0
- package/examples/program-fs-process/README.md +31 -0
- package/examples/program-fs-process/sloppy.json +9 -0
- package/examples/program-fs-process/src/main.ts +27 -0
- package/examples/program-hello/README.md +32 -0
- package/examples/program-hello/main.ts +8 -0
- package/examples/program-hello/message.ts +1 -0
- package/examples/program-hello/sloppy.json +5 -0
- package/examples/rate-limit-auth/README.md +3 -0
- package/examples/rate-limit-auth/app.js +14 -0
- package/examples/rate-limit-basic/README.md +3 -0
- package/examples/rate-limit-basic/app.js +13 -0
- package/examples/rate-limit-redis/README.md +5 -0
- package/examples/rate-limit-redis/app.js +20 -0
- package/examples/rate-limit-testhost/README.md +4 -0
- package/examples/rate-limit-testhost/app.js +13 -0
- package/examples/rate-limit-websocket/README.md +3 -0
- package/examples/rate-limit-websocket/app.js +16 -0
- package/examples/realtime-auth/README.md +8 -0
- package/examples/realtime-auth/app.js +25 -0
- package/examples/realtime-auth/test.mjs +43 -0
- package/examples/realtime-chat/README.md +8 -0
- package/examples/realtime-chat/app.js +32 -0
- package/examples/realtime-chat/test.mjs +52 -0
- package/examples/realtime-dashboard/README.md +20 -0
- package/examples/realtime-dashboard/app.js +37 -0
- package/examples/realtime-presence/README.md +8 -0
- package/examples/realtime-presence/app.js +32 -0
- package/examples/realtime-presence/test.mjs +50 -0
- package/examples/realtime-testhost/README.md +8 -0
- package/examples/realtime-testhost/test.mjs +31 -0
- package/examples/redis-basic/README.md +17 -0
- package/examples/redis-basic/app.js +39 -0
- package/examples/redis-cache/README.md +14 -0
- package/examples/redis-cache/app.js +36 -0
- package/examples/redis-locks/README.md +13 -0
- package/examples/redis-locks/app.js +49 -0
- package/examples/request-context/README.md +32 -0
- package/examples/request-context/app.js +15 -0
- package/examples/sqlite-basic/README.md +52 -0
- package/examples/sqlite-basic/app.js +56 -0
- package/examples/sqlserver-basic/README.md +36 -0
- package/examples/sqlserver-basic/app.js +59 -0
- package/examples/static-files-basic/README.md +11 -0
- package/examples/static-files-basic/app.js +12 -0
- package/examples/static-files-basic/public/app.js +1 -0
- package/examples/static-files-basic/public/site.css +3 -0
- package/examples/static-files-package/README.md +12 -0
- package/examples/static-files-package/app.js +10 -0
- package/examples/static-files-package/public/index.html +2 -0
- package/examples/static-files-precompressed/README.md +12 -0
- package/examples/static-files-precompressed/app.js +11 -0
- package/examples/static-files-precompressed/public/app.js +1 -0
- package/examples/static-files-precompressed/public/app.js.br +0 -0
- package/examples/static-files-precompressed/public/app.js.gz +0 -0
- package/examples/static-files-spa/README.md +12 -0
- package/examples/static-files-spa/app.js +16 -0
- package/examples/static-files-spa/dist/assets/app.js +1 -0
- package/examples/static-files-spa/dist/index.html +4 -0
- package/examples/static-files-testhost/README.md +8 -0
- package/examples/static-files-testhost/app.js +13 -0
- package/examples/static-files-testhost/public/app.js +1 -0
- package/examples/static-files-testhost/public/app.js.gz +0 -0
- package/examples/static-files-testhost/test.mjs +38 -0
- package/examples/testhost-basic/README.md +26 -0
- package/examples/testhost-db/README.md +31 -0
- package/examples/testservices-postgres/README.md +68 -0
- package/examples/testservices-redis/README.md +71 -0
- package/examples/testservices-sqlserver/README.md +75 -0
- package/examples/time-basic/README.md +18 -0
- package/examples/time-basic/app.js +12 -0
- package/examples/time-deadline-cancellation/README.md +11 -0
- package/examples/time-deadline-cancellation/app.js +27 -0
- package/examples/time-fake-clock/README.md +14 -0
- package/examples/time-fake-clock/app.js +25 -0
- package/examples/time-interval-schedule/README.md +13 -0
- package/examples/time-interval-schedule/app.js +60 -0
- package/examples/users-api-sqlite/README.md +74 -0
- package/examples/users-api-sqlite/app.js +11 -0
- package/examples/users-api-sqlite/appsettings.Development.json +11 -0
- package/examples/users-api-sqlite/appsettings.json +11 -0
- package/examples/users-api-sqlite/modules/users.js +40 -0
- package/examples/users-api-sqlite/sloppy.json +5 -0
- package/examples/validation-errors/README.md +36 -0
- package/examples/validation-errors/app.js +14 -0
- package/examples/validation-errors/invalid-user.http +6 -0
- package/examples/validation-errors/sloppy.json +5 -0
- package/examples/web-dynamic-routes/README.md +17 -0
- package/examples/web-dynamic-routes/app.ts +27 -0
- package/examples/webhooks-basic/README.md +11 -0
- package/examples/webhooks-basic/app.js +48 -0
- package/examples/websocket-auth/README.md +8 -0
- package/examples/websocket-auth/app.js +16 -0
- package/examples/websocket-echo/README.md +9 -0
- package/examples/websocket-echo/app.js +36 -0
- package/examples/websocket-json-schema/README.md +5 -0
- package/examples/websocket-json-schema/app.js +25 -0
- package/examples/websocket-testhost/README.md +11 -0
- package/examples/websocket-testhost/test.mjs +49 -0
- package/examples/workers-background-service/README.md +7 -0
- package/examples/workers-background-service/app.js +16 -0
- package/examples/workers-js-isolate/README.md +8 -0
- package/examples/workers-js-isolate/app.js +19 -0
- package/examples/workers-js-isolate/workers/parser.ts +11 -0
- package/examples/workers-shutdown/README.md +6 -0
- package/examples/workers-shutdown/app.js +26 -0
- package/examples/workers-workerpool/README.md +6 -0
- package/examples/workers-workerpool/app.js +23 -0
- package/examples/workers-workqueue/README.md +8 -0
- package/examples/workers-workqueue/app.js +24 -0
- package/manifest.json +59 -0
- package/package.json +34 -0
- package/stdlib/sloppy/README.md +177 -0
- package/stdlib/sloppy/app.js +2142 -0
- package/stdlib/sloppy/auth.js +1813 -0
- package/stdlib/sloppy/bootstrap.manifest.json +83 -0
- package/stdlib/sloppy/cache.js +1542 -0
- package/stdlib/sloppy/codec.js +1153 -0
- package/stdlib/sloppy/config.js +61 -0
- package/stdlib/sloppy/crypto.js +312 -0
- package/stdlib/sloppy/data.js +2945 -0
- package/stdlib/sloppy/ffi.js +185 -0
- package/stdlib/sloppy/fs.js +795 -0
- package/stdlib/sloppy/health.js +603 -0
- package/stdlib/sloppy/http.js +1595 -0
- package/stdlib/sloppy/index.js +59 -0
- package/stdlib/sloppy/internal/bytes.js +31 -0
- package/stdlib/sloppy/internal/capabilities.js +155 -0
- package/stdlib/sloppy/internal/config.js +640 -0
- package/stdlib/sloppy/internal/disposable.js +31 -0
- package/stdlib/sloppy/internal/headers.js +63 -0
- package/stdlib/sloppy/internal/intrinsics.js +2 -0
- package/stdlib/sloppy/internal/json.js +20 -0
- package/stdlib/sloppy/internal/logging.js +278 -0
- package/stdlib/sloppy/internal/modules.js +405 -0
- package/stdlib/sloppy/internal/redaction.js +87 -0
- package/stdlib/sloppy/internal/routes.js +2279 -0
- package/stdlib/sloppy/internal/runtime-classic.js +19837 -0
- package/stdlib/sloppy/internal/services.js +690 -0
- package/stdlib/sloppy/internal/shared.js +32 -0
- package/stdlib/sloppy/internal/testhost-diagnostics.js +88 -0
- package/stdlib/sloppy/internal/testhost-http-server.js +238 -0
- package/stdlib/sloppy/internal/testhost-http.js +118 -0
- package/stdlib/sloppy/internal/testhost-loopback.js +50 -0
- package/stdlib/sloppy/internal/testservices-docker.js +154 -0
- package/stdlib/sloppy/internal/validation.js +117 -0
- package/stdlib/sloppy/metrics.js +427 -0
- package/stdlib/sloppy/net.js +5208 -0
- package/stdlib/sloppy/node/assert/strict.js +39 -0
- package/stdlib/sloppy/node/assert.js +228 -0
- package/stdlib/sloppy/node/buffer.js +247 -0
- package/stdlib/sloppy/node/console.js +33 -0
- package/stdlib/sloppy/node/constants.js +9 -0
- package/stdlib/sloppy/node/crypto.js +89 -0
- package/stdlib/sloppy/node/diagnostics_channel.js +41 -0
- package/stdlib/sloppy/node/events.js +113 -0
- package/stdlib/sloppy/node/fs/promises.js +27 -0
- package/stdlib/sloppy/node/fs.js +280 -0
- package/stdlib/sloppy/node/http.js +11 -0
- package/stdlib/sloppy/node/https.js +11 -0
- package/stdlib/sloppy/node/module.js +40 -0
- package/stdlib/sloppy/node/os.js +22 -0
- package/stdlib/sloppy/node/path.js +78 -0
- package/stdlib/sloppy/node/perf_hooks.js +12 -0
- package/stdlib/sloppy/node/process.js +129 -0
- package/stdlib/sloppy/node/querystring.js +21 -0
- package/stdlib/sloppy/node/stream/promises.js +3 -0
- package/stdlib/sloppy/node/stream.js +132 -0
- package/stdlib/sloppy/node/string_decoder.js +23 -0
- package/stdlib/sloppy/node/timers.js +26 -0
- package/stdlib/sloppy/node/tty.js +18 -0
- package/stdlib/sloppy/node/url.js +17 -0
- package/stdlib/sloppy/node/util.js +95 -0
- package/stdlib/sloppy/node/zlib.js +72 -0
- package/stdlib/sloppy/orm.js +2188 -0
- package/stdlib/sloppy/os.js +580 -0
- package/stdlib/sloppy/problem-details.js +29 -0
- package/stdlib/sloppy/providers/sqlite.js +26 -0
- package/stdlib/sloppy/rate-limit.js +856 -0
- package/stdlib/sloppy/realtime.js +1508 -0
- package/stdlib/sloppy/redis.js +1272 -0
- package/stdlib/sloppy/request-id.js +184 -0
- package/stdlib/sloppy/request-logging.js +101 -0
- package/stdlib/sloppy/results.js +933 -0
- package/stdlib/sloppy/schema.js +546 -0
- package/stdlib/sloppy/testing.js +4081 -0
- package/stdlib/sloppy/testservices.js +1041 -0
- package/stdlib/sloppy/time.js +894 -0
- package/stdlib/sloppy/webhooks.js +1330 -0
- package/stdlib/sloppy/workers.js +986 -0
- package/templates/api/README.md +82 -0
- package/templates/api/appsettings.Development.json +14 -0
- package/templates/api/appsettings.json +13 -0
- package/templates/api/data/.gitkeep +1 -0
- package/templates/api/gitignore +4 -0
- package/templates/api/migrations/0001_create_users.sql +1 -0
- package/templates/api/package.json +16 -0
- package/templates/api/public/hello.txt +1 -0
- package/templates/api/sloppy.json +14 -0
- package/templates/api/src/config.ts +1 -0
- package/templates/api/src/db/migrate.ts +14 -0
- package/templates/api/src/db/schema.ts +4 -0
- package/templates/api/src/db/usersRepository.ts +23 -0
- package/templates/api/src/main.ts +18 -0
- package/templates/api/src/models/user.ts +7 -0
- package/templates/api/src/routes/health.ts +20 -0
- package/templates/api/src/routes/users.ts +40 -0
- package/templates/api/src/services/usersService.ts +21 -0
- package/templates/api/tsconfig.json +15 -0
- package/templates/cli/README.md +16 -0
- package/templates/cli/gitignore +2 -0
- package/templates/cli/package.json +13 -0
- package/templates/cli/sloppy.json +6 -0
- package/templates/cli/src/commands/echo.ts +9 -0
- package/templates/cli/src/commands/inspect.ts +20 -0
- package/templates/cli/src/main.ts +50 -0
- package/templates/cli/tsconfig.json +15 -0
- package/templates/minimal-api/README.md +14 -0
- package/templates/minimal-api/gitignore +3 -0
- package/templates/minimal-api/package.json +14 -0
- package/templates/minimal-api/sloppy.json +5 -0
- package/templates/minimal-api/src/main.ts +9 -0
- package/templates/minimal-api/tsconfig.json +15 -0
- package/templates/node-compat/README.md +40 -0
- package/templates/node-compat/gitignore +2 -0
- package/templates/node-compat/package.json +11 -0
- package/templates/node-compat/sloppy.json +6 -0
- package/templates/node-compat/src/main.ts +40 -0
- package/templates/package-api/README.md +44 -0
- package/templates/package-api/fixtures/validator-lite/index.js +7 -0
- package/templates/package-api/fixtures/validator-lite/package.json +6 -0
- package/templates/package-api/gitignore +3 -0
- package/templates/package-api/package.json +17 -0
- package/templates/package-api/sloppy.json +5 -0
- package/templates/package-api/src/main.ts +10 -0
- package/templates/package-api/src/routes/health.ts +5 -0
- package/templates/package-api/src/routes/users.ts +12 -0
- package/templates/package-api/tsconfig.json +15 -0
- package/templates/program/README.md +12 -0
- package/templates/program/gitignore +1 -0
- package/templates/program/package.json +10 -0
- package/templates/program/sloppy.json +6 -0
- package/templates/program/src/main.ts +9 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Health, Results, Sloppy } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const app = Sloppy.create();
|
|
4
|
+
|
|
5
|
+
app.health()
|
|
6
|
+
.check("self", Health.self(), { tags: ["live", "ready", "startup"] })
|
|
7
|
+
.check("runtime", Health.runtime(), { tags: ["ready", "startup"], critical: true })
|
|
8
|
+
.check("memory", Health.memory(), { tags: ["health"], critical: false })
|
|
9
|
+
.expose({
|
|
10
|
+
health: "/health",
|
|
11
|
+
live: "/live",
|
|
12
|
+
ready: "/ready",
|
|
13
|
+
startup: "/startup",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
app.management({
|
|
17
|
+
path: "/_sloppy",
|
|
18
|
+
health: true,
|
|
19
|
+
metrics: true,
|
|
20
|
+
info: true,
|
|
21
|
+
runtime: true,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
app.get("/orders/{id}", () => Results.ok({ ok: true }));
|
|
25
|
+
|
|
26
|
+
export default app;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Operations Health Metrics Management
|
|
2
|
+
|
|
3
|
+
This example wires the first-party operations backend:
|
|
4
|
+
|
|
5
|
+
- liveness at `/live`;
|
|
6
|
+
- readiness at `/ready`;
|
|
7
|
+
- startup at `/startup`;
|
|
8
|
+
- detailed health at `/health`;
|
|
9
|
+
- protected management endpoints under `/_sloppy`;
|
|
10
|
+
- Prometheus metrics at `/_sloppy/metrics`;
|
|
11
|
+
- JSON metrics at `/_sloppy/metrics.json`.
|
|
12
|
+
|
|
13
|
+
The management group uses a small local `protect` hook. Real deployments should
|
|
14
|
+
use an auth policy or ingress policy appropriate for the environment.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Health, Results, Sloppy } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const app = Sloppy.create();
|
|
4
|
+
|
|
5
|
+
const ordersCreated = app.metrics.counter("orders_created_total", {
|
|
6
|
+
description: "Orders accepted by the example app.",
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
app.health()
|
|
10
|
+
.check("self", Health.self(), { tags: ["live", "ready", "startup"] })
|
|
11
|
+
.check("memory", Health.memory(), { tags: ["health"], critical: false, cacheMs: 1000 })
|
|
12
|
+
.expose();
|
|
13
|
+
|
|
14
|
+
app.post("/orders", () => {
|
|
15
|
+
ordersCreated.inc({ route: "/orders" });
|
|
16
|
+
return Results.accepted({ accepted: true });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
app.management({
|
|
20
|
+
path: "/_sloppy",
|
|
21
|
+
protect: (ctx) => ctx.request.headers.get("x-ops-key") === "local-dev-key",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { app };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# ORM Basic
|
|
2
|
+
|
|
3
|
+
This example shows the first-party `sloppy/orm` model and query shape for a
|
|
4
|
+
small team/user API.
|
|
5
|
+
|
|
6
|
+
It covers:
|
|
7
|
+
|
|
8
|
+
- `table`, `column`, and `relation` declarations
|
|
9
|
+
- generated insert, patch, row, and public DTO schemas
|
|
10
|
+
- route `.accepts()` / `.returns()` metadata with ORM schemas
|
|
11
|
+
- transactional insert with `.returning()`
|
|
12
|
+
- split-query collection include with a soft-delete filter
|
|
13
|
+
- public DTO projection that excludes a private password hash column
|
|
14
|
+
|
|
15
|
+
The handlers expect `ctx.db` to be a Sloppy database provider connection. The
|
|
16
|
+
same table metadata can generate provider-specific migration SQL through
|
|
17
|
+
`orm.migrations.script([Teams, Users], { provider })`.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Results, Sloppy } from "sloppy";
|
|
2
|
+
import { column, orm, relation, table } from "sloppy/orm";
|
|
3
|
+
|
|
4
|
+
const Teams = table("teams", {
|
|
5
|
+
id: column.uuid().primaryKey(),
|
|
6
|
+
slug: column.text().notNull().unique(),
|
|
7
|
+
name: column.text().notNull(),
|
|
8
|
+
createdAt: column.instant().notNull().defaultNow(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const Users = table("users", {
|
|
12
|
+
id: column.uuid().primaryKey(),
|
|
13
|
+
teamId: column.uuid().notNull().references(() => Teams.id),
|
|
14
|
+
email: column.text().notNull().unique(),
|
|
15
|
+
displayName: column.text().nullable(),
|
|
16
|
+
passwordHash: column.text().notNull().private(),
|
|
17
|
+
version: column.int().notNull().concurrencyToken(),
|
|
18
|
+
deletedAt: column.instant().nullable().softDelete(),
|
|
19
|
+
createdAt: column.instant().notNull().defaultNow(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
relation(Users, ({ one }) => ({
|
|
23
|
+
team: one(Teams, {
|
|
24
|
+
local: Users.teamId,
|
|
25
|
+
foreign: Teams.id,
|
|
26
|
+
}),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
relation(Teams, ({ many }) => ({
|
|
30
|
+
users: many(Users, {
|
|
31
|
+
local: Teams.id,
|
|
32
|
+
foreign: Users.teamId,
|
|
33
|
+
}),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
const app = Sloppy.create();
|
|
37
|
+
|
|
38
|
+
app.post("/teams/{teamId:uuid}/users", async (ctx) => {
|
|
39
|
+
const input = await ctx.body.json(
|
|
40
|
+
Users.insertSchema.pick("email", "displayName", "passwordHash"),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const created = await orm.transaction(ctx.db, async (tx) => Users.insert(tx, {
|
|
44
|
+
id: crypto.randomUUID(),
|
|
45
|
+
teamId: ctx.params.teamId,
|
|
46
|
+
email: input.email,
|
|
47
|
+
displayName: input.displayName ?? null,
|
|
48
|
+
passwordHash: input.passwordHash,
|
|
49
|
+
version: 1,
|
|
50
|
+
}).returning());
|
|
51
|
+
|
|
52
|
+
return Results.json(
|
|
53
|
+
Users.public(created, ["id", "email", "displayName", "createdAt"]),
|
|
54
|
+
{ status: 201 },
|
|
55
|
+
);
|
|
56
|
+
})
|
|
57
|
+
.accepts(Users.insertSchema.pick("email", "displayName", "passwordHash"))
|
|
58
|
+
.returns(201, Users.publicSchema(["id", "email", "displayName", "createdAt"]));
|
|
59
|
+
|
|
60
|
+
app.get("/teams/{teamId:uuid}", async (ctx) => {
|
|
61
|
+
const team = await orm
|
|
62
|
+
.from(Teams)
|
|
63
|
+
.where((t) => t.id.eq(ctx.params.teamId))
|
|
64
|
+
.include((t) => t.users.where((u) => u.deletedAt.isNull()).take(100))
|
|
65
|
+
.singleOrDefault(ctx.db);
|
|
66
|
+
|
|
67
|
+
if (team === null) {
|
|
68
|
+
return Results.notFound();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return Results.json({
|
|
72
|
+
id: team.id,
|
|
73
|
+
slug: team.slug,
|
|
74
|
+
name: team.name,
|
|
75
|
+
createdAt: team.createdAt,
|
|
76
|
+
users: team.users.map((user) =>
|
|
77
|
+
Users.public(user, ["id", "email", "displayName", "createdAt"])),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export { Teams, Users };
|
|
82
|
+
export default app;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# ORM Cursor Export
|
|
2
|
+
|
|
3
|
+
This experimental documentation example shows the ORM cursor-to-NDJSON adapter:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const cursor = await orm.from(Users).cursor(ctx.db, {
|
|
7
|
+
batchSize: 512,
|
|
8
|
+
maxRows: 100000,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const stream = orm.stream.ndjson(cursor);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The cursor is incremental and closes on early exit or adapter completion.
|
|
15
|
+
`Results.stream` remains the current bounded result descriptor; the ORM adapter
|
|
16
|
+
keeps selected-column metadata available for the native streaming path.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Sloppy, Results, column, orm, table } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const Users = table("users", {
|
|
4
|
+
id: column.uuid().primaryKey(),
|
|
5
|
+
email: column.text().notNull().unique(),
|
|
6
|
+
createdAt: column.instant().notNull().defaultNow(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const app = Sloppy.create();
|
|
10
|
+
|
|
11
|
+
app.get("/exports/users.ndjson", async (ctx) => {
|
|
12
|
+
const cursor = await orm
|
|
13
|
+
.from(Users)
|
|
14
|
+
.select((u) => ({ id: u.id, email: u.email }))
|
|
15
|
+
.orderBy((u) => u.id.asc())
|
|
16
|
+
.cursor(ctx.db, { batchSize: 512, maxRows: 100000 });
|
|
17
|
+
|
|
18
|
+
const stream = orm.stream.ndjson(cursor);
|
|
19
|
+
return Results.stream(async (writer) => {
|
|
20
|
+
for await (const chunk of stream) {
|
|
21
|
+
writer.writeText(chunk);
|
|
22
|
+
}
|
|
23
|
+
}, {
|
|
24
|
+
contentType: stream.contentType,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default app;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# ORM Migrations
|
|
2
|
+
|
|
3
|
+
This example shows the ORM migration draft workflow for a built app.
|
|
4
|
+
|
|
5
|
+
```powershell
|
|
6
|
+
sloppy build
|
|
7
|
+
sloppy orm migration script .sloppy --provider main
|
|
8
|
+
sloppy orm migration add CreateUsers .sloppy --provider main
|
|
9
|
+
sloppy orm migration status .sloppy --provider main
|
|
10
|
+
sloppy orm migration apply .sloppy --provider main
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`script` and `add` read static ORM table metadata from `app.plan.json`.
|
|
14
|
+
Review the generated SQL before applying it.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Results, Sloppy, column, relation, table } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const Teams = table("teams", {
|
|
4
|
+
id: column.uuid().primaryKey(),
|
|
5
|
+
slug: column.text().notNull().unique(),
|
|
6
|
+
name: column.text().notNull(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const Users = table("users", {
|
|
10
|
+
id: column.uuid().primaryKey(),
|
|
11
|
+
teamId: column.uuid().notNull().references(() => Teams.id),
|
|
12
|
+
email: column.text().notNull().unique(),
|
|
13
|
+
deletedAt: column.instant().nullable().softDelete(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
relation(Users, ({ one }) => ({
|
|
17
|
+
team: one(Teams, {
|
|
18
|
+
local: Users.teamId,
|
|
19
|
+
foreign: Teams.id,
|
|
20
|
+
}),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const builder = Sloppy.createBuilder();
|
|
24
|
+
builder.capabilities.addDatabase("data.main", {
|
|
25
|
+
provider: "sqlite",
|
|
26
|
+
database: "data/app.db",
|
|
27
|
+
access: "readwrite",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const app = builder.build();
|
|
31
|
+
|
|
32
|
+
app.mapGet("/users", () => Results.json([]));
|
|
33
|
+
|
|
34
|
+
export default app;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# ORM Relations and Includes
|
|
2
|
+
|
|
3
|
+
This documentation example focuses on relation metadata and include behavior:
|
|
4
|
+
|
|
5
|
+
- `Users -> team` defaults to a join include.
|
|
6
|
+
- `Teams -> users` defaults to a split-query collection include.
|
|
7
|
+
- Filtered collection includes can use `where(...).take(...)`.
|
|
8
|
+
|
|
9
|
+
The app expects `ctx.db` to be supplied by `TestHost` provider overrides or by a
|
|
10
|
+
runtime provider configured in the Plan.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Sloppy, Results, column, orm, relation, table } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const Teams = table("teams", {
|
|
4
|
+
id: column.uuid().primaryKey(),
|
|
5
|
+
slug: column.text().notNull().unique(),
|
|
6
|
+
name: column.text().notNull(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const Users = table("users", {
|
|
10
|
+
id: column.uuid().primaryKey(),
|
|
11
|
+
teamId: column.uuid().notNull().references(() => Teams.id),
|
|
12
|
+
email: column.text().notNull().unique(),
|
|
13
|
+
displayName: column.text().nullable(),
|
|
14
|
+
deletedAt: column.instant().nullable().softDelete(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
relation(Teams, ({ many }) => ({
|
|
18
|
+
users: many(Users, { local: Teams.id, foreign: Users.teamId }),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
relation(Users, ({ one }) => ({
|
|
22
|
+
team: one(Teams, { local: Users.teamId, foreign: Teams.id }),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const app = Sloppy.create();
|
|
26
|
+
|
|
27
|
+
app.get("/teams/{teamId:uuid}", async (ctx) => {
|
|
28
|
+
const team = await orm
|
|
29
|
+
.from(Teams)
|
|
30
|
+
.where((t) => t.id.eq(ctx.params.teamId))
|
|
31
|
+
.include((t) => t.users.where((u) => u.deletedAt.isNull()).take(100))
|
|
32
|
+
.singleOrDefault(ctx.db);
|
|
33
|
+
|
|
34
|
+
return team === null ? Results.notFound() : Results.json(team);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
app.get("/users/{userId:uuid}", async (ctx) => {
|
|
38
|
+
const user = await orm
|
|
39
|
+
.from(Users)
|
|
40
|
+
.where((u) => u.id.eq(ctx.params.userId))
|
|
41
|
+
.include((u) => u.team)
|
|
42
|
+
.singleOrDefault(ctx.db);
|
|
43
|
+
|
|
44
|
+
return user === null ? Results.notFound() : Results.json(user);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default app;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# ORM TestServices
|
|
2
|
+
|
|
3
|
+
`TestServices.postgres()` and `TestServices.sqlServer()` are opt-in live
|
|
4
|
+
provider helpers for app-host tests. They report `SKIPPED` when the matching
|
|
5
|
+
environment variable or native bridge is unavailable.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { Sloppy, TestHost, TestServices } from "sloppy";
|
|
9
|
+
|
|
10
|
+
const app = Sloppy.create();
|
|
11
|
+
// Register routes that use ctx.db.
|
|
12
|
+
|
|
13
|
+
const pg = await TestServices.postgres({
|
|
14
|
+
migrations: "migrations/postgres/*.sql",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (!pg.available) {
|
|
18
|
+
console.log(pg.status, pg.reason);
|
|
19
|
+
} else {
|
|
20
|
+
const host = await TestHost.create(app, {
|
|
21
|
+
providers: {
|
|
22
|
+
main: pg.provider(),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
try {
|
|
26
|
+
// Run requests and assertions.
|
|
27
|
+
} finally {
|
|
28
|
+
await host.close();
|
|
29
|
+
await pg.close();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The default environment variables are:
|
|
35
|
+
|
|
36
|
+
- `SLOPPY_POSTGRES_TEST_URL`
|
|
37
|
+
- `SLOPPY_SQLSERVER_TEST_CONNECTION_STRING`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Results, Sloppy, TestHost, TestServices, column, orm, table } from "sloppy";
|
|
2
|
+
|
|
3
|
+
const Users = table("users", {
|
|
4
|
+
id: column.uuid().primaryKey(),
|
|
5
|
+
email: column.text().notNull().unique(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const app = Sloppy.create();
|
|
9
|
+
app.mapGet("/users", async (ctx) => {
|
|
10
|
+
const rows = await orm.from(Users).select((u) => ({ id: u.id, email: u.email })).toList(ctx.db);
|
|
11
|
+
return Results.json(rows);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const pg = await TestServices.postgres({
|
|
15
|
+
migrations: "migrations/postgres/*.sql",
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (!pg.available) {
|
|
19
|
+
console.log(`${pg.status}: ${pg.reason}`);
|
|
20
|
+
} else {
|
|
21
|
+
const host = await TestHost.create(app, {
|
|
22
|
+
providers: {
|
|
23
|
+
main: pg.provider(),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
await host.get("/users").expectStatus(200);
|
|
28
|
+
} finally {
|
|
29
|
+
await host.close();
|
|
30
|
+
await pg.close();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# OS Runtime API
|
|
2
|
+
|
|
3
|
+
This source example shows the `sloppy/os` API shape for host information,
|
|
4
|
+
current-process snapshots, redacted environment access, explicit-argv process
|
|
5
|
+
execution, streaming process handles, and shutdown handler registration.
|
|
6
|
+
|
|
7
|
+
## Limitations
|
|
8
|
+
|
|
9
|
+
This example is limited to the Sloppy-owned OS runtime API shape shown in
|
|
10
|
+
source. Shell execution, PTY behavior, daemon supervision, and raw native handle
|
|
11
|
+
access are outside this example.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Environment, Process, Signals, System } from "sloppy/os";
|
|
2
|
+
import { Deadline } from "sloppy/time";
|
|
3
|
+
|
|
4
|
+
export function describeHost() {
|
|
5
|
+
const current = Process.info();
|
|
6
|
+
return {
|
|
7
|
+
platform: System.platform,
|
|
8
|
+
arch: System.arch,
|
|
9
|
+
cpuCount: System.cpuCount,
|
|
10
|
+
tempDirectory: System.tempDirectory,
|
|
11
|
+
setting: Environment.get("MY_APP_SETTING"),
|
|
12
|
+
pid: current.pid,
|
|
13
|
+
cwd: current.cwd,
|
|
14
|
+
argsAvailable: current.argsAvailable
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function gitStatus(repo) {
|
|
19
|
+
return Process.run("git", ["status", "--short"], {
|
|
20
|
+
cwd: repo,
|
|
21
|
+
timeoutMs: 5000,
|
|
22
|
+
capture: "text"
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function probeProcess(command, args) {
|
|
27
|
+
const proc = await Process.start(command, args, {
|
|
28
|
+
stdout: "pipe",
|
|
29
|
+
stderr: "pipe",
|
|
30
|
+
deadline: Deadline.after(5000)
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const lines = [];
|
|
34
|
+
for await (const line of proc.stdout.readLines()) {
|
|
35
|
+
lines.push(line);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const exit = await proc.wait();
|
|
39
|
+
return { exit, lines };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Signals.onShutdown(async (ctx) => {
|
|
43
|
+
await Promise.resolve({ signal: ctx.signal, forced: ctx.forced });
|
|
44
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Package: zod-like
|
|
2
|
+
|
|
3
|
+
This example uses a local fixture package to demonstrate Sloppy's installed
|
|
4
|
+
package graph. It does not require internet access.
|
|
5
|
+
|
|
6
|
+
The fixture package is intentionally small and zod-shaped: it exports a
|
|
7
|
+
validator factory with `string()`, `number()`, and `object(...)` helpers. It is
|
|
8
|
+
not the real Zod package.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install
|
|
14
|
+
sloppy build
|
|
15
|
+
sloppy deps .sloppy
|
|
16
|
+
sloppy run -- Ada
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`npm install` installs `fixtures/zod-like` through a local `file:` dependency.
|
|
20
|
+
Real installed packages work when their JavaScript and runtime API usage are
|
|
21
|
+
compatible with Sloppy's loader and Node compatibility shims.
|
|
22
|
+
|
|
23
|
+
## What It Covers
|
|
24
|
+
|
|
25
|
+
- installed package resolution from `node_modules`;
|
|
26
|
+
- package.json `exports`;
|
|
27
|
+
- ESM package import from Program Mode;
|
|
28
|
+
- dependency graph inspection with `sloppy deps`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function issue(message) {
|
|
2
|
+
const error = new Error(message);
|
|
3
|
+
error.name = "ZodLikeError";
|
|
4
|
+
return error;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function string() {
|
|
8
|
+
return {
|
|
9
|
+
parse(value) {
|
|
10
|
+
if (typeof value !== "string") {
|
|
11
|
+
throw issue("expected string");
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function number() {
|
|
19
|
+
return {
|
|
20
|
+
parse(value) {
|
|
21
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
22
|
+
throw issue("expected number");
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function object(shape) {
|
|
30
|
+
return {
|
|
31
|
+
parse(value) {
|
|
32
|
+
if (value === null || typeof value !== "object") {
|
|
33
|
+
throw issue("expected object");
|
|
34
|
+
}
|
|
35
|
+
const result = {};
|
|
36
|
+
for (const key of Object.keys(shape)) {
|
|
37
|
+
result[key] = shape[key].parse(value[key]);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const z = Object.freeze({
|
|
45
|
+
string,
|
|
46
|
+
number,
|
|
47
|
+
object
|
|
48
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod-like";
|
|
2
|
+
|
|
3
|
+
const userSchema = z.object({
|
|
4
|
+
name: z.string(),
|
|
5
|
+
score: z.number()
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export function main(args) {
|
|
9
|
+
const user = userSchema.parse({
|
|
10
|
+
name: args[0] ?? "Ada",
|
|
11
|
+
score: Number(args[1] ?? 42)
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
console.log(`validated ${user.name} score=${user.score}`);
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# PostgreSQL Basic Example
|
|
2
|
+
|
|
3
|
+
This is an API-shape example for the PostgreSQL provider.
|
|
4
|
+
|
|
5
|
+
It shows the intended module/capability/service registration shape, PostgreSQL `$1`
|
|
6
|
+
query-template lowering, a simple bounded pool option, and transaction usage.
|
|
7
|
+
|
|
8
|
+
Current limitations:
|
|
9
|
+
|
|
10
|
+
- this example requires PostgreSQL, PostgreSQL client support, and a connection
|
|
11
|
+
string such as `SLOPPY_POSTGRES_TEST_URL`;
|
|
12
|
+
- normal Sloppy apps, the Quickstart, SQLite, templates, and package support do
|
|
13
|
+
not require PostgreSQL or libpq;
|
|
14
|
+
- not part of default CI live database execution;
|
|
15
|
+
- the V8 bridge uses nonblocking libpq socket readiness and a bounded connection pool;
|
|
16
|
+
- parameterized exec/query/queryOne and callback transactions are supported through the
|
|
17
|
+
stdlib bridge when the Plan enables `provider.postgres`;
|
|
18
|
+
- no migrations;
|
|
19
|
+
- no ORM;
|
|
20
|
+
- TLS option hardening and advanced operational pooling policy remain separate provider
|
|
21
|
+
hardening work.
|
|
22
|
+
|
|
23
|
+
Native live provider tests are opt-in:
|
|
24
|
+
|
|
25
|
+
```powershell
|
|
26
|
+
$env:SLOPPY_POSTGRES_TEST_URL="<redacted PostgreSQL connection string>"
|
|
27
|
+
.\tools\windows\test-live-postgres.ps1
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Do not paste credentials into PR bodies or diagnostics. Connection strings must be redacted
|
|
31
|
+
before reporting.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Sloppy, data, sql } from "sloppy";
|
|
2
|
+
import { Environment } from "sloppy/os";
|
|
3
|
+
|
|
4
|
+
function requireEnvironment(name) {
|
|
5
|
+
const value = Environment.get(name);
|
|
6
|
+
if (value === undefined || value === "") {
|
|
7
|
+
throw new Error(`Missing required environment value: ${name}`);
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const PostgresModule = Sloppy.module("data.postgres")
|
|
13
|
+
.capabilities((caps) => {
|
|
14
|
+
caps.addDatabase("data.main", {
|
|
15
|
+
provider: "postgres",
|
|
16
|
+
configKey: "SLOPPY_POSTGRES_TEST_URL",
|
|
17
|
+
access: "readwrite",
|
|
18
|
+
});
|
|
19
|
+
})
|
|
20
|
+
.services((services) => {
|
|
21
|
+
services.addSingleton("data.main", () => data.postgres.open({
|
|
22
|
+
connectionString: requireEnvironment("SLOPPY_POSTGRES_TEST_URL"),
|
|
23
|
+
maxConnections: 2,
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const app = Sloppy.createBuilder()
|
|
28
|
+
.addModule(PostgresModule)
|
|
29
|
+
.build();
|
|
30
|
+
|
|
31
|
+
const lowered = sql.lower(["select id, name from users where name = ", ""], ["Ada"], {
|
|
32
|
+
placeholderStyle: data.postgres.placeholderStyle,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
async function insertUser(db, name) {
|
|
36
|
+
return db.queryOne`
|
|
37
|
+
insert into users (name)
|
|
38
|
+
values (${name})
|
|
39
|
+
returning id, name
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function renameUser(db, id, name) {
|
|
44
|
+
return db.transaction(async (tx) => {
|
|
45
|
+
await tx.exec`update users set name = ${name} where id = ${id}`;
|
|
46
|
+
return tx.queryOne`select id, name from users where id = ${id}`;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { app, insertUser, lowered, renameUser };
|