@wix/himalaya-cli 0.1430.0 → 0.1432.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/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/data-resources/src/base44/ownership.d.ts +38 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/data-resources/src/base44/schema.d.ts +65 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/data-resources/src/schema.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/base44/src/index.d.ts +17 -9
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/base44-entities.d.ts +8 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +12 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +209 -26
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/data-resources.mjs +184 -1
- package/dist/cli.mjs +3614 -2613
- package/guides/base44-app-context.md +2 -2
- package/guides/base44-app-to-himi-app.md +38 -3
- package/guides/base44-entities.md +150 -0
- package/guides/himi-json-output.md +30 -0
- package/guides/himi-test.md +10 -0
- package/guides/index.json +6 -0
- package/guides/sdk-reference.json +4 -4
- package/package.json +2 -2
|
@@ -1,3 +1,176 @@
|
|
|
1
|
+
// ../../core/data-resources/src/base44/schema.ts
|
|
2
|
+
var BASE44_FIELD_TYPES = ["string", "number", "integer", "boolean", "array", "object"];
|
|
3
|
+
var BASE44_STRING_FORMATS = ["date", "date-time", "time", "email", "uri", "uuid", "file", "richtext"];
|
|
4
|
+
var BASE44_BUILTIN_FIELDS = ["id", "created_date", "updated_date", "created_by", "created_by_id"];
|
|
5
|
+
|
|
6
|
+
// ../../core/data-resources/src/base44/ownership.ts
|
|
7
|
+
function base44Prefix(app) {
|
|
8
|
+
const runs = app.match(/[A-Za-z0-9]+/g) ?? [];
|
|
9
|
+
return `Himi${runs.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("")}`;
|
|
10
|
+
}
|
|
11
|
+
function nonEmpty(value) {
|
|
12
|
+
return typeof value === "string" && value.trim() !== "";
|
|
13
|
+
}
|
|
14
|
+
function isAdoptedEntity(spec) {
|
|
15
|
+
return nonEmpty(spec.base44Name);
|
|
16
|
+
}
|
|
17
|
+
function isOwnedEntity(spec) {
|
|
18
|
+
return !isAdoptedEntity(spec) && nonEmpty(spec.name);
|
|
19
|
+
}
|
|
20
|
+
function physicalEntityName(spec, app) {
|
|
21
|
+
if (isAdoptedEntity(spec)) return spec.base44Name;
|
|
22
|
+
return nonEmpty(spec.name) ? `${base44Prefix(app)}${spec.name}` : "";
|
|
23
|
+
}
|
|
24
|
+
function isOwnedFunction(spec) {
|
|
25
|
+
return !nonEmpty(spec.base44Name) && nonEmpty(spec.name);
|
|
26
|
+
}
|
|
27
|
+
function physicalFunctionName(spec) {
|
|
28
|
+
return nonEmpty(spec.base44Name) ? spec.base44Name : nonEmpty(spec.name) ? spec.name : "";
|
|
29
|
+
}
|
|
30
|
+
var ENTITY_NAME = /^[A-Za-z][A-Za-z0-9]*$/;
|
|
31
|
+
var FUNCTION_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
32
|
+
function label(spec) {
|
|
33
|
+
if (nonEmpty(spec.base44Name)) return spec.base44Name;
|
|
34
|
+
if (nonEmpty(spec.name)) return spec.name;
|
|
35
|
+
return "<unnamed>";
|
|
36
|
+
}
|
|
37
|
+
function userScoped(rule) {
|
|
38
|
+
if (rule === void 0) return false;
|
|
39
|
+
try {
|
|
40
|
+
return (JSON.stringify(rule) ?? "").includes("{{user.");
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function validateBase44Entities(cfg, app) {
|
|
46
|
+
if (!cfg) return [];
|
|
47
|
+
const issues = [];
|
|
48
|
+
const add = (severity, ruleCode, entity, message) => issues.push({ severity, ruleCode, message, ...entity !== void 0 ? { entity } : {} });
|
|
49
|
+
const err = (ruleCode, entity, message) => add("error", ruleCode, entity, message);
|
|
50
|
+
const prefix = base44Prefix(app);
|
|
51
|
+
const types = new Set(BASE44_FIELD_TYPES);
|
|
52
|
+
const formats = new Set(BASE44_STRING_FORMATS);
|
|
53
|
+
const builtins = new Set(BASE44_BUILTIN_FIELDS);
|
|
54
|
+
if (cfg.entities !== void 0 && !Array.isArray(cfg.entities)) err("shape-invalid", void 0, "base44.entities must be an array");
|
|
55
|
+
const seen = /* @__PURE__ */ new Set();
|
|
56
|
+
for (const raw of Array.isArray(cfg.entities) ? cfg.entities : []) {
|
|
57
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
58
|
+
err("shape-invalid", void 0, "every base44 entity declaration must be an object");
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const spec = raw;
|
|
62
|
+
const name = label(spec);
|
|
63
|
+
const rawName = spec.name;
|
|
64
|
+
const rawAdopted = spec.base44Name;
|
|
65
|
+
const hasName = rawName !== void 0;
|
|
66
|
+
const hasAdopted = rawAdopted !== void 0;
|
|
67
|
+
if (hasName && hasAdopted) {
|
|
68
|
+
err("entity-owned-and-adopted", name, "declare either `name` (owned) or `base44Name` (adopted), not both");
|
|
69
|
+
} else if (!hasName && !hasAdopted) {
|
|
70
|
+
err("entity-neither-owned-nor-adopted", name, "needs `name` (owned, namespaced) or `base44Name` (adopted, an entity the Base44 app already has)");
|
|
71
|
+
} else {
|
|
72
|
+
const value = hasName ? rawName : rawAdopted;
|
|
73
|
+
if (typeof value !== "string" || !ENTITY_NAME.test(value)) {
|
|
74
|
+
err("entity-name-invalid", name, `entity ${hasName ? "name" : "base44Name"} ${JSON.stringify(value)} must be alphanumeric and start with a letter \u2014 Base44 entity names allow nothing else`);
|
|
75
|
+
} else if (hasAdopted && value.startsWith(prefix)) {
|
|
76
|
+
err("adopted-in-owned-namespace", name, `adopted entity "${value}" starts with this app's owned prefix "${prefix}" \u2014 himi would treat a foreign entity as its own. Declare it with \`name\` if himi owns it, or rename it.`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const physical = physicalEntityName(spec, app);
|
|
80
|
+
if (physical) {
|
|
81
|
+
if (seen.has(physical)) err("entity-duplicate", name, `duplicate entity "${physical}"`);
|
|
82
|
+
seen.add(physical);
|
|
83
|
+
}
|
|
84
|
+
const keys = /* @__PURE__ */ new Set();
|
|
85
|
+
if (!Array.isArray(spec.fields)) {
|
|
86
|
+
err("shape-invalid", name, "`fields` must be an array");
|
|
87
|
+
} else {
|
|
88
|
+
for (const rawField of spec.fields) {
|
|
89
|
+
if (!rawField || typeof rawField !== "object" || Array.isArray(rawField)) {
|
|
90
|
+
err("shape-invalid", name, "every field declaration must be an object");
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const field = rawField;
|
|
94
|
+
if (typeof field.key !== "string" || !field.key) {
|
|
95
|
+
err("shape-invalid", name, "every field needs a string `key`");
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (builtins.has(field.key)) {
|
|
99
|
+
err("field-builtin", name, `field "${field.key}" is built in \u2014 Base44 adds ${BASE44_BUILTIN_FIELDS.join(", ")} to every row. Remove it from the declaration.`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (keys.has(field.key)) err("field-duplicate", name, `duplicate field key "${field.key}"`);
|
|
103
|
+
keys.add(field.key);
|
|
104
|
+
if (!types.has(field.type)) err("field-type-unsupported", name, `field "${field.key}" has unsupported type ${JSON.stringify(field.type)} \u2014 supported: ${BASE44_FIELD_TYPES.join(", ")}`);
|
|
105
|
+
if (field.format !== void 0) {
|
|
106
|
+
if (field.type !== "string") err("field-format-invalid", name, `field "${field.key}" declares a format but only string fields take one`);
|
|
107
|
+
else if (!formats.has(field.format)) err("field-format-invalid", name, `field "${field.key}" has unsupported format ${JSON.stringify(field.format)} \u2014 supported: ${BASE44_STRING_FORMATS.join(", ")}`);
|
|
108
|
+
}
|
|
109
|
+
if (field.items !== void 0 && (field.type !== "array" || !types.has(field.items?.type))) {
|
|
110
|
+
err("field-type-unsupported", name, field.type !== "array" ? `field "${field.key}" declares \`items\` but only array fields take one` : `field "${field.key}" has unsupported items type ${JSON.stringify(field.items?.type)} \u2014 supported: ${BASE44_FIELD_TYPES.join(", ")}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (spec.displayField !== void 0 && !keys.has(spec.displayField) && !builtins.has(spec.displayField)) {
|
|
115
|
+
err("display-field-unknown", name, `displayField "${spec.displayField}" is not one of the declared fields (${[...keys].join(", ") || "none"})`);
|
|
116
|
+
}
|
|
117
|
+
if (spec.required !== void 0) {
|
|
118
|
+
if (!Array.isArray(spec.required)) err("shape-invalid", name, "`required` must be an array of field keys");
|
|
119
|
+
else for (const key of spec.required) {
|
|
120
|
+
if (!keys.has(key)) err("required-unknown", name, `required field "${key}" is not declared`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (spec.seed !== void 0) {
|
|
124
|
+
if (hasAdopted) {
|
|
125
|
+
err("seed-on-adopted", name, "an adopted entity cannot declare `seed` \u2014 himi never writes to entities it does not own");
|
|
126
|
+
} else if (!Array.isArray(spec.seed)) {
|
|
127
|
+
err("shape-invalid", name, "seed must be an array of row objects");
|
|
128
|
+
} else {
|
|
129
|
+
spec.seed.forEach((row, index) => {
|
|
130
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) {
|
|
131
|
+
err("shape-invalid", name, `seed row ${index} must be an object`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
for (const key of Object.keys(row)) {
|
|
135
|
+
if (!keys.has(key)) err("seed-key-unknown", name, `seed row ${index} sets undeclared field "${key}"`);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (userScoped(spec.rls?.read)) {
|
|
141
|
+
add("warning", "read-rule-user-scoped", name, "rls.read is scoped to the signed-in user ({{user.\u2026}}), so a signed-out viewer sees an empty list. Gate the screen behind a sign-in, or widen the read rule if the rows are public.");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (cfg.functions !== void 0 && !Array.isArray(cfg.functions)) err("shape-invalid", void 0, "base44.functions must be an array");
|
|
145
|
+
const seenFns = /* @__PURE__ */ new Set();
|
|
146
|
+
for (const raw of Array.isArray(cfg.functions) ? cfg.functions : []) {
|
|
147
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
148
|
+
err("shape-invalid", void 0, "every base44 function declaration must be an object");
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const spec = raw;
|
|
152
|
+
const name = label(spec);
|
|
153
|
+
const hasName = spec.name !== void 0;
|
|
154
|
+
const hasAdopted = spec.base44Name !== void 0;
|
|
155
|
+
if (hasName && hasAdopted) {
|
|
156
|
+
err("function-owned-and-adopted", name, "declare either `name` (owned) or `base44Name` (adopted), not both");
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (!hasName && !hasAdopted) {
|
|
160
|
+
err("function-neither-owned-nor-adopted", name, "needs `name` (owned, source under base44/functions/<name>/) or `base44Name` (adopted, an existing backend function)");
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const value = hasName ? spec.name : spec.base44Name;
|
|
164
|
+
if (typeof value !== "string" || !FUNCTION_NAME.test(value)) {
|
|
165
|
+
err("function-name-invalid", name, `function name ${JSON.stringify(value)} must be letters, digits, "-" or "_"`);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (seenFns.has(value)) err("function-duplicate", name, `duplicate function "${value}"`);
|
|
169
|
+
seenFns.add(value);
|
|
170
|
+
}
|
|
171
|
+
return issues;
|
|
172
|
+
}
|
|
173
|
+
|
|
1
174
|
// ../../core/data-resources/src/schema.ts
|
|
2
175
|
var WIX_FIELD_TYPES = [
|
|
3
176
|
"TEXT",
|
|
@@ -41,12 +214,22 @@ var KV_DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
|
|
|
41
214
|
var KV_MAX_VALUE_BYTES = 256 * 1024;
|
|
42
215
|
var KV_MAX_TTL_SECONDS = 365 * 24 * 60 * 60;
|
|
43
216
|
export {
|
|
217
|
+
BASE44_BUILTIN_FIELDS,
|
|
218
|
+
BASE44_FIELD_TYPES,
|
|
219
|
+
BASE44_STRING_FORMATS,
|
|
44
220
|
KV_DEFAULT_MAX_ENTRIES,
|
|
45
221
|
KV_DEFAULT_MAX_VALUE_BYTES,
|
|
46
222
|
KV_MAX_TTL_SECONDS,
|
|
47
223
|
KV_MAX_VALUE_BYTES,
|
|
48
224
|
WIX_FIELD_TYPES,
|
|
225
|
+
base44Prefix,
|
|
226
|
+
isAdoptedEntity,
|
|
227
|
+
isOwnedEntity,
|
|
228
|
+
isOwnedFunction,
|
|
49
229
|
mergeDataResources,
|
|
50
|
-
|
|
230
|
+
physicalEntityName,
|
|
231
|
+
physicalFunctionName,
|
|
232
|
+
provisionedKvSpec,
|
|
233
|
+
validateBase44Entities
|
|
51
234
|
};
|
|
52
235
|
//# sourceMappingURL=data-resources.mjs.map
|