dzql 0.6.10 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/runtime/namespace.ts +16 -10
package/package.json
CHANGED
package/src/runtime/namespace.ts
CHANGED
|
@@ -53,6 +53,12 @@ import type { Manifest, FunctionDef } from "../cli/codegen/manifest.js";
|
|
|
53
53
|
// Default user for CLI operations
|
|
54
54
|
const DEFAULT_USER_ID = 1;
|
|
55
55
|
|
|
56
|
+
/** Context interface compatible with invoket - kept minimal to avoid dependency */
|
|
57
|
+
export interface Context {
|
|
58
|
+
cwd: string;
|
|
59
|
+
run(command: string, options?: { echo?: boolean }): Promise<unknown>;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
/** Query parameters for search operations */
|
|
57
63
|
export interface SearchParams {
|
|
58
64
|
query?: string;
|
|
@@ -224,7 +230,7 @@ export class DzqlNamespace {
|
|
|
224
230
|
* List all available entities
|
|
225
231
|
* @example invt dzql:entities
|
|
226
232
|
*/
|
|
227
|
-
async entities(
|
|
233
|
+
async entities(c: Context): Promise<void> {
|
|
228
234
|
try {
|
|
229
235
|
const { manifest } = await this.init();
|
|
230
236
|
const entities = discoverEntities(manifest);
|
|
@@ -241,7 +247,7 @@ export class DzqlNamespace {
|
|
|
241
247
|
* List all available subscribables
|
|
242
248
|
* @example invt dzql:subscribables
|
|
243
249
|
*/
|
|
244
|
-
async subscribables(
|
|
250
|
+
async subscribables(c: Context): Promise<void> {
|
|
245
251
|
try {
|
|
246
252
|
const { manifest } = await this.init();
|
|
247
253
|
const subscribables = discoverSubscribables(manifest);
|
|
@@ -258,7 +264,7 @@ export class DzqlNamespace {
|
|
|
258
264
|
* Search an entity
|
|
259
265
|
* @example invt dzql:search venues '{"query": "test"}'
|
|
260
266
|
*/
|
|
261
|
-
async search(
|
|
267
|
+
async search(c: Context, entity: string, params: SearchParams = {}): Promise<void> {
|
|
262
268
|
try {
|
|
263
269
|
const result = await this.executeFunction(`search_${entity}`, params);
|
|
264
270
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -274,7 +280,7 @@ export class DzqlNamespace {
|
|
|
274
280
|
* Get entity by ID
|
|
275
281
|
* @example invt dzql:get venues '{"id": 1}'
|
|
276
282
|
*/
|
|
277
|
-
async get(
|
|
283
|
+
async get(c: Context, entity: string, pk: PkParams): Promise<void> {
|
|
278
284
|
try {
|
|
279
285
|
const result = await this.executeFunction(`get_${entity}`, pk);
|
|
280
286
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -290,7 +296,7 @@ export class DzqlNamespace {
|
|
|
290
296
|
* Save (create or update) entity
|
|
291
297
|
* @example invt dzql:save venues '{"name": "New Venue", "org_id": 1}'
|
|
292
298
|
*/
|
|
293
|
-
async save(
|
|
299
|
+
async save(c: Context, entity: string, data: CallParams): Promise<void> {
|
|
294
300
|
try {
|
|
295
301
|
const result = await this.executeFunction(`save_${entity}`, data);
|
|
296
302
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -306,7 +312,7 @@ export class DzqlNamespace {
|
|
|
306
312
|
* Delete entity by ID
|
|
307
313
|
* @example invt dzql:delete venues '{"id": 1}'
|
|
308
314
|
*/
|
|
309
|
-
async delete(
|
|
315
|
+
async delete(c: Context, entity: string, pk: PkParams): Promise<void> {
|
|
310
316
|
try {
|
|
311
317
|
const result = await this.executeFunction(`delete_${entity}`, pk);
|
|
312
318
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -322,7 +328,7 @@ export class DzqlNamespace {
|
|
|
322
328
|
* Lookup entity (for dropdowns/autocomplete)
|
|
323
329
|
* @example invt dzql:lookup organisations '{"query": "acme"}'
|
|
324
330
|
*/
|
|
325
|
-
async lookup(
|
|
331
|
+
async lookup(c: Context, entity: string, params: SearchParams = {}): Promise<void> {
|
|
326
332
|
try {
|
|
327
333
|
const result = await this.executeFunction(`lookup_${entity}`, params);
|
|
328
334
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -338,7 +344,7 @@ export class DzqlNamespace {
|
|
|
338
344
|
* Get subscribable snapshot
|
|
339
345
|
* @example invt dzql:subscribe venue_detail '{"venue_id": 1}'
|
|
340
346
|
*/
|
|
341
|
-
async subscribe(
|
|
347
|
+
async subscribe(c: Context, name: string, params: CallParams = {}): Promise<void> {
|
|
342
348
|
try {
|
|
343
349
|
const result = await this.executeFunction(`get_${name}`, params);
|
|
344
350
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -355,7 +361,7 @@ export class DzqlNamespace {
|
|
|
355
361
|
* @example invt dzql:call login_user '{"email": "test@example.com", "password": "secret"}'
|
|
356
362
|
* @example invt dzql:call get_venue_detail '{"venue_id": 1}'
|
|
357
363
|
*/
|
|
358
|
-
async call(
|
|
364
|
+
async call(c: Context, funcName: string, params: CallParams = {}): Promise<void> {
|
|
359
365
|
try {
|
|
360
366
|
const result = await this.executeFunction(funcName, params);
|
|
361
367
|
console.log(JSON.stringify({ success: true, result }, null, 2));
|
|
@@ -371,7 +377,7 @@ export class DzqlNamespace {
|
|
|
371
377
|
* List all available functions in the manifest
|
|
372
378
|
* @example invt dzql:functions
|
|
373
379
|
*/
|
|
374
|
-
async functions(
|
|
380
|
+
async functions(c: Context): Promise<void> {
|
|
375
381
|
try {
|
|
376
382
|
const { manifest } = await this.init();
|
|
377
383
|
const functions: Record<string, { args: string[]; returnType: string }> = {};
|