dzql 0.6.1 → 0.6.2

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/docs/README.md CHANGED
@@ -147,7 +147,7 @@ await ws.logout(); // Clears token and user state
147
147
 
148
148
  ## Generated Pinia Subscribable Stores
149
149
 
150
- TZQL generates Pinia stores for each subscribable that handle:
150
+ DZQL generates Pinia stores for each subscribable that handle:
151
151
  - Initial data fetch via WebSocket subscription
152
152
  - Automatic realtime patching when related data changes
153
153
  - Deduplication of subscriptions by parameter key
@@ -1,4 +1,4 @@
1
- # tzql Bug Report
1
+ # DZQL Bug Report
2
2
 
3
3
  ## Generated Store applyPatch Doesn't Match Data Structure
4
4
 
@@ -79,7 +79,7 @@ to_jsonb(rel.*) || jsonb_build_object(...)
79
79
 
80
80
  ## Environment
81
81
 
82
- - tzql version: local development (linked)
82
+ - dzql version: local development (linked)
83
83
  - Database: PostgreSQL 17 (Docker)
84
84
  - Client: Vue 3 + Pinia + TypeScript
85
85
  - Runtime: Bun
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Summary
6
6
 
7
- When a client connects to the tzql WebSocket server, the server should immediately send a connection:ready message containing the authenticated user profile (or null if not authenticated).
7
+ When a client connects to the DZQL WebSocket server, the server should immediately send a connection:ready message containing the authenticated user profile (or null if not authenticated).
8
8
 
9
9
  ## Current Behavior
10
10
 
@@ -1,6 +1,6 @@
1
- # tzql Bug Report
1
+ # DZQL Bug Report
2
2
 
3
- Bugs discovered while building the Venues application with tzql.
3
+ Bugs discovered while building the Venues application with DZQL.
4
4
 
5
5
  ---
6
6
 
@@ -97,7 +97,7 @@ Updated `compileSubscribePermission` in `subscribable_sql.ts` to map param names
97
97
 
98
98
  ## Environment
99
99
 
100
- - tzql version: (linked local development version)
100
+ - dzql version: (linked local development version)
101
101
  - Database: PostgreSQL 17 (via Docker)
102
102
  - Client: Vue 3 + Pinia + TypeScript
103
103
  - Runtime: Bun
@@ -106,6 +106,6 @@ Updated `compileSubscribePermission` in `subscribable_sql.ts` to map param names
106
106
 
107
107
  ## Related Files
108
108
 
109
- Detailed bug documents created in tzql docs:
109
+ Detailed bug documents created in dzql docs:
110
110
  - `/packages/tzql/docs/feature-requests/hidden-fields-in-subscribables.md`
111
111
  - `/packages/tzql/docs/feature-requests/subscribable-param-key-bug.md`
@@ -1,4 +1,4 @@
1
- # TZQL v2 Gap Analysis TODO
1
+ # DZQL v2 Gap Analysis TODO
2
2
 
3
3
  Gap analysis comparing v1 tests to v2 functionality. Updated 2024-12-17.
4
4
 
package/docs/for_ai.md CHANGED
@@ -288,7 +288,7 @@ Use `type: 'reactor'` for anything that requires Node.js (Email, Stripe, AI proc
288
288
 
289
289
  ## Custom Functions
290
290
 
291
- TZQL supports two types of custom functions that can be called via RPC:
291
+ DZQL supports two types of custom functions that can be called via RPC:
292
292
 
293
293
  ### 1. SQL Custom Functions
294
294
 
@@ -367,7 +367,7 @@ JavaScript custom functions run in the Bun/Node runtime. They are ideal for:
367
367
 
368
368
  ```typescript
369
369
  // server.ts or wherever you start your runtime
370
- import { registerJsFunction } from 'tzql/runtime';
370
+ import { registerJsFunction } from 'dzql/runtime';
371
371
 
372
372
  // Simple function
373
373
  registerJsFunction('hello_world', async (ctx) => {
@@ -471,7 +471,7 @@ interface JsFunctionContext {
471
471
 
472
472
  ## Unmanaged Entities (Junction Tables)
473
473
 
474
- For junction tables used in many-to-many relationships, you typically don't want TZQL to generate CRUD functions. These tables are managed via the M2M relationship on the parent entity.
474
+ For junction tables used in many-to-many relationships, you typically don't want DZQL to generate CRUD functions. These tables are managed via the M2M relationship on the parent entity.
475
475
 
476
476
  Use `managed: false` to skip CRUD generation:
477
477
 
@@ -580,7 +580,7 @@ await ws.logout(); // Clears token, user state, and reconnects
580
580
 
581
581
  ## CLI Integration with Namespace
582
582
 
583
- TZQL provides a namespace export for CLI tools like `invokej` to interact with the database directly without going through the WebSocket runtime.
583
+ DZQL provides a namespace export for CLI tools like `invokej` to interact with the database directly without going through the WebSocket runtime.
584
584
 
585
585
  ### Setup
586
586
 
@@ -599,19 +599,19 @@ const dzql = new DzqlNamespace(sql, manifest);
599
599
 
600
600
  ```typescript
601
601
  // Get a record
602
- const venue = await tzql.get('venues', { id: 1 }, userId);
602
+ const venue = await dzql.get('venues', { id: 1 }, userId);
603
603
 
604
604
  // Save (create or update)
605
- const newVenue = await tzql.save('venues', { name: 'New Venue', org_id: 1 }, userId);
605
+ const newVenue = await dzql.save('venues', { name: 'New Venue', org_id: 1 }, userId);
606
606
 
607
607
  // Delete
608
- const deleted = await tzql.delete('venues', { id: 1 }, userId);
608
+ const deleted = await dzql.delete('venues', { id: 1 }, userId);
609
609
 
610
610
  // Search with filters
611
- const venues = await tzql.search('venues', { org_id: 1, limit: 10 }, userId);
611
+ const venues = await dzql.search('venues', { org_id: 1, limit: 10 }, userId);
612
612
 
613
613
  // Lookup for autocomplete
614
- const options = await tzql.lookup('venues', { q: 'test' }, userId);
614
+ const options = await dzql.lookup('venues', { q: 'test' }, userId);
615
615
  ```
616
616
 
617
617
  ### Ad-hoc Function Calls
@@ -620,17 +620,17 @@ Call any function in the manifest directly:
620
620
 
621
621
  ```typescript
622
622
  // Call a custom function
623
- const result = await tzql.call('calculate_org_stats', { org_id: 1 }, userId);
623
+ const result = await dzql.call('calculate_org_stats', { org_id: 1 }, userId);
624
624
 
625
625
  // Call a subscribable getter
626
- const detail = await tzql.call('get_venue_detail', { venue_id: 1 }, userId);
626
+ const detail = await dzql.call('get_venue_detail', { venue_id: 1 }, userId);
627
627
  ```
628
628
 
629
629
  ### List Available Functions
630
630
 
631
631
  ```typescript
632
632
  // Get all functions from manifest
633
- const functions = tzql.functions();
633
+ const functions = dzql.functions();
634
634
  // Returns: ['login_user', 'register_user', 'get_venues', 'save_venues', ...]
635
635
  ```
636
636
 
@@ -639,11 +639,11 @@ const functions = tzql.functions();
639
639
  The namespace is designed for use with `invokej`, a CLI tool for invoking functions:
640
640
 
641
641
  ```bash
642
- # In your invokej configuration, register the TZQL namespace
643
- invokej tzql:get venues '{"id": 1}'
644
- invokej tzql:save venues '{"name": "Updated Venue", "id": 1}'
645
- invokej tzql:call calculate_org_stats '{"org_id": 1}'
646
- invokej tzql:functions
642
+ # In your invokej configuration, register the DZQL namespace
643
+ invokej dzql:get venues '{"id": 1}'
644
+ invokej dzql:save venues '{"name": "Updated Venue", "id": 1}'
645
+ invokej dzql:call calculate_org_stats '{"org_id": 1}'
646
+ invokej dzql:functions
647
647
  ```
648
648
 
649
649
  **Key Points:**
@@ -26,7 +26,7 @@ If you prefer to set up manually:
26
26
  my-app/
27
27
  ├── package.json # Workspaces root
28
28
  ├── bun.lock # Single lockfile
29
- ├── domain.js # TZQL domain definition
29
+ ├── domain.js # DZQL domain definition
30
30
  ├── .env # Environment variables
31
31
  ├── compose.yml # PostgreSQL for development
32
32
  ├── generated/ # DO NOT EDIT - compiled output
@@ -43,7 +43,7 @@ my-app/
43
43
  │ ├── composables/
44
44
  │ ├── components/
45
45
  │ └── views/
46
- └── server/ # TZQL server workspace
46
+ └── server/ # DZQL server workspace
47
47
  ├── package.json
48
48
  └── index.ts
49
49
  ```
@@ -164,7 +164,7 @@ MANIFEST_PATH=./generated/runtime/manifest.json
164
164
  JWT_SECRET=dev-secret-change-in-production
165
165
 
166
166
  # Client (Vite)
167
- VITE_TZQL_TOKEN_NAME=myapp_token
167
+ VITE_DZQL_TOKEN_NAME=myapp_token
168
168
  ```
169
169
 
170
170
  ## 4. Vite Configuration
@@ -189,7 +189,7 @@ export default defineConfig({
189
189
  host: '0.0.0.0',
190
190
  allowedHosts: ['host.docker.internal'],
191
191
 
192
- // Proxy WebSocket to TZQL server
192
+ // Proxy WebSocket to DZQL server
193
193
  proxy: {
194
194
  '/ws': {
195
195
  target: 'ws://localhost:3000',
@@ -204,7 +204,7 @@ export default defineConfig({
204
204
 
205
205
  - `host: '0.0.0.0'` - Binds to all interfaces, required for Docker access
206
206
  - `allowedHosts: ['host.docker.internal']` - Allows Playwright MCP (running in Docker) to connect
207
- - `proxy: { '/ws': ... }` - Client connects to `/ws` on Vite's port, proxied to TZQL server on port 3000
207
+ - `proxy: { '/ws': ... }` - Client connects to `/ws` on Vite's port, proxied to DZQL server on port 3000
208
208
 
209
209
  **For Playwright MCP testing:** Navigate to `http://host.docker.internal:5173`
210
210
 
@@ -227,7 +227,7 @@ export default defineConfig({
227
227
 
228
228
  ## 6. Authentication Composable
229
229
 
230
- `src/src/composables/useTzql.ts`:
230
+ `src/src/composables/useDzql.ts`:
231
231
 
232
232
  ```typescript
233
233
  import { ref } from 'vue'
@@ -237,7 +237,7 @@ const ready = ref(false)
237
237
  const user = ref<any>(null)
238
238
  const connectionError = ref<string | null>(null)
239
239
 
240
- export function useTzql() {
240
+ export function useDzql() {
241
241
  async function connect(url?: string) {
242
242
  try {
243
243
  connectionError.value = null
@@ -293,15 +293,15 @@ import { createApp } from 'vue'
293
293
  import { createPinia } from 'pinia'
294
294
  import App from './App.vue'
295
295
  import router from './router'
296
- import { useTzql } from './composables/useTzql'
296
+ import { useDzql } from './composables/useDzql'
297
297
 
298
298
  const app = createApp(App)
299
299
  app.use(createPinia())
300
300
  app.use(router)
301
301
  app.mount('#app')
302
302
 
303
- // Connect to TZQL server
304
- const { connect } = useTzql()
303
+ // Connect to DZQL server
304
+ const { connect } = useDzql()
305
305
  connect()
306
306
  ```
307
307
 
@@ -311,10 +311,10 @@ connect()
311
311
 
312
312
  ```vue
313
313
  <script setup lang="ts">
314
- import { useTzql } from '@/composables/useTzql'
314
+ import { useDzql } from '@/composables/useDzql'
315
315
  import LoginModal from '@/components/LoginModal.vue'
316
316
 
317
- const { ready, user, logout } = useTzql()
317
+ const { ready, user, logout } = useDzql()
318
318
  </script>
319
319
 
320
320
  <template>
@@ -347,11 +347,11 @@ const { ready, user, logout } = useTzql()
347
347
  <script setup lang="ts">
348
348
  import { computed, watchEffect } from 'vue'
349
349
  import { useRoute } from 'vue-router'
350
- import { useTzql } from '@/composables/useTzql'
350
+ import { useDzql } from '@/composables/useDzql'
351
351
  import { useVenueDetailStore } from '@generated/client/stores/useVenueDetailStore.js'
352
352
 
353
353
  const route = useRoute()
354
- const { ws } = useTzql()
354
+ const { ws } = useDzql()
355
355
  const store = useVenueDetailStore()
356
356
 
357
357
  const venueId = computed(() => Number(route.params.id))
@@ -391,11 +391,11 @@ async function deleteSite(id: number) {
391
391
  Create `tasks.js` in the project root to enable CLI database operations:
392
392
 
393
393
  ```javascript
394
- import { TzqlNamespace } from "tzql/namespace";
394
+ import { DzqlNamespace } from "dzql/namespace";
395
395
 
396
396
  export class Tasks {
397
397
  constructor() {
398
- this.tzql = new TzqlNamespace();
398
+ this.dzql = new DzqlNamespace();
399
399
  }
400
400
  }
401
401
  ```
@@ -406,25 +406,25 @@ This integrates with `invj` to provide direct database access:
406
406
  # List available commands
407
407
  invj -l
408
408
 
409
- # Available tzql commands:
410
- # tzql:entities - List all entities
411
- # tzql:subscribables - List all subscribables
412
- # tzql:functions - List all functions
413
- # tzql:search <entity> [json] - Search records
414
- # tzql:get <entity> [json] - Get single record
415
- # tzql:save <entity> [json] - Create/update record
416
- # tzql:delete <entity> [json] - Delete record
417
- # tzql:lookup <entity> [json] - Autocomplete lookup
418
- # tzql:call <func> [json] - Call custom function
419
- # tzql:subscribe <name> [json] - Get subscribable data
409
+ # Available dzql commands:
410
+ # dzql:entities - List all entities
411
+ # dzql:subscribables - List all subscribables
412
+ # dzql:functions - List all functions
413
+ # dzql:search <entity> [json] - Search records
414
+ # dzql:get <entity> [json] - Get single record
415
+ # dzql:save <entity> [json] - Create/update record
416
+ # dzql:delete <entity> [json] - Delete record
417
+ # dzql:lookup <entity> [json] - Autocomplete lookup
418
+ # dzql:call <func> [json] - Call custom function
419
+ # dzql:subscribe <name> [json] - Get subscribable data
420
420
 
421
421
  # Examples
422
- invj tzql:entities
423
- invj tzql:search venues
424
- invj tzql:search venues '{"org_id": 1}'
425
- invj tzql:get venues '{"id": 1}'
426
- invj tzql:save venues '{"org_id": 1, "name": "New Venue", "address": "123 Main St"}'
427
- invj tzql:delete venues '{"id": 1}'
422
+ invj dzql:entities
423
+ invj dzql:search venues
424
+ invj dzql:search venues '{"org_id": 1}'
425
+ invj dzql:get venues '{"id": 1}'
426
+ invj dzql:save venues '{"org_id": 1, "name": "New Venue", "address": "123 Main St"}'
427
+ invj dzql:delete venues '{"id": 1}'
428
428
  ```
429
429
 
430
430
  ## Development Workflow
@@ -442,15 +442,15 @@ bun run dev
442
442
 
443
443
  After `bun run db`, the database initializes with migrations automatically. After domain changes, run `bun run compile` then restart the server.
444
444
 
445
- ## Linking TZQL for Local Development
445
+ ## Linking DZQL for Local Development
446
446
 
447
- If developing TZQL locally:
447
+ If developing DZQL locally:
448
448
 
449
449
  ```bash
450
- cd /path/to/tzql
450
+ cd /path/to/dzql
451
451
  bun link
452
452
 
453
453
  cd /path/to/my-app
454
- # tzql is already in package.json as "link:tzql"
454
+ # dzql is already in package.json as "link:dzql"
455
455
  bun install
456
456
  ```
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "dzql",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Database-first real-time framework with TypeScript support",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/blueshed/dzql"
8
+ },
5
9
  "type": "module",
6
10
  "bin": {
7
11
  "dzql": "./src/cli/index.ts"
@@ -64,21 +64,21 @@ export function generateClientSDK(manifest: Manifest): string {
64
64
  return ` ${funcName}: (params: ${paramType}) => Promise<${returnType}>;`;
65
65
  }).join('\n');
66
66
 
67
- return `// Generated by TZQL Compiler v${manifest.version}
67
+ return `// Generated by DZQL Compiler v${manifest.version}
68
68
  // Do not edit this file directly.
69
69
 
70
- import { WebSocketManager } from 'tzql/client';
70
+ import { WebSocketManager } from 'dzql/client';
71
71
 
72
72
  ${typeDefs}
73
73
 
74
74
  /** API interface with typed methods */
75
- export interface TzqlAPI {
75
+ export interface DzqlAPI {
76
76
  ${apiMethods}
77
77
  }
78
78
 
79
79
  /** Extended WebSocket manager with typed API */
80
80
  export class GeneratedWebSocketManager extends WebSocketManager {
81
- api: TzqlAPI;
81
+ api: DzqlAPI;
82
82
 
83
83
  constructor(options: { url?: string; reconnect?: boolean } = {}) {
84
84
  super(options);
@@ -89,7 +89,7 @@ ${regularFunctions.map(([funcName]) =>
89
89
  ${subscriptionFunctions.map(([funcName]) =>
90
90
  ` ${funcName}: (params: Record<string, unknown>, callback: (data: unknown) => void) => this.subscribe('${funcName}', params, callback),`
91
91
  ).join('\n')}
92
- } as TzqlAPI;
92
+ } as DzqlAPI;
93
93
  }
94
94
  }
95
95
 
@@ -48,7 +48,7 @@ export function generatePiniaStore(manifest: Manifest, entityName: string): stri
48
48
  ? 'number'
49
49
  : 'string';
50
50
 
51
- return `// Generated by TZQL Compiler v${manifest.version}
51
+ return `// Generated by DZQL Compiler v${manifest.version}
52
52
  // Do not edit this file directly.
53
53
 
54
54
  import { defineStore } from 'pinia';
@@ -81,7 +81,7 @@ export function generateSubscribableStore(manifest: Manifest, subName: string):
81
81
 
82
82
  const patchCases = generatePatchCases();
83
83
 
84
- return `// Generated by TZQL Compiler v${manifest.version}
84
+ return `// Generated by DZQL Compiler v${manifest.version}
85
85
  // Do not edit this file directly.
86
86
 
87
87
  import { defineStore } from 'pinia';
package/src/client/ws.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Core WebSocket Manager for TZQL Client
1
+ // Core WebSocket Manager for DZQL Client
2
2
  // Handles connection, auth, reconnects, and message dispatching.
3
3
  // This is a pure transport layer - it does not manage or cache data.
4
4
 
@@ -10,17 +10,17 @@ export interface WebSocketOptions {
10
10
 
11
11
  // Get default token name from environment (build-time injection)
12
12
  function getDefaultTokenName(): string {
13
- // Vite: import.meta.env.VITE_TZQL_TOKEN_NAME
13
+ // Vite: import.meta.env.VITE_DZQL_TOKEN_NAME
14
14
  // @ts-ignore
15
- if (typeof import.meta !== 'undefined' && import.meta.env?.VITE_TZQL_TOKEN_NAME) {
15
+ if (typeof import.meta !== 'undefined' && import.meta.env?.VITE_DZQL_TOKEN_NAME) {
16
16
  // @ts-ignore
17
- return import.meta.env.VITE_TZQL_TOKEN_NAME;
17
+ return import.meta.env.VITE_DZQL_TOKEN_NAME;
18
18
  }
19
- // Node/bundlers: process.env.TZQL_TOKEN_NAME
20
- if (typeof process !== 'undefined' && process.env?.TZQL_TOKEN_NAME) {
21
- return process.env.TZQL_TOKEN_NAME;
19
+ // Node/bundlers: process.env.DZQL_TOKEN_NAME
20
+ if (typeof process !== 'undefined' && process.env?.DZQL_TOKEN_NAME) {
21
+ return process.env.DZQL_TOKEN_NAME;
22
22
  }
23
- return 'tzql_token';
23
+ return 'dzql_token';
24
24
  }
25
25
 
26
26
  export class WebSocketManager {
@@ -32,7 +32,7 @@ export class WebSocketManager {
32
32
  protected readyCallbacks = new Set<(user: any) => void>();
33
33
  protected reconnectAttempts = 0;
34
34
  protected maxReconnectAttempts = 5;
35
- protected tokenName = 'tzql_token';
35
+ protected tokenName = 'dzql_token';
36
36
  protected isShuttingDown = false;
37
37
 
38
38
  // Connection state
@@ -123,7 +123,7 @@ export class WebSocketManager {
123
123
 
124
124
  this.ws.onopen = () => {
125
125
  clearTimeout(connectionTimeout);
126
- console.log('[TZQL] Connected to ' + wsUrl);
126
+ console.log('[DZQL] Connected to ' + wsUrl);
127
127
  this.reconnectAttempts = 0;
128
128
  resolve();
129
129
  };
@@ -133,12 +133,12 @@ export class WebSocketManager {
133
133
  const message = JSON.parse(event.data);
134
134
  this.handleMessage(message);
135
135
  } catch (error) {
136
- console.error("[TZQL] Failed to parse message:", error);
136
+ console.error("[DZQL] Failed to parse message:", error);
137
137
  }
138
138
  };
139
139
 
140
140
  this.ws.onclose = () => {
141
- console.log("[TZQL] Disconnected");
141
+ console.log("[DZQL] Disconnected");
142
142
  if (!this.isShuttingDown) {
143
143
  this.attemptReconnect();
144
144
  }
@@ -146,7 +146,7 @@ export class WebSocketManager {
146
146
 
147
147
  this.ws.onerror = (error) => {
148
148
  clearTimeout(connectionTimeout);
149
- console.error("[TZQL] Connection error:", error);
149
+ console.error("[DZQL] Connection error:", error);
150
150
  reject(error);
151
151
  };
152
152
  });
@@ -157,7 +157,7 @@ export class WebSocketManager {
157
157
  this.reconnectAttempts++;
158
158
  const delay = 1000 * this.reconnectAttempts;
159
159
  setTimeout(() => {
160
- console.log('[TZQL] Reconnecting (' + this.reconnectAttempts + ')...');
160
+ console.log('[DZQL] Reconnecting (' + this.reconnectAttempts + ')...');
161
161
  this.connect();
162
162
  }, delay);
163
163
  }
@@ -90,7 +90,7 @@ const server = serve({
90
90
  if (server.upgrade(req, { data: { token } })) {
91
91
  return;
92
92
  }
93
- return new Response("TZQL Runtime Active", { status: 200 });
93
+ return new Response("DZQL Runtime Active", { status: 200 });
94
94
  },
95
95
  websocket: wsServer.handlers
96
96
  });