joist-core 2.3.0-next.77 → 2.3.0-next.78
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/build/index.cjs +1 -0
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +2 -2
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +2 -2
- package/build/index.d.mts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/query.cjs +95 -13
- package/build/query.cjs.map +1 -1
- package/build/query.d.cts +51 -3
- package/build/query.d.cts.map +1 -1
- package/build/query.d.mts +51 -3
- package/build/query.d.mts.map +1 -1
- package/build/query.js +95 -14
- package/build/query.js.map +1 -1
- package/package.json +2 -2
package/build/index.cjs
CHANGED
|
@@ -470,6 +470,7 @@ exports.plainTimeMapper = require_temporalMappers.plainTimeMapper;
|
|
|
470
470
|
exports.polymorphicField = require_fieldSerde.polymorphicField;
|
|
471
471
|
exports.query = require_query.query;
|
|
472
472
|
exports.rangeValueRule = require_rules.rangeValueRule;
|
|
473
|
+
exports.recursiveQuery = require_query.recursiveQuery;
|
|
473
474
|
exports.requireTemporal = require_temporal.requireTemporal;
|
|
474
475
|
exports.resetBootFlag = require_config.resetBootFlag;
|
|
475
476
|
exports.resetDefaultEntityLimit = require_EntityManager.resetDefaultEntityLimit;
|
package/build/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["getMetadata","getProperties","getBaseMeta","getField","AbstractRelationImpl","isLazyField","isProperty","isAsyncProperty","isReactiveGetter","isReactiveField","isAsyncReactiveField","FactoryInitialValue","ReactiveFieldImpl","AsyncReactiveFieldImpl","getInstanceData"],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"./BaseEntity.ts\";\nimport { getDefaultDependencies } from \"./defaults.ts\";\nimport { buildWhereClause } from \"./drivers/buildUtils.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"./EntityMetadata.ts\";\nimport { getField, setField } from \"./fields.ts\";\nimport { getProperties } from \"./getProperties.ts\";\nimport { type New } from \"./loadHints.ts\";\nimport { isAllSqlPaths } from \"./loadLens.ts\";\nimport { FactoryInitialValue } from \"./newTestInstance.ts\";\nimport { partitionHint } from \"./preloading/partitionHint.ts\";\nimport { AbstractRelationImpl } from \"./relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"./relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"./relations/index.ts\";\nimport { ReactiveFieldImpl } from \"./relations/ReactiveField.ts\";\nimport { type OptsOf } from \"./typeMap.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"./AliasAssigner.ts\";\nexport {\n type ConditionGroup,\n type DomainPredicate,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"./conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"./Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableFor,\n type TableMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"./Tables.ts\";\nexport { BaseEntity, getInstanceData } from \"./BaseEntity.ts\";\nexport { ConditionBuilder } from \"./ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nexport type * from \"./EntityFields.ts\";\nexport * from \"./EntityFilter.ts\";\nexport * from \"./EntityGraphQLFilter.ts\";\nexport * from \"./EntityManager.ts\";\nexport * from \"./EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"./execute.ts\";\nexport type { EnumMetadata } from \"./EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport { type Expr, type ExprBrand, exprBrand, type ExprLike, type InnerJoin, type LeftJoin } from \"./Expr.ts\";\nexport { skipCondition } from \"./skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"./HintTree.ts\";\nexport { InstanceData } from \"./InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"./JoinRows.ts\";\nexport type * from \"./PendingChanges.ts\";\nexport { Plugin } from \"./PluginManager.ts\";\nexport * from \"./QueryParser.ts\";\nexport * from \"./QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"./QueryVisitor.ts\";\nexport * from \"./RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"./Todo.ts\";\nexport * from \"./changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"./config.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"./configure.ts\";\nexport { driverApi } from \"./driverApi.ts\";\nexport * from \"./drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"./fields.ts\";\nexport * from \"./getProperties.ts\";\nexport * from \"./json.ts\";\nexport * from \"./keys.ts\";\nexport { kq, kqDot, kqStar } from \"./keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"./loadHints.ts\";\nexport * from \"./loadLens.ts\";\nexport { setFactoryWriter } from \"./logging/FactoryLogger.ts\";\nexport * from \"./logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"./logging/ReactionLogger.ts\";\nexport { lazyField } from \"./newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"./newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"./normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"./plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"./plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"./preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseUserQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoins,\n type QueryOrderBy,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n type ScalarQuery,\n type SetQuery,\n query,\n sql,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"./query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"./reactiveHints.ts\";\nexport * from \"./relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"./rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"./runtimeConfig.ts\";\nexport { nowUTC } from \"./nowUTC.ts\";\nexport * from \"./serde.ts\";\nexport * from \"./columns.ts\";\nexport * from \"./fieldSerde.ts\";\nexport * from \"./scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"./temporal.ts\";\nexport * from \"./temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"./trusted.ts\";\nexport type * from \"./typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"./unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"./upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"./utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"./withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id; otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" ? getField(entity, key) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["getMetadata","getProperties","getBaseMeta","getField","AbstractRelationImpl","isLazyField","isProperty","isAsyncProperty","isReactiveGetter","isReactiveField","isAsyncReactiveField","FactoryInitialValue","ReactiveFieldImpl","AsyncReactiveFieldImpl","getInstanceData"],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"./BaseEntity.ts\";\nimport { getDefaultDependencies } from \"./defaults.ts\";\nimport { buildWhereClause } from \"./drivers/buildUtils.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"./EntityMetadata.ts\";\nimport { getField, setField } from \"./fields.ts\";\nimport { getProperties } from \"./getProperties.ts\";\nimport { type New } from \"./loadHints.ts\";\nimport { isAllSqlPaths } from \"./loadLens.ts\";\nimport { FactoryInitialValue } from \"./newTestInstance.ts\";\nimport { partitionHint } from \"./preloading/partitionHint.ts\";\nimport { AbstractRelationImpl } from \"./relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"./relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"./relations/index.ts\";\nimport { ReactiveFieldImpl } from \"./relations/ReactiveField.ts\";\nimport { type OptsOf } from \"./typeMap.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"./AliasAssigner.ts\";\nexport {\n type ConditionGroup,\n type DomainPredicate,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"./conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"./Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableFor,\n type TableMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"./Tables.ts\";\nexport { BaseEntity, getInstanceData } from \"./BaseEntity.ts\";\nexport { ConditionBuilder } from \"./ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nexport type * from \"./EntityFields.ts\";\nexport * from \"./EntityFilter.ts\";\nexport * from \"./EntityGraphQLFilter.ts\";\nexport * from \"./EntityManager.ts\";\nexport * from \"./EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"./execute.ts\";\nexport type { EnumMetadata } from \"./EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport { type Expr, type ExprBrand, exprBrand, type ExprLike, type InnerJoin, type LeftJoin } from \"./Expr.ts\";\nexport { skipCondition } from \"./skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"./HintTree.ts\";\nexport { InstanceData } from \"./InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"./JoinRows.ts\";\nexport type * from \"./PendingChanges.ts\";\nexport { Plugin } from \"./PluginManager.ts\";\nexport * from \"./QueryParser.ts\";\nexport * from \"./QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"./QueryVisitor.ts\";\nexport * from \"./RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"./Todo.ts\";\nexport * from \"./changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"./config.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"./configure.ts\";\nexport { driverApi } from \"./driverApi.ts\";\nexport * from \"./drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"./fields.ts\";\nexport * from \"./getProperties.ts\";\nexport * from \"./json.ts\";\nexport * from \"./keys.ts\";\nexport { kq, kqDot, kqStar } from \"./keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"./loadHints.ts\";\nexport * from \"./loadLens.ts\";\nexport { setFactoryWriter } from \"./logging/FactoryLogger.ts\";\nexport * from \"./logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"./logging/ReactionLogger.ts\";\nexport { lazyField } from \"./newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"./newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"./normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"./plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"./plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"./preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseUserQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoins,\n type QueryOrderBy,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ScalarQuery,\n type SetQuery,\n query,\n sql,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"./query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"./reactiveHints.ts\";\nexport * from \"./relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"./rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"./runtimeConfig.ts\";\nexport { nowUTC } from \"./nowUTC.ts\";\nexport * from \"./serde.ts\";\nexport * from \"./columns.ts\";\nexport * from \"./fieldSerde.ts\";\nexport * from \"./scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"./temporal.ts\";\nexport * from \"./temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"./trusted.ts\";\nexport type * from \"./typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"./unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"./upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"./utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"./withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id; otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" ? getField(entity, key) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":"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"}
|
package/build/index.d.cts
CHANGED
|
@@ -65,7 +65,7 @@ import { BooleanGraphQLFilter, EntityGraphQLFilter, GraphQLFilterAndSettings, Gr
|
|
|
65
65
|
import { EntityOrId, HintNode } from "./HintTree.cjs";
|
|
66
66
|
import { JoinResult, PreloadHydrator, PreloadPlugin } from "./plugins/PreloadPlugin.cjs";
|
|
67
67
|
import { Driver, DriverQueryResult } from "./drivers/Driver.cjs";
|
|
68
|
-
import { CheckScope, Clauses, EntityQuery, ExistsQuery, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, Query, QueryArg, QueryCondition, QueryJoin, QueryJoins, QueryOrderBy, QueryRow, QuerySelect, QuerySource, QueryValue, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, sql, subqueryBrand } from "./query.cjs";
|
|
68
|
+
import { CheckScope, Clauses, EntityQuery, ExistsQuery, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, Query, QueryArg, QueryCondition, QueryJoin, QueryJoins, QueryOrderBy, QueryRow, QuerySelect, QuerySource, QueryValue, RecursiveOptions, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, recursiveQuery, sql, subqueryBrand } from "./query.cjs";
|
|
69
69
|
import { DeleteStatement, ExecuteResult, InsertStatement, InsertValues, MutationReturning, MutationStatement, UpdateStatement, UpdateValues } from "./execute.cjs";
|
|
70
70
|
import { skipCondition } from "./skipCondition.cjs";
|
|
71
71
|
import { InstanceData } from "./InstanceData.cjs";
|
|
@@ -168,5 +168,5 @@ declare function failNoIdYet(entity: string): never;
|
|
|
168
168
|
*/
|
|
169
169
|
declare function isNewEntity<T extends Entity>(entity: T): entity is New<T>;
|
|
170
170
|
//#endregion
|
|
171
|
-
export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type CheckScope, type Clauses, type Collection, type CollectionJoin, Column, ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type ExecuteResult, ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprLike, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, Flavor, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, type NotWidened, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, ParsedEntityFilter, ParsedExpressionCondition, ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, ParsedValueFilter, PartialOrNull, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoins, type QueryOrderBy, type QueryRow, type QuerySelect, type QuerySource, type QueryValue, RandomUuidAssigner, RawCondition, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type SqlPredicate, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
171
|
+
export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type CheckScope, type Clauses, type Collection, type CollectionJoin, Column, ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type ExecuteResult, ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprLike, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, Flavor, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, type NotWidened, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, ParsedEntityFilter, ParsedExpressionCondition, ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, ParsedValueFilter, PartialOrNull, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoins, type QueryOrderBy, type QueryRow, type QuerySelect, type QuerySource, type QueryValue, RandomUuidAssigner, RawCondition, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type RecursiveOptions, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type SqlPredicate, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
172
172
|
//# sourceMappingURL=index.d.cts.map
|
package/build/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;UAiOH,UAAU;EAClB,QAAQ;;KAGE,OAAO,GAAG,WAAW,IAAI,UAAU;;;;;;;;;;;;;;;iBAgB/B,QAAQ,UAAU,QAChC,QAAQ,GACR,QAAQ,QAAQ,OAAO,iBACvB;EAAS;EAAmB;;;;;;;;;iBAoBd,OAAO,UAAU,QAC/B,MAAM,eAAe,IACrB,QAAQ,GACR,aACA,aACA,mBACA;iBAwDc,iBAAiB,QAAQ,QAAQ;;KAOrC,cAAc,QACvB,WAAW,KAAK,EAAE;iBAGL,gBAAgB,UAAU,QAAQ,QAAQ;iBAC1C,gBAAgB,UAAU,QAAQ,MAAM,kBAAkB;iBAO1D,aAAa,QAAQ,SAAS;iBAM9B,mBAAmB,QAAQ,kBAAkB;;iBAO7C,eAAe,UAAU,QAAQ,MAAM,+BAA+B,KAAK,kBAAkB;;;;;;;;cAWhG,kBAAkB;;iBAGf,YAAY;;;;;;iBASZ,YAAY,UAAU,QAAQ,QAAQ,IAAI,UAAU,IAAI"}
|
package/build/index.d.mts
CHANGED
|
@@ -65,7 +65,7 @@ import { BooleanGraphQLFilter, EntityGraphQLFilter, GraphQLFilterAndSettings, Gr
|
|
|
65
65
|
import { EntityOrId, HintNode } from "./HintTree.mjs";
|
|
66
66
|
import { JoinResult, PreloadHydrator, PreloadPlugin } from "./plugins/PreloadPlugin.mjs";
|
|
67
67
|
import { Driver, DriverQueryResult } from "./drivers/Driver.mjs";
|
|
68
|
-
import { CheckScope, Clauses, EntityQuery, ExistsQuery, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, Query, QueryArg, QueryCondition, QueryJoin, QueryJoins, QueryOrderBy, QueryRow, QuerySelect, QuerySource, QueryValue, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, sql, subqueryBrand } from "./query.mjs";
|
|
68
|
+
import { CheckScope, Clauses, EntityQuery, ExistsQuery, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, Query, QueryArg, QueryCondition, QueryJoin, QueryJoins, QueryOrderBy, QueryRow, QuerySelect, QuerySource, QueryValue, RecursiveOptions, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, recursiveQuery, sql, subqueryBrand } from "./query.mjs";
|
|
69
69
|
import { DeleteStatement, ExecuteResult, InsertStatement, InsertValues, MutationReturning, MutationStatement, UpdateStatement, UpdateValues } from "./execute.mjs";
|
|
70
70
|
import { skipCondition } from "./skipCondition.mjs";
|
|
71
71
|
import { InstanceData } from "./InstanceData.mjs";
|
|
@@ -168,5 +168,5 @@ declare function failNoIdYet(entity: string): never;
|
|
|
168
168
|
*/
|
|
169
169
|
declare function isNewEntity<T extends Entity>(entity: T): entity is New<T>;
|
|
170
170
|
//#endregion
|
|
171
|
-
export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type CheckScope, type Clauses, type Collection, type CollectionJoin, Column, ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type ExecuteResult, ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprLike, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, Flavor, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, type NotWidened, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, ParsedEntityFilter, ParsedExpressionCondition, ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, ParsedValueFilter, PartialOrNull, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoins, type QueryOrderBy, type QueryRow, type QuerySelect, type QuerySource, type QueryValue, RandomUuidAssigner, RawCondition, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type SqlPredicate, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
171
|
+
export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type CheckScope, type Clauses, type Collection, type CollectionJoin, Column, ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type ExecuteResult, ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprLike, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, Flavor, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, type NotWidened, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, ParsedEntityFilter, ParsedExpressionCondition, ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, ParsedValueFilter, PartialOrNull, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoins, type QueryOrderBy, type QueryRow, type QuerySelect, type QuerySource, type QueryValue, RandomUuidAssigner, RawCondition, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type RecursiveOptions, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type SqlPredicate, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
172
172
|
//# sourceMappingURL=index.d.mts.map
|
package/build/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;UAiOH,UAAU;EAClB,QAAQ;;KAGE,OAAO,GAAG,WAAW,IAAI,UAAU;;;;;;;;;;;;;;;iBAgB/B,QAAQ,UAAU,QAChC,QAAQ,GACR,QAAQ,QAAQ,OAAO,iBACvB;EAAS;EAAmB;;;;;;;;;iBAoBd,OAAO,UAAU,QAC/B,MAAM,eAAe,IACrB,QAAQ,GACR,aACA,aACA,mBACA;iBAwDc,iBAAiB,QAAQ,QAAQ;;KAOrC,cAAc,QACvB,WAAW,KAAK,EAAE;iBAGL,gBAAgB,UAAU,QAAQ,QAAQ;iBAC1C,gBAAgB,UAAU,QAAQ,MAAM,kBAAkB;iBAO1D,aAAa,QAAQ,SAAS;iBAM9B,mBAAmB,QAAQ,kBAAkB;;iBAO7C,eAAe,UAAU,QAAQ,MAAM,+BAA+B,KAAK,kBAAkB;;;;;;;;cAWhG,kBAAkB;;iBAGf,YAAY;;;;;;iBASZ,YAAY,UAAU,QAAQ,QAAQ,IAAI,UAAU,IAAI"}
|
package/build/index.js
CHANGED
|
@@ -79,7 +79,7 @@ import { toJSON } from "./json.js";
|
|
|
79
79
|
import { FieldLogger, noopFieldLogger } from "./logging/FieldLogger.js";
|
|
80
80
|
import { ImmutableEntitiesPlugin } from "./plugins/ImmutableEntitiesPlugin.js";
|
|
81
81
|
import { JsonAggregatePreloader } from "./preloading/JsonAggregatePreloader.js";
|
|
82
|
-
import { entityQueryBrand, query, sql, subqueryBrand } from "./query.js";
|
|
82
|
+
import { entityQueryBrand, query, recursiveQuery, sql, subqueryBrand } from "./query.js";
|
|
83
83
|
import { ValidationCode, ValidationErrors, cannotBeChanged, cannotBeUpdated, maxValueRule, minValueRule, mustBeSubType, newRequiredLazyFieldRule, newRequiredRule, rangeValueRule } from "./rules.js";
|
|
84
84
|
import { nowUTC } from "./nowUTC.js";
|
|
85
85
|
import { updatePartial, upsert } from "./upsert.js";
|
|
@@ -188,6 +188,6 @@ function isNewEntity(entity) {
|
|
|
188
188
|
return entity.isNewEntity;
|
|
189
189
|
}
|
|
190
190
|
//#endregion
|
|
191
|
-
export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, Column, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FieldColumn, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolyComponent, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, SimpleFieldSerde, StubbedRelation, SuperstructSerde, Temporal, TestUuidAssigner, Todo, TooManyError, UnknownProperty, ValidationCode, ValidationErrors, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
191
|
+
export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, Column, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FieldColumn, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolyComponent, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, SimpleFieldSerde, StubbedRelation, SuperstructSerde, Temporal, TestUuidAssigner, Todo, TooManyError, UnknownProperty, ValidationCode, ValidationErrors, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
|
|
192
192
|
|
|
193
193
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"./BaseEntity.ts\";\nimport { getDefaultDependencies } from \"./defaults.ts\";\nimport { buildWhereClause } from \"./drivers/buildUtils.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"./EntityMetadata.ts\";\nimport { getField, setField } from \"./fields.ts\";\nimport { getProperties } from \"./getProperties.ts\";\nimport { type New } from \"./loadHints.ts\";\nimport { isAllSqlPaths } from \"./loadLens.ts\";\nimport { FactoryInitialValue } from \"./newTestInstance.ts\";\nimport { partitionHint } from \"./preloading/partitionHint.ts\";\nimport { AbstractRelationImpl } from \"./relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"./relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"./relations/index.ts\";\nimport { ReactiveFieldImpl } from \"./relations/ReactiveField.ts\";\nimport { type OptsOf } from \"./typeMap.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"./AliasAssigner.ts\";\nexport {\n type ConditionGroup,\n type DomainPredicate,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"./conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"./Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableFor,\n type TableMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"./Tables.ts\";\nexport { BaseEntity, getInstanceData } from \"./BaseEntity.ts\";\nexport { ConditionBuilder } from \"./ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nexport type * from \"./EntityFields.ts\";\nexport * from \"./EntityFilter.ts\";\nexport * from \"./EntityGraphQLFilter.ts\";\nexport * from \"./EntityManager.ts\";\nexport * from \"./EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"./execute.ts\";\nexport type { EnumMetadata } from \"./EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport { type Expr, type ExprBrand, exprBrand, type ExprLike, type InnerJoin, type LeftJoin } from \"./Expr.ts\";\nexport { skipCondition } from \"./skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"./HintTree.ts\";\nexport { InstanceData } from \"./InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"./JoinRows.ts\";\nexport type * from \"./PendingChanges.ts\";\nexport { Plugin } from \"./PluginManager.ts\";\nexport * from \"./QueryParser.ts\";\nexport * from \"./QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"./QueryVisitor.ts\";\nexport * from \"./RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"./Todo.ts\";\nexport * from \"./changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"./config.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"./configure.ts\";\nexport { driverApi } from \"./driverApi.ts\";\nexport * from \"./drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"./fields.ts\";\nexport * from \"./getProperties.ts\";\nexport * from \"./json.ts\";\nexport * from \"./keys.ts\";\nexport { kq, kqDot, kqStar } from \"./keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"./loadHints.ts\";\nexport * from \"./loadLens.ts\";\nexport { setFactoryWriter } from \"./logging/FactoryLogger.ts\";\nexport * from \"./logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"./logging/ReactionLogger.ts\";\nexport { lazyField } from \"./newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"./newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"./normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"./plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"./plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"./preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseUserQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoins,\n type QueryOrderBy,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n type ScalarQuery,\n type SetQuery,\n query,\n sql,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"./query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"./reactiveHints.ts\";\nexport * from \"./relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"./rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"./runtimeConfig.ts\";\nexport { nowUTC } from \"./nowUTC.ts\";\nexport * from \"./serde.ts\";\nexport * from \"./columns.ts\";\nexport * from \"./fieldSerde.ts\";\nexport * from \"./scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"./temporal.ts\";\nexport * from \"./temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"./trusted.ts\";\nexport type * from \"./typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"./unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"./upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"./utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"./withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id; otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" ? getField(entity, key) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"./BaseEntity.ts\";\nimport { getDefaultDependencies } from \"./defaults.ts\";\nimport { buildWhereClause } from \"./drivers/buildUtils.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"./EntityMetadata.ts\";\nimport { getField, setField } from \"./fields.ts\";\nimport { getProperties } from \"./getProperties.ts\";\nimport { type New } from \"./loadHints.ts\";\nimport { isAllSqlPaths } from \"./loadLens.ts\";\nimport { FactoryInitialValue } from \"./newTestInstance.ts\";\nimport { partitionHint } from \"./preloading/partitionHint.ts\";\nimport { AbstractRelationImpl } from \"./relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"./relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"./relations/index.ts\";\nimport { ReactiveFieldImpl } from \"./relations/ReactiveField.ts\";\nimport { type OptsOf } from \"./typeMap.ts\";\nimport { fail } from \"./utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"./AliasAssigner.ts\";\nexport {\n type ConditionGroup,\n type DomainPredicate,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"./conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"./Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableFor,\n type TableMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"./Tables.ts\";\nexport { BaseEntity, getInstanceData } from \"./BaseEntity.ts\";\nexport { ConditionBuilder } from \"./ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nexport type * from \"./EntityFields.ts\";\nexport * from \"./EntityFilter.ts\";\nexport * from \"./EntityGraphQLFilter.ts\";\nexport * from \"./EntityManager.ts\";\nexport * from \"./EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"./execute.ts\";\nexport type { EnumMetadata } from \"./EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport { type Expr, type ExprBrand, exprBrand, type ExprLike, type InnerJoin, type LeftJoin } from \"./Expr.ts\";\nexport { skipCondition } from \"./skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"./HintTree.ts\";\nexport { InstanceData } from \"./InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"./JoinRows.ts\";\nexport type * from \"./PendingChanges.ts\";\nexport { Plugin } from \"./PluginManager.ts\";\nexport * from \"./QueryParser.ts\";\nexport * from \"./QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"./QueryVisitor.ts\";\nexport * from \"./RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"./Todo.ts\";\nexport * from \"./changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"./config.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"./configure.ts\";\nexport { driverApi } from \"./driverApi.ts\";\nexport * from \"./drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"./fields.ts\";\nexport * from \"./getProperties.ts\";\nexport * from \"./json.ts\";\nexport * from \"./keys.ts\";\nexport { kq, kqDot, kqStar } from \"./keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"./loadHints.ts\";\nexport * from \"./loadLens.ts\";\nexport { setFactoryWriter } from \"./logging/FactoryLogger.ts\";\nexport * from \"./logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"./logging/ReactionLogger.ts\";\nexport { lazyField } from \"./newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"./newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"./normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"./plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"./plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"./preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseUserQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoins,\n type QueryOrderBy,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ScalarQuery,\n type SetQuery,\n query,\n sql,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"./query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"./reactiveHints.ts\";\nexport * from \"./relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"./rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"./runtimeConfig.ts\";\nexport { nowUTC } from \"./nowUTC.ts\";\nexport * from \"./serde.ts\";\nexport * from \"./columns.ts\";\nexport * from \"./fieldSerde.ts\";\nexport * from \"./scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"./temporal.ts\";\nexport * from \"./temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"./trusted.ts\";\nexport type * from \"./typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"./unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"./upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"./utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"./withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id; otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" ? getField(entity, key) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":"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"}
|
package/build/query.cjs
CHANGED
|
@@ -59,6 +59,46 @@ function query(q) {
|
|
|
59
59
|
else return newSubqueryProxy(handle);
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
+
* Declares a `WITH RECURSIVE` CTE from its two terms, and returns the CTE as a readable value.
|
|
63
|
+
*
|
|
64
|
+
* `base` is the non-recursive term, which seeds the rows and, as in PostgreSQL, supplies the CTE's
|
|
65
|
+
* columns. `step` is the recursive term: it receives the CTE itself, so it can join back to the rows
|
|
66
|
+
* found so far. The two terms are combined with UNION ALL, or UNION when `union: "distinct"` drops
|
|
67
|
+
* duplicates, which is how a cyclic graph is kept from looping forever.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* const [a] = tables(Author);
|
|
71
|
+
* const tree = recursiveQuery(
|
|
72
|
+
* "tree",
|
|
73
|
+
* { from: a, where: a.mentor_id.isNull(), select: { id: a.id, mentorId: a.mentor_id } },
|
|
74
|
+
* (self) => ({
|
|
75
|
+
* from: a,
|
|
76
|
+
* join: [{ inner: self, on: a.mentor_id.eq(self.id) }],
|
|
77
|
+
* select: { id: a.id, mentorId: a.mentor_id },
|
|
78
|
+
* }),
|
|
79
|
+
* );
|
|
80
|
+
* const rows = await em.query({ with: tree, from: tree, select: tree });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* Unlike `query()`, the name is required, because the step term must name it.
|
|
84
|
+
*/
|
|
85
|
+
function recursiveQuery(name, base, step, opts = {}) {
|
|
86
|
+
if (typeof name !== "string" || name === "") require_utils.fail("A recursive CTE needs a name");
|
|
87
|
+
if (opts.union !== void 0 && opts.union !== "all" && opts.union !== "distinct") require_utils.fail("A recursive CTE's union must be 'all' or 'distinct'");
|
|
88
|
+
const handle = new SubqueryHandle(toQuery(base), true);
|
|
89
|
+
if (handle.output().kind !== "pojo") require_utils.fail("A recursive CTE's base term needs a named projection");
|
|
90
|
+
const self = newSubqueryProxy(handle);
|
|
91
|
+
const operands = [base, step(self)];
|
|
92
|
+
handle.setBody(opts.union === "distinct" ? {
|
|
93
|
+
union: operands,
|
|
94
|
+
as: name
|
|
95
|
+
} : {
|
|
96
|
+
unionAll: operands,
|
|
97
|
+
as: name
|
|
98
|
+
});
|
|
99
|
+
return self;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
62
102
|
* Builds a SQL expression from a tagged template.
|
|
63
103
|
*
|
|
64
104
|
* For an Author alias `a` assigned the SQL alias `a1`:
|
|
@@ -147,9 +187,23 @@ function projectionToSql(select, ctx) {
|
|
|
147
187
|
}
|
|
148
188
|
/** The runtime identity of a `query(...)` value; `Ctx.aliasFor` keys on it, like a table's `TableMgmt`. */
|
|
149
189
|
var SubqueryHandle = class {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
190
|
+
recursive;
|
|
191
|
+
#q;
|
|
192
|
+
constructor(q, recursive = false) {
|
|
193
|
+
this.recursive = recursive;
|
|
194
|
+
this.#q = q;
|
|
195
|
+
}
|
|
196
|
+
get q() {
|
|
197
|
+
return this.#q;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Gives a recursive CTE its finished body. `recursiveQuery` starts the handle on its base term, so
|
|
201
|
+
* the step term can read the CTE's columns while the body that will hold that step is still being
|
|
202
|
+
* built. The base term supplies the CTE's columns either way, PostgreSQL's rule for a recursive WITH.
|
|
203
|
+
*/
|
|
204
|
+
setBody(q) {
|
|
205
|
+
if (!this.recursive) require_utils.fail("Only a recursive CTE replaces its body");
|
|
206
|
+
this.#q = q;
|
|
153
207
|
}
|
|
154
208
|
get name() {
|
|
155
209
|
return this.q.as;
|
|
@@ -494,10 +548,11 @@ var OutputExpr = class extends require_Expr.BaseExpr {
|
|
|
494
548
|
* output positions without moving DISTINCT/order/pagination or repeating volatile selected expressions.
|
|
495
549
|
* Parenthesizing each accumulated left side preserves array association and explicit nested grouping.
|
|
496
550
|
*/
|
|
497
|
-
function parseSetQuery(q, parent, assigner) {
|
|
551
|
+
function parseSetQuery(q, parent, assigner, recursiveSelf) {
|
|
498
552
|
const [operation, operands] = setOperands(q);
|
|
499
553
|
const output = queryOutput(q);
|
|
500
554
|
const ctx = new Ctx(assigner, parent);
|
|
555
|
+
if (recursiveSelf) ctx.setRecursiveSelf(recursiveSelf);
|
|
501
556
|
const ctes = registerCtes(q, ctx, assigner);
|
|
502
557
|
const plans = operands.map((operand) => parseQuery(toQuery(operand), ctx, assigner));
|
|
503
558
|
let sql = "";
|
|
@@ -583,6 +638,8 @@ var Ctx = class {
|
|
|
583
638
|
pendingCtes = /* @__PURE__ */ new Map();
|
|
584
639
|
/** CTEs already read by this query's `from`/`join`, so a second read fails instead of colliding. */
|
|
585
640
|
usedCtes = /* @__PURE__ */ new Set();
|
|
641
|
+
/** The recursive CTE whose body this query is part of, if any; see `recursiveSelf`. */
|
|
642
|
+
ownRecursiveSelf;
|
|
586
643
|
outerRefs = /* @__PURE__ */ new Set();
|
|
587
644
|
constructor(assigner, parent) {
|
|
588
645
|
this.assigner = assigner;
|
|
@@ -617,6 +674,18 @@ var Ctx = class {
|
|
|
617
674
|
cteAliasFor(handle) {
|
|
618
675
|
return this.ctes.get(handle) ?? this.parent?.cteAliasFor(handle);
|
|
619
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* The recursive CTE this query's terms belong to, inherited from the enclosing query.
|
|
679
|
+
*
|
|
680
|
+
* PostgreSQL requires a recursive term to reference its own CTE, so that reference is not optional
|
|
681
|
+
* and must survive pruning, unlike an ordinary explicit join that nothing else reads.
|
|
682
|
+
*/
|
|
683
|
+
get recursiveSelf() {
|
|
684
|
+
return this.ownRecursiveSelf ?? this.parent?.recursiveSelf;
|
|
685
|
+
}
|
|
686
|
+
setRecursiveSelf(handle) {
|
|
687
|
+
this.ownRecursiveSelf = handle;
|
|
688
|
+
}
|
|
620
689
|
/** Whether `handle` is a CTE with no SQL yet, i.e. itself or a later `with` entry. */
|
|
621
690
|
isPendingCte(handle) {
|
|
622
691
|
return this.pendingCtes.has(handle) || (this.parent?.isPendingCte(handle) ?? false);
|
|
@@ -662,10 +731,11 @@ function describeHandle(handle) {
|
|
|
662
731
|
* 3. Prune: drop joins nothing references (see below), then reject a kept join whose ON collapsed.
|
|
663
732
|
* 4. Assemble the SQL from the kept fragments, so pruned bindings disappear with their SQL.
|
|
664
733
|
*/
|
|
665
|
-
function parseQuery(q, parent, assigner) {
|
|
734
|
+
function parseQuery(q, parent, assigner, recursiveSelf) {
|
|
666
735
|
validateReadQuery(q);
|
|
667
|
-
if (isSetQuery(q)) return parseSetQuery(q, parent, assigner);
|
|
736
|
+
if (isSetQuery(q)) return parseSetQuery(q, parent, assigner, recursiveSelf);
|
|
668
737
|
const ctx = new Ctx(assigner, parent);
|
|
738
|
+
if (recursiveSelf) ctx.setRecursiveSelf(recursiveSelf);
|
|
669
739
|
const joinEntries = [...q.join ?? []].filter(isDefined);
|
|
670
740
|
const ctes = registerCtes(q, ctx, assigner);
|
|
671
741
|
const parseFrom = registerSource(q.from, ctx, assigner);
|
|
@@ -712,7 +782,7 @@ function parseQuery(q, parent, assigner) {
|
|
|
712
782
|
const having = conditionToSql(q.having, ctx, true);
|
|
713
783
|
const groupBys = (q.groupBy ?? []).map((g) => asExpr(g, "groupBy").toSql(ctx));
|
|
714
784
|
const orderBys = orderBysToSql(q, ctx);
|
|
715
|
-
const { joins: kept, ctes: keptCtes } = pruneJoins(q, from, joins, ctes, [
|
|
785
|
+
const { joins: kept, ctes: keptCtes } = pruneJoins(q, ctx, from, joins, ctes, [
|
|
716
786
|
...selects,
|
|
717
787
|
...groupBys,
|
|
718
788
|
...orderBys,
|
|
@@ -1153,8 +1223,11 @@ function refsOf(parsed) {
|
|
|
1153
1223
|
* CTEs prune on the same rule and through the same dependency map: a `with` entry nothing reads
|
|
1154
1224
|
* anymore drops with the join that read it, and a CTE read only by another CTE survives with it.
|
|
1155
1225
|
* A CTE joined into the query shares its alias with that join, so their dependencies are merged.
|
|
1226
|
+
*
|
|
1227
|
+
* The one join that never prunes is a recursive term's reference to its own CTE: PostgreSQL requires
|
|
1228
|
+
* it, so it is not the caller's optional filter (see `Ctx.recursiveSelf`).
|
|
1156
1229
|
*/
|
|
1157
|
-
function pruneJoins(q, from, joins, ctes, used) {
|
|
1230
|
+
function pruneJoins(q, ctx, from, joins, ctes, used) {
|
|
1158
1231
|
if (q.pruneJoins === false) return {
|
|
1159
1232
|
joins,
|
|
1160
1233
|
ctes
|
|
@@ -1177,6 +1250,7 @@ function pruneJoins(q, from, joins, ctes, used) {
|
|
|
1177
1250
|
markRequired(from.alias);
|
|
1178
1251
|
for (const r of used.flatMap((u) => u.refs)) markRequired(r);
|
|
1179
1252
|
for (const j of joins) if (j.keep) markRequired(j.source.alias);
|
|
1253
|
+
for (const j of joins) if (j.source.handle === ctx.recursiveSelf) markRequired(j.source.alias);
|
|
1180
1254
|
return {
|
|
1181
1255
|
joins: joins.filter((j) => required.has(j.source.alias)),
|
|
1182
1256
|
ctes: ctes.filter((c) => required.has(c.alias))
|
|
@@ -1196,11 +1270,13 @@ function registerCtes(q, ctx, assigner) {
|
|
|
1196
1270
|
const aliases = handles.map((handle) => assigner.getLiteralAlias(handle.name ?? "cte"));
|
|
1197
1271
|
handles.forEach((handle, i) => ctx.declareCte(handle, aliases[i]));
|
|
1198
1272
|
return handles.map((handle, i) => {
|
|
1199
|
-
|
|
1200
|
-
ctx.
|
|
1273
|
+
if (handle.recursive) ctx.promoteCte(handle);
|
|
1274
|
+
const plan = parseQuery(handle.q, ctx, assigner, handle.recursive ? handle : void 0);
|
|
1275
|
+
if (!handle.recursive) ctx.promoteCte(handle);
|
|
1201
1276
|
return {
|
|
1202
1277
|
alias: aliases[i],
|
|
1203
|
-
plan
|
|
1278
|
+
plan,
|
|
1279
|
+
recursive: handle.recursive
|
|
1204
1280
|
};
|
|
1205
1281
|
});
|
|
1206
1282
|
}
|
|
@@ -1209,10 +1285,15 @@ function withEntryHandle(entry) {
|
|
|
1209
1285
|
if (!isSubqueryValue(entry)) require_utils.fail(entry instanceof SubqueryExpr || isEntityQueryValue(entry) ? "A `with` entry needs named columns; entity and scalar query(...) values have none" : "A `with` entry must be a query(...) value");
|
|
1210
1286
|
return readValueHandle(entry);
|
|
1211
1287
|
}
|
|
1212
|
-
/**
|
|
1288
|
+
/**
|
|
1289
|
+
* Renders `WITH a AS (...), b AS (...) `, whose bindings lead the statement, as their SQL does.
|
|
1290
|
+
*
|
|
1291
|
+
* One recursive CTE makes the whole clause `WITH RECURSIVE`, PostgreSQL's rule: the keyword is on the
|
|
1292
|
+
* clause, not on the entry that needs it, and it does not force the other entries to be recursive.
|
|
1293
|
+
*/
|
|
1213
1294
|
function withFragment(ctes) {
|
|
1214
1295
|
return {
|
|
1215
|
-
sql: `WITH ${ctes.map((c) => `${require_keywords.safeKq(c.alias)} AS (${c.plan.sql})`).join(", ")} `,
|
|
1296
|
+
sql: `WITH${ctes.some((c) => c.recursive) ? " RECURSIVE" : ""} ${ctes.map((c) => `${require_keywords.safeKq(c.alias)} AS (${c.plan.sql})`).join(", ")} `,
|
|
1216
1297
|
bindings: ctes.flatMap((c) => c.plan.bindings),
|
|
1217
1298
|
refs: []
|
|
1218
1299
|
};
|
|
@@ -1241,6 +1322,7 @@ exports.isReadQueryValue = isReadQueryValue;
|
|
|
1241
1322
|
exports.parseUserQuery = parseUserQuery;
|
|
1242
1323
|
exports.projectionToSql = projectionToSql;
|
|
1243
1324
|
exports.query = query;
|
|
1325
|
+
exports.recursiveQuery = recursiveQuery;
|
|
1244
1326
|
exports.scalarQueryBrand = scalarQueryBrand;
|
|
1245
1327
|
exports.sql = sql;
|
|
1246
1328
|
exports.subqueryBrand = subqueryBrand;
|