simetra 0.1.0 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simetra",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Metadata-driven platform for business applications on Postgres: metamodel, compiler and schema engine",
5
5
  "keywords": [
6
6
  "metadata",
@@ -30,21 +30,21 @@
30
30
  "dependencies": {
31
31
  "@libpg-query/parser": "17.8.0",
32
32
  "jsonc-parser": "3.3.1",
33
- "libpg-query": "17.7.4",
34
- "zod": "^4.6.5"
33
+ "libpg-query": "17.8.2",
34
+ "zod": "^4.6.7"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@eslint/js": "^10.0.1",
38
- "@types/node": "^24.13.6",
38
+ "@types/node": "^24.19.2",
39
39
  "@types/pg": "^8.23.1",
40
40
  "@typescript/native": "npm:typescript@^7.0.2",
41
- "eslint": "^10.11.0",
41
+ "eslint": "^10.14.0",
42
42
  "pg": "8.23.1",
43
- "tsdown": "0.23.1",
43
+ "tsdown": "0.23.5",
44
44
  "tsx": "4.23.15",
45
45
  "typescript": "npm:@typescript/typescript6@^6.0.2",
46
- "typescript-eslint": "^8.70.1",
47
- "vitest": "^5.0.2"
46
+ "typescript-eslint": "^8.72.1",
47
+ "vitest": "^5.1.0"
48
48
  },
49
49
  "exports": {
50
50
  "./model": {
@@ -59,6 +59,10 @@
59
59
  "types": "./dist/schema/index.d.ts",
60
60
  "import": "./dist/schema/index.js"
61
61
  },
62
+ "./server": {
63
+ "types": "./dist/server/index.d.ts",
64
+ "import": "./dist/server/index.js"
65
+ },
62
66
  "./schemas/*": "./schemas/*"
63
67
  },
64
68
  "publishConfig": {
@@ -73,6 +77,8 @@
73
77
  "test": "vitest run --project unit",
74
78
  "test:watch": "vitest --project unit",
75
79
  "test:db": "vitest run --project db",
76
- "catalog-functions": "node scripts/catalog-functions.ts"
80
+ "bench:rights": "vitest run --project bench",
81
+ "catalog-functions": "node scripts/catalog-functions.ts",
82
+ "builtin-functions": "node scripts/builtin-functions.ts"
77
83
  }
78
84
  }
@@ -71,9 +71,13 @@
71
71
  "minLength": 1
72
72
  },
73
73
  "role": {
74
- "description": "System role of the catalog: users marks the users catalog that the platform layer provisions and references; at most one per project, unscoped.",
74
+ "description": "System role of the catalog: users marks the users catalog that the platform layer provisions and references (at most one per project, unscoped); rightsRoles and roleAssignments mark the custom roles and role assignments catalogs of a rights level, the level being the catalog's own scope (at most one per role and level).",
75
75
  "type": "string",
76
- "const": "users"
76
+ "enum": [
77
+ "users",
78
+ "rightsRoles",
79
+ "roleAssignments"
80
+ ]
77
81
  },
78
82
  "codeLength": {
79
83
  "default": 9,
@@ -489,7 +489,7 @@
489
489
  "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
490
490
  "description": "Logical element name (attribute, section, column). The casing style is checked against the project naming setting."
491
491
  },
492
- "description": "Logical names of columns of the referenced object."
492
+ "description": "Logical names of columns of the referenced CustomTable."
493
493
  }
494
494
  },
495
495
  "required": [
@@ -498,6 +498,57 @@
498
498
  ],
499
499
  "additionalProperties": false
500
500
  },
501
+ {
502
+ "type": "object",
503
+ "properties": {
504
+ "object": {
505
+ "type": "object",
506
+ "properties": {
507
+ "kind": {
508
+ "type": "string",
509
+ "enum": [
510
+ "Catalog",
511
+ "Document",
512
+ "Enumeration",
513
+ "InformationRegister",
514
+ "AccumulationRegister",
515
+ "Constant",
516
+ "CustomTable",
517
+ "PgEnum",
518
+ "EventSubscription",
519
+ "RightsSet",
520
+ "Role"
521
+ ],
522
+ "description": "Kind of the referenced metadata object."
523
+ },
524
+ "name": {
525
+ "type": "string",
526
+ "pattern": "^[A-Z][A-Za-z0-9]*$",
527
+ "description": "Logical name of the referenced object."
528
+ }
529
+ },
530
+ "required": [
531
+ "kind",
532
+ "name"
533
+ ],
534
+ "additionalProperties": false,
535
+ "description": "Referenced object of a kind (not a CustomTable)."
536
+ },
537
+ "key": {
538
+ "type": "string",
539
+ "enum": [
540
+ "ref",
541
+ "scopedRef"
542
+ ],
543
+ "description": "Referenced key of the kind table: \"ref\" is its key column (one local column); \"scopedRef\" is the pair (scope column, key) of a table with its own scope column (two local columns: scope, then key)."
544
+ }
545
+ },
546
+ "required": [
547
+ "object",
548
+ "key"
549
+ ],
550
+ "additionalProperties": false
551
+ },
501
552
  {
502
553
  "type": "object",
503
554
  "properties": {
@@ -539,7 +590,7 @@
539
590
  "additionalProperties": false
540
591
  }
541
592
  ],
542
- "description": "Referenced target: a metadata object or an external table."
593
+ "description": "Referenced target: columns of a CustomTable, the key of a kind table, or an external table."
543
594
  },
544
595
  "onDelete": {
545
596
  "default": "noAction",
@@ -490,6 +490,66 @@
490
490
  ],
491
491
  "additionalProperties": false,
492
492
  "description": "Logical names of the table columns."
493
+ },
494
+ "where": {
495
+ "default": [],
496
+ "description": "Conditions every row of the source must meet (a conjunction); rows that fail them are not part of the source.",
497
+ "type": "array",
498
+ "items": {
499
+ "anyOf": [
500
+ {
501
+ "type": "object",
502
+ "properties": {
503
+ "column": {
504
+ "type": "string",
505
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
506
+ "description": "Logical name of a column of the table."
507
+ },
508
+ "equals": {
509
+ "anyOf": [
510
+ {
511
+ "type": "string"
512
+ },
513
+ {
514
+ "type": "boolean"
515
+ },
516
+ {
517
+ "type": "integer",
518
+ "minimum": -9007199254740991,
519
+ "maximum": 9007199254740991
520
+ }
521
+ ],
522
+ "description": "Literal the column must equal: a string for a text or uuid column, a boolean, or an integer."
523
+ }
524
+ },
525
+ "required": [
526
+ "column",
527
+ "equals"
528
+ ],
529
+ "additionalProperties": false
530
+ },
531
+ {
532
+ "type": "object",
533
+ "properties": {
534
+ "column": {
535
+ "type": "string",
536
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
537
+ "description": "Logical name of a column of the table."
538
+ },
539
+ "isNull": {
540
+ "type": "boolean",
541
+ "description": "true: the column must be NULL; false: must not be NULL."
542
+ }
543
+ },
544
+ "required": [
545
+ "column",
546
+ "isNull"
547
+ ],
548
+ "additionalProperties": false
549
+ }
550
+ ],
551
+ "description": "Condition on a row of the table: a column equals a literal or is (not) NULL."
552
+ }
493
553
  }
494
554
  },
495
555
  "required": [
@@ -626,9 +686,141 @@
626
686
  "description": "Column with the member (a user for the global level)."
627
687
  },
628
688
  "role": {
629
- "type": "string",
630
- "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
631
- "description": "Column with the role key declared by a role in sourceKeys."
689
+ "anyOf": [
690
+ {
691
+ "type": "string",
692
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
693
+ "description": "Logical element name (attribute, section, column). The casing style is checked against the project naming setting."
694
+ },
695
+ {
696
+ "type": "object",
697
+ "properties": {
698
+ "column": {
699
+ "type": "string",
700
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
701
+ "description": "Column of the source table with the uuid reference to the role table."
702
+ },
703
+ "references": {
704
+ "type": "object",
705
+ "properties": {
706
+ "kind": {
707
+ "type": "string",
708
+ "enum": [
709
+ "Catalog",
710
+ "Document",
711
+ "Enumeration",
712
+ "InformationRegister",
713
+ "AccumulationRegister",
714
+ "Constant",
715
+ "CustomTable",
716
+ "PgEnum",
717
+ "EventSubscription",
718
+ "RightsSet",
719
+ "Role"
720
+ ],
721
+ "description": "Kind of the referenced metadata object."
722
+ },
723
+ "name": {
724
+ "type": "string",
725
+ "pattern": "^[A-Z][A-Za-z0-9]*$",
726
+ "description": "Logical name of the referenced object."
727
+ }
728
+ },
729
+ "required": [
730
+ "kind",
731
+ "name"
732
+ ],
733
+ "additionalProperties": false,
734
+ "description": "Adopted role table (CustomTable) with a single-column uuid key."
735
+ },
736
+ "key": {
737
+ "type": "string",
738
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
739
+ "description": "Column of the role table with the role key declared by a role in sourceKeys."
740
+ },
741
+ "where": {
742
+ "default": [],
743
+ "description": "Conditions every row of the role table must meet (a conjunction); required unless the key column is unique on its own.",
744
+ "type": "array",
745
+ "items": {
746
+ "anyOf": [
747
+ {
748
+ "type": "object",
749
+ "properties": {
750
+ "column": {
751
+ "type": "string",
752
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
753
+ "description": "Logical name of a column of the table."
754
+ },
755
+ "equals": {
756
+ "anyOf": [
757
+ {
758
+ "type": "string"
759
+ },
760
+ {
761
+ "type": "boolean"
762
+ },
763
+ {
764
+ "type": "integer",
765
+ "minimum": -9007199254740991,
766
+ "maximum": 9007199254740991
767
+ }
768
+ ],
769
+ "description": "Literal the column must equal: a string for a text or uuid column, a boolean, or an integer."
770
+ }
771
+ },
772
+ "required": [
773
+ "column",
774
+ "equals"
775
+ ],
776
+ "additionalProperties": false
777
+ },
778
+ {
779
+ "type": "object",
780
+ "properties": {
781
+ "column": {
782
+ "type": "string",
783
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
784
+ "description": "Logical name of a column of the table."
785
+ },
786
+ "isNull": {
787
+ "type": "boolean",
788
+ "description": "true: the column must be NULL; false: must not be NULL."
789
+ }
790
+ },
791
+ "required": [
792
+ "column",
793
+ "isNull"
794
+ ],
795
+ "additionalProperties": false
796
+ }
797
+ ],
798
+ "description": "Condition on a row of the table: a column equals a literal or is (not) NULL."
799
+ }
800
+ }
801
+ },
802
+ "required": [
803
+ "column",
804
+ "references",
805
+ "key"
806
+ ],
807
+ "additionalProperties": false
808
+ }
809
+ ],
810
+ "description": "Column with the role key declared by a role in sourceKeys, or a reference to an adopted role table with the key column."
811
+ },
812
+ "scope": {
813
+ "description": "Scope level only: column with the scope of the row, which must equal the scope of the member; null takes the scope from the member; omitted means the scopeColumn of the table.",
814
+ "anyOf": [
815
+ {
816
+ "type": "string",
817
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
818
+ "description": "Logical element name (attribute, section, column). The casing style is checked against the project naming setting."
819
+ },
820
+ {
821
+ "type": "null"
822
+ }
823
+ ]
632
824
  },
633
825
  "container": {
634
826
  "description": "Column with the container; required for the container level only.",
@@ -647,6 +839,66 @@
647
839
  ],
648
840
  "additionalProperties": false,
649
841
  "description": "Logical names of the table columns."
842
+ },
843
+ "where": {
844
+ "default": [],
845
+ "description": "Conditions every row of the source must meet (a conjunction); rows that fail them are not part of the source.",
846
+ "type": "array",
847
+ "items": {
848
+ "anyOf": [
849
+ {
850
+ "type": "object",
851
+ "properties": {
852
+ "column": {
853
+ "type": "string",
854
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
855
+ "description": "Logical name of a column of the table."
856
+ },
857
+ "equals": {
858
+ "anyOf": [
859
+ {
860
+ "type": "string"
861
+ },
862
+ {
863
+ "type": "boolean"
864
+ },
865
+ {
866
+ "type": "integer",
867
+ "minimum": -9007199254740991,
868
+ "maximum": 9007199254740991
869
+ }
870
+ ],
871
+ "description": "Literal the column must equal: a string for a text or uuid column, a boolean, or an integer."
872
+ }
873
+ },
874
+ "required": [
875
+ "column",
876
+ "equals"
877
+ ],
878
+ "additionalProperties": false
879
+ },
880
+ {
881
+ "type": "object",
882
+ "properties": {
883
+ "column": {
884
+ "type": "string",
885
+ "pattern": "^[A-Za-z][A-Za-z0-9_]*$",
886
+ "description": "Logical name of a column of the table."
887
+ },
888
+ "isNull": {
889
+ "type": "boolean",
890
+ "description": "true: the column must be NULL; false: must not be NULL."
891
+ }
892
+ },
893
+ "required": [
894
+ "column",
895
+ "isNull"
896
+ ],
897
+ "additionalProperties": false
898
+ }
899
+ ],
900
+ "description": "Condition on a row of the table: a column equals a literal or is (not) NULL."
901
+ }
650
902
  }
651
903
  },
652
904
  "required": [