zitejs 0.0.1 → 0.1.0
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/README.md +30 -0
- package/api/index.d.ts +42 -0
- package/api/index.js +13 -0
- package/auth/index.d.ts +23 -0
- package/auth/index.js +8 -0
- package/db/index.d.ts +34 -0
- package/db/index.js +23 -0
- package/package.json +42 -9
- package/pdf/index.d.ts +15 -0
- package/pdf/index.js +6 -0
- package/schedules/index.d.ts +19 -0
- package/schedules/index.js +12 -0
- package/upload/index.d.ts +11 -0
- package/upload/index.js +4 -0
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# zitejs
|
|
2
|
+
|
|
3
|
+
The Zite framework package. Provides typed access to your Zite Database, API endpoints, authentication, and more.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
// Database client (generated per-project by `zite sync`)
|
|
9
|
+
import { zite } from 'zitejs/db';
|
|
10
|
+
const users = await zite.users.findMany();
|
|
11
|
+
|
|
12
|
+
// Define API endpoints
|
|
13
|
+
import { createEndpoint, ZiteError } from 'zitejs/api';
|
|
14
|
+
export default createEndpoint({
|
|
15
|
+
execute: async ({ input }) => { ... },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Authentication
|
|
19
|
+
import { useAuth } from 'zitejs/auth';
|
|
20
|
+
const { user } = useAuth();
|
|
21
|
+
|
|
22
|
+
// File uploads
|
|
23
|
+
import { useUpload } from 'zitejs/upload';
|
|
24
|
+
|
|
25
|
+
// PDF generation
|
|
26
|
+
import { ZitePdf } from 'zitejs/pdf';
|
|
27
|
+
|
|
28
|
+
// Scheduled tasks
|
|
29
|
+
import { ZiteSchedule } from 'zitejs/schedules';
|
|
30
|
+
```
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zitejs/api — Server-side endpoint definition.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { createEndpoint, ZiteError } from 'zitejs/api';
|
|
6
|
+
*
|
|
7
|
+
* export default createEndpoint({
|
|
8
|
+
* description: 'Get user by ID',
|
|
9
|
+
* inputSchema: z.object({ id: z.string() }),
|
|
10
|
+
* outputSchema: z.object({ name: z.string() }),
|
|
11
|
+
* execute: async ({ input }) => {
|
|
12
|
+
* const user = await zite.users.findOne(input.id);
|
|
13
|
+
* return { name: user.name };
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface ZiteRequestContext {
|
|
19
|
+
userId?: string;
|
|
20
|
+
organizationId?: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ZiteScheduledContext extends ZiteRequestContext {
|
|
25
|
+
scheduledAt: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare class ZiteError extends Error {
|
|
29
|
+
constructor(message: string, options?: { statusCode?: number });
|
|
30
|
+
statusCode: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare function createEndpoint<TInput = unknown, TOutput = unknown>(config: {
|
|
34
|
+
description?: string;
|
|
35
|
+
inputSchema?: unknown;
|
|
36
|
+
outputSchema?: unknown;
|
|
37
|
+
stream?: boolean;
|
|
38
|
+
execute: (params: {
|
|
39
|
+
input: TInput;
|
|
40
|
+
context: ZiteRequestContext | ZiteScheduledContext;
|
|
41
|
+
}) => Promise<TOutput> | TOutput;
|
|
42
|
+
}): unknown;
|
package/api/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// zitejs/api — runtime stub.
|
|
2
|
+
// The actual implementations are injected by the Zite sandbox at runtime.
|
|
3
|
+
export class ZiteError extends Error {
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'ZiteError';
|
|
7
|
+
this.statusCode = options?.statusCode ?? 500;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createEndpoint(config) {
|
|
12
|
+
return config;
|
|
13
|
+
}
|
package/auth/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zitejs/auth — Authentication helpers.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { useAuth } from 'zitejs/auth';
|
|
6
|
+
* const { user, isLoading } = useAuth();
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface ZiteUser {
|
|
10
|
+
id: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare function useAuth(): {
|
|
17
|
+
user: ZiteUser | null;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
authLoading: boolean;
|
|
20
|
+
logout: () => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export declare function getCurrentUser(): ZiteUser | null;
|
package/auth/index.js
ADDED
package/db/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zitejs/db — The database client.
|
|
3
|
+
*
|
|
4
|
+
* The `zite` object is generated per-project by `zite sync` and provides
|
|
5
|
+
* typed access to your Zite Database tables.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { zite } from 'zitejs/db';
|
|
9
|
+
* const users = await zite.users.findMany();
|
|
10
|
+
*
|
|
11
|
+
* The actual `zite` object is generated into `.zite/db.ts` in your project.
|
|
12
|
+
* This module re-exports it. If you see type errors, run `zite sync` to
|
|
13
|
+
* regenerate the client.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export declare const zite: Record<
|
|
17
|
+
string,
|
|
18
|
+
{
|
|
19
|
+
findMany(params?: Record<string, unknown>): Promise<{
|
|
20
|
+
records: Record<string, unknown>[];
|
|
21
|
+
hasMore: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
findOne(id: string): Promise<Record<string, unknown>>;
|
|
24
|
+
create(data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
25
|
+
update(
|
|
26
|
+
id: string,
|
|
27
|
+
data: Record<string, unknown>,
|
|
28
|
+
): Promise<Record<string, unknown>>;
|
|
29
|
+
delete(id: string): Promise<void>;
|
|
30
|
+
bulkCreate(
|
|
31
|
+
items: Record<string, unknown>[],
|
|
32
|
+
): Promise<Record<string, unknown>[]>;
|
|
33
|
+
}
|
|
34
|
+
>;
|
package/db/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// zitejs/db — runtime stub.
|
|
2
|
+
// The actual `zite` object is generated by `zite sync` into .zite/db.ts.
|
|
3
|
+
// This stub exists so the package resolves; the generated code overrides it.
|
|
4
|
+
export const zite = new Proxy(
|
|
5
|
+
{},
|
|
6
|
+
{
|
|
7
|
+
get(_, tableName) {
|
|
8
|
+
const notGenerated = () => {
|
|
9
|
+
throw new Error(
|
|
10
|
+
`zite.${String(tableName)} is not available. Run \`zite sync\` to generate the database client.`,
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
findMany: notGenerated,
|
|
15
|
+
findOne: notGenerated,
|
|
16
|
+
create: notGenerated,
|
|
17
|
+
update: notGenerated,
|
|
18
|
+
delete: notGenerated,
|
|
19
|
+
bulkCreate: notGenerated,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
);
|
package/package.json
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Zite framework — build apps on Zite Database",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./db": {
|
|
8
|
+
"types": "./db/index.d.ts",
|
|
9
|
+
"default": "./db/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./api": {
|
|
12
|
+
"types": "./api/index.d.ts",
|
|
13
|
+
"default": "./api/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./auth": {
|
|
16
|
+
"types": "./auth/index.d.ts",
|
|
17
|
+
"default": "./auth/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./upload": {
|
|
20
|
+
"types": "./upload/index.d.ts",
|
|
21
|
+
"default": "./upload/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./pdf": {
|
|
24
|
+
"types": "./pdf/index.d.ts",
|
|
25
|
+
"default": "./pdf/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./schedules": {
|
|
28
|
+
"types": "./schedules/index.d.ts",
|
|
29
|
+
"default": "./schedules/index.js"
|
|
30
|
+
}
|
|
7
31
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
32
|
+
"files": [
|
|
33
|
+
"db",
|
|
34
|
+
"api",
|
|
35
|
+
"auth",
|
|
36
|
+
"upload",
|
|
37
|
+
"pdf",
|
|
38
|
+
"schedules"
|
|
39
|
+
],
|
|
40
|
+
"keywords": ["zite", "zitejs", "framework", "database", "vibe-coding"],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/zite/zitejs"
|
|
45
|
+
}
|
|
13
46
|
}
|
package/pdf/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zitejs/pdf — PDF generation.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { ZitePdf } from 'zitejs/pdf';
|
|
6
|
+
* const pdf = new ZitePdf();
|
|
7
|
+
* const result = await pdf.generate({ html: '<h1>Hello</h1>' });
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export declare class ZitePdf {
|
|
11
|
+
generate(options: { html: string; [key: string]: unknown }): Promise<{
|
|
12
|
+
url: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
package/pdf/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zitejs/schedules — Scheduled task helpers.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { ZiteSchedule } from 'zitejs/schedules';
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export declare class ZiteSchedule {
|
|
9
|
+
static create(config: {
|
|
10
|
+
name: string;
|
|
11
|
+
cron: string;
|
|
12
|
+
endpoint: string;
|
|
13
|
+
input?: Record<string, unknown>;
|
|
14
|
+
}): Promise<{ id: string }>;
|
|
15
|
+
|
|
16
|
+
static delete(id: string): Promise<void>;
|
|
17
|
+
|
|
18
|
+
static list(): Promise<Array<{ id: string; name: string; cron: string }>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// zitejs/schedules — runtime stub.
|
|
2
|
+
export class ZiteSchedule {
|
|
3
|
+
static async create() {
|
|
4
|
+
throw new Error('ZiteSchedule is not available outside the Zite sandbox.');
|
|
5
|
+
}
|
|
6
|
+
static async delete() {
|
|
7
|
+
throw new Error('ZiteSchedule is not available outside the Zite sandbox.');
|
|
8
|
+
}
|
|
9
|
+
static async list() {
|
|
10
|
+
throw new Error('ZiteSchedule is not available outside the Zite sandbox.');
|
|
11
|
+
}
|
|
12
|
+
}
|
package/upload/index.js
ADDED
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|