zitejs 0.9.24 → 0.9.26

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.
@@ -26,13 +26,14 @@ function getToken() {
26
26
  return (0, env_js_1.getEnv)('ZITE_DB_TOKEN', 'VITE_ZITE_DB_TOKEN') ?? '';
27
27
  }
28
28
  async function wrapSdkCall(integrationId, className, methodName, params) {
29
+ const mergedParams = { tableId: className, ...params };
29
30
  const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
30
31
  method: 'POST',
31
32
  headers: {
32
33
  Authorization: `Bearer ${getToken()}`,
33
34
  'Content-Type': 'application/json',
34
35
  },
35
- body: JSON.stringify({ integrationId, className, methodName, params }),
36
+ body: JSON.stringify({ integrationId, methodName, params: mergedParams }),
36
37
  });
37
38
  if (!res.ok) {
38
39
  const text = await res.text().catch(() => '');
@@ -64,6 +64,11 @@ function generateSchema(base) {
64
64
  function generateDbTs(base, schema, integrationId = 'databases') {
65
65
  const lines = [];
66
66
  lines.push('// Auto-generated by zitejs sync. Do not edit manually.');
67
+ lines.push('// createTableClient<T> returns a typed client with:');
68
+ lines.push('// .findAll(options?) → { records: T[], total: number, hasMore: boolean }');
69
+ lines.push('// .findOne(id | filters) → T');
70
+ lines.push('// .create(data) → T | .update(id, data) → T | .delete(id) → { deleted: true }');
71
+ lines.push('// .bulkCreate(records) → T[]');
67
72
  lines.push("import { createTableClient, wrapSdkCall } from 'zitejs/runtime';");
68
73
  lines.push('');
69
74
  for (const table of base.tables ?? []) {
@@ -99,7 +104,14 @@ function generateDbDts(base, schema) {
99
104
  '// This file contains only type declarations for LLM context.',
100
105
  '// See db.ts for the full runtime.',
101
106
  '',
102
- "import type { TableClient } from 'zitejs/runtime';",
107
+ 'interface TableClient<T> {',
108
+ ' findAll(options?: { limit?: number; offset?: number; sort?: unknown[]; filter?: unknown; filters?: unknown }): Promise<{ records: T[]; total: number; hasMore: boolean }>;',
109
+ ' findOne(recordId: string | { filters?: unknown; filter?: unknown }): Promise<T>;',
110
+ ' create(data: Partial<T> | { record: Partial<T> }): Promise<T>;',
111
+ ' update(recordId: string | { id: string; record?: Partial<T> }, data?: Partial<T> | { record: Partial<T> }): Promise<T>;',
112
+ ' delete(recordId: string | { id: string }): Promise<{ deleted: true }>;',
113
+ ' bulkCreate(records: Partial<T>[]): Promise<T[]>;',
114
+ '}',
103
115
  '',
104
116
  ];
105
117
  for (const table of base.tables ?? []) {
@@ -21,13 +21,14 @@ function getToken() {
21
21
  return getEnv('ZITE_DB_TOKEN', 'VITE_ZITE_DB_TOKEN') ?? '';
22
22
  }
23
23
  export async function wrapSdkCall(integrationId, className, methodName, params) {
24
+ const mergedParams = { tableId: className, ...params };
24
25
  const res = await fetch(`${getRunnerUrl()}/sdk/execute`, {
25
26
  method: 'POST',
26
27
  headers: {
27
28
  Authorization: `Bearer ${getToken()}`,
28
29
  'Content-Type': 'application/json',
29
30
  },
30
- body: JSON.stringify({ integrationId, className, methodName, params }),
31
+ body: JSON.stringify({ integrationId, methodName, params: mergedParams }),
31
32
  });
32
33
  if (!res.ok) {
33
34
  const text = await res.text().catch(() => '');
@@ -53,6 +53,11 @@ export function generateSchema(base) {
53
53
  export function generateDbTs(base, schema, integrationId = 'databases') {
54
54
  const lines = [];
55
55
  lines.push('// Auto-generated by zitejs sync. Do not edit manually.');
56
+ lines.push('// createTableClient<T> returns a typed client with:');
57
+ lines.push('// .findAll(options?) → { records: T[], total: number, hasMore: boolean }');
58
+ lines.push('// .findOne(id | filters) → T');
59
+ lines.push('// .create(data) → T | .update(id, data) → T | .delete(id) → { deleted: true }');
60
+ lines.push('// .bulkCreate(records) → T[]');
56
61
  lines.push("import { createTableClient, wrapSdkCall } from 'zitejs/runtime';");
57
62
  lines.push('');
58
63
  for (const table of base.tables ?? []) {
@@ -88,7 +93,14 @@ export function generateDbDts(base, schema) {
88
93
  '// This file contains only type declarations for LLM context.',
89
94
  '// See db.ts for the full runtime.',
90
95
  '',
91
- "import type { TableClient } from 'zitejs/runtime';",
96
+ 'interface TableClient<T> {',
97
+ ' findAll(options?: { limit?: number; offset?: number; sort?: unknown[]; filter?: unknown; filters?: unknown }): Promise<{ records: T[]; total: number; hasMore: boolean }>;',
98
+ ' findOne(recordId: string | { filters?: unknown; filter?: unknown }): Promise<T>;',
99
+ ' create(data: Partial<T> | { record: Partial<T> }): Promise<T>;',
100
+ ' update(recordId: string | { id: string; record?: Partial<T> }, data?: Partial<T> | { record: Partial<T> }): Promise<T>;',
101
+ ' delete(recordId: string | { id: string }): Promise<{ deleted: true }>;',
102
+ ' bulkCreate(records: Partial<T>[]): Promise<T[]>;',
103
+ '}',
92
104
  '',
93
105
  ];
94
106
  for (const table of base.tables ?? []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.24",
3
+ "version": "0.9.26",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/runtime/index.js",