@oondemand/oon-core-front 0.3.41 → 0.3.43

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/bin/cli.js CHANGED
@@ -16,21 +16,49 @@
16
16
 
17
17
  import path from "node:path";
18
18
  import fs from "node:fs";
19
+ import { createRequire } from "node:module";
19
20
  import { spawnSync } from "node:child_process";
20
21
 
21
22
  const cmd = process.argv[2];
22
23
  const cwd = process.cwd();
23
24
 
25
+ function resolveViteEntry() {
26
+ const projectRequire = createRequire(path.join(cwd, "package.json"));
27
+ const vitePackageJson = projectRequire.resolve("vite/package.json");
28
+ const entry = path.join(path.dirname(vitePackageJson), "bin", "vite.js");
29
+
30
+ if (!fs.existsSync(entry)) {
31
+ throw new Error(`Entrada do Vite não encontrada em ${entry}.`);
32
+ }
33
+
34
+ return entry;
35
+ }
36
+
24
37
  function runVite(args) {
25
- const bin = path.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "vite.cmd" : "vite");
26
- const exec = fs.existsSync(bin) ? bin : "vite";
27
- const r = spawnSync(exec, args, { stdio: "inherit", cwd });
28
- if (r.error) {
29
- console.error("Falha ao executar vite:", r.error.message);
38
+ let entry;
39
+
40
+ try {
41
+ entry = resolveViteEntry();
42
+ } catch (error) {
43
+ const message = error instanceof Error ? error.message : String(error);
44
+ console.error("Falha ao localizar vite:", message);
30
45
  console.error("Instale o vite no projeto da Central: npm i -D vite");
31
46
  process.exit(1);
32
47
  }
33
- process.exit(r.status || 0);
48
+
49
+ // Executar o arquivo JavaScript do Vite pelo próprio Node evita o EINVAL
50
+ // do spawnSync ao tentar abrir diretamente vite.cmd no Windows.
51
+ const result = spawnSync(process.execPath, [entry, ...args], {
52
+ stdio: "inherit",
53
+ cwd,
54
+ });
55
+
56
+ if (result.error) {
57
+ console.error("Falha ao executar vite:", result.error.message);
58
+ process.exit(1);
59
+ }
60
+
61
+ process.exit(result.status ?? 0);
34
62
  }
35
63
 
36
64
  function readEnv(name) {
package/dist/index.d.ts CHANGED
@@ -776,6 +776,55 @@ declare function manifestToConfig(manifest: CentralUiManifest, runtime: Manifest
776
776
  */
777
777
  declare function startFromManifest(manifest: CentralUiManifest, runtime: ManifestRuntime): void;
778
778
 
779
+ type OonDomainExpressionOperator = "add" | "subtract" | "multiply" | "divide" | "min" | "max" | "abs" | "negate" | "coalesce" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "and" | "or" | "not" | "present" | "in";
780
+ type OonDomainExpression = {
781
+ value: unknown;
782
+ } | {
783
+ field: string;
784
+ } | {
785
+ op: OonDomainExpressionOperator;
786
+ args: OonDomainExpression[];
787
+ };
788
+ interface OonComputedFieldDefinition {
789
+ expression: OonDomainExpression;
790
+ precision?: number;
791
+ nullAsZero?: boolean;
792
+ }
793
+ interface OonReactiveFormField {
794
+ field: string;
795
+ kind?: string;
796
+ readonly?: boolean;
797
+ computed?: OonComputedFieldDefinition;
798
+ }
799
+ interface ReactiveFormulaResult {
800
+ values: Record<string, string>;
801
+ errors: Record<string, string>;
802
+ }
803
+ declare class DomainExpressionError extends Error {
804
+ readonly code: string;
805
+ readonly field?: string;
806
+ constructor(message: string, options?: {
807
+ code?: string;
808
+ field?: string;
809
+ });
810
+ }
811
+ /**
812
+ * Avalia exatamente a mesma AST fechada aceita pelo backend. Esta função é
813
+ * somente uma prévia de UX; o backend recalcula e valida toda mutação.
814
+ */
815
+ declare function evaluateDomainExpression(expression: OonDomainExpression, record?: Record<string, unknown>, context?: {
816
+ field?: string;
817
+ nullAsZero?: boolean;
818
+ }): unknown;
819
+ declare function coerceDomainFormValue(value: string, kind?: string): unknown;
820
+ /** Recalcula a cadeia de campos computed para exibição imediata no formulário. */
821
+ declare function applyReactiveFormulas(fields: OonReactiveFormField[], currentValues: Record<string, string>): ReactiveFormulaResult;
822
+ /**
823
+ * Remove campos controlados pelo servidor. O backend recebe somente entradas do
824
+ * usuário e recalcula novamente os valores computed antes de persistir.
825
+ */
826
+ declare function buildDomainMutationPayload(fields: OonReactiveFormField[], values: Record<string, string>): Record<string, unknown>;
827
+
779
828
  /**
780
829
  * Helpers declarativos (API pública da Seção 4.3). São identidades tipadas que
781
830
  * fixam o `type` da view — servem para o autocomplete e para registrar a view
@@ -1028,4 +1077,4 @@ declare function useCoreMetadata(): _tanstack_react_query.UseQueryResult<NoInfer
1028
1077
  /** Descrição de uma model específica — base do modo "dynamic". */
1029
1078
  declare function useModelSchema(name: string): _tanstack_react_query.UseQueryResult<NoInfer<ModelSummary>, Error>;
1030
1079
 
1031
- export { type CentralFormFieldDef, type CentralUiManifest, type CollectionMode, type CollectionViewDef, CoreActions, CoreAssistant, CoreCards, CoreCollection, CoreCurrency, CoreDashboard, CoreDataGrid, CoreDocument, CoreEmptyState, CoreField, CoreForm, CoreIntegration, CoreLoadingState, type CoreMetadata, CorePage, CorePageHeader, CorePipeline, CoreRelationField, CoreToolbar, type DashboardViewDef, type DashboardWidgetDef, type DocumentViewDef, type FieldKind, type FieldMeta, type ListParams, type ManifestRuntime, type ModelSummary, type OonActionDef, type OonApiConfig, type OonAppConfig, type OonAppKind, type OonAuthConfig, type OonAuthMode, type OonBlockDef, type OonColumnDef, type OonComponentRegistry, type OonCoreFrontConfig, type OonError, type OonFormFieldDef, type OonLayoutConfig, type OonMenuItem, type OonModule, type OonNavigationConfig, type OonNavigationMode, type OonPageDef, type OonPipelineActionDef, type OonPipelineActionGroup, type OonPipelineActionTone, type OonPipelineDefaultActionsConfig, type OonPipelineDefaultActionsDef, type OonPipelineTicketModalConfig, type OonPipelineViewDef, type OonRoute, type OonSchemaVersion, type OonSecurityConfig, type OonUiManifest, type OonUser, type OonViewDefinition, type PaginatedResult, type Pagination, PermissionGate, type PipelineViewDef, defineCollectionView, defineDashboard, defineDocumentView, defineOonModule, definePipelineView, manifestToConfig, oonCoreFront, start, startFromManifest, useCoreMetadata, useModelSchema, useOonApi, useOonAuth, useOonResource };
1080
+ export { type CentralFormFieldDef, type CentralUiManifest, type CollectionMode, type CollectionViewDef, CoreActions, CoreAssistant, CoreCards, CoreCollection, CoreCurrency, CoreDashboard, CoreDataGrid, CoreDocument, CoreEmptyState, CoreField, CoreForm, CoreIntegration, CoreLoadingState, type CoreMetadata, CorePage, CorePageHeader, CorePipeline, CoreRelationField, CoreToolbar, type DashboardViewDef, type DashboardWidgetDef, type DocumentViewDef, DomainExpressionError, type FieldKind, type FieldMeta, type ListParams, type ManifestRuntime, type ModelSummary, type OonActionDef, type OonApiConfig, type OonAppConfig, type OonAppKind, type OonAuthConfig, type OonAuthMode, type OonBlockDef, type OonColumnDef, type OonComponentRegistry, type OonComputedFieldDefinition, type OonCoreFrontConfig, type OonDomainExpression, type OonDomainExpressionOperator, type OonError, type OonFormFieldDef, type OonLayoutConfig, type OonMenuItem, type OonModule, type OonNavigationConfig, type OonNavigationMode, type OonPageDef, type OonPipelineActionDef, type OonPipelineActionGroup, type OonPipelineActionTone, type OonPipelineDefaultActionsConfig, type OonPipelineDefaultActionsDef, type OonPipelineTicketModalConfig, type OonPipelineViewDef, type OonReactiveFormField, type OonRoute, type OonSchemaVersion, type OonSecurityConfig, type OonUiManifest, type OonUser, type OonViewDefinition, type PaginatedResult, type Pagination, PermissionGate, type PipelineViewDef, type ReactiveFormulaResult, applyReactiveFormulas, buildDomainMutationPayload, coerceDomainFormValue, defineCollectionView, defineDashboard, defineDocumentView, defineOonModule, definePipelineView, evaluateDomainExpression, manifestToConfig, oonCoreFront, start, startFromManifest, useCoreMetadata, useModelSchema, useOonApi, useOonAuth, useOonResource };