zitejs 0.9.6 → 0.9.7

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.
@@ -44,14 +44,17 @@ async function wrapSdkCall(integrationId, className, methodName, params) {
44
44
  function createTableClient(integrationId, className) {
45
45
  return {
46
46
  findAll: (options) => wrapSdkCall(integrationId, className, 'findAll', options),
47
- findOne: (recordId) => wrapSdkCall(integrationId, className, 'findOne', {
48
- id: recordId,
49
- }),
47
+ findOne: (recordId) => wrapSdkCall(integrationId, className, 'findOne', typeof recordId === 'string' ? { id: recordId } : recordId),
50
48
  create: (data) => wrapSdkCall(integrationId, className, 'create', data),
51
- update: (recordId, data) => wrapSdkCall(integrationId, className, 'update', {
52
- id: recordId,
53
- ...data,
54
- }),
49
+ update: (recordId, data) => {
50
+ if (typeof recordId === 'object') {
51
+ return wrapSdkCall(integrationId, className, 'update', recordId);
52
+ }
53
+ return wrapSdkCall(integrationId, className, 'update', {
54
+ id: recordId,
55
+ ...(data && 'record' in data ? data.record : data),
56
+ });
57
+ },
55
58
  delete: (recordId) => wrapSdkCall(integrationId, className, 'delete', {
56
59
  id: typeof recordId === 'string' ? recordId : recordId.id,
57
60
  }),
@@ -23,7 +23,7 @@ const FIELD_TYPE_MAP = {
23
23
  date: 'string',
24
24
  datetime: 'string',
25
25
  attachments: 'Array<{ url: string; name?: string }>',
26
- linked_record: 'string[]',
26
+ linked_record: 'string | string[]',
27
27
  lookup: 'unknown',
28
28
  autonumber: 'number',
29
29
  source: 'string',
@@ -84,8 +84,8 @@ function generateDbTs(base, schema, integrationId = 'databases') {
84
84
  const propName = toCamelCase(table.name);
85
85
  lines.push(` ${propName}: createTableClient<${className}RecordType>('${integrationId}', '${className}'),`);
86
86
  }
87
- lines.push(" executeSql: (params: { query: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }>,");
88
- lines.push(" db: { executeSql: (params: { query: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }> },");
87
+ lines.push(" executeSql: (params: { query?: string; sql?: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }>,");
88
+ lines.push(" db: { executeSql: (params: { query?: string; sql?: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }> },");
89
89
  lines.push('};');
90
90
  lines.push('');
91
91
  return lines.join('\n');
@@ -120,7 +120,7 @@ function generateDbDts(base, schema) {
120
120
  const propName = toCamelCase(table.name);
121
121
  lines.push(` ${propName}: TableClient<${className}RecordType>;`);
122
122
  }
123
- lines.push(' executeSql: (params: { query: string; params?: unknown[] }) => Promise<{ rows: Record<string, unknown>[] }>;');
123
+ lines.push(' executeSql: (params: { query?: string; sql?: string; params?: unknown[] }) => Promise<{ rows: Record<string, unknown>[] }>;');
124
124
  lines.push('};');
125
125
  lines.push('');
126
126
  return lines.join('\n');
@@ -21,6 +21,7 @@ export interface EndpointConfig<TInput = unknown, TOutput = unknown> {
21
21
  inputSchema?: SchemaLike<TInput>;
22
22
  outputSchema?: SchemaLike<TOutput>;
23
23
  stream?: boolean;
24
+ authenticated?: boolean;
24
25
  execute: (params: {
25
26
  input: TInput;
26
27
  context: ZiteRequestContext | ZiteScheduledContext;
@@ -11,9 +11,19 @@ export interface TableClient<T> {
11
11
  total: number;
12
12
  hasMore: boolean;
13
13
  }>;
14
- findOne(recordId: string): Promise<T>;
15
- create(data: Partial<T>): Promise<T>;
16
- update(recordId: string, data: Partial<T>): Promise<T>;
14
+ findOne(recordId: string | {
15
+ filters?: unknown;
16
+ filter?: unknown;
17
+ }): Promise<T>;
18
+ create(data: Partial<T> | {
19
+ record: Partial<T>;
20
+ }): Promise<T>;
21
+ update(recordId: string | {
22
+ id: string;
23
+ record?: Partial<T>;
24
+ }, data?: Partial<T> | {
25
+ record: Partial<T>;
26
+ }): Promise<T>;
17
27
  delete(recordId: string | {
18
28
  id: string;
19
29
  }): Promise<{
@@ -39,14 +39,17 @@ export async function wrapSdkCall(integrationId, className, methodName, params)
39
39
  export function createTableClient(integrationId, className) {
40
40
  return {
41
41
  findAll: (options) => wrapSdkCall(integrationId, className, 'findAll', options),
42
- findOne: (recordId) => wrapSdkCall(integrationId, className, 'findOne', {
43
- id: recordId,
44
- }),
42
+ findOne: (recordId) => wrapSdkCall(integrationId, className, 'findOne', typeof recordId === 'string' ? { id: recordId } : recordId),
45
43
  create: (data) => wrapSdkCall(integrationId, className, 'create', data),
46
- update: (recordId, data) => wrapSdkCall(integrationId, className, 'update', {
47
- id: recordId,
48
- ...data,
49
- }),
44
+ update: (recordId, data) => {
45
+ if (typeof recordId === 'object') {
46
+ return wrapSdkCall(integrationId, className, 'update', recordId);
47
+ }
48
+ return wrapSdkCall(integrationId, className, 'update', {
49
+ id: recordId,
50
+ ...(data && 'record' in data ? data.record : data),
51
+ });
52
+ },
50
53
  delete: (recordId) => wrapSdkCall(integrationId, className, 'delete', {
51
54
  id: typeof recordId === 'string' ? recordId : recordId.id,
52
55
  }),
@@ -15,7 +15,7 @@ const FIELD_TYPE_MAP = {
15
15
  date: 'string',
16
16
  datetime: 'string',
17
17
  attachments: 'Array<{ url: string; name?: string }>',
18
- linked_record: 'string[]',
18
+ linked_record: 'string | string[]',
19
19
  lookup: 'unknown',
20
20
  autonumber: 'number',
21
21
  source: 'string',
@@ -76,8 +76,8 @@ export function generateDbTs(base, schema, integrationId = 'databases') {
76
76
  const propName = toCamelCase(table.name);
77
77
  lines.push(` ${propName}: createTableClient<${className}RecordType>('${integrationId}', '${className}'),`);
78
78
  }
79
- lines.push(" executeSql: (params: { query: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }>,");
80
- lines.push(" db: { executeSql: (params: { query: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }> },");
79
+ lines.push(" executeSql: (params: { query?: string; sql?: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }>,");
80
+ lines.push(" db: { executeSql: (params: { query?: string; sql?: string; params?: unknown[] }) => wrapSdkCall('databases', 'Db', 'executeSql', params) as Promise<{ rows: Record<string, unknown>[] }> },");
81
81
  lines.push('};');
82
82
  lines.push('');
83
83
  return lines.join('\n');
@@ -112,7 +112,7 @@ export function generateDbDts(base, schema) {
112
112
  const propName = toCamelCase(table.name);
113
113
  lines.push(` ${propName}: TableClient<${className}RecordType>;`);
114
114
  }
115
- lines.push(' executeSql: (params: { query: string; params?: unknown[] }) => Promise<{ rows: Record<string, unknown>[] }>;');
115
+ lines.push(' executeSql: (params: { query?: string; sql?: string; params?: unknown[] }) => Promise<{ rows: Record<string, unknown>[] }>;');
116
116
  lines.push('};');
117
117
  lines.push('');
118
118
  return lines.join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/runtime/index.js",