Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,423 changes: 3,423 additions & 0 deletions platform/packages/sdk/package-lock.json

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions platform/packages/sdk/src/api/index.ts

This file was deleted.

16 changes: 8 additions & 8 deletions platform/packages/sdk/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { HttpClient } from './http.js';
import { MetadataApi } from './api/metadata.js';
import { CrudResourceApi } from './api/crud.js';
import { CrudServiceApi } from './api/crud-service.js';
import { ActionsApi } from './api/actions.js';
import { ReportsApi } from './api/reports.js';
import { FilesApi } from './api/files.js';
import { SaasApi } from './api/saas.js';
import { ScheduleApi } from './api/schedule.js';
import { MetadataApi } from './metadata/api.js';
import { ActionsApi } from './metadata/actions.js';
import { CrudResourceApi } from './cruds/crud-resource.js';
import { CrudServiceApi } from './cruds/crud-service.js';
import { ReportsApi } from './reports/api.js';
import { FilesApi } from './files/api.js';
import { SaasApi } from './saas/api.js';
import { ScheduleApi } from './schedule/api.js';
import type { DynamiaClientConfig } from './types.js';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HttpClient } from '../http.js';
import type { CrudListResult, CrudQueryParams, CrudRawResponse } from '../types.js';
import type { CrudListResult, CrudQueryParams, CrudRawResponse } from './types.js';

/**
* CRUD operations for a single CrudPage resource (navigation-based endpoints).
Expand Down Expand Up @@ -76,4 +76,3 @@ function normaliseCrudResponse<T>(raw: CrudRawResponse<T> | CrudListResult<T>):
totalPages: p?.pagesNumber ?? 1,
};
}

Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ export class CrudServiceApi<T = unknown> {
return this.http.post<string | number>(`${this.basePath}/id`, params);
}
}

8 changes: 8 additions & 0 deletions platform/packages/sdk/src/cruds/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export { CrudResourceApi } from './crud-resource.js';
export { CrudServiceApi } from './crud-service.js';
export type {
CrudPageable,
CrudRawResponse,
CrudListResult,
CrudQueryParams,
} from './types.js';
71 changes: 71 additions & 0 deletions platform/packages/sdk/src/cruds/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ─── CRUD types mirroring the Dynamia Platform Java model ───────────────────

/**
* Maps to Java `DataPaginator` — serialized as the `pageable` field inside `ListResult`.
*
* Java source: `tools.dynamia.domain.query.DataPaginator`
*
* | Java field | Java type | JSON key |
* |-----------------|-----------|----------------|
* | `totalSize` | `long` | `totalSize` |
* | `pageSize` | `int` | `pageSize` |
* | `firstResult` | `int` | `firstResult` |
* | `page` | `int` | `page` |
* | `pagesNumber` | `int` | `pagesNumber` |
*/
export interface CrudPageable {
/** Total number of records across all pages (`DataPaginator.totalSize` — Java `long`) */
totalSize: number;
/** Number of records per page (`DataPaginator.pageSize` — default 30) */
pageSize: number;
/** Zero-based offset of the first record on this page (`DataPaginator.firstResult`) */
firstResult: number;
/** Current 1-based page number (`DataPaginator.page`) */
page: number;
/** Total number of pages (`DataPaginator.pagesNumber`) */
pagesNumber: number;
}

/**
* Raw envelope returned by `RestNavigationContext.ListResult`.
*
* Java source: `tools.dynamia.web.navigation.RestNavigationContext.ListResult`
*
* | Java field | Annotation | JSON key |
* |-------------|------------------------------------|------------|
* | `data` | — | `data` |
* | `pageable` | `@JsonInclude(NON_NULL)` — nullable | `pageable` |
* | `response` | — | `response` |
*
* `pageable` is `null` when the result is not paginated (e.g. a flat list endpoint).
*/
export interface CrudRawResponse<T = unknown> {
/** The page records */
data: T[];
/**
* Pagination metadata. `null` when the response is not paginated
* (`@JsonInclude(JsonInclude.Include.NON_NULL)` in Java — field may be absent from JSON).
*/
pageable: CrudPageable | null;
/** Status string, typically `"OK"` */
response: string;
}

/**
* Normalised result returned by all SDK `CrudResourceApi.findAll()` calls.
* The SDK maps `CrudRawResponse` → `CrudListResult` so consumers never deal with the raw envelope.
*/
export interface CrudListResult<T = unknown> {
/** The records for this page */
content: T[];
/** Total number of records across all pages (`DataPaginator.totalSize`) */
total: number;
/** Current 1-based page number (`DataPaginator.page`) */
page: number;
/** Number of records per page (`DataPaginator.pageSize`) */
pageSize: number;
/** Total number of pages (`DataPaginator.pagesNumber`) */
totalPages: number;
}

export type CrudQueryParams = Record<string, string | number | boolean | undefined | null>;
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ export class FilesApi {
return this.http.url(`/storage/${encodeURIComponent(file)}`, { uuid });
}
}

1 change: 1 addition & 0 deletions platform/packages/sdk/src/files/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { FilesApi } from './api.js';
41 changes: 24 additions & 17 deletions platform/packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ export { DynamiaClient } from './client.js';
// ── Error ────────────────────────────────────────────────────────────────────
export { DynamiaApiError } from './errors.js';

// ── Types ────────────────────────────────────────────────────────────────────
// ── Core types ────────────────────────────────────────────────────────────────
export type { DynamiaClientConfig } from './types.js';

// ── Metadata module ──────────────────────────────────────────────────────────
export { MetadataApi, ActionsApi } from './metadata/index.js';
export type {
DynamiaClientConfig,
// Application
ApplicationMetadata,
// Navigation
Expand All @@ -27,26 +30,30 @@ export type {
ViewDescriptorMetadata,
ViewDescriptor,
ViewField,
// CRUD
} from './metadata/index.js';

// ── CRUD module ───────────────────────────────────────────────────────────────
export { CrudResourceApi, CrudServiceApi } from './cruds/index.js';
export type {
CrudListResult,
CrudQueryParams,
CrudRawResponse,
CrudPageable,
// Reports
} from './cruds/index.js';

// ── Reports module ────────────────────────────────────────────────────────────
export { ReportsApi } from './reports/index.js';
export type {
ReportDTO,
ReportFilter,
ReportFilters,
// SaaS
AccountDTO,
} from './types.js';

// ── API classes (for advanced usage / extension) ─────────────────────────────
export { MetadataApi } from './api/metadata.js';
export { CrudResourceApi } from './api/crud.js';
export { CrudServiceApi } from './api/crud-service.js';
export { ActionsApi } from './api/actions.js';
export { ReportsApi } from './api/reports.js';
export { FilesApi } from './api/files.js';
export { SaasApi } from './api/saas.js';
export { ScheduleApi } from './api/schedule.js';
} from './reports/index.js';

// ── SaaS module ───────────────────────────────────────────────────────────────
export { SaasApi } from './saas/index.js';
export type { AccountDTO } from './saas/index.js';

// ── API classes (files & schedule — core extensions) ─────────────────────────
export { FilesApi } from './files/index.js';
export { ScheduleApi } from './schedule/index.js';

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HttpClient } from '../http.js';
import type { ActionExecutionRequest, ActionExecutionResponse } from '../types.js';
import type { ActionExecutionRequest, ActionExecutionResponse } from './types.js';

/**
* Execute platform actions (global or entity-scoped).
Expand Down Expand Up @@ -37,4 +37,3 @@ export class ActionsApi {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
NavigationTree,
ViewDescriptor,
ViewDescriptorMetadata,
} from '../types.js';
} from './types.js';

/**
* Provides access to application metadata endpoints.
Expand Down Expand Up @@ -57,5 +57,3 @@ export class MetadataApi {
);
}
}


19 changes: 19 additions & 0 deletions platform/packages/sdk/src/metadata/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export { MetadataApi } from './api.js';
export { ActionsApi } from './actions.js';
export type {
BasicMetadata,
ApplicationMetadata,
NavigationTree,
NavigationModule,
NavigationGroup,
NavigationPage,
ApplicationMetadataEntities,
EntityMetadata,
ApplicationMetadataActions,
ActionMetadata,
ActionExecutionRequest,
ActionExecutionResponse,
ViewDescriptorMetadata,
ViewDescriptor,
ViewField,
} from './types.js';
114 changes: 114 additions & 0 deletions platform/packages/sdk/src/metadata/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// ─── Metadata types mirroring the Dynamia Platform Java model ───────────────

// ── Basic / shared ─────────────────────────────────────────────────────────

export interface BasicMetadata {
id: string;
name: string;
endpoint?: string;
description?: string;
icon?: string;
}

// ── Application metadata ───────────────────────────────────────────────────

export interface ApplicationMetadata {
name: string;
version: string;
description?: string;
logo?: string;
url?: string;
modules?: NavigationModule[];
}

// ── Navigation ─────────────────────────────────────────────────────────────

export interface NavigationTree {
modules: NavigationModule[];
}

export interface NavigationModule {
id: string;
name: string;
description?: string;
icon?: string;
groups: NavigationGroup[];
}

export interface NavigationGroup {
id: string;
name: string;
description?: string;
icon?: string;
pages: NavigationPage[];
}

export interface NavigationPage {
id: string;
name: string;
description?: string;
icon?: string;
virtualPath: string;
prettyVirtualPath: string;
pageClass?: string;
}

// ── Entity metadata ────────────────────────────────────────────────────────

export interface ApplicationMetadataEntities {
entities: EntityMetadata[];
}

export interface EntityMetadata extends BasicMetadata {
className: string;
actions: ActionMetadata[];
descriptors: ViewDescriptorMetadata[];
actionsEndpoint: string;
}

// ── Actions ────────────────────────────────────────────────────────────────

export interface ApplicationMetadataActions {
actions: ActionMetadata[];
}

export interface ActionMetadata extends BasicMetadata {
actionClass?: string;
params?: Record<string, unknown>;
}

export interface ActionExecutionRequest {
data?: Record<string, unknown>;
params?: Record<string, unknown>;
}

export interface ActionExecutionResponse {
message: string;
status: string;
code: number;
data?: unknown;
}

// ── View descriptors ───────────────────────────────────────────────────────

export interface ViewDescriptorMetadata {
view: string;
descriptor: ViewDescriptor;
}

export interface ViewDescriptor {
id: string;
beanClass: string;
viewTypeName: string;
fields: ViewField[];
params: Record<string, unknown>;
}

export interface ViewField {
name: string;
fieldClass?: string;
label?: string;
visible?: boolean;
required?: boolean;
params: Record<string, unknown>;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HttpClient } from '../http.js';
import type { ReportDTO, ReportFilters } from '../types.js';
import type { ReportDTO, ReportFilters } from './types.js';

type ReportGetParams = Record<string, string | number | boolean | undefined | null>;

Expand Down Expand Up @@ -35,4 +35,3 @@ export class ReportsApi {
);
}
}

6 changes: 6 additions & 0 deletions platform/packages/sdk/src/reports/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { ReportsApi } from './api.js';
export type {
ReportDTO,
ReportFilter,
ReportFilters,
} from './types.js';
18 changes: 18 additions & 0 deletions platform/packages/sdk/src/reports/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// ─── Reports types mirroring the Dynamia Platform Java model ────────────────

export interface ReportDTO {
id: string;
name: string;
group: string;
endpoint: string;
description?: string;
}

export interface ReportFilter {
name: string;
value: string;
}

export interface ReportFilters {
filters: ReportFilter[];
}
Loading
Loading