Skip to content

Commit 6670fb2

Browse files
Merge pull request #55 from dynamiatools/copilot/organize-modules-and-extensions
refactor(sdk): reorganize src and test into per-module folders
2 parents 46b8f4a + 01809bc commit 6670fb2

File tree

29 files changed

+3886
-430
lines changed

29 files changed

+3886
-430
lines changed

platform/packages/sdk/package-lock.json

Lines changed: 3423 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platform/packages/sdk/src/api/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

platform/packages/sdk/src/client.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { HttpClient } from './http.js';
2-
import { MetadataApi } from './api/metadata.js';
3-
import { CrudResourceApi } from './api/crud.js';
4-
import { CrudServiceApi } from './api/crud-service.js';
5-
import { ActionsApi } from './api/actions.js';
6-
import { ReportsApi } from './api/reports.js';
7-
import { FilesApi } from './api/files.js';
8-
import { SaasApi } from './api/saas.js';
9-
import { ScheduleApi } from './api/schedule.js';
2+
import { MetadataApi } from './metadata/api.js';
3+
import { ActionsApi } from './metadata/actions.js';
4+
import { CrudResourceApi } from './cruds/crud-resource.js';
5+
import { CrudServiceApi } from './cruds/crud-service.js';
6+
import { ReportsApi } from './reports/api.js';
7+
import { FilesApi } from './files/api.js';
8+
import { SaasApi } from './saas/api.js';
9+
import { ScheduleApi } from './schedule/api.js';
1010
import type { DynamiaClientConfig } from './types.js';
1111

1212
/**

platform/packages/sdk/src/api/crud.ts renamed to platform/packages/sdk/src/cruds/crud-resource.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { HttpClient } from '../http.js';
2-
import type { CrudListResult, CrudQueryParams, CrudRawResponse } from '../types.js';
2+
import type { CrudListResult, CrudQueryParams, CrudRawResponse } from './types.js';
33

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

platform/packages/sdk/src/api/crud-service.ts renamed to platform/packages/sdk/src/cruds/crud-service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ export class CrudServiceApi<T = unknown> {
4040
return this.http.post<string | number>(`${this.basePath}/id`, params);
4141
}
4242
}
43-
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export { CrudResourceApi } from './crud-resource.js';
2+
export { CrudServiceApi } from './crud-service.js';
3+
export type {
4+
CrudPageable,
5+
CrudRawResponse,
6+
CrudListResult,
7+
CrudQueryParams,
8+
} from './types.js';
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// ─── CRUD types mirroring the Dynamia Platform Java model ───────────────────
2+
3+
/**
4+
* Maps to Java `DataPaginator` — serialized as the `pageable` field inside `ListResult`.
5+
*
6+
* Java source: `tools.dynamia.domain.query.DataPaginator`
7+
*
8+
* | Java field | Java type | JSON key |
9+
* |-----------------|-----------|----------------|
10+
* | `totalSize` | `long` | `totalSize` |
11+
* | `pageSize` | `int` | `pageSize` |
12+
* | `firstResult` | `int` | `firstResult` |
13+
* | `page` | `int` | `page` |
14+
* | `pagesNumber` | `int` | `pagesNumber` |
15+
*/
16+
export interface CrudPageable {
17+
/** Total number of records across all pages (`DataPaginator.totalSize` — Java `long`) */
18+
totalSize: number;
19+
/** Number of records per page (`DataPaginator.pageSize` — default 30) */
20+
pageSize: number;
21+
/** Zero-based offset of the first record on this page (`DataPaginator.firstResult`) */
22+
firstResult: number;
23+
/** Current 1-based page number (`DataPaginator.page`) */
24+
page: number;
25+
/** Total number of pages (`DataPaginator.pagesNumber`) */
26+
pagesNumber: number;
27+
}
28+
29+
/**
30+
* Raw envelope returned by `RestNavigationContext.ListResult`.
31+
*
32+
* Java source: `tools.dynamia.web.navigation.RestNavigationContext.ListResult`
33+
*
34+
* | Java field | Annotation | JSON key |
35+
* |-------------|------------------------------------|------------|
36+
* | `data` | — | `data` |
37+
* | `pageable` | `@JsonInclude(NON_NULL)` — nullable | `pageable` |
38+
* | `response` | — | `response` |
39+
*
40+
* `pageable` is `null` when the result is not paginated (e.g. a flat list endpoint).
41+
*/
42+
export interface CrudRawResponse<T = unknown> {
43+
/** The page records */
44+
data: T[];
45+
/**
46+
* Pagination metadata. `null` when the response is not paginated
47+
* (`@JsonInclude(JsonInclude.Include.NON_NULL)` in Java — field may be absent from JSON).
48+
*/
49+
pageable: CrudPageable | null;
50+
/** Status string, typically `"OK"` */
51+
response: string;
52+
}
53+
54+
/**
55+
* Normalised result returned by all SDK `CrudResourceApi.findAll()` calls.
56+
* The SDK maps `CrudRawResponse` → `CrudListResult` so consumers never deal with the raw envelope.
57+
*/
58+
export interface CrudListResult<T = unknown> {
59+
/** The records for this page */
60+
content: T[];
61+
/** Total number of records across all pages (`DataPaginator.totalSize`) */
62+
total: number;
63+
/** Current 1-based page number (`DataPaginator.page`) */
64+
page: number;
65+
/** Number of records per page (`DataPaginator.pageSize`) */
66+
pageSize: number;
67+
/** Total number of pages (`DataPaginator.pagesNumber`) */
68+
totalPages: number;
69+
}
70+
71+
export type CrudQueryParams = Record<string, string | number | boolean | undefined | null>;
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ export class FilesApi {
2727
return this.http.url(`/storage/${encodeURIComponent(file)}`, { uuid });
2828
}
2929
}
30-
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { FilesApi } from './api.js';

platform/packages/sdk/src/index.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ export { DynamiaClient } from './client.js';
44
// ── Error ────────────────────────────────────────────────────────────────────
55
export { DynamiaApiError } from './errors.js';
66

7-
// ── Types ────────────────────────────────────────────────────────────────────
7+
// ── Core types ────────────────────────────────────────────────────────────────
8+
export type { DynamiaClientConfig } from './types.js';
9+
10+
// ── Metadata module ──────────────────────────────────────────────────────────
11+
export { MetadataApi, ActionsApi } from './metadata/index.js';
812
export type {
9-
DynamiaClientConfig,
1013
// Application
1114
ApplicationMetadata,
1215
// Navigation
@@ -27,26 +30,30 @@ export type {
2730
ViewDescriptorMetadata,
2831
ViewDescriptor,
2932
ViewField,
30-
// CRUD
33+
} from './metadata/index.js';
34+
35+
// ── CRUD module ───────────────────────────────────────────────────────────────
36+
export { CrudResourceApi, CrudServiceApi } from './cruds/index.js';
37+
export type {
3138
CrudListResult,
3239
CrudQueryParams,
3340
CrudRawResponse,
3441
CrudPageable,
35-
// Reports
42+
} from './cruds/index.js';
43+
44+
// ── Reports module ────────────────────────────────────────────────────────────
45+
export { ReportsApi } from './reports/index.js';
46+
export type {
3647
ReportDTO,
3748
ReportFilter,
3849
ReportFilters,
39-
// SaaS
40-
AccountDTO,
41-
} from './types.js';
42-
43-
// ── API classes (for advanced usage / extension) ─────────────────────────────
44-
export { MetadataApi } from './api/metadata.js';
45-
export { CrudResourceApi } from './api/crud.js';
46-
export { CrudServiceApi } from './api/crud-service.js';
47-
export { ActionsApi } from './api/actions.js';
48-
export { ReportsApi } from './api/reports.js';
49-
export { FilesApi } from './api/files.js';
50-
export { SaasApi } from './api/saas.js';
51-
export { ScheduleApi } from './api/schedule.js';
50+
} from './reports/index.js';
51+
52+
// ── SaaS module ───────────────────────────────────────────────────────────────
53+
export { SaasApi } from './saas/index.js';
54+
export type { AccountDTO } from './saas/index.js';
55+
56+
// ── API classes (files & schedule — core extensions) ─────────────────────────
57+
export { FilesApi } from './files/index.js';
58+
export { ScheduleApi } from './schedule/index.js';
5259

0 commit comments

Comments
 (0)