joist-core 2.3.0-next.57 → 2.3.0-next.58

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.
@@ -68,6 +68,7 @@ const ignoredKeys = /* @__PURE__ */ new Set([
68
68
  "setDeepPartial",
69
69
  "changes",
70
70
  "isSoftDeletedEntity",
71
+ "softDelete",
71
72
  "load",
72
73
  "populate",
73
74
  "isLoaded",
@@ -1 +1 @@
1
- {"version":3,"file":"getProperties.cjs","names":["partition","LazyRelation","fail","BaseEntity"],"sources":["../src/getProperties.ts"],"sourcesContent":["import { BaseEntity } from \"./BaseEntity.ts\";\nimport { type EntityMetadata } from \"./EntityMetadata.ts\";\nimport { LazyRelation } from \"./newEntity.ts\";\nimport { fail, partition } from \"./utils.ts\";\n\n/**\n * Returns the relations in `meta`, both those defined in the codegen file + any user-defined `CustomReference`s.\n *\n * This is a little tricky because field assignments don't show up on the prototype, so we actually\n * instantiate a throw-away instance to observe the side-effect of what fields it has.\n *\n * The map values will be:\n *\n * - The `AbstractRelationImpl` or `AbstractPropertyImpl` for relations\n * - The primitive value like true/false/\"foo\" for getters that return primitive values\n * - A `UnknownProperty` for keys/getters that return `undefined` or throw errors\n * - Any other custom value that the user has defined\n *\n * Basically the values won't be `undefined`, to avoid throwing off `if getPropertyes(meta)[key]`\n * checks.\n */\nexport function getProperties(meta: EntityMetadata): Record<string, any> {\n // If meta is an STI subtype, give it a different key\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n if (propertiesCache[key]) {\n return propertiesCache[key];\n }\n\n // Immediately populate key to avoid infinite loops when we later call `instance[key]` to probe\n // for properties, and we end up calling a getter than invokes a ReactiveField/anything else that\n // happens to ask for properties.\n // The caller will admittedly see incorrect (empty) properties, but we generally expect these \"evaled\n // on fake instances\" getters to throw nonsense errors anyway (which we suppress), so it should be fine.\n const cached = (propertiesCache[key] = {});\n\n const fakeEm = undefined as any;\n const instance = new (meta.cstr as any)(fakeEm, true);\n\n // Mostly for historical reasons, we don't treat known primitives/enums as properties,\n // i.e. properties were originally meant to be the wrapper objects like `hasOne`,\n // `hasMany`, `ReactiveField`, etc.\n //\n // That said, we've since start leaking other things like getters, regular async methods,\n // etc., into properties, so that `entityResolver` can pick them up as keys to put into\n // the GraphQL resolvers. So we should probably just remove this filter and let everything\n // get returned as properties.\n const knownPrimitives = Object.values(meta.allFields)\n .filter((f) => f.kind === \"primaryKey\" || f.kind === \"primitive\" || f.kind === \"enum\")\n .map((f) => f.fieldName);\n\n // We can look directly at the `instance` to find all relations (`has...` calls), and any other\n // instance-level fields (of which only the special `transientFields` is expected/allowed).\n const [relationFields, otherFields] = partition(\n Object.entries(instance),\n ([, value]) => value instanceof LazyRelation,\n );\n\n // Enforce transientFields usage\n const invalidFields = otherFields.filter(([fieldName]) => fieldName !== \"transientFields\");\n if (invalidFields.length > 0) {\n throw new Error(\n `${meta.type} has invalid class fields, ${invalidFields.map(([k]) => k).join(\", \")} should go in transientFields`,\n );\n }\n\n const properties = [\n // Include the instance-level relations that will be getter-ized by `newEntity`\n ...relationFields,\n // And then any prototype-level getters/methods like `isRed` by recursively looking for ownKeys\n // (this is the previously-mentioned nod to entityResolver to let it copy over getters/methods).\n ...getRecursivePrototypeKeys(instance)\n .filter((key) => !knownPrimitives.includes(key))\n .map((key) => {\n try {\n return [key, (instance as any)[key] ?? unknown];\n } catch {\n return [key, unknown];\n }\n }),\n ];\n\n // Keep one version with the relations still lazy, solely for `newEntity`\n // (technically newEntity will only ask for this once-per-cstr, so a cache is kind of over-kill,\n // but creating it here, right before we `relationCstr.create`, is a convenient spot).\n lazyFields[key] = [...relationFields, ...otherFields];\n\n // But expose to everyone else the concrete/constructed relations\n Object.assign(\n cached,\n Object.fromEntries(\n properties.map(([fieldName, value]) => [\n fieldName,\n value instanceof LazyRelation ? value.create(instance, fieldName) : value,\n ]),\n ),\n );\n\n // Since our fake instance is actually generating the callbacks for our lazy fields, it will be captured in any\n // lambdas created. If any of them reference `this`, then they'll actually be referencing the fake instance. So we\n // need to clear out any properties directly on the fake instance now that we're done with it and use a proxy to\n // intercept any attempts to access `this` from within the callbacks and fail.\n Object.setPrototypeOf(instance, afterGetPropertiesInstancePrototypeProxy);\n for (const prop of Object.getOwnPropertyNames(instance)) {\n if (prop !== \"__data\") delete instance[prop];\n }\n\n return cached;\n}\n\nconst afterGetPropertiesInstancePrototypeProxy = new Proxy(\n {},\n { get: () => fail(\"Cannot use 'this' in a property callback\") },\n);\n\n/**\n * Returns the `LazyRelation`s (...and transientField) for `meta`.\n *\n * Should only be used by `newEntity` while moving relations to the prototype.\n */\nexport function getLazyFields(meta: EntityMetadata): [string, LazyRelation<any> | object][] {\n getProperties(meta); // We populate the lazyFields during getProperties\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n return lazyFields[key];\n}\n\nexport class UnknownProperty {}\nconst unknown = new UnknownProperty();\n\nconst propertiesCache: Record<string, any> = {};\nconst lazyFields: Record<string, any> = {};\n\n// These are keys we codegen into `AuthorCodegen` files to get the best typing\n// experience, but really should be treated as BaseEntity keys that we don't\n// need to expose from `getProperties`.\nconst ignoredKeys = new Set([\n \"constructor\",\n \"id\",\n \"idMaybe\",\n \"idTagged\",\n \"idTaggedMaybe\",\n \"set\",\n \"setPartial\",\n \"setDeepPartial\",\n \"changes\",\n \"isSoftDeletedEntity\",\n \"load\",\n \"populate\",\n \"isLoaded\",\n \"toJSON\",\n]);\n\nfunction getRecursivePrototypeKeys(instance: any): string[] {\n const keys: string[] = [];\n for (\n let curr = Object.getPrototypeOf(instance);\n curr && curr !== BaseEntity.prototype;\n curr = Object.getPrototypeOf(curr)\n ) {\n for (const name of Object.getOwnPropertyNames(curr)) {\n if (!ignoredKeys.has(name)) {\n keys.push(name);\n }\n }\n }\n return keys;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cAAc,MAA2C;CAEvE,M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,IAAI,SAAS,UAAU,OAAO,SAAS;CAGzC,OAAO;AACT;AAEA,MAAM,2CAA2C,IAAI,MACnD,CAAC,GACD,EAAE,WAAWC,cAAAA,KAAK,0CAA0C,EAAE,CAChE;;;;;;AAOA,SAAgB,cAAc,MAA8D;CAC1F,cAAc,IAAI;CAClB,MAAM,MAAM,KAAK,wBAAwB,GAAG,KAAK,UAAU,GAAG,KAAK,0BAA0B,KAAK;CAClG,OAAO,WAAW;AACpB;AAEA,IAAa,kBAAb,MAA6B,CAAC;AAC9B,MAAM,UAAU,IAAI,gBAAgB;AAEpC,MAAM,kBAAuC,CAAC;AAC9C,MAAM,aAAkC,CAAC;AAKzC,MAAM,8BAAc,IAAI,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,UAAyB;CAC1D,MAAM,OAAiB,CAAC;CACxB,KACE,IAAI,OAAO,OAAO,eAAe,QAAQ,GACzC,QAAQ,SAASC,mBAAAA,WAAW,WAC5B,OAAO,OAAO,eAAe,IAAI,GAEjC,KAAK,MAAM,QAAQ,OAAO,oBAAoB,IAAI,GAChD,IAAI,CAAC,YAAY,IAAI,IAAI,GACvB,KAAK,KAAK,IAAI;CAIpB,OAAO;AACT"}
1
+ {"version":3,"file":"getProperties.cjs","names":["partition","LazyRelation","fail","BaseEntity"],"sources":["../src/getProperties.ts"],"sourcesContent":["import { BaseEntity } from \"./BaseEntity.ts\";\nimport { type EntityMetadata } from \"./EntityMetadata.ts\";\nimport { LazyRelation } from \"./newEntity.ts\";\nimport { fail, partition } from \"./utils.ts\";\n\n/**\n * Returns the relations in `meta`, both those defined in the codegen file + any user-defined `CustomReference`s.\n *\n * This is a little tricky because field assignments don't show up on the prototype, so we actually\n * instantiate a throw-away instance to observe the side-effect of what fields it has.\n *\n * The map values will be:\n *\n * - The `AbstractRelationImpl` or `AbstractPropertyImpl` for relations\n * - The primitive value like true/false/\"foo\" for getters that return primitive values\n * - A `UnknownProperty` for keys/getters that return `undefined` or throw errors\n * - Any other custom value that the user has defined\n *\n * Basically the values won't be `undefined`, to avoid throwing off `if getPropertyes(meta)[key]`\n * checks.\n */\nexport function getProperties(meta: EntityMetadata): Record<string, any> {\n // If meta is an STI subtype, give it a different key\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n if (propertiesCache[key]) {\n return propertiesCache[key];\n }\n\n // Immediately populate key to avoid infinite loops when we later call `instance[key]` to probe\n // for properties, and we end up calling a getter than invokes a ReactiveField/anything else that\n // happens to ask for properties.\n // The caller will admittedly see incorrect (empty) properties, but we generally expect these \"evaled\n // on fake instances\" getters to throw nonsense errors anyway (which we suppress), so it should be fine.\n const cached = (propertiesCache[key] = {});\n\n const fakeEm = undefined as any;\n const instance = new (meta.cstr as any)(fakeEm, true);\n\n // Mostly for historical reasons, we don't treat known primitives/enums as properties,\n // i.e. properties were originally meant to be the wrapper objects like `hasOne`,\n // `hasMany`, `ReactiveField`, etc.\n //\n // That said, we've since start leaking other things like getters, regular async methods,\n // etc., into properties, so that `entityResolver` can pick them up as keys to put into\n // the GraphQL resolvers. So we should probably just remove this filter and let everything\n // get returned as properties.\n const knownPrimitives = Object.values(meta.allFields)\n .filter((f) => f.kind === \"primaryKey\" || f.kind === \"primitive\" || f.kind === \"enum\")\n .map((f) => f.fieldName);\n\n // We can look directly at the `instance` to find all relations (`has...` calls), and any other\n // instance-level fields (of which only the special `transientFields` is expected/allowed).\n const [relationFields, otherFields] = partition(\n Object.entries(instance),\n ([, value]) => value instanceof LazyRelation,\n );\n\n // Enforce transientFields usage\n const invalidFields = otherFields.filter(([fieldName]) => fieldName !== \"transientFields\");\n if (invalidFields.length > 0) {\n throw new Error(\n `${meta.type} has invalid class fields, ${invalidFields.map(([k]) => k).join(\", \")} should go in transientFields`,\n );\n }\n\n const properties = [\n // Include the instance-level relations that will be getter-ized by `newEntity`\n ...relationFields,\n // And then any prototype-level getters/methods like `isRed` by recursively looking for ownKeys\n // (this is the previously-mentioned nod to entityResolver to let it copy over getters/methods).\n ...getRecursivePrototypeKeys(instance)\n .filter((key) => !knownPrimitives.includes(key))\n .map((key) => {\n try {\n return [key, (instance as any)[key] ?? unknown];\n } catch {\n return [key, unknown];\n }\n }),\n ];\n\n // Keep one version with the relations still lazy, solely for `newEntity`\n // (technically newEntity will only ask for this once-per-cstr, so a cache is kind of over-kill,\n // but creating it here, right before we `relationCstr.create`, is a convenient spot).\n lazyFields[key] = [...relationFields, ...otherFields];\n\n // But expose to everyone else the concrete/constructed relations\n Object.assign(\n cached,\n Object.fromEntries(\n properties.map(([fieldName, value]) => [\n fieldName,\n value instanceof LazyRelation ? value.create(instance, fieldName) : value,\n ]),\n ),\n );\n\n // Since our fake instance is actually generating the callbacks for our lazy fields, it will be captured in any\n // lambdas created. If any of them reference `this`, then they'll actually be referencing the fake instance. So we\n // need to clear out any properties directly on the fake instance now that we're done with it and use a proxy to\n // intercept any attempts to access `this` from within the callbacks and fail.\n Object.setPrototypeOf(instance, afterGetPropertiesInstancePrototypeProxy);\n for (const prop of Object.getOwnPropertyNames(instance)) {\n if (prop !== \"__data\") delete instance[prop];\n }\n\n return cached;\n}\n\nconst afterGetPropertiesInstancePrototypeProxy = new Proxy(\n {},\n { get: () => fail(\"Cannot use 'this' in a property callback\") },\n);\n\n/**\n * Returns the `LazyRelation`s (...and transientField) for `meta`.\n *\n * Should only be used by `newEntity` while moving relations to the prototype.\n */\nexport function getLazyFields(meta: EntityMetadata): [string, LazyRelation<any> | object][] {\n getProperties(meta); // We populate the lazyFields during getProperties\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n return lazyFields[key];\n}\n\nexport class UnknownProperty {}\nconst unknown = new UnknownProperty();\n\nconst propertiesCache: Record<string, any> = {};\nconst lazyFields: Record<string, any> = {};\n\n// These are keys we codegen into `AuthorCodegen` files to get the best typing\n// experience, but really should be treated as BaseEntity keys that we don't\n// need to expose from `getProperties`.\nconst ignoredKeys = new Set([\n \"constructor\",\n \"id\",\n \"idMaybe\",\n \"idTagged\",\n \"idTaggedMaybe\",\n \"set\",\n \"setPartial\",\n \"setDeepPartial\",\n \"changes\",\n \"isSoftDeletedEntity\",\n \"softDelete\",\n \"load\",\n \"populate\",\n \"isLoaded\",\n \"toJSON\",\n]);\n\nfunction getRecursivePrototypeKeys(instance: any): string[] {\n const keys: string[] = [];\n for (\n let curr = Object.getPrototypeOf(instance);\n curr && curr !== BaseEntity.prototype;\n curr = Object.getPrototypeOf(curr)\n ) {\n for (const name of Object.getOwnPropertyNames(curr)) {\n if (!ignoredKeys.has(name)) {\n keys.push(name);\n }\n }\n }\n return keys;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cAAc,MAA2C;CAEvE,MAAM,MAAM,KAAK,wBAAwB,GAAG,KAAK,UAAU,GAAG,KAAK,0BAA0B,KAAK;CAClG,IAAI,gBAAgB,MAClB,OAAO,gBAAgB;CAQzB,MAAM,SAAU,gBAAgB,OAAO,CAAC;CAGxC,MAAM,WAAW,IAAK,KAAK,KAAa,KAAA,GAAQ,IAAI;CAUpD,MAAM,kBAAkB,OAAO,OAAO,KAAK,SAAS,CAAC,CAClD,QAAQ,MAAM,EAAE,SAAS,gBAAgB,EAAE,SAAS,eAAe,EAAE,SAAS,MAAM,CAAC,CACrF,KAAK,MAAM,EAAE,SAAS;CAIzB,MAAM,CAAC,gBAAgB,eAAeA,cAAAA,UACpC,OAAO,QAAQ,QAAQ,IACtB,GAAG,WAAW,iBAAiBC,kBAAAA,YAClC;CAGA,MAAM,gBAAgB,YAAY,QAAQ,CAAC,eAAe,cAAc,iBAAiB;CACzF,IAAI,cAAc,SAAS,GACzB,MAAM,IAAI,MACR,GAAG,KAAK,KAAK,6BAA6B,cAAc,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,8BACrF;CAGF,M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,GAEjC,KAAK,MAAM,QAAQ,OAAO,oBAAoB,IAAI,GAChD,IAAI,CAAC,YAAY,IAAI,IAAI,GACvB,KAAK,KAAK,IAAI;CAIpB,OAAO;AACT"}
@@ -67,6 +67,7 @@ const ignoredKeys = /* @__PURE__ */ new Set([
67
67
  "setDeepPartial",
68
68
  "changes",
69
69
  "isSoftDeletedEntity",
70
+ "softDelete",
70
71
  "load",
71
72
  "populate",
72
73
  "isLoaded",
@@ -1 +1 @@
1
- {"version":3,"file":"getProperties.js","names":[],"sources":["../src/getProperties.ts"],"sourcesContent":["import { BaseEntity } from \"./BaseEntity.ts\";\nimport { type EntityMetadata } from \"./EntityMetadata.ts\";\nimport { LazyRelation } from \"./newEntity.ts\";\nimport { fail, partition } from \"./utils.ts\";\n\n/**\n * Returns the relations in `meta`, both those defined in the codegen file + any user-defined `CustomReference`s.\n *\n * This is a little tricky because field assignments don't show up on the prototype, so we actually\n * instantiate a throw-away instance to observe the side-effect of what fields it has.\n *\n * The map values will be:\n *\n * - The `AbstractRelationImpl` or `AbstractPropertyImpl` for relations\n * - The primitive value like true/false/\"foo\" for getters that return primitive values\n * - A `UnknownProperty` for keys/getters that return `undefined` or throw errors\n * - Any other custom value that the user has defined\n *\n * Basically the values won't be `undefined`, to avoid throwing off `if getPropertyes(meta)[key]`\n * checks.\n */\nexport function getProperties(meta: EntityMetadata): Record<string, any> {\n // If meta is an STI subtype, give it a different key\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n if (propertiesCache[key]) {\n return propertiesCache[key];\n }\n\n // Immediately populate key to avoid infinite loops when we later call `instance[key]` to probe\n // for properties, and we end up calling a getter than invokes a ReactiveField/anything else that\n // happens to ask for properties.\n // The caller will admittedly see incorrect (empty) properties, but we generally expect these \"evaled\n // on fake instances\" getters to throw nonsense errors anyway (which we suppress), so it should be fine.\n const cached = (propertiesCache[key] = {});\n\n const fakeEm = undefined as any;\n const instance = new (meta.cstr as any)(fakeEm, true);\n\n // Mostly for historical reasons, we don't treat known primitives/enums as properties,\n // i.e. properties were originally meant to be the wrapper objects like `hasOne`,\n // `hasMany`, `ReactiveField`, etc.\n //\n // That said, we've since start leaking other things like getters, regular async methods,\n // etc., into properties, so that `entityResolver` can pick them up as keys to put into\n // the GraphQL resolvers. So we should probably just remove this filter and let everything\n // get returned as properties.\n const knownPrimitives = Object.values(meta.allFields)\n .filter((f) => f.kind === \"primaryKey\" || f.kind === \"primitive\" || f.kind === \"enum\")\n .map((f) => f.fieldName);\n\n // We can look directly at the `instance` to find all relations (`has...` calls), and any other\n // instance-level fields (of which only the special `transientFields` is expected/allowed).\n const [relationFields, otherFields] = partition(\n Object.entries(instance),\n ([, value]) => value instanceof LazyRelation,\n );\n\n // Enforce transientFields usage\n const invalidFields = otherFields.filter(([fieldName]) => fieldName !== \"transientFields\");\n if (invalidFields.length > 0) {\n throw new Error(\n `${meta.type} has invalid class fields, ${invalidFields.map(([k]) => k).join(\", \")} should go in transientFields`,\n );\n }\n\n const properties = [\n // Include the instance-level relations that will be getter-ized by `newEntity`\n ...relationFields,\n // And then any prototype-level getters/methods like `isRed` by recursively looking for ownKeys\n // (this is the previously-mentioned nod to entityResolver to let it copy over getters/methods).\n ...getRecursivePrototypeKeys(instance)\n .filter((key) => !knownPrimitives.includes(key))\n .map((key) => {\n try {\n return [key, (instance as any)[key] ?? unknown];\n } catch {\n return [key, unknown];\n }\n }),\n ];\n\n // Keep one version with the relations still lazy, solely for `newEntity`\n // (technically newEntity will only ask for this once-per-cstr, so a cache is kind of over-kill,\n // but creating it here, right before we `relationCstr.create`, is a convenient spot).\n lazyFields[key] = [...relationFields, ...otherFields];\n\n // But expose to everyone else the concrete/constructed relations\n Object.assign(\n cached,\n Object.fromEntries(\n properties.map(([fieldName, value]) => [\n fieldName,\n value instanceof LazyRelation ? value.create(instance, fieldName) : value,\n ]),\n ),\n );\n\n // Since our fake instance is actually generating the callbacks for our lazy fields, it will be captured in any\n // lambdas created. If any of them reference `this`, then they'll actually be referencing the fake instance. So we\n // need to clear out any properties directly on the fake instance now that we're done with it and use a proxy to\n // intercept any attempts to access `this` from within the callbacks and fail.\n Object.setPrototypeOf(instance, afterGetPropertiesInstancePrototypeProxy);\n for (const prop of Object.getOwnPropertyNames(instance)) {\n if (prop !== \"__data\") delete instance[prop];\n }\n\n return cached;\n}\n\nconst afterGetPropertiesInstancePrototypeProxy = new Proxy(\n {},\n { get: () => fail(\"Cannot use 'this' in a property callback\") },\n);\n\n/**\n * Returns the `LazyRelation`s (...and transientField) for `meta`.\n *\n * Should only be used by `newEntity` while moving relations to the prototype.\n */\nexport function getLazyFields(meta: EntityMetadata): [string, LazyRelation<any> | object][] {\n getProperties(meta); // We populate the lazyFields during getProperties\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n return lazyFields[key];\n}\n\nexport class UnknownProperty {}\nconst unknown = new UnknownProperty();\n\nconst propertiesCache: Record<string, any> = {};\nconst lazyFields: Record<string, any> = {};\n\n// These are keys we codegen into `AuthorCodegen` files to get the best typing\n// experience, but really should be treated as BaseEntity keys that we don't\n// need to expose from `getProperties`.\nconst ignoredKeys = new Set([\n \"constructor\",\n \"id\",\n \"idMaybe\",\n \"idTagged\",\n \"idTaggedMaybe\",\n \"set\",\n \"setPartial\",\n \"setDeepPartial\",\n \"changes\",\n \"isSoftDeletedEntity\",\n \"load\",\n \"populate\",\n \"isLoaded\",\n \"toJSON\",\n]);\n\nfunction getRecursivePrototypeKeys(instance: any): string[] {\n const keys: string[] = [];\n for (\n let curr = Object.getPrototypeOf(instance);\n curr && curr !== BaseEntity.prototype;\n curr = Object.getPrototypeOf(curr)\n ) {\n for (const name of Object.getOwnPropertyNames(curr)) {\n if (!ignoredKeys.has(name)) {\n keys.push(name);\n }\n }\n }\n return keys;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cAAc,MAA2C;CAEvE,MAAM,MAAM,KAA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O;AACT;AAEA,MAAM,2CAA2C,IAAI,MACnD,CAAC,GACD,EAAE,WAAW,KAAK,0CAA0C,EAAE,CAChE;;;;;;AAOA,SAAgB,cAAc,MAA8D;CAC1F,cAAc,IAAI;CAClB,MAAM,MAAM,KAAK,wBAAwB,GAAG,KAAK,UAAU,GAAG,KAAK,0BAA0B,KAAK;CAClG,OAAO,WAAW;AACpB;AAEA,IAAa,kBAAb,MAA6B,CAAC;AAC9B,MAAM,UAAU,IAAI,gBAAgB;AAEpC,MAAM,kBAAuC,CAAC;AAC9C,MAAM,aAAkC,CAAC;AAKzC,MAAM,8BAAc,IAAI,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,UAAyB;CAC1D,MAAM,OAAiB,CAAC;CACxB,KACE,IAAI,OAAO,OAAO,eAAe,QAAQ,GACzC,QAAQ,SAAS,WAAW,WAC5B,OAAO,OAAO,eAAe,IAAI,GAEjC,KAAK,MAAM,QAAQ,OAAO,oBAAoB,IAAI,GAChD,IAAI,CAAC,YAAY,IAAI,IAAI,GACvB,KAAK,KAAK,IAAI;CAIpB,OAAO;AACT"}
1
+ {"version":3,"file":"getProperties.js","names":[],"sources":["../src/getProperties.ts"],"sourcesContent":["import { BaseEntity } from \"./BaseEntity.ts\";\nimport { type EntityMetadata } from \"./EntityMetadata.ts\";\nimport { LazyRelation } from \"./newEntity.ts\";\nimport { fail, partition } from \"./utils.ts\";\n\n/**\n * Returns the relations in `meta`, both those defined in the codegen file + any user-defined `CustomReference`s.\n *\n * This is a little tricky because field assignments don't show up on the prototype, so we actually\n * instantiate a throw-away instance to observe the side-effect of what fields it has.\n *\n * The map values will be:\n *\n * - The `AbstractRelationImpl` or `AbstractPropertyImpl` for relations\n * - The primitive value like true/false/\"foo\" for getters that return primitive values\n * - A `UnknownProperty` for keys/getters that return `undefined` or throw errors\n * - Any other custom value that the user has defined\n *\n * Basically the values won't be `undefined`, to avoid throwing off `if getPropertyes(meta)[key]`\n * checks.\n */\nexport function getProperties(meta: EntityMetadata): Record<string, any> {\n // If meta is an STI subtype, give it a different key\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n if (propertiesCache[key]) {\n return propertiesCache[key];\n }\n\n // Immediately populate key to avoid infinite loops when we later call `instance[key]` to probe\n // for properties, and we end up calling a getter than invokes a ReactiveField/anything else that\n // happens to ask for properties.\n // The caller will admittedly see incorrect (empty) properties, but we generally expect these \"evaled\n // on fake instances\" getters to throw nonsense errors anyway (which we suppress), so it should be fine.\n const cached = (propertiesCache[key] = {});\n\n const fakeEm = undefined as any;\n const instance = new (meta.cstr as any)(fakeEm, true);\n\n // Mostly for historical reasons, we don't treat known primitives/enums as properties,\n // i.e. properties were originally meant to be the wrapper objects like `hasOne`,\n // `hasMany`, `ReactiveField`, etc.\n //\n // That said, we've since start leaking other things like getters, regular async methods,\n // etc., into properties, so that `entityResolver` can pick them up as keys to put into\n // the GraphQL resolvers. So we should probably just remove this filter and let everything\n // get returned as properties.\n const knownPrimitives = Object.values(meta.allFields)\n .filter((f) => f.kind === \"primaryKey\" || f.kind === \"primitive\" || f.kind === \"enum\")\n .map((f) => f.fieldName);\n\n // We can look directly at the `instance` to find all relations (`has...` calls), and any other\n // instance-level fields (of which only the special `transientFields` is expected/allowed).\n const [relationFields, otherFields] = partition(\n Object.entries(instance),\n ([, value]) => value instanceof LazyRelation,\n );\n\n // Enforce transientFields usage\n const invalidFields = otherFields.filter(([fieldName]) => fieldName !== \"transientFields\");\n if (invalidFields.length > 0) {\n throw new Error(\n `${meta.type} has invalid class fields, ${invalidFields.map(([k]) => k).join(\", \")} should go in transientFields`,\n );\n }\n\n const properties = [\n // Include the instance-level relations that will be getter-ized by `newEntity`\n ...relationFields,\n // And then any prototype-level getters/methods like `isRed` by recursively looking for ownKeys\n // (this is the previously-mentioned nod to entityResolver to let it copy over getters/methods).\n ...getRecursivePrototypeKeys(instance)\n .filter((key) => !knownPrimitives.includes(key))\n .map((key) => {\n try {\n return [key, (instance as any)[key] ?? unknown];\n } catch {\n return [key, unknown];\n }\n }),\n ];\n\n // Keep one version with the relations still lazy, solely for `newEntity`\n // (technically newEntity will only ask for this once-per-cstr, so a cache is kind of over-kill,\n // but creating it here, right before we `relationCstr.create`, is a convenient spot).\n lazyFields[key] = [...relationFields, ...otherFields];\n\n // But expose to everyone else the concrete/constructed relations\n Object.assign(\n cached,\n Object.fromEntries(\n properties.map(([fieldName, value]) => [\n fieldName,\n value instanceof LazyRelation ? value.create(instance, fieldName) : value,\n ]),\n ),\n );\n\n // Since our fake instance is actually generating the callbacks for our lazy fields, it will be captured in any\n // lambdas created. If any of them reference `this`, then they'll actually be referencing the fake instance. So we\n // need to clear out any properties directly on the fake instance now that we're done with it and use a proxy to\n // intercept any attempts to access `this` from within the callbacks and fail.\n Object.setPrototypeOf(instance, afterGetPropertiesInstancePrototypeProxy);\n for (const prop of Object.getOwnPropertyNames(instance)) {\n if (prop !== \"__data\") delete instance[prop];\n }\n\n return cached;\n}\n\nconst afterGetPropertiesInstancePrototypeProxy = new Proxy(\n {},\n { get: () => fail(\"Cannot use 'this' in a property callback\") },\n);\n\n/**\n * Returns the `LazyRelation`s (...and transientField) for `meta`.\n *\n * Should only be used by `newEntity` while moving relations to the prototype.\n */\nexport function getLazyFields(meta: EntityMetadata): [string, LazyRelation<any> | object][] {\n getProperties(meta); // We populate the lazyFields during getProperties\n const key = meta.stiDiscriminatorValue ? `${meta.tableName}:${meta.stiDiscriminatorValue}` : meta.tableName;\n return lazyFields[key];\n}\n\nexport class UnknownProperty {}\nconst unknown = new UnknownProperty();\n\nconst propertiesCache: Record<string, any> = {};\nconst lazyFields: Record<string, any> = {};\n\n// These are keys we codegen into `AuthorCodegen` files to get the best typing\n// experience, but really should be treated as BaseEntity keys that we don't\n// need to expose from `getProperties`.\nconst ignoredKeys = new Set([\n \"constructor\",\n \"id\",\n \"idMaybe\",\n \"idTagged\",\n \"idTaggedMaybe\",\n \"set\",\n \"setPartial\",\n \"setDeepPartial\",\n \"changes\",\n \"isSoftDeletedEntity\",\n \"softDelete\",\n \"load\",\n \"populate\",\n \"isLoaded\",\n \"toJSON\",\n]);\n\nfunction getRecursivePrototypeKeys(instance: any): string[] {\n const keys: string[] = [];\n for (\n let curr = Object.getPrototypeOf(instance);\n curr && curr !== BaseEntity.prototype;\n curr = Object.getPrototypeOf(curr)\n ) {\n for (const name of Object.getOwnPropertyNames(curr)) {\n if (!ignoredKeys.has(name)) {\n keys.push(name);\n }\n }\n }\n return keys;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cAAc,MAA2C;CAEvE,MAAM,MAAM,KAAK,wBAAwB,GAAG,KAAK,UAAU,GAAG,KAAK,0BAA0B,KAAK;CAClG,IAAI,gBAAgB,MAClB,OAAO,gBAAgB;CAQzB,MAAM,SAAU,gBAAgB,OAAO,CAAC;CAGxC,MAAM,WAAW,IAAK,KAAK,KAAa,KAAA,GAAQ,IAAI;CAUpD,MAAM,kBAAkB,OAAO,OAAO,KAAK,SAAS,CAAC,CAClD,QAAQ,MAAM,EAAE,SAAS,gBAAgB,EAAE,SAAS,eAAe,EAAE,SAAS,MAAM,CAAC,CACrF,KAAK,MAAM,EAAE,SAAS;CAIzB,MAAM,CAAC,gBAAgB,eAAe,UACpC,OAAO,QAAQ,QAAQ,IACtB,GAAG,WAAW,iBAAiB,YAClC;CAGA,MAAM,gBAAgB,YAAY,QAAQ,CAAC,eAAe,cAAc,iBAAiB;CACzF,IAAI,cAAc,SAAS,GACzB,MAAM,IAAI,MACR,GAAG,KAAK,KAAK,6BAA6B,cAAc,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,8BACrF;CAGF,MAAM,aAAa,CAEjB,GAAG,gBAGH,GAAG,0BAA0B,QAAQ,CAAC,CACnC,QAAQ,QAAQ,CAAC,gBAAgB,SAAS,GAAG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build/index.cjs CHANGED
@@ -76,6 +76,7 @@ const require_logging_FieldLogger = require("./logging/FieldLogger.cjs");
76
76
  const require_plugins_ImmutableEntitiesPlugin = require("./plugins/ImmutableEntitiesPlugin.cjs");
77
77
  const require_preloading_JsonAggregatePreloader = require("./preloading/JsonAggregatePreloader.cjs");
78
78
  const require_rules = require("./rules.cjs");
79
+ const require_nowUTC = require("./nowUTC.cjs");
79
80
  const require_upsert = require("./upsert.cjs");
80
81
  const require_withLoaded = require("./withLoaded.cjs");
81
82
  const require_EntityManager = require("./EntityManager.cjs");
@@ -437,6 +438,7 @@ exports.newTestInstance = require_newTestInstance.newTestInstance;
437
438
  exports.noValue = require_newTestInstance.noValue;
438
439
  exports.noopFieldLogger = require_logging_FieldLogger.noopFieldLogger;
439
440
  exports.normalizeHint = require_normalizeHints.normalizeHint;
441
+ exports.nowUTC = require_nowUTC.nowUTC;
440
442
  exports.opToFn = require_EntityGraphQLFilter.opToFn;
441
443
  exports.operators = require_EntityGraphQLFilter.operators;
442
444
  exports.optimizeCollectionJoins = require_QueryParser_collectionJoins.optimizeCollectionJoins;
@@ -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 * from \"./Aliases.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 { EnumMetadata } from \"./EnumMetadata.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\";\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 * from \"./serde.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 `hydrate` set the fields via the serde\n * `setOnEntityFromRowData` 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,UAAU;CAAE,eAAA,iBAAA;CAAe,wBAAA,iBAAA;CAAwB,eAAA,iCAAA;AAAc;AAC9E,MAAa,YAAY,EAAE,kBAAA,2BAAA,iBAAiB;;;;;;;;;;;;;;;AAsJ5C,SAAgB,QACd,QACA,QACA,MACM;CACN,MAAM,EAAE,wBAAwB,OAAO,YAAY,QAAQ,CAAC;CAG5D,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,OAAOA,uBAAAA,YAAY,MAAM;EAC/B,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,MAAY,GACrD,OAAO,MAAM,QAAQ,KAAK,QAAQ,SAAS,qBAAqB;CAEpE;AACF;;;;;;;;AASA,SAAgB,OACd,MACA,QACA,KACA,QACA,UAAU,OACV,wBAAwB,OAClB;CAEN,IAAI,CADU,KAAK,UAAU,MAIvB;MAAA,CADSC,sBAAAA,cAAc,IAAI,CAAC,CAAC,MAE/B,MAAM,IAAI,MAAM,iBAAiB,KAAK;CAAA;CAK1C,IAAI,WAAW,WAAW,KAAA,GAAW;CAErC,IAAI,KAAK,oBAAoB,SAASC,uBAAAA,YAAY,IAAI,CAAC,CAAC,0BAA0B,KAAK;CAGvF,MAAM,QAAQ,WAAW,OAAO,KAAA,IAAY;CAI5C,MAAM,UAAU,QAAQ,OAAOC,eAAAA,SAAS,QAAQ,GAAG,IAAK,OAAe;CAEvE,IAAI,mBAAmBC,uCAAAA,sBAAsB;EAC3C,IAAI,uBACF,QAAQ,YAAY,KAAK;OAEzB,QAAQ,IAAI,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,KAAK;AAC1C;AAEA,SAAgB,mBAAmB,QAA4D;CAC7F,OAAO,OAAO,QAAQH,sBAAAA,cAAcD,uBAAAA,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAaI,uCAAAA,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAU,CAAC,MAAO,OAAe,KAAK,CAAC;AAClD;;AAGA,SAAgB,eAAiC,MAA+D;CAC9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
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 * from \"./Aliases.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 { EnumMetadata } from \"./EnumMetadata.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\";\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 \"./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 `hydrate` set the fields via the serde\n * `setOnEntityFromRowData` 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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UAAU,CAAC,MAAO,OAAe,KAAK,CAAC;AAClD;;AAGA,SAAgB,eAAiC,MAA+D;CAC9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
package/build/index.d.cts CHANGED
@@ -81,6 +81,7 @@ import { setFactoryWriter } from "./logging/FactoryLogger.cjs";
81
81
  import { FieldLogger, FieldLoggerWatch, WriteFn, noopFieldLogger } from "./logging/FieldLogger.cjs";
82
82
  import { ImmutableEntitiesPlugin } from "./plugins/ImmutableEntitiesPlugin.cjs";
83
83
  import { JsonAggregatePreloader } from "./preloading/JsonAggregatePreloader.cjs";
84
+ import { nowUTC } from "./nowUTC.cjs";
84
85
  import { AliasFn, ResolvedScope, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, isScope, isScopeJoinFilter, isSelectAllFilter, newScopeFn, resolveScope } from "./scopes.cjs";
85
86
  import { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper } from "./temporalMappers.cjs";
86
87
  import { isInTrustedContext, runInTrustedContext } from "./trusted.cjs";
@@ -159,5 +160,5 @@ declare function failNoIdYet(entity: string): never;
159
160
  */
160
161
  declare function isNewEntity<T extends Entity>(entity: T): entity is New<T>;
161
162
  //#endregion
162
- export { type ActualFactoryOpts, Alias, AliasAssigner, AliasFn, AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type Collection, Column, ColumnCondition, ConditionBuilder, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type Driver, type Entity, EntityAlias, EntityChanges, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, ExistsCondition, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, 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, InsertFixup, InsertOp, 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, 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, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, 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, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, PrimitiveAlias, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, 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 Relation, type RelationsIn, type RelationsOf, ResolvedScope, RowData, type RuntimeConfig, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SettableFields, StubbedRelation, SubqueryRenderer, SuperstructSerde, TaggedId, Temporal, TestUuidAssigner, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, UniqueFilter, UnknownProperty, UpdateOp, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithLoaded, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, 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, 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, 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, newTestInstance, noValue, noopFieldLogger, normalizeHint, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
163
+ export { type ActualFactoryOpts, Alias, AliasAssigner, AliasFn, AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type Collection, Column, ColumnCondition, ConditionBuilder, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type Driver, type Entity, EntityAlias, EntityChanges, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, ExistsCondition, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, 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, InsertFixup, InsertOp, 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, 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, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, 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, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, PrimitiveAlias, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, 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 Relation, type RelationsIn, type RelationsOf, ResolvedScope, RowData, type RuntimeConfig, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SettableFields, StubbedRelation, SubqueryRenderer, SuperstructSerde, TaggedId, Temporal, TestUuidAssigner, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, UniqueFilter, UnknownProperty, UpdateOp, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithLoaded, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, 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, 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, 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, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
163
164
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;UAkIH,UAAU;EAClB,QAAQ;;KAGE,OAAO,GAAG,WAAW,IAAI,UAAU;;;;;;;;;;;;;;;iBAgB/B,QAAQ,UAAU,QAChC,QAAQ,GACR,QAAQ,QAAQ,OAAO,iBACvB;EAAS;EAAmB;;;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AQ,IAAI,UAAU,IAAI"}
package/build/index.d.mts CHANGED
@@ -81,6 +81,7 @@ import { setFactoryWriter } from "./logging/FactoryLogger.mjs";
81
81
  import { FieldLogger, FieldLoggerWatch, WriteFn, noopFieldLogger } from "./logging/FieldLogger.mjs";
82
82
  import { ImmutableEntitiesPlugin } from "./plugins/ImmutableEntitiesPlugin.mjs";
83
83
  import { JsonAggregatePreloader } from "./preloading/JsonAggregatePreloader.mjs";
84
+ import { nowUTC } from "./nowUTC.mjs";
84
85
  import { AliasFn, ResolvedScope, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, isScope, isScopeJoinFilter, isSelectAllFilter, newScopeFn, resolveScope } from "./scopes.mjs";
85
86
  import { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper } from "./temporalMappers.mjs";
86
87
  import { isInTrustedContext, runInTrustedContext } from "./trusted.mjs";
@@ -159,5 +160,5 @@ declare function failNoIdYet(entity: string): never;
159
160
  */
160
161
  declare function isNewEntity<T extends Entity>(entity: T): entity is New<T>;
161
162
  //#endregion
162
- export { type ActualFactoryOpts, Alias, AliasAssigner, AliasFn, AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type Collection, Column, ColumnCondition, ConditionBuilder, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type Driver, type Entity, EntityAlias, EntityChanges, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, ExistsCondition, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, 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, InsertFixup, InsertOp, 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, 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, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, 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, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, PrimitiveAlias, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, 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 Relation, type RelationsIn, type RelationsOf, ResolvedScope, RowData, type RuntimeConfig, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SettableFields, StubbedRelation, SubqueryRenderer, SuperstructSerde, TaggedId, Temporal, TestUuidAssigner, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, UniqueFilter, UnknownProperty, UpdateOp, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithLoaded, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, 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, 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, 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, newTestInstance, noValue, noopFieldLogger, normalizeHint, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
163
+ export { type ActualFactoryOpts, Alias, AliasAssigner, AliasFn, AliasMgmt, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, Changes, type Collection, Column, ColumnCondition, ConditionBuilder, ConfigApi, CrossJoinTable, CustomCollection, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type Driver, type Entity, EntityAlias, EntityChanges, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, type EntityOf, type EntityOrId, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, ExistsCondition, ExpressionCondition, ExpressionFilter, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, Field, 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, InsertFixup, InsertOp, 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, 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, NestedJsonHint, type NestedLoadHint, type New, NoIdError, NotFoundError, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, OrderBy, 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, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, PrimitiveAlias, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, 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 Relation, type RelationsIn, type RelationsOf, ResolvedScope, RowData, type RuntimeConfig, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SettableFields, StubbedRelation, SubqueryRenderer, SuperstructSerde, TaggedId, Temporal, TestUuidAssigner, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TypeMap, type TypeMapEntry, UniqueFilter, UnknownProperty, UpdateOp, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, type WithLoaded, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, 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, 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, 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, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
163
164
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;UAkIH,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"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Ba;;;;;cACA;2BAAA;;UAmIH,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
@@ -75,6 +75,7 @@ import { FieldLogger, noopFieldLogger } from "./logging/FieldLogger.js";
75
75
  import { ImmutableEntitiesPlugin } from "./plugins/ImmutableEntitiesPlugin.js";
76
76
  import { JsonAggregatePreloader } from "./preloading/JsonAggregatePreloader.js";
77
77
  import { ValidationCode, ValidationErrors, cannotBeChanged, cannotBeUpdated, maxValueRule, minValueRule, mustBeSubType, newRequiredLazyFieldRule, newRequiredRule, rangeValueRule } from "./rules.js";
78
+ import { nowUTC } from "./nowUTC.js";
78
79
  import { updatePartial, upsert } from "./upsert.js";
79
80
  import { StubbedRelation, ensureWithLoaded, withLoaded } from "./withLoaded.js";
80
81
  import { EntityManager, NotFoundError, ReadOnlyError, TooManyError, appendStack, createRowFromEntityData, driverAfterBegin, driverAfterCommit, driverBeforeBegin, driverBeforeCommit, getDefaultEntityLimit, getEmInternalApi, isDefined, isId, isKey, resetDefaultEntityLimit, sameEntity, sameReference, setDefaultEntityLimit, setLastNow } from "./EntityManager.js";
@@ -181,6 +182,6 @@ function isNewEntity(entity) {
181
182
  return entity.isNewEntity;
182
183
  }
183
184
  //#endregion
184
- export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, 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, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, 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, 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, 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, newTestInstance, noValue, noopFieldLogger, normalizeHint, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
185
+ export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, 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, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, 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, 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, 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, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, rangeValueRule, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, tagFromId, tagId, tagIds, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
185
186
 
186
187
  //# sourceMappingURL=index.js.map
@@ -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 * from \"./Aliases.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 { EnumMetadata } from \"./EnumMetadata.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\";\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 * from \"./serde.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 `hydrate` set the fields via the serde\n * `setOnEntityFromRowData` 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,UAAU;CAAE;CAAe;CAAwB;AAAc;AAC9E,MAAa,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;AAsJ5C,SAAgB,QACd,QACA,QACA,MACM;CACN,MAAM,EAAE,wBAAwB,OAAO,YAAY,QAAQ,CAAC;CAG5D,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,OAAO,YAAY,M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SAAgB,iBAAiB,QAAgB,QAA0B;CACzE,IAAI,OAAO,oBAAoB,WAAW,KAAA,KAAa,gBAAgB,MAAM,CAAC,CAAC,sBAC7E,KAAK,GAAG,OAAO,sBAAsB;AAEzC;AASA,SAAgB,gBAAkC,cAAkD;CAClG,OAAO,OAAO,OAAO,YAAY,YAAmB,CAAC,CAAC,MAAM,CAAC,CAC1D,QAAQ,MAAM,EAAE,QAAQ,CAAC,CACzB,KAAK,MAAM,EAAE,SAAS;AAC3B;AAEA,SAAgB,aAAa,QAAkD;CAC7E,OAAO,OAAO,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAa,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAW,OAAe,KAAK;AAC1C;AAEA,SAAgB,mBAAmB,QAA4D;CAC7F,OAAO,OAAO,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAa,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAU,CAAC,MAAO,OAAe,KAAK,CAAC;AAClD;;AAGA,SAAgB,eAAiC,MAA+D;CAC9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
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 * from \"./Aliases.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 { EnumMetadata } from \"./EnumMetadata.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\";\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 \"./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 `hydrate` set the fields via the serde\n * `setOnEntityFromRowData` 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,UAAU;CAAE;CAAe;CAAwB;AAAc;AAC9E,MAAa,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;AAuJ5C,SAAgB,QACd,QACA,QACA,MACM;CACN,MAAM,EAAE,wBAAwB,OAAO,YAAY,QAAQ,CAAC;CAG5D,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,OAAO,YAAY,MAAM;EAC/B,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,MAAY,GACrD,OAAO,MAAM,QAAQ,KAAK,QAAQ,SAAS,qBAAqB;CAEpE;AACF;;;;;;;;AASA,SAAgB,OACd,MACA,QACA,KACA,QACA,UAAU,OACV,wBAAwB,OAClB;CAEN,IAAI,CADU,KAAK,UAAU,MAIvB;MAAA,CADS,cAAc,IAAI,CAAC,CAAC,MAE/B,MAAM,IAAI,MAAM,iBAAiB,KAAK;CAAA;CAK1C,IAAI,WAAW,WAAW,KAAA,GAAW;CAErC,IAAI,KAAK,oBAAoB,SAAS,YAAY,IAAI,CAAC,CAAC,0BAA0B,KAAK;CAGvF,MAAM,QAAQ,WAAW,OAAO,KAAA,IAAY;CAI5C,MAAM,UAAU,QAAQ,OAAO,SAAS,QAAQ,GAAG,IAAK,OAAe;CAEvE,IAAI,mBAAmB,sBAAsB;EAC3C,IAAI,uBACF,QAAQ,YAAY,KAAK;OAEzB,QAAQ,IAAI,KAAK;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CACpD,KAAK,CAAC,UAAU,CAAC,MAAO,OAAe,KAAK,CAAC;AAClD;;AAGA,SAAgB,eAAiC,MAA+D;CAC9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_temporal = require("./temporal.cjs");
3
+ //#region src/nowUTC.ts
4
+ function nowUTC(type) {
5
+ const now = /* @__PURE__ */ new Date();
6
+ if (type === void 0) return now;
7
+ const zonedDateTime = require_temporal.requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO("UTC");
8
+ if (type === "plainDate") return zonedDateTime.toPlainDate();
9
+ if (type === "plainDateTime") return zonedDateTime.toPlainDateTime();
10
+ return zonedDateTime;
11
+ }
12
+ //#endregion
13
+ exports.nowUTC = nowUTC;
14
+
15
+ //# sourceMappingURL=nowUTC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nowUTC.cjs","names":["requireTemporal"],"sources":["../src/nowUTC.ts"],"sourcesContent":["import { type Temporal, requireTemporal } from \"./temporal.ts\";\n\n/** Returns the current UTC value in the requested Date or Temporal shape. */\nexport function nowUTC(): Date;\nexport function nowUTC(type: \"plainDate\"): Temporal.PlainDate;\nexport function nowUTC(type: \"plainDateTime\"): Temporal.PlainDateTime;\nexport function nowUTC(type: \"zonedDateTime\"): Temporal.ZonedDateTime;\nexport function nowUTC(\n type?: \"plainDate\" | \"plainDateTime\" | \"zonedDateTime\",\n): Date | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime {\n const now = new Date();\n if (type === undefined) return now;\n\n const zonedDateTime = requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO(\"UTC\");\n if (type === \"plainDate\") return zonedDateTime.toPlainDate();\n if (type === \"plainDateTime\") return zonedDateTime.toPlainDateTime();\n return zonedDateTime;\n}\n"],"mappings":";;;AAOA,SAAgB,OACd,MAC6E;CAC7E,MAAM,sBAAM,IAAI,KAAK;CACrB,IAAI,SAAS,KAAA,GAAW,OAAO;CAE/B,MAAM,gBAAgBA,iBAAAA,gBAAgB,CAAC,CAAC,kBAAkB,KAAK,GAAG,CAAC,CAAC,mBAAmB,KAAK;CAC5F,IAAI,SAAS,aAAa,OAAO,cAAc,YAAY;CAC3D,IAAI,SAAS,iBAAiB,OAAO,cAAc,gBAAgB;CACnE,OAAO;AACT"}
@@ -0,0 +1,10 @@
1
+ import { Temporal } from "./temporal.cjs";
2
+ //#region src/nowUTC.d.ts
3
+ /** Returns the current UTC value in the requested Date or Temporal shape. */
4
+ declare function nowUTC(): Date;
5
+ declare function nowUTC(type: "plainDate"): Temporal.PlainDate;
6
+ declare function nowUTC(type: "plainDateTime"): Temporal.PlainDateTime;
7
+ declare function nowUTC(type: "zonedDateTime"): Temporal.ZonedDateTime;
8
+ //#endregion
9
+ export { nowUTC };
10
+ //# sourceMappingURL=nowUTC.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nowUTC.d.cts","names":[],"sources":["../src/nowUTC.ts"],"mappings":";;;iBAGgB,UAAU;iBACV,OAAO,oBAAoB,SAAS;iBACpC,OAAO,wBAAwB,SAAS;iBACxC,OAAO,wBAAwB,SAAS"}
@@ -0,0 +1,10 @@
1
+ import { Temporal } from "./temporal.mjs";
2
+ //#region src/nowUTC.d.ts
3
+ /** Returns the current UTC value in the requested Date or Temporal shape. */
4
+ declare function nowUTC(): Date;
5
+ declare function nowUTC(type: "plainDate"): Temporal.PlainDate;
6
+ declare function nowUTC(type: "plainDateTime"): Temporal.PlainDateTime;
7
+ declare function nowUTC(type: "zonedDateTime"): Temporal.ZonedDateTime;
8
+ //#endregion
9
+ export { nowUTC };
10
+ //# sourceMappingURL=nowUTC.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nowUTC.d.mts","names":[],"sources":["../src/nowUTC.ts"],"mappings":";;;iBAGgB,UAAU;iBACV,OAAO,oBAAoB,SAAS;iBACpC,OAAO,wBAAwB,SAAS;iBACxC,OAAO,wBAAwB,SAAS"}
@@ -0,0 +1,14 @@
1
+ import { requireTemporal } from "./temporal.js";
2
+ //#region src/nowUTC.ts
3
+ function nowUTC(type) {
4
+ const now = /* @__PURE__ */ new Date();
5
+ if (type === void 0) return now;
6
+ const zonedDateTime = requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO("UTC");
7
+ if (type === "plainDate") return zonedDateTime.toPlainDate();
8
+ if (type === "plainDateTime") return zonedDateTime.toPlainDateTime();
9
+ return zonedDateTime;
10
+ }
11
+ //#endregion
12
+ export { nowUTC };
13
+
14
+ //# sourceMappingURL=nowUTC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nowUTC.js","names":[],"sources":["../src/nowUTC.ts"],"sourcesContent":["import { type Temporal, requireTemporal } from \"./temporal.ts\";\n\n/** Returns the current UTC value in the requested Date or Temporal shape. */\nexport function nowUTC(): Date;\nexport function nowUTC(type: \"plainDate\"): Temporal.PlainDate;\nexport function nowUTC(type: \"plainDateTime\"): Temporal.PlainDateTime;\nexport function nowUTC(type: \"zonedDateTime\"): Temporal.ZonedDateTime;\nexport function nowUTC(\n type?: \"plainDate\" | \"plainDateTime\" | \"zonedDateTime\",\n): Date | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime {\n const now = new Date();\n if (type === undefined) return now;\n\n const zonedDateTime = requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO(\"UTC\");\n if (type === \"plainDate\") return zonedDateTime.toPlainDate();\n if (type === \"plainDateTime\") return zonedDateTime.toPlainDateTime();\n return zonedDateTime;\n}\n"],"mappings":";;AAOA,SAAgB,OACd,MAC6E;CAC7E,MAAM,sBAAM,IAAI,KAAK;CACrB,IAAI,SAAS,KAAA,GAAW,OAAO;CAE/B,MAAM,gBAAgB,gBAAgB,CAAC,CAAC,kBAAkB,KAAK,GAAG,CAAC,CAAC,mBAAmB,KAAK;CAC5F,IAAI,SAAS,aAAa,OAAO,cAAc,YAAY;CAC3D,IAAI,SAAS,iBAAiB,OAAO,cAAc,gBAAgB;CACnE,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joist-core",
3
- "version": "2.3.0-next.57",
3
+ "version": "2.3.0-next.58",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "build"
43
43
  ],
44
44
  "peerDependencies": {
45
- "joist-utils": "2.3.0-next.57"
45
+ "joist-utils": "2.3.0-next.58"
46
46
  },
47
47
  "dependencies": {
48
48
  "ansis": "^4.3.1",