dzql 0.6.3 → 0.6.5

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 (41) hide show
  1. package/README.md +33 -0
  2. package/docs/for_ai.md +14 -18
  3. package/docs/project-setup.md +15 -14
  4. package/package.json +28 -6
  5. package/src/cli/codegen/client.ts +5 -6
  6. package/src/cli/codegen/subscribable_store.ts +5 -5
  7. package/src/runtime/ws.ts +16 -15
  8. package/.env.sample +0 -28
  9. package/compose.yml +0 -28
  10. package/dist/client/index.ts +0 -1
  11. package/dist/client/stores/useMyProfileStore.ts +0 -114
  12. package/dist/client/stores/useOrgDashboardStore.ts +0 -131
  13. package/dist/client/stores/useVenueDetailStore.ts +0 -117
  14. package/dist/client/ws.ts +0 -716
  15. package/dist/db/migrations/000_core.sql +0 -92
  16. package/dist/db/migrations/20260101T235039268Z_schema.sql +0 -3020
  17. package/dist/db/migrations/20260101T235039268Z_subscribables.sql +0 -371
  18. package/dist/runtime/manifest.json +0 -1562
  19. package/examples/blog.ts +0 -50
  20. package/examples/invalid.ts +0 -18
  21. package/examples/venues.js +0 -485
  22. package/tests/client.test.ts +0 -38
  23. package/tests/codegen.test.ts +0 -71
  24. package/tests/compiler.test.ts +0 -45
  25. package/tests/graph_rules.test.ts +0 -173
  26. package/tests/integration/db.test.ts +0 -174
  27. package/tests/integration/e2e.test.ts +0 -65
  28. package/tests/integration/features.test.ts +0 -922
  29. package/tests/integration/full_stack.test.ts +0 -262
  30. package/tests/integration/setup.ts +0 -45
  31. package/tests/ir.test.ts +0 -32
  32. package/tests/namespace.test.ts +0 -395
  33. package/tests/permissions.test.ts +0 -55
  34. package/tests/pinia.test.ts +0 -48
  35. package/tests/realtime.test.ts +0 -22
  36. package/tests/runtime.test.ts +0 -80
  37. package/tests/subscribable_gen.test.ts +0 -72
  38. package/tests/subscribable_reactivity.test.ts +0 -258
  39. package/tests/venues_gen.test.ts +0 -25
  40. package/tsconfig.json +0 -20
  41. package/tsconfig.tsbuildinfo +0 -1
@@ -1,117 +0,0 @@
1
- // Generated by DZQL Compiler v2.0.0
2
- // Do not edit this file directly.
3
-
4
- import { defineStore } from 'pinia';
5
- import { ref, type Ref } from 'vue';
6
- import { ws } from '../index.js';
7
-
8
- /** Parameters for venue_detail subscription */
9
- export interface VenueDetailParams {
10
- venue_id: number;
11
- }
12
-
13
- /** Event from server for patching */
14
- export interface PatchEvent {
15
- table: string;
16
- op: 'insert' | 'update' | 'delete';
17
- pk: { id: number };
18
- data: Record<string, unknown> | null;
19
- }
20
-
21
- /** Document wrapper with loading state */
22
- export interface DocumentWrapper<T> {
23
- data: T;
24
- loading: boolean;
25
- ready: Promise<void>;
26
- }
27
-
28
- export const useVenueDetailStore = defineStore('sub-venue_detail', () => {
29
- const documents: Ref<Record<string, DocumentWrapper<Record<string, unknown>>>> = ref({});
30
- const unsubscribers = new Map<string, () => void>();
31
-
32
- async function bind(params: VenueDetailParams): Promise<DocumentWrapper<Record<string, unknown>>> {
33
- const key = JSON.stringify(params);
34
-
35
- if (documents.value[key]) {
36
- const existing = documents.value[key];
37
- if (existing.loading) {
38
- await existing.ready;
39
- }
40
- return existing;
41
- }
42
-
43
- let resolveReady!: () => void;
44
- const ready = new Promise<void>((resolve) => { resolveReady = resolve; });
45
-
46
- documents.value[key] = { data: {}, loading: true, ready };
47
- let isFirst = true;
48
-
49
- const unsubscribe = await ws.api.subscribe_venue_detail(params, (eventData: unknown) => {
50
- if (isFirst) {
51
- // Initial data - merge into existing object to preserve reactivity
52
- Object.assign(documents.value[key].data, eventData as Record<string, unknown>);
53
- documents.value[key].loading = false;
54
- isFirst = false;
55
- resolveReady();
56
- } else {
57
- // Patch event
58
- applyPatch(documents.value[key].data, eventData as PatchEvent);
59
- }
60
- });
61
-
62
- unsubscribers.set(key, unsubscribe as () => void);
63
- await ready;
64
- return documents.value[key];
65
- }
66
-
67
- function unbind(params: VenueDetailParams): void {
68
- const key = JSON.stringify(params);
69
- const unsubscribe = unsubscribers.get(key);
70
- if (unsubscribe) {
71
- unsubscribe();
72
- unsubscribers.delete(key);
73
- delete documents.value[key];
74
- }
75
- }
76
-
77
- function applyPatch(doc: Record<string, unknown>, event: PatchEvent): void {
78
- if (!doc) return;
79
- switch (event.table) {
80
- case 'venues':
81
- if (event.op === 'update' && doc.venues) {
82
- Object.assign(doc.venues, event.data);
83
- }
84
- break;
85
- case 'organisations':
86
- handleArrayPatch(doc.org, event);
87
- break;
88
- case 'sites':
89
- handleArrayPatch(doc.sites, event);
90
- break;
91
- case 'allocations':
92
- if (event.data && event.data.site_id) {
93
- const parent = doc.sites?.find((p: { id: number }) => p.id === event.data.site_id);
94
- if (parent && parent.allocations) {
95
- handleArrayPatch(parent.allocations, event);
96
- }
97
- }
98
- break;
99
- }
100
- }
101
-
102
- function handleArrayPatch(arr: unknown[] | undefined, event: PatchEvent): void {
103
- if (!arr || !Array.isArray(arr)) return;
104
- const pkValue = event.pk?.id;
105
- const idx = arr.findIndex((i: unknown) => (i as { id: number }).id === pkValue);
106
-
107
- if (event.op === 'insert') {
108
- if (idx === -1 && event.data) arr.push(event.data);
109
- } else if (event.op === 'update') {
110
- if (idx !== -1 && event.data) Object.assign(arr[idx] as object, event.data);
111
- } else if (event.op === 'delete') {
112
- if (idx !== -1) arr.splice(idx, 1);
113
- }
114
- }
115
-
116
- return { bind, unbind, documents };
117
- });