Skip to content

Commit f2a9054

Browse files
Merge pull request #54 from dynamiatools/feature/typescript-basic-sdk
New Typescript SDK with support for CRUDs, Application Metadata and more
2 parents bbe847b + 90c0363 commit f2a9054

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+11191
-2
lines changed

.github/workflows/publish-npm.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish NPM Packages
2+
3+
on:
4+
release:
5+
types: [published] # triggers when a release is published on GitHub
6+
workflow_dispatch: # allows manual trigger from the Actions tab
7+
8+
jobs:
9+
publish:
10+
name: Build, Test & Publish to NPM
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: platform/packages
15+
16+
permissions:
17+
contents: read
18+
id-token: write # required for npm provenance
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
run_install: false
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '24'
33+
registry-url: 'https://registry.npmjs.org'
34+
cache: 'pnpm'
35+
cache-dependency-path: framework/platform/packages/pnpm-lock.yaml
36+
37+
- name: Install dependencies
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Build all packages
41+
run: pnpm build
42+
43+
- name: Run tests
44+
run: pnpm test
45+
46+
- name: Publish all packages to NPM
47+
run: pnpm -r publish --access public --no-git-checks
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
50+

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name: Release and Deploy
66

77
on:
88
release:
9-
types: [ created ]
9+
types: [ published ]
1010

1111
jobs:
1212
build:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# demo-client-books backend API URL — override for production
2+
PUBLIC_API_URL=https://your-demo-zk-books.example.com
3+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
.env
4+
.env.local
5+
.astro/
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# demo-client-books
2+
3+
> Public storefront demo built with **Astro** + **@dynamia-tools/sdk**, consuming the [`demo-zk-books`](../demo-zk-books) backend.
4+
5+
---
6+
7+
## What it shows
8+
9+
| Page | URL | Description |
10+
|------|-----|-------------|
11+
| Home | `/` | Featured books grid with category filter and pagination |
12+
| Books | `/books` | Full catalog with search, category filter and pagination |
13+
| Book detail | `/books/:id` | Cover, price, stock status, synopsis and reader reviews |
14+
| Categories | `/categories` | All categories with links to filtered book list |
15+
16+
Everything is **server-rendered** (SSR via `@astrojs/node`), so each request fetches live data from the Dynamia Platform REST API via `@dynamia-tools/sdk`.
17+
18+
---
19+
20+
## Prerequisites
21+
22+
- Node.js ≥ 20
23+
- [`demo-zk-books`](../demo-zk-books) backend running (defaults to `http://localhost:8080`)
24+
25+
---
26+
27+
## Quick start
28+
29+
```bash
30+
# 1 – Install dependencies
31+
npm install
32+
33+
# 2 – Point to your backend (edit .env or set the env var)
34+
echo "PUBLIC_API_URL=http://localhost:8484" > .env
35+
36+
# 3 – Dev server with hot-reload
37+
npm run dev # http://localhost:4321
38+
39+
# 4 – Production build
40+
npm run build
41+
node dist/server/entry.mjs
42+
```
43+
44+
---
45+
46+
## Project structure
47+
48+
```
49+
demo-client-books/
50+
├── src/
51+
│ ├── layouts/
52+
│ │ └── Layout.astro # Navbar, footer, global CSS
53+
│ ├── lib/
54+
│ │ ├── client.ts # DynamiaClient singleton (reads PUBLIC_API_URL)
55+
│ │ ├── types.ts # TypeScript types mirroring Java domain
56+
│ │ └── api.ts # Thin helpers: getBooks(), getCoverUrl(), ...
57+
│ └── pages/
58+
│ ├── index.astro # Home / featured books
59+
│ ├── books/
60+
│ │ ├── index.astro # /books — full catalog
61+
│ │ └── [id].astro # /books/:id — book detail
62+
│ └── categories/
63+
│ └── index.astro # /categories
64+
├── .env # PUBLIC_API_URL (git-ignored)
65+
├── .env.example # Template
66+
├── astro.config.mjs
67+
├── package.json
68+
└── tsconfig.json
69+
```
70+
71+
---
72+
73+
## SDK usage
74+
75+
```typescript
76+
import { DynamiaClient } from '@dynamia-tools/sdk';
77+
78+
const client = new DynamiaClient({ baseUrl: 'http://localhost:8080' });
79+
80+
// List books (CrudPage virtual path: "library/books")
81+
const { content, total } = await client.crud('library/books').findAll({ page: 1, size: 12 });
82+
83+
// Single book
84+
const book = await client.crud('library/books').findById(1);
85+
86+
// File cover URL
87+
const url = client.files.getUrl(book.bookCover.filename, book.bookCover.uuid);
88+
```
89+
90+
---
91+
92+
## License
93+
94+
Apache 2.0 — © Dynamia Soluciones IT SAS
95+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'astro/config';
2+
import node from '@astrojs/node';
3+
4+
// https://astro.build/config
5+
export default defineConfig({
6+
output: 'server',
7+
adapter: node({ mode: 'standalone' }),
8+
server: {
9+
port: 4321,
10+
},
11+
});
12+
13+

0 commit comments

Comments
 (0)