@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.
- package/dist/app.d.ts +17 -0
- package/dist/app.js +2 -0
- package/dist/concepts/authorizers.d.ts +7 -0
- package/dist/concepts/authorizers.js +2 -0
- package/dist/concepts/command.d.ts +14 -0
- package/dist/concepts/command.js +2 -0
- package/dist/concepts/data-migration.d.ts +19 -0
- package/dist/concepts/data-migration.js +8 -0
- package/dist/concepts/entity.d.ts +12 -0
- package/dist/concepts/entity.js +2 -0
- package/dist/concepts/event-handler.d.ts +6 -0
- package/dist/concepts/event-handler.js +2 -0
- package/dist/concepts/event-stream-configuration.d.ts +14 -0
- package/dist/concepts/event-stream-configuration.js +2 -0
- package/dist/concepts/event.d.ts +12 -0
- package/dist/concepts/event.js +2 -0
- package/dist/concepts/filter-hooks.d.ts +15 -0
- package/dist/concepts/filter-hooks.js +2 -0
- package/dist/concepts/global-error-handler-metadata.d.ts +24 -0
- package/dist/concepts/global-error-handler-metadata.js +2 -0
- package/dist/concepts/index.d.ts +21 -0
- package/dist/concepts/index.js +24 -0
- package/dist/concepts/migration.d.ts +8 -0
- package/dist/concepts/migration.js +2 -0
- package/dist/concepts/notification.d.ts +12 -0
- package/dist/concepts/notification.js +2 -0
- package/dist/concepts/projection-metadata.d.ts +15 -0
- package/dist/concepts/projection-metadata.js +8 -0
- package/dist/concepts/query.d.ts +21 -0
- package/dist/concepts/query.js +2 -0
- package/dist/concepts/read-model.d.ts +33 -0
- package/dist/concepts/read-model.js +8 -0
- package/dist/concepts/reducer-metadata.d.ts +5 -0
- package/dist/concepts/reducer-metadata.js +2 -0
- package/dist/concepts/register.d.ts +91 -0
- package/dist/concepts/register.js +84 -0
- package/dist/concepts/role.d.ts +27 -0
- package/dist/concepts/role.js +2 -0
- package/dist/concepts/scheduled-command.d.ts +10 -0
- package/dist/concepts/scheduled-command.js +2 -0
- package/dist/concepts/sequence-metadata.d.ts +5 -0
- package/dist/concepts/sequence-metadata.js +2 -0
- package/dist/concepts/token-verifier.d.ts +25 -0
- package/dist/concepts/token-verifier.js +2 -0
- package/dist/concepts/uuid.d.ts +18 -0
- package/dist/concepts/uuid.js +28 -0
- package/dist/config.d.ts +122 -0
- package/dist/config.js +180 -0
- package/dist/data-migration-parameters.d.ts +3 -0
- package/dist/data-migration-parameters.js +2 -0
- package/dist/envelope.d.ts +188 -0
- package/dist/envelope.js +2 -0
- package/dist/errors/command-handler-global-error.d.ts +8 -0
- package/dist/errors/command-handler-global-error.js +12 -0
- package/dist/errors/event-global-error.d.ts +6 -0
- package/dist/errors/event-global-error.js +11 -0
- package/dist/errors/event-handler-global-error.d.ts +9 -0
- package/dist/errors/event-handler-global-error.js +13 -0
- package/dist/errors/global-error-container.d.ts +4 -0
- package/dist/errors/global-error-container.js +9 -0
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.js +12 -0
- package/dist/errors/projection-global-error.d.ts +10 -0
- package/dist/errors/projection-global-error.js +14 -0
- package/dist/errors/query-handler-global-error.d.ts +6 -0
- package/dist/errors/query-handler-global-error.js +11 -0
- package/dist/errors/reducer-global-error.d.ts +10 -0
- package/dist/errors/reducer-global-error.js +14 -0
- package/dist/errors/schedule-command-global-error.d.ts +8 -0
- package/dist/errors/schedule-command-global-error.js +12 -0
- package/dist/errors/snapshot-persist-handler-global-error.d.ts +16 -0
- package/dist/errors/snapshot-persist-handler-global-error.js +21 -0
- package/dist/errors.d.ts +30 -0
- package/dist/errors.js +60 -0
- package/dist/event-store-adapter.d.ts +123 -0
- package/dist/event-store-adapter.js +2 -0
- package/dist/field-decorator.d.ts +63 -0
- package/dist/field-decorator.js +122 -0
- package/dist/graphql-websocket-messages.d.ts +65 -0
- package/dist/graphql-websocket-messages.js +55 -0
- package/dist/groups.d.ts +4 -0
- package/dist/groups.js +9 -0
- package/dist/http-service.d.ts +10 -0
- package/dist/http-service.js +50 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +33 -0
- package/dist/instances.d.ts +47 -0
- package/dist/instances.js +136 -0
- package/dist/instrumentation/trace-types.d.ts +52 -0
- package/dist/instrumentation/trace-types.js +34 -0
- package/dist/internal-info.d.ts +2 -0
- package/dist/internal-info.js +6 -0
- package/dist/logger.d.ts +14 -0
- package/dist/logger.js +33 -0
- package/dist/metadata-types.d.ts +28 -0
- package/dist/metadata-types.js +12 -0
- package/dist/promises.d.ts +25 -0
- package/dist/promises.js +42 -0
- package/dist/provider/azure-configuration.d.ts +12 -0
- package/dist/provider/azure-configuration.js +4 -0
- package/dist/provider.d.ts +83 -0
- package/dist/provider.js +2 -0
- package/dist/read-model-store-adapter.d.ts +84 -0
- package/dist/read-model-store-adapter.js +2 -0
- package/dist/retrier.d.ts +12 -0
- package/dist/retrier.js +36 -0
- package/dist/rocket-loader.d.ts +7 -0
- package/dist/rocket-loader.js +21 -0
- package/dist/rockets.d.ts +10 -0
- package/dist/rockets.js +4 -0
- package/dist/run-command.d.ts +5 -0
- package/dist/run-command.js +48 -0
- package/dist/schedule.d.ts +8 -0
- package/dist/schedule.js +2 -0
- package/dist/searcher.d.ts +98 -0
- package/dist/searcher.js +79 -0
- package/dist/sensor/health-indicator-configuration.d.ts +60 -0
- package/dist/sensor/health-indicator-configuration.js +31 -0
- package/dist/session-store-adapter.d.ts +103 -0
- package/dist/session-store-adapter.js +2 -0
- package/dist/stream-types.d.ts +1 -0
- package/dist/stream-types.js +2 -0
- package/dist/super-kind.d.ts +2 -0
- package/dist/super-kind.js +5 -0
- package/dist/typelevel.d.ts +28 -0
- package/dist/typelevel.js +9 -0
- package/dist/user-app.d.ts +18 -0
- package/dist/user-app.js +2 -0
- 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 @@
|
|
|
1
|
+
export type EventStream = Array<unknown>;
|
|
@@ -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
|
+
}
|
package/dist/user-app.js
ADDED
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
|
+
}
|