@objectstack/objectql 3.2.0 → 3.2.2

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/objectql@3.2.0 build /home/runner/work/spec/spec/packages/objectql
2
+ > @objectstack/objectql@3.2.2 build /home/runner/work/spec/spec/packages/objectql
3
3
  > tsup --config ../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 93.78 KB
14
- ESM dist/index.mjs.map 191.98 KB
15
- ESM ⚡️ Build success in 179ms
16
- CJS dist/index.js 95.52 KB
17
- CJS dist/index.js.map 193.28 KB
13
+ ESM dist/index.mjs 93.53 KB
14
+ ESM dist/index.mjs.map 191.56 KB
15
+ ESM ⚡️ Build success in 169ms
16
+ CJS dist/index.js 95.27 KB
17
+ CJS dist/index.js.map 192.86 KB
18
18
  CJS ⚡️ Build success in 181ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 22038ms
21
- DTS dist/index.d.mts 77.32 KB
22
- DTS dist/index.d.ts 77.32 KB
20
+ DTS ⚡️ Build success in 23512ms
21
+ DTS dist/index.d.mts 77.33 KB
22
+ DTS dist/index.d.ts 77.33 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @objectstack/objectql
2
2
 
3
+ ## 3.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [46defbb]
8
+ - @objectstack/spec@3.2.2
9
+ - @objectstack/core@3.2.2
10
+ - @objectstack/types@3.2.2
11
+
12
+ ## 3.2.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [850b546]
17
+ - @objectstack/spec@3.2.1
18
+ - @objectstack/core@3.2.1
19
+ - @objectstack/types@3.2.1
20
+
3
21
  ## 3.2.0
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1867,12 +1867,12 @@ declare class ObjectQLPlugin implements Plugin {
1867
1867
  init: (ctx: PluginContext) => Promise<void>;
1868
1868
  start: (ctx: PluginContext) => Promise<void>;
1869
1869
  /**
1870
- * Register built-in audit hooks for auto-stamping createdBy/modifiedBy
1870
+ * Register built-in audit hooks for auto-stamping created_by/updated_by
1871
1871
  * and fetching previousData for update/delete operations.
1872
1872
  */
1873
1873
  private registerAuditHooks;
1874
1874
  /**
1875
- * Register tenant isolation middleware that auto-injects space_id filter
1875
+ * Register tenant isolation middleware that auto-injects tenant_id filter
1876
1876
  * for multi-tenant operations.
1877
1877
  */
1878
1878
  private registerTenantMiddleware;
package/dist/index.d.ts CHANGED
@@ -1867,12 +1867,12 @@ declare class ObjectQLPlugin implements Plugin {
1867
1867
  init: (ctx: PluginContext) => Promise<void>;
1868
1868
  start: (ctx: PluginContext) => Promise<void>;
1869
1869
  /**
1870
- * Register built-in audit hooks for auto-stamping createdBy/modifiedBy
1870
+ * Register built-in audit hooks for auto-stamping created_by/updated_by
1871
1871
  * and fetching previousData for update/delete operations.
1872
1872
  */
1873
1873
  private registerAuditHooks;
1874
1874
  /**
1875
- * Register tenant isolation middleware that auto-injects space_id filter
1875
+ * Register tenant isolation middleware that auto-injects tenant_id filter
1876
1876
  * for multi-tenant operations.
1877
1877
  */
1878
1878
  private registerTenantMiddleware;
package/dist/index.js CHANGED
@@ -710,7 +710,7 @@ var ObjectStackProtocolImplementation = class {
710
710
  }
711
711
  };
712
712
  } else {
713
- const formFields = fieldKeys.filter((k) => k !== "id" && k !== "created_at" && k !== "modified_at" && !fields[k].hidden).map((f) => ({
713
+ const formFields = fieldKeys.filter((k) => k !== "id" && k !== "created_at" && k !== "updated_at" && !fields[k].hidden).map((f) => ({
714
714
  field: f,
715
715
  label: fields[f]?.label,
716
716
  required: fields[f]?.required,
@@ -801,7 +801,7 @@ var ObjectStackProtocolImplementation = class {
801
801
  }
802
802
  async getData(request) {
803
803
  const queryOptions = {
804
- filter: { _id: request.id }
804
+ filter: { id: request.id }
805
805
  };
806
806
  if (request.select) {
807
807
  queryOptions.select = typeof request.select === "string" ? request.select.split(",").map((s) => s.trim()).filter(Boolean) : request.select;
@@ -823,12 +823,12 @@ var ObjectStackProtocolImplementation = class {
823
823
  const result = await this.engine.insert(request.object, request.data);
824
824
  return {
825
825
  object: request.object,
826
- id: result._id || result.id,
826
+ id: result.id,
827
827
  record: result
828
828
  };
829
829
  }
830
830
  async updateData(request) {
831
- const result = await this.engine.update(request.object, request.data, { filter: { _id: request.id } });
831
+ const result = await this.engine.update(request.object, request.data, { filter: { id: request.id } });
832
832
  return {
833
833
  object: request.object,
834
834
  id: request.id,
@@ -836,7 +836,7 @@ var ObjectStackProtocolImplementation = class {
836
836
  };
837
837
  }
838
838
  async deleteData(request) {
839
- await this.engine.delete(request.object, { filter: { _id: request.id } });
839
+ await this.engine.delete(request.object, { filter: { id: request.id } });
840
840
  return {
841
841
  object: request.object,
842
842
  id: request.id,
@@ -893,13 +893,13 @@ var ObjectStackProtocolImplementation = class {
893
893
  switch (operation) {
894
894
  case "create": {
895
895
  const created = await this.engine.insert(object, record.data || record);
896
- results.push({ id: created._id || created.id, success: true, record: created });
896
+ results.push({ id: created.id, success: true, record: created });
897
897
  succeeded++;
898
898
  break;
899
899
  }
900
900
  case "update": {
901
901
  if (!record.id) throw new Error("Record id is required for update");
902
- const updated = await this.engine.update(object, record.data || {}, { filter: { _id: record.id } });
902
+ const updated = await this.engine.update(object, record.data || {}, { filter: { id: record.id } });
903
903
  results.push({ id: record.id, success: true, record: updated });
904
904
  succeeded++;
905
905
  break;
@@ -907,28 +907,28 @@ var ObjectStackProtocolImplementation = class {
907
907
  case "upsert": {
908
908
  if (record.id) {
909
909
  try {
910
- const existing = await this.engine.findOne(object, { filter: { _id: record.id } });
910
+ const existing = await this.engine.findOne(object, { filter: { id: record.id } });
911
911
  if (existing) {
912
- const updated = await this.engine.update(object, record.data || {}, { filter: { _id: record.id } });
912
+ const updated = await this.engine.update(object, record.data || {}, { filter: { id: record.id } });
913
913
  results.push({ id: record.id, success: true, record: updated });
914
914
  } else {
915
- const created = await this.engine.insert(object, { _id: record.id, ...record.data || {} });
916
- results.push({ id: created._id || created.id, success: true, record: created });
915
+ const created = await this.engine.insert(object, { id: record.id, ...record.data || {} });
916
+ results.push({ id: created.id, success: true, record: created });
917
917
  }
918
918
  } catch {
919
- const created = await this.engine.insert(object, { _id: record.id, ...record.data || {} });
920
- results.push({ id: created._id || created.id, success: true, record: created });
919
+ const created = await this.engine.insert(object, { id: record.id, ...record.data || {} });
920
+ results.push({ id: created.id, success: true, record: created });
921
921
  }
922
922
  } else {
923
923
  const created = await this.engine.insert(object, record.data || record);
924
- results.push({ id: created._id || created.id, success: true, record: created });
924
+ results.push({ id: created.id, success: true, record: created });
925
925
  }
926
926
  succeeded++;
927
927
  break;
928
928
  }
929
929
  case "delete": {
930
930
  if (!record.id) throw new Error("Record id is required for delete");
931
- await this.engine.delete(object, { filter: { _id: record.id } });
931
+ await this.engine.delete(object, { filter: { id: record.id } });
932
932
  results.push({ id: record.id, success: true });
933
933
  succeeded++;
934
934
  break;
@@ -972,7 +972,7 @@ var ObjectStackProtocolImplementation = class {
972
972
  let failed = 0;
973
973
  for (const record of records) {
974
974
  try {
975
- const updated = await this.engine.update(object, record.data, { filter: { _id: record.id } });
975
+ const updated = await this.engine.update(object, record.data, { filter: { id: record.id } });
976
976
  results.push({ id: record.id, success: true, record: updated });
977
977
  succeeded++;
978
978
  } catch (err) {
@@ -1136,7 +1136,7 @@ var ObjectStackProtocolImplementation = class {
1136
1136
  }
1137
1137
  async deleteManyData(request) {
1138
1138
  return this.engine.delete(request.object, {
1139
- filter: { _id: { $in: request.ids } },
1139
+ filter: { id: { $in: request.ids } },
1140
1140
  ...request.options
1141
1141
  });
1142
1142
  }
@@ -1821,7 +1821,7 @@ var _ObjectQL = class _ObjectQL {
1821
1821
  try {
1822
1822
  const relatedQuery = {
1823
1823
  object: referenceObject,
1824
- where: { _id: { $in: uniqueIds } },
1824
+ where: { id: { $in: uniqueIds } },
1825
1825
  ...nestedAST.fields ? { fields: nestedAST.fields } : {},
1826
1826
  ...nestedAST.orderBy ? { orderBy: nestedAST.orderBy } : {}
1827
1827
  };
@@ -1829,7 +1829,7 @@ var _ObjectQL = class _ObjectQL {
1829
1829
  const relatedRecords = await driver.find(referenceObject, relatedQuery) ?? [];
1830
1830
  const recordMap = /* @__PURE__ */ new Map();
1831
1831
  for (const rec of relatedRecords) {
1832
- const id = rec._id ?? rec.id;
1832
+ const id = rec.id;
1833
1833
  if (id != null) recordMap.set(String(id), rec);
1834
1834
  }
1835
1835
  if (nestedAST.expand && Object.keys(nestedAST.expand).length > 0) {
@@ -1841,7 +1841,7 @@ var _ObjectQL = class _ObjectQL {
1841
1841
  );
1842
1842
  recordMap.clear();
1843
1843
  for (const rec of expandedRelated) {
1844
- const id = rec._id ?? rec.id;
1844
+ const id = rec.id;
1845
1845
  if (id != null) recordMap.set(String(id), rec);
1846
1846
  }
1847
1847
  }
@@ -2009,10 +2009,9 @@ var _ObjectQL = class _ObjectQL {
2009
2009
  object = this.resolveObjectName(object);
2010
2010
  this.logger.debug("Update operation starting", { object });
2011
2011
  const driver = this.getDriver(object);
2012
- let id = data.id || data._id;
2012
+ let id = data.id;
2013
2013
  if (!id && options?.filter) {
2014
2014
  if (typeof options.filter === "string") id = options.filter;
2015
- else if (options.filter._id) id = options.filter._id;
2016
2015
  else if (options.filter.id) id = options.filter.id;
2017
2016
  }
2018
2017
  const opCtx = {
@@ -2060,7 +2059,6 @@ var _ObjectQL = class _ObjectQL {
2060
2059
  let id = void 0;
2061
2060
  if (options?.filter) {
2062
2061
  if (typeof options.filter === "string") id = options.filter;
2063
- else if (options.filter._id) id = options.filter._id;
2064
2062
  else if (options.filter.id) id = options.filter.id;
2065
2063
  }
2066
2064
  const opCtx = {
@@ -2114,7 +2112,7 @@ var _ObjectQL = class _ObjectQL {
2114
2112
  const ast = this.toQueryAST(object, { filter: query?.filter });
2115
2113
  return driver.count(object, ast);
2116
2114
  }
2117
- const res = await this.find(object, { filter: query?.filter, select: ["_id"] });
2115
+ const res = await this.find(object, { filter: query?.filter, select: ["id"] });
2118
2116
  return res.length;
2119
2117
  });
2120
2118
  return opCtx.result;
@@ -2348,8 +2346,8 @@ var ObjectRepository = class {
2348
2346
  }
2349
2347
  /** Update a single record by ID */
2350
2348
  async updateById(id, data) {
2351
- return this.engine.update(this.objectName, { ...data, _id: id }, {
2352
- filter: { _id: id },
2349
+ return this.engine.update(this.objectName, { ...data, id }, {
2350
+ filter: { id },
2353
2351
  context: this.context
2354
2352
  });
2355
2353
  }
@@ -2362,7 +2360,7 @@ var ObjectRepository = class {
2362
2360
  /** Delete a single record by ID */
2363
2361
  async deleteById(id) {
2364
2362
  return this.engine.delete(this.objectName, {
2365
- filter: { _id: id },
2363
+ filter: { id },
2366
2364
  context: this.context
2367
2365
  });
2368
2366
  }
@@ -2624,7 +2622,7 @@ var ObjectQLPlugin = class {
2624
2622
  }
2625
2623
  }
2626
2624
  /**
2627
- * Register built-in audit hooks for auto-stamping createdBy/modifiedBy
2625
+ * Register built-in audit hooks for auto-stamping created_by/updated_by
2628
2626
  * and fetching previousData for update/delete operations.
2629
2627
  */
2630
2628
  registerAuditHooks(ctx) {
@@ -2634,11 +2632,11 @@ var ObjectQLPlugin = class {
2634
2632
  const data = hookCtx.input.data;
2635
2633
  if (typeof data === "object" && data !== null) {
2636
2634
  data.created_by = data.created_by ?? hookCtx.session.userId;
2637
- data.modified_by = hookCtx.session.userId;
2635
+ data.updated_by = hookCtx.session.userId;
2638
2636
  data.created_at = data.created_at ?? (/* @__PURE__ */ new Date()).toISOString();
2639
- data.modified_at = (/* @__PURE__ */ new Date()).toISOString();
2637
+ data.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2640
2638
  if (hookCtx.session.tenantId) {
2641
- data.space_id = data.space_id ?? hookCtx.session.tenantId;
2639
+ data.tenant_id = data.tenant_id ?? hookCtx.session.tenantId;
2642
2640
  }
2643
2641
  }
2644
2642
  }
@@ -2647,8 +2645,8 @@ var ObjectQLPlugin = class {
2647
2645
  if (hookCtx.session?.userId && hookCtx.input?.data) {
2648
2646
  const data = hookCtx.input.data;
2649
2647
  if (typeof data === "object" && data !== null) {
2650
- data.modified_by = hookCtx.session.userId;
2651
- data.modified_at = (/* @__PURE__ */ new Date()).toISOString();
2648
+ data.updated_by = hookCtx.session.userId;
2649
+ data.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2652
2650
  }
2653
2651
  }
2654
2652
  }, { object: "*", priority: 10 });
@@ -2656,7 +2654,7 @@ var ObjectQLPlugin = class {
2656
2654
  if (hookCtx.input?.id && !hookCtx.previous) {
2657
2655
  try {
2658
2656
  const existing = await this.ql.findOne(hookCtx.object, {
2659
- filter: { _id: hookCtx.input.id }
2657
+ filter: { id: hookCtx.input.id }
2660
2658
  });
2661
2659
  if (existing) {
2662
2660
  hookCtx.previous = existing;
@@ -2669,7 +2667,7 @@ var ObjectQLPlugin = class {
2669
2667
  if (hookCtx.input?.id && !hookCtx.previous) {
2670
2668
  try {
2671
2669
  const existing = await this.ql.findOne(hookCtx.object, {
2672
- filter: { _id: hookCtx.input.id }
2670
+ filter: { id: hookCtx.input.id }
2673
2671
  });
2674
2672
  if (existing) {
2675
2673
  hookCtx.previous = existing;
@@ -2678,10 +2676,10 @@ var ObjectQLPlugin = class {
2678
2676
  }
2679
2677
  }
2680
2678
  }, { object: "*", priority: 5 });
2681
- ctx.logger.debug("Audit hooks registered (createdBy/modifiedBy, previousData)");
2679
+ ctx.logger.debug("Audit hooks registered (created_by/updated_by, previousData)");
2682
2680
  }
2683
2681
  /**
2684
- * Register tenant isolation middleware that auto-injects space_id filter
2682
+ * Register tenant isolation middleware that auto-injects tenant_id filter
2685
2683
  * for multi-tenant operations.
2686
2684
  */
2687
2685
  registerTenantMiddleware(ctx) {
@@ -2692,7 +2690,7 @@ var ObjectQLPlugin = class {
2692
2690
  }
2693
2691
  if (["find", "findOne", "count", "aggregate"].includes(opCtx.operation)) {
2694
2692
  if (opCtx.ast) {
2695
- const tenantFilter = { space_id: opCtx.context.tenantId };
2693
+ const tenantFilter = { tenant_id: opCtx.context.tenantId };
2696
2694
  if (opCtx.ast.where) {
2697
2695
  opCtx.ast.where = { $and: [opCtx.ast.where, tenantFilter] };
2698
2696
  } else {