velocity-python 0.9.6__py3-none-any.whl → 0.9.7__py3-none-any.whl
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.
- velocity/__init__.py +1 -1
- velocity/aws/handlers/mixins/__init__.py +7 -1
- velocity/aws/handlers/mixins/data_service.py +153 -0
- velocity/aws/handlers/mixins/row_scoped.py +13 -0
- velocity/db/core/table.py +45 -0
- velocity/db/servers/postgres/sql.py +25 -0
- velocity/metadata/__init__.py +52 -0
- velocity/metadata/declarations.py +325 -0
- velocity/metadata/merge.py +252 -0
- velocity/metadata/validate.py +81 -0
- velocity/testing/fake_db.py +42 -3
- {velocity_python-0.9.6.dist-info → velocity_python-0.9.7.dist-info}/METADATA +1 -1
- {velocity_python-0.9.6.dist-info → velocity_python-0.9.7.dist-info}/RECORD +17 -13
- {velocity_python-0.9.6.dist-info → velocity_python-0.9.7.dist-info}/WHEEL +0 -0
- {velocity_python-0.9.6.dist-info → velocity_python-0.9.7.dist-info}/entry_points.txt +0 -0
- {velocity_python-0.9.6.dist-info → velocity_python-0.9.7.dist-info}/licenses/LICENSE +0 -0
- {velocity_python-0.9.6.dist-info → velocity_python-0.9.7.dist-info}/top_level.txt +0 -0
velocity/__init__.py
CHANGED
|
@@ -25,7 +25,12 @@ This package provides mixins for common Lambda handler patterns:
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
from .web_handler import WebHandler, ButtonHandler
|
|
28
|
-
from .data_service import
|
|
28
|
+
from .data_service import (
|
|
29
|
+
ALL_TABLES,
|
|
30
|
+
METADATA_ACTIONS,
|
|
31
|
+
VALIDATION_ACTIONS,
|
|
32
|
+
DataServiceMixin,
|
|
33
|
+
)
|
|
29
34
|
from .row_scoped import RowScopedDataService
|
|
30
35
|
from .audit_trail import AuditTrailMixin
|
|
31
36
|
from .job_handler import JobHandler
|
|
@@ -46,6 +51,7 @@ from velocity.aws.scheduler import SchedulerMixin
|
|
|
46
51
|
__all__ = [
|
|
47
52
|
"ALL_TABLES",
|
|
48
53
|
"VALIDATION_ACTIONS",
|
|
54
|
+
"METADATA_ACTIONS",
|
|
49
55
|
"WebHandler",
|
|
50
56
|
"ButtonHandler",
|
|
51
57
|
"DataServiceMixin",
|
|
@@ -6,6 +6,7 @@ that uses velocity.db for database access.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import base64
|
|
9
|
+
import copy
|
|
9
10
|
import datetime
|
|
10
11
|
import importlib
|
|
11
12
|
import json
|
|
@@ -26,6 +27,8 @@ from velocity.aws.handlers.exceptions import (
|
|
|
26
27
|
ValidationError,
|
|
27
28
|
)
|
|
28
29
|
from velocity.aws.handlers.mixins.client_input import MODES, STRICT, ClientInputGuard
|
|
30
|
+
from velocity import metadata as _metadata
|
|
31
|
+
from velocity.cache import memo as read_cache_memo
|
|
29
32
|
from velocity.db.exceptions import DbDataIntegrityError
|
|
30
33
|
from velocity.db.fragments import Expr, Literal
|
|
31
34
|
from velocity.db.servers.tablehelper import TableHelper
|
|
@@ -492,6 +495,15 @@ ACTION_NOT_AVAILABLE = "This action is not available."
|
|
|
492
495
|
# ``client_actions`` allow-list: ``client_actions = MINE | VALIDATION_ACTIONS``.
|
|
493
496
|
VALIDATION_ACTIONS = frozenset({"validation-overrides"})
|
|
494
497
|
|
|
498
|
+
# The served-metadata action (velocity.metadata), for a ``client_actions``
|
|
499
|
+
# allow-list. It also needs ``metadata_enabled = True`` on the handler.
|
|
500
|
+
METADATA_ACTIONS = frozenset({"get-metadata"})
|
|
501
|
+
|
|
502
|
+
# declarations ship with the code: reread at most this often per container
|
|
503
|
+
METADATA_DECLARATIONS_CACHE_SECONDS = 3600
|
|
504
|
+
# the most table names one get-metadata request may name
|
|
505
|
+
METADATA_MAX_TABLES = 500
|
|
506
|
+
|
|
495
507
|
|
|
496
508
|
class _AllTables:
|
|
497
509
|
"""``direct_allowed_tables = ALL_TABLES``: an explicit opt-in to every
|
|
@@ -780,6 +792,23 @@ class DataServiceMixin:
|
|
|
780
792
|
client_denied_tables = frozenset()
|
|
781
793
|
client_allowed_tables = None
|
|
782
794
|
|
|
795
|
+
# Served metadata (velocity.metadata, ``get-metadata``): OFF unless a
|
|
796
|
+
# handler sets ``metadata_enabled = True``; a ``client_actions``
|
|
797
|
+
# allow-list must also name it (``METADATA_ACTIONS``). Declarations are
|
|
798
|
+
# read from ``metadata_dirs`` (later directories override earlier ones
|
|
799
|
+
# per table); override :meth:`metadata_declarations` to supply them
|
|
800
|
+
# another way. Only tables that pass the client table gate (as read by
|
|
801
|
+
# ``get-tables`` and ``query``) are served.
|
|
802
|
+
metadata_enabled = False
|
|
803
|
+
metadata_dirs = ()
|
|
804
|
+
# A table with no declaration is served from its database columns only
|
|
805
|
+
# when this is True (and it passes every gate below); off by default.
|
|
806
|
+
metadata_undeclared = False
|
|
807
|
+
# ``{table: {column, ...}}`` never served for an undeclared table (the
|
|
808
|
+
# undeclared-table fallback); the user table's compiled permissions
|
|
809
|
+
# column is always hidden.
|
|
810
|
+
metadata_hidden_columns = MappingProxyType({})
|
|
811
|
+
|
|
783
812
|
# The authorization decision point (velocity.aws.authz) at the client
|
|
784
813
|
# table gate. ``"off"`` (default): the gate is as above. ``"log"``: every
|
|
785
814
|
# table is also put to the rules and what they would refuse is logged,
|
|
@@ -2740,6 +2769,130 @@ class DataServiceMixin:
|
|
|
2740
2769
|
tables.add(name)
|
|
2741
2770
|
context.response().set_body({"tables": sorted(tables)})
|
|
2742
2771
|
|
|
2772
|
+
def metadata_declarations(self, tx, context):
|
|
2773
|
+
"""``{table: declaration}`` served by ``get-metadata``: by default
|
|
2774
|
+
``velocity.metadata.load_declarations(*metadata_dirs)``, read once
|
|
2775
|
+
per container (an invalid declaration raises, naming every
|
|
2776
|
+
problem). Each call returns its own copy."""
|
|
2777
|
+
dirs = tuple(str(d) for d in (self.metadata_dirs or ()))
|
|
2778
|
+
if not dirs:
|
|
2779
|
+
return {}
|
|
2780
|
+
return copy.deepcopy(
|
|
2781
|
+
read_cache_memo(
|
|
2782
|
+
("metadata-declarations", dirs),
|
|
2783
|
+
lambda: _metadata.load_declarations(*dirs),
|
|
2784
|
+
METADATA_DECLARATIONS_CACHE_SECONDS,
|
|
2785
|
+
)
|
|
2786
|
+
)
|
|
2787
|
+
|
|
2788
|
+
def _metadata_table_allowed(self, tx, table, context, declared=False):
|
|
2789
|
+
"""The metadata-specific table gate ``get-metadata`` applies after the
|
|
2790
|
+
client table gate (always; the action has no path around it). It
|
|
2791
|
+
stands in for what ``query`` refuses later than the table gate:
|
|
2792
|
+
|
|
2793
|
+
* a table in ``restricted_direct_tables``, or one a tenant or owner
|
|
2794
|
+
scope applies to, is served only when it is declared (a
|
|
2795
|
+
declaration is a deliberate decision to describe it);
|
|
2796
|
+
* whatever ``query``'s tenant/owner resolution refuses
|
|
2797
|
+
(:meth:`_resolve_tenant_scope`: a scope that raises, a session with
|
|
2798
|
+
no tenant value, a non-strict client SQL mode under a scope, a
|
|
2799
|
+
table without the scope column) refuses it here too, declared or
|
|
2800
|
+
not.
|
|
2801
|
+
|
|
2802
|
+
A site whose ``before_query`` hooks (or ``scope_query_params``)
|
|
2803
|
+
refuse tables to some callers must mirror that rule in an override
|
|
2804
|
+
of this method (``return super()._metadata_table_allowed(...) and
|
|
2805
|
+
...``): those hooks run only for a query, never here.
|
|
2806
|
+
``RowScopedDataService`` adds its own row-scope requirement."""
|
|
2807
|
+
try:
|
|
2808
|
+
# the same fail-closed resolution query applies (read-only)
|
|
2809
|
+
scoped = self._resolve_tenant_scope(tx, table, context) is not None
|
|
2810
|
+
except Exception: # noqa: BLE001 — a scope that refuses refuses here
|
|
2811
|
+
return False
|
|
2812
|
+
if declared:
|
|
2813
|
+
return True
|
|
2814
|
+
if table in self.restricted_direct_tables:
|
|
2815
|
+
return False
|
|
2816
|
+
return not scoped
|
|
2817
|
+
|
|
2818
|
+
def _metadata_hidden_columns(self):
|
|
2819
|
+
"""``{table: frozenset(columns)}`` never served for an undeclared
|
|
2820
|
+
table: ``metadata_hidden_columns`` plus the user table's compiled
|
|
2821
|
+
permissions column."""
|
|
2822
|
+
hidden = {
|
|
2823
|
+
str(table): frozenset(columns)
|
|
2824
|
+
for table, columns in (self.metadata_hidden_columns or {}).items()
|
|
2825
|
+
}
|
|
2826
|
+
user_table = getattr(self, "user_table", None)
|
|
2827
|
+
if isinstance(user_table, str) and user_table:
|
|
2828
|
+
hidden[user_table] = hidden.get(user_table, frozenset()) | {
|
|
2829
|
+
_grants.USER_COLUMN
|
|
2830
|
+
}
|
|
2831
|
+
return hidden
|
|
2832
|
+
|
|
2833
|
+
def OnActionGetMetadata(self, tx, context):
|
|
2834
|
+
"""``get-metadata {tables?, hash?}``: the merged metadata
|
|
2835
|
+
(declaration -> database column info -> live overrides) of the
|
|
2836
|
+
tables this caller may read, and its hash.
|
|
2837
|
+
|
|
2838
|
+
Off unless the handler sets ``metadata_enabled`` (an
|
|
2839
|
+
``AccessError`` otherwise). ``tables`` (a list of table names)
|
|
2840
|
+
narrows the answer; without it every declared table is considered.
|
|
2841
|
+
Only declared tables are served unless ``metadata_undeclared`` is
|
|
2842
|
+
set. A table must pass the client table gate (the check
|
|
2843
|
+
``get-tables`` and ``query`` apply) and then
|
|
2844
|
+
:meth:`_metadata_table_allowed`; confidential tables are never
|
|
2845
|
+
served. Any other table is left out silently. A declared table
|
|
2846
|
+
carries only its declared fields (plus read-only ``sys_*`` columns).
|
|
2847
|
+
When ``hash`` equals the hash of what would be served the answer is
|
|
2848
|
+
``{"hash", "unchanged": true}``; otherwise
|
|
2849
|
+
``{"metadata": {table: ...}, "hash"}``. Override problems are
|
|
2850
|
+
logged, never served."""
|
|
2851
|
+
if not self.metadata_enabled:
|
|
2852
|
+
raise AccessError(ACTION_NOT_AVAILABLE)
|
|
2853
|
+
payload = context.payload() or {}
|
|
2854
|
+
requested = payload.get("tables")
|
|
2855
|
+
if requested is not None:
|
|
2856
|
+
if not isinstance(requested, list) or not all(
|
|
2857
|
+
isinstance(name, str) for name in requested
|
|
2858
|
+
):
|
|
2859
|
+
raise BadRequestError("tables: expected a list of table names")
|
|
2860
|
+
if len(requested) > METADATA_MAX_TABLES:
|
|
2861
|
+
raise BadRequestError(
|
|
2862
|
+
f"tables: at most {METADATA_MAX_TABLES} names per request"
|
|
2863
|
+
)
|
|
2864
|
+
known = payload.get("hash")
|
|
2865
|
+
if known is not None and not isinstance(known, str):
|
|
2866
|
+
raise BadRequestError("hash: expected a string")
|
|
2867
|
+
declarations = self.metadata_declarations(tx, context) or {}
|
|
2868
|
+
names = declarations if requested is None else requested
|
|
2869
|
+
tables = []
|
|
2870
|
+
for name in sorted(set(names)):
|
|
2871
|
+
declared = name in declarations
|
|
2872
|
+
if not declared and not self.metadata_undeclared:
|
|
2873
|
+
continue
|
|
2874
|
+
if not self._client_table_allowed(name):
|
|
2875
|
+
continue
|
|
2876
|
+
if authz.is_confidential(name):
|
|
2877
|
+
continue
|
|
2878
|
+
if not self._metadata_table_allowed(tx, name, context, declared=declared):
|
|
2879
|
+
continue
|
|
2880
|
+
tables.append(name)
|
|
2881
|
+
built = _metadata.build_metadata(
|
|
2882
|
+
tx,
|
|
2883
|
+
declarations,
|
|
2884
|
+
tables,
|
|
2885
|
+
hidden_columns=self._metadata_hidden_columns(),
|
|
2886
|
+
)
|
|
2887
|
+
for warning in built["warnings"]:
|
|
2888
|
+
logger.warning("get-metadata: %s", warning)
|
|
2889
|
+
if known is not None and known == built["hash"]:
|
|
2890
|
+
context.response().set_body({"hash": built["hash"], "unchanged": True})
|
|
2891
|
+
return
|
|
2892
|
+
context.response().set_body(
|
|
2893
|
+
{"metadata": built["metadata"], "hash": built["hash"]}
|
|
2894
|
+
)
|
|
2895
|
+
|
|
2743
2896
|
def OnActionUpdateRows(self, tx, context):
|
|
2744
2897
|
"""
|
|
2745
2898
|
Update multiple rows with the same data.
|
|
@@ -277,6 +277,19 @@ class RowScopedDataService(DataServiceMixin):
|
|
|
277
277
|
raise AlertError(f"Record {sys_id} was not found in {table}.")
|
|
278
278
|
return super().delete_hook(tx, table, sys_id, context)
|
|
279
279
|
|
|
280
|
+
def _metadata_table_allowed(self, tx, table, context, declared=False):
|
|
281
|
+
"""``get-metadata`` serves a table only when this caller has a row
|
|
282
|
+
scope for it (or it is a read-only shared table), as ``query``
|
|
283
|
+
would: a table with no scope configured, or a session with no
|
|
284
|
+
owner, is refused."""
|
|
285
|
+
if not super()._metadata_table_allowed(tx, table, context, declared):
|
|
286
|
+
return False
|
|
287
|
+
try:
|
|
288
|
+
self.row_scope(tx, table, context)
|
|
289
|
+
except Exception: # noqa: BLE001 — no scope, no metadata
|
|
290
|
+
return False
|
|
291
|
+
return True
|
|
292
|
+
|
|
280
293
|
def _assert_direct_access_allowed(self, table):
|
|
281
294
|
"""query-direct / update-rows / get-table-schema / renumber-object
|
|
282
295
|
bypass the hooks above: never available on a row-scoped service."""
|
velocity/db/core/table.py
CHANGED
|
@@ -783,6 +783,51 @@ class Table:
|
|
|
783
783
|
)
|
|
784
784
|
return load()
|
|
785
785
|
|
|
786
|
+
def column_details(self, **kwds):
|
|
787
|
+
"""The table's columns in ordinal order, one dict each:
|
|
788
|
+
``{"name", "type", "nullable", "max_length"}`` (``type`` is the
|
|
789
|
+
information_schema name such as ``text`` or ``timestamp with time
|
|
790
|
+
zone``; ``nullable`` a bool; ``max_length`` the character limit or
|
|
791
|
+
``None``). An unqualified name is looked up in the connection's
|
|
792
|
+
current schema. ``[]`` for a missing table, or when the server module
|
|
793
|
+
has no ``column_details`` SQL. ``cache_ttl=N`` as in ``sys_columns``.
|
|
794
|
+
Read-only: never creates anything."""
|
|
795
|
+
builder = getattr(self.sql, "column_details", None)
|
|
796
|
+
if builder is None:
|
|
797
|
+
return []
|
|
798
|
+
sql, vals = builder(self.name)
|
|
799
|
+
if kwds.get("sql_only", False):
|
|
800
|
+
return sql, vals
|
|
801
|
+
|
|
802
|
+
def load():
|
|
803
|
+
result = self.tx.execute(sql, vals, cursor=self.cursor())
|
|
804
|
+
out = []
|
|
805
|
+
for name, dtype, nullable, max_length in result.as_tuple():
|
|
806
|
+
out.append(
|
|
807
|
+
{
|
|
808
|
+
"name": name,
|
|
809
|
+
"type": dtype,
|
|
810
|
+
"nullable": str(nullable).upper() in ("YES", "TRUE", "1"),
|
|
811
|
+
"max_length": (
|
|
812
|
+
int(max_length) if max_length is not None else None
|
|
813
|
+
),
|
|
814
|
+
}
|
|
815
|
+
)
|
|
816
|
+
return out
|
|
817
|
+
|
|
818
|
+
cache_ttl = kwds.get("cache_ttl")
|
|
819
|
+
if cache_ttl:
|
|
820
|
+
from velocity.cache import SCHEMA_TAG
|
|
821
|
+
|
|
822
|
+
cached = self.tx.cached_read(
|
|
823
|
+
("column_details", self._cache_scope(), self.name),
|
|
824
|
+
load,
|
|
825
|
+
cache_ttl,
|
|
826
|
+
tables=(self.name, SCHEMA_TAG),
|
|
827
|
+
)
|
|
828
|
+
return [dict(column) for column in cached]
|
|
829
|
+
return load()
|
|
830
|
+
|
|
786
831
|
def columns(self):
|
|
787
832
|
"""
|
|
788
833
|
Returns non-system column names.
|
|
@@ -1888,6 +1888,31 @@ class SQL(BaseSQLDialect):
|
|
|
1888
1888
|
name,
|
|
1889
1889
|
)
|
|
1890
1890
|
|
|
1891
|
+
@classmethod
|
|
1892
|
+
def column_details(cls, name):
|
|
1893
|
+
"""``(column_name, data_type, is_nullable, character_maximum_length)``
|
|
1894
|
+
rows in ordinal order (``Table.column_details``). Names match
|
|
1895
|
+
exactly, as PostgreSQL resolves an unquoted (lower-case) name: a
|
|
1896
|
+
quoted mixed-case table is never matched by its lower-case spelling.
|
|
1897
|
+
An unqualified name is looked up in ``current_schema()`` only, so a
|
|
1898
|
+
same-named table in another schema never adds columns."""
|
|
1899
|
+
if "." in name:
|
|
1900
|
+
where = "table_schema = %s"
|
|
1901
|
+
params = tuple(name.split(".", 1))
|
|
1902
|
+
else:
|
|
1903
|
+
where = "table_schema = current_schema()"
|
|
1904
|
+
params = (name,)
|
|
1905
|
+
return (
|
|
1906
|
+
f"""
|
|
1907
|
+
select column_name, data_type, is_nullable, character_maximum_length
|
|
1908
|
+
from information_schema.columns
|
|
1909
|
+
where {where}
|
|
1910
|
+
and table_name = %s
|
|
1911
|
+
order by ordinal_position
|
|
1912
|
+
""",
|
|
1913
|
+
params,
|
|
1914
|
+
)
|
|
1915
|
+
|
|
1891
1916
|
@classmethod
|
|
1892
1917
|
def column_info(cls, table, name):
|
|
1893
1918
|
params = table.split(".")
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Server-declared table and form metadata.
|
|
2
|
+
|
|
3
|
+
Each table's metadata is declared once as JSON (widgets, labels, options,
|
|
4
|
+
forms, grid settings), merged on the server with the database's column info
|
|
5
|
+
and any live overrides, and served to clients by DataService's opt-in
|
|
6
|
+
``get-metadata`` action. The same declaration checks writes
|
|
7
|
+
(:func:`validate_row`). See ``docs/metadata.md``.
|
|
8
|
+
|
|
9
|
+
Importing this package needs no database driver.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from velocity.metadata.declarations import (
|
|
13
|
+
DeclarationError,
|
|
14
|
+
check_declaration,
|
|
15
|
+
load_declarations,
|
|
16
|
+
template_names,
|
|
17
|
+
)
|
|
18
|
+
from velocity.metadata.merge import (
|
|
19
|
+
OVERRIDABLE,
|
|
20
|
+
OVERRIDES_TABLE,
|
|
21
|
+
SYSTEM_COLUMNS,
|
|
22
|
+
apply_overrides,
|
|
23
|
+
build_metadata,
|
|
24
|
+
column_info,
|
|
25
|
+
default_field,
|
|
26
|
+
default_label,
|
|
27
|
+
default_widget,
|
|
28
|
+
merge_table,
|
|
29
|
+
metadata_hash,
|
|
30
|
+
read_overrides,
|
|
31
|
+
)
|
|
32
|
+
from velocity.metadata.validate import validate_row
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"DeclarationError",
|
|
36
|
+
"OVERRIDABLE",
|
|
37
|
+
"OVERRIDES_TABLE",
|
|
38
|
+
"SYSTEM_COLUMNS",
|
|
39
|
+
"apply_overrides",
|
|
40
|
+
"build_metadata",
|
|
41
|
+
"check_declaration",
|
|
42
|
+
"column_info",
|
|
43
|
+
"default_field",
|
|
44
|
+
"default_label",
|
|
45
|
+
"default_widget",
|
|
46
|
+
"load_declarations",
|
|
47
|
+
"merge_table",
|
|
48
|
+
"metadata_hash",
|
|
49
|
+
"read_overrides",
|
|
50
|
+
"template_names",
|
|
51
|
+
"validate_row",
|
|
52
|
+
]
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"""Table metadata declarations: the format, its checker and the loader.
|
|
2
|
+
|
|
3
|
+
One JSON object per table, data only (see ``docs/metadata.md``)::
|
|
4
|
+
|
|
5
|
+
{"table": "people",
|
|
6
|
+
"headline": "{last_name}, {first_name}",
|
|
7
|
+
"orderby": "last_name",
|
|
8
|
+
"fields": {"status": {"widget": "TextWidget", "label": "Status",
|
|
9
|
+
"options": [{"key": "Active", "value": "active"}]}},
|
|
10
|
+
"forms": {"default": {"sections": [{"title": "Who", "fields": ["status"]}]}},
|
|
11
|
+
"cells": {"status": "statusChip"},
|
|
12
|
+
"cards": ["resendInvite"]}
|
|
13
|
+
|
|
14
|
+
:func:`check_declaration` lists every problem in one declaration;
|
|
15
|
+
:func:`load_declarations` reads ``*.json`` files from directories and raises
|
|
16
|
+
:class:`DeclarationError` naming every problem in every file.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import copy
|
|
22
|
+
import json
|
|
23
|
+
import numbers
|
|
24
|
+
import os
|
|
25
|
+
import re
|
|
26
|
+
from typing import Any, Dict, List, Mapping, Optional
|
|
27
|
+
|
|
28
|
+
_IDENTIFIER = re.compile(r"^[a-z_][a-z0-9_]*$")
|
|
29
|
+
_TEMPLATE_PART = re.compile(r"\{([^{}]*)\}")
|
|
30
|
+
|
|
31
|
+
TOP_KEYS = frozenset(
|
|
32
|
+
{"table", "headline", "orderby", "fields", "forms", "cells", "cards"}
|
|
33
|
+
)
|
|
34
|
+
FIELD_KEYS = frozenset(
|
|
35
|
+
{
|
|
36
|
+
"widget",
|
|
37
|
+
"label",
|
|
38
|
+
"help",
|
|
39
|
+
"placeholder",
|
|
40
|
+
"options",
|
|
41
|
+
"pointer",
|
|
42
|
+
"display",
|
|
43
|
+
"required",
|
|
44
|
+
"min",
|
|
45
|
+
"max",
|
|
46
|
+
"max_length",
|
|
47
|
+
"read_only",
|
|
48
|
+
"grid",
|
|
49
|
+
"link",
|
|
50
|
+
"props",
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
GRID_KEYS = frozenset({"show", "searchable", "order"})
|
|
54
|
+
OPTION_KEYS = frozenset({"key", "value"})
|
|
55
|
+
FORM_KEYS = frozenset({"sections"})
|
|
56
|
+
SECTION_KEYS = frozenset({"title", "fields"})
|
|
57
|
+
|
|
58
|
+
_STRING_FIELD_KEYS = ("widget", "label", "help", "placeholder", "pointer", "display")
|
|
59
|
+
_BOOL_FIELD_KEYS = ("required", "read_only")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class DeclarationError(ValueError):
|
|
63
|
+
"""Declarations that do not pass :func:`check_declaration`;
|
|
64
|
+
``problems`` lists every one, each prefixed with its file."""
|
|
65
|
+
|
|
66
|
+
def __init__(self, problems: List[str]):
|
|
67
|
+
self.problems = list(problems)
|
|
68
|
+
super().__init__(
|
|
69
|
+
"metadata declarations have problems:\n " + "\n ".join(self.problems)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _is_number(value) -> bool:
|
|
74
|
+
return isinstance(value, numbers.Real) and not isinstance(value, bool)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _is_int(value) -> bool:
|
|
78
|
+
return isinstance(value, int) and not isinstance(value, bool)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def template_names(template: str) -> List[str]:
|
|
82
|
+
"""The ``{column}`` names a ``headline`` / ``display`` template uses, in
|
|
83
|
+
order. Raises ``ValueError`` for a stray brace or a name that is not a
|
|
84
|
+
plain lower-case identifier."""
|
|
85
|
+
names = []
|
|
86
|
+
for name in _TEMPLATE_PART.findall(template):
|
|
87
|
+
if not _IDENTIFIER.match(name):
|
|
88
|
+
raise ValueError(f"{{{name}}} is not a column name")
|
|
89
|
+
names.append(name)
|
|
90
|
+
if "{" in _TEMPLATE_PART.sub("", template) or "}" in _TEMPLATE_PART.sub(
|
|
91
|
+
"", template
|
|
92
|
+
):
|
|
93
|
+
raise ValueError("has an unmatched brace")
|
|
94
|
+
return names
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _unknown_keys(where: str, value: Mapping, allowed) -> List[str]:
|
|
98
|
+
return [
|
|
99
|
+
f"{where}: unknown key {key!r}"
|
|
100
|
+
for key in sorted(map(str, value))
|
|
101
|
+
if key not in allowed
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _check_template(where, template, columns, problems):
|
|
106
|
+
if not isinstance(template, str):
|
|
107
|
+
problems.append(f"{where}: expected a string")
|
|
108
|
+
return
|
|
109
|
+
try:
|
|
110
|
+
names = template_names(template)
|
|
111
|
+
except ValueError as exc:
|
|
112
|
+
problems.append(f"{where}: {exc}")
|
|
113
|
+
return
|
|
114
|
+
if columns is None:
|
|
115
|
+
return
|
|
116
|
+
for name in names:
|
|
117
|
+
if name not in columns:
|
|
118
|
+
problems.append(f"{where}: {{{name}}} is not a declared field")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _check_options(where, options, problems):
|
|
122
|
+
if not isinstance(options, list):
|
|
123
|
+
problems.append(f"{where}: expected a list of {{key, value}}")
|
|
124
|
+
return
|
|
125
|
+
seen = set()
|
|
126
|
+
for i, option in enumerate(options):
|
|
127
|
+
at = f"{where}[{i}]"
|
|
128
|
+
if not isinstance(option, dict):
|
|
129
|
+
problems.append(f"{at}: expected an object with key and value")
|
|
130
|
+
continue
|
|
131
|
+
problems.extend(_unknown_keys(at, option, OPTION_KEYS))
|
|
132
|
+
if not isinstance(option.get("key"), str):
|
|
133
|
+
problems.append(f"{at}.key: expected a string")
|
|
134
|
+
if "value" not in option:
|
|
135
|
+
problems.append(f"{at}: missing value")
|
|
136
|
+
continue
|
|
137
|
+
value = option["value"]
|
|
138
|
+
if value is not None and not isinstance(value, (str, int, float, bool)):
|
|
139
|
+
problems.append(f"{at}.value: expected a string, number or boolean")
|
|
140
|
+
continue
|
|
141
|
+
marker = (type(value).__name__, value)
|
|
142
|
+
if marker in seen:
|
|
143
|
+
problems.append(f"{at}.value: {value!r} is listed twice")
|
|
144
|
+
seen.add(marker)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _check_field(table, column, field, pointed, problems):
|
|
148
|
+
where = f"{table}.fields.{column}"
|
|
149
|
+
if not _IDENTIFIER.match(column):
|
|
150
|
+
problems.append(f"{where}: field name is not a lower-case column name")
|
|
151
|
+
if not isinstance(field, dict):
|
|
152
|
+
problems.append(f"{where}: expected an object")
|
|
153
|
+
return
|
|
154
|
+
problems.extend(_unknown_keys(where, field, FIELD_KEYS))
|
|
155
|
+
if "widget" not in field:
|
|
156
|
+
problems.append(f"{where}: missing widget")
|
|
157
|
+
for key in _STRING_FIELD_KEYS:
|
|
158
|
+
if key in field and key != "display":
|
|
159
|
+
if not isinstance(field[key], str) or not field[key].strip():
|
|
160
|
+
problems.append(f"{where}.{key}: expected a non-empty string")
|
|
161
|
+
for key in _BOOL_FIELD_KEYS:
|
|
162
|
+
if key in field and not isinstance(field[key], bool):
|
|
163
|
+
problems.append(f"{where}.{key}: expected true or false")
|
|
164
|
+
for key in ("min", "max"):
|
|
165
|
+
if key in field and not _is_number(field[key]):
|
|
166
|
+
problems.append(f"{where}.{key}: expected a number")
|
|
167
|
+
if (
|
|
168
|
+
_is_number(field.get("min"))
|
|
169
|
+
and _is_number(field.get("max"))
|
|
170
|
+
and field["min"] > field["max"]
|
|
171
|
+
):
|
|
172
|
+
problems.append(f"{where}: min is greater than max")
|
|
173
|
+
if "max_length" in field and not (
|
|
174
|
+
_is_int(field["max_length"]) and field["max_length"] > 0
|
|
175
|
+
):
|
|
176
|
+
problems.append(f"{where}.max_length: expected a positive whole number")
|
|
177
|
+
if "options" in field:
|
|
178
|
+
_check_options(f"{where}.options", field["options"], problems)
|
|
179
|
+
if "grid" in field:
|
|
180
|
+
grid = field["grid"]
|
|
181
|
+
if not isinstance(grid, dict):
|
|
182
|
+
problems.append(f"{where}.grid: expected an object")
|
|
183
|
+
else:
|
|
184
|
+
problems.extend(_unknown_keys(f"{where}.grid", grid, GRID_KEYS))
|
|
185
|
+
for key in ("show", "searchable"):
|
|
186
|
+
if key in grid and not isinstance(grid[key], bool):
|
|
187
|
+
problems.append(f"{where}.grid.{key}: expected true or false")
|
|
188
|
+
if "order" in grid and not _is_int(grid["order"]):
|
|
189
|
+
problems.append(f"{where}.grid.order: expected a whole number")
|
|
190
|
+
for key in ("link", "props"):
|
|
191
|
+
if key in field and not isinstance(field[key], dict):
|
|
192
|
+
problems.append(f"{where}.{key}: expected an object")
|
|
193
|
+
if "display" in field:
|
|
194
|
+
if "pointer" not in field:
|
|
195
|
+
problems.append(f"{where}.display: only a pointer field has a display")
|
|
196
|
+
# a display template names the POINTED table's columns: checked
|
|
197
|
+
# against its declaration when that table is declared too
|
|
198
|
+
target = pointed.get(field.get("pointer")) if pointed else None
|
|
199
|
+
columns = None
|
|
200
|
+
if isinstance(target, dict) and isinstance(target.get("fields"), dict):
|
|
201
|
+
columns = target["fields"]
|
|
202
|
+
_check_template(f"{where}.display", field["display"], columns, problems)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def check_declaration(
|
|
206
|
+
decl: Any, declarations: Optional[Mapping[str, Any]] = None
|
|
207
|
+
) -> List[str]:
|
|
208
|
+
"""Every problem in one table declaration, ``[]`` when it is sound:
|
|
209
|
+
unknown keys, wrong types, form/cell fields that are not declared
|
|
210
|
+
fields, and ``{column}`` templates naming unknown columns.
|
|
211
|
+
|
|
212
|
+
``declarations`` (``{table: decl}``, optional) lets a pointer field's
|
|
213
|
+
``display`` template be checked against the pointed table's fields; a
|
|
214
|
+
pointer to an undeclared table is not checked."""
|
|
215
|
+
if not isinstance(decl, dict):
|
|
216
|
+
return ["declaration: expected a JSON object"]
|
|
217
|
+
table = decl.get("table")
|
|
218
|
+
problems: List[str] = []
|
|
219
|
+
if not isinstance(table, str) or not _IDENTIFIER.match(table):
|
|
220
|
+
problems.append("table: expected a lower-case table name")
|
|
221
|
+
table = str(table)
|
|
222
|
+
problems.extend(_unknown_keys(table, decl, TOP_KEYS))
|
|
223
|
+
for key in ("headline", "orderby"):
|
|
224
|
+
if key in decl and (not isinstance(decl[key], str) or not decl[key].strip()):
|
|
225
|
+
problems.append(f"{table}.{key}: expected a non-empty string")
|
|
226
|
+
|
|
227
|
+
fields = decl.get("fields")
|
|
228
|
+
if not isinstance(fields, dict):
|
|
229
|
+
problems.append(f"{table}.fields: expected an object of columns")
|
|
230
|
+
fields = {}
|
|
231
|
+
for column in fields:
|
|
232
|
+
_check_field(table, str(column), fields[column], declarations, problems)
|
|
233
|
+
|
|
234
|
+
if isinstance(decl.get("headline"), str):
|
|
235
|
+
_check_template(f"{table}.headline", decl["headline"], fields, problems)
|
|
236
|
+
|
|
237
|
+
forms = decl.get("forms", {})
|
|
238
|
+
if not isinstance(forms, dict):
|
|
239
|
+
problems.append(f"{table}.forms: expected an object of forms")
|
|
240
|
+
forms = {}
|
|
241
|
+
for name, form in forms.items():
|
|
242
|
+
at = f"{table}.forms.{name}"
|
|
243
|
+
if not isinstance(form, dict):
|
|
244
|
+
problems.append(f"{at}: expected an object")
|
|
245
|
+
continue
|
|
246
|
+
problems.extend(_unknown_keys(at, form, FORM_KEYS))
|
|
247
|
+
sections = form.get("sections")
|
|
248
|
+
if not isinstance(sections, list):
|
|
249
|
+
problems.append(f"{at}.sections: expected a list")
|
|
250
|
+
continue
|
|
251
|
+
for i, section in enumerate(sections):
|
|
252
|
+
sat = f"{at}.sections[{i}]"
|
|
253
|
+
if not isinstance(section, dict):
|
|
254
|
+
problems.append(f"{sat}: expected an object")
|
|
255
|
+
continue
|
|
256
|
+
problems.extend(_unknown_keys(sat, section, SECTION_KEYS))
|
|
257
|
+
if "title" in section and not isinstance(section["title"], str):
|
|
258
|
+
problems.append(f"{sat}.title: expected a string")
|
|
259
|
+
names = section.get("fields")
|
|
260
|
+
if not isinstance(names, list):
|
|
261
|
+
problems.append(f"{sat}.fields: expected a list of fields")
|
|
262
|
+
continue
|
|
263
|
+
for column in names:
|
|
264
|
+
if not isinstance(column, str) or column not in fields:
|
|
265
|
+
problems.append(f"{sat}.fields: {column!r} is not a declared field")
|
|
266
|
+
|
|
267
|
+
cells = decl.get("cells", {})
|
|
268
|
+
if not isinstance(cells, dict):
|
|
269
|
+
problems.append(f"{table}.cells: expected an object of column: name")
|
|
270
|
+
cells = {}
|
|
271
|
+
for column, name in cells.items():
|
|
272
|
+
if column not in fields:
|
|
273
|
+
problems.append(f"{table}.cells: {column!r} is not a declared field")
|
|
274
|
+
if not isinstance(name, str) or not name.strip():
|
|
275
|
+
problems.append(f"{table}.cells.{column}: expected a registered name")
|
|
276
|
+
|
|
277
|
+
cards = decl.get("cards", [])
|
|
278
|
+
if not isinstance(cards, list) or not all(
|
|
279
|
+
isinstance(name, str) and name.strip() for name in cards
|
|
280
|
+
):
|
|
281
|
+
problems.append(f"{table}.cards: expected a list of registered names")
|
|
282
|
+
return problems
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def load_declarations(*dirs) -> Dict[str, dict]:
|
|
286
|
+
"""``{table: declaration}`` from the ``*.json`` files in ``dirs`` (each
|
|
287
|
+
read in name order). A later directory's declaration of a table replaces
|
|
288
|
+
an earlier one whole; two files for one table in the same directory is a
|
|
289
|
+
problem. Every declaration is checked (display templates against the
|
|
290
|
+
final set), and :class:`DeclarationError` lists every problem found."""
|
|
291
|
+
problems: List[str] = []
|
|
292
|
+
found: Dict[str, dict] = {}
|
|
293
|
+
sources: Dict[str, str] = {}
|
|
294
|
+
for directory in dirs:
|
|
295
|
+
directory = os.fspath(directory)
|
|
296
|
+
if not os.path.isdir(directory):
|
|
297
|
+
problems.append(f"{directory}: not a directory")
|
|
298
|
+
continue
|
|
299
|
+
here: Dict[str, str] = {}
|
|
300
|
+
for name in sorted(os.listdir(directory)):
|
|
301
|
+
if not name.endswith(".json"):
|
|
302
|
+
continue
|
|
303
|
+
path = os.path.join(directory, name)
|
|
304
|
+
try:
|
|
305
|
+
with open(path, encoding="utf-8") as handle:
|
|
306
|
+
decl = json.load(handle)
|
|
307
|
+
except (OSError, ValueError) as exc:
|
|
308
|
+
problems.append(f"{path}: not readable JSON ({exc})")
|
|
309
|
+
continue
|
|
310
|
+
table = decl.get("table") if isinstance(decl, dict) else None
|
|
311
|
+
if not isinstance(table, str):
|
|
312
|
+
problems.append(f"{path}: table: expected a lower-case table name")
|
|
313
|
+
continue
|
|
314
|
+
if table in here:
|
|
315
|
+
problems.append(f"{path}: {table!r} is also declared in {here[table]}")
|
|
316
|
+
continue
|
|
317
|
+
here[table] = path
|
|
318
|
+
found[table] = decl
|
|
319
|
+
sources[table] = path
|
|
320
|
+
for table in sorted(found):
|
|
321
|
+
for problem in check_declaration(found[table], found):
|
|
322
|
+
problems.append(f"{sources[table]}: {problem}")
|
|
323
|
+
if problems:
|
|
324
|
+
raise DeclarationError(problems)
|
|
325
|
+
return {table: copy.deepcopy(found[table]) for table in sorted(found)}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"""Server-side metadata merge: declaration -> database column info -> live
|
|
2
|
+
overrides, plus a hash of the result.
|
|
3
|
+
|
|
4
|
+
Reads only. Column info comes from ``Table.column_details``; overrides from
|
|
5
|
+
``sys_metadata_overrides`` when that table exists (it is never created here:
|
|
6
|
+
reading must not trigger auto-schema).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import copy
|
|
12
|
+
import hashlib
|
|
13
|
+
import json
|
|
14
|
+
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple
|
|
15
|
+
|
|
16
|
+
from velocity.db.core.table import SYSTEM_COLUMN_NAMES
|
|
17
|
+
|
|
18
|
+
OVERRIDES_TABLE = "sys_metadata_overrides"
|
|
19
|
+
|
|
20
|
+
# velocity's own bookkeeping columns: served (read-only, off the grid) beside
|
|
21
|
+
# a declared table's fields; every other undeclared column is not served
|
|
22
|
+
SYSTEM_COLUMNS = frozenset(SYSTEM_COLUMN_NAMES)
|
|
23
|
+
|
|
24
|
+
# The only properties a live override may set. Widget, options, pointer and
|
|
25
|
+
# validation (required, min, max, max_length, read_only) are never
|
|
26
|
+
# overridden: they change what a write may contain, which is a code change.
|
|
27
|
+
OVERRIDABLE = ("label", "help", "placeholder", "grid.show", "grid.order")
|
|
28
|
+
|
|
29
|
+
# a table's columns change only on deploy or a lazy ALTER in this process
|
|
30
|
+
# (which drops the cached entry)
|
|
31
|
+
SCHEMA_CACHE_SECONDS = 300
|
|
32
|
+
# whether the overrides table exists (created by the capability that edits it)
|
|
33
|
+
OVERRIDES_TABLE_CACHE_SECONDS = 60
|
|
34
|
+
|
|
35
|
+
_NUMBER_TYPES = frozenset(
|
|
36
|
+
{
|
|
37
|
+
"smallint",
|
|
38
|
+
"integer",
|
|
39
|
+
"bigint",
|
|
40
|
+
"numeric",
|
|
41
|
+
"decimal",
|
|
42
|
+
"real",
|
|
43
|
+
"double precision",
|
|
44
|
+
"money",
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def default_label(column: str) -> str:
|
|
50
|
+
"""``first_name`` -> ``First Name``."""
|
|
51
|
+
return str(column).replace("_", " ").strip().title()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def default_widget(column_type: Optional[str]) -> str:
|
|
55
|
+
"""The widget for an undeclared column, from its database type."""
|
|
56
|
+
kind = str(column_type or "").strip().lower()
|
|
57
|
+
if kind == "boolean":
|
|
58
|
+
return "CheckboxWidget"
|
|
59
|
+
if kind.startswith("timestamp"):
|
|
60
|
+
return "DateTimeTextWidget"
|
|
61
|
+
if kind in _NUMBER_TYPES:
|
|
62
|
+
return "NumberWidget"
|
|
63
|
+
return "TextWidget"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def column_info(tx, table: str) -> Dict[str, Dict[str, Any]]:
|
|
67
|
+
"""``{column: {"type", "nullable", "max_length"}}`` in ordinal order,
|
|
68
|
+
from the database (``Table.column_details``, cached per process); ``{}``
|
|
69
|
+
for a missing table."""
|
|
70
|
+
details = tx.table(table).column_details(cache_ttl=SCHEMA_CACHE_SECONDS)
|
|
71
|
+
return {
|
|
72
|
+
column["name"]: {
|
|
73
|
+
"type": column["type"],
|
|
74
|
+
"nullable": column["nullable"],
|
|
75
|
+
"max_length": column["max_length"],
|
|
76
|
+
}
|
|
77
|
+
for column in details
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def default_field(column: str, info: Mapping[str, Any]) -> Dict[str, Any]:
|
|
82
|
+
"""The field an undeclared database column is served as. A velocity
|
|
83
|
+
system column (:data:`SYSTEM_COLUMNS`: ``sys_id``, ``sys_modified`` ...)
|
|
84
|
+
is read-only and off the grid by default."""
|
|
85
|
+
field: Dict[str, Any] = {
|
|
86
|
+
"widget": default_widget(info.get("type")),
|
|
87
|
+
"label": default_label(column),
|
|
88
|
+
}
|
|
89
|
+
if column in SYSTEM_COLUMNS:
|
|
90
|
+
field["read_only"] = True
|
|
91
|
+
field["grid"] = {"show": False}
|
|
92
|
+
return field
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def merge_table(
|
|
96
|
+
decl: Optional[Mapping[str, Any]],
|
|
97
|
+
table: str,
|
|
98
|
+
columns: Mapping[str, Mapping[str, Any]],
|
|
99
|
+
hidden: Iterable[str] = (),
|
|
100
|
+
) -> Tuple[Dict[str, Any], List[str]]:
|
|
101
|
+
"""One table merged with its database columns. Returns
|
|
102
|
+
``(merged, warnings)``.
|
|
103
|
+
|
|
104
|
+
A declared table carries its declared fields only: each gains
|
|
105
|
+
``"column": {...}`` when the column exists and a label when it has none;
|
|
106
|
+
of its undeclared columns only velocity's :data:`SYSTEM_COLUMNS` are
|
|
107
|
+
added (read-only). An undeclared table (``decl`` is None) is served
|
|
108
|
+
from every database column except ``hidden``."""
|
|
109
|
+
warnings: List[str] = []
|
|
110
|
+
merged: Dict[str, Any] = copy.deepcopy(dict(decl)) if decl else {"table": table}
|
|
111
|
+
merged["table"] = table
|
|
112
|
+
declared = merged.get("fields") or {}
|
|
113
|
+
fields: Dict[str, Any] = {}
|
|
114
|
+
for column, field in declared.items():
|
|
115
|
+
field = dict(field)
|
|
116
|
+
field.setdefault("label", default_label(column))
|
|
117
|
+
if column in columns:
|
|
118
|
+
field["column"] = dict(columns[column])
|
|
119
|
+
elif columns:
|
|
120
|
+
warnings.append(f"{table}.{column}: declared but not in the database")
|
|
121
|
+
fields[column] = field
|
|
122
|
+
hidden = frozenset(hidden)
|
|
123
|
+
for column, info in columns.items():
|
|
124
|
+
if column in fields:
|
|
125
|
+
continue
|
|
126
|
+
if decl is not None and column not in SYSTEM_COLUMNS:
|
|
127
|
+
continue
|
|
128
|
+
if decl is None and column in hidden:
|
|
129
|
+
continue
|
|
130
|
+
field = default_field(column, info)
|
|
131
|
+
field["column"] = dict(info)
|
|
132
|
+
fields[column] = field
|
|
133
|
+
merged["fields"] = fields
|
|
134
|
+
return merged, warnings
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def overrides_exist(tx) -> bool:
|
|
138
|
+
"""Whether ``sys_metadata_overrides`` exists (a read; never creates it)."""
|
|
139
|
+
return bool(
|
|
140
|
+
tx.table(OVERRIDES_TABLE).exists(cache_ttl=OVERRIDES_TABLE_CACHE_SECONDS)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def read_overrides(tx, tables: Iterable[str]) -> List[Dict[str, Any]]:
|
|
145
|
+
"""The override rows for ``tables``, oldest first (a later row for the
|
|
146
|
+
same property wins); ``[]`` when the overrides table does not exist."""
|
|
147
|
+
names = sorted(set(tables))
|
|
148
|
+
if not names or not overrides_exist(tx):
|
|
149
|
+
return []
|
|
150
|
+
result = tx.table(OVERRIDES_TABLE).select(
|
|
151
|
+
columns=["sys_id", "table_name", "field_name", "property", "value"],
|
|
152
|
+
where={"table_name": names},
|
|
153
|
+
orderby="sys_id",
|
|
154
|
+
)
|
|
155
|
+
return [dict(row) for row in result.all()]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _override_value(prop: str, value: Any):
|
|
159
|
+
"""The typed value for an allow-listed property; raises ``ValueError``."""
|
|
160
|
+
if prop == "grid.show":
|
|
161
|
+
if isinstance(value, bool):
|
|
162
|
+
return value
|
|
163
|
+
text = str(value).strip().lower()
|
|
164
|
+
if text in ("true", "1", "yes", "t"):
|
|
165
|
+
return True
|
|
166
|
+
if text in ("false", "0", "no", "f"):
|
|
167
|
+
return False
|
|
168
|
+
raise ValueError("expected true or false")
|
|
169
|
+
if prop == "grid.order":
|
|
170
|
+
if isinstance(value, bool):
|
|
171
|
+
raise ValueError("expected a whole number")
|
|
172
|
+
try:
|
|
173
|
+
number = int(str(value).strip())
|
|
174
|
+
except (TypeError, ValueError):
|
|
175
|
+
raise ValueError("expected a whole number") from None
|
|
176
|
+
return number
|
|
177
|
+
if value is None or not isinstance(value, str):
|
|
178
|
+
raise ValueError("expected text")
|
|
179
|
+
return value
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def apply_overrides(
|
|
183
|
+
metadata: Dict[str, Dict[str, Any]], rows: Iterable[Mapping[str, Any]]
|
|
184
|
+
) -> List[str]:
|
|
185
|
+
"""Apply override rows to merged ``metadata`` in place. Only
|
|
186
|
+
:data:`OVERRIDABLE` properties of an existing field are applied; every
|
|
187
|
+
other row is skipped and named in the returned warnings."""
|
|
188
|
+
warnings: List[str] = []
|
|
189
|
+
for row in rows:
|
|
190
|
+
table = row.get("table_name")
|
|
191
|
+
column = row.get("field_name")
|
|
192
|
+
prop = str(row.get("property") or "").strip()
|
|
193
|
+
where = f"{OVERRIDES_TABLE} row {row.get('sys_id')} ({table}.{column} {prop})"
|
|
194
|
+
if prop not in OVERRIDABLE:
|
|
195
|
+
warnings.append(f"{where}: {prop!r} cannot be overridden; ignored")
|
|
196
|
+
continue
|
|
197
|
+
field = (metadata.get(table) or {}).get("fields", {}).get(column)
|
|
198
|
+
if field is None:
|
|
199
|
+
warnings.append(f"{where}: no such field; ignored")
|
|
200
|
+
continue
|
|
201
|
+
try:
|
|
202
|
+
value = _override_value(prop, row.get("value"))
|
|
203
|
+
except ValueError as exc:
|
|
204
|
+
warnings.append(f"{where}: {exc}; ignored")
|
|
205
|
+
continue
|
|
206
|
+
if prop.startswith("grid."):
|
|
207
|
+
grid = field.get("grid")
|
|
208
|
+
grid = dict(grid) if isinstance(grid, dict) else {}
|
|
209
|
+
grid[prop.split(".", 1)[1]] = value
|
|
210
|
+
field["grid"] = grid
|
|
211
|
+
else:
|
|
212
|
+
field[prop] = value
|
|
213
|
+
return warnings
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def metadata_hash(metadata: Mapping[str, Any]) -> str:
|
|
217
|
+
"""sha256 of the canonical JSON of ``metadata`` (sorted keys, compact)."""
|
|
218
|
+
canonical = json.dumps(
|
|
219
|
+
metadata, sort_keys=True, separators=(",", ":"), ensure_ascii=False, default=str
|
|
220
|
+
)
|
|
221
|
+
return hashlib.sha256(canonical.encode("utf-8")).hexdigest()
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def build_metadata(
|
|
225
|
+
tx,
|
|
226
|
+
declarations: Mapping[str, Mapping[str, Any]],
|
|
227
|
+
tables: Optional[Iterable[str]] = None,
|
|
228
|
+
hidden_columns: Optional[Mapping[str, Iterable[str]]] = None,
|
|
229
|
+
) -> Dict[str, Any]:
|
|
230
|
+
"""``{"metadata": {table: merged}, "hash": str, "warnings": [str]}``.
|
|
231
|
+
|
|
232
|
+
``tables`` (default: every declared table) chooses what is built; a
|
|
233
|
+
requested table with no declaration is served from its database columns
|
|
234
|
+
alone (less ``hidden_columns[table]``), and one that is neither declared
|
|
235
|
+
nor in the database is left out. A declared table carries only its
|
|
236
|
+
declared fields plus velocity's system columns.
|
|
237
|
+
Deterministic: the same declarations, schema and overrides give the same
|
|
238
|
+
hash (tables in name order; the hash covers ``metadata`` only)."""
|
|
239
|
+
names = sorted(set(declarations if tables is None else tables))
|
|
240
|
+
metadata: Dict[str, Dict[str, Any]] = {}
|
|
241
|
+
warnings: List[str] = []
|
|
242
|
+
for table in names:
|
|
243
|
+
decl = declarations.get(table)
|
|
244
|
+
columns = column_info(tx, table)
|
|
245
|
+
if decl is None and not columns:
|
|
246
|
+
continue
|
|
247
|
+
hidden = (hidden_columns or {}).get(table, ())
|
|
248
|
+
merged, notes = merge_table(decl, table, columns, hidden)
|
|
249
|
+
metadata[table] = merged
|
|
250
|
+
warnings.extend(notes)
|
|
251
|
+
warnings.extend(apply_overrides(metadata, read_overrides(tx, metadata)))
|
|
252
|
+
return {"metadata": metadata, "hash": metadata_hash(metadata), "warnings": warnings}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Write validation from a table declaration (for a site's write hooks).
|
|
2
|
+
|
|
3
|
+
:func:`validate_row` checks a row against the declared rules (options,
|
|
4
|
+
required, min/max, max_length) and lists what is wrong. It is not wired into
|
|
5
|
+
DataService writes; a hook calls it and raises as the site chooses.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import decimal
|
|
11
|
+
import numbers
|
|
12
|
+
from typing import Any, List, Mapping
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _blank(value) -> bool:
|
|
16
|
+
return value is None or (isinstance(value, str) and not value.strip())
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _as_number(value):
|
|
20
|
+
if isinstance(value, bool):
|
|
21
|
+
raise ValueError
|
|
22
|
+
if isinstance(value, numbers.Real) or isinstance(value, decimal.Decimal):
|
|
23
|
+
return value
|
|
24
|
+
if isinstance(value, str):
|
|
25
|
+
try:
|
|
26
|
+
return decimal.Decimal(value.strip())
|
|
27
|
+
except decimal.InvalidOperation:
|
|
28
|
+
raise ValueError from None
|
|
29
|
+
raise ValueError
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _matches(value, allowed) -> bool:
|
|
33
|
+
if value == allowed and type(value) is not bool and type(allowed) is not bool:
|
|
34
|
+
return True
|
|
35
|
+
if isinstance(value, bool) or isinstance(allowed, bool):
|
|
36
|
+
return value is allowed or str(value).lower() == str(allowed).lower()
|
|
37
|
+
# a form posts "3" for an option whose value is 3
|
|
38
|
+
return str(value) == str(allowed)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def validate_row(
|
|
42
|
+
decl: Mapping[str, Any], row: Mapping[str, Any], *, partial: bool = False
|
|
43
|
+
) -> List[str]:
|
|
44
|
+
"""What is wrong with ``row`` under ``decl``'s field rules, ``[]`` when
|
|
45
|
+
nothing is. ``partial=True`` (an update carrying only changed columns)
|
|
46
|
+
skips the required check for columns the row does not carry; a column it
|
|
47
|
+
does carry is always checked. Blank values (``None``, ``""``) are only a
|
|
48
|
+
problem for a required field."""
|
|
49
|
+
problems: List[str] = []
|
|
50
|
+
fields = decl.get("fields") or {}
|
|
51
|
+
for column, field in fields.items():
|
|
52
|
+
if not isinstance(field, Mapping):
|
|
53
|
+
continue
|
|
54
|
+
label = field.get("label") or column.replace("_", " ").title()
|
|
55
|
+
present = column in row
|
|
56
|
+
value = row.get(column)
|
|
57
|
+
if _blank(value):
|
|
58
|
+
if field.get("required") and (present or not partial):
|
|
59
|
+
problems.append(f"{label} is required.")
|
|
60
|
+
continue
|
|
61
|
+
options = field.get("options")
|
|
62
|
+
if isinstance(options, list) and options:
|
|
63
|
+
allowed = [o.get("value") for o in options if isinstance(o, Mapping)]
|
|
64
|
+
if not any(_matches(value, a) for a in allowed):
|
|
65
|
+
problems.append(f"{label}: {value!r} is not one of the allowed values.")
|
|
66
|
+
if "min" in field or "max" in field:
|
|
67
|
+
try:
|
|
68
|
+
number = _as_number(value)
|
|
69
|
+
except ValueError:
|
|
70
|
+
problems.append(f"{label} must be a number.")
|
|
71
|
+
else:
|
|
72
|
+
low, high = field.get("min"), field.get("max")
|
|
73
|
+
if low is not None and number < decimal.Decimal(str(low)):
|
|
74
|
+
problems.append(f"{label} must be at least {low}.")
|
|
75
|
+
if high is not None and number > decimal.Decimal(str(high)):
|
|
76
|
+
problems.append(f"{label} must be at most {high}.")
|
|
77
|
+
limit = field.get("max_length")
|
|
78
|
+
if isinstance(limit, int) and not isinstance(limit, bool):
|
|
79
|
+
if len(str(value)) > limit:
|
|
80
|
+
problems.append(f"{label} must be at most {limit} characters.")
|
|
81
|
+
return problems
|
velocity/testing/fake_db.py
CHANGED
|
@@ -193,6 +193,7 @@ TABLE_SPECS: Dict[str, Dict[str, Any]] = {
|
|
|
193
193
|
VAR_KEYWORD: {"sql_only": REJECT},
|
|
194
194
|
},
|
|
195
195
|
"sys_columns": {VAR_KEYWORD: {"cache_ttl": IGNORE}},
|
|
196
|
+
"column_details": {VAR_KEYWORD: {"cache_ttl": IGNORE, "sql_only": REJECT}},
|
|
196
197
|
"json_columns": {},
|
|
197
198
|
}
|
|
198
199
|
|
|
@@ -358,7 +359,7 @@ _NEGATED_PATTERN = {"NOT LIKE", "NOT ILIKE", "!~", "!~*"}
|
|
|
358
359
|
_GROUP_KEYS = {"@@or", "@@and"}
|
|
359
360
|
_DEFAULT = object() # the "@@DEFAULT" token: leave the column out of an INSERT
|
|
360
361
|
# Calls that touch no rows (handles and metadata) stay out of FakeTx.calls.
|
|
361
|
-
_UNRECORDED = frozenset({"table", "json_columns", "sys_columns"})
|
|
362
|
+
_UNRECORDED = frozenset({"table", "json_columns", "sys_columns", "column_details"})
|
|
362
363
|
|
|
363
364
|
|
|
364
365
|
def _token_value(sql, now):
|
|
@@ -1045,7 +1046,7 @@ class FakeTable:
|
|
|
1045
1046
|
return self.first(a["where"] or {}, orderby="sys_modified ASC, sys_id ASC")
|
|
1046
1047
|
|
|
1047
1048
|
def _impl_exists(self, a):
|
|
1048
|
-
return self.name in self.tx.rows
|
|
1049
|
+
return self.name in self.tx.rows or self.name in self.tx.columns
|
|
1049
1050
|
|
|
1050
1051
|
def _impl_insert(self, a):
|
|
1051
1052
|
self._do_insert(a["data"])
|
|
@@ -1242,7 +1243,9 @@ class FakeTable:
|
|
|
1242
1243
|
return self.update(payload, where=a["where"])
|
|
1243
1244
|
|
|
1244
1245
|
def _impl_sys_columns(self, a):
|
|
1245
|
-
names
|
|
1246
|
+
# a seeded schema (FakeTx(columns=...)) names the table's columns, as
|
|
1247
|
+
# the database would, even before any row is stored
|
|
1248
|
+
names = [c["name"] for c in self.tx.columns.get(self.name) or []]
|
|
1246
1249
|
for row in self._stored():
|
|
1247
1250
|
for key in row:
|
|
1248
1251
|
if key not in names:
|
|
@@ -1252,6 +1255,33 @@ class FakeTable:
|
|
|
1252
1255
|
def _impl_json_columns(self, a):
|
|
1253
1256
|
return frozenset()
|
|
1254
1257
|
|
|
1258
|
+
def _impl_column_details(self, a):
|
|
1259
|
+
"""The table's seeded schema (``FakeTx(columns=...)``), copied; ``[]``
|
|
1260
|
+
for a table that neither has rows nor a seeded schema (a missing
|
|
1261
|
+
table, as information_schema answers). A table with rows but no
|
|
1262
|
+
seeded schema raises: the fake will not invent column types."""
|
|
1263
|
+
seeded = self.tx.columns.get(self.name)
|
|
1264
|
+
if seeded is None:
|
|
1265
|
+
if self.name in self.tx.rows:
|
|
1266
|
+
raise FakeUnsupported(
|
|
1267
|
+
f"Table.column_details() on {self.name!r} needs its schema: "
|
|
1268
|
+
"FakeTx(columns={table: [{name, type, nullable, max_length}]})"
|
|
1269
|
+
)
|
|
1270
|
+
return []
|
|
1271
|
+
out = []
|
|
1272
|
+
for column in seeded:
|
|
1273
|
+
if isinstance(column, str):
|
|
1274
|
+
column = {"name": column}
|
|
1275
|
+
out.append(
|
|
1276
|
+
{
|
|
1277
|
+
"name": column["name"],
|
|
1278
|
+
"type": column.get("type", "text"),
|
|
1279
|
+
"nullable": bool(column.get("nullable", True)),
|
|
1280
|
+
"max_length": column.get("max_length"),
|
|
1281
|
+
}
|
|
1282
|
+
)
|
|
1283
|
+
return out
|
|
1284
|
+
|
|
1255
1285
|
|
|
1256
1286
|
class FakeTx:
|
|
1257
1287
|
"""In-memory stand-in for :class:`velocity.db.core.transaction.Transaction`.
|
|
@@ -1264,6 +1294,10 @@ class FakeTx:
|
|
|
1264
1294
|
row dicts, an ``int`` rowcount, a ``Result`` or ``None`` (no rows).
|
|
1265
1295
|
Without a handler, ``tx.execute`` raises :class:`FakeUnsupported`.
|
|
1266
1296
|
|
|
1297
|
+
``columns`` seeds what ``Table.column_details`` reports:
|
|
1298
|
+
``{"people": [{"name": "email", "type": "text", "nullable": False,
|
|
1299
|
+
"max_length": 80}, ...]}`` (a bare column name means nullable ``text``).
|
|
1300
|
+
|
|
1267
1301
|
``now`` is the clock used for ``@@CURRENT_TIMESTAMP`` & co. and ``claim``.
|
|
1268
1302
|
``sys_id_floor``: a new row's ``sys_id`` is one above the larger of this
|
|
1269
1303
|
and the table's highest ``sys_id``.
|
|
@@ -1281,11 +1315,16 @@ class FakeTx:
|
|
|
1281
1315
|
execute: Optional[Callable[[str, Any], Any]] = None,
|
|
1282
1316
|
now: Optional[Callable[[], datetime.datetime]] = None,
|
|
1283
1317
|
sys_id_floor: int = 1000,
|
|
1318
|
+
columns: Optional[Mapping[str, Any]] = None,
|
|
1284
1319
|
):
|
|
1285
1320
|
self.rows: Dict[str, List[dict]] = {
|
|
1286
1321
|
str(name).lower(): [dict(_snapshot(r)) for r in table_rows]
|
|
1287
1322
|
for name, table_rows in (rows or {}).items()
|
|
1288
1323
|
}
|
|
1324
|
+
self.columns: Dict[str, List[Any]] = {
|
|
1325
|
+
str(name).lower(): list(_snapshot(cols))
|
|
1326
|
+
for name, cols in (columns or {}).items()
|
|
1327
|
+
}
|
|
1289
1328
|
self.execute_handler = execute
|
|
1290
1329
|
self.now = now or _utcnow
|
|
1291
1330
|
self.sys_id_floor = sys_id_floor
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
velocity/__init__.py,sha256=
|
|
1
|
+
velocity/__init__.py,sha256=kTCmpCw1w9AUZdrpHaN5IHMp0fERI3q6A0cqV7E5bho,362
|
|
2
2
|
velocity/cache.py,sha256=pthvw7gDVEXRzkTcQtA5YVf4Q1IxAamWsba4UReT0RE,8933
|
|
3
3
|
velocity/hooks.py,sha256=jY_qtAapNHvptmryFSD-Zc7RvLhV6e5nJEH3x2xTgCw,20575
|
|
4
4
|
velocity/logging.py,sha256=MAsZap1cDSdOBNRc_9ezQxup5dHOS0ARxU9NI_-UK3E,4037
|
|
@@ -61,15 +61,15 @@ velocity/aws/handlers/masquerade.py,sha256=ZMXGGB-w7pXRV8Fq0qBmJOL1Eq55hXP3Rq3dW
|
|
|
61
61
|
velocity/aws/handlers/perf.py,sha256=zLAcr_IrvpnZS1zzzXi-YhopRgCv3OeetQgOx_S43Xw,1421
|
|
62
62
|
velocity/aws/handlers/response.py,sha256=Xi5mzBPiYC-VVS3qFyCgfuV3YyuGuhS1O54QGI7jGHs,17201
|
|
63
63
|
velocity/aws/handlers/sqs_handler.py,sha256=1A7pHnZ-gl6AGcdK5hWvNUg-s8IjRhrBeiQLacHHhHk,9669
|
|
64
|
-
velocity/aws/handlers/mixins/__init__.py,sha256=
|
|
64
|
+
velocity/aws/handlers/mixins/__init__.py,sha256=I64njGcpdcDzuZKpPoeEjpwzGguhcD6nGftYKKulAlY,2820
|
|
65
65
|
velocity/aws/handlers/mixins/action_names.py,sha256=6RYAdromGcDD9Fv6tYKAtgzLhKx8gf5oG-7K67roWqI,1112
|
|
66
66
|
velocity/aws/handlers/mixins/audit_trail.py,sha256=CxZ_3IgbxZ3Ev2pSvwLeVPxlsVqUjazr87QsBqOuHHs,27421
|
|
67
67
|
velocity/aws/handlers/mixins/client_errors.py,sha256=0LqIRm1gZRwzHH32ravGHAgcQqJzjh5p6M_ptuL2Tto,20105
|
|
68
68
|
velocity/aws/handlers/mixins/client_input.py,sha256=UhfwsRiztOYDrJnQPZhQ6J71NAmCyrXjMgxbko2rnfQ,24225
|
|
69
|
-
velocity/aws/handlers/mixins/data_service.py,sha256=
|
|
69
|
+
velocity/aws/handlers/mixins/data_service.py,sha256=PQ34UjiTBmMkLjfnyrIic1pQ51hy3EdYj0dYpX4EO94,132893
|
|
70
70
|
velocity/aws/handlers/mixins/job_handler.py,sha256=RvMtoMiZiivoxSVp-egQUQSpr6xZCDfeaYxzonIPLyw,7509
|
|
71
71
|
velocity/aws/handlers/mixins/permissions_actions.py,sha256=KjWKu4in0OvczEqO4JpVkmBPL_C0I1qOAraBeW21XvI,32409
|
|
72
|
-
velocity/aws/handlers/mixins/row_scoped.py,sha256=
|
|
72
|
+
velocity/aws/handlers/mixins/row_scoped.py,sha256=ko5CUqgY-_MpyxZSchUx0cOgGHwCELPbcC93k-8ZcZg,13565
|
|
73
73
|
velocity/aws/handlers/mixins/session_control.py,sha256=w2wGC_XiM-W-tL5mhZvVCt_GiQjE3Gao0Ut7tx6JdLk,12937
|
|
74
74
|
velocity/aws/handlers/mixins/tiles_actions.py,sha256=n9m_PuyjPoBulqPpkSBxvMJgTdD0BXWQ3_vXf3jcUBY,28349
|
|
75
75
|
velocity/aws/handlers/mixins/web_handler.py,sha256=NYYdtNbMQyVkDEJVntEzrPVx6DYQ1E_lJaz7hn1Vj04,37044
|
|
@@ -106,7 +106,7 @@ velocity/db/core/lazy_engine.py,sha256=yFJFN0WIrEQhZh-tSMeWWBOTvi6pyYiMNHQP32MFZ
|
|
|
106
106
|
velocity/db/core/result.py,sha256=Ij0YtKKiUjX2mfG0Kkz8VA0n-X08xyz-vGyYjHoCDwY,15822
|
|
107
107
|
velocity/db/core/row.py,sha256=A2U5cRW03wFOf15jDr_LUCJe0pNW6RYddG-PK3vYqX4,18777
|
|
108
108
|
velocity/db/core/sequence.py,sha256=dap4Ip0m3htgWV9eCF6ajt-SImnPJJGb8pb8kZVVY4Y,4064
|
|
109
|
-
velocity/db/core/table.py,sha256=
|
|
109
|
+
velocity/db/core/table.py,sha256=K-B0yVx7OZL6ObTlg602q94gzkoLyYjWYTM2jIFuPmU,128056
|
|
110
110
|
velocity/db/core/transaction.py,sha256=GSVuhqzrLXtdqWojn5b9X92M9ERm-lbvCntKzlmXbsc,56245
|
|
111
111
|
velocity/db/core/view.py,sha256=lrT1V-NlRioCSfk5pmdXGdCEafdP-t1Pl_EalIrX_cc,5286
|
|
112
112
|
velocity/db/servers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -124,7 +124,7 @@ velocity/db/servers/mysql/types.py,sha256=_4Fq0CQ9alOtt2JMZHyWJ7-uAsmFObEx9oRiW-
|
|
|
124
124
|
velocity/db/servers/postgres/__init__.py,sha256=AuXBcg1Pjd4nSF4NivVvEi14pBlyUkHCDORTWXTW8l0,8442
|
|
125
125
|
velocity/db/servers/postgres/operators.py,sha256=y9k6enReeR5hJxU_lYYR2epoaw4qCxEqmYJJ5jjaVWA,1166
|
|
126
126
|
velocity/db/servers/postgres/reserved.py,sha256=5tKLaqFV-HrWRj-nsrxl5KGbmeM3ukn_bPZK36XEu8M,3648
|
|
127
|
-
velocity/db/servers/postgres/sql.py,sha256=
|
|
127
|
+
velocity/db/servers/postgres/sql.py,sha256=XRSkN8G9ZOEj5Sa9SD9He86lNh_USavZznEEe5-0Ta4,92502
|
|
128
128
|
velocity/db/servers/postgres/types.py,sha256=0c1liFhJas6EL-CcFfgf9cwLbFu55R05t7GmEzaXg0Q,9901
|
|
129
129
|
velocity/db/servers/sqlite/__init__.py,sha256=Kf456zvJ9iffTAxCqxkKrSSnQkOpXxIuzfiiQcVFSbY,2333
|
|
130
130
|
velocity/db/servers/sqlite/operators.py,sha256=ItDbTrTozpSG_QAt0zwZDf6p1GItPafcL1RNxGBVJqI,1220
|
|
@@ -175,6 +175,10 @@ velocity/db/tests/sql/__init__.py,sha256=evafiIjAB0jyhqZ8HfiPgRujXJkRpQ7a34Bjac4
|
|
|
175
175
|
velocity/db/tests/sql/common.py,sha256=8EGdw9SRj-EywKnzUTVnoHw_C3GWwttFyecWOFxIv_I,5810
|
|
176
176
|
velocity/db/tests/sql/test_postgres_select_advanced.py,sha256=xODItdjxYBg1kdpmiEqzrqX4a5H8tS40kz4sX3yLza8,8360
|
|
177
177
|
velocity/db/tests/sql/test_postgres_select_variances.py,sha256=F3d6TleZVtYnWndvEqeamvn5BteILyHfUAlUegiZMvA,17611
|
|
178
|
+
velocity/metadata/__init__.py,sha256=vzLP9RvdTGCPW3Tzj_n2V5qvBfJyx4DbqSl8__i4huM,1272
|
|
179
|
+
velocity/metadata/declarations.py,sha256=__Ux7hwy3fu2ySLNT9z7K0CJx08-l7nf-SK9o5zAqgU,13009
|
|
180
|
+
velocity/metadata/merge.py,sha256=asV1fpR8_46ol6s-EAOsWxYcZe5Ot1enlO_UFu2MUjk,9505
|
|
181
|
+
velocity/metadata/validate.py,sha256=EgIF_7GQ-sSCGdruq-8QPaLK-JlEwoHkhZGqahHnucE,3330
|
|
178
182
|
velocity/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
179
183
|
velocity/misc/db.py,sha256=MPgt-kkukKR_Wh_S_5W-MyDgaeoZ4YLoDJ54wU2ppm4,2830
|
|
180
184
|
velocity/misc/export.py,sha256=DbrhNFH3MQPA6DC222KSRhjwqQYrGnGYOtiz7zCfEac,24692
|
|
@@ -239,7 +243,7 @@ velocity/rules/expressions.py,sha256=IqCL0jsXBkTVpCBlX4zR3D0r5VsFj3gyn4wQjICTTxI
|
|
|
239
243
|
velocity/rules/facts.py,sha256=07GuPDW7sB81jihObfwC29eDrGJ-NRVEskWMo9gl1ME,11619
|
|
240
244
|
velocity/rules/storage.py,sha256=dCWhN6g5_kQCTWy66CgpyNmIwrTY1VsVsMPXKoaiO6U,13054
|
|
241
245
|
velocity/testing/__init__.py,sha256=WtYMDHgCLxOq6mlemcOYV5Y9HqF_2QQgSfuAjFRg69Q,731
|
|
242
|
-
velocity/testing/fake_db.py,sha256=
|
|
246
|
+
velocity/testing/fake_db.py,sha256=AGXbrcEKIOyDiXVH0mjTqPvrMHv6IJW78i8PKe2mPuE,55124
|
|
243
247
|
velocity/workflow/__init__.py,sha256=Z32UX9tOLIrUFcqkDztiZIEHZW7UEg_x_K6nMu5d9rc,4501
|
|
244
248
|
velocity/workflow/access.py,sha256=lYueYjX3WD8WZUPO7ldmiKGauze9YgzbK0tKKX5vTgk,33014
|
|
245
249
|
velocity/workflow/contract.py,sha256=VtitgsoHCUmeSehce0jyjcogk07cKm0ydC2o3Gu49Og,40365
|
|
@@ -254,9 +258,9 @@ velocity/workflow/points.py,sha256=g_vQ3cdHdx_JloVCS5dVjo_jJoSolO92K5p3suDzxlE,1
|
|
|
254
258
|
velocity/workflow/schema.py,sha256=1ZAkGZ_4YrTAfY6TIPCviWQJGLhhmAJmkxisfLyy2og,21597
|
|
255
259
|
velocity/workflow/traveler.py,sha256=Ik1InoEo69sZB1wVV-UinVo4P0P5QlcV_hh858p3OWE,20562
|
|
256
260
|
velocity/workflow/views.py,sha256=oTPjpuheND8y4VbcTY8c-4fMdSHKb0jgGzXMuT_G7_s,32175
|
|
257
|
-
velocity_python-0.9.
|
|
258
|
-
velocity_python-0.9.
|
|
259
|
-
velocity_python-0.9.
|
|
260
|
-
velocity_python-0.9.
|
|
261
|
-
velocity_python-0.9.
|
|
262
|
-
velocity_python-0.9.
|
|
261
|
+
velocity_python-0.9.7.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
262
|
+
velocity_python-0.9.7.dist-info/METADATA,sha256=5u_tu_AiOlo9AhP7VATvnW_A_SZqMsA2N8-ozFbftsI,17789
|
|
263
|
+
velocity_python-0.9.7.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
264
|
+
velocity_python-0.9.7.dist-info/entry_points.txt,sha256=nXUKJHkOGQCSPoagdmMNd_qycrle1LVU-GhYknLGM1M,56
|
|
265
|
+
velocity_python-0.9.7.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
266
|
+
velocity_python-0.9.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|