semola 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -45
- package/dist/chunk-CKQMccvm.cjs +28 -0
- package/dist/lib/api/index.cjs +536 -4
- package/dist/lib/api/index.d.cts +270 -4
- package/dist/lib/api/index.d.mts +270 -4
- package/dist/lib/api/index.mjs +534 -2
- package/dist/lib/cache/index.cjs +47 -22
- package/dist/lib/cache/index.d.cts +14 -23
- package/dist/lib/cache/index.d.mts +14 -23
- package/dist/lib/cache/index.mjs +48 -25
- package/dist/lib/cron/index.cjs +734 -12
- package/dist/lib/cron/index.d.cts +145 -3
- package/dist/lib/cron/index.d.mts +145 -3
- package/dist/lib/cron/index.mjs +725 -3
- package/dist/lib/errors/index.d.cts +4 -4
- package/dist/lib/errors/index.d.mts +4 -4
- package/dist/lib/errors/index.mjs +0 -2
- package/dist/lib/i18n/index.d.cts +12 -4
- package/dist/lib/i18n/index.d.mts +12 -4
- package/dist/lib/i18n/index.mjs +0 -2
- package/dist/lib/logging/index.cjs +387 -17
- package/dist/lib/logging/index.d.cts +107 -6
- package/dist/lib/logging/index.d.mts +107 -6
- package/dist/lib/logging/index.mjs +373 -4
- package/dist/lib/orm/index.cjs +1641 -19
- package/dist/lib/orm/index.d.cts +402 -7
- package/dist/lib/orm/index.d.mts +402 -7
- package/dist/lib/orm/index.mjs +1630 -6
- package/dist/lib/policy/index.cjs +206 -20
- package/dist/lib/policy/index.d.cts +61 -5
- package/dist/lib/policy/index.d.mts +61 -5
- package/dist/lib/policy/index.mjs +187 -3
- package/dist/lib/prompts/index.cjs +374 -14
- package/dist/lib/prompts/index.d.cts +73 -29
- package/dist/lib/prompts/index.d.mts +73 -29
- package/dist/lib/prompts/index.mjs +361 -4
- package/dist/lib/pubsub/index.cjs +43 -19
- package/dist/lib/pubsub/index.d.cts +12 -22
- package/dist/lib/pubsub/index.d.mts +12 -22
- package/dist/lib/pubsub/index.mjs +44 -22
- package/dist/lib/queue/index.cjs +40 -10
- package/dist/lib/queue/index.d.cts +57 -8
- package/dist/lib/queue/index.d.mts +57 -8
- package/dist/lib/queue/index.mjs +39 -13
- package/dist/lib/workflow/index.cjs +285 -282
- package/dist/lib/workflow/index.d.cts +147 -4
- package/dist/lib/workflow/index.d.mts +147 -4
- package/dist/lib/workflow/index.mjs +278 -286
- package/package.json +11 -1
- package/dist/api/core/index.cjs +0 -206
- package/dist/api/core/index.d.cts +0 -21
- package/dist/api/core/index.d.cts.map +0 -1
- package/dist/api/core/index.d.mts +0 -21
- package/dist/api/core/index.d.mts.map +0 -1
- package/dist/api/core/index.mjs +0 -208
- package/dist/api/core/index.mjs.map +0 -1
- package/dist/api/core/types.d.cts +0 -107
- package/dist/api/core/types.d.cts.map +0 -1
- package/dist/api/core/types.d.mts +0 -107
- package/dist/api/core/types.d.mts.map +0 -1
- package/dist/api/middleware/index.cjs +0 -8
- package/dist/api/middleware/index.d.cts +0 -11
- package/dist/api/middleware/index.d.cts.map +0 -1
- package/dist/api/middleware/index.d.mts +0 -11
- package/dist/api/middleware/index.d.mts.map +0 -1
- package/dist/api/middleware/index.mjs +0 -10
- package/dist/api/middleware/index.mjs.map +0 -1
- package/dist/api/middleware/types.d.cts +0 -16
- package/dist/api/middleware/types.d.cts.map +0 -1
- package/dist/api/middleware/types.d.mts +0 -16
- package/dist/api/middleware/types.d.mts.map +0 -1
- package/dist/api/openapi/index.cjs +0 -254
- package/dist/api/openapi/index.mjs +0 -256
- package/dist/api/openapi/index.mjs.map +0 -1
- package/dist/api/openapi/types.d.cts +0 -60
- package/dist/api/openapi/types.d.cts.map +0 -1
- package/dist/api/openapi/types.d.mts +0 -60
- package/dist/api/openapi/types.d.mts.map +0 -1
- package/dist/api/validation/index.cjs +0 -64
- package/dist/api/validation/index.mjs +0 -61
- package/dist/api/validation/index.mjs.map +0 -1
- package/dist/cache/types.d.cts +0 -17
- package/dist/cache/types.d.cts.map +0 -1
- package/dist/cache/types.d.mts +0 -17
- package/dist/cache/types.d.mts.map +0 -1
- package/dist/cron/builder/index.cjs +0 -166
- package/dist/cron/builder/index.d.cts +0 -28
- package/dist/cron/builder/index.d.cts.map +0 -1
- package/dist/cron/builder/index.d.mts +0 -28
- package/dist/cron/builder/index.d.mts.map +0 -1
- package/dist/cron/builder/index.mjs +0 -163
- package/dist/cron/builder/index.mjs.map +0 -1
- package/dist/cron/builder/types.cjs +0 -27
- package/dist/cron/builder/types.d.cts +0 -79
- package/dist/cron/builder/types.d.cts.map +0 -1
- package/dist/cron/builder/types.d.mts +0 -79
- package/dist/cron/builder/types.d.mts.map +0 -1
- package/dist/cron/builder/types.mjs +0 -28
- package/dist/cron/builder/types.mjs.map +0 -1
- package/dist/cron/core/index.cjs +0 -308
- package/dist/cron/core/index.d.cts +0 -39
- package/dist/cron/core/index.d.cts.map +0 -1
- package/dist/cron/core/index.d.mts +0 -39
- package/dist/cron/core/index.d.mts.map +0 -1
- package/dist/cron/core/index.mjs +0 -310
- package/dist/cron/core/index.mjs.map +0 -1
- package/dist/cron/core/scanner.cjs +0 -237
- package/dist/cron/core/scanner.mjs +0 -238
- package/dist/cron/core/scanner.mjs.map +0 -1
- package/dist/cron/core/types.d.cts +0 -11
- package/dist/cron/core/types.d.cts.map +0 -1
- package/dist/cron/core/types.d.mts +0 -11
- package/dist/cron/core/types.d.mts.map +0 -1
- package/dist/errors/types.d.cts +0 -5
- package/dist/errors/types.d.cts.map +0 -1
- package/dist/errors/types.d.mts +0 -5
- package/dist/errors/types.d.mts.map +0 -1
- package/dist/i18n/types.d.cts +0 -13
- package/dist/i18n/types.d.cts.map +0 -1
- package/dist/i18n/types.d.mts +0 -13
- package/dist/i18n/types.d.mts.map +0 -1
- package/dist/lib/cache/index.d.cts.map +0 -1
- package/dist/lib/cache/index.d.mts.map +0 -1
- package/dist/lib/cache/index.mjs.map +0 -1
- package/dist/lib/errors/index.d.cts.map +0 -1
- package/dist/lib/errors/index.d.mts.map +0 -1
- package/dist/lib/errors/index.mjs.map +0 -1
- package/dist/lib/i18n/index.d.cts.map +0 -1
- package/dist/lib/i18n/index.d.mts.map +0 -1
- package/dist/lib/i18n/index.mjs.map +0 -1
- package/dist/lib/policy/index.d.cts.map +0 -1
- package/dist/lib/policy/index.d.mts.map +0 -1
- package/dist/lib/policy/index.mjs.map +0 -1
- package/dist/lib/prompts/index.d.cts.map +0 -1
- package/dist/lib/prompts/index.d.mts.map +0 -1
- package/dist/lib/prompts/index.mjs.map +0 -1
- package/dist/lib/pubsub/index.d.cts.map +0 -1
- package/dist/lib/pubsub/index.d.mts.map +0 -1
- package/dist/lib/pubsub/index.mjs.map +0 -1
- package/dist/lib/queue/index.d.cts.map +0 -1
- package/dist/lib/queue/index.d.mts.map +0 -1
- package/dist/lib/queue/index.mjs.map +0 -1
- package/dist/lib/workflow/index.d.cts.map +0 -1
- package/dist/lib/workflow/index.d.mts.map +0 -1
- package/dist/lib/workflow/index.mjs.map +0 -1
- package/dist/logging/core/index.cjs +0 -99
- package/dist/logging/core/index.d.cts +0 -26
- package/dist/logging/core/index.d.cts.map +0 -1
- package/dist/logging/core/index.d.mts +0 -26
- package/dist/logging/core/index.d.mts.map +0 -1
- package/dist/logging/core/index.mjs +0 -99
- package/dist/logging/core/index.mjs.map +0 -1
- package/dist/logging/core/types.cjs +0 -10
- package/dist/logging/core/types.d.cts +0 -22
- package/dist/logging/core/types.d.cts.map +0 -1
- package/dist/logging/core/types.d.mts +0 -22
- package/dist/logging/core/types.d.mts.map +0 -1
- package/dist/logging/core/types.mjs +0 -12
- package/dist/logging/core/types.mjs.map +0 -1
- package/dist/logging/formatter/index.cjs +0 -119
- package/dist/logging/formatter/index.d.cts +0 -27
- package/dist/logging/formatter/index.d.cts.map +0 -1
- package/dist/logging/formatter/index.d.mts +0 -27
- package/dist/logging/formatter/index.d.mts.map +0 -1
- package/dist/logging/formatter/index.mjs +0 -115
- package/dist/logging/formatter/index.mjs.map +0 -1
- package/dist/logging/formatter/types.d.cts +0 -5
- package/dist/logging/formatter/types.d.cts.map +0 -1
- package/dist/logging/formatter/types.d.mts +0 -5
- package/dist/logging/formatter/types.d.mts.map +0 -1
- package/dist/logging/provider/index.cjs +0 -165
- package/dist/logging/provider/index.d.cts +0 -28
- package/dist/logging/provider/index.d.cts.map +0 -1
- package/dist/logging/provider/index.d.mts +0 -28
- package/dist/logging/provider/index.d.mts.map +0 -1
- package/dist/logging/provider/index.mjs +0 -165
- package/dist/logging/provider/index.mjs.map +0 -1
- package/dist/logging/provider/types.d.cts +0 -23
- package/dist/logging/provider/types.d.cts.map +0 -1
- package/dist/logging/provider/types.d.mts +0 -23
- package/dist/logging/provider/types.d.mts.map +0 -1
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +0 -80
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +0 -1
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +0 -80
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +0 -1
- package/dist/orm/column.cjs +0 -137
- package/dist/orm/column.d.cts +0 -121
- package/dist/orm/column.d.cts.map +0 -1
- package/dist/orm/column.d.mts +0 -121
- package/dist/orm/column.d.mts.map +0 -1
- package/dist/orm/column.mjs +0 -132
- package/dist/orm/column.mjs.map +0 -1
- package/dist/orm/dialect/index.cjs +0 -14
- package/dist/orm/dialect/index.mjs +0 -16
- package/dist/orm/dialect/index.mjs.map +0 -1
- package/dist/orm/dialect/mysql.cjs +0 -31
- package/dist/orm/dialect/mysql.mjs +0 -33
- package/dist/orm/dialect/mysql.mjs.map +0 -1
- package/dist/orm/dialect/postgres.cjs +0 -23
- package/dist/orm/dialect/postgres.mjs +0 -25
- package/dist/orm/dialect/postgres.mjs.map +0 -1
- package/dist/orm/dialect/sqlite.cjs +0 -31
- package/dist/orm/dialect/sqlite.mjs +0 -33
- package/dist/orm/dialect/sqlite.mjs.map +0 -1
- package/dist/orm/dialect/utils.cjs +0 -8
- package/dist/orm/dialect/utils.mjs +0 -10
- package/dist/orm/dialect/utils.mjs.map +0 -1
- package/dist/orm/internal/table-columns.cjs +0 -31
- package/dist/orm/internal/table-columns.mjs +0 -32
- package/dist/orm/internal/table-columns.mjs.map +0 -1
- package/dist/orm/internal/table-lookup.cjs +0 -35
- package/dist/orm/internal/table-lookup.mjs +0 -35
- package/dist/orm/internal/table-lookup.mjs.map +0 -1
- package/dist/orm/internal/table-relations.cjs +0 -28
- package/dist/orm/internal/table-relations.mjs +0 -29
- package/dist/orm/internal/table-relations.mjs.map +0 -1
- package/dist/orm/migration/config.cjs +0 -7
- package/dist/orm/migration/config.d.cts +0 -7
- package/dist/orm/migration/config.d.cts.map +0 -1
- package/dist/orm/migration/config.d.mts +0 -7
- package/dist/orm/migration/config.d.mts.map +0 -1
- package/dist/orm/migration/config.mjs +0 -8
- package/dist/orm/migration/config.mjs.map +0 -1
- package/dist/orm/migration/types.d.cts +0 -20
- package/dist/orm/migration/types.d.cts.map +0 -1
- package/dist/orm/migration/types.d.mts +0 -20
- package/dist/orm/migration/types.d.mts.map +0 -1
- package/dist/orm/orm.cjs +0 -41
- package/dist/orm/orm.d.cts +0 -18
- package/dist/orm/orm.d.cts.map +0 -1
- package/dist/orm/orm.d.mts +0 -18
- package/dist/orm/orm.d.mts.map +0 -1
- package/dist/orm/orm.mjs +0 -43
- package/dist/orm/orm.mjs.map +0 -1
- package/dist/orm/relation.cjs +0 -18
- package/dist/orm/relation.d.cts +0 -8
- package/dist/orm/relation.d.cts.map +0 -1
- package/dist/orm/relation.d.mts +0 -8
- package/dist/orm/relation.d.mts.map +0 -1
- package/dist/orm/relation.mjs +0 -19
- package/dist/orm/relation.mjs.map +0 -1
- package/dist/orm/runtime/builders/mutations.cjs +0 -29
- package/dist/orm/runtime/builders/mutations.mjs +0 -28
- package/dist/orm/runtime/builders/mutations.mjs.map +0 -1
- package/dist/orm/runtime/builders/select.cjs +0 -18
- package/dist/orm/runtime/builders/select.mjs +0 -19
- package/dist/orm/runtime/builders/select.mjs.map +0 -1
- package/dist/orm/runtime/client.cjs +0 -90
- package/dist/orm/runtime/client.mjs +0 -92
- package/dist/orm/runtime/client.mjs.map +0 -1
- package/dist/orm/runtime/context.cjs +0 -49
- package/dist/orm/runtime/context.mjs +0 -51
- package/dist/orm/runtime/context.mjs.map +0 -1
- package/dist/orm/runtime/dialect/index.cjs +0 -11
- package/dist/orm/runtime/dialect/index.mjs +0 -13
- package/dist/orm/runtime/dialect/index.mjs.map +0 -1
- package/dist/orm/runtime/dialect/mysql.cjs +0 -95
- package/dist/orm/runtime/dialect/mysql.mjs +0 -97
- package/dist/orm/runtime/dialect/mysql.mjs.map +0 -1
- package/dist/orm/runtime/dialect/postgres.cjs +0 -51
- package/dist/orm/runtime/dialect/postgres.mjs +0 -53
- package/dist/orm/runtime/dialect/postgres.mjs.map +0 -1
- package/dist/orm/runtime/dialect/sqlite.cjs +0 -4
- package/dist/orm/runtime/dialect/sqlite.mjs +0 -7
- package/dist/orm/runtime/dialect/sqlite.mjs.map +0 -1
- package/dist/orm/runtime/errors.cjs +0 -19
- package/dist/orm/runtime/errors.mjs +0 -21
- package/dist/orm/runtime/errors.mjs.map +0 -1
- package/dist/orm/runtime/hydrate/many.cjs +0 -46
- package/dist/orm/runtime/hydrate/many.mjs +0 -48
- package/dist/orm/runtime/hydrate/many.mjs.map +0 -1
- package/dist/orm/runtime/hydrate/one.cjs +0 -38
- package/dist/orm/runtime/hydrate/one.mjs +0 -40
- package/dist/orm/runtime/hydrate/one.mjs.map +0 -1
- package/dist/orm/runtime/hydrate.cjs +0 -49
- package/dist/orm/runtime/hydrate.mjs +0 -51
- package/dist/orm/runtime/hydrate.mjs.map +0 -1
- package/dist/orm/runtime/rows.cjs +0 -30
- package/dist/orm/runtime/rows.mjs +0 -31
- package/dist/orm/runtime/rows.mjs.map +0 -1
- package/dist/orm/runtime/utils.cjs +0 -27
- package/dist/orm/runtime/utils.mjs +0 -27
- package/dist/orm/runtime/utils.mjs.map +0 -1
- package/dist/orm/sql/parse-array.cjs +0 -64
- package/dist/orm/sql/parse-array.mjs +0 -66
- package/dist/orm/sql/parse-array.mjs.map +0 -1
- package/dist/orm/sql/plan/select.cjs +0 -36
- package/dist/orm/sql/plan/select.mjs +0 -38
- package/dist/orm/sql/plan/select.mjs.map +0 -1
- package/dist/orm/sql/plan/where/operators.cjs +0 -95
- package/dist/orm/sql/plan/where/operators.mjs +0 -97
- package/dist/orm/sql/plan/where/operators.mjs.map +0 -1
- package/dist/orm/sql/plan/where.cjs +0 -59
- package/dist/orm/sql/plan/where.mjs +0 -61
- package/dist/orm/sql/plan/where.mjs.map +0 -1
- package/dist/orm/sql/serialize/clauses.cjs +0 -36
- package/dist/orm/sql/serialize/clauses.mjs +0 -37
- package/dist/orm/sql/serialize/clauses.mjs.map +0 -1
- package/dist/orm/sql/serialize/joins.cjs +0 -31
- package/dist/orm/sql/serialize/joins.mjs +0 -33
- package/dist/orm/sql/serialize/joins.mjs.map +0 -1
- package/dist/orm/sql/serialize/values.cjs +0 -30
- package/dist/orm/sql/serialize/values.mjs +0 -32
- package/dist/orm/sql/serialize/values.mjs.map +0 -1
- package/dist/orm/sql/serialize/where/predicate.cjs +0 -73
- package/dist/orm/sql/serialize/where/predicate.mjs +0 -75
- package/dist/orm/sql/serialize/where/predicate.mjs.map +0 -1
- package/dist/orm/sql/serialize/where/tree.cjs +0 -26
- package/dist/orm/sql/serialize/where/tree.mjs +0 -28
- package/dist/orm/sql/serialize/where/tree.mjs.map +0 -1
- package/dist/orm/sql/serialize/where.cjs +0 -10
- package/dist/orm/sql/serialize/where.mjs +0 -12
- package/dist/orm/sql/serialize/where.mjs.map +0 -1
- package/dist/orm/sql/serialize.cjs +0 -24
- package/dist/orm/sql/serialize.mjs +0 -25
- package/dist/orm/sql/serialize.mjs.map +0 -1
- package/dist/orm/table.cjs +0 -12
- package/dist/orm/table.d.cts +0 -12
- package/dist/orm/table.d.cts.map +0 -1
- package/dist/orm/table.d.mts +0 -12
- package/dist/orm/table.d.mts.map +0 -1
- package/dist/orm/table.mjs +0 -14
- package/dist/orm/table.mjs.map +0 -1
- package/dist/orm/types.d.cts +0 -183
- package/dist/orm/types.d.cts.map +0 -1
- package/dist/orm/types.d.mts +0 -183
- package/dist/orm/types.d.mts.map +0 -1
- package/dist/policy/helpers.cjs +0 -206
- package/dist/policy/helpers.d.cts +0 -50
- package/dist/policy/helpers.d.cts.map +0 -1
- package/dist/policy/helpers.d.mts +0 -50
- package/dist/policy/helpers.d.mts.map +0 -1
- package/dist/policy/helpers.mjs +0 -190
- package/dist/policy/helpers.mjs.map +0 -1
- package/dist/policy/types.d.cts +0 -16
- package/dist/policy/types.d.cts.map +0 -1
- package/dist/policy/types.d.mts +0 -16
- package/dist/policy/types.d.mts.map +0 -1
- package/dist/prompts/core/keys.cjs +0 -165
- package/dist/prompts/core/keys.mjs +0 -167
- package/dist/prompts/core/keys.mjs.map +0 -1
- package/dist/prompts/core/runtime.cjs +0 -104
- package/dist/prompts/core/runtime.mjs +0 -106
- package/dist/prompts/core/runtime.mjs.map +0 -1
- package/dist/prompts/core/session.cjs +0 -98
- package/dist/prompts/core/session.mjs +0 -100
- package/dist/prompts/core/session.mjs.map +0 -1
- package/dist/prompts/core/types.d.cts +0 -21
- package/dist/prompts/core/types.d.cts.map +0 -1
- package/dist/prompts/core/types.d.mts +0 -21
- package/dist/prompts/core/types.d.mts.map +0 -1
- package/dist/prompts/types.d.cts +0 -52
- package/dist/prompts/types.d.cts.map +0 -1
- package/dist/prompts/types.d.mts +0 -52
- package/dist/prompts/types.d.mts.map +0 -1
- package/dist/pubsub/types.d.cts +0 -10
- package/dist/pubsub/types.d.cts.map +0 -1
- package/dist/pubsub/types.d.mts +0 -10
- package/dist/pubsub/types.d.mts.map +0 -1
- package/dist/queue/types.d.cts +0 -47
- package/dist/queue/types.d.cts.map +0 -1
- package/dist/queue/types.d.mts +0 -47
- package/dist/queue/types.d.mts.map +0 -1
- package/dist/workflow/types.d.cts +0 -83
- package/dist/workflow/types.d.cts.map +0 -1
- package/dist/workflow/types.d.mts +0 -83
- package/dist/workflow/types.d.mts.map +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const require_table_lookup = require("../../internal/table-lookup.cjs");
|
|
2
|
-
//#region src/lib/orm/runtime/hydrate/one.ts
|
|
3
|
-
async function hydrateOneRelation(options) {
|
|
4
|
-
const { rows, relationKey, relationForeignKey, table, targetTable, selectWhereIn } = options;
|
|
5
|
-
const targetPk = require_table_lookup.getPrimaryKeyColumn(targetTable);
|
|
6
|
-
if (!targetPk) {
|
|
7
|
-
for (const row of rows) Reflect.set(row, relationKey, null);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const sourceFk = require_table_lookup.findColumnBySqlName(table, relationForeignKey);
|
|
11
|
-
if (!sourceFk) {
|
|
12
|
-
for (const row of rows) Reflect.set(row, relationKey, null);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const fkValues = /* @__PURE__ */ new Set();
|
|
16
|
-
for (const row of rows) {
|
|
17
|
-
const value = Reflect.get(row, sourceFk.jsKey);
|
|
18
|
-
if (value === null || value === void 0) continue;
|
|
19
|
-
fkValues.add(value);
|
|
20
|
-
}
|
|
21
|
-
const targetRows = await selectWhereIn(targetTable, targetPk.col.meta.sqlName, Array.from(fkValues));
|
|
22
|
-
const byPk = /* @__PURE__ */ new Map();
|
|
23
|
-
for (const targetRow of targetRows) {
|
|
24
|
-
const key = Reflect.get(targetRow, targetPk.jsKey);
|
|
25
|
-
if (key === null || key === void 0) continue;
|
|
26
|
-
byPk.set(key, targetRow);
|
|
27
|
-
}
|
|
28
|
-
for (const row of rows) {
|
|
29
|
-
const sourceKey = Reflect.get(row, sourceFk.jsKey);
|
|
30
|
-
if (sourceKey === null || sourceKey === void 0) {
|
|
31
|
-
Reflect.set(row, relationKey, null);
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
Reflect.set(row, relationKey, byPk.get(sourceKey) ?? null);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
exports.hydrateOneRelation = hydrateOneRelation;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { findColumnBySqlName, getPrimaryKeyColumn } from "../../internal/table-lookup.mjs";
|
|
2
|
-
//#region src/lib/orm/runtime/hydrate/one.ts
|
|
3
|
-
async function hydrateOneRelation(options) {
|
|
4
|
-
const { rows, relationKey, relationForeignKey, table, targetTable, selectWhereIn } = options;
|
|
5
|
-
const targetPk = getPrimaryKeyColumn(targetTable);
|
|
6
|
-
if (!targetPk) {
|
|
7
|
-
for (const row of rows) Reflect.set(row, relationKey, null);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const sourceFk = findColumnBySqlName(table, relationForeignKey);
|
|
11
|
-
if (!sourceFk) {
|
|
12
|
-
for (const row of rows) Reflect.set(row, relationKey, null);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const fkValues = /* @__PURE__ */ new Set();
|
|
16
|
-
for (const row of rows) {
|
|
17
|
-
const value = Reflect.get(row, sourceFk.jsKey);
|
|
18
|
-
if (value === null || value === void 0) continue;
|
|
19
|
-
fkValues.add(value);
|
|
20
|
-
}
|
|
21
|
-
const targetRows = await selectWhereIn(targetTable, targetPk.col.meta.sqlName, Array.from(fkValues));
|
|
22
|
-
const byPk = /* @__PURE__ */ new Map();
|
|
23
|
-
for (const targetRow of targetRows) {
|
|
24
|
-
const key = Reflect.get(targetRow, targetPk.jsKey);
|
|
25
|
-
if (key === null || key === void 0) continue;
|
|
26
|
-
byPk.set(key, targetRow);
|
|
27
|
-
}
|
|
28
|
-
for (const row of rows) {
|
|
29
|
-
const sourceKey = Reflect.get(row, sourceFk.jsKey);
|
|
30
|
-
if (sourceKey === null || sourceKey === void 0) {
|
|
31
|
-
Reflect.set(row, relationKey, null);
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
Reflect.set(row, relationKey, byPk.get(sourceKey) ?? null);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { hydrateOneRelation };
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=one.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"one.mjs","names":[],"sources":["../../../../src/lib/orm/runtime/hydrate/one.ts"],"sourcesContent":["import {\n findColumnBySqlName,\n getPrimaryKeyColumn,\n} from \"../../internal/table.js\";\nimport type { Table } from \"../../table.js\";\nimport type { ColDefs, TableRow } from \"../../types.js\";\nimport type { SelectWhereIn } from \"./types.js\";\n\nexport async function hydrateOneRelation<T extends ColDefs>(options: {\n rows: TableRow<T>[];\n relationKey: string;\n relationForeignKey: string;\n table: Table<T>;\n targetTable: Table<ColDefs>;\n selectWhereIn: SelectWhereIn;\n}) {\n const {\n rows,\n relationKey,\n relationForeignKey,\n table,\n targetTable,\n selectWhereIn,\n } = options;\n\n const targetPk = getPrimaryKeyColumn(targetTable);\n\n if (!targetPk) {\n for (const row of rows) {\n Reflect.set(row as Record<string, unknown>, relationKey, null);\n }\n\n return;\n }\n\n const sourceFk = findColumnBySqlName(table, relationForeignKey);\n\n if (!sourceFk) {\n for (const row of rows) {\n Reflect.set(row as Record<string, unknown>, relationKey, null);\n }\n\n return;\n }\n\n const fkValues = new Set<unknown>();\n\n for (const row of rows) {\n const value = Reflect.get(row as Record<string, unknown>, sourceFk.jsKey);\n\n if (value === null || value === undefined) {\n continue;\n }\n\n fkValues.add(value);\n }\n\n const targetRows = await selectWhereIn(\n targetTable,\n targetPk.col.meta.sqlName,\n Array.from(fkValues),\n );\n\n const byPk = new Map<unknown, Record<string, unknown>>();\n\n for (const targetRow of targetRows) {\n const key = Reflect.get(targetRow, targetPk.jsKey);\n\n if (key === null || key === undefined) {\n continue;\n }\n\n byPk.set(key, targetRow);\n }\n\n for (const row of rows) {\n const sourceKey = Reflect.get(\n row as Record<string, unknown>,\n sourceFk.jsKey,\n );\n\n if (sourceKey === null || sourceKey === undefined) {\n Reflect.set(row as Record<string, unknown>, relationKey, null);\n continue;\n }\n\n Reflect.set(\n row as Record<string, unknown>,\n relationKey,\n byPk.get(sourceKey) ?? null,\n );\n }\n}\n"],"mappings":";;AAQA,eAAsB,mBAAsC,SAOzD;CACD,MAAM,EACJ,MACA,aACA,oBACA,OACA,aACA,kBACE;CAEJ,MAAM,WAAW,oBAAoB,YAAY;AAEjD,KAAI,CAAC,UAAU;AACb,OAAK,MAAM,OAAO,KAChB,SAAQ,IAAI,KAAgC,aAAa,KAAK;AAGhE;;CAGF,MAAM,WAAW,oBAAoB,OAAO,mBAAmB;AAE/D,KAAI,CAAC,UAAU;AACb,OAAK,MAAM,OAAO,KAChB,SAAQ,IAAI,KAAgC,aAAa,KAAK;AAGhE;;CAGF,MAAM,2BAAW,IAAI,KAAc;AAEnC,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,QAAQ,IAAI,KAAgC,SAAS,MAAM;AAEzE,MAAI,UAAU,QAAQ,UAAU,KAAA,EAC9B;AAGF,WAAS,IAAI,MAAM;;CAGrB,MAAM,aAAa,MAAM,cACvB,aACA,SAAS,IAAI,KAAK,SAClB,MAAM,KAAK,SAAS,CACrB;CAED,MAAM,uBAAO,IAAI,KAAuC;AAExD,MAAK,MAAM,aAAa,YAAY;EAClC,MAAM,MAAM,QAAQ,IAAI,WAAW,SAAS,MAAM;AAElD,MAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B;AAGF,OAAK,IAAI,KAAK,UAAU;;AAG1B,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,YAAY,QAAQ,IACxB,KACA,SAAS,MACV;AAED,MAAI,cAAc,QAAQ,cAAc,KAAA,GAAW;AACjD,WAAQ,IAAI,KAAgC,aAAa,KAAK;AAC9D;;AAGF,UAAQ,IACN,KACA,aACA,KAAK,IAAI,UAAU,IAAI,KACxB"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const require_table_columns = require("../internal/table-columns.cjs");
|
|
2
|
-
const require_table_lookup = require("../internal/table-lookup.cjs");
|
|
3
|
-
const require_many = require("./hydrate/many.cjs");
|
|
4
|
-
const require_one = require("./hydrate/one.cjs");
|
|
5
|
-
//#region src/lib/orm/runtime/hydrate.ts
|
|
6
|
-
function createRelationHydrator(context) {
|
|
7
|
-
const selectWhereIn = async (targetTable, sqlColumnName, values) => {
|
|
8
|
-
if (values.length === 0) return [];
|
|
9
|
-
const columns = require_table_columns.buildSelectColumns(context.sql, targetTable);
|
|
10
|
-
const rows = await context.executeOrThrow(context.sql`SELECT ${columns} FROM ${context.sql(targetTable.tableName)} WHERE ${context.sql(targetTable.tableName)}.${context.sql(sqlColumnName)} IN ${context.sql(values)}`);
|
|
11
|
-
return context.normalizeRowsForTable(targetTable, rows);
|
|
12
|
-
};
|
|
13
|
-
return async (rows, include) => {
|
|
14
|
-
if (!include) return rows;
|
|
15
|
-
const basePk = require_table_lookup.getPrimaryKeyColumn(context.table);
|
|
16
|
-
if (!basePk) return rows;
|
|
17
|
-
for (const [relationKey, enabled] of Object.entries(include)) {
|
|
18
|
-
if (enabled !== true) continue;
|
|
19
|
-
const relation = context.relations[relationKey];
|
|
20
|
-
if (!relation) continue;
|
|
21
|
-
const targetTable = relation.table();
|
|
22
|
-
if (relation.kind === "one") {
|
|
23
|
-
await require_one.hydrateOneRelation({
|
|
24
|
-
rows,
|
|
25
|
-
relationKey,
|
|
26
|
-
relationForeignKey: relation.foreignKey,
|
|
27
|
-
table: context.table,
|
|
28
|
-
targetTable,
|
|
29
|
-
selectWhereIn
|
|
30
|
-
});
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
await require_many.hydrateManyRelation({
|
|
34
|
-
rows,
|
|
35
|
-
relationKey,
|
|
36
|
-
relationForeignKey: relation.foreignKey,
|
|
37
|
-
table: context.table,
|
|
38
|
-
targetTable,
|
|
39
|
-
basePk,
|
|
40
|
-
allRelations: context.allRelations,
|
|
41
|
-
allTables: context.allTables,
|
|
42
|
-
selectWhereIn
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return rows;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
exports.createRelationHydrator = createRelationHydrator;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { buildSelectColumns } from "../internal/table-columns.mjs";
|
|
2
|
-
import { getPrimaryKeyColumn } from "../internal/table-lookup.mjs";
|
|
3
|
-
import { hydrateManyRelation } from "./hydrate/many.mjs";
|
|
4
|
-
import { hydrateOneRelation } from "./hydrate/one.mjs";
|
|
5
|
-
//#region src/lib/orm/runtime/hydrate.ts
|
|
6
|
-
function createRelationHydrator(context) {
|
|
7
|
-
const selectWhereIn = async (targetTable, sqlColumnName, values) => {
|
|
8
|
-
if (values.length === 0) return [];
|
|
9
|
-
const columns = buildSelectColumns(context.sql, targetTable);
|
|
10
|
-
const rows = await context.executeOrThrow(context.sql`SELECT ${columns} FROM ${context.sql(targetTable.tableName)} WHERE ${context.sql(targetTable.tableName)}.${context.sql(sqlColumnName)} IN ${context.sql(values)}`);
|
|
11
|
-
return context.normalizeRowsForTable(targetTable, rows);
|
|
12
|
-
};
|
|
13
|
-
return async (rows, include) => {
|
|
14
|
-
if (!include) return rows;
|
|
15
|
-
const basePk = getPrimaryKeyColumn(context.table);
|
|
16
|
-
if (!basePk) return rows;
|
|
17
|
-
for (const [relationKey, enabled] of Object.entries(include)) {
|
|
18
|
-
if (enabled !== true) continue;
|
|
19
|
-
const relation = context.relations[relationKey];
|
|
20
|
-
if (!relation) continue;
|
|
21
|
-
const targetTable = relation.table();
|
|
22
|
-
if (relation.kind === "one") {
|
|
23
|
-
await hydrateOneRelation({
|
|
24
|
-
rows,
|
|
25
|
-
relationKey,
|
|
26
|
-
relationForeignKey: relation.foreignKey,
|
|
27
|
-
table: context.table,
|
|
28
|
-
targetTable,
|
|
29
|
-
selectWhereIn
|
|
30
|
-
});
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
await hydrateManyRelation({
|
|
34
|
-
rows,
|
|
35
|
-
relationKey,
|
|
36
|
-
relationForeignKey: relation.foreignKey,
|
|
37
|
-
table: context.table,
|
|
38
|
-
targetTable,
|
|
39
|
-
basePk,
|
|
40
|
-
allRelations: context.allRelations,
|
|
41
|
-
allTables: context.allTables,
|
|
42
|
-
selectWhereIn
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return rows;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { createRelationHydrator };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=hydrate.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hydrate.mjs","names":[],"sources":["../../../src/lib/orm/runtime/hydrate.ts"],"sourcesContent":["import { buildSelectColumns, getPrimaryKeyColumn } from \"../internal/table.js\";\nimport type { Table } from \"../table.js\";\nimport type {\n ColDefs,\n FindManyInput,\n RelationDefs,\n TableRow,\n} from \"../types.js\";\nimport { hydrateManyRelation } from \"./hydrate/many.js\";\nimport { hydrateOneRelation } from \"./hydrate/one.js\";\nimport type { HydratorContext } from \"./hydrate/types.js\";\n\nexport function createRelationHydrator<\n T extends ColDefs,\n TRels extends RelationDefs,\n>(context: HydratorContext<T, TRels>) {\n const selectWhereIn = async (\n targetTable: Table<ColDefs>,\n sqlColumnName: string,\n values: unknown[],\n ) => {\n if (values.length === 0) {\n return [];\n }\n\n const columns = buildSelectColumns(context.sql, targetTable);\n const rows = await context.executeOrThrow(\n context.sql`SELECT ${columns} FROM ${context.sql(targetTable.tableName)} WHERE ${context.sql(targetTable.tableName)}.${context.sql(sqlColumnName)} IN ${context.sql(values)}`,\n );\n\n return context.normalizeRowsForTable(\n targetTable,\n rows as Record<string, unknown>[],\n );\n };\n\n return async (\n rows: TableRow<T>[],\n include: FindManyInput<T, TRels>[\"include\"] | undefined,\n ) => {\n if (!include) {\n return rows;\n }\n\n const basePk = getPrimaryKeyColumn(context.table);\n\n if (!basePk) {\n return rows;\n }\n\n for (const [relationKey, enabled] of Object.entries(include)) {\n if (enabled !== true) {\n continue;\n }\n\n const relation = context.relations[relationKey as keyof TRels];\n\n if (!relation) {\n continue;\n }\n\n const targetTable = relation.table();\n\n if (relation.kind === \"one\") {\n await hydrateOneRelation({\n rows,\n relationKey,\n relationForeignKey: relation.foreignKey,\n table: context.table,\n targetTable,\n selectWhereIn,\n });\n\n continue;\n }\n\n await hydrateManyRelation({\n rows,\n relationKey,\n relationForeignKey: relation.foreignKey,\n table: context.table,\n targetTable,\n basePk,\n allRelations: context.allRelations,\n allTables: context.allTables,\n selectWhereIn,\n });\n }\n\n return rows;\n };\n}\n"],"mappings":";;;;;AAYA,SAAgB,uBAGd,SAAoC;CACpC,MAAM,gBAAgB,OACpB,aACA,eACA,WACG;AACH,MAAI,OAAO,WAAW,EACpB,QAAO,EAAE;EAGX,MAAM,UAAU,mBAAmB,QAAQ,KAAK,YAAY;EAC5D,MAAM,OAAO,MAAM,QAAQ,eACzB,QAAQ,GAAG,UAAU,QAAQ,QAAQ,QAAQ,IAAI,YAAY,UAAU,CAAC,SAAS,QAAQ,IAAI,YAAY,UAAU,CAAC,GAAG,QAAQ,IAAI,cAAc,CAAC,MAAM,QAAQ,IAAI,OAAO,GAC5K;AAED,SAAO,QAAQ,sBACb,aACA,KACD;;AAGH,QAAO,OACL,MACA,YACG;AACH,MAAI,CAAC,QACH,QAAO;EAGT,MAAM,SAAS,oBAAoB,QAAQ,MAAM;AAEjD,MAAI,CAAC,OACH,QAAO;AAGT,OAAK,MAAM,CAAC,aAAa,YAAY,OAAO,QAAQ,QAAQ,EAAE;AAC5D,OAAI,YAAY,KACd;GAGF,MAAM,WAAW,QAAQ,UAAU;AAEnC,OAAI,CAAC,SACH;GAGF,MAAM,cAAc,SAAS,OAAO;AAEpC,OAAI,SAAS,SAAS,OAAO;AAC3B,UAAM,mBAAmB;KACvB;KACA;KACA,oBAAoB,SAAS;KAC7B,OAAO,QAAQ;KACf;KACA;KACD,CAAC;AAEF;;AAGF,SAAM,oBAAoB;IACxB;IACA;IACA,oBAAoB,SAAS;IAC7B,OAAO,QAAQ;IACf;IACA;IACA,cAAc,QAAQ;IACtB,WAAW,QAAQ;IACnB;IACD,CAAC;;AAGJ,SAAO"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const require_parse_array = require("../sql/parse-array.cjs");
|
|
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 = require_parse_array.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
|
-
exports.normalizeRows = normalizeRows;
|
|
30
|
-
exports.normalizeRowsForTable = normalizeRowsForTable;
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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;
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,64 +0,0 @@
|
|
|
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;
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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;
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,95 +0,0 @@
|
|
|
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;
|