node-type-registry 0.36.0 → 0.38.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 (133) hide show
  1. package/blueprint-types.generated.d.ts +46 -7
  2. package/codegen/generate-types.js +40 -4
  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/index.d.ts +0 -10
  8. package/data/index.js +1 -21
  9. package/data/search-unified.js +8 -0
  10. package/data/search-vector.js +12 -0
  11. package/esm/blueprint-types.generated.d.ts +46 -7
  12. package/esm/codegen/generate-types.js +40 -4
  13. package/esm/conditions/index.d.ts +1 -0
  14. package/esm/conditions/index.js +1 -0
  15. package/esm/conditions/trigger-condition.d.ts +35 -0
  16. package/esm/conditions/trigger-condition.js +94 -0
  17. package/esm/data/index.d.ts +0 -10
  18. package/esm/data/index.js +0 -10
  19. package/esm/data/search-unified.js +8 -0
  20. package/esm/data/search-vector.js +12 -0
  21. package/esm/event/index.d.ts +2 -0
  22. package/esm/event/index.js +2 -0
  23. package/esm/event/referral.d.ts +2 -0
  24. package/esm/event/referral.js +62 -0
  25. package/esm/event/tracker.d.ts +2 -0
  26. package/esm/event/tracker.js +71 -0
  27. package/esm/index.d.ts +5 -0
  28. package/esm/index.js +13 -0
  29. package/esm/job/index.d.ts +1 -0
  30. package/esm/job/index.js +1 -0
  31. package/esm/{data/data-job-trigger.js → job/trigger.js} +3 -53
  32. package/esm/limit/enforce-aggregate.d.ts +2 -0
  33. package/esm/{data/data-aggregate-limit-counter.js → limit/enforce-aggregate.js} +6 -6
  34. package/esm/limit/enforce-counter.d.ts +2 -0
  35. package/esm/{data/data-limit-counter.js → limit/enforce-counter.js} +6 -6
  36. package/esm/limit/enforce-feature.d.ts +2 -0
  37. package/esm/{data/data-feature-flag.js → limit/enforce-feature.js} +6 -6
  38. package/esm/limit/enforce-rate.d.ts +2 -0
  39. package/esm/limit/enforce-rate.js +39 -0
  40. package/esm/limit/index.d.ts +8 -0
  41. package/esm/limit/index.js +8 -0
  42. package/esm/limit/track-usage.d.ts +2 -0
  43. package/esm/{data/data-billing-meter.js → limit/track-usage.js} +6 -6
  44. package/esm/limit/warning-aggregate.d.ts +2 -0
  45. package/esm/limit/warning-aggregate.js +24 -0
  46. package/esm/limit/warning-counter.d.ts +2 -0
  47. package/esm/limit/warning-counter.js +30 -0
  48. package/esm/limit/warning-rate.d.ts +2 -0
  49. package/esm/limit/warning-rate.js +30 -0
  50. package/esm/module-presets/auth-email-magic.js +2 -2
  51. package/esm/module-presets/auth-email.js +5 -5
  52. package/esm/module-presets/auth-hardened.js +2 -2
  53. package/esm/module-presets/auth-passkey.js +2 -2
  54. package/esm/module-presets/auth-sso.d.ts +1 -1
  55. package/esm/module-presets/auth-sso.js +5 -5
  56. package/esm/module-presets/b2b-storage.js +6 -6
  57. package/esm/module-presets/b2b.js +2 -2
  58. package/esm/module-presets/minimal.d.ts +1 -1
  59. package/esm/module-presets/minimal.js +3 -3
  60. package/esm/{data/data-chunks.js → process/chunks.js} +19 -0
  61. package/esm/{data/process-extraction.js → process/extraction.js} +15 -10
  62. package/esm/{data/data-file-embedding.js → process/file-embedding.js} +22 -10
  63. package/esm/{data/data-image-embedding.js → process/image-embedding.js} +15 -9
  64. package/esm/{data/process-image-versions.js → process/image-versions.js} +3 -9
  65. package/esm/process/index.d.ts +5 -0
  66. package/esm/process/index.js +5 -0
  67. package/event/index.d.ts +2 -0
  68. package/event/index.js +7 -0
  69. package/event/referral.d.ts +2 -0
  70. package/event/referral.js +65 -0
  71. package/event/tracker.d.ts +2 -0
  72. package/event/tracker.js +74 -0
  73. package/index.d.ts +5 -0
  74. package/index.js +13 -0
  75. package/job/index.d.ts +1 -0
  76. package/job/index.js +5 -0
  77. package/{data/data-job-trigger.js → job/trigger.js} +3 -53
  78. package/limit/enforce-aggregate.d.ts +2 -0
  79. package/{data/data-aggregate-limit-counter.js → limit/enforce-aggregate.js} +7 -7
  80. package/limit/enforce-counter.d.ts +2 -0
  81. package/{data/data-limit-counter.js → limit/enforce-counter.js} +7 -7
  82. package/limit/enforce-feature.d.ts +2 -0
  83. package/{data/data-feature-flag.js → limit/enforce-feature.js} +7 -7
  84. package/limit/enforce-rate.d.ts +2 -0
  85. package/limit/enforce-rate.js +42 -0
  86. package/limit/index.d.ts +8 -0
  87. package/limit/index.js +19 -0
  88. package/limit/track-usage.d.ts +2 -0
  89. package/{data/data-billing-meter.js → limit/track-usage.js} +7 -7
  90. package/limit/warning-aggregate.d.ts +2 -0
  91. package/limit/warning-aggregate.js +27 -0
  92. package/limit/warning-counter.d.ts +2 -0
  93. package/limit/warning-counter.js +33 -0
  94. package/limit/warning-rate.d.ts +2 -0
  95. package/limit/warning-rate.js +33 -0
  96. package/module-presets/auth-email-magic.js +2 -2
  97. package/module-presets/auth-email.js +5 -5
  98. package/module-presets/auth-hardened.js +2 -2
  99. package/module-presets/auth-passkey.js +2 -2
  100. package/module-presets/auth-sso.d.ts +1 -1
  101. package/module-presets/auth-sso.js +5 -5
  102. package/module-presets/b2b-storage.js +6 -6
  103. package/module-presets/b2b.js +2 -2
  104. package/module-presets/minimal.d.ts +1 -1
  105. package/module-presets/minimal.js +3 -3
  106. package/package.json +2 -2
  107. package/{data/data-chunks.js → process/chunks.js} +19 -0
  108. package/{data/process-extraction.js → process/extraction.js} +15 -10
  109. package/{data/data-file-embedding.js → process/file-embedding.js} +22 -10
  110. package/{data/data-image-embedding.js → process/image-embedding.js} +15 -9
  111. package/{data/process-image-versions.js → process/image-versions.js} +3 -9
  112. package/process/index.d.ts +5 -0
  113. package/process/index.js +13 -0
  114. package/data/data-aggregate-limit-counter.d.ts +0 -2
  115. package/data/data-billing-meter.d.ts +0 -2
  116. package/data/data-feature-flag.d.ts +0 -2
  117. package/data/data-limit-counter.d.ts +0 -2
  118. package/esm/data/data-aggregate-limit-counter.d.ts +0 -2
  119. package/esm/data/data-billing-meter.d.ts +0 -2
  120. package/esm/data/data-feature-flag.d.ts +0 -2
  121. package/esm/data/data-limit-counter.d.ts +0 -2
  122. /package/{data/data-job-trigger.d.ts → esm/job/trigger.d.ts} +0 -0
  123. /package/{data/data-chunks.d.ts → esm/process/chunks.d.ts} +0 -0
  124. /package/{data/process-extraction.d.ts → esm/process/extraction.d.ts} +0 -0
  125. /package/{data/data-file-embedding.d.ts → esm/process/file-embedding.d.ts} +0 -0
  126. /package/{data/data-image-embedding.d.ts → esm/process/image-embedding.d.ts} +0 -0
  127. /package/{data/process-image-versions.d.ts → esm/process/image-versions.d.ts} +0 -0
  128. /package/{esm/data/data-job-trigger.d.ts → job/trigger.d.ts} +0 -0
  129. /package/{esm/data/data-chunks.d.ts → process/chunks.d.ts} +0 -0
  130. /package/{esm/data/process-extraction.d.ts → process/extraction.d.ts} +0 -0
  131. /package/{esm/data/data-file-embedding.d.ts → process/file-embedding.d.ts} +0 -0
  132. /package/{esm/data/data-image-embedding.d.ts → process/image-embedding.d.ts} +0 -0
  133. /package/{esm/data/process-image-versions.d.ts → process/image-versions.d.ts} +0 -0
@@ -480,7 +480,8 @@ function buildBlueprintBucketSeed() {
480
480
  */
481
481
  function buildBlueprintStorageConfig() {
482
482
  return addJSDoc(exportInterface('BlueprintStorageConfig', [
483
- addJSDoc(optionalProp('buckets', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintBucketSeed')))), 'Initial bucket seed entries. Each creates a row in {prefix}_buckets during provisioning. Only used for app-level storage (not entity-scoped).'),
483
+ addJSDoc(optionalProp('storage_key', t.tsStringKeyword()), 'Discriminator for multi-module storage. Defaults to "default" (omitted from table names). Non-default keys appear as an infix: {prefix}_{storage_key}_buckets. Max 16 chars, lowercase snake_case.'),
484
+ addJSDoc(optionalProp('buckets', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintBucketSeed')))), 'Initial bucket seed entries. Each creates a row in {prefix}_buckets during provisioning.'),
484
485
  addJSDoc(optionalProp('upload_url_expiry_seconds', t.tsNumberKeyword()), 'Override for presigned upload URL expiry time in seconds.'),
485
486
  addJSDoc(optionalProp('download_url_expiry_seconds', t.tsNumberKeyword()), 'Override for presigned download URL expiry time in seconds.'),
486
487
  addJSDoc(optionalProp('default_max_file_size', t.tsNumberKeyword()), 'Default maximum file size in bytes for the storage module.'),
@@ -493,6 +494,37 @@ function buildBlueprintStorageConfig() {
493
494
  ])), '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
495
  ]), '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
496
  }
497
+ // ---------------------------------------------------------------------------
498
+ // Achievement types
499
+ // ---------------------------------------------------------------------------
500
+ function buildBlueprintAchievementRequirement() {
501
+ return addJSDoc(exportInterface('BlueprintAchievementRequirement', [
502
+ addJSDoc(requiredProp('event_name', t.tsStringKeyword()), 'Name identifier matching an event_type or step name.'),
503
+ addJSDoc(requiredProp('count', t.tsNumberKeyword()), 'Number of events needed to satisfy this requirement.'),
504
+ addJSDoc(optionalProp('description', t.tsStringKeyword()), 'Human-readable description of what this requirement entails.')
505
+ ]), 'A requirement entry within a blueprint achievement. Defines what events must occur to earn the achievement.');
506
+ }
507
+ function buildBlueprintAchievementReward() {
508
+ return addJSDoc(exportInterface('BlueprintAchievementReward', [
509
+ addJSDoc(requiredProp('reward_type', t.tsUnionType([
510
+ t.tsLiteralType(t.stringLiteral('limit_credit')),
511
+ t.tsLiteralType(t.stringLiteral('meter_credit'))
512
+ ])), 'Type of reward: limit_credit (grants limit credits) or meter_credit (grants meter credits).'),
513
+ addJSDoc(requiredProp('target_name', t.tsStringKeyword()), 'Target limit name or meter slug for the credit grant.'),
514
+ addJSDoc(requiredProp('amount', t.tsNumberKeyword()), 'Number of credits to grant.'),
515
+ addJSDoc(optionalProp('credit_type', t.tsStringKeyword()), 'Credit type: permanent, expiring, etc. Defaults to "permanent".')
516
+ ]), 'A reward entry within a blueprint achievement. Defines credits granted when the achievement is earned.');
517
+ }
518
+ function buildBlueprintAchievement() {
519
+ return addJSDoc(exportInterface('BlueprintAchievement', [
520
+ addJSDoc(requiredProp('name', t.tsStringKeyword()), 'Unique name for the achievement level.'),
521
+ addJSDoc(optionalProp('description', t.tsStringKeyword()), 'Human-readable description of this achievement.'),
522
+ addJSDoc(optionalProp('priority', t.tsNumberKeyword()), 'Display ordering priority; lower values appear first. Defaults to 100.'),
523
+ addJSDoc(requiredProp('requirements', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAchievementRequirement')))), 'Requirements that must be met to earn this achievement.'),
524
+ addJSDoc(optionalProp('rewards', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAchievementReward')))), 'Rewards granted when the achievement is earned.'),
525
+ 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".')
526
+ ]), '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).');
527
+ }
496
528
  function buildBlueprintEntityTableProvision() {
497
529
  return addJSDoc(exportInterface('BlueprintEntityTableProvision', [
498
530
  addJSDoc(optionalProp('use_rls', t.tsBooleanKeyword()), 'Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true.'),
@@ -516,11 +548,11 @@ function buildBlueprintEntityType() {
516
548
  addJSDoc(optionalProp('has_limits', t.tsBooleanKeyword()), 'Whether to provision a limits module for this entity type. Defaults to false.'),
517
549
  addJSDoc(optionalProp('has_profiles', t.tsBooleanKeyword()), 'Whether to provision a profiles module for this entity type. Defaults to false.'),
518
550
  addJSDoc(optionalProp('has_levels', t.tsBooleanKeyword()), 'Whether to provision a levels module for this entity type. Defaults to false.'),
519
- 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
- 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).')
555
+ addJSDoc(optionalProp('storage', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintStorageConfig')))), 'Storage module configuration array. Each entry provisions a separate storage module with its own tables, RLS, and settings. When non-empty, has_storage is derived as true. Each entry may specify a storage_key for multi-module support (defaults to "default").')
524
556
  ]), 'An entity type entry for Phase 0 of construct_blueprint(). Provisions a full entity type with its own entity table, membership modules, and security policies via entity_type_provision.');
525
557
  }
526
558
  function buildBlueprintTable() {
@@ -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.tsArrayType(t.tsTypeReference(t.identifier('BlueprintStorageConfig')))), 'App-level storage configuration array. Each entry creates a storage_module (membership_type = NULL) with its own tables and settings. For entity-scoped storage, use 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
+ };
@@ -2,27 +2,17 @@ export { CheckGreaterThan } from './check-greater-than';
2
2
  export { CheckLessThan } from './check-less-than';
3
3
  export { CheckNotEqual } from './check-not-equal';
4
4
  export { CheckOneOf } from './check-one-of';
5
- export { LimitAggregate } from './data-aggregate-limit-counter';
6
- export { BillingMeter } from './data-billing-meter';
7
5
  export { DataBulk } from './data-bulk';
8
- export { ProcessChunks } from './data-chunks';
9
6
  export { DataCompositeField } from './data-composite-field';
10
7
  export { DataDirectOwner } from './data-direct-owner';
11
8
  export { DataEntityMembership } from './data-entity-membership';
12
- export { ProcessFileEmbedding } from './data-file-embedding';
13
- export { LimitFeatureFlag } from './data-feature-flag';
14
9
  export { DataForceCurrentUser } from './data-force-current-user';
15
10
  export { DataId } from './data-id';
16
- export { ProcessImageEmbedding } from './data-image-embedding';
17
11
  export { DataImmutableFields } from './data-immutable-fields';
18
12
  export { DataInflection } from './data-inflection';
19
13
  export { DataInheritFromParent } from './data-inherit-from-parent';
20
- export { JobTrigger } from './data-job-trigger';
21
- export { LimitCounter } from './data-limit-counter';
22
14
  export { DataJsonb } from './data-jsonb';
23
15
  export { DataOwnedFields } from './data-owned-fields';
24
- export { ProcessExtraction } from './process-extraction';
25
- export { ProcessImageVersions } from './process-image-versions';
26
16
  export { DataOwnershipInEntity } from './data-ownership-in-entity';
27
17
  export { DataPeoplestamps } from './data-peoplestamps';
28
18
  export { DataPublishable } from './data-publishable';
package/esm/data/index.js CHANGED
@@ -2,27 +2,17 @@ export { CheckGreaterThan } from './check-greater-than';
2
2
  export { CheckLessThan } from './check-less-than';
3
3
  export { CheckNotEqual } from './check-not-equal';
4
4
  export { CheckOneOf } from './check-one-of';
5
- export { LimitAggregate } from './data-aggregate-limit-counter';
6
- export { BillingMeter } from './data-billing-meter';
7
5
  export { DataBulk } from './data-bulk';
8
- export { ProcessChunks } from './data-chunks';
9
6
  export { DataCompositeField } from './data-composite-field';
10
7
  export { DataDirectOwner } from './data-direct-owner';
11
8
  export { DataEntityMembership } from './data-entity-membership';
12
- export { ProcessFileEmbedding } from './data-file-embedding';
13
- export { LimitFeatureFlag } from './data-feature-flag';
14
9
  export { DataForceCurrentUser } from './data-force-current-user';
15
10
  export { DataId } from './data-id';
16
- export { ProcessImageEmbedding } from './data-image-embedding';
17
11
  export { DataImmutableFields } from './data-immutable-fields';
18
12
  export { DataInflection } from './data-inflection';
19
13
  export { DataInheritFromParent } from './data-inherit-from-parent';
20
- export { JobTrigger } from './data-job-trigger';
21
- export { LimitCounter } from './data-limit-counter';
22
14
  export { DataJsonb } from './data-jsonb';
23
15
  export { DataOwnedFields } from './data-owned-fields';
24
- export { ProcessExtraction } from './process-extraction';
25
- export { ProcessImageVersions } from './process-image-versions';
26
16
  export { DataOwnershipInEntity } from './data-ownership-in-entity';
27
17
  export { DataPeoplestamps } from './data-peoplestamps';
28
18
  export { DataPublishable } from './data-publishable';
@@ -108,6 +108,14 @@ export const SearchUnified = {
108
108
  format: 'column-ref'
109
109
  }
110
110
  },
111
+ embedding_model: {
112
+ type: 'string',
113
+ description: 'Embedding model identifier. When null, the worker falls back to runtime config.'
114
+ },
115
+ embedding_provider: {
116
+ type: 'string',
117
+ description: 'Embedding provider name. When null, the worker falls back to runtime config.'
118
+ },
111
119
  search_score_weight: {
112
120
  type: 'number',
113
121
  default: 1
@@ -50,6 +50,18 @@ export const SearchVector = {
50
50
  },
51
51
  description: 'Column names that feed the embedding. Used by stale trigger to detect content changes.'
52
52
  },
53
+ // ── Model config (optional — flows into job payload) ──────────
54
+ embedding_model: {
55
+ type: 'string',
56
+ description: 'Embedding model identifier (e.g. "nomic-embed-text", "text-embedding-3-small"). ' +
57
+ 'Included in the job payload so the worker knows which model to use. ' +
58
+ 'When null, the worker falls back to runtime config (llm_module / env vars).'
59
+ },
60
+ embedding_provider: {
61
+ type: 'string',
62
+ description: 'Embedding provider name (e.g. "ollama", "openai"). ' +
63
+ 'When null, the worker falls back to runtime config.'
64
+ },
53
65
  enqueue_job: {
54
66
  type: 'boolean',
55
67
  description: 'Auto-create trigger that enqueues embedding generation jobs',
@@ -0,0 +1,2 @@
1
+ export { EventReferral } from './referral';
2
+ export { EventTracker } from './tracker';
@@ -0,0 +1,2 @@
1
+ export { EventReferral } from './referral';
2
+ export { EventTracker } from './tracker';
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeDefinition } from '../types';
2
+ export declare const EventReferral: NodeTypeDefinition;
@@ -0,0 +1,62 @@
1
+ import { conditionDefs, conditionProperties } from '../conditions';
2
+ export const EventReferral = {
3
+ name: 'EventReferral',
4
+ slug: 'event_referral',
5
+ category: 'event',
6
+ display_name: 'Event Referral',
7
+ description: 'Creates triggers that record events for the referrer (inviter) when their ' +
8
+ 'invitees perform actions on a watched table. Resolves the referrer automatically ' +
9
+ 'via the invites module\'s claimed_invites table using the membership_type context. ' +
10
+ 'Supports the same compound condition system as EventTracker. Use with achievements ' +
11
+ 'to unlock levels and grant credits based on invitee activity.',
12
+ parameter_schema: {
13
+ type: 'object',
14
+ $defs: conditionDefs,
15
+ properties: {
16
+ event_name: {
17
+ type: 'string',
18
+ description: 'Event type name to record for the referrer (e.g., "invitee_uploaded_avatar", "invitee_completed_onboarding")'
19
+ },
20
+ events: {
21
+ type: 'array',
22
+ items: {
23
+ type: 'string',
24
+ enum: [
25
+ 'INSERT',
26
+ 'UPDATE',
27
+ 'DELETE'
28
+ ]
29
+ },
30
+ description: 'DML events that trigger recording',
31
+ default: ['INSERT']
32
+ },
33
+ actor_field: {
34
+ type: 'string',
35
+ format: 'column-ref',
36
+ description: 'Column containing the invitee (actor) ID on the source table — used to look up the referrer via claimed_invites.receiver_id',
37
+ default: 'owner_id'
38
+ },
39
+ entity_field: {
40
+ type: 'string',
41
+ format: 'column-ref',
42
+ description: 'Column containing the entity ID (org/group) for entity-scoped referral events. Omit for user-only events.'
43
+ },
44
+ auto_register_type: {
45
+ type: 'boolean',
46
+ description: 'Automatically register the event_name in event_types during provisioning',
47
+ default: true
48
+ },
49
+ ...conditionProperties
50
+ },
51
+ required: [
52
+ 'event_name'
53
+ ]
54
+ },
55
+ tags: [
56
+ 'events',
57
+ 'referral',
58
+ 'invites',
59
+ 'analytics',
60
+ 'tracking'
61
+ ]
62
+ };
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeDefinition } from '../types';
2
+ export declare const EventTracker: NodeTypeDefinition;
@@ -0,0 +1,71 @@
1
+ import { conditionDefs, conditionProperties } from '../conditions';
2
+ export const EventTracker = {
3
+ name: 'EventTracker',
4
+ slug: 'event_tracker',
5
+ category: 'event',
6
+ display_name: 'Event Tracker',
7
+ description: 'Creates triggers that record events via the events module when table rows change. ' +
8
+ 'Supports the same compound condition system as JobTrigger (condition_field, watch_fields, ' +
9
+ 'or full AND/OR/NOT conditions). Events are recorded to app_events and aggregated ' +
10
+ 'automatically. Use with achievements (blueprint-level) to unlock levels and grant ' +
11
+ 'credits based on event accumulation.',
12
+ parameter_schema: {
13
+ type: 'object',
14
+ $defs: conditionDefs,
15
+ properties: {
16
+ event_name: {
17
+ type: 'string',
18
+ description: 'Event type name to record (e.g., "avatar_uploaded", "order_completed")'
19
+ },
20
+ events: {
21
+ type: 'array',
22
+ items: {
23
+ type: 'string',
24
+ enum: [
25
+ 'INSERT',
26
+ 'UPDATE',
27
+ 'DELETE'
28
+ ]
29
+ },
30
+ description: 'DML events that trigger recording',
31
+ default: ['INSERT']
32
+ },
33
+ count: {
34
+ type: 'integer',
35
+ description: 'Number of events to record per trigger fire',
36
+ default: 1
37
+ },
38
+ toggle: {
39
+ type: 'boolean',
40
+ description: 'Toggle mode: records event when condition is met, removes when condition is unmet',
41
+ default: false
42
+ },
43
+ actor_field: {
44
+ type: 'string',
45
+ format: 'column-ref',
46
+ description: 'Column containing the actor (user) ID to attribute the event to',
47
+ default: 'owner_id'
48
+ },
49
+ entity_field: {
50
+ type: 'string',
51
+ format: 'column-ref',
52
+ description: 'Column containing the entity ID (org/group) for entity-scoped events. Omit for user-only events.'
53
+ },
54
+ auto_register_type: {
55
+ type: 'boolean',
56
+ description: 'Automatically register the event_name in event_types during provisioning',
57
+ default: true
58
+ },
59
+ ...conditionProperties
60
+ },
61
+ required: [
62
+ 'event_name'
63
+ ]
64
+ },
65
+ tags: [
66
+ 'events',
67
+ 'triggers',
68
+ 'analytics',
69
+ 'tracking'
70
+ ]
71
+ };
package/esm/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  export * from './authz';
2
2
  export * from './blueprint-types.generated';
3
+ export * from './conditions';
3
4
  export * from './data';
5
+ export * from './event';
6
+ export * from './job';
7
+ export * from './limit';
4
8
  export * from './module-presets';
9
+ export * from './process';
5
10
  export * from './relation';
6
11
  export type { JSONSchema, NodeTypeDefinition } from './types';
7
12
  export * from './view';
package/esm/index.js CHANGED
@@ -1,16 +1,29 @@
1
1
  export * from './authz';
2
2
  export * from './blueprint-types.generated';
3
+ export * from './conditions';
3
4
  export * from './data';
5
+ export * from './event';
6
+ export * from './job';
7
+ export * from './limit';
4
8
  export * from './module-presets';
9
+ export * from './process';
5
10
  export * from './relation';
6
11
  export * from './view';
7
12
  import * as authz from './authz';
8
13
  import * as data from './data';
14
+ import * as event from './event';
15
+ import * as job from './job';
16
+ import * as limit from './limit';
17
+ import * as process from './process';
9
18
  import * as relation from './relation';
10
19
  import * as view from './view';
11
20
  export const allNodeTypes = [
12
21
  ...Object.values(authz),
13
22
  ...Object.values(data),
23
+ ...Object.values(event),
24
+ ...Object.values(job),
25
+ ...Object.values(limit),
26
+ ...Object.values(process),
14
27
  ...Object.values(relation),
15
28
  ...Object.values(view)
16
29
  ];
@@ -0,0 +1 @@
1
+ export { JobTrigger } from './trigger';
@@ -0,0 +1 @@
1
+ export { JobTrigger } from './trigger';
@@ -1,28 +1,4 @@
1
- const triggerConditionSchema = {
2
- type: 'object',
3
- description: 'A leaf condition ({field, op, value?, row?, ref?}) or a combinator ({AND, OR, NOT}).',
4
- properties: {
5
- field: { type: 'string', format: 'column-ref', description: 'Column name (validated against the table).' },
6
- op: {
7
- type: 'string',
8
- enum: ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'NOT LIKE', 'IS NULL', 'IS NOT NULL', 'IS DISTINCT FROM'],
9
- description: 'Comparison operator.'
10
- },
11
- value: { description: 'Comparison value. Type is resolved from the column definition. Omit for IS NULL, IS NOT NULL, IS DISTINCT FROM.' },
12
- row: { type: 'string', enum: ['NEW', 'OLD'], default: 'NEW', description: 'Row reference (default: NEW).' },
13
- ref: {
14
- type: 'object',
15
- description: 'Column reference for field-to-field comparison (alternative to value).',
16
- properties: {
17
- field: { type: 'string', format: 'column-ref' },
18
- row: { type: 'string', enum: ['NEW', 'OLD'], default: 'NEW' }
19
- }
20
- },
21
- AND: { type: 'array', description: 'Array of conditions combined with AND.', items: { $ref: '#/$defs/triggerCondition' } },
22
- OR: { type: 'array', description: 'Array of conditions combined with OR.', items: { $ref: '#/$defs/triggerCondition' } },
23
- NOT: { $ref: '#/$defs/triggerCondition', description: 'Negated condition.' }
24
- }
25
- };
1
+ import { conditionDefs, conditionProperties } from '../conditions';
26
2
  export const JobTrigger = {
27
3
  name: 'JobTrigger',
28
4
  slug: 'data_job_trigger',
@@ -31,9 +7,7 @@ export const JobTrigger = {
31
7
  description: 'Dynamically creates PostgreSQL triggers that enqueue jobs via app_jobs.add_job() when table rows are inserted, updated, or deleted. Supports configurable payload strategies (full row, row ID, selected fields, or custom mapping), conditional firing via WHEN clauses, watched field changes, and extended job options (queue, priority, delay, max attempts).',
32
8
  parameter_schema: {
33
9
  type: 'object',
34
- $defs: {
35
- triggerCondition: triggerConditionSchema
36
- },
10
+ $defs: conditionDefs,
37
11
  properties: {
38
12
  task_identifier: {
39
13
  type: 'string',
@@ -92,31 +66,7 @@ export const JobTrigger = {
92
66
  description: 'Include table/schema metadata in payload',
93
67
  default: false
94
68
  },
95
- condition_field: {
96
- type: 'string',
97
- format: 'column-ref',
98
- description: 'Column name for conditional WHEN clause (fires only when field equals condition_value)'
99
- },
100
- condition_value: {
101
- type: 'string',
102
- description: 'Value to compare against condition_field in WHEN clause'
103
- },
104
- conditions: {
105
- 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.',
106
- 'x-codegen-type': 'TriggerCondition | TriggerCondition[]',
107
- oneOf: [
108
- { $ref: '#/$defs/triggerCondition' },
109
- { type: 'array', items: { $ref: '#/$defs/triggerCondition' } }
110
- ]
111
- },
112
- watch_fields: {
113
- type: 'array',
114
- items: {
115
- type: 'string',
116
- format: 'column-ref'
117
- },
118
- description: 'For UPDATE triggers, only fire when these fields change (uses DISTINCT FROM)'
119
- },
69
+ ...conditionProperties,
120
70
  job_key: {
121
71
  type: 'string',
122
72
  description: 'Static job key for upsert semantics (prevents duplicate jobs)'
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeDefinition } from '../types';
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
  };
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeDefinition } from '../types';
2
+ export declare const LimitEnforceCounter: NodeTypeDefinition;