Skip to content
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

feat: Filter out internal and private metadata #82

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
88 changes: 6 additions & 82 deletions __tests__/__snapshots__/ordCdsrc.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,58 +51,6 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"apiProtocol": "odata-v4",
"description": "Description for CatalogService",
"entityTypeMappings": [
{
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:odm.bookshop.Authors:v1",
},
],
},
],
"entryPoints": [
"/browse",
],
"extensible": {
"supported": "no",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "sap.test.cdsrc.sample:apiResource:CatalogService:v1",
"partOfGroups": [
"sap.cds:service:sap.test.cdsrc.sample:CatalogService",
],
"partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "openapi-v3",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/CatalogService.oas3.json",
},
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/xml",
"type": "edmx",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/CatalogService.edmx",
},
],
"shortDescription": "Short description for CatalogService",
"title": "CatalogService",
"version": "1.0.0",
"visibility": "public",
},
],
Expand Down Expand Up @@ -178,35 +126,6 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"description": "CAP Event resource describing events / messages.",
"extensible": {
"supported": "no",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "sap.test.cdsrc.sample:eventResource:CatalogService:v1",
"partOfGroups": [
"sap.cds:service:sap.test.cdsrc.sample:CatalogService",
],
"partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-event:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "asyncapi-v2",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/CatalogService.asyncapi2.json",
},
],
"shortDescription": "CatalogService event resource",
"title": "ODM capirebookshopordsample Events",
"version": "1.0.0",
"visibility": "public",
},
],
Expand All @@ -219,7 +138,12 @@ exports[`Tests for default ORD document when .cdsrc.json is present Successfully
{
"groupId": "sap.cds:service:sap.test.cdsrc.sample:CatalogService",
"groupTypeId": "sap.cds:service",
"title": "Catalog Service",
"title": "This is test Catalog Service title",
},
{
"groupId": "sap.cds:service:sap.test.cdsrc.sample:CinemaService",
"groupTypeId": "sap.cds:service",
"title": "This is test Cinema Service title",
},
],
"openResourceDiscovery": "1.10",
Expand Down
88 changes: 6 additions & 82 deletions __tests__/__snapshots__/ordPackageJson.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,58 +52,6 @@ exports[`Tests for default ORD document when .cdsrc.json is not present Successf
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"apiProtocol": "odata-v4",
"description": "Description for CatalogService",
"entityTypeMappings": [
{
"entityTypeTargets": [
{
"ordId": "sap.odm:entityType:odm.bookshop.Authors:v1",
},
],
},
],
"entryPoints": [
"/browse",
],
"extensible": {
"supported": "no",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "customer.capirebookshopordsample:apiResource:CatalogService:v1",
"partOfGroups": [
"sap.cds:service:customer.capirebookshopordsample:CatalogService",
],
"partOfPackage": "customer.capirebookshopordsample:package:capirebookshopordsample:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "openapi-v3",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/CatalogService.oas3.json",
},
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/xml",
"type": "edmx",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/CatalogService.edmx",
},
],
"shortDescription": "Short description for CatalogService",
"title": "CatalogService",
"version": "1.0.0",
"visibility": "public",
},
],
Expand Down Expand Up @@ -153,35 +101,6 @@ exports[`Tests for default ORD document when .cdsrc.json is not present Successf
"shortDescription": "short description for test AdminService",
"title": "This is test AdminService title",
"version": "2.0.0",
"visibility": "private",
},
{
"description": "CAP Event resource describing events / messages.",
"extensible": {
"supported": "no",
},
"lastUpdate": "2024-11-04T14:33:25+01:00",
"ordId": "customer.capirebookshopordsample:eventResource:CatalogService:v1",
"partOfGroups": [
"sap.cds:service:customer.capirebookshopordsample:CatalogService",
],
"partOfPackage": "customer.capirebookshopordsample:package:capirebookshopordsample:v1",
"releaseStatus": "active",
"resourceDefinitions": [
{
"accessStrategies": [
{
"type": "open",
},
],
"mediaType": "application/json",
"type": "asyncapi-v2",
"url": "/.well-known/open-resource-discovery/v1/api-metadata/CatalogService.asyncapi2.json",
},
],
"shortDescription": "CatalogService event resource",
"title": "ODM capirebookshopordsample Events",
"version": "1.0.0",
"visibility": "public",
},
],
Expand All @@ -194,7 +113,12 @@ exports[`Tests for default ORD document when .cdsrc.json is not present Successf
{
"groupId": "sap.cds:service:customer.capirebookshopordsample:CatalogService",
"groupTypeId": "sap.cds:service",
"title": "Catalog Service",
"title": "This is test Catalog Service title",
},
{
"groupId": "sap.cds:service:customer.capirebookshopordsample:CinemaService",
"groupTypeId": "sap.cds:service",
"title": "This is test Cinema Service title",
},
],
"openResourceDiscovery": "1.9",
Expand Down
8 changes: 8 additions & 0 deletions __tests__/bookshop/db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ entity Genres : sap.common.CodeList {
children : Composition of many Genres
on children.parent = $self;
}

entity Movies : managed {
key ID : Integer;
title : localized String(111);
descr : localized String(1111);
author : Association to Authors;
genre : Association to Genres;
}
2 changes: 1 addition & 1 deletion __tests__/bookshop/srv/admin-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ service AdminService @(requires: 'authenticated-user') {
annotate AdminService with @ORD.Extensions: {
title : 'This is test AdminService title',
shortDescription : 'short description for test AdminService',
visibility : 'private',
visibility : 'public',
version : '2.0.0',
extensible : {supported: 'yes'},
entityTypeMappings: {entityTypeTargets: [{ordId: 'sap.odm:entityType:test-from-extension:v1'}]},
Expand Down
8 changes: 8 additions & 0 deletions __tests__/bookshop/srv/cat-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ service CatalogService @(path: '/browse') {
title : String @title: 'Title';
}
}

annotate CatalogService with @ORD.Extensions: {
title : 'This is test Catalog Service title',
shortDescription : 'short description for test CatalogService',
visibility : 'private',
version : '2.0.0',
extensible : {supported: 'yes'}
};
40 changes: 40 additions & 0 deletions __tests__/bookshop/srv/cinema-service.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using {sap.capire.bookshop as my} from '../db/schema';

service CinemaService @(path: '/browse') {

@readonly
entity Movies as
select from my.Movies {
*,
author.name as author
}
excluding {
createdBy,
modifiedBy
};

@requires: 'authenticated-user'
action submitOrder(book : Movies:ID, quantity : Integer);

event MovieCreated : {
ID : Integer;
title : String @title: 'Title';
};

event MovieDeleted : {
ID : Integer;
};

event MovieUpdated : {
ID : Integer;
title : String @title: 'Title';
}
}

annotate CinemaService with @ORD.Extensions: {
title : 'This is test Cinema Service title',
shortDescription : 'short description for test CinemaService',
visibility : 'internal',
version : '1.0.0',
extensible : {supported: 'yes'}
};
6 changes: 3 additions & 3 deletions __tests__/ordCdsrc.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const cds = require("@sap/cds");
const ord = require("../lib/ord");
const path = require("path");

// Mock the @sap/cds module
jest.mock("@sap/cds", () => {
const { join } = require("path");
const path = require("path");
let originalCds = jest.requireActual("@sap/cds");
originalCds.root = join(__dirname, "bookshop");
originalCds.root = path.join(__dirname, "bookshop");
return originalCds;
});

jest.mock("../lib/date", () => ({
getRFC3339Date: jest.fn(() => "2024-11-04T14:33:25+01:00")
}));

const cds = require("@sap/cds");

describe("Tests for default ORD document when .cdsrc.json is present", () => {
let csn;
Expand Down
12 changes: 6 additions & 6 deletions __tests__/ordPackageJson.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
const cds = require("@sap/cds");
const ord = require("../lib/ord");
const { join } = require("path");
const path = require("path");


// Mock the @sap/cds module
jest.mock("@sap/cds", () => {
const { join } = require("path");
const path = require("path");
let originalCds = jest.requireActual("@sap/cds");
originalCds.root = join(__dirname, "bookshop");
originalCds.root = path.join(__dirname, "bookshop");
return originalCds;
});

jest.mock("../lib/date", () => ({
getRFC3339Date: jest.fn(() => "2024-11-04T14:33:25+01:00")
}));

const cds = require("@sap/cds");

describe("Tests for default ORD document when .cdsrc.json is not present", () => {
let csn;

beforeAll(async () => {
cds.env["ord"] = "";
csn = await cds.load(join(__dirname, "bookshop", "srv"));
csn = await cds.load(path.join(__dirname, "bookshop", "srv"));

});

Expand Down
Loading