mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-31 13:47:02 +02:00
chore: add application_created event type (#10351)
This is primarily to facilitate reading and processing these events in the payg cloud section of Unleash. We only emit these in one place, so I added the types in there.
This commit is contained in:
parent
ca485959b0
commit
ed9eccd743
@ -24,7 +24,11 @@ import type { IClientMetricsStoreV2 } from '../client-metrics/client-metrics-sto
|
|||||||
import { clientMetricsSchema } from '../shared/schema.js';
|
import { clientMetricsSchema } from '../shared/schema.js';
|
||||||
import type { PartialSome } from '../../../types/partial.js';
|
import type { PartialSome } from '../../../types/partial.js';
|
||||||
import type { IPrivateProjectChecker } from '../../private-project/privateProjectCheckerType.js';
|
import type { IPrivateProjectChecker } from '../../private-project/privateProjectCheckerType.js';
|
||||||
import { type IFlagResolver, SYSTEM_USER } from '../../../types/index.js';
|
import {
|
||||||
|
type ApplicationCreatedEvent,
|
||||||
|
type IFlagResolver,
|
||||||
|
SYSTEM_USER,
|
||||||
|
} from '../../../types/index.js';
|
||||||
import { ALL_PROJECTS, parseStrictSemVer } from '../../../util/index.js';
|
import { ALL_PROJECTS, parseStrictSemVer } from '../../../util/index.js';
|
||||||
import type { Logger } from '../../../logger.js';
|
import type { Logger } from '../../../logger.js';
|
||||||
import { findOutdatedSDKs, isOutdatedSdk } from './findOutdatedSdks.js';
|
import { findOutdatedSDKs, isOutdatedSdk } from './findOutdatedSdks.js';
|
||||||
@ -148,13 +152,15 @@ export default class ClientInstanceService {
|
|||||||
const appsToAnnounce =
|
const appsToAnnounce =
|
||||||
await this.clientApplicationsStore.setUnannouncedToAnnounced();
|
await this.clientApplicationsStore.setUnannouncedToAnnounced();
|
||||||
if (appsToAnnounce.length > 0) {
|
if (appsToAnnounce.length > 0) {
|
||||||
const events = appsToAnnounce.map((app) => ({
|
const events: ApplicationCreatedEvent[] = appsToAnnounce.map(
|
||||||
type: APPLICATION_CREATED,
|
(app) => ({
|
||||||
createdBy: app.createdBy || SYSTEM_USER.username!,
|
type: APPLICATION_CREATED,
|
||||||
data: app,
|
createdBy: app.createdBy || SYSTEM_USER.username!,
|
||||||
createdByUserId: app.createdByUserId || SYSTEM_USER.id,
|
data: app,
|
||||||
ip: '', // TODO: fix this, how do we get the ip from the client? This comes from a row in the DB
|
createdByUserId: app.createdByUserId || SYSTEM_USER.id,
|
||||||
}));
|
ip: '', // TODO: fix this, how do we get the ip from the client? This comes from a row in the DB
|
||||||
|
}),
|
||||||
|
);
|
||||||
await this.eventStore.batchStore(events);
|
await this.eventStore.batchStore(events);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,8 +120,10 @@ import {
|
|||||||
FEATURE_LINK_REMOVED,
|
FEATURE_LINK_REMOVED,
|
||||||
FEATURE_LINK_UPDATED,
|
FEATURE_LINK_UPDATED,
|
||||||
FEATURE_LINK_ADDED,
|
FEATURE_LINK_ADDED,
|
||||||
|
APPLICATION_CREATED,
|
||||||
} from '../events/index.js';
|
} from '../events/index.js';
|
||||||
import type { ITag } from '../tags/index.js';
|
import type { ITag } from '../tags/index.js';
|
||||||
|
import type { IClientApplication } from './stores/client-applications-store.js';
|
||||||
|
|
||||||
export class BaseEvent implements IBaseEvent {
|
export class BaseEvent implements IBaseEvent {
|
||||||
readonly type: IEventType;
|
readonly type: IEventType;
|
||||||
@ -1917,6 +1919,17 @@ export class ReleasePlanMilestoneStartedEvent extends BaseEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ApplicationCreatedEvent extends BaseEvent {
|
||||||
|
readonly data: IClientApplication;
|
||||||
|
constructor(eventData: {
|
||||||
|
data: IClientApplication;
|
||||||
|
auditUser: IAuditUser;
|
||||||
|
}) {
|
||||||
|
super(APPLICATION_CREATED, eventData.auditUser);
|
||||||
|
this.data = eventData.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface IUserEventData
|
interface IUserEventData
|
||||||
extends Pick<
|
extends Pick<
|
||||||
IUserWithRootRole,
|
IUserWithRootRole,
|
||||||
|
Loading…
Reference in New Issue
Block a user