semola 0.5.1 → 0.5.3
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 +144 -29
- package/dist/api/core/index.cjs +206 -0
- package/dist/api/core/index.d.cts +21 -0
- package/dist/api/core/index.d.cts.map +1 -0
- package/dist/api/core/index.d.mts +21 -0
- package/dist/api/core/index.d.mts.map +1 -0
- package/dist/api/core/index.mjs +208 -0
- package/dist/api/core/index.mjs.map +1 -0
- package/dist/api/core/types.d.cts +107 -0
- package/dist/api/core/types.d.cts.map +1 -0
- package/dist/api/core/types.d.mts +107 -0
- package/dist/api/core/types.d.mts.map +1 -0
- package/dist/api/middleware/index.cjs +8 -0
- package/dist/api/middleware/index.d.cts +11 -0
- package/dist/api/middleware/index.d.cts.map +1 -0
- package/dist/api/middleware/index.d.mts +11 -0
- package/dist/api/middleware/index.d.mts.map +1 -0
- package/dist/api/middleware/index.mjs +10 -0
- package/dist/api/middleware/index.mjs.map +1 -0
- package/dist/api/middleware/types.d.cts +16 -0
- package/dist/api/middleware/types.d.cts.map +1 -0
- package/dist/api/middleware/types.d.mts +16 -0
- package/dist/api/middleware/types.d.mts.map +1 -0
- package/dist/api/openapi/index.cjs +254 -0
- package/dist/api/openapi/index.mjs +256 -0
- package/dist/api/openapi/index.mjs.map +1 -0
- package/dist/api/openapi/types.d.cts +60 -0
- package/dist/api/openapi/types.d.cts.map +1 -0
- package/dist/api/openapi/types.d.mts +60 -0
- package/dist/api/openapi/types.d.mts.map +1 -0
- package/dist/api/validation/index.cjs +64 -0
- package/dist/api/validation/index.mjs +61 -0
- package/dist/api/validation/index.mjs.map +1 -0
- package/dist/cache/types.d.cts +17 -0
- package/dist/cache/types.d.cts.map +1 -0
- package/dist/cache/types.d.mts +17 -0
- package/dist/cache/types.d.mts.map +1 -0
- package/dist/cron/builder/index.cjs +166 -0
- package/dist/cron/builder/index.d.cts +28 -0
- package/dist/cron/builder/index.d.cts.map +1 -0
- package/dist/cron/builder/index.d.mts +28 -0
- package/dist/cron/builder/index.d.mts.map +1 -0
- package/dist/cron/builder/index.mjs +163 -0
- package/dist/cron/builder/index.mjs.map +1 -0
- package/dist/cron/builder/types.cjs +27 -0
- package/dist/cron/builder/types.d.cts +79 -0
- package/dist/cron/builder/types.d.cts.map +1 -0
- package/dist/cron/builder/types.d.mts +79 -0
- package/dist/cron/builder/types.d.mts.map +1 -0
- package/dist/cron/builder/types.mjs +28 -0
- package/dist/cron/builder/types.mjs.map +1 -0
- package/dist/cron/core/index.cjs +308 -0
- package/dist/cron/core/index.d.cts +39 -0
- package/dist/cron/core/index.d.cts.map +1 -0
- package/dist/cron/core/index.d.mts +39 -0
- package/dist/cron/core/index.d.mts.map +1 -0
- package/dist/cron/core/index.mjs +310 -0
- package/dist/cron/core/index.mjs.map +1 -0
- package/dist/cron/core/scanner.cjs +237 -0
- package/dist/cron/core/scanner.mjs +238 -0
- package/dist/cron/core/scanner.mjs.map +1 -0
- package/dist/cron/core/types.d.cts +11 -0
- package/dist/cron/core/types.d.cts.map +1 -0
- package/dist/cron/core/types.d.mts +11 -0
- package/dist/cron/core/types.d.mts.map +1 -0
- package/dist/errors/types.d.cts +5 -0
- package/dist/errors/types.d.cts.map +1 -0
- package/dist/errors/types.d.mts +5 -0
- package/dist/errors/types.d.mts.map +1 -0
- package/dist/i18n/types.d.cts +13 -0
- package/dist/i18n/types.d.cts.map +1 -0
- package/dist/i18n/types.d.mts +13 -0
- package/dist/i18n/types.d.mts.map +1 -0
- package/dist/lib/api/index.cjs +5 -0
- package/dist/lib/api/index.d.cts +5 -0
- package/dist/lib/api/index.d.mts +5 -0
- package/dist/lib/api/index.mjs +3 -0
- package/dist/lib/cache/index.cjs +74 -0
- package/dist/lib/cache/index.d.cts +36 -0
- package/dist/lib/cache/index.d.cts.map +1 -0
- package/dist/lib/cache/index.d.mts +36 -0
- package/dist/lib/cache/index.d.mts.map +1 -0
- package/dist/lib/cache/index.mjs +75 -0
- package/dist/lib/cache/index.mjs.map +1 -0
- package/dist/lib/cron/index.cjs +13 -0
- package/dist/lib/cron/index.d.cts +4 -0
- package/dist/lib/cron/index.d.mts +4 -0
- package/dist/lib/cron/index.mjs +4 -0
- package/dist/lib/errors/index.cjs +30 -0
- package/dist/lib/errors/index.d.cts +13 -0
- package/dist/lib/errors/index.d.cts.map +1 -0
- package/dist/lib/errors/index.d.mts +13 -0
- package/dist/lib/errors/index.d.mts.map +1 -0
- package/dist/lib/errors/index.mjs +28 -0
- package/dist/lib/errors/index.mjs.map +1 -0
- package/dist/lib/i18n/index.cjs +42 -0
- package/dist/lib/i18n/index.d.cts +20 -0
- package/dist/lib/i18n/index.d.cts.map +1 -0
- package/dist/lib/i18n/index.d.mts +20 -0
- package/dist/lib/i18n/index.d.mts.map +1 -0
- package/dist/lib/i18n/index.mjs +43 -0
- package/dist/lib/i18n/index.mjs.map +1 -0
- package/dist/lib/logging/index.cjs +18 -0
- package/dist/lib/logging/index.d.cts +7 -0
- package/dist/lib/logging/index.d.mts +7 -0
- package/dist/lib/logging/index.mjs +5 -0
- package/dist/lib/orm/index.cjs +20 -0
- package/dist/lib/orm/index.d.cts +7 -0
- package/dist/lib/orm/index.d.mts +7 -0
- package/dist/lib/orm/index.mjs +6 -0
- package/dist/lib/policy/index.cjs +99 -0
- package/dist/lib/policy/index.d.cts +21 -0
- package/dist/lib/policy/index.d.cts.map +1 -0
- package/dist/lib/policy/index.d.mts +21 -0
- package/dist/lib/policy/index.d.mts.map +1 -0
- package/dist/lib/policy/index.mjs +81 -0
- package/dist/lib/policy/index.mjs.map +1 -0
- package/dist/lib/prompts/index.cjs +409 -0
- package/dist/lib/prompts/index.d.cts +31 -0
- package/dist/lib/prompts/index.d.cts.map +1 -0
- package/dist/lib/prompts/index.d.mts +31 -0
- package/dist/lib/prompts/index.d.mts.map +1 -0
- package/dist/lib/prompts/index.mjs +405 -0
- package/dist/lib/prompts/index.mjs.map +1 -0
- package/dist/lib/pubsub/index.cjs +117 -0
- package/dist/lib/pubsub/index.d.cts +36 -0
- package/dist/lib/pubsub/index.d.cts.map +1 -0
- package/dist/lib/pubsub/index.d.mts +36 -0
- package/dist/lib/pubsub/index.d.mts.map +1 -0
- package/dist/lib/pubsub/index.mjs +118 -0
- package/dist/lib/pubsub/index.mjs.map +1 -0
- package/dist/lib/queue/index.cjs +182 -0
- package/dist/lib/queue/index.d.cts +32 -0
- package/dist/lib/queue/index.d.cts.map +1 -0
- package/dist/lib/queue/index.d.mts +32 -0
- package/dist/lib/queue/index.d.mts.map +1 -0
- package/dist/lib/queue/index.mjs +183 -0
- package/dist/lib/queue/index.mjs.map +1 -0
- package/dist/lib/workflow/index.cjs +534 -0
- package/dist/lib/workflow/index.d.cts +7 -0
- package/dist/lib/workflow/index.d.cts.map +1 -0
- package/dist/lib/workflow/index.d.mts +7 -0
- package/dist/lib/workflow/index.d.mts.map +1 -0
- package/dist/lib/workflow/index.mjs +535 -0
- package/dist/lib/workflow/index.mjs.map +1 -0
- package/dist/logging/core/index.cjs +99 -0
- package/dist/logging/core/index.d.cts +26 -0
- package/dist/logging/core/index.d.cts.map +1 -0
- package/dist/logging/core/index.d.mts +26 -0
- package/dist/logging/core/index.d.mts.map +1 -0
- package/dist/logging/core/index.mjs +99 -0
- package/dist/logging/core/index.mjs.map +1 -0
- package/dist/logging/core/types.cjs +10 -0
- package/dist/logging/core/types.d.cts +22 -0
- package/dist/logging/core/types.d.cts.map +1 -0
- package/dist/logging/core/types.d.mts +22 -0
- package/dist/logging/core/types.d.mts.map +1 -0
- package/dist/logging/core/types.mjs +12 -0
- package/dist/logging/core/types.mjs.map +1 -0
- package/dist/logging/formatter/index.cjs +119 -0
- package/dist/logging/formatter/index.d.cts +27 -0
- package/dist/logging/formatter/index.d.cts.map +1 -0
- package/dist/logging/formatter/index.d.mts +27 -0
- package/dist/logging/formatter/index.d.mts.map +1 -0
- package/dist/logging/formatter/index.mjs +115 -0
- package/dist/logging/formatter/index.mjs.map +1 -0
- package/dist/logging/formatter/types.d.cts +5 -0
- package/dist/logging/formatter/types.d.cts.map +1 -0
- package/dist/logging/formatter/types.d.mts +5 -0
- package/dist/logging/formatter/types.d.mts.map +1 -0
- package/dist/logging/provider/index.cjs +165 -0
- package/dist/logging/provider/index.d.cts +28 -0
- package/dist/logging/provider/index.d.cts.map +1 -0
- package/dist/logging/provider/index.d.mts +28 -0
- package/dist/logging/provider/index.d.mts.map +1 -0
- package/dist/logging/provider/index.mjs +165 -0
- package/dist/logging/provider/index.mjs.map +1 -0
- package/dist/logging/provider/types.d.cts +23 -0
- package/dist/logging/provider/types.d.cts.map +1 -0
- package/dist/logging/provider/types.d.mts +23 -0
- package/dist/logging/provider/types.d.mts.map +1 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +80 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +1 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +80 -0
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +1 -0
- package/dist/orm/column.cjs +137 -0
- package/dist/orm/column.d.cts +121 -0
- package/dist/orm/column.d.cts.map +1 -0
- package/dist/orm/column.d.mts +121 -0
- package/dist/orm/column.d.mts.map +1 -0
- package/dist/orm/column.mjs +132 -0
- package/dist/orm/column.mjs.map +1 -0
- package/dist/orm/dialect/index.cjs +14 -0
- package/dist/orm/dialect/index.mjs +16 -0
- package/dist/orm/dialect/index.mjs.map +1 -0
- package/dist/orm/dialect/mysql.cjs +31 -0
- package/dist/orm/dialect/mysql.mjs +33 -0
- package/dist/orm/dialect/mysql.mjs.map +1 -0
- package/dist/orm/dialect/postgres.cjs +23 -0
- package/dist/orm/dialect/postgres.mjs +25 -0
- package/dist/orm/dialect/postgres.mjs.map +1 -0
- package/dist/orm/dialect/sqlite.cjs +31 -0
- package/dist/orm/dialect/sqlite.mjs +33 -0
- package/dist/orm/dialect/sqlite.mjs.map +1 -0
- package/dist/orm/dialect/utils.cjs +8 -0
- package/dist/orm/dialect/utils.mjs +10 -0
- package/dist/orm/dialect/utils.mjs.map +1 -0
- package/dist/orm/internal/table-columns.cjs +31 -0
- package/dist/orm/internal/table-columns.mjs +32 -0
- package/dist/orm/internal/table-columns.mjs.map +1 -0
- package/dist/orm/internal/table-lookup.cjs +35 -0
- package/dist/orm/internal/table-lookup.mjs +35 -0
- package/dist/orm/internal/table-lookup.mjs.map +1 -0
- package/dist/orm/internal/table-relations.cjs +28 -0
- package/dist/orm/internal/table-relations.mjs +29 -0
- package/dist/orm/internal/table-relations.mjs.map +1 -0
- package/dist/orm/migration/config.cjs +7 -0
- package/dist/orm/migration/config.d.cts +7 -0
- package/dist/orm/migration/config.d.cts.map +1 -0
- package/dist/orm/migration/config.d.mts +7 -0
- package/dist/orm/migration/config.d.mts.map +1 -0
- package/dist/orm/migration/config.mjs +8 -0
- package/dist/orm/migration/config.mjs.map +1 -0
- package/dist/orm/migration/types.d.cts +20 -0
- package/dist/orm/migration/types.d.cts.map +1 -0
- package/dist/orm/migration/types.d.mts +20 -0
- package/dist/orm/migration/types.d.mts.map +1 -0
- package/dist/orm/orm.cjs +41 -0
- package/dist/orm/orm.d.cts +18 -0
- package/dist/orm/orm.d.cts.map +1 -0
- package/dist/orm/orm.d.mts +18 -0
- package/dist/orm/orm.d.mts.map +1 -0
- package/dist/orm/orm.mjs +43 -0
- package/dist/orm/orm.mjs.map +1 -0
- package/dist/orm/relation.cjs +18 -0
- package/dist/orm/relation.d.cts +8 -0
- package/dist/orm/relation.d.cts.map +1 -0
- package/dist/orm/relation.d.mts +8 -0
- package/dist/orm/relation.d.mts.map +1 -0
- package/dist/orm/relation.mjs +19 -0
- package/dist/orm/relation.mjs.map +1 -0
- package/dist/orm/runtime/builders/mutations.cjs +29 -0
- package/dist/orm/runtime/builders/mutations.mjs +28 -0
- package/dist/orm/runtime/builders/mutations.mjs.map +1 -0
- package/dist/orm/runtime/builders/select.cjs +18 -0
- package/dist/orm/runtime/builders/select.mjs +19 -0
- package/dist/orm/runtime/builders/select.mjs.map +1 -0
- package/dist/orm/runtime/client.cjs +90 -0
- package/dist/orm/runtime/client.mjs +92 -0
- package/dist/orm/runtime/client.mjs.map +1 -0
- package/dist/orm/runtime/context.cjs +49 -0
- package/dist/orm/runtime/context.mjs +51 -0
- package/dist/orm/runtime/context.mjs.map +1 -0
- package/dist/orm/runtime/dialect/index.cjs +11 -0
- package/dist/orm/runtime/dialect/index.mjs +13 -0
- package/dist/orm/runtime/dialect/index.mjs.map +1 -0
- package/dist/orm/runtime/dialect/mysql.cjs +95 -0
- package/dist/orm/runtime/dialect/mysql.mjs +97 -0
- package/dist/orm/runtime/dialect/mysql.mjs.map +1 -0
- package/dist/orm/runtime/dialect/postgres.cjs +51 -0
- package/dist/orm/runtime/dialect/postgres.mjs +53 -0
- package/dist/orm/runtime/dialect/postgres.mjs.map +1 -0
- package/dist/orm/runtime/dialect/sqlite.cjs +4 -0
- package/dist/orm/runtime/dialect/sqlite.mjs +7 -0
- package/dist/orm/runtime/dialect/sqlite.mjs.map +1 -0
- package/dist/orm/runtime/errors.cjs +19 -0
- package/dist/orm/runtime/errors.mjs +21 -0
- package/dist/orm/runtime/errors.mjs.map +1 -0
- package/dist/orm/runtime/hydrate/many.cjs +46 -0
- package/dist/orm/runtime/hydrate/many.mjs +48 -0
- package/dist/orm/runtime/hydrate/many.mjs.map +1 -0
- package/dist/orm/runtime/hydrate/one.cjs +38 -0
- package/dist/orm/runtime/hydrate/one.mjs +40 -0
- package/dist/orm/runtime/hydrate/one.mjs.map +1 -0
- package/dist/orm/runtime/hydrate.cjs +49 -0
- package/dist/orm/runtime/hydrate.mjs +51 -0
- package/dist/orm/runtime/hydrate.mjs.map +1 -0
- package/dist/orm/runtime/rows.cjs +30 -0
- package/dist/orm/runtime/rows.mjs +31 -0
- package/dist/orm/runtime/rows.mjs.map +1 -0
- package/dist/orm/runtime/utils.cjs +27 -0
- package/dist/orm/runtime/utils.mjs +27 -0
- package/dist/orm/runtime/utils.mjs.map +1 -0
- package/dist/orm/sql/parse-array.cjs +64 -0
- package/dist/orm/sql/parse-array.mjs +66 -0
- package/dist/orm/sql/parse-array.mjs.map +1 -0
- package/dist/orm/sql/plan/select.cjs +36 -0
- package/dist/orm/sql/plan/select.mjs +38 -0
- package/dist/orm/sql/plan/select.mjs.map +1 -0
- package/dist/orm/sql/plan/where/operators.cjs +95 -0
- package/dist/orm/sql/plan/where/operators.mjs +97 -0
- package/dist/orm/sql/plan/where/operators.mjs.map +1 -0
- package/dist/orm/sql/plan/where.cjs +59 -0
- package/dist/orm/sql/plan/where.mjs +61 -0
- package/dist/orm/sql/plan/where.mjs.map +1 -0
- package/dist/orm/sql/serialize/clauses.cjs +36 -0
- package/dist/orm/sql/serialize/clauses.mjs +37 -0
- package/dist/orm/sql/serialize/clauses.mjs.map +1 -0
- package/dist/orm/sql/serialize/joins.cjs +31 -0
- package/dist/orm/sql/serialize/joins.mjs +33 -0
- package/dist/orm/sql/serialize/joins.mjs.map +1 -0
- package/dist/orm/sql/serialize/values.cjs +30 -0
- package/dist/orm/sql/serialize/values.mjs +32 -0
- package/dist/orm/sql/serialize/values.mjs.map +1 -0
- package/dist/orm/sql/serialize/where/predicate.cjs +73 -0
- package/dist/orm/sql/serialize/where/predicate.mjs +75 -0
- package/dist/orm/sql/serialize/where/predicate.mjs.map +1 -0
- package/dist/orm/sql/serialize/where/tree.cjs +26 -0
- package/dist/orm/sql/serialize/where/tree.mjs +28 -0
- package/dist/orm/sql/serialize/where/tree.mjs.map +1 -0
- package/dist/orm/sql/serialize/where.cjs +10 -0
- package/dist/orm/sql/serialize/where.mjs +12 -0
- package/dist/orm/sql/serialize/where.mjs.map +1 -0
- package/dist/orm/sql/serialize.cjs +24 -0
- package/dist/orm/sql/serialize.mjs +25 -0
- package/dist/orm/sql/serialize.mjs.map +1 -0
- package/dist/orm/table.cjs +12 -0
- package/dist/orm/table.d.cts +12 -0
- package/dist/orm/table.d.cts.map +1 -0
- package/dist/orm/table.d.mts +12 -0
- package/dist/orm/table.d.mts.map +1 -0
- package/dist/orm/table.mjs +14 -0
- package/dist/orm/table.mjs.map +1 -0
- package/dist/orm/types.d.cts +183 -0
- package/dist/orm/types.d.cts.map +1 -0
- package/dist/orm/types.d.mts +183 -0
- package/dist/orm/types.d.mts.map +1 -0
- package/dist/policy/helpers.cjs +206 -0
- package/dist/policy/helpers.d.cts +50 -0
- package/dist/policy/helpers.d.cts.map +1 -0
- package/dist/policy/helpers.d.mts +50 -0
- package/dist/policy/helpers.d.mts.map +1 -0
- package/dist/policy/helpers.mjs +190 -0
- package/dist/policy/helpers.mjs.map +1 -0
- package/dist/policy/types.d.cts +16 -0
- package/dist/policy/types.d.cts.map +1 -0
- package/dist/policy/types.d.mts +16 -0
- package/dist/policy/types.d.mts.map +1 -0
- package/dist/prompts/core/keys.cjs +165 -0
- package/dist/prompts/core/keys.mjs +167 -0
- package/dist/prompts/core/keys.mjs.map +1 -0
- package/dist/prompts/core/runtime.cjs +104 -0
- package/dist/prompts/core/runtime.mjs +106 -0
- package/dist/prompts/core/runtime.mjs.map +1 -0
- package/dist/prompts/core/session.cjs +98 -0
- package/dist/prompts/core/session.mjs +100 -0
- package/dist/prompts/core/session.mjs.map +1 -0
- package/dist/prompts/core/types.d.cts +21 -0
- package/dist/prompts/core/types.d.cts.map +1 -0
- package/dist/prompts/core/types.d.mts +21 -0
- package/dist/prompts/core/types.d.mts.map +1 -0
- package/dist/prompts/types.d.cts +52 -0
- package/dist/prompts/types.d.cts.map +1 -0
- package/dist/prompts/types.d.mts +52 -0
- package/dist/prompts/types.d.mts.map +1 -0
- package/dist/pubsub/types.d.cts +10 -0
- package/dist/pubsub/types.d.cts.map +1 -0
- package/dist/pubsub/types.d.mts +10 -0
- package/dist/pubsub/types.d.mts.map +1 -0
- package/dist/queue/types.d.cts +47 -0
- package/dist/queue/types.d.cts.map +1 -0
- package/dist/queue/types.d.mts +47 -0
- package/dist/queue/types.d.mts.map +1 -0
- package/dist/workflow/types.d.cts +83 -0
- package/dist/workflow/types.d.cts.map +1 -0
- package/dist/workflow/types.d.mts +83 -0
- package/dist/workflow/types.d.mts.map +1 -0
- package/package.json +112 -16
- package/dist/lib/api/core/index.d.ts +0 -15
- package/dist/lib/api/core/index.d.ts.map +0 -1
- package/dist/lib/api/core/index.js +0 -218
- package/dist/lib/api/core/index.js.map +0 -1
- package/dist/lib/api/core/index.test.d.ts +0 -2
- package/dist/lib/api/core/index.test.d.ts.map +0 -1
- package/dist/lib/api/core/index.test.js +0 -219
- package/dist/lib/api/core/index.test.js.map +0 -1
- package/dist/lib/api/core/types.d.ts +0 -109
- package/dist/lib/api/core/types.d.ts.map +0 -1
- package/dist/lib/api/core/types.js +0 -2
- package/dist/lib/api/core/types.js.map +0 -1
- package/dist/lib/api/index.d.ts +0 -5
- package/dist/lib/api/index.d.ts.map +0 -1
- package/dist/lib/api/index.js +0 -3
- package/dist/lib/api/index.js.map +0 -1
- package/dist/lib/api/middleware/index.d.ts +0 -7
- package/dist/lib/api/middleware/index.d.ts.map +0 -1
- package/dist/lib/api/middleware/index.js +0 -7
- package/dist/lib/api/middleware/index.js.map +0 -1
- package/dist/lib/api/middleware/index.test.d.ts +0 -2
- package/dist/lib/api/middleware/index.test.d.ts.map +0 -1
- package/dist/lib/api/middleware/index.test.js +0 -67
- package/dist/lib/api/middleware/index.test.js.map +0 -1
- package/dist/lib/api/middleware/types.d.ts +0 -12
- package/dist/lib/api/middleware/types.d.ts.map +0 -1
- package/dist/lib/api/middleware/types.js +0 -2
- package/dist/lib/api/middleware/types.js.map +0 -1
- package/dist/lib/api/openapi/index.d.ts +0 -31
- package/dist/lib/api/openapi/index.d.ts.map +0 -1
- package/dist/lib/api/openapi/index.js +0 -284
- package/dist/lib/api/openapi/index.js.map +0 -1
- package/dist/lib/api/openapi/index.test.d.ts +0 -2
- package/dist/lib/api/openapi/index.test.d.ts.map +0 -1
- package/dist/lib/api/openapi/index.test.js +0 -359
- package/dist/lib/api/openapi/index.test.js.map +0 -1
- package/dist/lib/api/openapi/types.d.ts +0 -57
- package/dist/lib/api/openapi/types.d.ts.map +0 -1
- package/dist/lib/api/openapi/types.js +0 -5
- package/dist/lib/api/openapi/types.js.map +0 -1
- package/dist/lib/api/validation/index.d.ts +0 -33
- package/dist/lib/api/validation/index.d.ts.map +0 -1
- package/dist/lib/api/validation/index.js +0 -92
- package/dist/lib/api/validation/index.js.map +0 -1
- package/dist/lib/api/validation/index.test.d.ts +0 -2
- package/dist/lib/api/validation/index.test.d.ts.map +0 -1
- package/dist/lib/api/validation/index.test.js +0 -135
- package/dist/lib/api/validation/index.test.js.map +0 -1
- package/dist/lib/cache/index.d.ts +0 -25
- package/dist/lib/cache/index.d.ts.map +0 -1
- package/dist/lib/cache/index.js +0 -62
- package/dist/lib/cache/index.js.map +0 -1
- package/dist/lib/cache/index.test.d.ts +0 -2
- package/dist/lib/cache/index.test.d.ts.map +0 -1
- package/dist/lib/cache/index.test.js +0 -314
- package/dist/lib/cache/index.test.js.map +0 -1
- package/dist/lib/cache/types.d.ts +0 -5
- package/dist/lib/cache/types.d.ts.map +0 -1
- package/dist/lib/cache/types.js +0 -2
- package/dist/lib/cache/types.js.map +0 -1
- package/dist/lib/errors/index.d.ts +0 -9
- package/dist/lib/errors/index.d.ts.map +0 -1
- package/dist/lib/errors/index.js +0 -25
- package/dist/lib/errors/index.js.map +0 -1
- package/dist/lib/errors/index.test.d.ts +0 -2
- package/dist/lib/errors/index.test.d.ts.map +0 -1
- package/dist/lib/errors/index.test.js +0 -197
- package/dist/lib/errors/index.test.js.map +0 -1
- package/dist/lib/errors/types.d.ts +0 -2
- package/dist/lib/errors/types.d.ts.map +0 -1
- package/dist/lib/errors/types.js +0 -2
- package/dist/lib/errors/types.js.map +0 -1
- package/dist/lib/i18n/index.d.ts +0 -18
- package/dist/lib/i18n/index.d.ts.map +0 -1
- package/dist/lib/i18n/index.js +0 -38
- package/dist/lib/i18n/index.js.map +0 -1
- package/dist/lib/i18n/index.test.d.ts +0 -2
- package/dist/lib/i18n/index.test.d.ts.map +0 -1
- package/dist/lib/i18n/index.test.js +0 -402
- package/dist/lib/i18n/index.test.js.map +0 -1
- package/dist/lib/i18n/types.d.ts +0 -15
- package/dist/lib/i18n/types.d.ts.map +0 -1
- package/dist/lib/i18n/types.js +0 -2
- package/dist/lib/i18n/types.js.map +0 -1
- package/dist/lib/policy/index.d.ts +0 -9
- package/dist/lib/policy/index.d.ts.map +0 -1
- package/dist/lib/policy/index.js +0 -51
- package/dist/lib/policy/index.js.map +0 -1
- package/dist/lib/policy/index.test.d.ts +0 -2
- package/dist/lib/policy/index.test.d.ts.map +0 -1
- package/dist/lib/policy/index.test.js +0 -328
- package/dist/lib/policy/index.test.js.map +0 -1
- package/dist/lib/policy/types.d.ts +0 -27
- package/dist/lib/policy/types.d.ts.map +0 -1
- package/dist/lib/policy/types.js +0 -2
- package/dist/lib/policy/types.js.map +0 -1
- package/dist/lib/pubsub/index.d.ts +0 -23
- package/dist/lib/pubsub/index.d.ts.map +0 -1
- package/dist/lib/pubsub/index.js +0 -55
- package/dist/lib/pubsub/index.js.map +0 -1
- package/dist/lib/pubsub/index.test.d.ts +0 -2
- package/dist/lib/pubsub/index.test.d.ts.map +0 -1
- package/dist/lib/pubsub/index.test.js +0 -550
- package/dist/lib/pubsub/index.test.js.map +0 -1
- package/dist/lib/pubsub/types.d.ts +0 -7
- package/dist/lib/pubsub/types.d.ts.map +0 -1
- package/dist/lib/pubsub/types.js +0 -2
- package/dist/lib/pubsub/types.js.map +0 -1
- package/dist/lib/queue/index.d.ts +0 -28
- package/dist/lib/queue/index.d.ts.map +0 -1
- package/dist/lib/queue/index.js +0 -211
- package/dist/lib/queue/index.js.map +0 -1
- package/dist/lib/queue/index.test.d.ts +0 -2
- package/dist/lib/queue/index.test.d.ts.map +0 -1
- package/dist/lib/queue/index.test.js +0 -740
- package/dist/lib/queue/index.test.js.map +0 -1
- package/dist/lib/queue/types.d.ts +0 -52
- package/dist/lib/queue/types.d.ts.map +0 -1
- package/dist/lib/queue/types.js +0 -2
- package/dist/lib/queue/types.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parsePostgresArrayLiteral } from "../sql/parse-array.mjs";
|
|
2
|
+
//#region src/lib/orm/runtime/rows.ts
|
|
3
|
+
function normalizeRecordForTable(table, row) {
|
|
4
|
+
let normalized = null;
|
|
5
|
+
for (const jsKey in table.columns) {
|
|
6
|
+
const col = table.columns[jsKey];
|
|
7
|
+
if (!col) continue;
|
|
8
|
+
if (!col.meta.isSqlArray) continue;
|
|
9
|
+
const value = Reflect.get(row, jsKey);
|
|
10
|
+
if (Array.isArray(value)) continue;
|
|
11
|
+
if (typeof value !== "string") continue;
|
|
12
|
+
const parsed = parsePostgresArrayLiteral(value);
|
|
13
|
+
if (!parsed) continue;
|
|
14
|
+
if (!normalized) normalized = { ...row };
|
|
15
|
+
normalized[jsKey] = parsed;
|
|
16
|
+
}
|
|
17
|
+
if (!normalized) return row;
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|
|
20
|
+
function normalizeRows(dialect, table, rows) {
|
|
21
|
+
if (dialect !== "postgres") return rows;
|
|
22
|
+
return rows.map((row) => normalizeRecordForTable(table, row));
|
|
23
|
+
}
|
|
24
|
+
function normalizeRowsForTable(dialect, table, rows) {
|
|
25
|
+
if (dialect !== "postgres") return rows;
|
|
26
|
+
return rows.map((row) => normalizeRecordForTable(table, row));
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { normalizeRows, normalizeRowsForTable };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=rows.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rows.mjs","names":[],"sources":["../../../src/lib/orm/runtime/rows.ts"],"sourcesContent":["import { parsePostgresArrayLiteral } from \"../sql/parse-array.js\";\nimport type { Table } from \"../table.js\";\nimport type { ColDefs, Dialect, TableRow } from \"../types.js\";\n\nfunction normalizeRecordForTable<T extends ColDefs>(\n table: Table<T>,\n row: Record<string, unknown>,\n) {\n let normalized: Record<string, unknown> | null = null;\n\n for (const jsKey in table.columns) {\n const col = table.columns[jsKey];\n\n if (!col) {\n continue;\n }\n\n if (!col.meta.isSqlArray) {\n continue;\n }\n\n const value = Reflect.get(row, jsKey);\n\n if (Array.isArray(value)) {\n continue;\n }\n\n if (typeof value !== \"string\") {\n continue;\n }\n\n const parsed = parsePostgresArrayLiteral(value);\n\n if (!parsed) {\n continue;\n }\n\n if (!normalized) {\n normalized = { ...row };\n }\n\n normalized[jsKey] = parsed;\n }\n\n if (!normalized) {\n return row;\n }\n\n return normalized;\n}\n\nexport function normalizeRows<T extends ColDefs>(\n dialect: Dialect,\n table: Table<T>,\n rows: TableRow<T>[],\n) {\n if (dialect !== \"postgres\") {\n return rows;\n }\n\n return rows.map((row) => normalizeRecordForTable(table, row) as TableRow<T>);\n}\n\nexport function normalizeRowsForTable(\n dialect: Dialect,\n table: Table<ColDefs>,\n rows: Record<string, unknown>[],\n) {\n if (dialect !== \"postgres\") {\n return rows;\n }\n\n return rows.map((row) => normalizeRecordForTable(table, row));\n}\n"],"mappings":";;AAIA,SAAS,wBACP,OACA,KACA;CACA,IAAI,aAA6C;AAEjD,MAAK,MAAM,SAAS,MAAM,SAAS;EACjC,MAAM,MAAM,MAAM,QAAQ;AAE1B,MAAI,CAAC,IACH;AAGF,MAAI,CAAC,IAAI,KAAK,WACZ;EAGF,MAAM,QAAQ,QAAQ,IAAI,KAAK,MAAM;AAErC,MAAI,MAAM,QAAQ,MAAM,CACtB;AAGF,MAAI,OAAO,UAAU,SACnB;EAGF,MAAM,SAAS,0BAA0B,MAAM;AAE/C,MAAI,CAAC,OACH;AAGF,MAAI,CAAC,WACH,cAAa,EAAE,GAAG,KAAK;AAGzB,aAAW,SAAS;;AAGtB,KAAI,CAAC,WACH,QAAO;AAGT,QAAO;;AAGT,SAAgB,cACd,SACA,OACA,MACA;AACA,KAAI,YAAY,WACd,QAAO;AAGT,QAAO,KAAK,KAAK,QAAQ,wBAAwB,OAAO,IAAI,CAAgB;;AAG9E,SAAgB,sBACd,SACA,OACA,MACA;AACA,KAAI,YAAY,WACd,QAAO;AAGT,QAAO,KAAK,KAAK,QAAQ,wBAAwB,OAAO,IAAI,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/lib/orm/runtime/utils.ts
|
|
2
|
+
async function expectSingleRow(rows, message) {
|
|
3
|
+
if (rows.length === 0) throw new Error(message);
|
|
4
|
+
const first = rows[0];
|
|
5
|
+
if (first === void 0) throw new Error(message);
|
|
6
|
+
return first;
|
|
7
|
+
}
|
|
8
|
+
function mergeRows(rows, data) {
|
|
9
|
+
return rows.map((row) => ({
|
|
10
|
+
...row,
|
|
11
|
+
...data
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function toWhereInput(value) {
|
|
15
|
+
const where = {};
|
|
16
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
17
|
+
if (key === "__proto__") continue;
|
|
18
|
+
if (key === "constructor") continue;
|
|
19
|
+
if (key === "prototype") continue;
|
|
20
|
+
Reflect.set(where, key, entry);
|
|
21
|
+
}
|
|
22
|
+
return where;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.expectSingleRow = expectSingleRow;
|
|
26
|
+
exports.mergeRows = mergeRows;
|
|
27
|
+
exports.toWhereInput = toWhereInput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/lib/orm/runtime/utils.ts
|
|
2
|
+
async function expectSingleRow(rows, message) {
|
|
3
|
+
if (rows.length === 0) throw new Error(message);
|
|
4
|
+
const first = rows[0];
|
|
5
|
+
if (first === void 0) throw new Error(message);
|
|
6
|
+
return first;
|
|
7
|
+
}
|
|
8
|
+
function mergeRows(rows, data) {
|
|
9
|
+
return rows.map((row) => ({
|
|
10
|
+
...row,
|
|
11
|
+
...data
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function toWhereInput(value) {
|
|
15
|
+
const where = {};
|
|
16
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
17
|
+
if (key === "__proto__") continue;
|
|
18
|
+
if (key === "constructor") continue;
|
|
19
|
+
if (key === "prototype") continue;
|
|
20
|
+
Reflect.set(where, key, entry);
|
|
21
|
+
}
|
|
22
|
+
return where;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { expectSingleRow, mergeRows, toWhereInput };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/lib/orm/runtime/utils.ts"],"sourcesContent":["import type { ColDefs, TableRow, WhereInput } from \"../types.js\";\n\nexport async function expectSingleRow<T>(rows: T[], message: string) {\n if (rows.length === 0) {\n throw new Error(message);\n }\n\n const first = rows[0];\n\n if (first === undefined) {\n throw new Error(message);\n }\n\n return first;\n}\n\nexport function mergeRows<T extends ColDefs>(\n rows: TableRow<T>[],\n data: Partial<Record<string, unknown>>,\n) {\n return rows.map((row) => ({\n ...row,\n ...data,\n }));\n}\n\nexport function toWhereInput<T extends ColDefs>(value: object) {\n const where: WhereInput<T> = {};\n\n for (const [key, entry] of Object.entries(value)) {\n if (key === \"__proto__\") {\n continue;\n }\n\n if (key === \"constructor\") {\n continue;\n }\n\n if (key === \"prototype\") {\n continue;\n }\n\n Reflect.set(where, key, entry);\n }\n\n return where;\n}\n"],"mappings":";AAEA,eAAsB,gBAAmB,MAAW,SAAiB;AACnE,KAAI,KAAK,WAAW,EAClB,OAAM,IAAI,MAAM,QAAQ;CAG1B,MAAM,QAAQ,KAAK;AAEnB,KAAI,UAAU,KAAA,EACZ,OAAM,IAAI,MAAM,QAAQ;AAG1B,QAAO;;AAGT,SAAgB,UACd,MACA,MACA;AACA,QAAO,KAAK,KAAK,SAAS;EACxB,GAAG;EACH,GAAG;EACJ,EAAE;;AAGL,SAAgB,aAAgC,OAAe;CAC7D,MAAM,QAAuB,EAAE;AAE/B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;AAChD,MAAI,QAAQ,YACV;AAGF,MAAI,QAAQ,cACV;AAGF,MAAI,QAAQ,YACV;AAGF,UAAQ,IAAI,OAAO,KAAK,MAAM;;AAGhC,QAAO"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/lib/orm/sql/parse-array.ts
|
|
2
|
+
function coerceUnquotedToken(token) {
|
|
3
|
+
const trimmed = token.trim();
|
|
4
|
+
if (trimmed === "NULL") return null;
|
|
5
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) return Number(trimmed);
|
|
6
|
+
const lower = trimmed.toLowerCase();
|
|
7
|
+
if (lower === "true") return true;
|
|
8
|
+
if (lower === "false") return false;
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
function parsePostgresArrayLiteral(value) {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return null;
|
|
14
|
+
const inner = trimmed.slice(1, -1);
|
|
15
|
+
if (inner.length === 0) return [];
|
|
16
|
+
const out = [];
|
|
17
|
+
let token = "";
|
|
18
|
+
let index = 0;
|
|
19
|
+
let inQuotes = false;
|
|
20
|
+
let tokenWasQuoted = false;
|
|
21
|
+
while (index < inner.length) {
|
|
22
|
+
const char = inner[index];
|
|
23
|
+
if (inQuotes) {
|
|
24
|
+
if (char === "\\") {
|
|
25
|
+
const next = inner[index + 1];
|
|
26
|
+
if (next) {
|
|
27
|
+
token += next;
|
|
28
|
+
index += 2;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (char === "\"") {
|
|
33
|
+
inQuotes = false;
|
|
34
|
+
index++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
token += char;
|
|
38
|
+
index++;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (char === "\"") {
|
|
42
|
+
inQuotes = true;
|
|
43
|
+
tokenWasQuoted = true;
|
|
44
|
+
index++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (char === ",") {
|
|
48
|
+
if (tokenWasQuoted) out.push(token);
|
|
49
|
+
else out.push(coerceUnquotedToken(token));
|
|
50
|
+
token = "";
|
|
51
|
+
tokenWasQuoted = false;
|
|
52
|
+
index++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
token += char;
|
|
56
|
+
index++;
|
|
57
|
+
}
|
|
58
|
+
if (inQuotes) return null;
|
|
59
|
+
if (tokenWasQuoted) out.push(token);
|
|
60
|
+
else out.push(coerceUnquotedToken(token));
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.parsePostgresArrayLiteral = parsePostgresArrayLiteral;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/lib/orm/sql/parse-array.ts
|
|
2
|
+
function coerceUnquotedToken(token) {
|
|
3
|
+
const trimmed = token.trim();
|
|
4
|
+
if (trimmed === "NULL") return null;
|
|
5
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) return Number(trimmed);
|
|
6
|
+
const lower = trimmed.toLowerCase();
|
|
7
|
+
if (lower === "true") return true;
|
|
8
|
+
if (lower === "false") return false;
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
function parsePostgresArrayLiteral(value) {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return null;
|
|
14
|
+
const inner = trimmed.slice(1, -1);
|
|
15
|
+
if (inner.length === 0) return [];
|
|
16
|
+
const out = [];
|
|
17
|
+
let token = "";
|
|
18
|
+
let index = 0;
|
|
19
|
+
let inQuotes = false;
|
|
20
|
+
let tokenWasQuoted = false;
|
|
21
|
+
while (index < inner.length) {
|
|
22
|
+
const char = inner[index];
|
|
23
|
+
if (inQuotes) {
|
|
24
|
+
if (char === "\\") {
|
|
25
|
+
const next = inner[index + 1];
|
|
26
|
+
if (next) {
|
|
27
|
+
token += next;
|
|
28
|
+
index += 2;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (char === "\"") {
|
|
33
|
+
inQuotes = false;
|
|
34
|
+
index++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
token += char;
|
|
38
|
+
index++;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (char === "\"") {
|
|
42
|
+
inQuotes = true;
|
|
43
|
+
tokenWasQuoted = true;
|
|
44
|
+
index++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (char === ",") {
|
|
48
|
+
if (tokenWasQuoted) out.push(token);
|
|
49
|
+
else out.push(coerceUnquotedToken(token));
|
|
50
|
+
token = "";
|
|
51
|
+
tokenWasQuoted = false;
|
|
52
|
+
index++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
token += char;
|
|
56
|
+
index++;
|
|
57
|
+
}
|
|
58
|
+
if (inQuotes) return null;
|
|
59
|
+
if (tokenWasQuoted) out.push(token);
|
|
60
|
+
else out.push(coerceUnquotedToken(token));
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { parsePostgresArrayLiteral };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=parse-array.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-array.mjs","names":[],"sources":["../../../src/lib/orm/sql/parse-array.ts"],"sourcesContent":["function coerceUnquotedToken(token: string) {\n const trimmed = token.trim();\n\n if (trimmed === \"NULL\") {\n return null;\n }\n\n if (/^-?\\d+(\\.\\d+)?$/.test(trimmed)) {\n return Number(trimmed);\n }\n\n const lower = trimmed.toLowerCase();\n\n if (lower === \"true\") {\n return true;\n }\n\n if (lower === \"false\") {\n return false;\n }\n\n return trimmed;\n}\n\nexport function parsePostgresArrayLiteral(value: string) {\n const trimmed = value.trim();\n\n if (!trimmed.startsWith(\"{\") || !trimmed.endsWith(\"}\")) {\n return null;\n }\n\n const inner = trimmed.slice(1, -1);\n\n if (inner.length === 0) {\n return [];\n }\n\n const out: unknown[] = [];\n let token = \"\";\n let index = 0;\n let inQuotes = false;\n let tokenWasQuoted = false;\n\n while (index < inner.length) {\n const char = inner[index];\n\n if (inQuotes) {\n if (char === \"\\\\\") {\n const next = inner[index + 1];\n\n if (next) {\n token += next;\n index += 2;\n continue;\n }\n }\n\n if (char === '\"') {\n inQuotes = false;\n index++;\n continue;\n }\n\n token += char;\n index++;\n continue;\n }\n\n if (char === '\"') {\n inQuotes = true;\n tokenWasQuoted = true;\n index++;\n continue;\n }\n\n if (char === \",\") {\n if (tokenWasQuoted) {\n out.push(token);\n } else {\n out.push(coerceUnquotedToken(token));\n }\n\n token = \"\";\n tokenWasQuoted = false;\n index++;\n continue;\n }\n\n token += char;\n index++;\n }\n\n if (inQuotes) {\n return null;\n }\n\n if (tokenWasQuoted) {\n out.push(token);\n } else {\n out.push(coerceUnquotedToken(token));\n }\n\n return out;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB,OAAe;CAC1C,MAAM,UAAU,MAAM,MAAM;AAE5B,KAAI,YAAY,OACd,QAAO;AAGT,KAAI,kBAAkB,KAAK,QAAQ,CACjC,QAAO,OAAO,QAAQ;CAGxB,MAAM,QAAQ,QAAQ,aAAa;AAEnC,KAAI,UAAU,OACZ,QAAO;AAGT,KAAI,UAAU,QACZ,QAAO;AAGT,QAAO;;AAGT,SAAgB,0BAA0B,OAAe;CACvD,MAAM,UAAU,MAAM,MAAM;AAE5B,KAAI,CAAC,QAAQ,WAAW,IAAI,IAAI,CAAC,QAAQ,SAAS,IAAI,CACpD,QAAO;CAGT,MAAM,QAAQ,QAAQ,MAAM,GAAG,GAAG;AAElC,KAAI,MAAM,WAAW,EACnB,QAAO,EAAE;CAGX,MAAM,MAAiB,EAAE;CACzB,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,IAAI,WAAW;CACf,IAAI,iBAAiB;AAErB,QAAO,QAAQ,MAAM,QAAQ;EAC3B,MAAM,OAAO,MAAM;AAEnB,MAAI,UAAU;AACZ,OAAI,SAAS,MAAM;IACjB,MAAM,OAAO,MAAM,QAAQ;AAE3B,QAAI,MAAM;AACR,cAAS;AACT,cAAS;AACT;;;AAIJ,OAAI,SAAS,MAAK;AAChB,eAAW;AACX;AACA;;AAGF,YAAS;AACT;AACA;;AAGF,MAAI,SAAS,MAAK;AAChB,cAAW;AACX,oBAAiB;AACjB;AACA;;AAGF,MAAI,SAAS,KAAK;AAChB,OAAI,eACF,KAAI,KAAK,MAAM;OAEf,KAAI,KAAK,oBAAoB,MAAM,CAAC;AAGtC,WAAQ;AACR,oBAAiB;AACjB;AACA;;AAGF,WAAS;AACT;;AAGF,KAAI,SACF,QAAO;AAGT,KAAI,eACF,KAAI,KAAK,MAAM;KAEf,KAAI,KAAK,oBAAoB,MAAM,CAAC;AAGtC,QAAO"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_where = require("./where.cjs");
|
|
2
|
+
//#region src/lib/orm/sql/plan/select.ts
|
|
3
|
+
function buildJoinNodes(include) {
|
|
4
|
+
if (!include) return [];
|
|
5
|
+
const joins = [];
|
|
6
|
+
for (const [relationKey, enabled] of Object.entries(include)) {
|
|
7
|
+
if (enabled !== true) continue;
|
|
8
|
+
joins.push({
|
|
9
|
+
relationKey,
|
|
10
|
+
kind: "left"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return joins;
|
|
14
|
+
}
|
|
15
|
+
function buildOrderByNodes(orderBy) {
|
|
16
|
+
if (!orderBy) return [];
|
|
17
|
+
const nodes = [];
|
|
18
|
+
for (const [key, direction] of Object.entries(orderBy)) nodes.push({
|
|
19
|
+
key,
|
|
20
|
+
direction: direction === "desc" ? "desc" : "asc"
|
|
21
|
+
});
|
|
22
|
+
return nodes;
|
|
23
|
+
}
|
|
24
|
+
function buildSelectPlan(input = {}) {
|
|
25
|
+
return {
|
|
26
|
+
where: require_where.buildWhereNode(input.where),
|
|
27
|
+
joins: buildJoinNodes(input.include),
|
|
28
|
+
orderBy: buildOrderByNodes(input.orderBy),
|
|
29
|
+
page: {
|
|
30
|
+
limit: input.limit,
|
|
31
|
+
offset: input.offset
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.buildSelectPlan = buildSelectPlan;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { buildWhereNode } from "./where.mjs";
|
|
2
|
+
//#region src/lib/orm/sql/plan/select.ts
|
|
3
|
+
function buildJoinNodes(include) {
|
|
4
|
+
if (!include) return [];
|
|
5
|
+
const joins = [];
|
|
6
|
+
for (const [relationKey, enabled] of Object.entries(include)) {
|
|
7
|
+
if (enabled !== true) continue;
|
|
8
|
+
joins.push({
|
|
9
|
+
relationKey,
|
|
10
|
+
kind: "left"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return joins;
|
|
14
|
+
}
|
|
15
|
+
function buildOrderByNodes(orderBy) {
|
|
16
|
+
if (!orderBy) return [];
|
|
17
|
+
const nodes = [];
|
|
18
|
+
for (const [key, direction] of Object.entries(orderBy)) nodes.push({
|
|
19
|
+
key,
|
|
20
|
+
direction: direction === "desc" ? "desc" : "asc"
|
|
21
|
+
});
|
|
22
|
+
return nodes;
|
|
23
|
+
}
|
|
24
|
+
function buildSelectPlan(input = {}) {
|
|
25
|
+
return {
|
|
26
|
+
where: buildWhereNode(input.where),
|
|
27
|
+
joins: buildJoinNodes(input.include),
|
|
28
|
+
orderBy: buildOrderByNodes(input.orderBy),
|
|
29
|
+
page: {
|
|
30
|
+
limit: input.limit,
|
|
31
|
+
offset: input.offset
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { buildSelectPlan };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.mjs","names":[],"sources":["../../../../src/lib/orm/sql/plan/select.ts"],"sourcesContent":["import type {\n ColDefs,\n JoinNode,\n OrderDirection,\n SelectInput,\n SelectPlan,\n} from \"../../types.js\";\nimport { buildWhereNode } from \"./where.js\";\n\nfunction buildJoinNodes<TRels>(include?: { [K in keyof TRels]?: true }) {\n if (!include) {\n return [];\n }\n\n const joins: JoinNode[] = [];\n\n for (const [relationKey, enabled] of Object.entries(include)) {\n if (enabled !== true) {\n continue;\n }\n\n joins.push({\n relationKey,\n kind: \"left\",\n });\n }\n\n return joins;\n}\n\nfunction buildOrderByNodes<T extends ColDefs>(\n orderBy?: Partial<Record<keyof T, OrderDirection>>,\n) {\n if (!orderBy) {\n return [];\n }\n\n const nodes: Array<{ key: keyof T & string; direction: OrderDirection }> = [];\n\n for (const [key, direction] of Object.entries(orderBy)) {\n nodes.push({\n key: key as keyof T & string,\n direction: direction === \"desc\" ? \"desc\" : \"asc\",\n });\n }\n\n return nodes;\n}\n\nexport function buildSelectPlan<T extends ColDefs, TRels>(\n input: SelectInput<T, TRels> = {},\n): SelectPlan<T> {\n return {\n where: buildWhereNode(input.where),\n joins: buildJoinNodes(input.include),\n orderBy: buildOrderByNodes(input.orderBy),\n page: {\n limit: input.limit,\n offset: input.offset,\n },\n };\n}\n"],"mappings":";;AASA,SAAS,eAAsB,SAAyC;AACtE,KAAI,CAAC,QACH,QAAO,EAAE;CAGX,MAAM,QAAoB,EAAE;AAE5B,MAAK,MAAM,CAAC,aAAa,YAAY,OAAO,QAAQ,QAAQ,EAAE;AAC5D,MAAI,YAAY,KACd;AAGF,QAAM,KAAK;GACT;GACA,MAAM;GACP,CAAC;;AAGJ,QAAO;;AAGT,SAAS,kBACP,SACA;AACA,KAAI,CAAC,QACH,QAAO,EAAE;CAGX,MAAM,QAAqE,EAAE;AAE7E,MAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,QAAQ,CACpD,OAAM,KAAK;EACJ;EACL,WAAW,cAAc,SAAS,SAAS;EAC5C,CAAC;AAGJ,QAAO;;AAGT,SAAgB,gBACd,QAA+B,EAAE,EAClB;AACf,QAAO;EACL,OAAO,eAAe,MAAM,MAAM;EAClC,OAAO,eAAe,MAAM,QAAQ;EACpC,SAAS,kBAAkB,MAAM,QAAQ;EACzC,MAAM;GACJ,OAAO,MAAM;GACb,QAAQ,MAAM;GACf;EACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region src/lib/orm/sql/plan/where/operators.ts
|
|
2
|
+
function toOperatorPredicates(key, condition) {
|
|
3
|
+
const predicates = [];
|
|
4
|
+
if ("startsWith" in condition) predicates.push({
|
|
5
|
+
kind: "predicate",
|
|
6
|
+
key,
|
|
7
|
+
op: "like",
|
|
8
|
+
value: {
|
|
9
|
+
mode: "startsWith",
|
|
10
|
+
value: String(Reflect.get(condition, "startsWith"))
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if ("endsWith" in condition) predicates.push({
|
|
14
|
+
kind: "predicate",
|
|
15
|
+
key,
|
|
16
|
+
op: "like",
|
|
17
|
+
value: {
|
|
18
|
+
mode: "endsWith",
|
|
19
|
+
value: String(Reflect.get(condition, "endsWith"))
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if ("contains" in condition) predicates.push({
|
|
23
|
+
kind: "predicate",
|
|
24
|
+
key,
|
|
25
|
+
op: "like",
|
|
26
|
+
value: {
|
|
27
|
+
mode: "contains",
|
|
28
|
+
value: String(Reflect.get(condition, "contains"))
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if ("gt" in condition) predicates.push({
|
|
32
|
+
kind: "predicate",
|
|
33
|
+
key,
|
|
34
|
+
op: "gt",
|
|
35
|
+
value: Reflect.get(condition, "gt")
|
|
36
|
+
});
|
|
37
|
+
if ("gte" in condition) predicates.push({
|
|
38
|
+
kind: "predicate",
|
|
39
|
+
key,
|
|
40
|
+
op: "gte",
|
|
41
|
+
value: Reflect.get(condition, "gte")
|
|
42
|
+
});
|
|
43
|
+
if ("lt" in condition) predicates.push({
|
|
44
|
+
kind: "predicate",
|
|
45
|
+
key,
|
|
46
|
+
op: "lt",
|
|
47
|
+
value: Reflect.get(condition, "lt")
|
|
48
|
+
});
|
|
49
|
+
if ("lte" in condition) predicates.push({
|
|
50
|
+
kind: "predicate",
|
|
51
|
+
key,
|
|
52
|
+
op: "lte",
|
|
53
|
+
value: Reflect.get(condition, "lte")
|
|
54
|
+
});
|
|
55
|
+
if ("in" in condition) predicates.push({
|
|
56
|
+
kind: "predicate",
|
|
57
|
+
key,
|
|
58
|
+
op: "in",
|
|
59
|
+
value: Reflect.get(condition, "in")
|
|
60
|
+
});
|
|
61
|
+
if ("notIn" in condition) predicates.push({
|
|
62
|
+
kind: "predicate",
|
|
63
|
+
key,
|
|
64
|
+
op: "not_in",
|
|
65
|
+
value: Reflect.get(condition, "notIn")
|
|
66
|
+
});
|
|
67
|
+
if ("equals" in condition) predicates.push({
|
|
68
|
+
kind: "predicate",
|
|
69
|
+
key,
|
|
70
|
+
op: "eq",
|
|
71
|
+
value: Reflect.get(condition, "equals")
|
|
72
|
+
});
|
|
73
|
+
if ("not" in condition) predicates.push({
|
|
74
|
+
kind: "predicate",
|
|
75
|
+
key,
|
|
76
|
+
op: "neq",
|
|
77
|
+
value: Reflect.get(condition, "not")
|
|
78
|
+
});
|
|
79
|
+
if ("isNull" in condition) {
|
|
80
|
+
const isNull = Reflect.get(condition, "isNull");
|
|
81
|
+
if (isNull === true) predicates.push({
|
|
82
|
+
kind: "predicate",
|
|
83
|
+
key,
|
|
84
|
+
op: "is_null"
|
|
85
|
+
});
|
|
86
|
+
if (isNull === false) predicates.push({
|
|
87
|
+
kind: "predicate",
|
|
88
|
+
key,
|
|
89
|
+
op: "is_not_null"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return predicates;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
exports.toOperatorPredicates = toOperatorPredicates;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//#region src/lib/orm/sql/plan/where/operators.ts
|
|
2
|
+
function toOperatorPredicates(key, condition) {
|
|
3
|
+
const predicates = [];
|
|
4
|
+
if ("startsWith" in condition) predicates.push({
|
|
5
|
+
kind: "predicate",
|
|
6
|
+
key,
|
|
7
|
+
op: "like",
|
|
8
|
+
value: {
|
|
9
|
+
mode: "startsWith",
|
|
10
|
+
value: String(Reflect.get(condition, "startsWith"))
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if ("endsWith" in condition) predicates.push({
|
|
14
|
+
kind: "predicate",
|
|
15
|
+
key,
|
|
16
|
+
op: "like",
|
|
17
|
+
value: {
|
|
18
|
+
mode: "endsWith",
|
|
19
|
+
value: String(Reflect.get(condition, "endsWith"))
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if ("contains" in condition) predicates.push({
|
|
23
|
+
kind: "predicate",
|
|
24
|
+
key,
|
|
25
|
+
op: "like",
|
|
26
|
+
value: {
|
|
27
|
+
mode: "contains",
|
|
28
|
+
value: String(Reflect.get(condition, "contains"))
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if ("gt" in condition) predicates.push({
|
|
32
|
+
kind: "predicate",
|
|
33
|
+
key,
|
|
34
|
+
op: "gt",
|
|
35
|
+
value: Reflect.get(condition, "gt")
|
|
36
|
+
});
|
|
37
|
+
if ("gte" in condition) predicates.push({
|
|
38
|
+
kind: "predicate",
|
|
39
|
+
key,
|
|
40
|
+
op: "gte",
|
|
41
|
+
value: Reflect.get(condition, "gte")
|
|
42
|
+
});
|
|
43
|
+
if ("lt" in condition) predicates.push({
|
|
44
|
+
kind: "predicate",
|
|
45
|
+
key,
|
|
46
|
+
op: "lt",
|
|
47
|
+
value: Reflect.get(condition, "lt")
|
|
48
|
+
});
|
|
49
|
+
if ("lte" in condition) predicates.push({
|
|
50
|
+
kind: "predicate",
|
|
51
|
+
key,
|
|
52
|
+
op: "lte",
|
|
53
|
+
value: Reflect.get(condition, "lte")
|
|
54
|
+
});
|
|
55
|
+
if ("in" in condition) predicates.push({
|
|
56
|
+
kind: "predicate",
|
|
57
|
+
key,
|
|
58
|
+
op: "in",
|
|
59
|
+
value: Reflect.get(condition, "in")
|
|
60
|
+
});
|
|
61
|
+
if ("notIn" in condition) predicates.push({
|
|
62
|
+
kind: "predicate",
|
|
63
|
+
key,
|
|
64
|
+
op: "not_in",
|
|
65
|
+
value: Reflect.get(condition, "notIn")
|
|
66
|
+
});
|
|
67
|
+
if ("equals" in condition) predicates.push({
|
|
68
|
+
kind: "predicate",
|
|
69
|
+
key,
|
|
70
|
+
op: "eq",
|
|
71
|
+
value: Reflect.get(condition, "equals")
|
|
72
|
+
});
|
|
73
|
+
if ("not" in condition) predicates.push({
|
|
74
|
+
kind: "predicate",
|
|
75
|
+
key,
|
|
76
|
+
op: "neq",
|
|
77
|
+
value: Reflect.get(condition, "not")
|
|
78
|
+
});
|
|
79
|
+
if ("isNull" in condition) {
|
|
80
|
+
const isNull = Reflect.get(condition, "isNull");
|
|
81
|
+
if (isNull === true) predicates.push({
|
|
82
|
+
kind: "predicate",
|
|
83
|
+
key,
|
|
84
|
+
op: "is_null"
|
|
85
|
+
});
|
|
86
|
+
if (isNull === false) predicates.push({
|
|
87
|
+
kind: "predicate",
|
|
88
|
+
key,
|
|
89
|
+
op: "is_not_null"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return predicates;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { toOperatorPredicates };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=operators.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.mjs","names":[],"sources":["../../../../../src/lib/orm/sql/plan/where/operators.ts"],"sourcesContent":["import type { ColDefs, WhereNode } from \"../../../types.js\";\n\nexport function toOperatorPredicates<T extends ColDefs>(\n key: keyof T & string,\n condition: object,\n) {\n const predicates: Array<WhereNode<T>> = [];\n\n if (\"startsWith\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"like\",\n value: {\n mode: \"startsWith\",\n value: String(Reflect.get(condition, \"startsWith\")),\n },\n });\n }\n\n if (\"endsWith\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"like\",\n value: {\n mode: \"endsWith\",\n value: String(Reflect.get(condition, \"endsWith\")),\n },\n });\n }\n\n if (\"contains\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"like\",\n value: {\n mode: \"contains\",\n value: String(Reflect.get(condition, \"contains\")),\n },\n });\n }\n\n if (\"gt\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"gt\",\n value: Reflect.get(condition, \"gt\"),\n });\n }\n\n if (\"gte\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"gte\",\n value: Reflect.get(condition, \"gte\"),\n });\n }\n\n if (\"lt\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"lt\",\n value: Reflect.get(condition, \"lt\"),\n });\n }\n\n if (\"lte\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"lte\",\n value: Reflect.get(condition, \"lte\"),\n });\n }\n\n if (\"in\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"in\",\n value: Reflect.get(condition, \"in\"),\n });\n }\n\n if (\"notIn\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"not_in\",\n value: Reflect.get(condition, \"notIn\"),\n });\n }\n\n if (\"equals\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"eq\",\n value: Reflect.get(condition, \"equals\"),\n });\n }\n\n if (\"not\" in condition) {\n predicates.push({\n kind: \"predicate\",\n key,\n op: \"neq\",\n value: Reflect.get(condition, \"not\"),\n });\n }\n\n if (\"isNull\" in condition) {\n const isNull = Reflect.get(condition, \"isNull\");\n\n if (isNull === true) {\n predicates.push({ kind: \"predicate\", key, op: \"is_null\" });\n }\n\n if (isNull === false) {\n predicates.push({ kind: \"predicate\", key, op: \"is_not_null\" });\n }\n }\n\n return predicates;\n}\n"],"mappings":";AAEA,SAAgB,qBACd,KACA,WACA;CACA,MAAM,aAAkC,EAAE;AAE1C,KAAI,gBAAgB,UAClB,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO;GACL,MAAM;GACN,OAAO,OAAO,QAAQ,IAAI,WAAW,aAAa,CAAC;GACpD;EACF,CAAC;AAGJ,KAAI,cAAc,UAChB,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO;GACL,MAAM;GACN,OAAO,OAAO,QAAQ,IAAI,WAAW,WAAW,CAAC;GAClD;EACF,CAAC;AAGJ,KAAI,cAAc,UAChB,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO;GACL,MAAM;GACN,OAAO,OAAO,QAAQ,IAAI,WAAW,WAAW,CAAC;GAClD;EACF,CAAC;AAGJ,KAAI,QAAQ,UACV,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,KAAK;EACpC,CAAC;AAGJ,KAAI,SAAS,UACX,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,MAAM;EACrC,CAAC;AAGJ,KAAI,QAAQ,UACV,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,KAAK;EACpC,CAAC;AAGJ,KAAI,SAAS,UACX,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,MAAM;EACrC,CAAC;AAGJ,KAAI,QAAQ,UACV,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,KAAK;EACpC,CAAC;AAGJ,KAAI,WAAW,UACb,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,QAAQ;EACvC,CAAC;AAGJ,KAAI,YAAY,UACd,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,SAAS;EACxC,CAAC;AAGJ,KAAI,SAAS,UACX,YAAW,KAAK;EACd,MAAM;EACN;EACA,IAAI;EACJ,OAAO,QAAQ,IAAI,WAAW,MAAM;EACrC,CAAC;AAGJ,KAAI,YAAY,WAAW;EACzB,MAAM,SAAS,QAAQ,IAAI,WAAW,SAAS;AAE/C,MAAI,WAAW,KACb,YAAW,KAAK;GAAE,MAAM;GAAa;GAAK,IAAI;GAAW,CAAC;AAG5D,MAAI,WAAW,MACb,YAAW,KAAK;GAAE,MAAM;GAAa;GAAK,IAAI;GAAe,CAAC;;AAIlE,QAAO"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const require_operators = require("./where/operators.cjs");
|
|
2
|
+
//#region src/lib/orm/sql/plan/where.ts
|
|
3
|
+
function combineWhereNodes(kind, nodes) {
|
|
4
|
+
if (nodes.length === 0) return;
|
|
5
|
+
if (nodes.length === 1) return nodes[0];
|
|
6
|
+
return {
|
|
7
|
+
kind,
|
|
8
|
+
nodes
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function buildWhereNode(where) {
|
|
12
|
+
if (!where) return;
|
|
13
|
+
const nodes = [];
|
|
14
|
+
const andInputs = where.and;
|
|
15
|
+
if (andInputs) for (const entry of andInputs) {
|
|
16
|
+
const node = buildWhereNode(entry);
|
|
17
|
+
if (!node) continue;
|
|
18
|
+
nodes.push(node);
|
|
19
|
+
}
|
|
20
|
+
const orInputs = where.or;
|
|
21
|
+
if (orInputs) {
|
|
22
|
+
const orNodes = [];
|
|
23
|
+
for (const entry of orInputs) {
|
|
24
|
+
const node = buildWhereNode(entry);
|
|
25
|
+
if (!node) continue;
|
|
26
|
+
orNodes.push(node);
|
|
27
|
+
}
|
|
28
|
+
const orNode = combineWhereNodes("or", orNodes);
|
|
29
|
+
if (orNode) nodes.push(orNode);
|
|
30
|
+
}
|
|
31
|
+
for (const [key, condition] of Object.entries(where)) {
|
|
32
|
+
if (key === "and") continue;
|
|
33
|
+
if (key === "or") continue;
|
|
34
|
+
const typedKey = key;
|
|
35
|
+
if (typeof condition !== "object" || condition === null) {
|
|
36
|
+
nodes.push({
|
|
37
|
+
kind: "predicate",
|
|
38
|
+
key: typedKey,
|
|
39
|
+
op: "eq",
|
|
40
|
+
value: condition
|
|
41
|
+
});
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const predicates = require_operators.toOperatorPredicates(typedKey, condition);
|
|
45
|
+
if (predicates.length === 0) {
|
|
46
|
+
nodes.push({
|
|
47
|
+
kind: "predicate",
|
|
48
|
+
key: typedKey,
|
|
49
|
+
op: "eq",
|
|
50
|
+
value: condition
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (const predicate of predicates) nodes.push(predicate);
|
|
55
|
+
}
|
|
56
|
+
return combineWhereNodes("and", nodes);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.buildWhereNode = buildWhereNode;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { toOperatorPredicates } from "./where/operators.mjs";
|
|
2
|
+
//#region src/lib/orm/sql/plan/where.ts
|
|
3
|
+
function combineWhereNodes(kind, nodes) {
|
|
4
|
+
if (nodes.length === 0) return;
|
|
5
|
+
if (nodes.length === 1) return nodes[0];
|
|
6
|
+
return {
|
|
7
|
+
kind,
|
|
8
|
+
nodes
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function buildWhereNode(where) {
|
|
12
|
+
if (!where) return;
|
|
13
|
+
const nodes = [];
|
|
14
|
+
const andInputs = where.and;
|
|
15
|
+
if (andInputs) for (const entry of andInputs) {
|
|
16
|
+
const node = buildWhereNode(entry);
|
|
17
|
+
if (!node) continue;
|
|
18
|
+
nodes.push(node);
|
|
19
|
+
}
|
|
20
|
+
const orInputs = where.or;
|
|
21
|
+
if (orInputs) {
|
|
22
|
+
const orNodes = [];
|
|
23
|
+
for (const entry of orInputs) {
|
|
24
|
+
const node = buildWhereNode(entry);
|
|
25
|
+
if (!node) continue;
|
|
26
|
+
orNodes.push(node);
|
|
27
|
+
}
|
|
28
|
+
const orNode = combineWhereNodes("or", orNodes);
|
|
29
|
+
if (orNode) nodes.push(orNode);
|
|
30
|
+
}
|
|
31
|
+
for (const [key, condition] of Object.entries(where)) {
|
|
32
|
+
if (key === "and") continue;
|
|
33
|
+
if (key === "or") continue;
|
|
34
|
+
const typedKey = key;
|
|
35
|
+
if (typeof condition !== "object" || condition === null) {
|
|
36
|
+
nodes.push({
|
|
37
|
+
kind: "predicate",
|
|
38
|
+
key: typedKey,
|
|
39
|
+
op: "eq",
|
|
40
|
+
value: condition
|
|
41
|
+
});
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const predicates = toOperatorPredicates(typedKey, condition);
|
|
45
|
+
if (predicates.length === 0) {
|
|
46
|
+
nodes.push({
|
|
47
|
+
kind: "predicate",
|
|
48
|
+
key: typedKey,
|
|
49
|
+
op: "eq",
|
|
50
|
+
value: condition
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (const predicate of predicates) nodes.push(predicate);
|
|
55
|
+
}
|
|
56
|
+
return combineWhereNodes("and", nodes);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { buildWhereNode };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=where.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.mjs","names":[],"sources":["../../../../src/lib/orm/sql/plan/where.ts"],"sourcesContent":["import type { ColDefs, WhereInput, WhereNode } from \"../../types.js\";\nimport {\n isLikePredicateValue,\n isValueOperator,\n type LikeMode,\n type LikePredicateValue,\n} from \"./where/guards.js\";\nimport { toOperatorPredicates } from \"./where/operators.js\";\n\nfunction combineWhereNodes<T extends ColDefs>(\n kind: \"and\" | \"or\",\n nodes: Array<WhereNode<T>>,\n) {\n if (nodes.length === 0) {\n return undefined;\n }\n\n if (nodes.length === 1) {\n return nodes[0];\n }\n\n return { kind, nodes };\n}\n\nexport function buildWhereNode<T extends ColDefs>(where?: WhereInput<T>) {\n if (!where) {\n return undefined;\n }\n\n const nodes: Array<WhereNode<T>> = [];\n\n const andInputs = where.and;\n\n if (andInputs) {\n for (const entry of andInputs) {\n const node = buildWhereNode(entry);\n\n if (!node) {\n continue;\n }\n\n nodes.push(node);\n }\n }\n\n const orInputs = where.or;\n\n if (orInputs) {\n const orNodes: Array<WhereNode<T>> = [];\n\n for (const entry of orInputs) {\n const node = buildWhereNode(entry);\n\n if (!node) {\n continue;\n }\n\n orNodes.push(node);\n }\n\n const orNode = combineWhereNodes(\"or\", orNodes);\n\n if (orNode) {\n nodes.push(orNode);\n }\n }\n\n for (const [key, condition] of Object.entries(where)) {\n if (key === \"and\") {\n continue;\n }\n\n if (key === \"or\") {\n continue;\n }\n\n const typedKey = key as keyof T & string;\n\n if (typeof condition !== \"object\" || condition === null) {\n nodes.push({\n kind: \"predicate\",\n key: typedKey,\n op: \"eq\",\n value: condition,\n });\n\n continue;\n }\n\n const predicates = toOperatorPredicates(typedKey, condition);\n\n if (predicates.length === 0) {\n nodes.push({\n kind: \"predicate\",\n key: typedKey,\n op: \"eq\",\n value: condition,\n });\n continue;\n }\n\n for (const predicate of predicates) {\n nodes.push(predicate);\n }\n }\n\n return combineWhereNodes(\"and\", nodes);\n}\n\nexport { isLikePredicateValue, isValueOperator };\nexport type { LikeMode, LikePredicateValue };\n"],"mappings":";;AASA,SAAS,kBACP,MACA,OACA;AACA,KAAI,MAAM,WAAW,EACnB;AAGF,KAAI,MAAM,WAAW,EACnB,QAAO,MAAM;AAGf,QAAO;EAAE;EAAM;EAAO;;AAGxB,SAAgB,eAAkC,OAAuB;AACvE,KAAI,CAAC,MACH;CAGF,MAAM,QAA6B,EAAE;CAErC,MAAM,YAAY,MAAM;AAExB,KAAI,UACF,MAAK,MAAM,SAAS,WAAW;EAC7B,MAAM,OAAO,eAAe,MAAM;AAElC,MAAI,CAAC,KACH;AAGF,QAAM,KAAK,KAAK;;CAIpB,MAAM,WAAW,MAAM;AAEvB,KAAI,UAAU;EACZ,MAAM,UAA+B,EAAE;AAEvC,OAAK,MAAM,SAAS,UAAU;GAC5B,MAAM,OAAO,eAAe,MAAM;AAElC,OAAI,CAAC,KACH;AAGF,WAAQ,KAAK,KAAK;;EAGpB,MAAM,SAAS,kBAAkB,MAAM,QAAQ;AAE/C,MAAI,OACF,OAAM,KAAK,OAAO;;AAItB,MAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,MAAM,EAAE;AACpD,MAAI,QAAQ,MACV;AAGF,MAAI,QAAQ,KACV;EAGF,MAAM,WAAW;AAEjB,MAAI,OAAO,cAAc,YAAY,cAAc,MAAM;AACvD,SAAM,KAAK;IACT,MAAM;IACN,KAAK;IACL,IAAI;IACJ,OAAO;IACR,CAAC;AAEF;;EAGF,MAAM,aAAa,qBAAqB,UAAU,UAAU;AAE5D,MAAI,WAAW,WAAW,GAAG;AAC3B,SAAM,KAAK;IACT,MAAM;IACN,KAAK;IACL,IAAI;IACJ,OAAO;IACR,CAAC;AACF;;AAGF,OAAK,MAAM,aAAa,WACtB,OAAM,KAAK,UAAU;;AAIzB,QAAO,kBAAkB,OAAO,MAAM"}
|