@wix/himalaya-cli 0.1429.0 → 0.1431.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.
Binary file
@@ -4,7 +4,7 @@ This page takes an agent from a [Base44](https://base44.com) app to a running Hi
4
4
  uses that app's backend, with the himi CLI alone:
5
5
 
6
6
  ```
7
- himi base44 analyze → himi init --template base44-starter → one list + detail per entity → himi test → himi run / Himi Player
7
+ himi base44 analyze → himi init --template base44-starter → himi base44 adopt → one list + detail per entity → himi test → himi run / Himi Player
8
8
  ```
9
9
 
10
10
  The Base44 app keeps its data, its users and its backend functions. The Himi app is a native UI
@@ -81,6 +81,24 @@ himi run --content . # web preview — the Tasks tab lis
81
81
  If your app has no `Task` entity, the Tasks tab shows its error state with Base44's own message.
82
82
  That is expected: you are about to replace it.
83
83
 
84
+ ### Declare the entities the app uses
85
+
86
+ Turn the book's entities and functions into an adopted declaration, then wire it into `config.ts`:
87
+
88
+ ```bash
89
+ himi base44 adopt --content . --book ../.himi/base44-book --write # the book step 1 wrote, one level up → base44-entities.ts (never overwrites)
90
+ ```
91
+
92
+ ```ts
93
+ import { base44Entities, base44Functions } from "./base44-entities.js";
94
+ // …
95
+ base44: { appId: "<id>", entities: base44Entities, functions: base44Functions },
96
+ ```
97
+
98
+ `himi validate` then lints the declaration (`pass: "base44"`), and `himi base44 entities query`
99
+ reports row counts and schema drift against the live app. See
100
+ [`base44-entities`](base44-entities.md) (`himi docs base44-entities`).
101
+
84
102
  ## 3. Plan the screens from the book
85
103
 
86
104
  Write `.himi/screen-plan.md` before editing code. For each entity in `book.entities`:
@@ -0,0 +1,150 @@
1
+ # Base44 entities and functions (declare, lint, adopt, query)
2
+
3
+ A Himi app on [Base44](https://base44.com) names the entities and backend functions it depends on
4
+ in `config.ts`. With that declaration, `himi validate` lints it, `himi base44 adopt` writes it from
5
+ a book, and `himi base44 entities query` reports row counts and schema drift against the live app.
6
+
7
+ This is the Base44 sibling of [`cms-collections`](cms-collections.md) (`himi docs cms-collections`).
8
+ It reuses the same ideas (owned versus adopted, an offline lint, a read-only drift report) but not
9
+ the same block: Base44 field types, access rules and naming differ from Wix Data.
10
+
11
+ > **Read-only in this release.** Nothing here writes to a Base44 app. Creating schemas, seeding
12
+ > rows and deploying functions come next (see [Coming next](#coming-next)).
13
+
14
+ ## The block
15
+
16
+ ```ts
17
+ import { defineApp } from "@wix/himalaya/core";
18
+ import { base44Entities, base44Functions } from "./base44-entities.js";
19
+
20
+ export default defineApp({
21
+ // …
22
+ capabilities: ["base44"],
23
+ base44: {
24
+ appId: "69725232345f461f64ad1623",
25
+ entities: [
26
+ ...base44Entities, // ADOPTED: the Base44 app's own entities
27
+ { name: "Note", fields: [{ key: "body", type: "string" }], seed: [{ body: "Hello" }] }, // OWNED
28
+ ],
29
+ functions: [...base44Functions, { name: "importCsv" }],
30
+ },
31
+ });
32
+ ```
33
+
34
+ Each entity is one of two kinds:
35
+
36
+ | Kind | Declared by | Physical entity | himi may |
37
+ |---|---|---|---|
38
+ | **Owned** | `name: "Note"` (alphanumeric) | `Himi<AppPascal>Note`. For app `todo` that is `HimiTodoNote`, and for `video-courses` it is `HimiVideoCoursesNote` | create, seed (coming next) |
39
+ | **Adopted** | `base44Name: "Customer"` | `Customer`, verbatim | read only |
40
+
41
+ Base44 entity names are alphanumeric only, so the CMS `himi_<app>_` prefix cannot be used. The
42
+ owned prefix is `Himi` plus the app slug in PascalCase, where each `[a-z0-9]+` run is capitalized.
43
+
44
+ With no separator available, two himi apps bound to the **same** Base44 app can have overlapping
45
+ prefixes (`todo` → `HimiTodo`, `todo-list` → `HimiTodoList`). Give apps that share one Base44 app
46
+ slugs that are not prefixes of each other.
47
+
48
+ An entity's fields are JSON Schema properties:
49
+
50
+ ```ts
51
+ { key: "status", type: "string", enum: ["open", "done"], default: "open" }
52
+ { key: "due", type: "string", format: "date-time" }
53
+ { key: "tags", type: "array", items: { type: "string" } }
54
+ { key: "notes", type: "string", rls: { read: { user_condition: { role: "admin" } } } }
55
+ ```
56
+
57
+ - `type`: one of `string`, `number`, `integer`, `boolean`, `array` or `object`.
58
+ - `format` (strings only): one of `date`, `date-time`, `time`, `email`, `uri`, `uuid`, `file` or `richtext`.
59
+ - Entity- and field-level `rls` is the Base44 rule, verbatim. himi does not reinterpret it.
60
+ - Do not declare the built-in fields (`id`, `created_date`, `updated_date`, `created_by`,
61
+ `created_by_id`). Base44 adds them to every row.
62
+
63
+ A function is owned (`name`, with its source under `base44/functions/<name>/`) or adopted
64
+ (`base44Name`, an existing backend function that is invoked only).
65
+
66
+ The types are exported from `@wix/himalaya/core` (`@himalaya/core` in this repo):
67
+ `Base44EntitySpec`, `Base44FieldSpec` and `Base44FunctionSpec`.
68
+
69
+ ## The lint
70
+
71
+ `defineApp` throws on the first error, so a bad block fails at load time, just as a bad `appId`
72
+ does. `himi validate` and `himi push` report every finding with `pass: "base44"`, beside the
73
+ `pass: "cms"` findings, and `--strict` promotes warnings to errors. Each finding carries a stable
74
+ `ruleCode`:
75
+
76
+ | `ruleCode` | Severity | Fires when |
77
+ |---|---|---|
78
+ | `entity-name-invalid` | error | the `name` or `base44Name` is not alphanumeric (starting with a letter) |
79
+ | `entity-owned-and-adopted` | error | the entity has both `name` and `base44Name` |
80
+ | `entity-neither-owned-nor-adopted` | error | the entity has neither |
81
+ | `entity-duplicate` | error | two declarations resolve to one physical entity |
82
+ | `adopted-in-owned-namespace` | error | a `base44Name` starts with the app's own `Himi<AppPascal>` prefix |
83
+ | `field-builtin` | error | a built-in field is declared |
84
+ | `field-duplicate` | error | a field key appears twice |
85
+ | `field-type-unsupported` | error | a field `type` (or an array's `items.type`) is not in the list above |
86
+ | `field-format-invalid` | error | a `format` is unsupported or set on a non-string field |
87
+ | `display-field-unknown` | error | `displayField` names no field |
88
+ | `required-unknown` | error | `required` names an undeclared field |
89
+ | `seed-on-adopted` | error | an adopted entity declares `seed`. himi never writes to entities it does not own |
90
+ | `seed-key-unknown` | error | a seed row sets an undeclared field |
91
+ | `function-name-invalid` | error | a function name is not letters, digits, `-` or `_` |
92
+ | `function-owned-and-adopted` / `function-neither-owned-nor-adopted` | error | as for entities |
93
+ | `function-duplicate` | error | a function is declared twice |
94
+ | `shape-invalid` | error | a list or entry has the wrong JSON shape |
95
+ | `read-rule-user-scoped` | warning | `rls.read` names the signed-in user (`{{user.…}}`), so a signed-out viewer sees an empty list |
96
+
97
+ ## `himi base44 adopt`: write the declaration from a book
98
+
99
+ ```bash
100
+ himi base44 analyze --app-id <id> # → .himi/base44-book/book.json
101
+ himi base44 adopt # print base44-entities.ts
102
+ himi base44 adopt --write # write it next to config.ts
103
+ himi base44 adopt --entities Job,Customer --json # a subset, as JSON
104
+ ```
105
+
106
+ `adopt` maps each book entity to `{ base44Name, title, fields, required, rls }` and each function
107
+ to `{ base44Name }`. It drops a field it cannot declare (such as a `$ref` type or a built-in) and
108
+ lists it under `skipped[]` with the reason, so nothing disappears silently. The module exports
109
+ `base44Entities` and `base44Functions`, each one `satisfies` its spec type, and passes the lint
110
+ with zero errors.
111
+
112
+ `adopt` never edits `config.ts`, because a generated module is reviewable and an edit to
113
+ hand-written TypeScript is not. It also never overwrites an existing file (`code:
114
+ "adopt_target_exists"`). Add one line to `config.ts` yourself.
115
+
116
+ ## `himi base44 entities query`: drift and counts (read-only)
117
+
118
+ ```bash
119
+ himi base44 entities query --content . # needs `himi base44 login` (or BASE44_ACCESS_TOKEN)
120
+ himi base44 entities query --all # also name the foreign entities
121
+ ```
122
+
123
+ For each declared entity it reports:
124
+
125
+ - `ownership`: `owned` or `adopted`;
126
+ - `rows`: counted by paging `GET …/entities/<E>?fields=id&limit=500`, up to 5000 rows. Past that
127
+ cap it reports `capped: true`, and `rows` is a floor. Base44 lists have no total;
128
+ - `drift` against the live schema: `missing`, `missing-field`, `extra-field` or `type-mismatch`
129
+ (the same vocabulary as `himi cms query`). It also reports an informational `rls-mismatch` when
130
+ the declared `rls` differs from the live one.
131
+
132
+ `foreign` lists the live entities the config does not declare. It is a count by default and the
133
+ names with `--all`.
134
+
135
+ Base44 has no REST read for entity schemas, so the live schemas come from the project download
136
+ (the read half of `base44 eject`, the same request `himi base44 analyze` makes). This needs an
137
+ owner or editor session. When that read fails, the report says `sourceRead: "unavailable"` (with
138
+ `code: "source_unavailable"`), computes no drift, and still counts rows. Every call the command
139
+ makes is a `GET`.
140
+
141
+ Failure codes are listed in [`himi-json-output`](himi-json-output.md#himi-base44-entities-codes).
142
+
143
+ ## Coming next
144
+
145
+ - **Provisioning**: `create`, `seed` and `functions deploy` for owned entities and functions. It
146
+ consumes `diffEntityFields` and the `Base44QueryReport`. Base44's schema write is a destructive
147
+ full-set sync, which is why it is a separate, deliberate step.
148
+ - **Typed clients and hermetic test data**: `entities<"X">()` typed from the declaration, with
149
+ `seed` rows as mocks.
150
+ - **Generated screens**: list and detail screens per declared entity.
@@ -219,6 +219,36 @@ redirects, invalid data, source changes and disk errors remain failures.
219
219
  and the original failure is preserved if writing the failure manifest also fails
220
220
  (exit 1).
221
221
 
222
+ ## `himi base44 entities` codes
223
+
224
+ Covers `himi base44 adopt` and `himi base44 entities query` (#4557,
225
+ [base44-entities](base44-entities.md)). Failures print `ok: false` and `code` on stderr.
226
+
227
+ - `book_unreadable`: `adopt` could not read `<book>/book.json`, or it is not a Base44 app
228
+ book. Run `himi base44 analyze --app-id <id>` first (exit 1).
229
+ - `unknown_entity`: `adopt --entities` names an entity the book does not have; `known` lists
230
+ the book's entities (exit 2).
231
+ - `adopt_target_exists`: `adopt --write` refused to overwrite an existing file; `path` names
232
+ it (exit 1).
233
+ - `adopt_lint_errors`: the generated declaration would fail `himi validate`; `issues[]`
234
+ carries each `ruleCode`. Adopt only emits what the lint accepts, so this means a bug in
235
+ `adopt` (exit 1).
236
+ - `unknown_subcommand`: `himi base44 entities` was given no subcommand, or one other than
237
+ `query` (exit 2).
238
+ - `config_unloadable`: `entities query` could not load `config.ts` (exit 1).
239
+ - `invalid_config`: the `base44` block has lint errors; `issues[]` carries each one's
240
+ `ruleCode` (exit 1). `himi validate` reports the same findings with `pass: "base44"`.
241
+ - `not_signed_in`: `entities query` needs a Base44 session: `himi base44 login`, or
242
+ `BASE44_ACCESS_TOKEN` (exit 2).
243
+
244
+ Two codes ride on a **successful** envelope (`ok: true`, stdout, exit 0), so a consumer can
245
+ branch on them without parsing prose:
246
+
247
+ - `no_base44_block`: the config has no `base44` block, so there was nothing to query.
248
+ `declared` is `0`, matching `himi cms query`.
249
+ - `source_unavailable`: the project download (the eject read) failed, so no drift was
250
+ computed. Row counts still ran; `sourceRead` is `"unavailable"` and `sourceError` says why.
251
+
222
252
  ## Follow-ups
223
253
 
224
254
  - Migrate failure envelopes in subcommands other than `push`, keeping this contract.
package/guides/index.json CHANGED
@@ -270,6 +270,12 @@
270
270
  "category": "CLI & Loop",
271
271
  "file": "base44-app-to-himi-app.md"
272
272
  },
273
+ {
274
+ "id": "base44-entities",
275
+ "title": "Base44 entities and functions (declare, lint, adopt, query)",
276
+ "category": "CLI & Loop",
277
+ "file": "base44-entities.md"
278
+ },
273
279
  {
274
280
  "id": "headless-business-to-himi-app",
275
281
  "title": "From Wix Headless / Back Office → a native Himi app",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1429.0",
3
+ "version": "0.1431.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -71,5 +71,5 @@
71
71
  "artifactId": "himalaya-cli"
72
72
  }
73
73
  },
74
- "falconPackageHash": "b4d2420d483886e1ce73160edcfdc6a91646977229bb741920a0ea2f"
74
+ "falconPackageHash": "cb6ae1657ee30165de2fe500a05d3f531ee3a61071976c6db531172e"
75
75
  }