talizen 0.2.5 → 0.2.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.
package/README.md CHANGED
@@ -7,6 +7,7 @@ Talizen's frontend SDK package. It provides a small runtime client and shared ty
7
7
  - `talizen/cms`
8
8
  - `talizen/form`
9
9
  - `talizen/func`
10
+ - `talizen/func-runtime`
10
11
 
11
12
  The package is designed to hold the platform-level APIs that frontend projects use directly, while project-specific CMS and form schema types can still be generated separately per project.
12
13
 
@@ -113,8 +114,13 @@ When a `File` object appears in the payload, `submitForm()` will:
113
114
  ```ts
114
115
  import { currentUser, login, logout, register } from "talizen/auth";
115
116
 
116
- await register({ email: "hi@talizen.com", password: "secret", name: "Alice" });
117
- await login({ email: "hi@talizen.com", password: "secret" });
117
+ await register({
118
+ account: "alice",
119
+ password: "secret",
120
+ name: "Alice",
121
+ email: "hi@talizen.com",
122
+ });
123
+ await login({ account: "alice", password: "secret" });
118
124
 
119
125
  const user = await currentUser();
120
126
  await logout();
@@ -125,24 +131,25 @@ await logout();
125
131
  ```ts
126
132
  import { invoke } from "talizen/func";
127
133
 
128
- const result = await invoke<{ success: boolean }>("user/auth.login", {
134
+ const result = await invoke<{ ok: boolean; id: string }>("booking.create", {
129
135
  email: "hi@talizen.com",
130
- password: "secret",
136
+ date: "2026-07-04",
137
+ time: "10:00",
131
138
  });
132
139
  ```
133
140
 
134
141
  `invoke("<fileKey>.<method>", input)` calls the method exported by the script file. If `.method` is omitted, Talizen calls `main`:
135
142
 
136
143
  ```ts
137
- await invoke("user/auth", { email: "hi@talizen.com" });
144
+ await invoke("booking", { email: "hi@talizen.com" });
138
145
  ```
139
146
 
140
147
  ### Write function runtime code
141
148
 
142
- Func code can use TypeScript and import runtime-only helpers from `talizen/func`:
149
+ Func code can use TypeScript and import runtime-only helpers from `talizen/func-runtime`:
143
150
 
144
151
  ```ts
145
- import { auth, db, cache } from "talizen/func";
152
+ import { auth, db, cache } from "talizen/func-runtime";
146
153
 
147
154
  export function create(input: { title: string }) {
148
155
  const user = auth.requireUser();
@@ -164,7 +171,8 @@ export function create(input: { title: string }) {
164
171
  - `talizen/auth`: project user register, login, logout, and current user helpers.
165
172
  - `talizen/cms`: CMS content types and content query APIs.
166
173
  - `talizen/form`: form submission helpers and related types.
167
- - `talizen/func`: custom function invocation helpers and Func-runtime-only `db`, `cache`, `auth` types.
174
+ - `talizen/func`: custom function invocation helpers such as `invoke`.
175
+ - `talizen/func-runtime`: Func-runtime-only `db`, `cache`, and `auth` types.
168
176
 
169
177
  ## Publish
170
178
 
package/auth.d.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  import { type TalizenRequestOptions } from "./core.js";
2
2
  export interface AuthUser {
3
3
  id: string;
4
+ /**
5
+ * Login identifier for this project user.
6
+ * This does not need to be an email address or phone number.
7
+ */
8
+ account?: string;
9
+ /** Optional contact email/profile field, not the primary login identifier. */
4
10
  email?: string;
11
+ /** Optional contact phone/profile field, not the primary login identifier. */
5
12
  phone?: string;
6
13
  name?: string;
7
14
  avatar?: string;
@@ -13,10 +20,16 @@ export interface AuthUser {
13
20
  updated_at?: string;
14
21
  }
15
22
  export interface AuthPasswordInput {
16
- email: string;
23
+ /**
24
+ * Login identifier for register/login.
25
+ * Do not substitute email or phone unless the user intentionally uses that
26
+ * value as their account.
27
+ */
28
+ account: string;
17
29
  password: string;
18
30
  }
19
31
  export interface AuthRegisterInput extends AuthPasswordInput {
32
+ email?: string;
20
33
  phone?: string;
21
34
  name?: string;
22
35
  avatar?: string;
@@ -0,0 +1,65 @@
1
+ import type { AuthUser } from "./auth.js";
2
+ export type DbOrderBy = string;
3
+ export interface DbFilterCondition {
4
+ field_id?: string;
5
+ fieldId?: string;
6
+ operator: "equal" | "not_equal" | "in";
7
+ value?: unknown;
8
+ values?: unknown[];
9
+ }
10
+ export interface DbFilter {
11
+ match?: "and" | "or";
12
+ conditions?: DbFilterCondition[];
13
+ }
14
+ export interface DbQuery {
15
+ where?: Record<string, unknown>;
16
+ filter?: DbFilter;
17
+ limit?: number;
18
+ offset?: number;
19
+ order_by?: DbOrderBy;
20
+ orderBy?: DbOrderBy;
21
+ }
22
+ export type DbRecord<T extends Record<string, unknown> = Record<string, unknown>> = T & {
23
+ id: string;
24
+ };
25
+ export interface FuncDbRuntime {
26
+ get<T extends Record<string, unknown> = Record<string, unknown>>(table: string, id: string): DbRecord<T> | null;
27
+ query<T extends Record<string, unknown> = Record<string, unknown>>(table: string, query?: DbQuery): Array<DbRecord<T>>;
28
+ insert<T extends Record<string, unknown> = Record<string, unknown>>(table: string, data: T): DbRecord<T>;
29
+ update<T extends Record<string, unknown> = Record<string, unknown>>(table: string, id: string, data: Partial<T>): {
30
+ ok?: boolean;
31
+ updated?: boolean;
32
+ } | DbRecord<T>;
33
+ delete(table: string, id: string): {
34
+ ok?: boolean;
35
+ deleted?: boolean;
36
+ };
37
+ }
38
+ export interface FuncAuthRuntime {
39
+ currentUser(): AuthUser | null;
40
+ requireUser(): AuthUser;
41
+ }
42
+ export interface CacheSetOptions {
43
+ ttl?: number;
44
+ ttlSeconds?: number;
45
+ }
46
+ export interface FuncCacheRuntime {
47
+ get<T = unknown>(key: string): T | null;
48
+ set(key: string, value: unknown, ttlSeconds?: number): {
49
+ ok?: boolean;
50
+ };
51
+ set(key: string, value: unknown, options?: CacheSetOptions): {
52
+ ok?: boolean;
53
+ };
54
+ del(key: string): {
55
+ ok?: boolean;
56
+ deleted?: boolean;
57
+ };
58
+ incr(key: string, delta?: number): number;
59
+ expire(key: string, ttlSeconds: number): {
60
+ ok?: boolean;
61
+ };
62
+ }
63
+ export declare const db: FuncDbRuntime;
64
+ export declare const auth: FuncAuthRuntime;
65
+ export declare const cache: FuncCacheRuntime;
@@ -0,0 +1,21 @@
1
+ function unavailable() {
2
+ throw new Error("talizen/func-runtime is only available inside Talizen Func runtime.");
3
+ }
4
+ export const db = {
5
+ get: unavailable,
6
+ query: unavailable,
7
+ insert: unavailable,
8
+ update: unavailable,
9
+ delete: unavailable,
10
+ };
11
+ export const auth = {
12
+ currentUser: unavailable,
13
+ requireUser: unavailable,
14
+ };
15
+ export const cache = {
16
+ get: unavailable,
17
+ set: unavailable,
18
+ del: unavailable,
19
+ incr: unavailable,
20
+ expire: unavailable,
21
+ };
package/func.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { type TalizenRequestOptions } from "./core.js";
2
- import type { AuthUser } from "./auth.js";
3
2
  export interface FuncLogEntry {
4
3
  level: string;
5
4
  text: string;
@@ -10,70 +9,6 @@ export interface FuncRunResponse<T = unknown> {
10
9
  logs?: FuncLogEntry[];
11
10
  error?: string;
12
11
  }
13
- export type DbOrderBy = string;
14
- export interface DbFilterCondition {
15
- field_id?: string;
16
- fieldId?: string;
17
- operator: "equal" | "not_equal" | "in";
18
- value?: unknown;
19
- values?: unknown[];
20
- }
21
- export interface DbFilter {
22
- match?: "and" | "or";
23
- conditions?: DbFilterCondition[];
24
- }
25
- export interface DbQuery {
26
- where?: Record<string, unknown>;
27
- filter?: DbFilter;
28
- limit?: number;
29
- offset?: number;
30
- order_by?: DbOrderBy;
31
- orderBy?: DbOrderBy;
32
- }
33
- export type DbRecord<T extends Record<string, unknown> = Record<string, unknown>> = T & {
34
- id: string;
35
- };
36
- export interface FuncDbRuntime {
37
- get<T extends Record<string, unknown> = Record<string, unknown>>(table: string, id: string): DbRecord<T> | null;
38
- query<T extends Record<string, unknown> = Record<string, unknown>>(table: string, query?: DbQuery): Array<DbRecord<T>>;
39
- insert<T extends Record<string, unknown> = Record<string, unknown>>(table: string, data: T): DbRecord<T>;
40
- update<T extends Record<string, unknown> = Record<string, unknown>>(table: string, id: string, data: Partial<T>): {
41
- ok?: boolean;
42
- updated?: boolean;
43
- } | DbRecord<T>;
44
- delete(table: string, id: string): {
45
- ok?: boolean;
46
- deleted?: boolean;
47
- };
48
- }
49
- export interface FuncAuthRuntime {
50
- currentUser(): AuthUser | null;
51
- requireUser(): AuthUser;
52
- }
53
- export interface CacheSetOptions {
54
- ttl?: number;
55
- ttlSeconds?: number;
56
- }
57
- export interface FuncCacheRuntime {
58
- get<T = unknown>(key: string): T | null;
59
- set(key: string, value: unknown, ttlSeconds?: number): {
60
- ok?: boolean;
61
- };
62
- set(key: string, value: unknown, options?: CacheSetOptions): {
63
- ok?: boolean;
64
- };
65
- del(key: string): {
66
- ok?: boolean;
67
- deleted?: boolean;
68
- };
69
- incr(key: string, delta?: number): number;
70
- expire(key: string, ttlSeconds: number): {
71
- ok?: boolean;
72
- };
73
- }
74
- export declare const db: FuncDbRuntime;
75
- export declare const auth: FuncAuthRuntime;
76
- export declare const cache: FuncCacheRuntime;
77
12
  export declare class TalizenFuncError extends Error {
78
13
  readonly key: string;
79
14
  readonly method: string;
package/func.js CHANGED
@@ -1,25 +1,4 @@
1
1
  import { requestJson, } from "./core.js";
2
- function funcRuntimeUnavailable() {
3
- throw new Error("talizen/func db/cache/auth are only available inside Talizen Func runtime.");
4
- }
5
- export const db = {
6
- get: funcRuntimeUnavailable,
7
- query: funcRuntimeUnavailable,
8
- insert: funcRuntimeUnavailable,
9
- update: funcRuntimeUnavailable,
10
- delete: funcRuntimeUnavailable,
11
- };
12
- export const auth = {
13
- currentUser: funcRuntimeUnavailable,
14
- requireUser: funcRuntimeUnavailable,
15
- };
16
- export const cache = {
17
- get: funcRuntimeUnavailable,
18
- set: funcRuntimeUnavailable,
19
- del: funcRuntimeUnavailable,
20
- incr: funcRuntimeUnavailable,
21
- expire: funcRuntimeUnavailable,
22
- };
23
2
  export class TalizenFuncError extends Error {
24
3
  key;
25
4
  method;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talizen",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Talizen frontend SDK types for cms, form and core.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,6 +40,10 @@
40
40
  "types": "./func.d.ts",
41
41
  "import": "./func.js"
42
42
  },
43
+ "./func-runtime": {
44
+ "types": "./func-runtime.d.ts",
45
+ "import": "./func-runtime.js"
46
+ },
43
47
  "./i18n": {
44
48
  "types": "./i18n.d.ts",
45
49
  "import": "./i18n.js"