generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 145
Live cql #2403
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
Live cql #2403
Changes from all commits
Commits
Show all changes
151 commits
Select commit
Hold shift + click to select a range
e4fd59a
initial cxl diagrams
Akatuoro f2b2611
add some first drawings
patricebender 06639e7
more diagrams
patricebender 589aa42
add links and clickable diagrams to CXL
patricebender 5f579bf
more diagrams
patricebender db13438
some text
Akatuoro 6dd2daa
Merge branch 'cxl' of https://github.com/cap-js/docs into cxl
Akatuoro 4522abf
recangular entities
patricebender 57a75dc
Merge remote-tracking branch 'origin/cxl' into cxl
patricebender ca9858b
functions with method style
Akatuoro 45bf61b
add intro and some samples for ref
patricebender 784e99c
spelling
patricebender 493b3ee
update
Akatuoro ac6159e
minor changes to diagram
patricebender db644c2
small infix filter update
Akatuoro 709f355
adjustements
patricebender e9bec18
make imports relative
Akatuoro 6e25e92
fix formatting -> disable word-wrap and text formatting
Akatuoro c6fffef
some more samples
patricebender 137166f
Merge remote-tracking branch 'origin/cxl' into cxl
patricebender 1fe6bec
fix
Akatuoro 8f56dd6
adjustements to drawings and more samples
patricebender c22f480
css
Akatuoro 925d0af
more finetuning
patricebender 0038356
review notes
patricebender 13ce622
fix size for smaller diagrams
Akatuoro 4d8f4ba
update ref diagram and apply review feedback
Akatuoro 4a61002
fix diagram
Akatuoro ecc934f
associations as predefined joins and set theory
Akatuoro 7623638
.
Akatuoro fdb8336
apply review feedback
Akatuoro e650688
WIP: infix notation
patricebender 3e1de7c
todos
Akatuoro 745d47d
work through some todos, add samples
patricebender 124010c
Merge remote-tracking branch 'origin/main' into cxl
patricebender 346affe
link to md
patricebender 09b48c0
apply review feedback
Akatuoro 842fdbd
leaf elements
Akatuoro 439bbbb
examples, todos
Akatuoro 544482e
add first venn digram
patricebender 1a2d79b
add first venn digram
patricebender 3a05a6f
sets diagram
Akatuoro 245e6c3
set theory
Akatuoro ca9f554
math expressions
Akatuoro e54664f
apply review comments
Akatuoro b92f9f5
add cql-draft and resolve minimum todos for merge
patricebender 7a7eec0
package-lock
Akatuoro f82b0d7
Set theory graphics with syntax coloring
swaldmann 5bd9e2d
remove duplicate diagram
Akatuoro 932c424
Apply suggestions from code review
Akatuoro 84632de
fix
Akatuoro d2b337f
Merge branch 'cxl' of https://github.com/cap-js/docs into cxl
Akatuoro 87366e4
Merge remote-tracking branch 'origin/main' into cxl
Akatuoro 25c2fce
Books.title -> title
Akatuoro 395a800
lower case null, true, false
Akatuoro c653408
Merge branch 'main' into cxl
Akatuoro 34cb885
add examples
Akatuoro 1115e2c
move to cql + learn-more links
Akatuoro ab2e0d1
todos + move parts out
Akatuoro 8a07425
Merge remote-tracking branch 'origin/main' into cxl
Akatuoro 77b964c
fix
Akatuoro 768fac2
.
Akatuoro a73acf6
ready for merge
Akatuoro d742c11
remove binding parameter for first version
Akatuoro 4f87d16
move diagrams
Akatuoro 306f51a
fix diagram whitespace
Akatuoro 2994ffc
apply review feedback
Akatuoro f77f4a5
infix filter examples
Akatuoro dc19472
apply review comments
Akatuoro d481bb9
apply review comment
Akatuoro 460dec8
expr in annotations
Akatuoro 0b5a073
chore: terminal symbols with rounded corners
patricebender ed55e2c
Merge remote-tracking branch 'origin/main' into cxl
patricebender f328c00
chore: remove portable functions, point to new section
patricebender 43e98bb
fix diagrams
Akatuoro b639de0
fix diagram
Akatuoro 4df0961
fix link
Akatuoro 8f79807
chore: one more sample in intro section
patricebender 7939906
Merge branch 'main' into cxl
patricebender a57c977
chore: DateTime is not a literal
patricebender bfcf8af
chore: move literals and ops up
patricebender 8b6f859
chore: some samples for literals
patricebender d064183
chore: smoother entry section
patricebender e1d3cc3
apply review comments
Akatuoro 2086a33
remove forward-declared join section
Akatuoro 8030c18
move out ordering term
Akatuoro a723690
move out ordering term
Akatuoro efeb5d8
remove unused diagram
Akatuoro 1749d5d
live cql eval
Akatuoro f98119f
working vitepress build
Akatuoro 2b73751
use monaco editor
Akatuoro 489f62c
move out monaco editor
Akatuoro ad71b3b
theming
Akatuoro 67c854a
syntax highlight with @shikijs/monaco
Akatuoro 88da9ad
play icon
Akatuoro 5e8abd4
improved ux
Akatuoro d124fdc
fix
Akatuoro 0383f98
sql logging
Akatuoro f834081
better ux
Akatuoro adf9531
improve ux
Akatuoro 20fe327
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro 931f290
fixes
Akatuoro 5d568e5
style fix and hint
Akatuoro 6523422
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro b3717ca
add template functionality
Akatuoro 292ea1c
centralize cds initialization
Akatuoro c31a80c
resolve warnings, small fixes
Akatuoro 5984a5e
fixes
Akatuoro c69ff10
tmp styling
Akatuoro 750b740
equal shiki and monaco layouts
Akatuoro fbe4155
move to .vitepress
Akatuoro 81db04c
live code in md
Akatuoro 59bacda
copy button and language
Akatuoro e054913
avoid dynamic import
Akatuoro 1b771c8
switch in monaco only when loaded
Akatuoro d7ce0d7
account for syntax highlighting
Akatuoro fb17230
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro fe2c7a2
css fixes
Akatuoro baca189
deselecting result tabs
Akatuoro 9d6baf9
enhance model
Akatuoro 05706fe
use live code for samples
Akatuoro 63cf656
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro 6536b42
explicit sqlite-wasm for npm ci
Akatuoro 3bb6594
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro 03ed7da
only load if dependency is installed
Akatuoro 02abe29
lint
Akatuoro c18ea77
wait for highlighting before showing editor
Akatuoro e09c47e
add missing dependencies
Akatuoro 0305ad6
context for snippet checker
Akatuoro c790c27
fix copy
Akatuoro 6050685
update package-lock
Akatuoro 5905581
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro ece95d2
cleanup
Akatuoro d5f9c1c
updated introduction
Akatuoro 5388373
workaround for checker
Akatuoro d891426
cleanup
Akatuoro 2c4c4c1
button feedback
Akatuoro 02a8689
update plugin
Akatuoro 85d1244
cleanup
Akatuoro b4a36aa
update package lock
Akatuoro 554530a
apparently not all browsers support top-level await correctly
Akatuoro ddebb6c
Merge branch 'live-cql' of https://github.com/cap-js/docs into live-cql
Akatuoro 11801a5
top-level await for highlighter
Akatuoro 3801be3
update plugin
Akatuoro bc13961
Show keyboard shortcut in button tooltip
chgeo 92415e0
Merge remote-tracking branch 'origin/main' into live-cql
Akatuoro f83fc2c
md plugin description
Akatuoro 798fd2f
express 5
Akatuoro 968265f
express 5
Akatuoro 04849da
playground -> cds-playground
Akatuoro a323a47
playground -> cds-playground
Akatuoro 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
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
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,23 @@ | ||
| import templates from './vite-plugin-templates' | ||
| import path from 'path' | ||
|
|
||
| let enabled = false | ||
| let plugins = () => [] | ||
|
|
||
| try { | ||
| const { node, cap } = await import('vite-plugin-cds') | ||
| plugins = () => { | ||
| return [node(), cap(), templates([path.join(__dirname, 'templates')])] | ||
| } | ||
| enabled = true | ||
| } | ||
| catch { | ||
| // eslint-disable-next-line no-console | ||
| console.error('live code not available - run `npm i` to update your modules') | ||
| } | ||
|
|
||
| export { | ||
| enabled, | ||
| plugins, | ||
| } | ||
| export default { enabled, plugins } |
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,73 @@ | ||
| import { MarkdownRenderer, MarkdownEnv } from 'vitepress' | ||
| import { dirname, join, relative } from 'path' | ||
| import { enabled } from '.' | ||
|
|
||
| /** | ||
| * Makes code blocks with "live" in the info string interactive by rendering a <LiveCode /> component. | ||
| * | ||
| * ```cds live | ||
| * select from Books { title } | ||
| * ``` | ||
| * | ||
| * ```js live | ||
| * await INSERT.into('Books').entries( | ||
| * { ID: 2, author_ID: 150, title: 'Eldorado' } | ||
| * ) | ||
| * ``` | ||
| * | ||
| * Additional options: | ||
| * - as <lang>: specify the language to execute the code block as (defaults to the language specified before "live") | ||
| * example: ```cds live as cql | ||
| * - readonly: make the code block readonly | ||
| * example: ```cds live readonly | ||
| */ | ||
| export function install(md: MarkdownRenderer) { | ||
| if (!enabled) return | ||
| const fence = md.renderer.rules.fence | ||
| md.renderer.rules.fence = (tokens, idx, options, env: MarkdownEnv, ...args) => { | ||
|
|
||
| const { info } = tokens[idx] | ||
| const [language, live, ...rest] = info.split(' ') | ||
| if (live === 'live') { | ||
| const mdDir = dirname(env.realPath ?? env.path) | ||
| const filePath = './' + relative(mdDir, join(__dirname, '../../theme/components/cds-playground/LiveCode.vue')) | ||
| const imp = `import LiveCode from "${filePath}";` | ||
| insertScriptSetup(env, imp) | ||
|
|
||
| const opts = Object.fromEntries(['as'].map(key => { | ||
| const idx = rest.findIndex(k => k === key) | ||
| return idx > -1 ? [key, rest.splice(idx+1, 1)[0]] : []; | ||
| })) | ||
| const props = { | ||
| language: opts.as ?? language, | ||
| } | ||
| const flags = ['readonly'].filter(k => rest.includes(k)) | ||
|
|
||
| const content = tokens[idx].content.trim() | ||
| return `<LiveCode initialQuery="${md.utils.escapeHtml(content)}" ${Object.entries(props).map(([k, v]) => `${k}="${v}"`)} ${flags.join(' ')}></LiveCode>` | ||
| } | ||
| return fence!(tokens, idx, options, env, ...args) | ||
| } | ||
| } | ||
|
|
||
| function insertScriptSetup(env: MarkdownEnv, imp: string) { | ||
| const sfcBlocks = env.sfcBlocks! | ||
| if (!sfcBlocks.scriptSetup) { | ||
| sfcBlocks.scriptSetup = { | ||
| content: '<script setup>\n</script>', | ||
| contentStripped: '\n', | ||
| tagClose: '</script>', | ||
| tagOpen: '<script setup>', | ||
| type: 'script' | ||
| } | ||
| sfcBlocks.scripts.push(sfcBlocks.scriptSetup) | ||
| } | ||
|
|
||
| const { scriptSetup } = sfcBlocks | ||
| const { tagOpen, tagClose, contentStripped: rest } = scriptSetup | ||
|
|
||
| if (!scriptSetup.content.includes(imp)) { | ||
| scriptSetup.contentStripped = `${imp}\n${rest}` | ||
| scriptSetup.content = `${tagOpen}${imp}\n${rest}${tagClose}` | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
.vitepress/lib/cds-playground/templates/bookshop/db/data/sap.capire.bookshop-Authors.csv
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 @@ | ||
| ID,name,dateOfBirth,placeOfBirth,dateOfDeath,placeOfDeath | ||
| 101,Emily Brontë,1818-07-30,"Thornton, Yorkshire",1848-12-19,"Haworth, Yorkshire" | ||
| 107,Charlotte Brontë,1818-04-21,"Thornton, Yorkshire",1855-03-31,"Haworth, Yorkshire" | ||
| 150,Edgar Allen Poe,1809-01-19,"Boston, Massachusetts",1849-10-07,"Baltimore, Maryland" | ||
| 170,Richard Carpenter,1929-08-14,"King’s Lynn, Norfolk",2012-02-26,"Hertfordshire, England" |
6 changes: 6 additions & 0 deletions
6
.vitepress/lib/cds-playground/templates/bookshop/db/data/sap.capire.bookshop-Books.csv
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,6 @@ | ||
| ID,title,descr,author_ID,stock,price,currency_code,genre_ID | ||
| 201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa | ||
| 207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa | ||
| 251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa | ||
| 252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa | ||
| 271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa |
5 changes: 5 additions & 0 deletions
5
.vitepress/lib/cds-playground/templates/bookshop/db/data/sap.capire.bookshop-Books.texts.csv
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 @@ | ||
| ID_texts,ID,locale,title,descr | ||
| d2a65a27-9f2a-480f-bc38-84ee8ec5c13e,201,de,Sturmhöhe,"Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts." | ||
| 8c42c706-a979-41cf-9ffe-91e6cf1383a0,201,fr,Les Hauts de Hurlevent,"Les Hauts de Hurlevent (titre original : Wuthering Heights), parfois orthographié Les Hauts de Hurle-Vent, est l'unique roman d'Emily Brontë, publié pour la première fois en 1847 sous le pseudonyme d’Ellis Bell. Loin d'être un récit moralisateur, Emily Brontë achève néanmoins le roman dans une atmosphère sereine, suggérant le triomphe de la paix et du Bien sur la vengeance et le Mal." | ||
| 9e1c4c81-dc90-4600-85b1-e9dd4bf12ce0,207,de,Jane Eyre,"Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte" | ||
| 9be0524b-4cb9-4fc1-9dc2-d65b1c13cf53,252,de,Eleonora,"“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1841 erstveröffentlicht. In ihr geht es um das Paradox der Treue in der Treulosigkeit." |
43 changes: 43 additions & 0 deletions
43
.vitepress/lib/cds-playground/templates/bookshop/db/data/sap.capire.bookshop-Genres.csv
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,43 @@ | ||
| ID,parent_ID,name | ||
| 10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Fiction | ||
| 11aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Drama | ||
| 12aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Poetry | ||
| 13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fantasy | ||
| 131aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Fairy Tale | ||
| 132aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Epic Fantasy | ||
| 133aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,High Fantasy | ||
| 134aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,13aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Gothic | ||
| 14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Science Fiction | ||
| 141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian and Dystopian | ||
| 1411aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Utopian | ||
| 1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,141aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Dystopian | ||
| 14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1412aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cyberpunk | ||
| 141211aa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14121aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Steampunk | ||
| 142aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Space Opera | ||
| 143aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Time Travel | ||
| 144aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,14aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tech Noir | ||
| 15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romance | ||
| 151aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Contemporary Romance | ||
| 152aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Historical Romance | ||
| 153aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,15aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Romantic Suspense | ||
| 16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Mystery | ||
| 161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Crime | ||
| 1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Thriller | ||
| 16111aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Police Procedural | ||
| 16112aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Legal Thriller | ||
| 16113aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Medical Thriller | ||
| 16114aaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,1611aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Spy Thriller | ||
| 1612aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Detective | ||
| 1613aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,161aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Suspense | ||
| 162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Noir | ||
| 1621aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Nordic Noir | ||
| 1622aaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,162aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Tart Noir | ||
| 163aaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,16aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Cozy Mystery | ||
| 17aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Adventure | ||
| 18aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Short Story | ||
| 19aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,10aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Graphic Novel | ||
| 20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,,Non-Fiction | ||
| 21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Biography | ||
| 22aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,21aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Autobiography | ||
| 23aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Essay | ||
| 24aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,20aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,Speech |
42 changes: 42 additions & 0 deletions
42
.vitepress/lib/cds-playground/templates/bookshop/db/schema.cds
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,42 @@ | ||
| using { Currency, cuid, managed, sap } from '@sap/cds/common'; | ||
| namespace sap.capire.bookshop; | ||
|
|
||
| entity Books { | ||
| key ID : Integer; | ||
| author : Association to Authors @mandatory; | ||
| title : localized String @mandatory; | ||
| descr : localized String(2000); | ||
| genre : Association to Genres; | ||
| stock : Integer; | ||
| price : Price; | ||
| currency : Currency; | ||
|
|
||
| total = price * stock; | ||
| } | ||
|
|
||
| entity Authors { | ||
| key ID : Integer; | ||
| name : String @mandatory; | ||
| dateOfBirth : Date; | ||
| dateOfDeath : Date; | ||
| placeOfBirth : String; | ||
| placeOfDeath : String; | ||
| books : Association to many Books on books.author = $self; | ||
|
|
||
| cheapBooks = books[price < 19.99]; // based on `books` association | ||
| age = years_between(dateOfBirth, coalesce(dateOfDeath, date( $now ))); | ||
| } | ||
|
|
||
| /** Hierarchically organized Code List for Genres */ | ||
| entity Genres : cuid, sap.common.CodeList { | ||
| parent : Association to Genres; | ||
| children : Composition of many Genres on children.parent = $self; | ||
| } | ||
|
|
||
| type Price : Decimal(9,2); | ||
|
|
||
| // -------------------------------------------------------------------------------- | ||
| // Temporary workaround for this situation: | ||
| // - Fiori apps in bookstore annotate Books with @fiori.draft.enabled. | ||
| // - Because of that .csv data has to eagerly fill in ID_texts column. | ||
| annotate Books with @fiori.draft.enabled; |
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 @@ | ||
| # capire/bookshop | ||
|
|
||
| A copy of the [capire/bookshop](https://github.com/capire/bookshop) model. |
7 changes: 7 additions & 0 deletions
7
.vitepress/lib/cds-playground/templates/bookshop/srv/admin-service.cds
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,7 @@ | ||
| using { sap.capire.bookshop as my } from '../db/schema'; | ||
|
|
||
| service AdminService @(odata:'/admin') { | ||
| entity Authors as projection on my.Authors; | ||
| entity Books as projection on my.Books; | ||
| entity Genres as projection on my.Genres; | ||
| } |
20 changes: 20 additions & 0 deletions
20
.vitepress/lib/cds-playground/templates/bookshop/srv/cat-service.cds
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,20 @@ | ||
| using { sap.capire.bookshop as my } from '../db/schema'; | ||
|
|
||
| service CatalogService @(odata:'/browse') { | ||
|
|
||
| /** For displaying lists of Books */ | ||
| @readonly entity ListOfBooks as projection on Books { | ||
| *, currency.symbol as currency, | ||
| } | ||
| excluding { descr }; | ||
|
|
||
| /** For display in details pages */ | ||
| @readonly entity Books as projection on my.Books { | ||
| *, // all fields with the following denormalizations: | ||
| author.name as author, | ||
| genre.name as genre, | ||
| } excluding { createdBy, modifiedBy }; | ||
|
|
||
| @requires: 'authenticated-user' | ||
| action submitOrder ( book: Books:ID, quantity: Integer ); | ||
| } |
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,97 @@ | ||
| import type { Plugin, ResolvedConfig } from 'vite'; | ||
| import cds from '@sap/cds'; | ||
| import fs from 'fs/promises'; | ||
| import path from 'path'; | ||
|
|
||
| /** | ||
| * Vite plugin to load templates from specified directories. | ||
| * @example | ||
| * defineConfig({ | ||
| * plugins: [ templates([".vitepress/templates"]) ] | ||
| * }) | ||
| */ | ||
| function templates(sources : string[] = [] ): Plugin { | ||
| const RESOLVED_ID = '\0templates:'; | ||
| let config: ResolvedConfig; | ||
| let resolvedSources: string[] = sources; | ||
|
|
||
| async function walk(dirPath: string): Promise<string[]> { | ||
| const entries = await fs.readdir(dirPath, { withFileTypes: true, recursive: true }); | ||
| return entries.filter((e) => e.isFile()).map((e) => path.join(e.parentPath, e.name)); | ||
| }; | ||
|
|
||
| async function templateDirs(dir : string | string[]): Promise<string[]> { | ||
| if (Array.isArray(dir)) return Promise.all(dir.map(d => templateDirs(d))).then(arrs => arrs.flat()); | ||
| const entries = await fs.readdir(dir, { withFileTypes: true }); | ||
| return entries.filter((e) => e.isDirectory()).map((e) => path.join(dir, e.name)); | ||
| } | ||
|
|
||
| async function buildTemplates(dir : string | string[]): Promise<Record<string, { path: string; content: string }[]>> { | ||
|
|
||
| const dirs = await templateDirs(dir); | ||
|
|
||
| const templates = await Promise.all(dirs.map(async (d) => { | ||
| const filesInTemplate = await walk(d); | ||
| const files = await Promise.all(filesInTemplate | ||
| .map(async (f) => { | ||
| const relPath = path.relative(d, f); | ||
| const content = await fs.readFile(f, 'utf8'); | ||
| return { | ||
| path: relPath, | ||
| content, | ||
| }; | ||
| })); | ||
| const name = path.basename(d); | ||
|
|
||
| // revisit: better way to include cds artifacts from npm modules? | ||
| files.push({ | ||
| path: '@sap/cds/common', | ||
| content: JSON.stringify(await cds.load('@sap/cds/common')), | ||
| }) | ||
|
|
||
| return { | ||
| name, | ||
| files | ||
| }; | ||
| })); | ||
|
|
||
|
|
||
| return Object.fromEntries(templates.map(t => [t.name, t.files])); | ||
| } | ||
|
|
||
| function root(): string { | ||
| return config.root || process.cwd(); | ||
| } | ||
|
|
||
| return { | ||
| name: 'templates-plugin', | ||
| enforce: 'pre', | ||
| configResolved(c) { | ||
| config = c; | ||
| resolvedSources = sources.map(s => path.resolve(root(), s)); | ||
| }, | ||
| resolveId(id) { | ||
| if (id === 'virtual:templates') { | ||
| return { id : RESOLVED_ID, attributes: { path: id } }; | ||
| } | ||
| }, | ||
| async load(id) { | ||
| if (id.startsWith(RESOLVED_ID)) { | ||
| const templates = await buildTemplates(resolvedSources); | ||
| return `export default ${JSON.stringify(templates, null, 2)};`; | ||
| } | ||
| }, | ||
| async handleHotUpdate(ctx) { | ||
| if (resolvedSources.some(s => ctx.file.startsWith(s))) { | ||
| const mod = ctx.server.moduleGraph.getModuleById(RESOLVED_ID); | ||
| if (mod) { | ||
| ctx.server.moduleGraph.invalidateModule(mod); | ||
| return [mod]; | ||
| } | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| export default templates; | ||
| export { templates }; |
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.
Uh oh!
There was an error while loading. Please reload this page.