node-type-registry 0.35.0 → 0.37.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.
Files changed (91) hide show
  1. package/blueprint-types.generated.d.ts +46 -1
  2. package/codegen/generate-types.js +37 -1
  3. package/conditions/index.d.ts +1 -0
  4. package/conditions/index.js +8 -0
  5. package/conditions/trigger-condition.d.ts +35 -0
  6. package/conditions/trigger-condition.js +97 -0
  7. package/data/data-aggregate-limit-counter.d.ts +1 -1
  8. package/data/data-aggregate-limit-counter.js +7 -7
  9. package/data/data-billing-meter.d.ts +1 -1
  10. package/data/data-billing-meter.js +7 -7
  11. package/data/data-chunks.js +20 -0
  12. package/data/data-composite-field.js +4 -2
  13. package/data/data-direct-owner.js +5 -0
  14. package/data/data-entity-membership.js +5 -0
  15. package/data/data-feature-flag.d.ts +1 -1
  16. package/data/data-feature-flag.js +7 -7
  17. package/data/data-file-embedding.js +23 -10
  18. package/data/data-image-embedding.js +15 -9
  19. package/data/data-job-trigger.js +3 -53
  20. package/data/data-jsonb.js +2 -1
  21. package/data/data-limit-counter.d.ts +1 -1
  22. package/data/data-limit-counter.js +7 -7
  23. package/data/data-meter-rate-limit.d.ts +2 -0
  24. package/data/data-meter-rate-limit.js +42 -0
  25. package/data/data-ownership-in-entity.js +5 -0
  26. package/data/data-peoplestamps.js +5 -0
  27. package/data/data-publishable.js +2 -2
  28. package/data/data-slug.js +3 -4
  29. package/data/data-tags.js +2 -1
  30. package/data/event-tracker.d.ts +2 -0
  31. package/data/event-tracker.js +74 -0
  32. package/data/index.d.ts +9 -4
  33. package/data/index.js +15 -5
  34. package/data/limit-warning-aggregate.d.ts +2 -0
  35. package/data/limit-warning-aggregate.js +27 -0
  36. package/data/limit-warning-counter.d.ts +2 -0
  37. package/data/limit-warning-counter.js +33 -0
  38. package/data/limit-warning-rate.d.ts +2 -0
  39. package/data/limit-warning-rate.js +33 -0
  40. package/data/process-extraction.js +15 -10
  41. package/data/process-image-versions.js +3 -9
  42. package/data/search-unified.js +20 -0
  43. package/data/search-vector.js +12 -0
  44. package/esm/blueprint-types.generated.d.ts +46 -1
  45. package/esm/codegen/generate-types.js +37 -1
  46. package/esm/conditions/index.d.ts +1 -0
  47. package/esm/conditions/index.js +1 -0
  48. package/esm/conditions/trigger-condition.d.ts +35 -0
  49. package/esm/conditions/trigger-condition.js +94 -0
  50. package/esm/data/data-aggregate-limit-counter.d.ts +1 -1
  51. package/esm/data/data-aggregate-limit-counter.js +6 -6
  52. package/esm/data/data-billing-meter.d.ts +1 -1
  53. package/esm/data/data-billing-meter.js +6 -6
  54. package/esm/data/data-chunks.js +20 -0
  55. package/esm/data/data-composite-field.js +4 -2
  56. package/esm/data/data-direct-owner.js +5 -0
  57. package/esm/data/data-entity-membership.js +5 -0
  58. package/esm/data/data-feature-flag.d.ts +1 -1
  59. package/esm/data/data-feature-flag.js +6 -6
  60. package/esm/data/data-file-embedding.js +23 -10
  61. package/esm/data/data-image-embedding.js +15 -9
  62. package/esm/data/data-job-trigger.js +3 -53
  63. package/esm/data/data-jsonb.js +2 -1
  64. package/esm/data/data-limit-counter.d.ts +1 -1
  65. package/esm/data/data-limit-counter.js +6 -6
  66. package/esm/data/data-meter-rate-limit.d.ts +2 -0
  67. package/esm/data/data-meter-rate-limit.js +39 -0
  68. package/esm/data/data-ownership-in-entity.js +5 -0
  69. package/esm/data/data-peoplestamps.js +5 -0
  70. package/esm/data/data-publishable.js +2 -2
  71. package/esm/data/data-slug.js +3 -4
  72. package/esm/data/data-tags.js +2 -1
  73. package/esm/data/event-tracker.d.ts +2 -0
  74. package/esm/data/event-tracker.js +71 -0
  75. package/esm/data/index.d.ts +9 -4
  76. package/esm/data/index.js +9 -4
  77. package/esm/data/limit-warning-aggregate.d.ts +2 -0
  78. package/esm/data/limit-warning-aggregate.js +24 -0
  79. package/esm/data/limit-warning-counter.d.ts +2 -0
  80. package/esm/data/limit-warning-counter.js +30 -0
  81. package/esm/data/limit-warning-rate.d.ts +2 -0
  82. package/esm/data/limit-warning-rate.js +30 -0
  83. package/esm/data/process-extraction.js +15 -10
  84. package/esm/data/process-image-versions.js +3 -9
  85. package/esm/data/search-unified.js +20 -0
  86. package/esm/data/search-vector.js +12 -0
  87. package/esm/index.d.ts +1 -0
  88. package/esm/index.js +1 -0
  89. package/index.d.ts +1 -0
  90. package/index.js +1 -0
  91. package/package.json +2 -2
@@ -53,6 +53,18 @@ exports.SearchVector = {
53
53
  },
54
54
  description: 'Column names that feed the embedding. Used by stale trigger to detect content changes.'
55
55
  },
56
+ // ── Model config (optional — flows into job payload) ──────────
57
+ embedding_model: {
58
+ type: 'string',
59
+ description: 'Embedding model identifier (e.g. "nomic-embed-text", "text-embedding-3-small"). ' +
60
+ 'Included in the job payload so the worker knows which model to use. ' +
61
+ 'When null, the worker falls back to runtime config (llm_module / env vars).'
62
+ },
63
+ embedding_provider: {
64
+ type: 'string',
65
+ description: 'Embedding provider name (e.g. "ollama", "openai"). ' +
66
+ 'When null, the worker falls back to runtime config.'
67
+ },
56
68
  enqueue_job: {
57
69
  type: 'boolean',
58
70
  description: 'Auto-create trigger that enqueues embedding generation jobs',
@@ -66,12 +66,14 @@ export interface DataDirectOwnerParams {
66
66
  owner_field_name?: string;
67
67
  include_id?: boolean;
68
68
  include_user_fk?: boolean;
69
+ create_index?: boolean;
69
70
  }
70
71
  /** Adds entity reference for organization/group scoping. Enables AuthzEntityMembership, AuthzMembership, AuthzOrgHierarchy authorization. */
71
72
  export interface DataEntityMembershipParams {
72
73
  entity_field_name?: string;
73
74
  include_id?: boolean;
74
75
  include_user_fk?: boolean;
76
+ create_index?: boolean;
75
77
  }
76
78
  /** BEFORE INSERT trigger that forces a field to the value of jwt_public.current_user_id(). Prevents clients from spoofing the actor/uploader identity. The field value is always overwritten regardless of what the client provides. */
77
79
  export interface DataForceCurrentUserParams {
@@ -115,6 +117,7 @@ export interface DataOwnershipInEntityParams {
115
117
  entity_field_name?: string;
116
118
  include_id?: boolean;
117
119
  include_user_fk?: boolean;
120
+ create_index?: boolean;
118
121
  }
119
122
  /** Adds user tracking for creates/updates with created_by and updated_by columns. */
120
123
  export interface DataPeoplestampsParams {
@@ -122,6 +125,7 @@ export interface DataPeoplestampsParams {
122
125
  updated_by_field?: string;
123
126
  include_id?: boolean;
124
127
  include_user_fk?: boolean;
128
+ create_index?: boolean;
125
129
  }
126
130
  /** Adds publish state columns (is_published, published_at) for content visibility. Enables AuthzPublishable and AuthzTemporal authorization. */
127
131
  export interface DataPublishableParams {
@@ -136,7 +140,7 @@ export interface DataRealtimeParams {
136
140
  }
137
141
  /** Auto-generates URL-friendly slugs from field values on insert/update. Attaches BEFORE INSERT and BEFORE UPDATE triggers that call inflection.slugify() on the target field. References fields by name in data jsonb. */
138
142
  export interface DataSlugParams {
139
- field_name: string;
143
+ field_name?: string;
140
144
  source_field_name?: string;
141
145
  }
142
146
  /** Adds soft delete support with deleted_at and is_deleted columns. */
@@ -271,6 +275,8 @@ export interface SearchUnifiedParams {
271
275
  chunking_task_name?: string;
272
276
  };
273
277
  };
278
+ embedding_text_field?: string;
279
+ composite_format?: 'labeled' | 'plain';
274
280
  trgm_fields?: string[];
275
281
  search_config?: {
276
282
  weights?: {
@@ -824,6 +830,41 @@ export interface BlueprintStorageConfig {
824
830
  buckets?: BlueprintEntityTableProvision;
825
831
  };
826
832
  }
833
+ /** A requirement entry within a blueprint achievement. Defines what events must occur to earn the achievement. */
834
+ export interface BlueprintAchievementRequirement {
835
+ /** Name identifier matching an event_type or step name. */
836
+ event_name: string;
837
+ /** Number of events needed to satisfy this requirement. */
838
+ count: number;
839
+ /** Human-readable description of what this requirement entails. */
840
+ description?: string;
841
+ }
842
+ /** A reward entry within a blueprint achievement. Defines credits granted when the achievement is earned. */
843
+ export interface BlueprintAchievementReward {
844
+ /** Type of reward: limit_credit (grants limit credits) or meter_credit (grants meter credits). */
845
+ reward_type: 'limit_credit' | 'meter_credit';
846
+ /** Target limit name or meter slug for the credit grant. */
847
+ target_name: string;
848
+ /** Number of credits to grant. */
849
+ amount: number;
850
+ /** Credit type: permanent, expiring, etc. Defaults to "permanent". */
851
+ credit_type?: string;
852
+ }
853
+ /** An achievement entry for the blueprint achievements[] section. Creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module). */
854
+ export interface BlueprintAchievement {
855
+ /** Unique name for the achievement level. */
856
+ name: string;
857
+ /** Human-readable description of this achievement. */
858
+ description?: string;
859
+ /** Display ordering priority; lower values appear first. Defaults to 100. */
860
+ priority?: number;
861
+ /** Requirements that must be met to earn this achievement. */
862
+ requirements: BlueprintAchievementRequirement[];
863
+ /** Rewards granted when the achievement is earned. */
864
+ rewards?: BlueprintAchievementReward[];
865
+ /** Entity prefix to scope this achievement to (e.g., "org", "app"). Used to resolve the correct events_module. Defaults to "app". */
866
+ entity_prefix?: string;
867
+ }
827
868
  /** Override object for the entity table created by a BlueprintEntityType. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, policies[] replaces the default entity-table policies entirely. */
828
869
  export interface BlueprintEntityTableProvision {
829
870
  /** Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true. */
@@ -864,6 +905,8 @@ export interface BlueprintEntityType {
864
905
  has_storage?: boolean;
865
906
  /** Whether to provision entity-scoped invite tables ({prefix}_invites, {prefix}_claimed_invites) and a submit_{prefix}_invite_code() function. Defaults to false. */
866
907
  has_invites?: boolean;
908
+ /** Whether to auto-attach an EventTracker to the claimed_invites table for invite-based achievements. Requires has_invites=true AND has_levels=true. When true, records 'invite_claimed' events credited to the sender (inviter) on each claimed invite. Defaults to false. */
909
+ has_invite_achievements?: boolean;
867
910
  /** Escape hatch: when true AND table_provision is NULL, zero policies are provisioned on the entity table. Defaults to false. */
868
911
  skip_entity_policies?: boolean;
869
912
  /** Override for the entity table. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, its policies[] replaces the five default entity-table policies; is_visible becomes a no-op. When NULL (default), the five default policies are applied (gated by is_visible). */
@@ -1136,4 +1179,6 @@ export interface BlueprintDefinition {
1136
1179
  entity_types?: BlueprintEntityType[];
1137
1180
  /** App-level storage configuration. Creates a storage_module (membership_type = NULL), seeds initial buckets, and overrides module-level settings (expiry times, file size limits, CORS). Use provisions for per-table policy overrides. For entity-scoped storage, use entity_types[].has_storage + entity_types[].storage instead. */
1138
1181
  storage?: BlueprintStorageConfig;
1182
+ /** Achievement definitions. Each entry creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module). */
1183
+ achievements?: BlueprintAchievement[];
1139
1184
  }
@@ -493,6 +493,37 @@ function buildBlueprintStorageConfig() {
493
493
  ])), 'Per-table overrides for storage tables. Each key targets a specific storage table (files, buckets) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision targeting the corresponding table. When a key includes policies[], those REPLACE the default storage policies for that table; tables without a key still get defaults.')
494
494
  ]), 'Storage configuration for an entity type. Seeds initial buckets, overrides module-level settings (expiry times, file size limits, CORS), and provides per-table provisioning overrides via provisions.');
495
495
  }
496
+ // ---------------------------------------------------------------------------
497
+ // Achievement types
498
+ // ---------------------------------------------------------------------------
499
+ function buildBlueprintAchievementRequirement() {
500
+ return addJSDoc(exportInterface('BlueprintAchievementRequirement', [
501
+ addJSDoc(requiredProp('event_name', t.tsStringKeyword()), 'Name identifier matching an event_type or step name.'),
502
+ addJSDoc(requiredProp('count', t.tsNumberKeyword()), 'Number of events needed to satisfy this requirement.'),
503
+ addJSDoc(optionalProp('description', t.tsStringKeyword()), 'Human-readable description of what this requirement entails.')
504
+ ]), 'A requirement entry within a blueprint achievement. Defines what events must occur to earn the achievement.');
505
+ }
506
+ function buildBlueprintAchievementReward() {
507
+ return addJSDoc(exportInterface('BlueprintAchievementReward', [
508
+ addJSDoc(requiredProp('reward_type', t.tsUnionType([
509
+ t.tsLiteralType(t.stringLiteral('limit_credit')),
510
+ t.tsLiteralType(t.stringLiteral('meter_credit'))
511
+ ])), 'Type of reward: limit_credit (grants limit credits) or meter_credit (grants meter credits).'),
512
+ addJSDoc(requiredProp('target_name', t.tsStringKeyword()), 'Target limit name or meter slug for the credit grant.'),
513
+ addJSDoc(requiredProp('amount', t.tsNumberKeyword()), 'Number of credits to grant.'),
514
+ addJSDoc(optionalProp('credit_type', t.tsStringKeyword()), 'Credit type: permanent, expiring, etc. Defaults to "permanent".')
515
+ ]), 'A reward entry within a blueprint achievement. Defines credits granted when the achievement is earned.');
516
+ }
517
+ function buildBlueprintAchievement() {
518
+ return addJSDoc(exportInterface('BlueprintAchievement', [
519
+ addJSDoc(requiredProp('name', t.tsStringKeyword()), 'Unique name for the achievement level.'),
520
+ addJSDoc(optionalProp('description', t.tsStringKeyword()), 'Human-readable description of this achievement.'),
521
+ addJSDoc(optionalProp('priority', t.tsNumberKeyword()), 'Display ordering priority; lower values appear first. Defaults to 100.'),
522
+ addJSDoc(requiredProp('requirements', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAchievementRequirement')))), 'Requirements that must be met to earn this achievement.'),
523
+ addJSDoc(optionalProp('rewards', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAchievementReward')))), 'Rewards granted when the achievement is earned.'),
524
+ addJSDoc(optionalProp('entity_prefix', t.tsStringKeyword()), 'Entity prefix to scope this achievement to (e.g., "org", "app"). Used to resolve the correct events_module. Defaults to "app".')
525
+ ]), 'An achievement entry for the blueprint achievements[] section. Creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module).');
526
+ }
496
527
  function buildBlueprintEntityTableProvision() {
497
528
  return addJSDoc(exportInterface('BlueprintEntityTableProvision', [
498
529
  addJSDoc(optionalProp('use_rls', t.tsBooleanKeyword()), 'Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true.'),
@@ -518,6 +549,7 @@ function buildBlueprintEntityType() {
518
549
  addJSDoc(optionalProp('has_levels', t.tsBooleanKeyword()), 'Whether to provision a levels module for this entity type. Defaults to false.'),
519
550
  addJSDoc(optionalProp('has_storage', t.tsBooleanKeyword()), 'Whether to provision a storage module (buckets, files tables) for this entity type. Defaults to false.'),
520
551
  addJSDoc(optionalProp('has_invites', t.tsBooleanKeyword()), 'Whether to provision entity-scoped invite tables ({prefix}_invites, {prefix}_claimed_invites) and a submit_{prefix}_invite_code() function. Defaults to false.'),
552
+ addJSDoc(optionalProp('has_invite_achievements', t.tsBooleanKeyword()), "Whether to auto-attach an EventTracker to the claimed_invites table for invite-based achievements. Requires has_invites=true AND has_levels=true. When true, records 'invite_claimed' events credited to the sender (inviter) on each claimed invite. Defaults to false."),
521
553
  addJSDoc(optionalProp('skip_entity_policies', t.tsBooleanKeyword()), 'Escape hatch: when true AND table_provision is NULL, zero policies are provisioned on the entity table. Defaults to false.'),
522
554
  addJSDoc(optionalProp('table_provision', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))), 'Override for the entity table. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, its policies[] replaces the five default entity-table policies; is_visible becomes a no-op. When NULL (default), the five default policies are applied (gated by is_visible).'),
523
555
  addJSDoc(optionalProp('storage', t.tsTypeReference(t.identifier('BlueprintStorageConfig'))), 'Storage configuration. Only used when has_storage is true. Controls RLS policies on storage tables, seeds initial buckets, and overrides module-level settings (expiry times, file size limits, CORS).')
@@ -548,7 +580,8 @@ function buildBlueprintDefinition() {
548
580
  addJSDoc(optionalProp('full_text_searches', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintFullTextSearch')))), 'Full-text search configurations.'),
549
581
  addJSDoc(optionalProp('unique_constraints', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintUniqueConstraint')))), 'Unique constraints on table columns.'),
550
582
  addJSDoc(optionalProp('entity_types', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintEntityType')))), 'Entity types to provision in Phase 0 (before tables). Each entry creates an entity table with membership modules and security.'),
551
- addJSDoc(optionalProp('storage', t.tsTypeReference(t.identifier('BlueprintStorageConfig'))), 'App-level storage configuration. Creates a storage_module (membership_type = NULL), seeds initial buckets, and overrides module-level settings (expiry times, file size limits, CORS). Use provisions for per-table policy overrides. For entity-scoped storage, use entity_types[].has_storage + entity_types[].storage instead.')
583
+ addJSDoc(optionalProp('storage', t.tsTypeReference(t.identifier('BlueprintStorageConfig'))), 'App-level storage configuration. Creates a storage_module (membership_type = NULL), seeds initial buckets, and overrides module-level settings (expiry times, file size limits, CORS). Use provisions for per-table policy overrides. For entity-scoped storage, use entity_types[].has_storage + entity_types[].storage instead.'),
584
+ addJSDoc(optionalProp('achievements', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAchievement')))), 'Achievement definitions. Each entry creates a level with requirements and optional rewards in the events_module. Requires events_module to be provisioned (e.g., via entity_types[].has_levels = true or modules includes events_module).')
552
585
  ]), 'The complete blueprint definition -- the JSONB shape accepted by construct_blueprint().');
553
586
  }
554
587
  // ---------------------------------------------------------------------------
@@ -607,6 +640,9 @@ function buildProgram(meta) {
607
640
  statements.push(buildBlueprintTableUniqueConstraint());
608
641
  statements.push(buildBlueprintBucketSeed());
609
642
  statements.push(buildBlueprintStorageConfig());
643
+ statements.push(buildBlueprintAchievementRequirement());
644
+ statements.push(buildBlueprintAchievementReward());
645
+ statements.push(buildBlueprintAchievement());
610
646
  statements.push(buildBlueprintEntityTableProvision());
611
647
  statements.push(buildBlueprintEntityType());
612
648
  // -- Node types discriminated union --
@@ -0,0 +1 @@
1
+ export { conditionDefs, conditionProperties, triggerConditionSchema, triggerConditionsProperty } from './trigger-condition';
@@ -0,0 +1 @@
1
+ export { conditionDefs, conditionProperties, triggerConditionSchema, triggerConditionsProperty } from './trigger-condition';
@@ -0,0 +1,35 @@
1
+ import type { JSONSchema } from '../types';
2
+ /**
3
+ * Shared trigger condition schema used by any node type that creates
4
+ * PostgreSQL triggers with conditional WHEN clauses.
5
+ *
6
+ * Consumed by: JobTrigger, EventTracker, ProcessExtraction,
7
+ * ProcessImageVersions, ProcessFileEmbedding, ProcessImageEmbedding.
8
+ *
9
+ * On the SQL side, these conditions are compiled to AST via
10
+ * metaschema_generators.build_condition_ast().
11
+ */
12
+ export declare const triggerConditionSchema: JSONSchema;
13
+ /**
14
+ * $defs block for parameter_schema. Spread into any node that uses conditions.
15
+ *
16
+ * Usage:
17
+ * parameter_schema: { type: 'object', $defs: conditionDefs, properties: { ... } }
18
+ */
19
+ export declare const conditionDefs: Record<string, JSONSchema>;
20
+ /**
21
+ * Common condition-related properties for trigger-based nodes.
22
+ * Three mutually exclusive options for WHEN clause specification.
23
+ *
24
+ * Usage:
25
+ * properties: { event_name: { ... }, ...conditionProperties }
26
+ */
27
+ export declare const conditionProperties: Record<string, JSONSchema>;
28
+ /**
29
+ * Standalone trigger_conditions property for nodes that compose on top of
30
+ * JobTrigger (Process* nodes). These use trigger_conditions instead of
31
+ * the full condition_field/conditions/watch_fields trio because the
32
+ * underlying JobTrigger handles the WHEN clause; this property adds
33
+ * additional conditions merged via AND.
34
+ */
35
+ export declare const triggerConditionsProperty: JSONSchema;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Shared trigger condition schema used by any node type that creates
3
+ * PostgreSQL triggers with conditional WHEN clauses.
4
+ *
5
+ * Consumed by: JobTrigger, EventTracker, ProcessExtraction,
6
+ * ProcessImageVersions, ProcessFileEmbedding, ProcessImageEmbedding.
7
+ *
8
+ * On the SQL side, these conditions are compiled to AST via
9
+ * metaschema_generators.build_condition_ast().
10
+ */
11
+ export const triggerConditionSchema = {
12
+ type: 'object',
13
+ description: 'A leaf condition ({field, op, value?, row?, ref?}) or a combinator ({AND, OR, NOT}).',
14
+ properties: {
15
+ field: { type: 'string', format: 'column-ref', description: 'Column name (validated against the table).' },
16
+ op: {
17
+ type: 'string',
18
+ enum: ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'NOT LIKE', 'IS NULL', 'IS NOT NULL', 'IS DISTINCT FROM'],
19
+ description: 'Comparison operator.'
20
+ },
21
+ value: { description: 'Comparison value. Type is resolved from the column definition. Omit for IS NULL, IS NOT NULL, IS DISTINCT FROM.' },
22
+ row: { type: 'string', enum: ['NEW', 'OLD'], default: 'NEW', description: 'Row reference (default: NEW).' },
23
+ ref: {
24
+ type: 'object',
25
+ description: 'Column reference for field-to-field comparison (alternative to value).',
26
+ properties: {
27
+ field: { type: 'string', format: 'column-ref' },
28
+ row: { type: 'string', enum: ['NEW', 'OLD'], default: 'NEW' }
29
+ }
30
+ },
31
+ AND: { type: 'array', description: 'Array of conditions combined with AND.', items: { $ref: '#/$defs/triggerCondition' } },
32
+ OR: { type: 'array', description: 'Array of conditions combined with OR.', items: { $ref: '#/$defs/triggerCondition' } },
33
+ NOT: { $ref: '#/$defs/triggerCondition', description: 'Negated condition.' }
34
+ }
35
+ };
36
+ /**
37
+ * $defs block for parameter_schema. Spread into any node that uses conditions.
38
+ *
39
+ * Usage:
40
+ * parameter_schema: { type: 'object', $defs: conditionDefs, properties: { ... } }
41
+ */
42
+ export const conditionDefs = {
43
+ triggerCondition: triggerConditionSchema
44
+ };
45
+ /**
46
+ * Common condition-related properties for trigger-based nodes.
47
+ * Three mutually exclusive options for WHEN clause specification.
48
+ *
49
+ * Usage:
50
+ * properties: { event_name: { ... }, ...conditionProperties }
51
+ */
52
+ export const conditionProperties = {
53
+ condition_field: {
54
+ type: 'string',
55
+ format: 'column-ref',
56
+ description: 'Column name for conditional WHEN clause (fires only when field equals condition_value)'
57
+ },
58
+ condition_value: {
59
+ type: 'string',
60
+ description: 'Value to compare against condition_field in WHEN clause'
61
+ },
62
+ conditions: {
63
+ description: 'Compound conditions for the trigger WHEN clause. Accepts a single leaf condition, an array of conditions (implicitly AND), or a nested combinator tree ({AND: [...], OR: [...], NOT: {...}}). Each leaf is {field, op, value?, row?, ref?}. Column types are resolved automatically from the table schema. Cannot be combined with condition_field or watch_fields.',
64
+ 'x-codegen-type': 'TriggerCondition | TriggerCondition[]',
65
+ oneOf: [
66
+ { $ref: '#/$defs/triggerCondition' },
67
+ { type: 'array', items: { $ref: '#/$defs/triggerCondition' } }
68
+ ]
69
+ },
70
+ watch_fields: {
71
+ type: 'array',
72
+ items: {
73
+ type: 'string',
74
+ format: 'column-ref'
75
+ },
76
+ description: 'For UPDATE triggers, only fire when these fields change (uses DISTINCT FROM)'
77
+ }
78
+ };
79
+ /**
80
+ * Standalone trigger_conditions property for nodes that compose on top of
81
+ * JobTrigger (Process* nodes). These use trigger_conditions instead of
82
+ * the full condition_field/conditions/watch_fields trio because the
83
+ * underlying JobTrigger handles the WHEN clause; this property adds
84
+ * additional conditions merged via AND.
85
+ */
86
+ export const triggerConditionsProperty = {
87
+ description: 'Additional compound conditions beyond auto-generated filtering. ' +
88
+ 'Merged with the auto-generated conditions via AND.',
89
+ 'x-codegen-type': 'TriggerCondition | TriggerCondition[]',
90
+ oneOf: [
91
+ { $ref: '#/$defs/triggerCondition' },
92
+ { type: 'array', items: { $ref: '#/$defs/triggerCondition' } }
93
+ ]
94
+ };
@@ -1,2 +1,2 @@
1
1
  import type { NodeTypeDefinition } from '../types';
2
- export declare const LimitAggregate: NodeTypeDefinition;
2
+ export declare const LimitEnforceAggregate: NodeTypeDefinition;
@@ -1,8 +1,8 @@
1
- export const LimitAggregate = {
2
- name: 'LimitAggregate',
3
- slug: 'data_aggregate_limit_counter',
4
- category: 'limit',
5
- display_name: 'Aggregate Limit Counter',
1
+ export const LimitEnforceAggregate = {
2
+ name: 'LimitEnforceAggregate',
3
+ slug: 'limit_enforce_aggregate',
4
+ category: 'limit_enforce',
5
+ display_name: 'Enforce Aggregate Counter',
6
6
  description: 'Declaratively attaches aggregate limit-tracking triggers to a table. On INSERT the named limit is incremented per entity; on DELETE it is decremented. Uses org_limit_aggregates_inc/dec for per-entity (org-level) aggregate limits rather than per-user limits. Requires a provisioned limits_module for the target database.',
7
7
  parameter_schema: {
8
8
  type: 'object',
@@ -29,5 +29,5 @@ export const LimitAggregate = {
29
29
  },
30
30
  required: ['limit_name'],
31
31
  },
32
- tags: ['limits', 'triggers', 'aggregates', 'billing'],
32
+ tags: ['limits', 'triggers', 'aggregates', 'enforce'],
33
33
  };
@@ -1,2 +1,2 @@
1
1
  import type { NodeTypeDefinition } from '../types';
2
- export declare const BillingMeter: NodeTypeDefinition;
2
+ export declare const LimitTrackUsage: NodeTypeDefinition;
@@ -1,8 +1,8 @@
1
- export const BillingMeter = {
2
- name: 'BillingMeter',
3
- slug: 'data_billing_meter',
4
- category: 'billing',
5
- display_name: 'Billing Meter',
1
+ export const LimitTrackUsage = {
2
+ name: 'LimitTrackUsage',
3
+ slug: 'limit_track_usage',
4
+ category: 'limit_track',
5
+ display_name: 'Track Usage',
6
6
  description: 'Declaratively attaches billing usage-recording triggers to a table. On INSERT the named meter is incremented via record_usage; on DELETE it is decremented (reversal). On UPDATE, if the entity_field changes, the old entity is decremented and the new entity is incremented. Requires a provisioned billing_module for the target database.',
7
7
  parameter_schema: {
8
8
  type: 'object',
@@ -34,5 +34,5 @@ export const BillingMeter = {
34
34
  },
35
35
  required: ['meter_slug'],
36
36
  },
37
- tags: ['billing', 'triggers', 'metering', 'usage'],
37
+ tags: ['billing', 'triggers', 'metering', 'usage', 'track'],
38
38
  };
@@ -63,6 +63,17 @@ export const ProcessChunks = {
63
63
  description: 'Distance metric for the HNSW index on chunk embeddings',
64
64
  default: 'cosine'
65
65
  },
66
+ // ── Model config (optional — flows into job payload) ──────────
67
+ embedding_model: {
68
+ type: 'string',
69
+ description: 'Embedding model identifier for per-chunk embeddings. ' +
70
+ 'When null, the worker falls back to runtime config (llm_module / env vars).'
71
+ },
72
+ embedding_provider: {
73
+ type: 'string',
74
+ description: 'Embedding provider name (e.g. "ollama", "openai"). ' +
75
+ 'When null, the worker falls back to runtime config.'
76
+ },
66
77
  // ── Table naming ───────────────────────────────────────────────
67
78
  chunks_table_name: {
68
79
  type: 'string',
@@ -74,6 +85,15 @@ export const ProcessChunks = {
74
85
  items: { type: 'string' },
75
86
  description: 'Field names from the parent table to copy into chunk metadata'
76
87
  },
88
+ // ── Search indexes ───────────────────────────────────────────────
89
+ search_indexes: {
90
+ type: 'array',
91
+ items: { type: 'string', enum: ['fulltext', 'bm25', 'trigram'] },
92
+ description: 'Text search indexes to create on the chunks content column. ' +
93
+ 'Enables keyword-based retrieval alongside vector search for ' +
94
+ 'hybrid RAG workflows.',
95
+ default: ['fulltext']
96
+ },
77
97
  // ── Job trigger ────────────────────────────────────────────────
78
98
  enqueue_chunking_job: {
79
99
  type: 'boolean',
@@ -10,7 +10,8 @@ export const DataCompositeField = {
10
10
  target: {
11
11
  type: 'string',
12
12
  format: 'column-ref',
13
- description: "Name of the derived text field to create (default: 'embedding_text')"
13
+ description: 'Name of the derived text field to create',
14
+ default: 'embedding_text'
14
15
  },
15
16
  source_fields: {
16
17
  type: 'array',
@@ -23,7 +24,8 @@ export const DataCompositeField = {
23
24
  format: {
24
25
  type: 'string',
25
26
  enum: ['labeled', 'plain'],
26
- description: "Output format: 'labeled' (field_name: value) or 'plain' (values only). Default: 'labeled'"
27
+ description: "Output format: 'labeled' (field_name: value) or 'plain' (values only)",
28
+ default: 'labeled'
27
29
  }
28
30
  },
29
31
  required: [
@@ -22,6 +22,11 @@ export const DataDirectOwner = {
22
22
  type: 'boolean',
23
23
  description: 'If true, adds a foreign key constraint from owner_id to the users table',
24
24
  default: true
25
+ },
26
+ create_index: {
27
+ type: 'boolean',
28
+ description: 'If true, creates a B-tree index on the owner column',
29
+ default: true
25
30
  }
26
31
  }
27
32
  },
@@ -22,6 +22,11 @@ export const DataEntityMembership = {
22
22
  type: 'boolean',
23
23
  description: 'If true, adds a foreign key constraint from entity_id to the users table',
24
24
  default: true
25
+ },
26
+ create_index: {
27
+ type: 'boolean',
28
+ description: 'If true, creates a B-tree index on the entity column',
29
+ default: true
25
30
  }
26
31
  }
27
32
  },
@@ -1,2 +1,2 @@
1
1
  import type { NodeTypeDefinition } from '../types';
2
- export declare const LimitFeatureFlag: NodeTypeDefinition;
2
+ export declare const LimitEnforceFeature: NodeTypeDefinition;
@@ -1,8 +1,8 @@
1
- export const LimitFeatureFlag = {
2
- name: 'LimitFeatureFlag',
3
- slug: 'data_feature_flag',
4
- category: 'limit',
5
- display_name: 'Feature Flag',
1
+ export const LimitEnforceFeature = {
2
+ name: 'LimitEnforceFeature',
3
+ slug: 'limit_enforce_feature',
4
+ category: 'limit_enforce',
5
+ display_name: 'Enforce Feature Flag',
6
6
  description: 'Gates a table behind a feature flag backed by the cap tables. Attaches a BEFORE INSERT trigger that checks whether the named feature cap value is > 0. Features are modeled as caps with max=0 (disabled) or max=1 (enabled) in limit_caps / limit_caps_defaults tables. Resolution: COALESCE(per-entity cap, scope default, 0).',
7
7
  parameter_schema: {
8
8
  type: 'object',
@@ -26,5 +26,5 @@ export const LimitFeatureFlag = {
26
26
  },
27
27
  required: ['feature_name'],
28
28
  },
29
- tags: ['limits', 'triggers', 'feature-flags', 'billing', 'caps'],
29
+ tags: ['limits', 'triggers', 'feature-flags', 'enforce', 'caps'],
30
30
  };
@@ -1,3 +1,4 @@
1
+ import { conditionDefs, triggerConditionsProperty } from '../conditions';
1
2
  export const ProcessFileEmbedding = {
2
3
  name: 'ProcessFileEmbedding',
3
4
  slug: 'data_file_embedding',
@@ -12,6 +13,7 @@ export const ProcessFileEmbedding = {
12
13
  'names, and embedding strategies.',
13
14
  parameter_schema: {
14
15
  type: 'object',
16
+ $defs: conditionDefs,
15
17
  properties: {
16
18
  // ── Vector config (passed through to SearchVector) ─────────────
17
19
  field_name: {
@@ -42,6 +44,18 @@ export const ProcessFileEmbedding = {
42
44
  description: 'Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.',
43
45
  default: {}
44
46
  },
47
+ // ── Model config (optional — flows into job payload) ──────────
48
+ embedding_model: {
49
+ type: 'string',
50
+ description: 'Embedding model identifier (e.g. "nomic-embed-text", "text-embedding-3-small", ' +
51
+ '"clip-vit-base-patch32"). Included in the job payload so the worker knows which ' +
52
+ 'model to use. When null, the worker falls back to runtime config (llm_module / env vars).'
53
+ },
54
+ embedding_provider: {
55
+ type: 'string',
56
+ description: 'Embedding provider name (e.g. "ollama", "openai"). ' +
57
+ 'When null, the worker falls back to runtime config.'
58
+ },
45
59
  // ── MIME scoping ───────────────────────────────────────────────
46
60
  mime_patterns: {
47
61
  type: 'array',
@@ -74,16 +88,7 @@ export const ProcessFileEmbedding = {
74
88
  bucket_id: 'bucket_id'
75
89
  }
76
90
  },
77
- trigger_conditions: {
78
- description: 'Additional compound conditions beyond MIME filtering. ' +
79
- 'Merged with the auto-generated MIME conditions via AND. ' +
80
- 'Use this to add status checks, field guards, etc.',
81
- 'x-codegen-type': 'TriggerCondition | TriggerCondition[]',
82
- oneOf: [
83
- { $ref: '#/$defs/triggerCondition' },
84
- { type: 'array', items: { $ref: '#/$defs/triggerCondition' } }
85
- ]
86
- },
91
+ trigger_conditions: triggerConditionsProperty,
87
92
  // ── Extraction config (optional — enables extract mode) ────────
88
93
  extraction: {
89
94
  type: 'object',
@@ -118,6 +123,7 @@ export const ProcessFileEmbedding = {
118
123
  description: 'Chunking configuration passed through to ProcessChunks. When ' +
119
124
  'include_chunks is true (or defaults to true in extract mode), these ' +
120
125
  'params configure the chunks table, embedding dimensions, strategy, etc.',
126
+ default: {},
121
127
  properties: {
122
128
  content_field_name: {
123
129
  type: 'string',
@@ -146,6 +152,13 @@ export const ProcessFileEmbedding = {
146
152
  items: { type: 'string' },
147
153
  description: 'Field names from parent to copy into chunk metadata'
148
154
  },
155
+ search_indexes: {
156
+ type: 'array',
157
+ items: { type: 'string', enum: ['fulltext', 'bm25', 'trigram'] },
158
+ description: 'Text search indexes to create on the chunks content column. ' +
159
+ 'Enables keyword-based retrieval alongside vector search.',
160
+ default: ['fulltext']
161
+ },
149
162
  enqueue_chunking_job: {
150
163
  type: 'boolean',
151
164
  description: 'Whether to auto-enqueue a chunking job on insert/update',
@@ -1,3 +1,4 @@
1
+ import { conditionDefs, triggerConditionsProperty } from '../conditions';
1
2
  /**
2
3
  * Image-specific preset of ProcessFileEmbedding.
3
4
  *
@@ -21,6 +22,7 @@ export const ProcessImageEmbedding = {
21
22
  'Accepts all ProcessFileEmbedding parameters — any overrides are forwarded through.',
22
23
  parameter_schema: {
23
24
  type: 'object',
25
+ $defs: conditionDefs,
24
26
  properties: {
25
27
  // ── Vector config (passed through to ProcessFileEmbedding) ──────────
26
28
  field_name: {
@@ -51,6 +53,18 @@ export const ProcessImageEmbedding = {
51
53
  description: 'Index-specific options. HNSW: {m, ef_construction}. IVFFlat: {lists}.',
52
54
  default: {}
53
55
  },
56
+ // ── Model config (optional — flows into job payload) ──────────
57
+ embedding_model: {
58
+ type: 'string',
59
+ description: 'Embedding model identifier (e.g. "clip-vit-base-patch32"). ' +
60
+ 'Included in the job payload so the worker knows which model to use. ' +
61
+ 'When null, the worker falls back to runtime config (llm_module / env vars).'
62
+ },
63
+ embedding_provider: {
64
+ type: 'string',
65
+ description: 'Embedding provider name (e.g. "ollama", "openai"). ' +
66
+ 'When null, the worker falls back to runtime config.'
67
+ },
54
68
  // ── MIME scoping ───────────────────────────────────────────────
55
69
  mime_patterns: {
56
70
  type: 'array',
@@ -81,15 +95,7 @@ export const ProcessImageEmbedding = {
81
95
  bucket_id: 'bucket_id'
82
96
  }
83
97
  },
84
- trigger_conditions: {
85
- description: 'Additional compound conditions beyond MIME filtering. ' +
86
- 'Merged with the auto-generated MIME conditions via AND.',
87
- 'x-codegen-type': 'TriggerCondition | TriggerCondition[]',
88
- oneOf: [
89
- { $ref: '#/$defs/triggerCondition' },
90
- { type: 'array', items: { $ref: '#/$defs/triggerCondition' } }
91
- ]
92
- },
98
+ trigger_conditions: triggerConditionsProperty,
93
99
  // ── Extraction config (optional — enables extract mode) ────────
94
100
  extraction: {
95
101
  type: 'object',