-
Notifications
You must be signed in to change notification settings - Fork 3
New Typescript SDK with support for CRUDs, Application Metadata and more #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
463432a
Initialize pnpm workspace and add TypeScript configuration for SDK de…
marioserrano09 51383b0
Add API classes for Actions, CRUD operations, Files, and Reports for …
marioserrano09 b75177b
Enhance RestNavigationQuerySupport to dynamically create Field instan…
marioserrano09 4af207e
Astro example integration with Dynamia
marioserrano09 90c0363
Add GitHub Actions workflow for publishing NPM packages
marioserrano09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Publish NPM Packages | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] # triggers when a release is published on GitHub | ||
| workflow_dispatch: # allows manual trigger from the Actions tab | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Build, Test & Publish to NPM | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: platform/packages | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write # required for npm provenance | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '24' | ||
| registry-url: 'https://registry.npmjs.org' | ||
| cache: 'pnpm' | ||
| cache-dependency-path: framework/platform/packages/pnpm-lock.yaml | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build all packages | ||
| run: pnpm build | ||
|
|
||
| - name: Run tests | ||
| run: pnpm test | ||
|
|
||
| - name: Publish all packages to NPM | ||
| run: pnpm -r publish --access public --no-git-checks | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ name: Release and Deploy | |
|
|
||
| on: | ||
| release: | ||
| types: [ created ] | ||
| types: [ published ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # demo-client-books backend API URL — override for production | ||
| PUBLIC_API_URL=https://your-demo-zk-books.example.com | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules/ | ||
| dist/ | ||
| .env | ||
| .env.local | ||
| .astro/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # demo-client-books | ||
|
|
||
| > Public storefront demo built with **Astro** + **@dynamia-tools/sdk**, consuming the [`demo-zk-books`](../demo-zk-books) backend. | ||
|
|
||
| --- | ||
|
|
||
| ## What it shows | ||
|
|
||
| | Page | URL | Description | | ||
| |------|-----|-------------| | ||
| | Home | `/` | Featured books grid with category filter and pagination | | ||
| | Books | `/books` | Full catalog with search, category filter and pagination | | ||
| | Book detail | `/books/:id` | Cover, price, stock status, synopsis and reader reviews | | ||
| | Categories | `/categories` | All categories with links to filtered book list | | ||
|
|
||
| Everything is **server-rendered** (SSR via `@astrojs/node`), so each request fetches live data from the Dynamia Platform REST API via `@dynamia-tools/sdk`. | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node.js ≥ 20 | ||
| - [`demo-zk-books`](../demo-zk-books) backend running (defaults to `http://localhost:8080`) | ||
|
|
||
|
Comment on lines
+21
to
+24
|
||
| --- | ||
|
|
||
| ## Quick start | ||
|
|
||
| ```bash | ||
| # 1 – Install dependencies | ||
| npm install | ||
|
|
||
| # 2 – Point to your backend (edit .env or set the env var) | ||
| echo "PUBLIC_API_URL=http://localhost:8484" > .env | ||
|
|
||
| # 3 – Dev server with hot-reload | ||
| npm run dev # http://localhost:4321 | ||
|
|
||
| # 4 – Production build | ||
| npm run build | ||
| node dist/server/entry.mjs | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Project structure | ||
|
|
||
| ``` | ||
| demo-client-books/ | ||
| ├── src/ | ||
| │ ├── layouts/ | ||
| │ │ └── Layout.astro # Navbar, footer, global CSS | ||
| │ ├── lib/ | ||
| │ │ ├── client.ts # DynamiaClient singleton (reads PUBLIC_API_URL) | ||
| │ │ ├── types.ts # TypeScript types mirroring Java domain | ||
| │ │ └── api.ts # Thin helpers: getBooks(), getCoverUrl(), ... | ||
| │ └── pages/ | ||
| │ ├── index.astro # Home / featured books | ||
| │ ├── books/ | ||
| │ │ ├── index.astro # /books — full catalog | ||
| │ │ └── [id].astro # /books/:id — book detail | ||
| │ └── categories/ | ||
| │ └── index.astro # /categories | ||
| ├── .env # PUBLIC_API_URL (git-ignored) | ||
| ├── .env.example # Template | ||
| ├── astro.config.mjs | ||
| ├── package.json | ||
| └── tsconfig.json | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## SDK usage | ||
|
|
||
| ```typescript | ||
| import { DynamiaClient } from '@dynamia-tools/sdk'; | ||
|
|
||
| const client = new DynamiaClient({ baseUrl: 'http://localhost:8080' }); | ||
|
|
||
| // List books (CrudPage virtual path: "library/books") | ||
| const { content, total } = await client.crud('library/books').findAll({ page: 1, size: 12 }); | ||
|
|
||
| // Single book | ||
| const book = await client.crud('library/books').findById(1); | ||
|
|
||
| // File cover URL | ||
| const url = client.files.getUrl(book.bookCover.filename, book.bookCover.uuid); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## License | ||
|
|
||
| Apache 2.0 — © Dynamia Soluciones IT SAS | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { defineConfig } from 'astro/config'; | ||
| import node from '@astrojs/node'; | ||
|
|
||
| // https://astro.build/config | ||
| export default defineConfig({ | ||
| output: 'server', | ||
| adapter: node({ mode: 'standalone' }), | ||
| server: { | ||
| port: 4321, | ||
| }, | ||
| }); | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cache-dependency-pathpoints toframework/platform/packages/pnpm-lock.yaml, but this repo's lockfile is atplatform/packages/pnpm-lock.yaml(noframework/directory). This will disable pnpm caching and may slow down the workflow; update the path to the correct lockfile location.