dzql 0.5.33 → 0.6.1

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 (142) hide show
  1. package/.env.sample +28 -0
  2. package/compose.yml +28 -0
  3. package/dist/client/index.ts +1 -0
  4. package/dist/client/stores/useMyProfileStore.ts +114 -0
  5. package/dist/client/stores/useOrgDashboardStore.ts +131 -0
  6. package/dist/client/stores/useVenueDetailStore.ts +117 -0
  7. package/dist/client/ws.ts +716 -0
  8. package/dist/db/migrations/000_core.sql +92 -0
  9. package/dist/db/migrations/20251229T212912022Z_schema.sql +3020 -0
  10. package/dist/db/migrations/20251229T212912022Z_subscribables.sql +371 -0
  11. package/dist/runtime/manifest.json +1562 -0
  12. package/docs/README.md +309 -36
  13. package/docs/feature-requests/applyPatch-bug-report.md +85 -0
  14. package/docs/feature-requests/connection-ready-profile.md +57 -0
  15. package/docs/feature-requests/hidden-bug-report.md +111 -0
  16. package/docs/feature-requests/hidden-fields-subscribables.md +34 -0
  17. package/docs/feature-requests/subscribable-param-key-bug.md +38 -0
  18. package/docs/feature-requests/todo.md +146 -0
  19. package/docs/for_ai.md +653 -0
  20. package/docs/project-setup.md +456 -0
  21. package/examples/blog.ts +50 -0
  22. package/examples/invalid.ts +18 -0
  23. package/examples/venues.js +485 -0
  24. package/package.json +23 -60
  25. package/src/cli/codegen/client.ts +99 -0
  26. package/src/cli/codegen/manifest.ts +95 -0
  27. package/src/cli/codegen/pinia.ts +174 -0
  28. package/src/cli/codegen/realtime.ts +58 -0
  29. package/src/cli/codegen/sql.ts +698 -0
  30. package/src/cli/codegen/subscribable_sql.ts +547 -0
  31. package/src/cli/codegen/subscribable_store.ts +184 -0
  32. package/src/cli/codegen/types.ts +142 -0
  33. package/src/cli/compiler/analyzer.ts +52 -0
  34. package/src/cli/compiler/graph_rules.ts +251 -0
  35. package/src/cli/compiler/ir.ts +233 -0
  36. package/src/cli/compiler/loader.ts +132 -0
  37. package/src/cli/compiler/permissions.ts +227 -0
  38. package/src/cli/index.ts +166 -0
  39. package/src/client/index.ts +1 -0
  40. package/src/client/ws.ts +286 -0
  41. package/src/runtime/auth.ts +39 -0
  42. package/src/runtime/db.ts +33 -0
  43. package/src/runtime/errors.ts +51 -0
  44. package/src/runtime/index.ts +98 -0
  45. package/src/runtime/js_functions.ts +63 -0
  46. package/src/runtime/manifest_loader.ts +29 -0
  47. package/src/runtime/namespace.ts +483 -0
  48. package/src/runtime/server.ts +87 -0
  49. package/src/runtime/ws.ts +197 -0
  50. package/src/shared/ir.ts +197 -0
  51. package/tests/client.test.ts +38 -0
  52. package/tests/codegen.test.ts +71 -0
  53. package/tests/compiler.test.ts +45 -0
  54. package/tests/graph_rules.test.ts +173 -0
  55. package/tests/integration/db.test.ts +174 -0
  56. package/tests/integration/e2e.test.ts +65 -0
  57. package/tests/integration/features.test.ts +922 -0
  58. package/tests/integration/full_stack.test.ts +262 -0
  59. package/tests/integration/setup.ts +45 -0
  60. package/tests/ir.test.ts +32 -0
  61. package/tests/namespace.test.ts +395 -0
  62. package/tests/permissions.test.ts +55 -0
  63. package/tests/pinia.test.ts +48 -0
  64. package/tests/realtime.test.ts +22 -0
  65. package/tests/runtime.test.ts +80 -0
  66. package/tests/subscribable_gen.test.ts +72 -0
  67. package/tests/subscribable_reactivity.test.ts +258 -0
  68. package/tests/venues_gen.test.ts +25 -0
  69. package/tsconfig.json +20 -0
  70. package/tsconfig.tsbuildinfo +1 -0
  71. package/README.md +0 -90
  72. package/bin/cli.js +0 -727
  73. package/docs/compiler/ADVANCED_FILTERS.md +0 -183
  74. package/docs/compiler/CODING_STANDARDS.md +0 -415
  75. package/docs/compiler/COMPARISON.md +0 -673
  76. package/docs/compiler/QUICKSTART.md +0 -326
  77. package/docs/compiler/README.md +0 -134
  78. package/docs/examples/README.md +0 -38
  79. package/docs/examples/blog.sql +0 -160
  80. package/docs/examples/venue-detail-simple.sql +0 -8
  81. package/docs/examples/venue-detail-subscribable.sql +0 -45
  82. package/docs/for-ai/claude-guide.md +0 -1210
  83. package/docs/getting-started/quickstart.md +0 -125
  84. package/docs/getting-started/subscriptions-quick-start.md +0 -203
  85. package/docs/getting-started/tutorial.md +0 -1104
  86. package/docs/guides/atomic-updates.md +0 -299
  87. package/docs/guides/client-stores.md +0 -730
  88. package/docs/guides/composite-primary-keys.md +0 -158
  89. package/docs/guides/custom-functions.md +0 -362
  90. package/docs/guides/drop-semantics.md +0 -554
  91. package/docs/guides/field-defaults.md +0 -240
  92. package/docs/guides/interpreter-vs-compiler.md +0 -237
  93. package/docs/guides/many-to-many.md +0 -929
  94. package/docs/guides/subscriptions.md +0 -537
  95. package/docs/reference/api.md +0 -1373
  96. package/docs/reference/client.md +0 -224
  97. package/src/client/stores/index.js +0 -8
  98. package/src/client/stores/useAppStore.js +0 -285
  99. package/src/client/stores/useWsStore.js +0 -289
  100. package/src/client/ws.js +0 -762
  101. package/src/compiler/cli/compile-example.js +0 -33
  102. package/src/compiler/cli/compile-subscribable.js +0 -43
  103. package/src/compiler/cli/debug-compile.js +0 -44
  104. package/src/compiler/cli/debug-parse.js +0 -26
  105. package/src/compiler/cli/debug-path-parser.js +0 -18
  106. package/src/compiler/cli/debug-subscribable-parser.js +0 -21
  107. package/src/compiler/cli/index.js +0 -174
  108. package/src/compiler/codegen/auth-codegen.js +0 -153
  109. package/src/compiler/codegen/drop-semantics-codegen.js +0 -553
  110. package/src/compiler/codegen/graph-rules-codegen.js +0 -450
  111. package/src/compiler/codegen/notification-codegen.js +0 -232
  112. package/src/compiler/codegen/operation-codegen.js +0 -1382
  113. package/src/compiler/codegen/permission-codegen.js +0 -318
  114. package/src/compiler/codegen/subscribable-codegen.js +0 -827
  115. package/src/compiler/compiler.js +0 -371
  116. package/src/compiler/index.js +0 -11
  117. package/src/compiler/parser/entity-parser.js +0 -440
  118. package/src/compiler/parser/path-parser.js +0 -290
  119. package/src/compiler/parser/subscribable-parser.js +0 -244
  120. package/src/database/dzql-core.sql +0 -161
  121. package/src/database/migrations/001_schema.sql +0 -60
  122. package/src/database/migrations/002_functions.sql +0 -890
  123. package/src/database/migrations/003_operations.sql +0 -1135
  124. package/src/database/migrations/004_search.sql +0 -581
  125. package/src/database/migrations/005_entities.sql +0 -730
  126. package/src/database/migrations/006_auth.sql +0 -94
  127. package/src/database/migrations/007_events.sql +0 -133
  128. package/src/database/migrations/008_hello.sql +0 -18
  129. package/src/database/migrations/008a_meta.sql +0 -172
  130. package/src/database/migrations/009_subscriptions.sql +0 -240
  131. package/src/database/migrations/010_atomic_updates.sql +0 -157
  132. package/src/database/migrations/010_fix_m2m_events.sql +0 -94
  133. package/src/index.js +0 -40
  134. package/src/server/api.js +0 -9
  135. package/src/server/db.js +0 -442
  136. package/src/server/index.js +0 -317
  137. package/src/server/logger.js +0 -259
  138. package/src/server/mcp.js +0 -594
  139. package/src/server/meta-route.js +0 -251
  140. package/src/server/namespace.js +0 -292
  141. package/src/server/subscriptions.js +0 -351
  142. package/src/server/ws.js +0 -573
@@ -0,0 +1,146 @@
1
+ # TZQL v2 Gap Analysis TODO
2
+
3
+ Gap analysis comparing v1 tests to v2 functionality. Updated 2024-12-17.
4
+
5
+ ---
6
+
7
+ ## High Priority - COMPLETED
8
+
9
+ ### Soft Delete ✅
10
+ - [x] Add `softDelete` handling to `generateDeleteFunction()` in `src/cli/codegen/sql.ts`
11
+ - Sets `deleted_at = now()` instead of `DELETE FROM` when entity has `softDelete: true`
12
+ - [x] Add `deleted_at IS NULL` filter to `generateSearchFunction()`
13
+ - [x] GET still retrieves deleted records (for audit purposes)
14
+ - [x] Add soft delete integration tests (3 tests)
15
+ - Reference: `tests/integration/features.test.ts` - "Soft Delete" describe block
16
+
17
+ ### Field Defaults ✅
18
+ - [x] Add `fieldDefaults` handling to `generateSaveFunction()` INSERT branch in `src/cli/codegen/sql.ts`
19
+ - `@user_id` → `p_user_id`
20
+ - `@now` → `now()`
21
+ - `@today` → `current_date`
22
+ - Literal values → insert as-is
23
+ - [x] Only apply defaults on INSERT, not UPDATE (uses COALESCE)
24
+ - [x] Add field defaults integration tests (4 tests)
25
+ - Reference: `tests/integration/features.test.ts` - "Field Defaults" describe block
26
+
27
+ ### Composite Primary Key Support ✅
28
+ - [x] Update `generateSaveFunction()` to handle multi-column PKs
29
+ - Dynamic PK null check and EXISTS query
30
+ - WHERE clause supports all PK fields
31
+ - [x] Update `generateDeleteFunction()` for composite PKs
32
+ - [x] Update `generateGetFunction()` for composite PKs
33
+ - [x] Events store composite PK as JSONB object
34
+ - [x] Proper type casting for date, boolean, numeric columns
35
+ - [x] Add composite PK integration tests (4 tests)
36
+ - Reference: `tests/integration/features.test.ts` - "Composite Primary Keys" describe block
37
+
38
+ ---
39
+
40
+ ## Medium Priority - V1 Features Not Ported
41
+
42
+ ### Dashboard Collection (filter: TRUE)
43
+ - [ ] Add `filter: TRUE` handling to `generateSubscribableGetFunction()` in `src/cli/codegen/subscribable_sql.ts`
44
+ - Fetch ALL rows regardless of FK relationship to root
45
+ - [ ] Add `filter: TRUE` handling to `affected_keys` function
46
+ - Return `'{}'::jsonb` to notify ALL subscribers
47
+ - [ ] Add dashboard collection integration test
48
+ - Reference: `tests/integration/dashboard-collection.test.js` (v1)
49
+
50
+ ### Null-Root Dashboard
51
+ - [ ] Support subscribables with no root entity parameter
52
+ - `root.key: '@user_id'` or similar built-in
53
+ - [ ] Add null-root dashboard test
54
+ - Reference: `tests/integration/null-root-dashboard.test.js` (v1)
55
+
56
+ ### Delete Subscription Resolution
57
+ - [ ] Verify `affected_keys` function receives full record data on DELETE
58
+ - [ ] Add integration test for DELETE event subscription routing
59
+ - Reference: `tests/integration/delete-subscription-resolution.test.js` (v1)
60
+
61
+ ### Atomic Subscription Updates
62
+ - [ ] Add integration test for Pinia store `applyPatch` with real WebSocket events
63
+ - [ ] Verify schema inclusion in subscribe response
64
+ - Reference: `tests/integration/atomic-subscription-updates.test.js` (v1)
65
+
66
+ ---
67
+
68
+ ## Low Priority - COMPLETED
69
+
70
+ ### Custom Functions Pass-through ✅
71
+ - [x] Parse `customFunctions` from domain definition in IR generator
72
+ - [x] Include custom function SQL in generated migrations
73
+ - [x] Add custom functions to manifest allowlist for runtime security
74
+ - [x] Add custom functions integration tests (4 tests)
75
+ - Reference: `tests/integration/features.test.ts` - "Custom Functions" describe block
76
+
77
+ ### JavaScript Custom Functions ✅
78
+ - [x] Add JS function handler registry (`src/runtime/js_functions.ts`)
79
+ - [x] Update `handleRequest` to check for JS handlers (takes precedence over SQL)
80
+ - [x] JS functions receive context with `userId`, `params`, and `db.query()` access
81
+ - [x] Export `registerJsFunction` API from runtime
82
+ - [x] Add JavaScript custom function integration tests (5 tests)
83
+ - Reference: `tests/integration/features.test.ts` - "JavaScript Custom Functions" describe block
84
+
85
+ ### Temporal Table Support
86
+ - [ ] Implement `temporal.validFrom` / `temporal.validTo` filtering
87
+ - [ ] Auto-filter to current validity period
88
+ - Schema already defined in `venues.js:acts_for.temporal`
89
+
90
+ ### On-Delete Graph Rules
91
+ - [ ] Verify `onDelete` graph rules receive correct record data
92
+ - [ ] Test cascading deletes
93
+ - Reference: `tests/integration/on-delete-graph-rules.test.js` (v1)
94
+
95
+ ---
96
+
97
+ ## Integration Test Coverage
98
+
99
+ ### Missing Integration Tests (port from v1)
100
+ - [ ] Security / SQL injection prevention (`security.test.js`)
101
+ - [ ] M2M runtime operations (`m2m-runtime.test.js`)
102
+ - [ ] Permissions enforcement (`permissions.test.js` - more comprehensive)
103
+ - [ ] Event validation (`event-validation.test.js`)
104
+ - [ ] Namespace/entity discovery (`namespace-cli.test.js`)
105
+ - [ ] Migration runner (`migrations.test.js`)
106
+
107
+ ### Current V2 Integration Tests
108
+ - `tests/integration/db.test.ts` - CRUD, permissions, events, graph rules ✅
109
+ - `tests/integration/e2e.test.ts` - Compiler pipeline ✅
110
+ - `tests/integration/full_stack.test.ts` - Runtime + WebSocket + Pinia ✅
111
+ - `tests/integration/features.test.ts` - Search filters, deep paths, M2M, soft delete, field defaults, composite PK ✅
112
+
113
+ ---
114
+
115
+ ## Not Applicable to V2
116
+
117
+ ### Interpreted Mode
118
+ - V1 had runtime `register_entity` + generic functions
119
+ - V2 is compile-only by design - no gap, intentional removal
120
+
121
+ ---
122
+
123
+ ## Feature Comparison Summary
124
+
125
+ | Feature | V1 | V2 | Status |
126
+ |---------|----|----|--------|
127
+ | Authentication | ✅ | ✅ | Done |
128
+ | CRUD Operations | ✅ | ✅ | Done |
129
+ | Permissions | ✅ | ✅ | Done |
130
+ | Graph Rules | ✅ | ✅ | Done |
131
+ | M2M Relationships | ✅ | ✅ | Done |
132
+ | Events | ✅ | ✅ | Done |
133
+ | Subscribables | ✅ | ✅ | Done |
134
+ | Security (allowlist) | ✅ | ✅ | Done |
135
+ | Search Operators | ✅ | ✅ | Done |
136
+ | Deep Permission Paths | ✅ | ✅ | Done |
137
+ | Pinia Stores | ❌ | ✅ | New in V2 |
138
+ | .env Support | ❌ | ✅ | New in V2 |
139
+ | Soft Delete | ✅ | ✅ | Done |
140
+ | Field Defaults | ✅ | ✅ | Done |
141
+ | Composite PK | ✅ | ✅ | Done |
142
+ | Custom Functions (SQL) | ✅ | ✅ | Done |
143
+ | Custom Functions (JS) | ✅ | ✅ | Done |
144
+ | Dashboard Collection | ✅ | ❌ | **TODO** |
145
+ | Null-Root Dashboard | ✅ | ❌ | **TODO** |
146
+ | Interpreted Mode | ✅ | ❌ | Removed |