@magek/core 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/authorizer.d.ts +7 -0
- package/dist/authorizer.js +35 -0
- package/dist/command-dispatcher.d.ts +8 -0
- package/dist/command-dispatcher.js +55 -0
- package/dist/core-concepts/data-migration/entities/data-migration-entity.d.ts +12 -0
- package/dist/core-concepts/data-migration/entities/data-migration-entity.js +37 -0
- package/dist/core-concepts/data-migration/events/data-migration-finished.d.ts +7 -0
- package/dist/core-concepts/data-migration/events/data-migration-finished.js +13 -0
- package/dist/core-concepts/data-migration/events/data-migration-started.d.ts +7 -0
- package/dist/core-concepts/data-migration/events/data-migration-started.js +13 -0
- package/dist/core-concepts/data-migration/events/entity-migrated.d.ts +9 -0
- package/dist/core-concepts/data-migration/events/entity-migrated.js +15 -0
- package/dist/core-concepts/touch-entity/events/entity-touched.d.ts +7 -0
- package/dist/core-concepts/touch-entity/events/entity-touched.js +13 -0
- package/dist/data-migrations.d.ts +8 -0
- package/dist/data-migrations.js +73 -0
- package/dist/decorators/command.d.ts +19 -0
- package/dist/decorators/command.js +47 -0
- package/dist/decorators/data-migration.d.ts +9 -0
- package/dist/decorators/data-migration.js +25 -0
- package/dist/decorators/entity.d.ts +32 -0
- package/dist/decorators/entity.js +100 -0
- package/dist/decorators/event-handler.d.ts +3 -0
- package/dist/decorators/event-handler.js +18 -0
- package/dist/decorators/event.d.ts +8 -0
- package/dist/decorators/event.js +22 -0
- package/dist/decorators/field-metadata-reader.d.ts +6 -0
- package/dist/decorators/field-metadata-reader.js +221 -0
- package/dist/decorators/global-error-handler.d.ts +2 -0
- package/dist/decorators/global-error-handler.js +15 -0
- package/dist/decorators/global-event-handler.d.ts +3 -0
- package/dist/decorators/global-event-handler.js +9 -0
- package/dist/decorators/health-sensor.d.ts +14 -0
- package/dist/decorators/health-sensor.js +38 -0
- package/dist/decorators/index.d.ts +16 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/metadata.d.ts +13 -0
- package/dist/decorators/metadata.js +55 -0
- package/dist/decorators/non-exposed.d.ts +2 -0
- package/dist/decorators/non-exposed.js +24 -0
- package/dist/decorators/notification.d.ts +35 -0
- package/dist/decorators/notification.js +94 -0
- package/dist/decorators/projects.d.ts +32 -0
- package/dist/decorators/projects.js +87 -0
- package/dist/decorators/query.d.ts +2 -0
- package/dist/decorators/query.js +25 -0
- package/dist/decorators/read-model.d.ts +39 -0
- package/dist/decorators/read-model.js +129 -0
- package/dist/decorators/role.d.ts +6 -0
- package/dist/decorators/role.js +15 -0
- package/dist/decorators/scheduled-command.d.ts +9 -0
- package/dist/decorators/scheduled-command.js +25 -0
- package/dist/decorators/schema-migration.d.ts +36 -0
- package/dist/decorators/schema-migration.js +146 -0
- package/dist/decorators/sequenced-by.d.ts +28 -0
- package/dist/decorators/sequenced-by.js +79 -0
- package/dist/decorators/stage3-utils.d.ts +6 -0
- package/dist/decorators/stage3-utils.js +25 -0
- package/dist/delete-event-dispatcher.d.ts +4 -0
- package/dist/delete-event-dispatcher.js +23 -0
- package/dist/event-dispatcher.d.ts +9 -0
- package/dist/event-dispatcher.js +37 -0
- package/dist/event-processor.d.ts +15 -0
- package/dist/event-processor.js +125 -0
- package/dist/event-search.d.ts +2 -0
- package/dist/event-search.js +26 -0
- package/dist/event-stream-consumer.d.ts +7 -0
- package/dist/event-stream-consumer.js +36 -0
- package/dist/event-stream-producer.d.ts +7 -0
- package/dist/event-stream-producer.js +30 -0
- package/dist/events-reader.d.ts +11 -0
- package/dist/events-reader.js +63 -0
- package/dist/global-error-dispatcher.d.ts +16 -0
- package/dist/global-error-dispatcher.js +109 -0
- package/dist/graphql-dispatcher.d.ts +16 -0
- package/dist/graphql-dispatcher.js +195 -0
- package/dist/importer.d.ts +14 -0
- package/dist/importer.js +49 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +100 -0
- package/dist/injectable/index.d.ts +21 -0
- package/dist/injectable/index.js +2 -0
- package/dist/instrumentation/decorator/trace.d.ts +13 -0
- package/dist/instrumentation/decorator/trace.js +116 -0
- package/dist/instrumentation/index.d.ts +2 -0
- package/dist/instrumentation/index.js +5 -0
- package/dist/instrumentation/trace-notifier.d.ts +3 -0
- package/dist/instrumentation/trace-notifier.js +26 -0
- package/dist/magek.d.ts +42 -0
- package/dist/magek.js +158 -0
- package/dist/query-dispatcher.d.ts +8 -0
- package/dist/query-dispatcher.js +47 -0
- package/dist/read-model-schema-migrator.d.ts +14 -0
- package/dist/read-model-schema-migrator.js +80 -0
- package/dist/read-models-reader.d.ts +31 -0
- package/dist/read-models-reader.js +196 -0
- package/dist/register-handler.d.ts +11 -0
- package/dist/register-handler.js +95 -0
- package/dist/rocket-dispatcher.d.ts +6 -0
- package/dist/rocket-dispatcher.js +21 -0
- package/dist/scheduled-command-dispatcher.d.ts +12 -0
- package/dist/scheduled-command-dispatcher.js +54 -0
- package/dist/schema-migrator.d.ts +12 -0
- package/dist/schema-migrator.js +71 -0
- package/dist/sensor/health/health-indicators/database-events-health-indicator.d.ts +5 -0
- package/dist/sensor/health/health-indicators/database-events-health-indicator.js +26 -0
- package/dist/sensor/health/health-indicators/database-health-indicator.d.ts +5 -0
- package/dist/sensor/health/health-indicators/database-health-indicator.js +29 -0
- package/dist/sensor/health/health-indicators/database-read-models-health-indicator.d.ts +5 -0
- package/dist/sensor/health/health-indicators/database-read-models-health-indicator.js +26 -0
- package/dist/sensor/health/health-indicators/default-health-indicators.d.ts +5 -0
- package/dist/sensor/health/health-indicators/default-health-indicators.js +39 -0
- package/dist/sensor/health/health-indicators/function-health-indicator.d.ts +5 -0
- package/dist/sensor/health/health-indicators/function-health-indicator.js +30 -0
- package/dist/sensor/health/health-indicators/health-indicator.d.ts +5 -0
- package/dist/sensor/health/health-indicators/health-indicator.js +30 -0
- package/dist/sensor/health/health-indicators/index.d.ts +3 -0
- package/dist/sensor/health/health-indicators/index.js +6 -0
- package/dist/sensor/health/health-indicators/os-info.d.ts +14 -0
- package/dist/sensor/health/health-indicators/os-info.js +38 -0
- package/dist/sensor/health/health-indicators/rockets-health-indicator.d.ts +5 -0
- package/dist/sensor/health/health-indicators/rockets-health-indicator.js +57 -0
- package/dist/sensor/health/health-indicators/version.d.ts +2 -0
- package/dist/sensor/health/health-indicators/version.js +24 -0
- package/dist/sensor/health/health-service.d.ts +22 -0
- package/dist/sensor/health/health-service.js +117 -0
- package/dist/sensor/health/health-utils.d.ts +7 -0
- package/dist/sensor/health/health-utils.js +53 -0
- package/dist/sensor/health/index.d.ts +3 -0
- package/dist/sensor/health/index.js +6 -0
- package/dist/sensor/index.d.ts +1 -0
- package/dist/sensor/index.js +4 -0
- package/dist/services/event-store.d.ts +27 -0
- package/dist/services/event-store.js +260 -0
- package/dist/services/filter-helpers.d.ts +3 -0
- package/dist/services/filter-helpers.js +19 -0
- package/dist/services/graphql/common.d.ts +26 -0
- package/dist/services/graphql/common.js +53 -0
- package/dist/services/graphql/graphql-generator.d.ts +46 -0
- package/dist/services/graphql/graphql-generator.js +269 -0
- package/dist/services/graphql/graphql-mutation-generator.d.ts +12 -0
- package/dist/services/graphql/graphql-mutation-generator.js +25 -0
- package/dist/services/graphql/graphql-query-generator.d.ts +22 -0
- package/dist/services/graphql/graphql-query-generator.js +39 -0
- package/dist/services/graphql/graphql-subcriptions-generator.d.ts +17 -0
- package/dist/services/graphql/graphql-subcriptions-generator.js +60 -0
- package/dist/services/graphql/graphql-type-informer.d.ts +23 -0
- package/dist/services/graphql/graphql-type-informer.js +160 -0
- package/dist/services/graphql/query-generators/graphql-query-by-keys-generator.d.ts +14 -0
- package/dist/services/graphql/query-generators/graphql-query-by-keys-generator.js +48 -0
- package/dist/services/graphql/query-generators/graphql-query-events-generator.d.ts +11 -0
- package/dist/services/graphql/query-generators/graphql-query-events-generator.js +68 -0
- package/dist/services/graphql/query-generators/graphql-query-filters-generator.d.ts +14 -0
- package/dist/services/graphql/query-generators/graphql-query-filters-generator.js +31 -0
- package/dist/services/graphql/query-generators/graphql-query-generator.d.ts +12 -0
- package/dist/services/graphql/query-generators/graphql-query-generator.js +17 -0
- package/dist/services/graphql/query-generators/graphql-query-listed-generator.d.ts +16 -0
- package/dist/services/graphql/query-generators/graphql-query-listed-generator.js +65 -0
- package/dist/services/graphql/query-helpers/graphql-handled-fields-generator.d.ts +15 -0
- package/dist/services/graphql/query-helpers/graphql-handled-fields-generator.js +65 -0
- package/dist/services/graphql/query-helpers/graphql-query-filter-arguments-builder.d.ts +13 -0
- package/dist/services/graphql/query-helpers/graphql-query-filter-arguments-builder.js +169 -0
- package/dist/services/graphql/query-helpers/graphql-query-filter-fields-builder.d.ts +11 -0
- package/dist/services/graphql/query-helpers/graphql-query-filter-fields-builder.js +28 -0
- package/dist/services/graphql/query-helpers/graphql-query-sort-builder.d.ts +12 -0
- package/dist/services/graphql/query-helpers/graphql-query-sort-builder.js +61 -0
- package/dist/services/graphql/websocket-protocol/graphql-websocket-protocol.d.ts +20 -0
- package/dist/services/graphql/websocket-protocol/graphql-websocket-protocol.js +127 -0
- package/dist/services/pub-sub/noop-read-model-pub-sub.d.ts +5 -0
- package/dist/services/pub-sub/noop-read-model-pub-sub.js +10 -0
- package/dist/services/pub-sub/read-model-pub-sub.d.ts +9 -0
- package/dist/services/pub-sub/read-model-pub-sub.js +112 -0
- package/dist/services/raw-events-parser.d.ts +5 -0
- package/dist/services/raw-events-parser.js +44 -0
- package/dist/services/read-model-searcher.d.ts +2 -0
- package/dist/services/read-model-searcher.js +11 -0
- package/dist/services/read-model-store.d.ts +41 -0
- package/dist/services/read-model-store.js +295 -0
- package/dist/services/token-verifiers/index.d.ts +4 -0
- package/dist/services/token-verifiers/index.js +7 -0
- package/dist/services/token-verifiers/jwks-uri-token-verifier.d.ts +21 -0
- package/dist/services/token-verifiers/jwks-uri-token-verifier.js +23 -0
- package/dist/services/token-verifiers/public-key-token-verifier.d.ts +13 -0
- package/dist/services/token-verifiers/public-key-token-verifier.js +19 -0
- package/dist/services/token-verifiers/role-based-token-verifier.d.ts +8 -0
- package/dist/services/token-verifiers/role-based-token-verifier.js +35 -0
- package/dist/services/token-verifiers/utilities.d.ts +31 -0
- package/dist/services/token-verifiers/utilities.js +70 -0
- package/dist/subscribers-notifier.d.ts +14 -0
- package/dist/subscribers-notifier.js +109 -0
- package/dist/token-verifier.d.ts +11 -0
- package/dist/token-verifier.js +46 -0
- package/dist/touch-entity-handler.d.ts +4 -0
- package/dist/touch-entity-handler.js +16 -0
- package/package.json +71 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MagekSubscribersNotifier = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@magek/common");
|
|
6
|
+
const graphql = require("graphql");
|
|
7
|
+
const graphql_generator_1 = require("./services/graphql/graphql-generator");
|
|
8
|
+
const read_model_pub_sub_1 = require("./services/pub-sub/read-model-pub-sub");
|
|
9
|
+
const instrumentation_1 = require("./instrumentation");
|
|
10
|
+
class MagekSubscribersNotifier {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.graphQLSchema = graphql_generator_1.GraphQLGenerator.generateSchema(config);
|
|
14
|
+
}
|
|
15
|
+
async dispatch(request) {
|
|
16
|
+
const logger = (0, common_1.getLogger)(this.config, 'MagekSubscribersNotifier#dispatch');
|
|
17
|
+
try {
|
|
18
|
+
logger.debug('Received the following event for subscription dispatching: ', request);
|
|
19
|
+
const readModelEnvelopes = await this.config.readModelStore.rawToEnvelopes(this.config, request);
|
|
20
|
+
logger.debug('[SubsciptionDispatcher] The following ReadModels were updated: ', readModelEnvelopes);
|
|
21
|
+
const subscriptions = await this.getSubscriptions(readModelEnvelopes);
|
|
22
|
+
logger.debug('Found the following subscriptions for those read models: ', subscriptions);
|
|
23
|
+
const pubSub = this.getPubSub(readModelEnvelopes);
|
|
24
|
+
await common_1.Promises.allSettledAndFulfilled(subscriptions.map(this.runSubscriptionAndNotify.bind(this, pubSub)));
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
logger.error(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getReadModelInstance(envelope) {
|
|
31
|
+
const readModelMetadata = this.config.readModels[envelope.typeName];
|
|
32
|
+
if (!readModelMetadata) {
|
|
33
|
+
throw new Error('Could not get information about read model with name: ' + envelope.typeName);
|
|
34
|
+
}
|
|
35
|
+
const readModelInstance = new readModelMetadata.class();
|
|
36
|
+
Object.assign(readModelInstance, envelope.value);
|
|
37
|
+
return readModelInstance;
|
|
38
|
+
}
|
|
39
|
+
async getSubscriptions(readModelEnvelopes) {
|
|
40
|
+
const readModelNames = readModelEnvelopes.map((readModelEnvelope) => readModelEnvelope.typeName);
|
|
41
|
+
const readModelUniqueNames = [...new Set(readModelNames)];
|
|
42
|
+
const subscriptionSets = await Promise.all(readModelUniqueNames.map((name) => this.config.sessionStore.fetchSubscriptionsByClassName(this.config, name)));
|
|
43
|
+
return subscriptionSets.flat();
|
|
44
|
+
}
|
|
45
|
+
getPubSub(readModelEnvelopes) {
|
|
46
|
+
const readModelInstances = readModelEnvelopes.map(this.getReadModelInstance, this);
|
|
47
|
+
return new read_model_pub_sub_1.FilteredReadModelPubSub(readModelInstances);
|
|
48
|
+
}
|
|
49
|
+
async runSubscriptionAndNotify(pubSub, subscription) {
|
|
50
|
+
const logger = (0, common_1.getLogger)(this.config, 'MagekSubscribersNotifier#runSubscriptionAndNotify');
|
|
51
|
+
const context = {
|
|
52
|
+
connectionID: subscription.connectionID,
|
|
53
|
+
responseHeaders: {},
|
|
54
|
+
requestID: subscription.requestID,
|
|
55
|
+
user: subscription.currentUser,
|
|
56
|
+
operation: subscription.operation,
|
|
57
|
+
pubSub,
|
|
58
|
+
storeSubscriptions: false, // We don't store the subscription again, just get the result now
|
|
59
|
+
};
|
|
60
|
+
const document = this.parseSubscriptionQuery(subscription.operation.query);
|
|
61
|
+
logger.debug('Running subscription with context: ', context);
|
|
62
|
+
const iterator = await graphql.subscribe({
|
|
63
|
+
contextValue: context,
|
|
64
|
+
document: document,
|
|
65
|
+
schema: this.graphQLSchema,
|
|
66
|
+
variableValues: subscription.operation.variables,
|
|
67
|
+
});
|
|
68
|
+
if ('next' in iterator) {
|
|
69
|
+
// It is an AsyncIterator
|
|
70
|
+
return this.processSubscriptionsIterator(iterator, subscription);
|
|
71
|
+
}
|
|
72
|
+
// If "subscribe" returns an ExecutionResult (instead of an async iterator) the subscription failed.
|
|
73
|
+
throw iterator.errors;
|
|
74
|
+
}
|
|
75
|
+
parseSubscriptionQuery(query) {
|
|
76
|
+
const document = graphql.parse(query);
|
|
77
|
+
// We probably don't need to validate this again, as it was validated before storing it. BUT! It's always better to fail early
|
|
78
|
+
const errors = graphql.validate(this.graphQLSchema, document);
|
|
79
|
+
if (errors.length > 0) {
|
|
80
|
+
throw errors;
|
|
81
|
+
}
|
|
82
|
+
return document;
|
|
83
|
+
}
|
|
84
|
+
async processSubscriptionsIterator(iterator, subscription) {
|
|
85
|
+
const notificationPromises = [];
|
|
86
|
+
for await (const result of iterator) {
|
|
87
|
+
notificationPromises.push(this.notifyWithGraphQLResult(subscription, result));
|
|
88
|
+
}
|
|
89
|
+
return Promise.all(notificationPromises);
|
|
90
|
+
}
|
|
91
|
+
async notifyWithGraphQLResult(subscription, result) {
|
|
92
|
+
const logger = (0, common_1.getLogger)(this.config, 'MagekSubscribersNotifier#notifyWithGraphQLResult');
|
|
93
|
+
if (result.errors) {
|
|
94
|
+
throw result.errors;
|
|
95
|
+
}
|
|
96
|
+
const readModel = result.data;
|
|
97
|
+
const message = new common_1.GraphQLData(subscription.operation.id, { data: readModel });
|
|
98
|
+
logger.debug(`Notifying connectionID '${subscription.connectionID}' with the following wrappeed read model: `, readModel);
|
|
99
|
+
await this.config.provider.messaging.sendMessage(this.config, subscription.connectionID, message);
|
|
100
|
+
logger.debug('Notifications sent');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.MagekSubscribersNotifier = MagekSubscribersNotifier;
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, instrumentation_1.Trace)(common_1.TraceActionTypes.DISPATCH_SUBSCRIBER_NOTIFIER),
|
|
106
|
+
tslib_1.__metadata("design:type", Function),
|
|
107
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
108
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
109
|
+
], MagekSubscribersNotifier.prototype, "dispatch", null);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UserEnvelope, MagekConfig } from '@magek/common';
|
|
2
|
+
export declare class MagekTokenVerifier {
|
|
3
|
+
private config;
|
|
4
|
+
constructor(config: MagekConfig);
|
|
5
|
+
verify(token: string): Promise<UserEnvelope>;
|
|
6
|
+
private rejectVerification;
|
|
7
|
+
private getTokenNotBeforeErrors;
|
|
8
|
+
private getTokenExpiredErrors;
|
|
9
|
+
private getErrors;
|
|
10
|
+
private static joinReasons;
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MagekTokenVerifier = void 0;
|
|
4
|
+
const common_1 = require("@magek/common");
|
|
5
|
+
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
6
|
+
class MagekTokenVerifier {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
async verify(token) {
|
|
11
|
+
const userEnvelopes = await Promise.allSettled(this.config.tokenVerifiers.map((tokenVerifier) => tokenVerifier.verify(token).then((decodedToken) => Promise.resolve(tokenVerifier.toUserEnvelope(decodedToken)))));
|
|
12
|
+
const winner = userEnvelopes.find((result) => result.status === 'fulfilled');
|
|
13
|
+
if (!winner)
|
|
14
|
+
return this.rejectVerification(userEnvelopes);
|
|
15
|
+
return Promise.resolve(winner.value);
|
|
16
|
+
}
|
|
17
|
+
rejectVerification(results) {
|
|
18
|
+
const tokenExpiredErrors = this.getTokenExpiredErrors(results);
|
|
19
|
+
if (tokenExpiredErrors && tokenExpiredErrors.length > 0) {
|
|
20
|
+
const reasons = MagekTokenVerifier.joinReasons(tokenExpiredErrors);
|
|
21
|
+
return Promise.reject(new common_1.MagekTokenExpiredError(reasons));
|
|
22
|
+
}
|
|
23
|
+
const tokenNotBeforeErrors = this.getTokenNotBeforeErrors(results);
|
|
24
|
+
if (tokenNotBeforeErrors && tokenNotBeforeErrors.length > 0) {
|
|
25
|
+
const reasons = MagekTokenVerifier.joinReasons(tokenNotBeforeErrors);
|
|
26
|
+
return Promise.reject(new common_1.MagekTokenNotBeforeError(reasons));
|
|
27
|
+
}
|
|
28
|
+
const reasons = MagekTokenVerifier.joinReasons(results);
|
|
29
|
+
return Promise.reject(new common_1.NotAuthorizedError(reasons));
|
|
30
|
+
}
|
|
31
|
+
getTokenNotBeforeErrors(results) {
|
|
32
|
+
return this.getErrors(results).filter((result) => result.reason instanceof jsonwebtoken_1.NotBeforeError);
|
|
33
|
+
}
|
|
34
|
+
getTokenExpiredErrors(results) {
|
|
35
|
+
return this.getErrors(results).filter((result) => result.reason instanceof jsonwebtoken_1.TokenExpiredError);
|
|
36
|
+
}
|
|
37
|
+
getErrors(results) {
|
|
38
|
+
return results
|
|
39
|
+
.filter((result) => (result === null || result === void 0 ? void 0 : result.status) && (result === null || result === void 0 ? void 0 : result.status) !== 'fulfilled')
|
|
40
|
+
.map((result) => result);
|
|
41
|
+
}
|
|
42
|
+
static joinReasons(errors) {
|
|
43
|
+
return errors.map((error) => error.reason).join('\n');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MagekTokenVerifier = MagekTokenVerifier;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MagekTouchEntityHandler = void 0;
|
|
4
|
+
const common_1 = require("@magek/common");
|
|
5
|
+
const register_handler_1 = require("./register-handler");
|
|
6
|
+
const index_1 = require("./index");
|
|
7
|
+
const entity_touched_1 = require("./core-concepts/touch-entity/events/entity-touched");
|
|
8
|
+
class MagekTouchEntityHandler {
|
|
9
|
+
static async touchEntity(entityName, entityId) {
|
|
10
|
+
const requestID = common_1.UUID.generate();
|
|
11
|
+
const register = new common_1.Register(requestID, {}, register_handler_1.RegisterHandler.flush);
|
|
12
|
+
register.events(new entity_touched_1.MagekEntityTouched(entityName, entityId));
|
|
13
|
+
return register_handler_1.RegisterHandler.handle(index_1.Magek.config, register);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.MagekTouchEntityHandler = MagekTouchEntityHandler;
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magek/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Library for your Magek apps",
|
|
5
|
+
"author": "Boosterin Labs SLU",
|
|
6
|
+
"homepage": "https://magek.ai",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/theam/magek.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/theam/magek/issues"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.0.0 <23.0.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@magek/common": "^0.0.1",
|
|
27
|
+
"fp-ts": "2.16.11",
|
|
28
|
+
"graphql-scalars": "1.25.0",
|
|
29
|
+
"inflected": "2.1.0",
|
|
30
|
+
"iterall": "1.3.0",
|
|
31
|
+
"jsonwebtoken": "9.0.3",
|
|
32
|
+
"jwks-rsa": "3.2.0",
|
|
33
|
+
"tslib": "2.8.1",
|
|
34
|
+
"validator": "13.15.26",
|
|
35
|
+
"@oclif/core": "4.8.0",
|
|
36
|
+
"fast-check": "4.5.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@magek/eslint-config": "^0.0.1",
|
|
40
|
+
"@types/chai": "5.2.3",
|
|
41
|
+
"@types/chai-as-promised": "8.0.2",
|
|
42
|
+
"@types/inflected": "2.1.3",
|
|
43
|
+
"@types/jsonwebtoken": "9.0.10",
|
|
44
|
+
"@types/mocha": "10.0.10",
|
|
45
|
+
"@types/node": "22.19.3",
|
|
46
|
+
"@types/sinon": "21.0.0",
|
|
47
|
+
"@types/sinon-chai": "4.0.0",
|
|
48
|
+
"chai": "6.2.2",
|
|
49
|
+
"chai-as-promised": "8.0.2",
|
|
50
|
+
"cross-env": "10.1.0",
|
|
51
|
+
"@faker-js/faker": "10.2.0",
|
|
52
|
+
"mocha": "11.7.5",
|
|
53
|
+
"mock-jwks": "3.3.5",
|
|
54
|
+
"c8": "^10.1.3",
|
|
55
|
+
"rimraf": "6.1.2",
|
|
56
|
+
"sinon": "21.0.1",
|
|
57
|
+
"sinon-chai": "4.0.1",
|
|
58
|
+
"tsx": "^4.19.2",
|
|
59
|
+
"typescript": "5.9.3",
|
|
60
|
+
"graphql": "16.12.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"format": "prettier --write --ext '.js,.ts' **/*.ts **/*/*.ts",
|
|
64
|
+
"lint:check": "eslint \"**/*.ts\"",
|
|
65
|
+
"lint:fix": "eslint --quiet --fix \"**/*.ts\"",
|
|
66
|
+
"build": "tsc -b tsconfig.json",
|
|
67
|
+
"clean": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
68
|
+
"test:core": "npm run test",
|
|
69
|
+
"test": "tsc --noEmit -p tsconfig.test.json && cross-env MAGEK_ENV=test c8 mocha --forbid-only \"test/**/*.test.ts\""
|
|
70
|
+
}
|
|
71
|
+
}
|