node-type-registry 0.41.0 → 0.43.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 (71) hide show
  1. package/authz/authz-app-membership.js +8 -8
  2. package/authz/authz-member-owner.d.ts +2 -0
  3. package/authz/authz-member-owner.js +51 -0
  4. package/authz/index.d.ts +2 -1
  5. package/authz/index.js +5 -3
  6. package/blueprint-types.generated.d.ts +355 -77
  7. package/blueprint-types.generated.js +16 -4
  8. package/codegen/generate-types.js +175 -8
  9. package/data/check-greater-than.js +6 -6
  10. package/data/check-less-than.js +6 -6
  11. package/data/check-not-equal.js +4 -4
  12. package/data/check-one-of.js +5 -5
  13. package/data/data-jsonb.js +4 -3
  14. package/data/data-member-owner.d.ts +2 -0
  15. package/data/data-member-owner.js +53 -0
  16. package/data/data-status-field.js +4 -3
  17. package/data/data-tags.js +4 -3
  18. package/data/index.d.ts +1 -0
  19. package/data/index.js +3 -1
  20. package/esm/authz/authz-app-membership.js +8 -8
  21. package/esm/authz/authz-member-owner.d.ts +2 -0
  22. package/esm/authz/authz-member-owner.js +48 -0
  23. package/esm/authz/index.d.ts +2 -1
  24. package/esm/authz/index.js +2 -1
  25. package/esm/blueprint-types.generated.d.ts +355 -77
  26. package/esm/blueprint-types.generated.js +16 -4
  27. package/esm/codegen/generate-types.js +175 -8
  28. package/esm/data/check-greater-than.js +6 -6
  29. package/esm/data/check-less-than.js +6 -6
  30. package/esm/data/check-not-equal.js +4 -4
  31. package/esm/data/check-one-of.js +5 -5
  32. package/esm/data/data-jsonb.js +4 -3
  33. package/esm/data/data-member-owner.d.ts +2 -0
  34. package/esm/data/data-member-owner.js +50 -0
  35. package/esm/data/data-status-field.js +4 -3
  36. package/esm/data/data-tags.js +4 -3
  37. package/esm/data/index.d.ts +1 -0
  38. package/esm/data/index.js +1 -0
  39. package/esm/event/referral.js +21 -2
  40. package/esm/event/tracker.js +20 -1
  41. package/esm/index.d.ts +1 -1
  42. package/esm/limit/enforce-aggregate.js +32 -8
  43. package/esm/limit/enforce-counter.js +33 -10
  44. package/esm/limit/enforce-feature.js +26 -8
  45. package/esm/limit/enforce-rate.js +28 -9
  46. package/esm/limit/track-usage.js +28 -9
  47. package/esm/limit/warning-aggregate.js +29 -5
  48. package/esm/limit/warning-counter.js +30 -7
  49. package/esm/limit/warning-rate.js +31 -7
  50. package/esm/module-presets/full.js +2 -2
  51. package/esm/process/chunks.js +1 -1
  52. package/esm/process/file-embedding.js +1 -1
  53. package/esm/types.d.ts +92 -0
  54. package/esm/types.js +1 -0
  55. package/event/referral.js +21 -2
  56. package/event/tracker.js +20 -1
  57. package/index.d.ts +1 -1
  58. package/limit/enforce-aggregate.js +32 -8
  59. package/limit/enforce-counter.js +33 -10
  60. package/limit/enforce-feature.js +26 -8
  61. package/limit/enforce-rate.js +28 -9
  62. package/limit/track-usage.js +28 -9
  63. package/limit/warning-aggregate.js +29 -5
  64. package/limit/warning-counter.js +30 -7
  65. package/limit/warning-rate.js +31 -7
  66. package/module-presets/full.js +2 -2
  67. package/package.json +2 -2
  68. package/process/chunks.js +1 -1
  69. package/process/file-embedding.js +1 -1
  70. package/types.d.ts +92 -0
  71. package/types.js +1 -0
@@ -14,25 +14,37 @@
14
14
  ;
15
15
  /**
16
16
  * ===========================================================================
17
- * Billing node type parameters
17
+ * Check node type parameters
18
18
  * ===========================================================================
19
19
  */
20
20
  ;
21
21
  /**
22
22
  * ===========================================================================
23
- * Check node type parameters
23
+ * Data node type parameters
24
24
  * ===========================================================================
25
25
  */
26
26
  ;
27
27
  /**
28
28
  * ===========================================================================
29
- * Data node type parameters
29
+ * Event node type parameters
30
+ * ===========================================================================
31
+ */
32
+ ;
33
+ /**
34
+ * ===========================================================================
35
+ * Limit_enforce node type parameters
36
+ * ===========================================================================
37
+ */
38
+ ;
39
+ /**
40
+ * ===========================================================================
41
+ * Limit_track node type parameters
30
42
  * ===========================================================================
31
43
  */
32
44
  ;
33
45
  /**
34
46
  * ===========================================================================
35
- * Limit node type parameters
47
+ * Limit_warning node type parameters
36
48
  * ===========================================================================
37
49
  */
38
50
  ;
@@ -137,6 +137,56 @@ function buildTriggerConditionInterface() {
137
137
  ]), 'Recursive condition type for compound trigger WHEN clauses. Leaf conditions specify {field, op, value?, row?, ref?}. Combinators nest via AND, OR, NOT.');
138
138
  }
139
139
  // ---------------------------------------------------------------------------
140
+ // FieldType — structured PostgreSQL type representation.
141
+ // ---------------------------------------------------------------------------
142
+ function buildFieldTypeInterface() {
143
+ const argType = t.tsUnionType([
144
+ t.tsStringKeyword(),
145
+ t.tsNumberKeyword(),
146
+ t.tsBooleanKeyword()
147
+ ]);
148
+ return addJSDoc(exportInterface('FieldType', [
149
+ addJSDoc(requiredProp('name', t.tsStringKeyword()), 'Type name. Must be a valid SQL identifier.'),
150
+ addJSDoc(optionalProp('schema', t.tsStringKeyword()), 'Schema qualifier.'),
151
+ addJSDoc(optionalProp('args', t.tsArrayType(argType)), 'Type arguments (e.g., [10, 2] for numeric(10,2), ["Point", 4326] for geometry).'),
152
+ addJSDoc(optionalProp('array_dimensions', t.tsNumberKeyword()), 'Number of array dimensions. 1 = text[], 2 = text[][].'),
153
+ addJSDoc(optionalProp('range', t.tsArrayType(t.tsStringKeyword())), 'Interval field range. 1-2 elements: ["day"] or ["day", "second"].')
154
+ ]), 'Structured representation of a PostgreSQL data type. Stored as JSONB in metaschema_public.field.type.');
155
+ }
156
+ // ---------------------------------------------------------------------------
157
+ // FieldDefault — structured PostgreSQL default value expression.
158
+ // ---------------------------------------------------------------------------
159
+ function buildFieldDefaultInterface() {
160
+ const defaultRef = t.tsTypeReference(t.identifier('FieldDefault'));
161
+ const fieldTypeRef = t.tsTypeReference(t.identifier('FieldType'));
162
+ const valueType = t.tsUnionType([
163
+ t.tsStringKeyword(),
164
+ t.tsNumberKeyword(),
165
+ t.tsBooleanKeyword(),
166
+ t.tsNullKeyword(),
167
+ t.tsArrayType(t.tsUnknownKeyword()),
168
+ recordType(t.tsStringKeyword(), t.tsUnknownKeyword())
169
+ ]);
170
+ const argType = t.tsUnionType([
171
+ t.tsStringKeyword(),
172
+ t.tsNumberKeyword(),
173
+ t.tsBooleanKeyword(),
174
+ t.tsNullKeyword(),
175
+ defaultRef
176
+ ]);
177
+ return addJSDoc(exportInterface('FieldDefault', [
178
+ addJSDoc(optionalProp('value', valueType), 'Literal value (string, number, boolean, null, array, or object).'),
179
+ addJSDoc(optionalProp('function', t.tsStringKeyword()), 'Function name. Must be a valid SQL identifier.'),
180
+ addJSDoc(optionalProp('schema', t.tsStringKeyword()), 'Schema qualifier for function.'),
181
+ addJSDoc(optionalProp('args', t.tsArrayType(argType)), 'Function arguments (recursive).'),
182
+ addJSDoc(optionalProp('cast', fieldTypeRef), 'Output type cast.'),
183
+ addJSDoc(optionalProp('operator', t.tsStringKeyword()), 'Binary operator (e.g., "+", "-", "||").'),
184
+ addJSDoc(optionalProp('left', defaultRef), 'Left operand for operator expression.'),
185
+ addJSDoc(optionalProp('right', defaultRef), 'Right operand for operator expression.'),
186
+ addJSDoc(optionalProp('sql_keyword', t.tsStringKeyword()), 'SQL keyword (e.g., "CURRENT_TIMESTAMP", "CURRENT_USER").')
187
+ ]), 'Structured representation of a PostgreSQL default value expression. Stored as JSONB in metaschema_public.field.default_value.');
188
+ }
189
+ // ---------------------------------------------------------------------------
140
190
  // x-codegen-type post-processing — replaces properties that have an
141
191
  // 'x-codegen-type' marker in their JSON Schema with a hand-written TS type
142
192
  // reference. This lets node type definitions delegate complex types
@@ -302,11 +352,13 @@ function buildBlueprintField(meta) {
302
352
  return deriveInterfaceFromTable(table, 'BlueprintField', 'A custom field (column) to add to a blueprint table. Derived from _meta.');
303
353
  }
304
354
  // Static fallback
355
+ const fieldTypeRef = t.tsTypeReference(t.identifier('FieldType'));
356
+ const fieldDefaultRef = t.tsTypeReference(t.identifier('FieldDefault'));
305
357
  return addJSDoc(exportInterface('BlueprintField', [
306
358
  addJSDoc(requiredProp('name', t.tsStringKeyword()), 'The column name.'),
307
- addJSDoc(requiredProp('type', t.tsStringKeyword()), 'The PostgreSQL type (e.g., "text", "integer", "boolean", "uuid").'),
359
+ addJSDoc(requiredProp('type', t.tsUnionType([fieldTypeRef, t.tsStringKeyword()])), 'PostgreSQL type as a FieldType object (e.g., { name: "text" }) or legacy string.'),
308
360
  addJSDoc(optionalProp('is_required', t.tsBooleanKeyword()), 'Whether the column has a NOT NULL constraint.'),
309
- addJSDoc(optionalProp('default_value', t.tsStringKeyword()), 'SQL default value expression (e.g., "true", "now()").'),
361
+ addJSDoc(optionalProp('default_value', t.tsUnionType([fieldDefaultRef, t.tsStringKeyword()])), 'Default value as a FieldDefault object (e.g., { function: "now" }) or legacy string.'),
310
362
  addJSDoc(optionalProp('description', t.tsStringKeyword()), 'Comment/description for this field.')
311
363
  ]), 'A custom field (column) to add to a blueprint table.');
312
364
  }
@@ -461,7 +513,7 @@ function buildBlueprintTableUniqueConstraint() {
461
513
  /**
462
514
  * Build the BlueprintBucketSeed interface.
463
515
  *
464
- * Matches the bucket entries in storage_config.buckets[].
516
+ * Matches the bucket entries in storage.buckets[].
465
517
  */
466
518
  function buildBlueprintBucketSeed() {
467
519
  return addJSDoc(exportInterface('BlueprintBucketSeed', [
@@ -471,12 +523,12 @@ function buildBlueprintBucketSeed() {
471
523
  addJSDoc(optionalProp('allowed_mime_types', t.tsArrayType(t.tsStringKeyword())), 'MIME type allowlist (e.g., ["image/png", "image/jpeg"]). NULL means all types allowed.'),
472
524
  addJSDoc(optionalProp('max_file_size', t.tsNumberKeyword()), 'Maximum file size in bytes for this bucket. NULL means no limit.'),
473
525
  addJSDoc(optionalProp('allowed_origins', t.tsArrayType(t.tsStringKeyword())), 'CORS allowed origins for this bucket.')
474
- ]), 'A bucket seed entry for storage_config.buckets[]. Creates an initial bucket row in the {prefix}_buckets table during entity type provisioning. Only used for app-level storage (not entity-scoped).');
526
+ ]), 'A bucket seed entry for storage.buckets[]. Creates an initial bucket row in the {prefix}_buckets table during entity type provisioning. Only used for app-level storage (not entity-scoped).');
475
527
  }
476
528
  /**
477
529
  * Build the BlueprintStorageConfig interface.
478
530
  *
479
- * Matches the jsonb shape accepted by storage_config on entity_type_provision.
531
+ * Matches the jsonb shape accepted by storage on entity_type_provision.
480
532
  */
481
533
  function buildBlueprintStorageConfig() {
482
534
  return addJSDoc(exportInterface('BlueprintStorageConfig', [
@@ -529,6 +581,108 @@ function buildBlueprintAchievement() {
529
581
  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".')
530
582
  ]), '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).');
531
583
  }
584
+ // ---------------------------------------------------------------------------
585
+ // Module config types (namespace, function, agent, graph)
586
+ // ---------------------------------------------------------------------------
587
+ /**
588
+ * Build the BlueprintNamespaceConfig interface.
589
+ *
590
+ * Matches the jsonb shape accepted by namespaces on entity_type_provision
591
+ * and the top-level definition.namespaces[] array in construct_blueprint().
592
+ */
593
+ function buildBlueprintNamespaceConfig() {
594
+ return addJSDoc(exportInterface('BlueprintNamespaceConfig', [
595
+ addJSDoc(optionalProp('scope', t.tsUnionType([
596
+ t.tsLiteralType(t.stringLiteral('app')),
597
+ t.tsLiteralType(t.stringLiteral('org'))
598
+ ])), 'Namespace scope. "app" (default) creates app-level namespaces (membership_type = NULL). "org" creates per-org namespaces. Only used at the top level of a blueprint definition — entity-scoped namespaces inherit scope from the entity type.'),
599
+ addJSDoc(optionalProp('key', t.tsStringKeyword()), 'Module discriminator for multi-module namespaces. Defaults to "default" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_namespaces.'),
600
+ addJSDoc(optionalProp('policies', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintPolicy')))), 'RLS policy overrides for the namespaces table. NULL = apply defaults from apply_namespace_security().'),
601
+ addJSDoc(optionalProp('provisions', t.tsTypeLiteral([
602
+ optionalProp('namespaces', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
603
+ optionalProp('namespace_events', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision')))
604
+ ])), 'Per-table overrides for namespace tables. Each key targets a specific table (namespaces, namespace_events) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision.')
605
+ ]), 'Namespace module configuration. When used at the top level of a blueprint, the scope field controls whether namespaces are app-level ("app", default) or org-level ("org"). When used inside entity_types[], scope is inherited from the entity type. Provisions a namespaces table with computed-name proxy, rename trigger, and entity-scoped RLS.');
606
+ }
607
+ /**
608
+ * Build the BlueprintFunctionConfig interface.
609
+ *
610
+ * Matches the jsonb shape accepted by functions on entity_type_provision
611
+ * and the top-level definition.functions[] array in construct_blueprint().
612
+ */
613
+ function buildBlueprintFunctionConfig() {
614
+ return addJSDoc(exportInterface('BlueprintFunctionConfig', [
615
+ addJSDoc(optionalProp('scope', t.tsUnionType([
616
+ t.tsLiteralType(t.stringLiteral('app')),
617
+ t.tsLiteralType(t.stringLiteral('org'))
618
+ ])), 'Function scope. "app" (default) creates app-level functions (membership_type = NULL). "org" creates per-org functions. Only used at the top level of a blueprint definition — entity-scoped functions inherit scope from the entity type.'),
619
+ addJSDoc(optionalProp('key', t.tsStringKeyword()), 'Module discriminator for multi-module functions. Defaults to "default" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_function_definitions.'),
620
+ addJSDoc(optionalProp('policies', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintPolicy')))), 'RLS policy overrides for the function tables. NULL = apply defaults from apply_function_security().'),
621
+ addJSDoc(optionalProp('provisions', t.tsTypeLiteral([
622
+ optionalProp('definitions', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
623
+ optionalProp('invocations', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
624
+ optionalProp('execution_logs', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision')))
625
+ ])), 'Per-table overrides for function tables. Each key targets a specific table (definitions, invocations, execution_logs) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision.')
626
+ ]), 'Function module configuration. When used at the top level of a blueprint, the scope field controls whether functions are app-level ("app", default) or org-level ("org"). When used inside entity_types[], scope is inherited from the entity type. Provisions function_definitions, function_invocations (partitioned, 12-month retention), and function_execution_logs tables.');
627
+ }
628
+ /**
629
+ * Build the BlueprintAgentConfig interface.
630
+ *
631
+ * Matches the jsonb shape accepted by agents on entity_type_provision
632
+ * and the top-level definition.agents[] array in construct_blueprint().
633
+ */
634
+ function buildBlueprintAgentConfig() {
635
+ return addJSDoc(exportInterface('BlueprintAgentConfig', [
636
+ addJSDoc(optionalProp('scope', t.tsUnionType([
637
+ t.tsLiteralType(t.stringLiteral('app')),
638
+ t.tsLiteralType(t.stringLiteral('org'))
639
+ ])), 'Agent scope. "app" (default) creates app-level agent tables (membership_type = NULL). "org" creates per-org agent tables. Only used at the top level of a blueprint definition — entity-scoped agents inherit scope from the entity type.'),
640
+ addJSDoc(optionalProp('key', t.tsStringKeyword()), 'Module discriminator for multi-module agents. Defaults to "default" (omitted from table names). Non-default keys appear as an infix: {prefix}_{key}_agent_thread.'),
641
+ addJSDoc(optionalProp('api_name', t.tsStringKeyword()), 'API name for the agent module. Used in GraphQL naming. Defaults to "agent".'),
642
+ addJSDoc(optionalProp('has_knowledge', t.tsBooleanKeyword()), 'Whether to provision the agent_knowledge table with vector embeddings, tags, and trigger_phrases. Also inferred when a "knowledge" key is present. Defaults to false.'),
643
+ addJSDoc(optionalProp('knowledge', t.tsTypeLiteral([
644
+ optionalProp('has_chunks', t.tsBooleanKeyword()),
645
+ optionalProp('dimensions', t.tsNumberKeyword()),
646
+ optionalProp('chunk_size', t.tsNumberKeyword()),
647
+ optionalProp('chunk_overlap', t.tsNumberKeyword()),
648
+ optionalProp('chunk_strategy', t.tsUnionType([
649
+ t.tsLiteralType(t.stringLiteral('fixed')),
650
+ t.tsLiteralType(t.stringLiteral('sentence')),
651
+ t.tsLiteralType(t.stringLiteral('paragraph')),
652
+ t.tsLiteralType(t.stringLiteral('semantic'))
653
+ ])),
654
+ optionalProp('embedding_model', t.tsStringKeyword()),
655
+ optionalProp('embedding_provider', t.tsStringKeyword()),
656
+ optionalProp('search_indexes', t.tsArrayType(t.tsUnionType([
657
+ t.tsLiteralType(t.stringLiteral('fulltext')),
658
+ t.tsLiteralType(t.stringLiteral('bm25')),
659
+ t.tsLiteralType(t.stringLiteral('trigram'))
660
+ ])))
661
+ ])), 'Knowledge configuration overrides. Set has_chunks to false to disable the chunking pipeline. Controls vector dimensions, chunking strategy, embedding model/provider, and text search indexes for the agent_knowledge table. Presence implies has_knowledge = true.'),
662
+ addJSDoc(optionalProp('policies', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintPolicy')))), 'RLS policy overrides for the agent tables. NULL = apply defaults from apply_agent_security().'),
663
+ addJSDoc(optionalProp('provisions', t.tsTypeLiteral([
664
+ optionalProp('thread', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
665
+ optionalProp('message', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
666
+ optionalProp('task', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
667
+ optionalProp('prompt', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))),
668
+ optionalProp('knowledge', t.tsTypeReference(t.identifier('BlueprintEntityTableProvision')))
669
+ ])), 'Per-table overrides for agent tables. Each key targets a specific table (thread, message, task, prompt, knowledge) and uses the same shape as table_provision: { nodes, fields, grants, use_rls, policies }. Fanned out to secure_table_provision.')
670
+ ]), 'Agent module configuration. When used at the top level of a blueprint, the scope field controls whether agents are app-level ("app", default) or org-level ("org"). When used inside entity_types[], scope is inherited from the entity type. Provisions thread, message, task, prompt tables (and optionally knowledge with vector embeddings).');
671
+ }
672
+ /**
673
+ * Build the BlueprintGraphConfig interface.
674
+ *
675
+ * Matches the jsonb shape accepted by graphs on entity_type_provision.
676
+ * Graph module requires a merkle_store_module_id dependency, so
677
+ * entity_type_provision only registers permissions. The graph module itself
678
+ * must be provisioned separately with the merkle store dependency resolved.
679
+ */
680
+ function buildBlueprintGraphConfig() {
681
+ return addJSDoc(exportInterface('BlueprintGraphConfig', [
682
+ addJSDoc(optionalProp('key', t.tsStringKeyword()), 'Module discriminator for multi-module graphs. Defaults to "default".'),
683
+ addJSDoc(optionalProp('policies', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintPolicy')))), 'RLS policy overrides for the graph tables. NULL = apply defaults from apply_graph_security().')
684
+ ]), 'Graph module configuration. Presence triggers permission registration (manage_graphs, execute_graphs). The graph module requires a merkle_store_module_id dependency, so entity_type_provision only registers permissions here — the graph module itself must be provisioned separately.');
685
+ }
532
686
  function buildBlueprintEntityTableProvision() {
533
687
  return addJSDoc(exportInterface('BlueprintEntityTableProvision', [
534
688
  addJSDoc(optionalProp('use_rls', t.tsBooleanKeyword()), 'Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true.'),
@@ -556,7 +710,11 @@ function buildBlueprintEntityType() {
556
710
  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."),
557
711
  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.'),
558
712
  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).'),
559
- 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").')
713
+ addJSDoc(optionalProp('storage', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintStorageConfig')))), 'Storage module configuration array. Presence triggers provisioning (same inference model as namespaces, functions, agents). Each entry provisions a separate storage module with its own tables, RLS, and settings. Each entry may specify a storage_key for multi-module support (defaults to "default").'),
714
+ addJSDoc(optionalProp('namespaces', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintNamespaceConfig')))), 'Namespace module configuration array. Presence triggers provisioning. Each entry provisions a namespace_module with its own tables, computed-name proxy, and entity-scoped RLS. Registers manage_namespaces permission bit. "[{}]" = provision one default namespace module.'),
715
+ addJSDoc(optionalProp('functions', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintFunctionConfig')))), 'Function module configuration array. Presence triggers provisioning. Each entry provisions function_definitions, function_invocations (partitioned), and function_execution_logs tables. Registers manage_functions + invoke_functions permission bits. "[{}]" = provision one default function module.'),
716
+ addJSDoc(optionalProp('agents', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAgentConfig')))), 'Agent module configuration array. Presence triggers provisioning. Each entry provisions thread, message, task, prompt tables (and optionally knowledge with vector embeddings). "[{}]" = provision one default agent module.'),
717
+ addJSDoc(optionalProp('graphs', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintGraphConfig')))), 'Graph module configuration array. Presence triggers permission registration (manage_graphs, execute_graphs). Graph module requires a merkle_store_module_id dependency, so entity_type_provision only registers permissions here. "[{}]" = register default graph permissions.')
560
718
  ]), 'An entity type entry for Phase 0 of construct_blueprint(). When name is provided, provisions a new entity type with its own entity table, membership modules, and security policies via entity_type_provision. When name is omitted and only prefix is given, extends an existing entity type (e.g., the built-in "org") with additional capabilities like storage — without creating a new entity type.');
561
719
  }
562
720
  function buildBlueprintTable() {
@@ -585,7 +743,10 @@ function buildBlueprintDefinition() {
585
743
  addJSDoc(optionalProp('unique_constraints', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintUniqueConstraint')))), 'Unique constraints on table columns.'),
586
744
  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.'),
587
745
  addJSDoc(optionalProp('storage', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintStorageConfig')))), 'Top-level storage configuration array. Each entry has an optional scope ("app" or "org"). App-scoped (default) creates storage_module with membership_type = NULL. Org-scoped creates per-org/user storage with owner_id and AFTER INSERT bucket seeding. When infra is installed, a private "functions" bucket is auto-injected into org-scoped entries. For child entity type storage, use entity_types[].storage instead.'),
588
- 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).')
746
+ 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).'),
747
+ addJSDoc(optionalProp('namespaces', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintNamespaceConfig')))), 'Top-level namespace configuration array (Phase 0.6). Each entry has an optional scope ("app" or "org"). App-scoped (default) creates namespace_module with membership_type = NULL. Org-scoped creates per-org namespaces. For entity-scoped namespaces, use entity_types[].namespaces instead.'),
748
+ addJSDoc(optionalProp('functions', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintFunctionConfig')))), 'Top-level function configuration array (Phase 0.6). Each entry has an optional scope ("app" or "org"). App-scoped (default) creates function_module with membership_type = NULL. Org-scoped creates per-org functions. For entity-scoped functions, use entity_types[].functions instead.'),
749
+ addJSDoc(optionalProp('agents', t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintAgentConfig')))), 'Top-level agent configuration array (Phase 0.6). Each entry has an optional scope ("app" or "org"). App-scoped (default) creates agent_module with membership_type = NULL. Org-scoped creates per-org agents. For entity-scoped agents, use entity_types[].agents instead.')
589
750
  ]), 'The complete blueprint definition -- the JSONB shape accepted by construct_blueprint().');
590
751
  }
591
752
  // ---------------------------------------------------------------------------
@@ -619,8 +780,10 @@ function buildProgram(meta) {
619
780
  // -- Shared recursive types (emitted before parameter interfaces) --
620
781
  statements.push(sectionComment('Shared recursive types'));
621
782
  statements.push(buildTriggerConditionInterface());
783
+ statements.push(buildFieldTypeInterface());
784
+ statements.push(buildFieldDefaultInterface());
622
785
  // -- Parameter interfaces grouped by category --
623
- const categoryOrder = ['billing', 'check', 'data', 'limit', 'search', 'job', 'process', 'authz', 'relation', 'view'];
786
+ const categoryOrder = ['billing', 'check', 'data', 'event', 'limit', 'limit_enforce', 'limit_track', 'limit_warning', 'search', 'job', 'process', 'authz', 'relation', 'view'];
624
787
  for (const cat of categoryOrder) {
625
788
  const nts = categories.get(cat);
626
789
  if (!nts || nts.length === 0)
@@ -647,6 +810,10 @@ function buildProgram(meta) {
647
810
  statements.push(buildBlueprintAchievementRequirement());
648
811
  statements.push(buildBlueprintAchievementReward());
649
812
  statements.push(buildBlueprintAchievement());
813
+ statements.push(buildBlueprintNamespaceConfig());
814
+ statements.push(buildBlueprintFunctionConfig());
815
+ statements.push(buildBlueprintAgentConfig());
816
+ statements.push(buildBlueprintGraphConfig());
650
817
  statements.push(buildBlueprintEntityTableProvision());
651
818
  statements.push(buildBlueprintEntityType());
652
819
  // -- Node types discriminated union --
@@ -10,21 +10,21 @@ export const CheckGreaterThan = {
10
10
  column: {
11
11
  type: 'string',
12
12
  format: 'column-ref',
13
- description: 'Single column to compare against value (mutually exclusive with columns)',
13
+ description: 'Single column to compare against value (mutually exclusive with columns)'
14
14
  },
15
15
  value: {
16
16
  type: 'number',
17
17
  description: 'Threshold value for single-column comparison (column > value)',
18
- default: 0,
18
+ default: 0
19
19
  },
20
20
  columns: {
21
21
  type: 'array',
22
22
  items: { type: 'string', format: 'column-ref' },
23
23
  description: 'Two columns for cross-column comparison (columns[0] > columns[1])',
24
24
  minItems: 2,
25
- maxItems: 2,
26
- },
27
- },
25
+ maxItems: 2
26
+ }
27
+ }
28
28
  },
29
- tags: ['check', 'constraint', 'validation', 'comparison'],
29
+ tags: ['check', 'constraint', 'validation', 'comparison']
30
30
  };
@@ -10,20 +10,20 @@ export const CheckLessThan = {
10
10
  column: {
11
11
  type: 'string',
12
12
  format: 'column-ref',
13
- description: 'Single column to compare against value (mutually exclusive with columns)',
13
+ description: 'Single column to compare against value (mutually exclusive with columns)'
14
14
  },
15
15
  value: {
16
16
  type: 'number',
17
- description: 'Threshold value for single-column comparison (column < value)',
17
+ description: 'Threshold value for single-column comparison (column < value)'
18
18
  },
19
19
  columns: {
20
20
  type: 'array',
21
21
  items: { type: 'string', format: 'column-ref' },
22
22
  description: 'Two columns for cross-column comparison (columns[0] < columns[1])',
23
23
  minItems: 2,
24
- maxItems: 2,
25
- },
26
- },
24
+ maxItems: 2
25
+ }
26
+ }
27
27
  },
28
- tags: ['check', 'constraint', 'validation', 'comparison'],
28
+ tags: ['check', 'constraint', 'validation', 'comparison']
29
29
  };
@@ -12,10 +12,10 @@ export const CheckNotEqual = {
12
12
  items: { type: 'string', format: 'column-ref' },
13
13
  description: 'Two columns that must not be equal',
14
14
  minItems: 2,
15
- maxItems: 2,
16
- },
15
+ maxItems: 2
16
+ }
17
17
  },
18
- required: ['columns'],
18
+ required: ['columns']
19
19
  },
20
- tags: ['check', 'constraint', 'validation', 'inequality'],
20
+ tags: ['check', 'constraint', 'validation', 'inequality']
21
21
  };
@@ -10,15 +10,15 @@ export const CheckOneOf = {
10
10
  column: {
11
11
  type: 'string',
12
12
  format: 'column-ref',
13
- description: 'Column to validate against the allowed values',
13
+ description: 'Column to validate against the allowed values'
14
14
  },
15
15
  values: {
16
16
  type: 'array',
17
17
  items: { type: 'string' },
18
- description: 'Array of allowed values for the column',
19
- },
18
+ description: 'Array of allowed values for the column'
19
+ }
20
20
  },
21
- required: ['column', 'values'],
21
+ required: ['column', 'values']
22
22
  },
23
- tags: ['check', 'constraint', 'validation', 'enum'],
23
+ tags: ['check', 'constraint', 'validation', 'enum']
24
24
  };
@@ -14,9 +14,10 @@ export const DataJsonb = {
14
14
  default: 'metadata'
15
15
  },
16
16
  default_value: {
17
- type: 'string',
18
- description: 'Default value expression',
19
- default: "'{}'::jsonb"
17
+ type: 'object',
18
+ description: 'Default value as a FieldDefault object',
19
+ 'x-codegen-type': 'FieldDefault',
20
+ default: { value: {}, cast: { name: 'jsonb' } }
20
21
  },
21
22
  is_required: {
22
23
  type: 'boolean',
@@ -0,0 +1,2 @@
1
+ import type { NodeTypeDefinition } from '../types';
2
+ export declare const DataMemberOwner: NodeTypeDefinition;
@@ -0,0 +1,50 @@
1
+ export const DataMemberOwner = {
2
+ name: 'DataMemberOwner',
3
+ slug: 'data_member_owner',
4
+ category: 'data',
5
+ display_name: 'Member Owner',
6
+ description: 'Adds owner_id and entity_id columns with a compound AuthzMemberOwner policy. The actor must own the row (owner_id = current_user_id()) AND be a member of the entity (entity_id in SPRT). Use for private data within an entity scope — e.g., personal chat threads that belong to the company but only the author can see.',
7
+ parameter_schema: {
8
+ type: 'object',
9
+ properties: {
10
+ owner_field_name: {
11
+ type: 'string',
12
+ format: 'column-ref',
13
+ description: 'Column name for the owner reference',
14
+ default: 'owner_id'
15
+ },
16
+ entity_field_name: {
17
+ type: 'string',
18
+ format: 'column-ref',
19
+ description: 'Column name for the entity reference',
20
+ default: 'entity_id'
21
+ },
22
+ include_id: {
23
+ type: 'boolean',
24
+ description: 'If true, also adds a UUID primary key column with auto-generation',
25
+ default: true
26
+ },
27
+ include_user_fk: {
28
+ type: 'boolean',
29
+ description: 'If true, adds foreign key constraints from owner_id and entity_id to the users table',
30
+ default: true
31
+ },
32
+ create_index: {
33
+ type: 'boolean',
34
+ description: 'If true, creates B-tree indexes on the owner and entity columns',
35
+ default: true
36
+ },
37
+ membership_type: {
38
+ type: 'integer',
39
+ description: 'Membership type for SPRT resolution. Required for entity-scoped provisioning.',
40
+ default: null
41
+ }
42
+ }
43
+ },
44
+ tags: [
45
+ 'ownership',
46
+ 'membership',
47
+ 'security',
48
+ 'schema'
49
+ ]
50
+ };
@@ -14,9 +14,10 @@ export const DataStatusField = {
14
14
  default: 'status'
15
15
  },
16
16
  type: {
17
- type: 'string',
18
- description: 'Column type (text or citext)',
19
- default: 'text'
17
+ type: 'object',
18
+ description: 'Column type as a FieldType object',
19
+ 'x-codegen-type': 'FieldType',
20
+ default: { name: 'text' }
20
21
  },
21
22
  default_value: {
22
23
  type: 'string',
@@ -14,9 +14,10 @@ export const DataTags = {
14
14
  default: 'tags'
15
15
  },
16
16
  default_value: {
17
- type: 'string',
18
- description: 'Default value expression for the tags column',
19
- default: 'ARRAY[]::citext[]'
17
+ type: 'object',
18
+ description: 'Default value as a FieldDefault object',
19
+ 'x-codegen-type': 'FieldDefault',
20
+ default: { value: [], cast: { name: 'citext', array_dimensions: 1 } }
20
21
  },
21
22
  is_required: {
22
23
  type: 'boolean',
@@ -12,6 +12,7 @@ export { DataImmutableFields } from './data-immutable-fields';
12
12
  export { DataInflection } from './data-inflection';
13
13
  export { DataInheritFromParent } from './data-inherit-from-parent';
14
14
  export { DataJsonb } from './data-jsonb';
15
+ export { DataMemberOwner } from './data-member-owner';
15
16
  export { DataOwnedFields } from './data-owned-fields';
16
17
  export { DataOwnershipInEntity } from './data-ownership-in-entity';
17
18
  export { DataPeoplestamps } from './data-peoplestamps';
package/esm/data/index.js CHANGED
@@ -12,6 +12,7 @@ export { DataImmutableFields } from './data-immutable-fields';
12
12
  export { DataInflection } from './data-inflection';
13
13
  export { DataInheritFromParent } from './data-inherit-from-parent';
14
14
  export { DataJsonb } from './data-jsonb';
15
+ export { DataMemberOwner } from './data-member-owner';
15
16
  export { DataOwnedFields } from './data-owned-fields';
16
17
  export { DataOwnershipInEntity } from './data-ownership-in-entity';
17
18
  export { DataPeoplestamps } from './data-peoplestamps';
@@ -39,7 +39,26 @@ export const EventReferral = {
39
39
  entity_field: {
40
40
  type: 'string',
41
41
  format: 'column-ref',
42
- description: 'Column containing the entity ID (org/group) for entity-scoped referral events. Omit for user-only events.'
42
+ description: 'Column containing the entity ID (org/group) for entity-scoped referral events. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup. Omit for user-only events.'
43
+ },
44
+ entity_lookup: {
45
+ type: 'object',
46
+ description: 'FK lookup configuration for resolving entity_id through a related table. Used when entity_field is a FK (e.g., channel_id) rather than a direct entity_id. The generator validates all fields against metaschema within the same database_id.',
47
+ properties: {
48
+ obj_table: {
49
+ type: 'string',
50
+ description: 'Name of the related table to look up entity_id from (e.g., "channels"). Required.'
51
+ },
52
+ obj_schema: {
53
+ type: 'string',
54
+ description: 'Schema of the related table (user-facing name, e.g., "public"). Optional — if omitted, resolved by table name within the same database_id (raises error if ambiguous).'
55
+ },
56
+ obj_field: {
57
+ type: 'string',
58
+ description: 'Column on the related table that holds the entity_id (e.g., "entity_id"). Required.'
59
+ }
60
+ },
61
+ required: ['obj_table', 'obj_field']
43
62
  },
44
63
  max_depth: {
45
64
  type: 'integer',
@@ -49,7 +68,7 @@ export const EventReferral = {
49
68
  'be combined with entity_field.',
50
69
  default: 1,
51
70
  minimum: 1,
52
- maximum: 10,
71
+ maximum: 10
53
72
  },
54
73
  auto_register_type: {
55
74
  type: 'boolean',
@@ -49,7 +49,26 @@ export const EventTracker = {
49
49
  entity_field: {
50
50
  type: 'string',
51
51
  format: 'column-ref',
52
- description: 'Column containing the entity ID (org/group) for entity-scoped events. Omit for user-only events.'
52
+ description: 'Column containing the entity ID (org/group) for entity-scoped events. For FK lookups (e.g., channel_id → channels.entity_id), combine with entity_lookup. Omit for user-only events.'
53
+ },
54
+ entity_lookup: {
55
+ type: 'object',
56
+ description: 'FK lookup configuration for resolving entity_id through a related table. Used when entity_field is a FK (e.g., channel_id) rather than a direct entity_id. The generator validates all fields against metaschema within the same database_id.',
57
+ properties: {
58
+ obj_table: {
59
+ type: 'string',
60
+ description: 'Name of the related table to look up entity_id from (e.g., "channels"). Required.'
61
+ },
62
+ obj_schema: {
63
+ type: 'string',
64
+ description: 'Schema of the related table (user-facing name, e.g., "public"). Optional — if omitted, resolved by table name within the same database_id (raises error if ambiguous).'
65
+ },
66
+ obj_field: {
67
+ type: 'string',
68
+ description: 'Column on the related table that holds the entity_id (e.g., "entity_id"). Required.'
69
+ }
70
+ },
71
+ required: ['obj_table', 'obj_field']
53
72
  },
54
73
  auto_register_type: {
55
74
  type: 'boolean',
package/esm/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export * from './limit';
8
8
  export * from './module-presets';
9
9
  export * from './process';
10
10
  export * from './relation';
11
- export type { JSONSchema, NodeTypeDefinition } from './types';
11
+ export type { FieldDefault, FieldDefaultArg, FieldType, JSONSchema, NodeTypeDefinition } from './types';
12
12
  export * from './view';
13
13
  import type { NodeTypeDefinition } from './types';
14
14
  export declare const allNodeTypes: NodeTypeDefinition[];