-
-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preliminary project applications schema (#6152)
Currently keeping flat structure and separate out into multiple requests(schemas) if needed. In future, we will also add dates.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FromSchema } from 'json-schema-to-ts'; | ||
|
||
export const projectApplicationSchema = { | ||
$id: '#/components/schemas/projectApplicationSchema', | ||
type: 'object', | ||
additionalProperties: false, | ||
required: ['appName', 'instanceId', 'sdkVersion', 'environment'], | ||
description: 'A project application instance.', | ||
properties: { | ||
appName: { | ||
type: 'string', | ||
description: | ||
'Name of the application that is using the SDK. This is the same as the appName in the SDK configuration.', | ||
}, | ||
instanceId: { | ||
type: 'string', | ||
description: | ||
'The unique identifier of the application instance. This is the same as the instanceId in the SDK configuration', | ||
}, | ||
sdkVersion: { | ||
type: 'string', | ||
description: | ||
'The version of the SDK that is being used by the application', | ||
}, | ||
environment: { | ||
type: 'string', | ||
description: | ||
'The environment that the application is running in. This is coming from token configured in the SDK configuration.', | ||
}, | ||
}, | ||
components: {}, | ||
} as const; | ||
|
||
export type ProjectApplicationSchema = FromSchema< | ||
typeof projectApplicationSchema | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { validateSchema } from '../validate'; | ||
import { ProjectApplicationsSchema } from './project-applications-schema'; | ||
|
||
test('projectApplicationsSchema', () => { | ||
const data: ProjectApplicationsSchema = [ | ||
{ | ||
appName: 'my-weba-app', | ||
instanceId: 'app1:3:4', | ||
sdkVersion: '4.1.1', | ||
environment: 'production', | ||
}, | ||
]; | ||
|
||
expect( | ||
validateSchema('#/components/schemas/projectApplicationsSchema', data), | ||
).toBeUndefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { FromSchema } from 'json-schema-to-ts'; | ||
import { projectApplicationSchema } from './project-application-schema'; | ||
|
||
export const projectApplicationsSchema = { | ||
$id: '#/components/schemas/projectApplicationsSchema', | ||
type: 'array', | ||
description: 'A list of project applications', | ||
items: { | ||
$ref: '#/components/schemas/projectApplicationSchema', | ||
}, | ||
components: { | ||
schemas: { | ||
projectApplicationSchema, | ||
}, | ||
}, | ||
} as const; | ||
|
||
export type ProjectApplicationsSchema = FromSchema< | ||
typeof projectApplicationsSchema | ||
>; |