@stndrds/schema 1.0.0-alpha.183 → 1.0.0-alpha.186

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.d.mts CHANGED
@@ -6375,7 +6375,7 @@ declare const formRegistry: FormRegistry;
6375
6375
  * Event types emitted by write paths.
6376
6376
  * New types are added as handlers are implemented.
6377
6377
  */
6378
- type EventType = "record.created" | "record.updated" | "record.deleted" | "record.restored" | "form.submitted" | "meili.settings.refresh";
6378
+ type EventType = "record.created" | "record.updated" | "record.deleted" | "record.restored" | "form.submitted" | "schema.attribute.created" | "schema.attribute.updated" | "schema.attribute.deleted" | "schema.object.created" | "schema.object.deleted" | "tenant.created";
6379
6379
  /**
6380
6380
  * Typed payload map — each event type has a specific data shape.
6381
6381
  */
@@ -6419,13 +6419,52 @@ interface EventDataMap {
6419
6419
  stepValues: Record<string, Record<string, unknown>>;
6420
6420
  };
6421
6421
  /**
6422
- * Phase 6 — request a refresh of the Meilisearch index settings for a tenant.
6423
- * Emitted by schema mutations (attribute add/update/delete) so the search
6424
- * adapter can recompute sortableAttributes from the live schema without a
6425
- * full reindex.
6422
+ * Emitted after a custom attribute is added to an object. Triggers the
6423
+ * unified `SchemaSyncHandler` which converges the search index settings
6424
+ * (filterable/sortable/searchable) to the live schema.
6426
6425
  */
6427
- "meili.settings.refresh": {
6428
- /** Tenant whose Meili index should be reconfigured. */
6426
+ "schema.attribute.created": {
6427
+ objectId: string;
6428
+ attributeId: string;
6429
+ };
6430
+ /**
6431
+ * Emitted after an attribute mutation (label/required/config). The
6432
+ * `SchemaSyncHandler` reconciles index settings; downstream reindex is
6433
+ * handled separately by `ObjectSchemaService.updateObject` when needed.
6434
+ */
6435
+ "schema.attribute.updated": {
6436
+ objectId: string;
6437
+ attributeId: string;
6438
+ };
6439
+ /**
6440
+ * Emitted after a custom attribute is deleted from an object. Triggers
6441
+ * the unified `SchemaSyncHandler` to drop the attribute from the index
6442
+ * settings.
6443
+ */
6444
+ "schema.attribute.deleted": {
6445
+ objectId: string;
6446
+ attributeId: string;
6447
+ };
6448
+ /**
6449
+ * Emitted after a custom object is created. Triggers the unified
6450
+ * `SchemaSyncHandler` to provision per-tenant index settings.
6451
+ */
6452
+ "schema.object.created": {
6453
+ objectId: string;
6454
+ };
6455
+ /**
6456
+ * Emitted after a custom object is deleted. Triggers the unified
6457
+ * `SchemaSyncHandler` so the search adapter can clean up dangling settings.
6458
+ */
6459
+ "schema.object.deleted": {
6460
+ objectId: string;
6461
+ };
6462
+ /**
6463
+ * Emitted on initial provisioning of a tenant. Triggers the unified
6464
+ * `SchemaSyncHandler` to bootstrap the tenant's search index settings.
6465
+ */
6466
+ "tenant.created": {
6467
+ /** The tenant identifier (mirrors the envelope `tenantId` for convenience). */
6429
6468
  tenantId: string;
6430
6469
  };
6431
6470
  }
package/dist/index.d.ts CHANGED
@@ -6375,7 +6375,7 @@ declare const formRegistry: FormRegistry;
6375
6375
  * Event types emitted by write paths.
6376
6376
  * New types are added as handlers are implemented.
6377
6377
  */
6378
- type EventType = "record.created" | "record.updated" | "record.deleted" | "record.restored" | "form.submitted" | "meili.settings.refresh";
6378
+ type EventType = "record.created" | "record.updated" | "record.deleted" | "record.restored" | "form.submitted" | "schema.attribute.created" | "schema.attribute.updated" | "schema.attribute.deleted" | "schema.object.created" | "schema.object.deleted" | "tenant.created";
6379
6379
  /**
6380
6380
  * Typed payload map — each event type has a specific data shape.
6381
6381
  */
@@ -6419,13 +6419,52 @@ interface EventDataMap {
6419
6419
  stepValues: Record<string, Record<string, unknown>>;
6420
6420
  };
6421
6421
  /**
6422
- * Phase 6 — request a refresh of the Meilisearch index settings for a tenant.
6423
- * Emitted by schema mutations (attribute add/update/delete) so the search
6424
- * adapter can recompute sortableAttributes from the live schema without a
6425
- * full reindex.
6422
+ * Emitted after a custom attribute is added to an object. Triggers the
6423
+ * unified `SchemaSyncHandler` which converges the search index settings
6424
+ * (filterable/sortable/searchable) to the live schema.
6426
6425
  */
6427
- "meili.settings.refresh": {
6428
- /** Tenant whose Meili index should be reconfigured. */
6426
+ "schema.attribute.created": {
6427
+ objectId: string;
6428
+ attributeId: string;
6429
+ };
6430
+ /**
6431
+ * Emitted after an attribute mutation (label/required/config). The
6432
+ * `SchemaSyncHandler` reconciles index settings; downstream reindex is
6433
+ * handled separately by `ObjectSchemaService.updateObject` when needed.
6434
+ */
6435
+ "schema.attribute.updated": {
6436
+ objectId: string;
6437
+ attributeId: string;
6438
+ };
6439
+ /**
6440
+ * Emitted after a custom attribute is deleted from an object. Triggers
6441
+ * the unified `SchemaSyncHandler` to drop the attribute from the index
6442
+ * settings.
6443
+ */
6444
+ "schema.attribute.deleted": {
6445
+ objectId: string;
6446
+ attributeId: string;
6447
+ };
6448
+ /**
6449
+ * Emitted after a custom object is created. Triggers the unified
6450
+ * `SchemaSyncHandler` to provision per-tenant index settings.
6451
+ */
6452
+ "schema.object.created": {
6453
+ objectId: string;
6454
+ };
6455
+ /**
6456
+ * Emitted after a custom object is deleted. Triggers the unified
6457
+ * `SchemaSyncHandler` so the search adapter can clean up dangling settings.
6458
+ */
6459
+ "schema.object.deleted": {
6460
+ objectId: string;
6461
+ };
6462
+ /**
6463
+ * Emitted on initial provisioning of a tenant. Triggers the unified
6464
+ * `SchemaSyncHandler` to bootstrap the tenant's search index settings.
6465
+ */
6466
+ "tenant.created": {
6467
+ /** The tenant identifier (mirrors the envelope `tenantId` for convenience). */
6429
6468
  tenantId: string;
6430
6469
  };
6431
6470
  }
package/dist/index.js CHANGED
@@ -5670,24 +5670,65 @@ function normalizeForEdgeRpc(op) {
5670
5670
 
5671
5671
  // src/filters/validation.ts
5672
5672
  var REFERENCE_TYPES = /* @__PURE__ */ new Set(["relation", "document", "user"]);
5673
+ var ID_LIKE_OPERATORS = [
5674
+ "eq",
5675
+ "neq",
5676
+ "is",
5677
+ "is_not",
5678
+ "any_of",
5679
+ "none_of",
5680
+ "is_empty",
5681
+ "is_not_empty"
5682
+ ];
5683
+ var SYSTEM_FILTER_OPERATORS = {
5684
+ // Identifier columns (uuid)
5685
+ id: ID_LIKE_OPERATORS,
5686
+ objectId: ID_LIKE_OPERATORS,
5687
+ tenantId: ID_LIKE_OPERATORS,
5688
+ // Free-form text and status columns share their counterpart's operator set
5689
+ label: OPERATORS_BY_TYPE.text,
5690
+ completionStatus: OPERATORS_BY_TYPE.status,
5691
+ // Date columns
5692
+ createdAt: OPERATORS_BY_TYPE.date,
5693
+ updatedAt: OPERATORS_BY_TYPE.date,
5694
+ deletedAt: OPERATORS_BY_TYPE.date,
5695
+ // User columns (uuid → actor identity)
5696
+ createdBy: OPERATORS_BY_TYPE.user,
5697
+ lastUpdatedBy: OPERATORS_BY_TYPE.user
5698
+ };
5673
5699
  function assertOperatorForType(operator, type, context) {
5674
5700
  const ops = OPERATORS_BY_TYPE[type];
5675
5701
  if (!ops?.includes(operator)) {
5676
- throw new ValidationError(`Operator ${operator} is not valid for ${context} type ${type}`, [
5702
+ const validList = ops?.length ? ops.join(", ") : "(no operators registered for this type)";
5703
+ const summary = `Operator "${operator}" is not valid for ${context} type "${type}". Valid operators: ${validList}.`;
5704
+ throw new ValidationError(summary, [
5677
5705
  {
5678
5706
  path: ["operator"],
5679
- message: `Operator ${operator} not valid for ${type}`
5707
+ message: summary
5680
5708
  }
5681
5709
  ]);
5682
5710
  }
5683
5711
  }
5684
5712
  function validateQualifiedRule(rule, context) {
5685
5713
  const rootAttr = context.attributes.find((a) => a.name === rule.attribute);
5686
- if (!rootAttr) {
5714
+ const systemOps = SYSTEM_FILTER_OPERATORS[rule.attribute];
5715
+ if (!(rootAttr || systemOps)) {
5687
5716
  throw new ValidationError(`Unknown attribute: ${rule.attribute}`, [
5688
5717
  { path: ["attribute"], message: `Unknown attribute: ${rule.attribute}` }
5689
5718
  ]);
5690
5719
  }
5720
+ if (!rootAttr) {
5721
+ if (rule.property) {
5722
+ throw new ValidationError(`Cannot qualify system attribute "${rule.attribute}"`, [
5723
+ { path: ["property"], message: `"${rule.attribute}" is a system column, not a reference` }
5724
+ ]);
5725
+ }
5726
+ if (!systemOps.includes(rule.operator)) {
5727
+ const summary = `Operator "${rule.operator}" is not valid for system attribute "${rule.attribute}". Valid operators: ${systemOps.join(", ")}.`;
5728
+ throw new ValidationError(summary, [{ path: ["operator"], message: summary }]);
5729
+ }
5730
+ return;
5731
+ }
5691
5732
  if (!rule.property) {
5692
5733
  if (rootAttr.type === "rollup") {
5693
5734
  return;
package/dist/index.mjs CHANGED
@@ -5666,24 +5666,65 @@ function normalizeForEdgeRpc(op) {
5666
5666
 
5667
5667
  // src/filters/validation.ts
5668
5668
  var REFERENCE_TYPES = /* @__PURE__ */ new Set(["relation", "document", "user"]);
5669
+ var ID_LIKE_OPERATORS = [
5670
+ "eq",
5671
+ "neq",
5672
+ "is",
5673
+ "is_not",
5674
+ "any_of",
5675
+ "none_of",
5676
+ "is_empty",
5677
+ "is_not_empty"
5678
+ ];
5679
+ var SYSTEM_FILTER_OPERATORS = {
5680
+ // Identifier columns (uuid)
5681
+ id: ID_LIKE_OPERATORS,
5682
+ objectId: ID_LIKE_OPERATORS,
5683
+ tenantId: ID_LIKE_OPERATORS,
5684
+ // Free-form text and status columns share their counterpart's operator set
5685
+ label: OPERATORS_BY_TYPE.text,
5686
+ completionStatus: OPERATORS_BY_TYPE.status,
5687
+ // Date columns
5688
+ createdAt: OPERATORS_BY_TYPE.date,
5689
+ updatedAt: OPERATORS_BY_TYPE.date,
5690
+ deletedAt: OPERATORS_BY_TYPE.date,
5691
+ // User columns (uuid → actor identity)
5692
+ createdBy: OPERATORS_BY_TYPE.user,
5693
+ lastUpdatedBy: OPERATORS_BY_TYPE.user
5694
+ };
5669
5695
  function assertOperatorForType(operator, type, context) {
5670
5696
  const ops = OPERATORS_BY_TYPE[type];
5671
5697
  if (!ops?.includes(operator)) {
5672
- throw new ValidationError(`Operator ${operator} is not valid for ${context} type ${type}`, [
5698
+ const validList = ops?.length ? ops.join(", ") : "(no operators registered for this type)";
5699
+ const summary = `Operator "${operator}" is not valid for ${context} type "${type}". Valid operators: ${validList}.`;
5700
+ throw new ValidationError(summary, [
5673
5701
  {
5674
5702
  path: ["operator"],
5675
- message: `Operator ${operator} not valid for ${type}`
5703
+ message: summary
5676
5704
  }
5677
5705
  ]);
5678
5706
  }
5679
5707
  }
5680
5708
  function validateQualifiedRule(rule, context) {
5681
5709
  const rootAttr = context.attributes.find((a) => a.name === rule.attribute);
5682
- if (!rootAttr) {
5710
+ const systemOps = SYSTEM_FILTER_OPERATORS[rule.attribute];
5711
+ if (!(rootAttr || systemOps)) {
5683
5712
  throw new ValidationError(`Unknown attribute: ${rule.attribute}`, [
5684
5713
  { path: ["attribute"], message: `Unknown attribute: ${rule.attribute}` }
5685
5714
  ]);
5686
5715
  }
5716
+ if (!rootAttr) {
5717
+ if (rule.property) {
5718
+ throw new ValidationError(`Cannot qualify system attribute "${rule.attribute}"`, [
5719
+ { path: ["property"], message: `"${rule.attribute}" is a system column, not a reference` }
5720
+ ]);
5721
+ }
5722
+ if (!systemOps.includes(rule.operator)) {
5723
+ const summary = `Operator "${rule.operator}" is not valid for system attribute "${rule.attribute}". Valid operators: ${systemOps.join(", ")}.`;
5724
+ throw new ValidationError(summary, [{ path: ["operator"], message: summary }]);
5725
+ }
5726
+ return;
5727
+ }
5687
5728
  if (!rule.property) {
5688
5729
  if (rootAttr.type === "rollup") {
5689
5730
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stndrds/schema",
3
- "version": "1.0.0-alpha.183",
3
+ "version": "1.0.0-alpha.186",
4
4
  "description": "Standard schema definitions and utilities",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -131,7 +131,7 @@
131
131
  "expr-eval": "^2.0.2",
132
132
  "libphonenumber-js": "^1.12.31",
133
133
  "zod": "^4.2.1",
134
- "@stndrds/constants": "1.0.0-alpha.183"
134
+ "@stndrds/constants": "1.0.0-alpha.186"
135
135
  },
136
136
  "devDependencies": {
137
137
  "@types/node": "^25.0.3",