@objectstack/objectql 7.6.0 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -41,7 +41,7 @@ function applySystemFields(schema, opts) {
41
41
  if (schema.managedBy === "better-auth") return schema;
42
42
  const sf = typeof schema.systemFields === "object" && schema.systemFields !== null ? schema.systemFields : void 0;
43
43
  const tenancyDisabled = schema.tenancy?.enabled === false;
44
- const wantTenant = opts.multiTenant && sf?.tenant !== false && !tenancyDisabled;
44
+ const wantTenant = sf?.tenant !== false && !tenancyDisabled;
45
45
  const wantAudit = sf?.audit !== false;
46
46
  const additions = {};
47
47
  if (wantTenant && !schema.fields?.organization_id) {
@@ -50,11 +50,11 @@ function applySystemFields(schema, opts) {
50
50
  reference: "sys_organization",
51
51
  label: "Organization",
52
52
  required: false,
53
- indexed: true,
53
+ indexed: opts.multiTenant,
54
54
  hidden: true,
55
55
  readonly: true,
56
56
  system: true,
57
- description: "Tenant scope (auto-populated by SecurityPlugin on insert)."
57
+ description: "Tenant scope (auto-populated by org-scoping on insert; NULL on single-tenant stacks)."
58
58
  };
59
59
  }
60
60
  if (wantAudit) {
@@ -7014,7 +7014,11 @@ var _ObjectQL = class _ObjectQL {
7014
7014
  const driver = this.getDriver(object);
7015
7015
  let id = data.id;
7016
7016
  if (!id && options?.where && typeof options.where === "object" && "id" in options.where) {
7017
- id = options.where.id;
7017
+ const whereId = options.where.id;
7018
+ const t = typeof whereId;
7019
+ if (whereId !== null && (t === "string" || t === "number" || t === "bigint")) {
7020
+ id = whereId;
7021
+ }
7018
7022
  }
7019
7023
  const opCtx = {
7020
7024
  object,
@@ -7739,6 +7743,12 @@ var MetadataFacade = class {
7739
7743
 
7740
7744
  // src/plugin.ts
7741
7745
  import { StorageNameMapping as StorageNameMapping2 } from "@objectstack/spec/system";
7746
+ import {
7747
+ SysMetadataObject,
7748
+ SysMetadataHistoryObject,
7749
+ SysMetadataAuditObject,
7750
+ SysViewDefinitionObject
7751
+ } from "@objectstack/metadata-core";
7742
7752
  function hasLoadMetaFromDb(service) {
7743
7753
  return typeof service === "object" && service !== null && typeof service["loadMetaFromDb"] === "function";
7744
7754
  }
@@ -7775,6 +7785,21 @@ var ObjectQLPlugin = class {
7775
7785
  ctx.logger.info("ObjectQL engine registered", {
7776
7786
  services: ["objectql", "data", "manifest"]
7777
7787
  });
7788
+ if (this.environmentId === void 0) {
7789
+ this.ql.registerApp({
7790
+ id: "com.objectstack.metadata-objects",
7791
+ name: "Metadata Platform Objects",
7792
+ version: "1.0.0",
7793
+ type: "plugin",
7794
+ scope: "system",
7795
+ objects: [
7796
+ SysMetadataObject,
7797
+ SysMetadataHistoryObject,
7798
+ SysMetadataAuditObject,
7799
+ SysViewDefinitionObject
7800
+ ]
7801
+ });
7802
+ }
7778
7803
  const protocolShim = new ObjectStackProtocolImplementation(
7779
7804
  this.ql,
7780
7805
  () => ctx.getServices ? ctx.getServices() : /* @__PURE__ */ new Map(),