zitejs 0.9.70 → 0.9.73
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/dist/cjs/api/index.js +5 -0
- package/dist/cjs/db/index.js +5 -0
- package/dist/cjs/runtime/index.d.ts +3 -3
- package/dist/cjs/sync/lib.js +3 -1
- package/dist/cjs/types/fields.js +2 -1
- package/dist/cjs/vite/index.d.ts +2 -0
- package/dist/cjs/vite/index.js +88 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/api/index.js +1 -0
- package/dist/esm/cli.js +0 -0
- package/dist/esm/db/index.d.ts +2 -0
- package/dist/esm/db/index.js +1 -0
- package/dist/esm/runtime/index.d.ts +3 -3
- package/dist/esm/sync/lib.js +3 -1
- package/dist/esm/types/fields.js +2 -1
- package/dist/esm/vite/index.d.ts +2 -0
- package/dist/esm/vite/index.js +82 -0
- package/package.json +17 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCaller = void 0;
|
|
4
|
+
var index_js_1 = require("../caller/index.js");
|
|
5
|
+
Object.defineProperty(exports, "createCaller", { enumerable: true, get: function () { return index_js_1.createCaller; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTableClient = void 0;
|
|
4
|
+
var index_js_1 = require("../runtime/index.js");
|
|
5
|
+
Object.defineProperty(exports, "createTableClient", { enumerable: true, get: function () { return index_js_1.createTableClient; } });
|
|
@@ -73,7 +73,7 @@ export interface AirtableTableClient<T> {
|
|
|
73
73
|
}): Promise<T | undefined>;
|
|
74
74
|
create(params: {
|
|
75
75
|
record: Partial<T>;
|
|
76
|
-
}): Promise<T
|
|
76
|
+
}): Promise<T>;
|
|
77
77
|
bulkCreate(params: {
|
|
78
78
|
records: Partial<T>[];
|
|
79
79
|
}): Promise<T[]>;
|
|
@@ -82,8 +82,8 @@ export interface AirtableTableClient<T> {
|
|
|
82
82
|
record: Partial<T>;
|
|
83
83
|
}): Promise<{
|
|
84
84
|
id: string;
|
|
85
|
-
fields: T
|
|
86
|
-
}
|
|
85
|
+
fields: Partial<T>;
|
|
86
|
+
}>;
|
|
87
87
|
delete(params: {
|
|
88
88
|
id: string;
|
|
89
89
|
}): Promise<DeleteResult>;
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -320,7 +320,9 @@ function generateDbTs(schema) {
|
|
|
320
320
|
lines.push("// The tsconfig aliases resolve zitejs/* imports to the correct .zite/ files.");
|
|
321
321
|
lines.push("//");
|
|
322
322
|
lines.push("// Table client methods (all take a single params object):");
|
|
323
|
-
lines.push("// .findAll({ filters?, offset?, limit?, fields? }) → { records: T[], hasMore: boolean }");
|
|
323
|
+
lines.push("// .findAll({ filters?, sort?, offset?, limit?, fields? }) → { records: T[], hasMore: boolean }");
|
|
324
|
+
lines.push("// filters: { fieldName: value } for equality, { fieldName: { contains|gt|lt|gte|lte: value } } for operators");
|
|
325
|
+
lines.push("// sort: [{ field: 'fieldName', direction: 'asc' | 'desc' }]");
|
|
324
326
|
lines.push("// .findOne({ id?, filters?, fields? }) → T | undefined");
|
|
325
327
|
lines.push("// .create({ record }) → T");
|
|
326
328
|
lines.push("// .update({ id, record }) → { id: string, fields: Partial<T> }");
|
package/dist/cjs/types/fields.js
CHANGED
|
@@ -134,7 +134,8 @@ exports.ratingTemplateSchema = zod_1.z.object({
|
|
|
134
134
|
});
|
|
135
135
|
exports.durationTemplateSchema = zod_1.z.object({
|
|
136
136
|
format: zod_1.z.enum(exports.durationFormatEnum),
|
|
137
|
-
|
|
137
|
+
// Stored as seconds in a DECIMAL column; may be fractional.
|
|
138
|
+
defaultValue: zod_1.z.number().min(0).optional(),
|
|
138
139
|
});
|
|
139
140
|
exports.percentTemplateSchema = zod_1.z.object({
|
|
140
141
|
decimalPlaces: zod_1.z.number().min(0),
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ziteId = ziteId;
|
|
7
|
+
const parser_1 = require("@babel/parser");
|
|
8
|
+
const magic_string_1 = __importDefault(require("magic-string"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const estree_walker_1 = require("estree-walker");
|
|
11
|
+
const validExtensions = new Set([".jsx", ".tsx"]);
|
|
12
|
+
function getComponentName(elementName) {
|
|
13
|
+
if (elementName.type === "JSXIdentifier") {
|
|
14
|
+
return elementName.name;
|
|
15
|
+
}
|
|
16
|
+
if (elementName.type === "JSXMemberExpression") {
|
|
17
|
+
const object = getComponentName(elementName.object);
|
|
18
|
+
const property = elementName.property.name;
|
|
19
|
+
return object ? `${object}.${property}` : property;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function isNativeElement(name) {
|
|
24
|
+
return /^[a-z]/.test(name) && !name.includes(".");
|
|
25
|
+
}
|
|
26
|
+
function ziteId() {
|
|
27
|
+
const cwd = process.cwd();
|
|
28
|
+
return {
|
|
29
|
+
name: "vite-plugin-zite-id",
|
|
30
|
+
enforce: "pre",
|
|
31
|
+
async transform(code, id) {
|
|
32
|
+
if (!validExtensions.has(path_1.default.extname(id)) ||
|
|
33
|
+
id.includes("node_modules")) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const relativePath = path_1.default.relative(cwd, id);
|
|
37
|
+
try {
|
|
38
|
+
const ast = (0, parser_1.parse)(code, {
|
|
39
|
+
sourceType: "module",
|
|
40
|
+
plugins: ["jsx", "typescript"],
|
|
41
|
+
});
|
|
42
|
+
const magicString = new magic_string_1.default(code);
|
|
43
|
+
(0, estree_walker_1.walk)(ast, {
|
|
44
|
+
enter(_node) {
|
|
45
|
+
const node = _node;
|
|
46
|
+
if (node.type === "JSXElement") {
|
|
47
|
+
const openingElement = node.openingElement;
|
|
48
|
+
const children = node.children;
|
|
49
|
+
const elementName = openingElement.name;
|
|
50
|
+
const isFragment = (elementName.type === "JSXMemberExpression" &&
|
|
51
|
+
elementName.object.name === "React" &&
|
|
52
|
+
elementName.property.name === "Fragment") ||
|
|
53
|
+
(elementName.type === "JSXIdentifier" &&
|
|
54
|
+
elementName.name === "Fragment");
|
|
55
|
+
if (isFragment) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const line = openingElement.loc?.start?.line ?? 0;
|
|
59
|
+
const col = openingElement.loc?.start?.column ?? 0;
|
|
60
|
+
const dataComponentId = `${relativePath}|${line}|${col}`;
|
|
61
|
+
let attributes = ` data-zite-id="${dataComponentId}"`;
|
|
62
|
+
const componentName = getComponentName(openingElement.name);
|
|
63
|
+
if (componentName && !isNativeElement(componentName)) {
|
|
64
|
+
attributes += ` data-zite-component="${componentName}"`;
|
|
65
|
+
}
|
|
66
|
+
if (children.length === 1 &&
|
|
67
|
+
(children[0].type === "JSXText" ||
|
|
68
|
+
children[0].type === "StringLiteral" ||
|
|
69
|
+
(children[0].type === "JSXExpressionContainer" &&
|
|
70
|
+
children[0].expression.type === "StringLiteral"))) {
|
|
71
|
+
attributes += ` data-zite-editable="true"`;
|
|
72
|
+
}
|
|
73
|
+
magicString.appendLeft(openingElement.name.end ?? 0, attributes);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
code: magicString.toString(),
|
|
79
|
+
map: magicString.generateMap({ hires: true }),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(`Error processing file ${relativePath}:`, error);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCaller } from '../caller/index.js';
|
package/dist/esm/cli.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTableClient } from '../runtime/index.js';
|
|
@@ -73,7 +73,7 @@ export interface AirtableTableClient<T> {
|
|
|
73
73
|
}): Promise<T | undefined>;
|
|
74
74
|
create(params: {
|
|
75
75
|
record: Partial<T>;
|
|
76
|
-
}): Promise<T
|
|
76
|
+
}): Promise<T>;
|
|
77
77
|
bulkCreate(params: {
|
|
78
78
|
records: Partial<T>[];
|
|
79
79
|
}): Promise<T[]>;
|
|
@@ -82,8 +82,8 @@ export interface AirtableTableClient<T> {
|
|
|
82
82
|
record: Partial<T>;
|
|
83
83
|
}): Promise<{
|
|
84
84
|
id: string;
|
|
85
|
-
fields: T
|
|
86
|
-
}
|
|
85
|
+
fields: Partial<T>;
|
|
86
|
+
}>;
|
|
87
87
|
delete(params: {
|
|
88
88
|
id: string;
|
|
89
89
|
}): Promise<DeleteResult>;
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -308,7 +308,9 @@ export function generateDbTs(schema) {
|
|
|
308
308
|
lines.push("// The tsconfig aliases resolve zitejs/* imports to the correct .zite/ files.");
|
|
309
309
|
lines.push("//");
|
|
310
310
|
lines.push("// Table client methods (all take a single params object):");
|
|
311
|
-
lines.push("// .findAll({ filters?, offset?, limit?, fields? }) → { records: T[], hasMore: boolean }");
|
|
311
|
+
lines.push("// .findAll({ filters?, sort?, offset?, limit?, fields? }) → { records: T[], hasMore: boolean }");
|
|
312
|
+
lines.push("// filters: { fieldName: value } for equality, { fieldName: { contains|gt|lt|gte|lte: value } } for operators");
|
|
313
|
+
lines.push("// sort: [{ field: 'fieldName', direction: 'asc' | 'desc' }]");
|
|
312
314
|
lines.push("// .findOne({ id?, filters?, fields? }) → T | undefined");
|
|
313
315
|
lines.push("// .create({ record }) → T");
|
|
314
316
|
lines.push("// .update({ id, record }) → { id: string, fields: Partial<T> }");
|
package/dist/esm/types/fields.js
CHANGED
|
@@ -131,7 +131,8 @@ export const ratingTemplateSchema = z.object({
|
|
|
131
131
|
});
|
|
132
132
|
export const durationTemplateSchema = z.object({
|
|
133
133
|
format: z.enum(durationFormatEnum),
|
|
134
|
-
|
|
134
|
+
// Stored as seconds in a DECIMAL column; may be fractional.
|
|
135
|
+
defaultValue: z.number().min(0).optional(),
|
|
135
136
|
});
|
|
136
137
|
export const percentTemplateSchema = z.object({
|
|
137
138
|
decimalPlaces: z.number().min(0),
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
2
|
+
import MagicString from "magic-string";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { walk } from "estree-walker";
|
|
5
|
+
const validExtensions = new Set([".jsx", ".tsx"]);
|
|
6
|
+
function getComponentName(elementName) {
|
|
7
|
+
if (elementName.type === "JSXIdentifier") {
|
|
8
|
+
return elementName.name;
|
|
9
|
+
}
|
|
10
|
+
if (elementName.type === "JSXMemberExpression") {
|
|
11
|
+
const object = getComponentName(elementName.object);
|
|
12
|
+
const property = elementName.property.name;
|
|
13
|
+
return object ? `${object}.${property}` : property;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
function isNativeElement(name) {
|
|
18
|
+
return /^[a-z]/.test(name) && !name.includes(".");
|
|
19
|
+
}
|
|
20
|
+
export function ziteId() {
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
return {
|
|
23
|
+
name: "vite-plugin-zite-id",
|
|
24
|
+
enforce: "pre",
|
|
25
|
+
async transform(code, id) {
|
|
26
|
+
if (!validExtensions.has(path.extname(id)) ||
|
|
27
|
+
id.includes("node_modules")) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const relativePath = path.relative(cwd, id);
|
|
31
|
+
try {
|
|
32
|
+
const ast = parse(code, {
|
|
33
|
+
sourceType: "module",
|
|
34
|
+
plugins: ["jsx", "typescript"],
|
|
35
|
+
});
|
|
36
|
+
const magicString = new MagicString(code);
|
|
37
|
+
walk(ast, {
|
|
38
|
+
enter(_node) {
|
|
39
|
+
const node = _node;
|
|
40
|
+
if (node.type === "JSXElement") {
|
|
41
|
+
const openingElement = node.openingElement;
|
|
42
|
+
const children = node.children;
|
|
43
|
+
const elementName = openingElement.name;
|
|
44
|
+
const isFragment = (elementName.type === "JSXMemberExpression" &&
|
|
45
|
+
elementName.object.name === "React" &&
|
|
46
|
+
elementName.property.name === "Fragment") ||
|
|
47
|
+
(elementName.type === "JSXIdentifier" &&
|
|
48
|
+
elementName.name === "Fragment");
|
|
49
|
+
if (isFragment) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const line = openingElement.loc?.start?.line ?? 0;
|
|
53
|
+
const col = openingElement.loc?.start?.column ?? 0;
|
|
54
|
+
const dataComponentId = `${relativePath}|${line}|${col}`;
|
|
55
|
+
let attributes = ` data-zite-id="${dataComponentId}"`;
|
|
56
|
+
const componentName = getComponentName(openingElement.name);
|
|
57
|
+
if (componentName && !isNativeElement(componentName)) {
|
|
58
|
+
attributes += ` data-zite-component="${componentName}"`;
|
|
59
|
+
}
|
|
60
|
+
if (children.length === 1 &&
|
|
61
|
+
(children[0].type === "JSXText" ||
|
|
62
|
+
children[0].type === "StringLiteral" ||
|
|
63
|
+
(children[0].type === "JSXExpressionContainer" &&
|
|
64
|
+
children[0].expression.type === "StringLiteral"))) {
|
|
65
|
+
attributes += ` data-zite-editable="true"`;
|
|
66
|
+
}
|
|
67
|
+
magicString.appendLeft(openingElement.name.end ?? 0, attributes);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
code: magicString.toString(),
|
|
73
|
+
map: magicString.generateMap({ hires: true }),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error(`Error processing file ${relativePath}:`, error);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.73",
|
|
4
4
|
"description": "The Zite framework — build apps on Zite Database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -76,6 +76,12 @@
|
|
|
76
76
|
"types": "./dist/esm/sync/index.d.ts",
|
|
77
77
|
"import": "./dist/esm/sync/index.js",
|
|
78
78
|
"require": "./dist/cjs/sync/index.js"
|
|
79
|
+
},
|
|
80
|
+
"./vite-plugin": {
|
|
81
|
+
"types": "./dist/esm/vite/index.d.ts",
|
|
82
|
+
"import": "./dist/esm/vite/index.js",
|
|
83
|
+
"require": "./dist/cjs/vite/index.js",
|
|
84
|
+
"default": "./dist/esm/vite/index.js"
|
|
79
85
|
}
|
|
80
86
|
},
|
|
81
87
|
"scripts": {
|
|
@@ -125,12 +131,16 @@
|
|
|
125
131
|
],
|
|
126
132
|
"meta": [
|
|
127
133
|
"dist/esm/meta/index.d.ts"
|
|
134
|
+
],
|
|
135
|
+
"vite-plugin": [
|
|
136
|
+
"dist/esm/vite/index.d.ts"
|
|
128
137
|
]
|
|
129
138
|
}
|
|
130
139
|
},
|
|
131
140
|
"peerDependencies": {
|
|
132
141
|
"@tanstack/react-query": ">=5",
|
|
133
|
-
"react": ">=18"
|
|
142
|
+
"react": ">=18",
|
|
143
|
+
"vite": ">=5"
|
|
134
144
|
},
|
|
135
145
|
"peerDependenciesMeta": {
|
|
136
146
|
"react": {
|
|
@@ -138,6 +148,9 @@
|
|
|
138
148
|
},
|
|
139
149
|
"@tanstack/react-query": {
|
|
140
150
|
"optional": true
|
|
151
|
+
},
|
|
152
|
+
"vite": {
|
|
153
|
+
"optional": true
|
|
141
154
|
}
|
|
142
155
|
},
|
|
143
156
|
"devDependencies": {
|
|
@@ -164,6 +177,8 @@
|
|
|
164
177
|
"@babel/parser": "^7.29.7",
|
|
165
178
|
"dotenv": "^17.4.2",
|
|
166
179
|
"esbuild": "^0.28.0",
|
|
180
|
+
"estree-walker": "^3.0.3",
|
|
181
|
+
"magic-string": "^0.30.17",
|
|
167
182
|
"zod": "^4.1.12"
|
|
168
183
|
}
|
|
169
184
|
}
|