@bett3r-dev/pv3-types 1.0.0 → 1.11.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 (137) hide show
  1. package/CHANGELOG.md +305 -0
  2. package/build/adminPlugin.d.ts +24 -0
  3. package/build/adminPlugin.d.ts.map +1 -0
  4. package/build/{eventsourcing/utils.js → adminPlugin.js} +1 -1
  5. package/build/adminPlugin.js.map +1 -0
  6. package/build/aggregateSchema.d.ts +94 -0
  7. package/build/aggregateSchema.d.ts.map +1 -0
  8. package/build/aggregateSchema.js +287 -0
  9. package/build/aggregateSchema.js.map +1 -0
  10. package/build/authentication.d.ts +179 -78
  11. package/build/authentication.d.ts.map +1 -1
  12. package/build/authentication.js +62 -19
  13. package/build/authentication.js.map +1 -1
  14. package/build/cache.d.ts +50 -4
  15. package/build/cache.d.ts.map +1 -1
  16. package/build/clusterAdministration.d.ts +712 -225
  17. package/build/clusterAdministration.d.ts.map +1 -1
  18. package/build/clusterAdministration.js +175 -52
  19. package/build/clusterAdministration.js.map +1 -1
  20. package/build/configuration.d.ts +26 -5
  21. package/build/configuration.d.ts.map +1 -1
  22. package/build/database.d.ts +240 -56
  23. package/build/database.d.ts.map +1 -1
  24. package/build/database.js +102 -20
  25. package/build/database.js.map +1 -1
  26. package/build/endpoints.d.ts +141 -41
  27. package/build/endpoints.d.ts.map +1 -1
  28. package/build/endpoints.js +50 -26
  29. package/build/endpoints.js.map +1 -1
  30. package/build/errors.d.ts +166 -0
  31. package/build/errors.d.ts.map +1 -0
  32. package/build/errors.js +276 -0
  33. package/build/errors.js.map +1 -0
  34. package/build/evenstore.d.ts +47 -7
  35. package/build/evenstore.d.ts.map +1 -1
  36. package/build/eventsourcing/aggregateBuilder.d.ts +17 -8
  37. package/build/eventsourcing/aggregateBuilder.d.ts.map +1 -1
  38. package/build/eventsourcing/commandBuilder.d.ts +20 -13
  39. package/build/eventsourcing/commandBuilder.d.ts.map +1 -1
  40. package/build/eventsourcing/commandHandlers.d.ts +155 -33
  41. package/build/eventsourcing/commandHandlers.d.ts.map +1 -1
  42. package/build/eventsourcing/commandHandlers.js +62 -14
  43. package/build/eventsourcing/commandHandlers.js.map +1 -1
  44. package/build/eventsourcing/eventHandlers.d.ts +173 -44
  45. package/build/eventsourcing/eventHandlers.d.ts.map +1 -1
  46. package/build/eventsourcing/eventHandlers.js +29 -21
  47. package/build/eventsourcing/eventHandlers.js.map +1 -1
  48. package/build/eventsourcing/eventHandlersBuilder.d.ts +18 -12
  49. package/build/eventsourcing/eventHandlersBuilder.d.ts.map +1 -1
  50. package/build/eventsourcing/eventHandlersBuilder.js.map +1 -1
  51. package/build/eventsourcing/eventsourcing.types.d.ts +322 -0
  52. package/build/eventsourcing/eventsourcing.types.d.ts.map +1 -0
  53. package/build/eventsourcing/eventsourcing.types.js +26 -0
  54. package/build/eventsourcing/eventsourcing.types.js.map +1 -0
  55. package/build/eventsourcing/externalSystemBuilder.d.ts +8 -7
  56. package/build/eventsourcing/externalSystemBuilder.d.ts.map +1 -1
  57. package/build/eventsourcing/index.d.ts +2 -378
  58. package/build/eventsourcing/index.d.ts.map +1 -1
  59. package/build/eventsourcing/index.js +2 -23
  60. package/build/eventsourcing/index.js.map +1 -1
  61. package/build/eventsourcing/invariants.d.ts +34 -10
  62. package/build/eventsourcing/invariants.d.ts.map +1 -1
  63. package/build/eventsourcing/shapeChangeForSubscriber.d.ts +33 -0
  64. package/build/eventsourcing/shapeChangeForSubscriber.d.ts.map +1 -0
  65. package/build/eventsourcing/shapeChangeForSubscriber.js +47 -0
  66. package/build/eventsourcing/shapeChangeForSubscriber.js.map +1 -0
  67. package/build/index.d.ts +6 -1
  68. package/build/index.d.ts.map +1 -1
  69. package/build/index.js +6 -1
  70. package/build/index.js.map +1 -1
  71. package/build/infrastructure.d.ts +9 -1
  72. package/build/infrastructure.d.ts.map +1 -1
  73. package/build/infrastructure.js +33 -1
  74. package/build/infrastructure.js.map +1 -1
  75. package/build/livenessWatchdog.d.ts +28 -0
  76. package/build/livenessWatchdog.d.ts.map +1 -0
  77. package/build/livenessWatchdog.js +43 -0
  78. package/build/livenessWatchdog.js.map +1 -0
  79. package/build/logger.d.ts +8 -9
  80. package/build/logger.d.ts.map +1 -1
  81. package/build/logger.js +18 -6
  82. package/build/logger.js.map +1 -1
  83. package/build/outboxManager.d.ts +858 -14
  84. package/build/outboxManager.d.ts.map +1 -1
  85. package/build/outboxManager.js +173 -15
  86. package/build/outboxManager.js.map +1 -1
  87. package/build/permissions.d.ts +47 -0
  88. package/build/permissions.d.ts.map +1 -0
  89. package/build/permissions.js +3 -0
  90. package/build/permissions.js.map +1 -0
  91. package/build/ports.d.ts +10 -10
  92. package/build/ports.d.ts.map +1 -1
  93. package/build/routesAuth.d.ts +17 -25
  94. package/build/routesAuth.d.ts.map +1 -1
  95. package/build/routesAuth.js +4 -14
  96. package/build/routesAuth.js.map +1 -1
  97. package/build/typedEventEmitter.d.ts +7 -13
  98. package/build/typedEventEmitter.d.ts.map +1 -1
  99. package/build/typedEventEmitter.js +2 -2
  100. package/build/typedEventEmitter.js.map +1 -1
  101. package/build/userSession.d.ts +8 -0
  102. package/build/userSession.d.ts.map +1 -0
  103. package/build/userSession.js +3 -0
  104. package/build/userSession.js.map +1 -0
  105. package/package.json +22 -7
  106. package/build/eventsourcing/utils.d.ts +0 -4
  107. package/build/eventsourcing/utils.d.ts.map +0 -1
  108. package/build/eventsourcing/utils.js.map +0 -1
  109. package/build/validation.d.ts +0 -64
  110. package/build/validation.d.ts.map +0 -1
  111. package/build/validation.js +0 -57
  112. package/build/validation.js.map +0 -1
  113. package/src/authentication.ts +0 -273
  114. package/src/cache.ts +0 -109
  115. package/src/clusterAdministration.ts +0 -216
  116. package/src/configuration.ts +0 -71
  117. package/src/database.ts +0 -157
  118. package/src/endpoints.ts +0 -198
  119. package/src/evenstore.ts +0 -27
  120. package/src/eventsourcing/aggregateBuilder.ts +0 -11
  121. package/src/eventsourcing/commandBuilder.ts +0 -64
  122. package/src/eventsourcing/commandHandlers.ts +0 -137
  123. package/src/eventsourcing/eventHandlers.ts +0 -118
  124. package/src/eventsourcing/eventHandlersBuilder.ts +0 -42
  125. package/src/eventsourcing/externalSystemBuilder.ts +0 -20
  126. package/src/eventsourcing/index.ts +0 -111
  127. package/src/eventsourcing/invariants.ts +0 -27
  128. package/src/eventsourcing/utils.ts +0 -4
  129. package/src/index.ts +0 -15
  130. package/src/infrastructure.ts +0 -41
  131. package/src/logger.ts +0 -45
  132. package/src/outboxManager.ts +0 -36
  133. package/src/ports.ts +0 -42
  134. package/src/routesAuth.ts +0 -58
  135. package/src/typedEventEmitter.ts +0 -73
  136. package/src/validation.ts +0 -89
  137. package/tsconfig.json +0 -15
package/package.json CHANGED
@@ -1,15 +1,30 @@
1
1
  {
2
2
  "name": "@bett3r-dev/pv3-types",
3
- "version": "1.0.0",
3
+ "version": "1.11.0",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "clean": "yarn run -T tsc --build --clean",
9
- "prebuild": "yarn clean",
10
- "build": "yarn run -T tsc --build --verbose"
8
+ "clean": "rm -rf build && rm -rf *.tsbuildinfo",
9
+ "build": "yarn run -T tsgo --build --verbose"
11
10
  },
12
11
  "dependencies": {
13
- "@bett3r-dev/jsonschema-definer": "^1.4.4"
14
- }
15
- }
12
+ "@bett3r-dev/jsonschema-definer": "^1.5.9",
13
+ "json-schema": "^0.4.0",
14
+ "openapi-types": "^12.1.3",
15
+ "ts-toolbelt": "^6"
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/",
19
+ "access": "public"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/bett3r-dev/pv3.git",
24
+ "directory": "packages/pv3-types"
25
+ },
26
+ "files": [
27
+ "build/**/*",
28
+ "README.md"
29
+ ]
30
+ }
@@ -1,4 +0,0 @@
1
- import { CommittedEvent, EventFactory, EventHandler, GetMessageType, System } from '.';
2
- import { O } from 'ts-toolbelt';
3
- export type CreateEventType<Handler extends System | EventHandler> = <EVENT extends keyof O.Path<Handler, ['events']>>(event: EVENT, data?: GetMessageType<Handler['events'][EVENT]>, committedEvent?: Partial<Omit<CommittedEvent, 'data' | 'name'>>) => EventFactory<EVENT, GetMessageType<Handler['events'][EVENT]>>;
4
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/eventsourcing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AACvF,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,MAAM,GAAG,YAAY,IAAI,CAAC,KAAK,SAAS,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAG,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,KAAM,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/eventsourcing/utils.ts"],"names":[],"mappings":""}
@@ -1,64 +0,0 @@
1
- import { BaseSchema } from '@bett3r-dev/jsonschema-definer';
2
- export type AppErrorInstance<ErrorPayload = unknown> = Error & AppErrorData<ErrorPayload>;
3
- export type AppErrorData<ErrorPayload = unknown> = {
4
- error?: string;
5
- description?: string;
6
- type: ErrorTypes;
7
- details?: ErrorPayload;
8
- status?: number;
9
- };
10
- export type AppErrorType<ErrorPayload = any> = AppErrorData<ErrorPayload> & {
11
- schema?: BaseSchema<ErrorPayload>;
12
- };
13
- /**
14
- * @hidden
15
- */
16
- export declare const errorStatusCodeMap: {
17
- BadRequestError: number;
18
- UnauthorizedError: number;
19
- PaymentRequiredError: number;
20
- ForbiddenError: number;
21
- NotFoundError: number;
22
- MethodNotAllowedError: number;
23
- NotAcceptableError: number;
24
- ProxyAuthenticationRequiredError: number;
25
- RequestTimeoutError: number;
26
- ConflictError: number;
27
- ConcurrencyError: number;
28
- GoneError: number;
29
- LengthRequiredError: number;
30
- PreconditionFailedError: number;
31
- PayloadTooLargeError: number;
32
- TooManyRequestsError: number;
33
- InternalServerError: number;
34
- NotImplementedError: number;
35
- BadGatewayError: number;
36
- ServiceUnavailableError: number;
37
- GatewayTimeoutError: number;
38
- };
39
- export declare const statusCodeErrorMap: {
40
- 400: string;
41
- 401: string;
42
- 402: string;
43
- 403: string;
44
- 404: string;
45
- 405: string;
46
- 406: string;
47
- 407: string;
48
- 408: string;
49
- 409: string;
50
- 410: string;
51
- 411: string;
52
- 412: string;
53
- 413: string;
54
- 429: string;
55
- 500: string;
56
- 501: string;
57
- 502: string;
58
- 503: string;
59
- 504: string;
60
- };
61
- declare const ErrorTypesSchema: BaseSchema<"BadRequestError" | "UnauthorizedError" | "PaymentRequiredError" | "ForbiddenError" | "NotFoundError" | "MethodNotAllowedError" | "NotAcceptableError" | "ProxyAuthenticationRequiredError" | "RequestTimeoutError" | "ConflictError" | "ConcurrencyError" | "GoneError" | "LengthRequiredError" | "PreconditionFailedError" | "PayloadTooLargeError" | "TooManyRequestsError" | "InternalServerError" | "NotImplementedError" | "BadGatewayError" | "ServiceUnavailableError" | "GatewayTimeoutError", true, Readonly<import("@bett3r-dev/jsonschema-definer/dist/base").BaseJsonSchema>>;
62
- export type ErrorTypes = typeof ErrorTypesSchema.type;
63
- export {};
64
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAU,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE/D,MAAM,MAAM,gBAAgB,CAAC,YAAY,GAAG,OAAO,IAAI,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,CAAA;AACzF,MAAM,MAAM,YAAY,CAAC,YAAY,GAAG,OAAO,IAAI;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,MAAM,CAAC,EAAC,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,YAAY,GAAG,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,GAAG;IAAC,MAAM,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;CAAC,CAAA;AAE/G;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;CAsB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;CAqB9B,CAAC;AAGF,QAAA,MAAM,gBAAgB,ukBAsBrB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC"}
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.statusCodeErrorMap = exports.errorStatusCodeMap = void 0;
7
- const jsonschema_definer_1 = __importDefault(require("@bett3r-dev/jsonschema-definer"));
8
- /**
9
- * @hidden
10
- */
11
- exports.errorStatusCodeMap = {
12
- BadRequestError: 400,
13
- UnauthorizedError: 401,
14
- PaymentRequiredError: 402,
15
- ForbiddenError: 403,
16
- NotFoundError: 404,
17
- MethodNotAllowedError: 405,
18
- NotAcceptableError: 406,
19
- ProxyAuthenticationRequiredError: 407,
20
- RequestTimeoutError: 408,
21
- ConflictError: 409,
22
- ConcurrencyError: 409,
23
- GoneError: 410,
24
- LengthRequiredError: 411,
25
- PreconditionFailedError: 412,
26
- PayloadTooLargeError: 413,
27
- TooManyRequestsError: 429,
28
- InternalServerError: 500,
29
- NotImplementedError: 501,
30
- BadGatewayError: 502,
31
- ServiceUnavailableError: 503,
32
- GatewayTimeoutError: 504,
33
- };
34
- exports.statusCodeErrorMap = {
35
- 400: 'BadRequestError',
36
- 401: 'UnauthorizedError',
37
- 402: 'PaymentRequiredError',
38
- 403: 'ForbiddenError',
39
- 404: 'NotFoundError',
40
- 405: 'MethodNotAllowedError',
41
- 406: 'NotAcceptableError',
42
- 407: 'ProxyAuthenticationRequiredError',
43
- 408: 'RequestTimeoutError',
44
- 409: 'ConcurrencyError',
45
- 410: 'GoneError',
46
- 411: 'LengthRequiredError',
47
- 412: 'PreconditionFailedError',
48
- 413: 'PayloadTooLargeError',
49
- 429: 'TooManyRequestsError',
50
- 500: 'InternalServerError',
51
- 501: 'NotImplementedError',
52
- 502: 'BadGatewayError',
53
- 503: 'ServiceUnavailableError',
54
- 504: 'GatewayTimeoutError',
55
- };
56
- const ErrorTypesSchema = jsonschema_definer_1.default.string().enum('BadRequestError', 'UnauthorizedError', 'PaymentRequiredError', 'ForbiddenError', 'NotFoundError', 'MethodNotAllowedError', 'NotAcceptableError', 'ProxyAuthenticationRequiredError', 'RequestTimeoutError', 'ConflictError', 'ConcurrencyError', 'GoneError', 'LengthRequiredError', 'PreconditionFailedError', 'PayloadTooLargeError', 'TooManyRequestsError', 'InternalServerError', 'NotImplementedError', 'BadGatewayError', 'ServiceUnavailableError', 'GatewayTimeoutError');
57
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;;;;AAAA,wFAA+D;AAa/D;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,eAAe,EAAE,GAAG;IACpB,iBAAiB,EAAE,GAAG;IACtB,oBAAoB,EAAE,GAAG;IACzB,cAAc,EAAE,GAAG;IACnB,aAAa,EAAE,GAAG;IAClB,qBAAqB,EAAE,GAAG;IAC1B,kBAAkB,EAAE,GAAG;IACvB,gCAAgC,EAAE,GAAG;IACrC,mBAAmB,EAAE,GAAG;IACxB,aAAa,EAAE,GAAG;IAClB,gBAAgB,EAAE,GAAG;IACrB,SAAS,EAAE,GAAG;IACd,mBAAmB,EAAE,GAAG;IACxB,uBAAuB,EAAE,GAAG;IAC5B,oBAAoB,EAAE,GAAG;IACzB,oBAAoB,EAAE,GAAG;IACzB,mBAAmB,EAAE,GAAG;IACxB,mBAAmB,EAAE,GAAG;IACxB,eAAe,EAAE,GAAG;IACpB,uBAAuB,EAAE,GAAG;IAC5B,mBAAmB,EAAE,GAAG;CACzB,CAAC;AAEW,QAAA,kBAAkB,GAAG;IAChC,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,kCAAkC;IACvC,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,sBAAsB;IAC3B,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,qBAAqB;CAC3B,CAAC;AAGF,MAAM,gBAAgB,GAAG,4BAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CACtC,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,kCAAkC,EAClC,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,CACtB,CAAC"}
@@ -1,273 +0,0 @@
1
- import S, { mergeMultipleSchemas, mergeSchemas, omitFromSchema } from '@bett3r-dev/jsonschema-definer';
2
- import { RoutesAuthManagerType } from './routesAuth';
3
- import { ClusterRoutesConfigType } from './clusterAdministration';
4
- import { AdapterBase, PortEmitter } from './ports';
5
- import { Ports } from './ports';
6
-
7
- //*******************************************
8
- // Schemas
9
- //*******************************************
10
- /**
11
- * @category Schemas
12
- */
13
- export const AuthenticationIdSchema = S.shape({
14
- id: S.string()
15
- });
16
- /**
17
- * @category Schemas
18
- */
19
- export const AuthenticationEmailSchema = S.shape({
20
- email: S.string().format( 'email' )
21
- });
22
- export type AuthenticationEmail = typeof AuthenticationEmailSchema.type;
23
-
24
- /**
25
- * @category Schemas
26
- */
27
- export const AuthenticationPasswordSchema = S.shape({
28
- password: S.string()
29
- });
30
- export type AuthenticationPassword = typeof AuthenticationPasswordSchema.type;
31
-
32
- /**
33
- * @category Schemas
34
- */
35
- export const AuthenticationRoleSchema = S.shape({
36
- role: S.string(),
37
- });
38
-
39
- /**
40
- * @category Schemas
41
- */
42
- export const AuthenticationRolesSchema = S.shape({
43
- roles: S.array().items( S.string()),
44
- });
45
- export type AuthenticationRolesType = typeof AuthenticationRolesSchema.type;
46
-
47
- /**
48
- * @category Schemas
49
- */
50
- export const AuthenticationProviderIdSchema = S.shape({
51
- providerId: S.string(),
52
- providerName: S.string(),
53
- });
54
- export type AuthenticationProviderId = typeof AuthenticationProviderIdSchema.type
55
-
56
- /**
57
- * @category Schemas
58
- */
59
- export const AuthenticationProviderUserSchema = mergeSchemas( AuthenticationEmailSchema, AuthenticationProviderIdSchema );
60
-
61
- /**
62
- * @category Schemas
63
- */
64
- export const UserLoginSchema = mergeSchemas( AuthenticationEmailSchema, AuthenticationPasswordSchema );
65
- export type UserLogin = typeof UserLoginSchema.type
66
-
67
- /**
68
- * @category Schemas
69
- */
70
- export const AuthenticationRegistrationSchema = mergeSchemas( UserLoginSchema, AuthenticationRolesSchema );
71
- export type AuthenticationRegistrationType = typeof AuthenticationRegistrationSchema.type;
72
-
73
- /**
74
- * @category Schemas
75
- */
76
- export const AuthenticationCustomAttributesSchema = S.shape({
77
- attributes: S.shape({}).additionalProperties( true ).optional()
78
- });
79
- export type AuthenticationCustomAttributesType = typeof AuthenticationCustomAttributesSchema.type;
80
-
81
- /**
82
- * @category Schemas
83
- */
84
- export const AuthenticationUserSchema = mergeMultipleSchemas( AuthenticationIdSchema, AuthenticationEmailSchema, AuthenticationRolesSchema, AuthenticationCustomAttributesSchema );
85
- export type AuthenticationUser = typeof AuthenticationUserSchema.type;
86
-
87
-
88
- /**
89
- * @category Schemas
90
- */
91
- export const AuthenticationCreateUserCommandSchema = mergeSchemas( AuthenticationUserSchema, AuthenticationPasswordSchema );
92
- export type AuthenticationCreateUserCommand = typeof AuthenticationCreateUserCommandSchema.type
93
-
94
- export const AuthenticationUpdateUserCommandSchema = mergeSchemas( omitFromSchema( AuthenticationCreateUserCommandSchema, [ 'password', 'id', 'roles' ]).partial(), S.shape({ providerId: S.string() }));
95
- export type AuthenticationUpdateUserCommand = typeof AuthenticationUpdateUserCommandSchema.type;
96
-
97
- /**
98
- * @category Schemas
99
- */
100
- export const AuthenticationResponseSchema = mergeSchemas( AuthenticationRolesSchema, S.shape({
101
- 'expires_in': S.number(),
102
- 'refresh_expires_in': S.number(),
103
- 'not-before-policy': S.number(),
104
- 'access_token': S.string(),
105
- 'refresh_token': S.string(),
106
- 'token_type': S.string(),
107
- 'session_state': S.string(),
108
- 'scope': S.string(),
109
- }));
110
- export type AuthenticationResponseType = typeof AuthenticationResponseSchema.type;
111
-
112
-
113
- //*******************************************
114
- // Identity Provider
115
- //*******************************************
116
-
117
-
118
- /**
119
- * Logs a user in the Application.
120
- * @category Authentication Port
121
- * @param email Email of the user
122
- * @param password Password of the user
123
- */
124
- export declare function loginUser ( email:string, password:string ): Promise<AuthenticationResponseType>;
125
-
126
- /**
127
- * Inits the Recover Password process for the user with the given email.
128
- * @category Authentication Port
129
- * @param email Email of the user
130
- */
131
- export declare function recoverPassword ( email:string ): Promise<void>;
132
-
133
- /**
134
- * Marks the user email address as validated.
135
- * @category Authentication Port
136
- * @param email Email of the user
137
- */
138
- export declare function verifyEmail ( email: string ): Promise<void>;
139
-
140
- /**
141
- * Logs out a user from the application
142
- * @category Authentication Port
143
- * @param token Session Token to mark as logged out
144
- */
145
- export declare function logoutUser ( token: string ): Promise<void>;
146
-
147
- /**
148
- * Refreshes the user sesssion given the refresh token.
149
- * @category Authentication Port
150
- * @param refreshToken Session Refresh Token
151
- */
152
- export declare function refreshToken ( refreshToken: string ): Promise<AuthenticationResponseType>;
153
-
154
- /**
155
- * Changes the password of the user
156
- * @category Authentication Port
157
- * @param email User Email Address
158
- * @param password New Password for the User
159
- */
160
- export declare function resetPassword ( email:string, password:string ): Promise<void>;
161
-
162
- /**
163
- * Creates a new Role in the Application in the Authentication Provider
164
- * @category Authentication Port
165
- * @param name The name of the Role To Create
166
- */
167
- export declare function createRole ( name: string ): Promise<void>;
168
-
169
- /**
170
- * Fetches from the Authentication Provider the list of existing Roles for the given tenant or the default one.
171
- * @category Authentication Port
172
- * @param tenant [Optional] The tenant for the role list to be retrieved
173
- */
174
- export declare function getRoles ( tenant?: string ): Promise<void>;
175
-
176
- /**
177
- * Deletes a Role from the Authentication Provider.
178
- * @category Authentication Port
179
- * @param name The name of the Role to Delete
180
- */
181
- export declare function deleteRole ( name: string ): Promise<void>;
182
-
183
- /**
184
- * Creates a new User in the Authentication Provider
185
- * @category Authentication Port
186
- * @param id Application Id of the User to create
187
- * @param email The Email address of the user
188
- * @param roles The roles to create the user with
189
- * @param attributes Additional Attributes to add to the auth token
190
- */
191
- export declare function createUser ( id:string, email:string, password:string, roles: string[], attributes?: Record<string, any> ): Promise<string>;
192
- /**
193
- * Creates a new User in the Authentication Provider
194
- * @category Authentication Port
195
- * @param id Provider Id of the User to create
196
- * @param email The Email address of the user
197
- * @param attributes Additional Attributes to add to the auth token
198
- */
199
- export declare function updateUser ( providerId:string, email?:string, attributes?: Record<string, any> ): Promise<string>;
200
-
201
- /**
202
- * Assigns a list of roles to a given user
203
- * @category Authentication Port
204
- * @param email The User Email Address
205
- * @param roles The Roles to assign to the user
206
- */
207
- export declare function assignUserRoles ( email:string, roles: string[]): Promise<void>;
208
-
209
- /**
210
- * Removes a list of roles from a given user
211
- * @category Authentication Port
212
- * @param email The User Email Address
213
- * @param roles The roles to remove from the user
214
- */
215
- export declare function removeUserRoles ( email:string, roles: string[]): Promise<void>;
216
-
217
- /**
218
- * Performs the Authorization process for a request to a resource given the user Access Token.
219
- * This function is the response of the `authorizeRequest` curried execution.
220
- * @param accessToken JWT Access Token of the request
221
- * @param method The HTTP method accessing the resource
222
- * @param uri The resource uri
223
- * @see {@link authorizeRequest}
224
- */
225
- export declare function authorizeRequestFunction( accessToken: string, method: string, uri: string ): Promise<void>
226
-
227
- /**
228
- * Curried function that will receive the routeManager as parameter and
229
- * return another function with the actual authorization functionality
230
- * @category Authentication Port
231
- * @param routeManager The route manager to use to perform the authorization process of the resource requested.
232
- * @see {@link authorizeRequestFunction}
233
- */
234
- export declare function authorizeRequest ( routeManager: RoutesAuthManagerType ): typeof authorizeRequestFunction
235
-
236
- /**
237
- * @category Main Types
238
- */
239
- export type AuthenticationType = {
240
- name: string,
241
- loginUser: typeof loginUser
242
- recoverPassword: typeof recoverPassword
243
- verifyEmail: typeof verifyEmail
244
- logoutUser: typeof logoutUser
245
- refreshToken: typeof refreshToken
246
- resetPassword: typeof resetPassword
247
- createRole: typeof createRole
248
- getRoles: typeof getRoles
249
- deleteRole: typeof deleteRole
250
- createUser: typeof createUser
251
- updateUser: typeof updateUser
252
- assignUserRoles: typeof assignUserRoles
253
- removeUserRoles: typeof removeUserRoles
254
- authorizeRequest: typeof authorizeRequest
255
- }
256
-
257
- /**
258
- * @category Main Types
259
- */
260
- export type AuthenticationPort = PortEmitter & AuthenticationType & {
261
- RouteManager: ( ports: Pick<Ports, 'database'|'eventstore'>, config: ClusterRoutesConfigType, eventstore?: Ports['eventstore']) => RoutesAuthManagerType
262
- };
263
-
264
- /**
265
- * Defines the concrete implementation for the Authentication Port.
266
- *
267
- * __start__ Stablishes the connection with the Authentication Provider with a Service Account with administrative
268
- * Priviledges that will effect all the operations.
269
- *
270
- * __stop__ Disconnects the Service Account from the Authentication Provider
271
- * @category Main Types
272
- */
273
- export type AuthenticationAdapter = AuthenticationType & AdapterBase
package/src/cache.ts DELETED
@@ -1,109 +0,0 @@
1
- import { AdapterBase, PortEmitter } from './ports';
2
-
3
- /**
4
- * @category Main Types
5
- */
6
- export type CacheAdapter<T = any> = CacheType & AdapterBase<T> & {
7
- flushAll: () => Promise<void>
8
- }
9
-
10
- /**
11
- * @category Main Types
12
- */
13
- export type CachePort = PortEmitter & CacheType;
14
-
15
- /**
16
- * @hidden
17
- */
18
- export declare function set<T extends Record<string, any>>( key: string ) : ( value: T, expirationSeconds?: number | boolean ) => Promise<T>
19
- /**
20
- * Stores a key value pair in cache
21
- * @category Cache Port
22
- * @param key The key to store in cache
23
- * @param value The value to store in the key. Bear in mind that the value will be JSON stringified
24
- * @param expirationSeconds TTL for the cache, in case of `false` passed, the cache would not expire
25
- */
26
- export declare function set<T>( key: string, value: T, expirationSeconds?: number | false ): Promise<T>
27
- /**
28
- * @category Cache Port
29
- * @param key
30
- */
31
- export declare function get<T>( key: string ): Promise<T>
32
- /**
33
- * @category Cache Port
34
- * @param key
35
- */
36
- export declare function remove( key: string ): Promise<void>
37
- /**
38
- * @category Cache Port
39
- * @param key
40
- * @param value
41
- */
42
- export declare function incrementBy( key:string, value: number ): Promise<number>
43
- /**
44
- * @category Cache Port
45
- * @param function
46
- */
47
- export declare function memoize<F extends Function>( func: F, expirationSeconds?: number | false ): F
48
-
49
- /**
50
- * @category Cache Port
51
- * @param pattern
52
- */
53
- export declare function keys( pattern: string ): Promise<string[]>
54
-
55
- //*******************************************
56
- // HASHES
57
- //*******************************************
58
- /**
59
- * HEXISTS
60
- * @category Cache Port
61
- * */
62
- export declare function hashExists( key: string, hash:string ): Promise<boolean>
63
- /** HGET */
64
- export declare function hashGet<T>( key: string, hash:string ): Promise<T>
65
- /**
66
- * HGExTALL
67
- * It will always return a Record<string, string>, further coerce of types must be implemented by client
68
- * @category Cache Port
69
- */
70
- export declare function hashGetAll( key: string ): Promise<Record<string, string>>
71
- /**
72
- * HSET
73
- * @category Cache Port
74
- * */
75
- export declare function hashSet<T>( key: string, hash:string, value: T ): Promise<boolean>
76
- /**
77
- * HSETNX
78
- * @category Cache Port
79
- * */
80
- export declare function hashSetIfNotExists<T>( key: string, hash:string, value: T ): Promise<boolean>
81
- /**
82
- * HINCRBY
83
- * @category Cache Port
84
- * */
85
- export declare function hashIncrementBy( key: string, hash:string, value: number ): Promise<boolean>
86
- /**
87
- * HDEL
88
- * @category Cache Port
89
- * */
90
- export declare function hashDel( key: string, hash:string ): Promise<boolean>
91
-
92
- /**
93
- * @category Main Types
94
- */
95
- export type CacheType = {
96
- set: typeof set
97
- get: typeof get
98
- keys: typeof keys
99
- memoize: typeof memoize
100
- remove: typeof remove
101
- incrementBy: typeof incrementBy
102
- hashExists: typeof hashExists
103
- hashGet: typeof hashGet
104
- hashGetAll: typeof hashGetAll
105
- hashSet: typeof hashSet
106
- hashSetIfNotExists: typeof hashSetIfNotExists
107
- hashIncrementBy: typeof hashIncrementBy
108
- hashDel: typeof hashDel
109
- }