@oondemand/oon-core-front 0.3.43 → 0.3.45

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/index.d.ts CHANGED
@@ -776,6 +776,34 @@ declare function manifestToConfig(manifest: CentralUiManifest, runtime: Manifest
776
776
  */
777
777
  declare function startFromManifest(manifest: CentralUiManifest, runtime: ManifestRuntime): void;
778
778
 
779
+ interface CentralAppManifest {
780
+ $schema?: string;
781
+ schemaVersion: 1;
782
+ id: string;
783
+ name: string;
784
+ slug: string;
785
+ appKind: OonAppKind;
786
+ modules: Record<string, boolean>;
787
+ capabilities: string[];
788
+ compatibility: {
789
+ core: {
790
+ minVersion: string;
791
+ maxVersionExclusive?: string;
792
+ };
793
+ };
794
+ activation?: {
795
+ enabled?: boolean;
796
+ configurationVersion?: number;
797
+ fields?: unknown[];
798
+ };
799
+ }
800
+ type CentralUiOnlyManifest = Omit<CentralUiManifest, "name" | "slug" | "appKind" | "auth"> & Partial<Pick<CentralUiManifest, "name" | "slug" | "appKind" | "auth">>;
801
+ interface CentralManifestBundle {
802
+ app: CentralAppManifest;
803
+ ui: CentralUiOnlyManifest;
804
+ }
805
+ declare function startCentralFromManifest(manifest: CentralManifestBundle, runtime: ManifestRuntime): OonCoreFrontConfig;
806
+
779
807
  type OonDomainExpressionOperator = "add" | "subtract" | "multiply" | "divide" | "min" | "max" | "abs" | "negate" | "coalesce" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "and" | "or" | "not" | "present" | "in";
780
808
  type OonDomainExpression = {
781
809
  value: unknown;
@@ -1077,4 +1105,4 @@ declare function useCoreMetadata(): _tanstack_react_query.UseQueryResult<NoInfer
1077
1105
  /** Descrição de uma model específica — base do modo "dynamic". */
1078
1106
  declare function useModelSchema(name: string): _tanstack_react_query.UseQueryResult<NoInfer<ModelSummary>, Error>;
1079
1107
 
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 };
1108
+ export { type CentralAppManifest, type CentralFormFieldDef, type CentralManifestBundle, type CentralUiManifest, type CentralUiOnlyManifest, 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, startCentralFromManifest, startFromManifest, useCoreMetadata, useModelSchema, useOonApi, useOonAuth, useOonResource };
package/dist/index.js CHANGED
@@ -2478,6 +2478,18 @@ function CoreRowAction({ action, row, parent, onOpenDetail, onRefresh, onUpdate
2478
2478
 
2479
2479
  // src/components/internal/CoreRelatedGrid.tsx
2480
2480
  import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
2481
+ function parentValueAt(parent, path) {
2482
+ return path.split(".").reduce((current, part) => {
2483
+ if (!current || typeof current !== "object") return void 0;
2484
+ return current[part];
2485
+ }, parent);
2486
+ }
2487
+ function mergeCreateFields(schemaFields, overrides, foreignKey) {
2488
+ const base = schemaFields.filter((field) => ![foreignKey, "_id", "createdAt", "updatedAt"].includes(field.field));
2489
+ if (!overrides?.length) return base;
2490
+ const byName = new Map(base.map((field) => [field.field, field]));
2491
+ return overrides.map((override) => ({ ...byName.get(override.field) ?? {}, ...override }));
2492
+ }
2481
2493
  function CoreRelatedGrid({
2482
2494
  tab: rawTab,
2483
2495
  parent,
@@ -2502,6 +2514,17 @@ function CoreRelatedGrid({
2502
2514
  () => (tab.columns?.length ? tab.columns : schema?.fields.slice(0, 8).map((field) => field.name) ?? []).map((column) => normalizeColumn(column, schema)).filter((column) => !column.hidden),
2503
2515
  [tab.columns, schema]
2504
2516
  );
2517
+ const schemaFormFields = useMemo5(() => formFieldsFromMeta(schema?.fields ?? []), [schema?.fields]);
2518
+ const createFields = useMemo5(
2519
+ () => mergeCreateFields(schemaFormFields, tab.create?.fields, relation?.foreignKey),
2520
+ [schemaFormFields, tab.create?.fields, relation?.foreignKey]
2521
+ );
2522
+ const createInitialValues = useMemo5(() => {
2523
+ const inherited = Object.fromEntries(
2524
+ Object.entries(tab.create?.initialValuesFromParent ?? {}).map(([field, path]) => [field, parentValueAt(parent, path)])
2525
+ );
2526
+ return { ...tab.create?.initialValues ?? {}, ...inherited };
2527
+ }, [tab.create?.initialValues, tab.create?.initialValuesFromParent, parent]);
2505
2528
  const [drafts, setDrafts] = useState7({});
2506
2529
  const [errors, setErrors] = useState7({});
2507
2530
  const [creating, setCreating] = useState7(false);
@@ -2520,7 +2543,7 @@ function CoreRelatedGrid({
2520
2543
  });
2521
2544
  const createMutation = useMutation({
2522
2545
  mutationFn: (values) => resource.create({
2523
- ...tab.create?.initialValues ?? {},
2546
+ ...createInitialValues,
2524
2547
  ...values,
2525
2548
  ...relation && parentValue != null ? { [relation.foreignKey]: parentValue } : {}
2526
2549
  }),
@@ -2542,7 +2565,6 @@ function CoreRelatedGrid({
2542
2565
  ...current,
2543
2566
  [id]: { ...current[id] ?? {}, [field]: value }
2544
2567
  }));
2545
- const createFields = tab.create?.fields?.length ? tab.create.fields : formFieldsFromMeta(schema?.fields ?? []).filter((field) => ![relation.foreignKey, "_id", "createdAt", "updatedAt"].includes(field.field));
2546
2568
  return /* @__PURE__ */ jsxs9(Box7, { children: [
2547
2569
  canCreate ? /* @__PURE__ */ jsx14(Flex5, { justify: "flex-end", mb: "10px", children: /* @__PURE__ */ jsx14(Button6, { size: "sm", colorPalette: "brand", onClick: () => {
2548
2570
  setCreateError(null);
@@ -2619,7 +2641,7 @@ function CoreRelatedGrid({
2619
2641
  title: tab.create?.label ?? `Novo ${schema?.singular ?? relation.model}`,
2620
2642
  eyebrow: "Registro relacionado",
2621
2643
  fields: createFields,
2622
- initialValues: tab.create?.initialValues,
2644
+ initialValues: createInitialValues,
2623
2645
  submitting: createMutation.isPending,
2624
2646
  error: createError,
2625
2647
  onSubmit: (values) => createMutation.mutate(values),
@@ -5425,6 +5447,31 @@ function startFromManifest(manifest, runtime) {
5425
5447
  start(manifestToConfig(manifest, runtime));
5426
5448
  }
5427
5449
 
5450
+ // src/appManifest.ts
5451
+ function startCentralFromManifest(manifest, runtime) {
5452
+ const legacyCompatibleUi = {
5453
+ ...manifest.ui,
5454
+ name: manifest.app.name,
5455
+ slug: manifest.app.slug,
5456
+ appKind: manifest.app.appKind
5457
+ };
5458
+ const config = manifestToConfig(legacyCompatibleUi, runtime);
5459
+ config.app = {
5460
+ ...config.app,
5461
+ id: manifest.app.id,
5462
+ name: manifest.app.name,
5463
+ title: manifest.app.name,
5464
+ kind: manifest.app.appKind
5465
+ };
5466
+ const app = config.app;
5467
+ app.schemaVersion = manifest.app.schemaVersion;
5468
+ app.modules = manifest.app.modules;
5469
+ app.capabilities = manifest.app.capabilities;
5470
+ app.compatibility = manifest.app.compatibility;
5471
+ start(config);
5472
+ return config;
5473
+ }
5474
+
5428
5475
  // src/define/views.ts
5429
5476
  function defineCollectionView(def) {
5430
5477
  return { type: "collection", ...def };
@@ -5601,6 +5648,7 @@ export {
5601
5648
  manifestToConfig,
5602
5649
  oonCoreFront,
5603
5650
  start,
5651
+ startCentralFromManifest,
5604
5652
  startFromManifest,
5605
5653
  useCoreMetadata,
5606
5654
  useModelSchema,