Skip to content

Commit

Permalink
feat: add properties to AssetBundleConvertedEvent (#322)
Browse files Browse the repository at this point in the history
* feat: add properties to AssetBundleConvertedEvent

* refactor: rename AB Conversion event to AssetBundleConversionFinishedEvent
  • Loading branch information
aleortega authored Dec 16, 2024
1 parent 9105c6b commit 4dd23a2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
14 changes: 8 additions & 6 deletions report/schemas.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,27 @@ export namespace AnyMapping {
validate: ValidateFunction<Mapping>;
}

// Warning: (ae-missing-release-tag) "AssetBundleConvertedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "AssetBundleConvertedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "AssetBundleConversionFinishedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "AssetBundleConversionFinishedEvent" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AssetBundleConvertedEvent = BaseEvent & {
export type AssetBundleConversionFinishedEvent = BaseEvent & {
type: Events.Type.ASSET_BUNDLE;
subType: Events.SubType.AssetBundle.CONVERTED;
metadata: {
entityId: string;
platform: 'windows' | 'mac' | 'webglb';
statusCode: number;
isLods: boolean;
};
};

// @public (undocumented)
export namespace AssetBundleConvertedEvent {
export namespace AssetBundleConversionFinishedEvent {
const // (undocumented)
schema: JSONSchema<AssetBundleConvertedEvent>;
schema: JSONSchema<AssetBundleConversionFinishedEvent>;
const // (undocumented)
validate: ValidateFunction<AssetBundleConvertedEvent>;
validate: ValidateFunction<AssetBundleConversionFinishedEvent>;
}

// @public
Expand Down
16 changes: 10 additions & 6 deletions src/platform/events/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ export namespace BadgeGrantedEvent {
export const validate: ValidateFunction<BadgeGrantedEvent> = generateLazyValidator(schema)
}

export type AssetBundleConvertedEvent = BaseEvent & {
export type AssetBundleConversionFinishedEvent = BaseEvent & {
type: Events.Type.ASSET_BUNDLE
subType: Events.SubType.AssetBundle.CONVERTED
metadata: {
entityId: string
platform: 'windows' | 'mac' | 'webglb'
statusCode: number
isLods: boolean
}
}

export namespace AssetBundleConvertedEvent {
export const schema: JSONSchema<AssetBundleConvertedEvent> = {
export namespace AssetBundleConversionFinishedEvent {
export const schema: JSONSchema<AssetBundleConversionFinishedEvent> = {
type: 'object',
properties: {
type: { type: 'string', const: Events.Type.ASSET_BUNDLE },
Expand All @@ -61,14 +63,16 @@ export namespace AssetBundleConvertedEvent {
type: 'object',
properties: {
entityId: { type: 'string' },
platform: { type: 'string', enum: ['windows', 'mac', 'webglb'] }
platform: { type: 'string', enum: ['windows', 'mac', 'webglb'] },
statusCode: { type: 'number' },
isLods: { type: 'boolean' }
},
required: ['entityId', 'platform']
required: ['entityId', 'platform', 'statusCode', 'isLods']
}
},
required: ['type', 'subType', 'key', 'timestamp', 'metadata'],
additionalProperties: true
}

export const validate: ValidateFunction<AssetBundleConvertedEvent> = generateLazyValidator(schema)
export const validate: ValidateFunction<AssetBundleConversionFinishedEvent> = generateLazyValidator(schema)
}
18 changes: 10 additions & 8 deletions test/platform/events/asset-bundle-converted.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import expect from 'expect'
import { AssetBundleConvertedEvent, Events } from '../../../src'
import { AssetBundleConversionFinishedEvent, Events } from '../../../src'

describe('AssetBundleConverted Events tests', () => {
it('AssetBundleConvertedEvent static tests must pass', () => {
const event: AssetBundleConvertedEvent = {
describe('AssetBundleConversionFinished Events tests', () => {
it('AssetBundleConversionFinishedEvent static tests must pass', () => {
const event: AssetBundleConversionFinishedEvent = {
type: Events.Type.ASSET_BUNDLE,
subType: Events.SubType.AssetBundle.CONVERTED,
key: 'key',
timestamp: 1,
metadata: {
entityId: 'baf',
platform: 'mac'
platform: 'mac',
statusCode: 1,
isLods: false
}
}

expect(AssetBundleConvertedEvent.validate(event)).toEqual(true)
expect(AssetBundleConvertedEvent.validate(null)).toEqual(false)
expect(AssetBundleConvertedEvent.validate({})).toEqual(false)
expect(AssetBundleConversionFinishedEvent.validate(event)).toEqual(true)
expect(AssetBundleConversionFinishedEvent.validate(null)).toEqual(false)
expect(AssetBundleConversionFinishedEvent.validate({})).toEqual(false)
})
})

0 comments on commit 4dd23a2

Please sign in to comment.