@cap-js/cds-types 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cds-types.d.ts +81 -5
  2. package/package.json +18 -23
@@ -378,7 +378,13 @@ namespace cds {
378
378
  operator,
379
379
  function_call,
380
380
  enum_literal,
381
- expr_literal
381
+ expr_literal,
382
+ Texts,
383
+ I18nBundle,
384
+ I18nFacade,
385
+ I18nFilesOptions,
386
+ I18nFiles,
387
+ i18n
382
388
  }
383
389
  }
384
390
 
@@ -458,6 +464,7 @@ namespace classes {
458
464
  TimeStamp,
459
465
  array,
460
466
  struct,
467
+ Map_3 as Map,
461
468
  context_,
462
469
  service_,
463
470
  action,
@@ -644,7 +651,7 @@ class ConstructedQuery<T> {
644
651
  // that don't make explicit use of the generic. So `UPDATE<Books> !<: UPDATE<number>`
645
652
  private _: T
646
653
  then (_resolved: (x: any) => any, _rejected: (e: Error) => any): any
647
-
654
+ bind (service: Service): this
648
655
  }
649
656
 
650
657
  /**
@@ -760,6 +767,7 @@ namespace csn {
760
767
  service_2 as service,
761
768
  type_2 as type,
762
769
  struct_2 as struct,
770
+ Map_2 as Map,
763
771
  entity_2 as entity,
764
772
  EntityElements,
765
773
  Association_2 as Association
@@ -982,7 +990,13 @@ export namespace default_2 {
982
990
  operator,
983
991
  function_call,
984
992
  enum_literal,
985
- expr_literal
993
+ expr_literal,
994
+ Texts,
995
+ I18nBundle,
996
+ I18nFacade,
997
+ I18nFilesOptions,
998
+ I18nFiles,
999
+ i18n
986
1000
  }
987
1001
  }
988
1002
 
@@ -1430,8 +1444,57 @@ type HavingWhere<This, E> =
1430
1444
  & ((...expr: string[]) => This)
1431
1445
  & TaggedTemplateQueryPart<This>
1432
1446
 
1447
+ interface Hints {
1448
+ hints: ((...hints: string[]) => this)
1449
+ & ((hints: string[]) => this)
1450
+ }
1451
+
1433
1452
  export const home: string;
1434
1453
 
1454
+ export const i18n: I18nFacade;
1455
+
1456
+ export class I18nBundle {
1457
+ constructor(options: I18nFilesOptions)
1458
+ for(key: number | string | object, locale?: string | object, args?: object): string | undefined
1459
+ at(key: number | string | object, locale?: string | object, args?: object): string | undefined
1460
+ files: I18nFiles
1461
+ get defaults(): Record<string, string>
1462
+ get fallback(): Record<string, string>
1463
+ key4(definition: entity): string
1464
+ texts4 (locale: string): Texts
1465
+ translations4 (...locales : string[]) : { [locale: string]: Texts }
1466
+ translations4 (locale : 'all' ) : { [locale: string]: Texts }
1467
+ all () : Record<string, Texts>
1468
+ }
1469
+
1470
+ export interface I18nFacade {
1471
+ Bundle: typeof I18nBundle
1472
+ Facade: I18nFacade
1473
+ Files: typeof I18nFiles
1474
+ get file(): string
1475
+ get folders(): string[]
1476
+ get labels(): I18nBundle
1477
+ get messages(): I18nBundle
1478
+
1479
+ bundle4 (file: string, options?: I18nFilesOptions): I18nBundle
1480
+ bundle4 (model: csn.CSN): I18nBundle
1481
+ }
1482
+
1483
+ export class I18nFiles {
1484
+ constructor (options: I18nFilesOptions)
1485
+ get options(): I18nFilesOptions
1486
+ get basename(): string
1487
+ content4(locale: string, suffix: string): Array<object>
1488
+ }
1489
+
1490
+ export interface I18nFilesOptions {
1491
+ file? : string
1492
+ model? : csn.CSN
1493
+ roots? : string[]
1494
+ leafs? : string[]
1495
+ folders? : string[]
1496
+ }
1497
+
1435
1498
  export const insert: Service['insert'];
1436
1499
 
1437
1500
  type INSERT_2 = { INSERT: {
@@ -1874,6 +1937,17 @@ type ManagedAssociation = Association & {
1874
1937
  keys: Column[],
1875
1938
  }
1876
1939
 
1940
+ interface Map_2 extends Omit<struct_2, 'includes' | 'items'> {
1941
+ elements: Record<string,never>
1942
+ }
1943
+
1944
+ /**
1945
+ * @since 8.6.0
1946
+ */
1947
+ interface Map_3 extends csn.Map {}
1948
+
1949
+ class Map_3 {}
1950
+
1877
1951
  export class MessagingService extends Service {}
1878
1952
 
1879
1953
  export type Middlewares = 'context' | 'trace' | 'auth' | 'ctx_model' | string
@@ -2437,7 +2511,7 @@ type SELECT_2 = { SELECT: {
2437
2511
  }, }
2438
2512
  export { SELECT_2 as SELECT }
2439
2513
 
2440
- interface SELECT_3<T> extends Where<T>, And, Having<T>, GroupBy, OrderBy<T>, Limit {
2514
+ interface SELECT_3<T> extends Where<T>, And, Having<T>, GroupBy, OrderBy<T>, Limit, Hints {
2441
2515
  // overload specific to SELECT
2442
2516
  columns: Columns<T, this>['columns'] & ((projection: Projection<T>) => this)
2443
2517
  }
@@ -2962,6 +3036,8 @@ export const test: {
2962
3036
  log: Test['log'],
2963
3037
  };
2964
3038
 
3039
+ export type Texts = Record<string, string>
3040
+
2965
3041
  class Time extends date { }
2966
3042
 
2967
3043
  class TimeStamp extends DateTime { }
@@ -3006,7 +3082,7 @@ interface type_2 extends any__2 {
3006
3082
  'cds.UUID' | 'cds.String' | 'cds.LargeString' | 'cds.Binary' | 'cds.LargeBinary' | 'cds.Vector' |
3007
3083
  'cds.Integer' | 'cds.UInt8' | 'cds.Int16' | 'cds.Int32' | 'cds.Int64' | 'cds.Double' | 'cds.Decimal' |
3008
3084
  'cds.Date' | 'cds.Time' | 'cds.DateTime' | 'cds.Timestamp' |
3009
- 'cds.Association' | 'cds.Composition' |
3085
+ 'cds.Association' | 'cds.Composition' | 'cds.Map' |
3010
3086
  FQN & Record<never,never> // allow any other CDS type as well (e.g. 'User')
3011
3087
  items?: type_2
3012
3088
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/cds-types",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Type definitions for main packages of CAP, like `@sap/cds`",
5
5
  "repository": "github:cap-js/cds-types",
6
6
  "homepage": "https://cap.cloud.sap/",
@@ -10,18 +10,25 @@
10
10
  "Node.js"
11
11
  ],
12
12
  "author": "SAP SE (https://www.sap.com)",
13
- "license": "SEE LICENSE IN LICENSE",
13
+ "license": "Apache-2.0",
14
14
  "typings": "dist/cds-types.d.ts",
15
15
  "files": [
16
16
  "dist/",
17
17
  "scripts/",
18
- "LICENSE",
19
18
  "README.md"
20
19
  ],
21
20
  "scripts": {
22
- "test": "jest --silent",
23
- "test:integration": "jest --testMatch \"**/test/**/*.integrationtest.js\"",
24
- "test:rollup": "npm run rollup; npm run rollup:on; npm run test; npm run rollup:off",
21
+ "test:integration": "node --test ./test/postinstall.integrationtest.js",
22
+ "test:runtime": "npm run test:runtime:post-mortem; rm -rf test/typescript/_out",
23
+ "test:runtime:tsc": "npx tsc test/typescript/runtime.test.ts --outDir test/typescript/_out --target ES2020 --module commonjs --esModuleInterop",
24
+ "test:runtime:post-mortem": "npm run test:runtime:tsc && node --test './test/typescript/_out/runtime.test.js'",
25
+ "test:api-calls": "node --test './test/typescript/apis/cds-api-calls.test.js'",
26
+ "test:typings": "node --test './test/typescript/cds-typings.test.js'",
27
+ "test:all": "npm run test:runtime && npm run test:api-calls && npm run test:typings",
28
+ "test:setup": "npm install file:. --no-save --force && npm run prerelease:ci-fix",
29
+ "test": "npm run test:setup && npm run test:rollup-on",
30
+ "test:rollup-on": "npm run rollup && npm run rollup:on && npm run test:all --silent",
31
+ "test:rollup-off": "npm run rollup:off && npm run test:all --silent",
25
32
  "rollup": "rm -rf dist/ && mkdir -p etc/ && npx -y @microsoft/api-extractor run --local --verbose && .github/rollup-patch.js",
26
33
  "rollup:on": "npm pkg set typings=dist/cds-types.d.ts && [ -d 'apis' ] && mv -- apis -apis || true",
27
34
  "rollup:off": "npm pkg set typings=apis/cds.d.ts && [ -d '-apis' ] && mv -- -apis apis || true",
@@ -33,28 +40,16 @@
33
40
  "dependencies": "node ./scripts/postinstall.js"
34
41
  },
35
42
  "peerDependencies": {
36
- "@sap/cds": "^8.0.0",
43
+ "@sap/cds": ">=8.0.0",
37
44
  "@types/express": ">=4"
38
45
  },
39
46
  "devDependencies": {
40
- "@eslint/js": "^9.2.0",
41
- "@sap/cds": ">=8.0.0",
42
- "@stylistic/eslint-plugin-js": "^2.1.0",
43
- "@stylistic/eslint-plugin-ts": "^2.1.0",
44
- "@types/jest": "^29.5.11",
45
- "@types/node": "^22",
47
+ "@cap-js/cds-test": "^0",
48
+ "@stylistic/eslint-plugin-js": "^4.0.1",
49
+ "@stylistic/eslint-plugin-ts": "^4.0.1",
46
50
  "axios": "^1.6.2",
47
- "chai": "^4.3.10",
48
51
  "eslint": "^9.2.0",
49
- "jest": "^29.7.0",
50
- "ts-jest": "^29.1.1",
51
52
  "typescript": "^5.4.5",
52
- "typescript-eslint": "^8.0.0-alpha.51",
53
- "winston": "^3.13.0"
54
- },
55
- "jest": {
56
- "transform": {
57
- "^.+\\.(ts|tsx)$": "ts-jest"
58
- }
53
+ "typescript-eslint": "^8.0.0-alpha.51"
59
54
  }
60
55
  }