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
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
5 changes: 3 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ function validateCustomNotifyParameters(type, recipients, properties, navigation


function readFile(filePath) {
if (!existsSync(filePath)) {
const resolvedPath = cds.utils.path.resolve(cds.root, filePath);
if (!existsSync(resolvedPath)) {
LOG._warn && LOG.warn(messages.TYPES_FILE_NOT_EXISTS);
return [];
}

return JSON.parse(readFileSync(filePath));
return JSON.parse(readFileSync(resolvedPath));
}

async function getNotificationDestination() {
Expand Down
45 changes: 30 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
"@sap-cloud-sdk/util": "^3.13.0"
},
"devDependencies": {
"jest": "^29.7.0",
"chai": "^4.3.10",
"@cap-js/cds-test": ">=0",
"@cap-js/sqlite": "^2.2.0",
"@sap/cds": ">=8.0",
"@sap/cds-dk": ">=8.0"
"@sap/cds-dk": ">=8.0",
"chai": "^4.3.10",
"express": "^5.2.1",
"jest": "^29.7.0"
},
"engines": {
"node": ">=20.0.0"
},
"scripts": {
"lint": "npx eslint .",
Expand All @@ -35,17 +41,6 @@
"requires": {
"destinations": true,
"notifications": {
"[development]": {
"kind": "notify-to-console"
},
"[hybrid]": {
"destination": "SAP_Notifications",
"kind": "notify-to-rest"
},
"[production]": {
"destination": "SAP_Notifications",
"kind": "notify-to-rest"
},
"prefix": "$app-name",
"types": "srv/notification-types.json",
"outbox": true
Expand All @@ -57,7 +52,27 @@
"notify-to-rest": {
"impl": "@cap-js/notifications/srv/notifyToRest"
}
},
"[development]": {
"notifications": {
"kind": "notify-to-console"
}
},
"[hybrid]": {
"notifications": {
"destination": "SAP_Notifications",
"kind": "notify-to-rest"
}
},
"[production]": {
"notifications": {
"destination": "SAP_Notifications",
"kind": "notify-to-rest"
}
}
}
}
},
"workspaces": [
"tests/bookshop/"
]
}
8 changes: 0 additions & 8 deletions srv/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,3 @@ class NotificationService extends cds.Service {

}
module.exports = NotificationService

// Without Generic Outbox only alert.notify() can be used, not alert.emit()
// Remove that when @sap/cds with Generic Outbox is released
if (!cds.outboxed) {
class OutboxedNotificationService extends require('@sap/cds/libx/_runtime/messaging/Outbox') {}
OutboxedNotificationService.prototype.notify = NotificationService.prototype.emit
module.exports = OutboxedNotificationService
}
34 changes: 34 additions & 0 deletions tests/bookshop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CAP bookshop
_out
*.db
*.sqlite
connection.properties
default-*.json
.cdsrc-private.json
gen/
node_modules/
target/

# Web IDE, App Studio
.che/
.gen/

# MTA
*_mta_build_tmp
*.mtar
mta_archives/

# Other
.DS_Store
*.orig
*.log

*.iml
*.flattened-pom.xml

# IDEs
# .vscode
# .idea

# @cap-js/cds-typer
@cds-models
25 changes: 25 additions & 0 deletions tests/bookshop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Getting Started

Welcome to your new project.

It contains these folders and files, following our recommended project layout:

File or Folder | Purpose
---------|----------
`app/` | content for UI frontends goes here
`db/` | your domain models and data go here
`srv/` | your service models and code go here
`package.json` | project metadata and configuration
`readme.md` | this getting started guide


## Next Steps

- Open a new terminal and run `cds watch`
- (in VS Code simply choose _**Terminal** > Run Task > cds watch_)
- Start adding content, for example, a [db/schema.cds](db/schema.cds).


## Learn More

Learn more at https://cap.cloud.sap/docs/get-started/.
29 changes: 29 additions & 0 deletions tests/bookshop/app/_i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Books = Books
Book = Book
ID = ID
Title = Title
Author = Author
Authors = Authors
AuthorID = Author ID
AuthorName = Author Name
Name = Name
Age = Age
Stock = Stock
Order = Order
Orders = Orders
Price = Price
Genre = Genre
Genres = Genres
DateOfBirth = Date of Birth
DateOfDeath = Date of Death
PlaceOfBirth = Place of Birth
PlaceOfDeath = Place of Death
Details = Details
Languages = Languages
Currencies = Currencies
MainGenre = Main Genre
SubGenres = Subgenres
Admin = Admin
Translations = Translations
General = General
Locale = Locale
29 changes: 29 additions & 0 deletions tests/bookshop/app/_i18n/i18n_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Books = Bücher
Book = Buch
ID = ID
Title = Titel
Author = Autor
Authors = Autoren
AuthorID = ID des Autors
AuthorName = Name des Autors
Name = Name
Age = Alter
Stock = Bestand
Order = Bestellung
Orders = Bestellungen
Price = Preis
Genre = Genre
Genres = Genres
DateOfBirth = Geburtsdatum
DateOfDeath = Todesdatum
PlaceOfBirth = Geburtsort
PlaceOfDeath = Todesort
Details = Details
Languages = Sprachen
Currencies = Währungen
MainGenre = Hauptgenre
SubGenres = Subgenres
Admin = Admin
Translations = Übersetzungen
General = Allgemein
Locale = Gebietsschema
118 changes: 118 additions & 0 deletions tests/bookshop/app/admin-books/fiori-service.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using {AdminService} from '../../srv/admin-service.cds';

////////////////////////////////////////////////////////////////////////////
//
// Books Object Page
//

annotate AdminService.Books with @(UI: {
HeaderInfo : {
TypeName : '{i18n>Book}',
TypeNamePlural: '{i18n>Books}',
Title : {Value: title},
Description : {Value: author.name}
},
Facets : [
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>General}',
Target: '@UI.FieldGroup#General'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Translations}',
Target: 'texts/@UI.LineItem'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target: '@UI.FieldGroup#Details'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Admin}',
Target: '@UI.FieldGroup#Admin'
},
],
FieldGroup #General: {Data: [
{Value: title},
{Value: author_ID},
{Value: genre_ID},
{Value: descr},
]},
FieldGroup #Details: {Data: [
{Value: stock},
{Value: price},
{
Value: currency_code,
Label: '{i18n>Currency}'
},
]},
FieldGroup #Admin : {Data: [
{Value: createdBy},
{Value: createdAt},
{Value: modifiedBy},
{Value: modifiedAt}
]}
});


////////////////////////////////////////////////////////////
//
// Draft for Localized Data
//

annotate sap.capire.bookshop.Books with @fiori.draft.enabled;
annotate AdminService.Books with @odata.draft.enabled;

annotate AdminService.Books.texts with @(UI: {
Identification : [{Value: title}],
SelectionFields: [
locale,
title
],
LineItem : [
{
Value: locale,
Label: '{i18n>Locale}'
},
{
Value: title,
Label: '{i18n>Title}'
},
{
Value: descr,
Label: '{i18n>Description}'
},
]
});

annotate AdminService.Books.texts with {
ID @UI.Hidden;
ID_texts @UI.Hidden;
};

// Add Value Help for Locales
annotate AdminService.Books.texts {
locale @(
ValueList.entity: 'Languages',
Common.ValueListWithFixedValues, //show as drop down, not a dialog
)
};

// In addition we need to expose Languages through AdminService as a target for ValueList
using {sap} from '@sap/cds/common';

extend service AdminService {
@readonly
entity Languages as projection on sap.common.Languages;
}

// Workaround for Fiori popups for asking user to enter a valid UUID on Create
annotate AdminService.Authors : ID with @Core.Computed @odata.Type: 'Edm.String';
annotate AdminService.Books : ID with @Core.Computed @odata.Type: 'Edm.String';

// Show Genre as drop down, not a dialog
annotate AdminService.Books with {
genre @Common.ValueListWithFixedValues;
}
8 changes: 8 additions & 0 deletions tests/bookshop/app/admin-books/webapp/Component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sap.ui.define(["sap/fe/core/AppComponent"], function (AppComponent) {
"use strict";
return AppComponent.extend("books.Component", {
metadata: { manifest: "json" }
});
});

/* eslint no-undef:0 */
3 changes: 3 additions & 0 deletions tests/bookshop/app/admin-books/webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appTitle=Manage Books
appSubTitle=Manage bookshop inventory
appDescription=Manage your bookshop inventory with ease.
3 changes: 3 additions & 0 deletions tests/bookshop/app/admin-books/webapp/i18n/i18n_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appTitle=Bücher verwalten
appSubTitle=Verwalten Sie den Bestand der Buchhandlung
appDescription=Verwalten Sie den Bestand Ihrer Buchhandlung ganz einfach.
3 changes: 3 additions & 0 deletions tests/bookshop/app/admin-books/webapp/i18n/i18n_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appTitle=Manage Books
appSubTitle=Manage bookshop inventory
appDescription=Manage your bookshop inventory with ease.
Loading
Loading