@olenbetong/appframe-vite 6.3.1 → 6.3.3

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
@@ -148,6 +148,16 @@ dataObjects:
148
148
  permissions: IUD
149
149
  output: src/data/dsSubsidiaryLedger.ts
150
150
 
151
+ - id: dsProjectLocations
152
+ resource: aviw_Accounting_ProjectsLocations
153
+ global: true
154
+ types: true
155
+ master: dsProjects
156
+ linkFields:
157
+ - Domain
158
+ - ProjectID
159
+ output: src/data/dsProjectLocations.ts
160
+
151
161
  procedures:
152
162
  - id: procCreateCustomer
153
163
  resource: astp_Accounting_SubsidiaryLedger_Create
@@ -183,6 +193,8 @@ procedures:
183
193
 
184
194
  A top-level `server` key can override the hostname (defaults to `appframe.proxy.hostname` from `package.json`).
185
195
 
196
+ **Master/child relationships:** set both `master` and `linkFields` on the child object. The generated data object will include `masterDataObject` and `linkFields` in the `generateApiDataObject(...)` options.
197
+
186
198
  ## `@olenbetong/appframe-vite/resources` export
187
199
 
188
200
  Shared code generation utilities for Node.js consumers:
@@ -198,4 +210,3 @@ import {
198
210
  } from "@olenbetong/appframe-vite/resources";
199
211
  ```
200
212
 
201
-
@@ -1,11 +1,32 @@
1
1
  import { mkdir, writeFile } from "node:fs/promises";
2
- import { dirname, resolve } from "node:path";
2
+ import { dirname, relative, resolve, sep } from "node:path";
3
3
  import { Client } from "@olenbetong/appframe-data";
4
4
  import { config } from "dotenv";
5
5
  import { getLoginInfo } from "./devServer.js";
6
6
  import { fetchAndGenerate, formatWithBiome } from "./resourceGenerate.js";
7
7
  import { entryToCLIOptions, readResourcesConfig } from "./resourcesConfig.js";
8
8
  config({ quiet: true });
9
+ /**
10
+ * If `entry.master` is a bare ID (no colon), look it up in the data objects list and
11
+ * inject the relative import path so the generator emits the correct import statement.
12
+ */
13
+ function resolveMasterImport(entry, allDataObjects) {
14
+ if (!entry.master || entry.master.includes(":")) {
15
+ return entry;
16
+ }
17
+ let masterId = entry.master;
18
+ let masterEntry = allDataObjects.find((e) => e.id === masterId);
19
+ if (!masterEntry) {
20
+ return entry;
21
+ }
22
+ let thisOutputPath = resolve(process.cwd(), entry.output ?? `src/data/${entry.id}.ts`);
23
+ let masterOutputPath = resolve(process.cwd(), masterEntry.output ?? `src/data/${masterEntry.id}.ts`);
24
+ let rel = relative(dirname(thisOutputPath), masterOutputPath).replace(/\.ts$/, "").split(sep).join("/");
25
+ if (!rel.startsWith(".")) {
26
+ rel = `./${rel}`;
27
+ }
28
+ return { ...entry, master: `${masterId}:${rel}` };
29
+ }
9
30
  export async function generateFromConfig(configPath) {
10
31
  let { hostname, username, password } = await getLoginInfo();
11
32
  let resourcesConfig = await readResourcesConfig(configPath);
@@ -20,8 +41,10 @@ export async function generateFromConfig(configPath) {
20
41
  let client = new Client(hostname);
21
42
  await client.login(username, password);
22
43
  let errors = [];
44
+ let allDataObjects = resourcesConfig.dataObjects ?? [];
23
45
  for (let { entry } of allEntries) {
24
- let options = entryToCLIOptions(entry, resourcesConfig.server ?? hostname);
46
+ let resolvedEntry = resolveMasterImport(entry, allDataObjects);
47
+ let options = entryToCLIOptions(resolvedEntry, resourcesConfig.server ?? hostname);
25
48
  options.output = resolve(process.cwd(), entry.output ?? `src/data/${entry.id}.ts`);
26
49
  try {
27
50
  let content = await fetchAndGenerate(entry.resource, options, client);
@@ -140,12 +140,18 @@ async function handleApi(req, res, apiPath, hostname, next) {
140
140
  }
141
141
  if (method === "PUT" && id) {
142
142
  const updates = req.body;
143
+ if (!updates.id || !updates.resource || !updates.output) {
144
+ return sendJson(res, 400, { error: "id, resource, and output are required for updates" });
145
+ }
146
+ if (updates.id !== id) {
147
+ return sendJson(res, 400, { error: "Renaming resource id is not supported" });
148
+ }
143
149
  const config = await readResourcesConfig();
144
150
  let found = false;
145
151
  for (const list of [config.dataObjects ?? [], config.procedures ?? []]) {
146
152
  const idx = list.findIndex((e) => e.id === id);
147
153
  if (idx !== -1) {
148
- list[idx] = { ...list[idx], ...updates };
154
+ list[idx] = updates;
149
155
  found = true;
150
156
  break;
151
157
  }
@@ -436,7 +436,7 @@ ${fieldTypes}}`;
436
436
  }
437
437
  dsOptions.push(`id: "${options.id}"`);
438
438
  if (options.master && options.linkFields) {
439
- dsOptions.push(`masterDataObject: ${options.master.split(":")[0]}`);
439
+ dsOptions.push(`masterDataObject: ${options.master.split(":")[0]} as any`);
440
440
  let fields = options.linkFields.split(",");
441
441
  linkFields = `linkFields: {\n\t\t${fields
442
442
  .map((field) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-vite",
3
- "version": "6.3.1",
3
+ "version": "6.3.3",
4
4
  "description": "Tools to use and deploy Vite applications to Appframe",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -30,10 +30,10 @@
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
32
  "@olenbetong/appframe-data": "1.5.0",
33
- "body-parser": "^2.2.2",
34
- "chalk": "^5.6.2",
33
+ "body-parser": "^2.3.0",
34
+ "chalk": "5.6.2",
35
35
  "chokidar": "^5.0.0",
36
- "commander": "^14.0.3",
36
+ "commander": "15.0.0",
37
37
  "dotenv": "^17.4.2",
38
38
  "fuzzy": "^0.1.3",
39
39
  "inquirer": "^13.4.3",
@@ -41,13 +41,13 @@
41
41
  "jsdom": "29.1.1",
42
42
  "rollup-plugin-visualizer": "^7.0.1",
43
43
  "yaml": "^2.9.0",
44
- "@olenbetong/appframe-devtools": "0.2.0"
44
+ "@olenbetong/appframe-devtools": "0.3.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/jsdom": "^27.0.0",
48
- "@types/node": "25.9.1",
48
+ "@types/node": "25.9.3",
49
49
  "typescript": "6.0.3",
50
- "vite": "8.0.14"
50
+ "vite": "8.0.16"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "vite": ">=5.0.0"