@magek/common 0.0.1

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 (129) hide show
  1. package/dist/app.d.ts +17 -0
  2. package/dist/app.js +2 -0
  3. package/dist/concepts/authorizers.d.ts +7 -0
  4. package/dist/concepts/authorizers.js +2 -0
  5. package/dist/concepts/command.d.ts +14 -0
  6. package/dist/concepts/command.js +2 -0
  7. package/dist/concepts/data-migration.d.ts +19 -0
  8. package/dist/concepts/data-migration.js +8 -0
  9. package/dist/concepts/entity.d.ts +12 -0
  10. package/dist/concepts/entity.js +2 -0
  11. package/dist/concepts/event-handler.d.ts +6 -0
  12. package/dist/concepts/event-handler.js +2 -0
  13. package/dist/concepts/event-stream-configuration.d.ts +14 -0
  14. package/dist/concepts/event-stream-configuration.js +2 -0
  15. package/dist/concepts/event.d.ts +12 -0
  16. package/dist/concepts/event.js +2 -0
  17. package/dist/concepts/filter-hooks.d.ts +15 -0
  18. package/dist/concepts/filter-hooks.js +2 -0
  19. package/dist/concepts/global-error-handler-metadata.d.ts +24 -0
  20. package/dist/concepts/global-error-handler-metadata.js +2 -0
  21. package/dist/concepts/index.d.ts +21 -0
  22. package/dist/concepts/index.js +24 -0
  23. package/dist/concepts/migration.d.ts +8 -0
  24. package/dist/concepts/migration.js +2 -0
  25. package/dist/concepts/notification.d.ts +12 -0
  26. package/dist/concepts/notification.js +2 -0
  27. package/dist/concepts/projection-metadata.d.ts +15 -0
  28. package/dist/concepts/projection-metadata.js +8 -0
  29. package/dist/concepts/query.d.ts +21 -0
  30. package/dist/concepts/query.js +2 -0
  31. package/dist/concepts/read-model.d.ts +33 -0
  32. package/dist/concepts/read-model.js +8 -0
  33. package/dist/concepts/reducer-metadata.d.ts +5 -0
  34. package/dist/concepts/reducer-metadata.js +2 -0
  35. package/dist/concepts/register.d.ts +91 -0
  36. package/dist/concepts/register.js +84 -0
  37. package/dist/concepts/role.d.ts +27 -0
  38. package/dist/concepts/role.js +2 -0
  39. package/dist/concepts/scheduled-command.d.ts +10 -0
  40. package/dist/concepts/scheduled-command.js +2 -0
  41. package/dist/concepts/sequence-metadata.d.ts +5 -0
  42. package/dist/concepts/sequence-metadata.js +2 -0
  43. package/dist/concepts/token-verifier.d.ts +25 -0
  44. package/dist/concepts/token-verifier.js +2 -0
  45. package/dist/concepts/uuid.d.ts +18 -0
  46. package/dist/concepts/uuid.js +28 -0
  47. package/dist/config.d.ts +122 -0
  48. package/dist/config.js +180 -0
  49. package/dist/data-migration-parameters.d.ts +3 -0
  50. package/dist/data-migration-parameters.js +2 -0
  51. package/dist/envelope.d.ts +188 -0
  52. package/dist/envelope.js +2 -0
  53. package/dist/errors/command-handler-global-error.d.ts +8 -0
  54. package/dist/errors/command-handler-global-error.js +12 -0
  55. package/dist/errors/event-global-error.d.ts +6 -0
  56. package/dist/errors/event-global-error.js +11 -0
  57. package/dist/errors/event-handler-global-error.d.ts +9 -0
  58. package/dist/errors/event-handler-global-error.js +13 -0
  59. package/dist/errors/global-error-container.d.ts +4 -0
  60. package/dist/errors/global-error-container.js +9 -0
  61. package/dist/errors/index.d.ts +9 -0
  62. package/dist/errors/index.js +12 -0
  63. package/dist/errors/projection-global-error.d.ts +10 -0
  64. package/dist/errors/projection-global-error.js +14 -0
  65. package/dist/errors/query-handler-global-error.d.ts +6 -0
  66. package/dist/errors/query-handler-global-error.js +11 -0
  67. package/dist/errors/reducer-global-error.d.ts +10 -0
  68. package/dist/errors/reducer-global-error.js +14 -0
  69. package/dist/errors/schedule-command-global-error.d.ts +8 -0
  70. package/dist/errors/schedule-command-global-error.js +12 -0
  71. package/dist/errors/snapshot-persist-handler-global-error.d.ts +16 -0
  72. package/dist/errors/snapshot-persist-handler-global-error.js +21 -0
  73. package/dist/errors.d.ts +30 -0
  74. package/dist/errors.js +60 -0
  75. package/dist/event-store-adapter.d.ts +123 -0
  76. package/dist/event-store-adapter.js +2 -0
  77. package/dist/field-decorator.d.ts +63 -0
  78. package/dist/field-decorator.js +122 -0
  79. package/dist/graphql-websocket-messages.d.ts +65 -0
  80. package/dist/graphql-websocket-messages.js +55 -0
  81. package/dist/groups.d.ts +4 -0
  82. package/dist/groups.js +9 -0
  83. package/dist/http-service.d.ts +10 -0
  84. package/dist/http-service.js +50 -0
  85. package/dist/index.d.ts +30 -0
  86. package/dist/index.js +33 -0
  87. package/dist/instances.d.ts +47 -0
  88. package/dist/instances.js +136 -0
  89. package/dist/instrumentation/trace-types.d.ts +52 -0
  90. package/dist/instrumentation/trace-types.js +34 -0
  91. package/dist/internal-info.d.ts +2 -0
  92. package/dist/internal-info.js +6 -0
  93. package/dist/logger.d.ts +14 -0
  94. package/dist/logger.js +33 -0
  95. package/dist/metadata-types.d.ts +28 -0
  96. package/dist/metadata-types.js +12 -0
  97. package/dist/promises.d.ts +25 -0
  98. package/dist/promises.js +42 -0
  99. package/dist/provider/azure-configuration.d.ts +12 -0
  100. package/dist/provider/azure-configuration.js +4 -0
  101. package/dist/provider.d.ts +83 -0
  102. package/dist/provider.js +2 -0
  103. package/dist/read-model-store-adapter.d.ts +84 -0
  104. package/dist/read-model-store-adapter.js +2 -0
  105. package/dist/retrier.d.ts +12 -0
  106. package/dist/retrier.js +36 -0
  107. package/dist/rocket-loader.d.ts +7 -0
  108. package/dist/rocket-loader.js +21 -0
  109. package/dist/rockets.d.ts +10 -0
  110. package/dist/rockets.js +4 -0
  111. package/dist/run-command.d.ts +5 -0
  112. package/dist/run-command.js +48 -0
  113. package/dist/schedule.d.ts +8 -0
  114. package/dist/schedule.js +2 -0
  115. package/dist/searcher.d.ts +98 -0
  116. package/dist/searcher.js +79 -0
  117. package/dist/sensor/health-indicator-configuration.d.ts +60 -0
  118. package/dist/sensor/health-indicator-configuration.js +31 -0
  119. package/dist/session-store-adapter.d.ts +103 -0
  120. package/dist/session-store-adapter.js +2 -0
  121. package/dist/stream-types.d.ts +1 -0
  122. package/dist/stream-types.js +2 -0
  123. package/dist/super-kind.d.ts +2 -0
  124. package/dist/super-kind.js +5 -0
  125. package/dist/typelevel.d.ts +28 -0
  126. package/dist/typelevel.js +9 -0
  127. package/dist/user-app.d.ts +18 -0
  128. package/dist/user-app.js +2 -0
  129. package/package.json +66 -0
@@ -0,0 +1,103 @@
1
+ import { MagekConfig } from './config';
2
+ import { UUID } from './concepts';
3
+ import { SubscriptionEnvelope } from './envelope';
4
+ /**
5
+ * Interface for session store adapters that handle connection and subscription management
6
+ * for real-time features like GraphQL subscriptions and WebSocket connections.
7
+ */
8
+ export interface SessionStoreAdapter {
9
+ /**
10
+ * Establishes a new connection and stores connection metadata
11
+ *
12
+ * @param config - The Magek configuration object
13
+ * @param connectionId - Unique identifier for the connection
14
+ * @param connectionData - Metadata associated with the connection
15
+ * @returns A promise that resolves when the connection is established
16
+ */
17
+ storeConnection(config: MagekConfig, connectionId: UUID, connectionData: Record<string, any>): Promise<void>;
18
+ /**
19
+ * Retrieves connection data for a specific connection
20
+ *
21
+ * @param config - The Magek configuration object
22
+ * @param connectionId - Unique identifier for the connection
23
+ * @returns A promise that resolves to the connection data, or undefined if not found
24
+ */
25
+ fetchConnection(config: MagekConfig, connectionId: UUID): Promise<Record<string, any> | undefined>;
26
+ /**
27
+ * Removes a connection and all associated data
28
+ *
29
+ * @param config - The Magek configuration object
30
+ * @param connectionId - Unique identifier for the connection
31
+ * @returns A promise that resolves when the connection is removed
32
+ */
33
+ deleteConnection(config: MagekConfig, connectionId: UUID): Promise<void>;
34
+ /**
35
+ * Stores subscription information for a connection
36
+ *
37
+ * @param config - The Magek configuration object
38
+ * @param connectionId - Unique identifier for the connection
39
+ * @param subscriptionId - Unique identifier for the subscription
40
+ * @param subscriptionData - Metadata associated with the subscription
41
+ * @returns A promise that resolves when the subscription is stored
42
+ */
43
+ storeSubscription(config: MagekConfig, connectionId: UUID, subscriptionId: UUID, subscriptionData: Record<string, any>): Promise<void>;
44
+ /**
45
+ * Retrieves subscription data for a specific subscription
46
+ *
47
+ * @param config - The Magek configuration object
48
+ * @param subscriptionId - Unique identifier for the subscription
49
+ * @returns A promise that resolves to the subscription data, or undefined if not found
50
+ */
51
+ fetchSubscription(config: MagekConfig, subscriptionId: UUID): Promise<Record<string, any> | undefined>;
52
+ /**
53
+ * Removes a subscription
54
+ *
55
+ * @param config - The Magek configuration object
56
+ * @param connectionId - Unique identifier for the connection
57
+ * @param subscriptionId - Unique identifier for the subscription
58
+ * @returns A promise that resolves when the subscription is removed
59
+ */
60
+ deleteSubscription(config: MagekConfig, connectionId: UUID, subscriptionId: UUID): Promise<void>;
61
+ /**
62
+ * Retrieves all subscriptions for a specific connection
63
+ *
64
+ * @param config - The Magek configuration object
65
+ * @param connectionId - Unique identifier for the connection
66
+ * @returns A promise that resolves to an array of subscription data
67
+ */
68
+ fetchSubscriptionsForConnection(config: MagekConfig, connectionId: UUID): Promise<Array<Record<string, any>>>;
69
+ /**
70
+ * Removes all subscriptions associated with a connection
71
+ *
72
+ * @param config - The Magek configuration object
73
+ * @param connectionId - Unique identifier for the connection
74
+ * @returns A promise that resolves when all subscriptions are removed
75
+ */
76
+ deleteSubscriptionsForConnection(config: MagekConfig, connectionId: UUID): Promise<void>;
77
+ /**
78
+ * Retrieves subscriptions filtered by read model class name
79
+ * This method supports querying subscriptions by the read model type they are listening to
80
+ *
81
+ * @param config - The Magek configuration object
82
+ * @param className - The name of the read model class to filter subscriptions by
83
+ * @returns A promise that resolves to an array of subscription envelopes matching the class name
84
+ */
85
+ fetchSubscriptionsByClassName(config: MagekConfig, className: string): Promise<Array<SubscriptionEnvelope>>;
86
+ /**
87
+ * Health check methods for the session store
88
+ */
89
+ healthCheck?: {
90
+ /**
91
+ * Check if the session store is up and running
92
+ */
93
+ isUp(config: MagekConfig): Promise<boolean>;
94
+ /**
95
+ * Get detailed health information about the session store
96
+ */
97
+ details(config: MagekConfig): Promise<unknown>;
98
+ /**
99
+ * Get the URLs/endpoints of the session store
100
+ */
101
+ urls(config: MagekConfig): Promise<Array<string>>;
102
+ };
103
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type EventStream = Array<unknown>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export declare const MAGEK_SUPER_KIND = "magek";
2
+ export declare const DOMAIN_SUPER_KIND = "domain";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DOMAIN_SUPER_KIND = exports.MAGEK_SUPER_KIND = void 0;
4
+ exports.MAGEK_SUPER_KIND = 'magek';
5
+ exports.DOMAIN_SUPER_KIND = 'domain';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Interface to get information from a `TReflected`
3
+ * class.
4
+ *
5
+ * Usage:
6
+ *
7
+ * ```typescript
8
+ * function printName<T>(cls : Class<T>){
9
+ * console.log(cls.name)
10
+ * }
11
+ *
12
+ * printName(Person) // Prints "Person"
13
+ * ```
14
+ */
15
+ export interface Class<TReflected> {
16
+ new (...args: any[]): TReflected;
17
+ }
18
+ export interface AnyClass extends Class<any> {
19
+ }
20
+ export interface Instance {
21
+ constructor: {
22
+ name: string;
23
+ };
24
+ }
25
+ export declare function toClassTitle(instance: Instance): string;
26
+ export type ReadOnlyNonEmptyArray<TElement> = {
27
+ readonly 0: TElement;
28
+ } & ReadonlyArray<TElement>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toClassTitle = toClassTitle;
4
+ function toClassTitle(instance) {
5
+ return instance.constructor.name
6
+ .replace(/([A-Z])([a-z])/g, ' $1$2')
7
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
8
+ .trim();
9
+ }
@@ -0,0 +1,18 @@
1
+ import { MagekConfig } from './config';
2
+ /**
3
+ * `UserApp` represents the expected interface when we `require` the `dist/index.js` file of a Magek app
4
+ */
5
+ export interface UserApp {
6
+ Magek: {
7
+ config: MagekConfig;
8
+ configureCurrentEnv(configurator: (config: MagekConfig) => void): void;
9
+ configuredEnvironments: Set<string>;
10
+ };
11
+ eventDispatcher(_: unknown): Promise<void>;
12
+ graphQLDispatcher(_: unknown): Promise<unknown>;
13
+ triggerScheduledCommands(_: unknown): Promise<void>;
14
+ notifySubscribers(_: unknown): Promise<void>;
15
+ consumeEventStream(_: unknown): Promise<unknown>;
16
+ produceEventStream(_: unknown): Promise<unknown>;
17
+ health(_: unknown): Promise<any>;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@magek/common",
3
+ "version": "0.0.1",
4
+ "description": "Contains Magek common helpers used by the core and provider packages",
5
+ "keywords": [
6
+ "framework-common-helpers"
7
+ ],
8
+ "author": "Boosterin Labs SLU",
9
+ "homepage": "https://magek.ai",
10
+ "license": "Apache-2.0",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "main": "dist/index.js",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/theam/magek.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/theam/magek/issues"
24
+ },
25
+ "engines": {
26
+ "node": ">=22.0.0 <23.0.0"
27
+ },
28
+ "dependencies": {
29
+ "tslib": "2.8.1",
30
+ "class-transformer": "~0.5.1",
31
+ "execa": "9.6.1",
32
+ "reflect-metadata": "0.2.2",
33
+ "uuid": "^13.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@magek/eslint-config": "^0.0.1",
37
+ "@types/chai": "5.2.3",
38
+ "@types/chai-as-promised": "8.0.2",
39
+ "@types/mocha": "10.0.10",
40
+ "@types/node": "22.19.3",
41
+ "@types/sinon": "21.0.0",
42
+ "@types/sinon-chai": "4.0.0",
43
+ "@types/uuid": "11.0.0",
44
+ "chai": "6.2.2",
45
+ "chai-as-promised": "8.0.2",
46
+ "mocha": "11.7.5",
47
+ "c8": "^10.1.3",
48
+ "rimraf": "6.1.2",
49
+ "sinon": "21.0.1",
50
+ "sinon-chai": "4.0.1",
51
+ "tsx": "^4.19.2",
52
+ "typescript": "5.9.3",
53
+ "@faker-js/faker": "10.2.0",
54
+ "fast-check": "4.5.3",
55
+ "graphql": "16.12.0"
56
+ },
57
+ "scripts": {
58
+ "format": "prettier --write --ext '.js,.ts' **/*.ts **/*/*.ts",
59
+ "lint:check": "eslint \"**/*.ts\"",
60
+ "lint:fix": "eslint --quiet --fix \"**/*.ts\"",
61
+ "build": "tsc -b tsconfig.json",
62
+ "clean": "rimraf ./dist tsconfig.tsbuildinfo",
63
+ "test:helpers": "npm run test",
64
+ "test": "tsc --noEmit -p tsconfig.test.json && c8 mocha --forbid-only \"test/**/*.test.ts\""
65
+ }
66
+ }