@oondemand/oon-core-back 0.7.14 → 0.7.17

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
@@ -57,6 +57,12 @@ O comando de delivery preserva `central.app.json` em dois pontos da imagem:
57
57
 
58
58
  Centrais legadas sem o manifesto continuam suportadas. O empacotador cria uma pasta intermediária vazia, evitando tornar `central.app.json` obrigatório para aplicações que ainda usam somente `central.config.js`.
59
59
 
60
+ ### `bin/delivery.js deploy` (legado)
61
+
62
+ O subcomando `deploy` de `bin/delivery.js` é legado. Ele provisiona e aplica o runtime diretamente, mas não injeta capabilities no runtime. Não o use em publicações novas; os subcomandos `context` e `state` continuam disponíveis.
63
+
64
+ Na falha de inicialização da imagem, o runtime registra as issues do manifesto, uma por linha, no formato ` - <path>: <mensagem>`, antes da linha `OON_STARTUP_FAILURE`. As mensagens passam pela mesma sanitização do CLI e o stack não é impresso.
65
+
60
66
  ## Rótulos de campos relacionados
61
67
 
62
68
  Por padrão, campos declarados com `fields.ref(...)` continuam sendo devolvidos pelo CRUD como `ObjectId`. Uma model pode optar pela população segura das referências usadas em grids e cards:
package/bin/cli.js CHANGED
@@ -134,4 +134,11 @@ Códigos de saída: ${Object.entries(EXIT_CODES).map(([key, value]) => `${value}
134
134
  }
135
135
  }
136
136
 
137
- main().catch((err) => { console.error(sanitizeMessage(err?.message || err)); process.exit(1); });
137
+ main().catch((err) => {
138
+ console.error(sanitizeMessage(err?.message || err));
139
+ // Manifest errors (e.g. AppManifestError) carry the actionable detail in issues.
140
+ if (Array.isArray(err?.issues)) {
141
+ for (const issue of err.issues) console.error(` - ${issue?.path || "$"}: ${sanitizeMessage(issue?.message)}`);
142
+ }
143
+ process.exit(1);
144
+ });
package/bin/delivery.js CHANGED
@@ -37,6 +37,7 @@ async function main() {
37
37
  });
38
38
  return;
39
39
  }
40
+ // Legado: "deploy" não injeta capabilities no runtime. Ver README.
40
41
  if (command === "deploy") {
41
42
  const contextFile = required(flag("--context"), "--context");
42
43
  const imageDigest = required(flag("--image-digest"), "--image-digest");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oondemand/oon-core-back",
3
- "version": "0.7.14",
3
+ "version": "0.7.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oondemand/oon-platform.git",
@@ -32,6 +32,7 @@ COPY --from=frontend /src/frontend/dist /usr/share/nginx/html
32
32
  COPY .oon-delivery/nginx.conf /etc/nginx/oon.conf
33
33
  COPY .oon-delivery/supervisor.js /supervisor.js
34
34
  COPY .oon-delivery/launchRuntime.js .oon-delivery/validateImage.js /oon-delivery/
35
+ COPY .oon-delivery/errors.js /deploy/contracts/errors.js
35
36
  COPY .oon-delivery/entrypoint.sh /entrypoint.sh
36
37
  RUN chmod +x /entrypoint.sh && mkdir -p /app/backend/uploads /run/nginx && chown -R node:node /app/backend/uploads
37
38
  EXPOSE 8080
@@ -111,6 +112,8 @@ function prepareDeliveryFiles(workspace) {
111
112
  fs.mkdirSync(target, { recursive: true });
112
113
  prepareAppManifest(workspace, target);
113
114
  for (const file of ["supervisor.js", "launchRuntime.js", "validateImage.js"]) fs.copyFileSync(path.join(__dirname, file), path.join(target, file));
115
+ // launchRuntime.js requires ../deploy/contracts/errors (sanitizeMessage).
116
+ fs.copyFileSync(path.join(__dirname, "../deploy/contracts/errors.js"), path.join(target, "errors.js"));
114
117
  fs.writeFileSync(path.join(target, "Dockerfile"), DOCKERFILE);
115
118
  fs.writeFileSync(path.join(target, "nginx.conf"), NGINX);
116
119
  fs.writeFileSync(path.join(target, "entrypoint.sh"), ENTRYPOINT, {
@@ -1,13 +1,31 @@
1
1
  "use strict";
2
2
  const { createRequire } = require("node:module");
3
3
  const { classify } = require("./validateImage");
4
- const runtimeRequire = createRequire("/app/backend/package.json");
5
- // Invoke the public API of the SDK INSIDE the image; do not replace the app's
6
- // dependency version. Include the error class so SyntaxError is not lost by an
7
- // older CLI that prints only error.message. Never print the raw error/stack.
8
- Promise.resolve().then(() => runtimeRequire("@oondemand/oon-core-back").start({ cwd: "/app/backend" }))
9
- .catch((error) => {
10
- const diagnostic = classify(`${error?.name || "Error"}: ${error?.message || ""}`);
11
- console.error(`OON_STARTUP_FAILURE ${JSON.stringify(diagnostic)}`);
12
- process.exit(1);
13
- });
4
+ // Copied next to this file in the image (/deploy/contracts/errors.js) so the
5
+ // same relative path resolves in the repository and inside the image.
6
+ const { sanitizeMessage } = require("../deploy/contracts/errors");
7
+
8
+ // Manifest errors (e.g. AppManifestError) carry the actionable detail in
9
+ // issues. Print only path and sanitized message; never the stack or raw error.
10
+ function startupIssueLines(error) {
11
+ if (!Array.isArray(error?.issues)) return [];
12
+ return error.issues.map((issue) => ` - ${sanitizeMessage(issue?.path || "$")}: ${sanitizeMessage(issue?.message)}`);
13
+ }
14
+
15
+ function launch() {
16
+ const runtimeRequire = createRequire("/app/backend/package.json");
17
+ // Invoke the public API of the SDK INSIDE the image; do not replace the app's
18
+ // dependency version. Include the error class so SyntaxError is not lost by an
19
+ // older CLI that prints only error.message. Never print the raw error/stack.
20
+ Promise.resolve().then(() => runtimeRequire("@oondemand/oon-core-back").start({ cwd: "/app/backend" }))
21
+ .catch((error) => {
22
+ for (const line of startupIssueLines(error)) console.error(line);
23
+ const diagnostic = classify(`${error?.name || "Error"}: ${error?.message || ""}`);
24
+ console.error(`OON_STARTUP_FAILURE ${JSON.stringify(diagnostic)}`);
25
+ process.exit(1);
26
+ });
27
+ }
28
+
29
+ if (require.main === module) launch();
30
+
31
+ module.exports = { startupIssueLines };