@fragus/sam-types 1.1.8 → 1.1.10
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/README.md +31 -58
- package/package.json +1 -1
- package/types/contract/contractList.d.ts +39 -0
- package/types/outage.d.ts +66 -0
package/README.md
CHANGED
|
@@ -1,75 +1,48 @@
|
|
|
1
1
|
# SAM-types
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The TypeScript types shared by SAM-api and its clients: SAM-admin-v2, SAM-superadmin-frontend,
|
|
4
|
+
SAM-webcalc-v2 and MyPage. Requests, responses, error keys and enums live here once, so the API and
|
|
5
|
+
every client agree on what goes over the wire.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Published to npm as [`@fragus/sam-types`](https://www.npmjs.com/package/@fragus/sam-types).
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
TODO: Fill this out
|
|
9
|
+
## Using it
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Each consumer pins an exact version in its `package.json`:
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
```json
|
|
14
|
+
"@fragus/sam-types": "1.1.9"
|
|
15
|
+
```
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
### Dependencies
|
|
18
|
-
The project only has one dependency: `Typescript`
|
|
17
|
+
Import from the package root:
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
```ts
|
|
20
|
+
import { ContractState, INoContractsAvailableErrorParams } from '@fragus/sam-types'
|
|
21
|
+
```
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
## Prerequisites
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
- Node.js: the version in `.nvmrc`
|
|
26
|
+
- npm
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
## Getting started
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
npm run tsc # npm run tsc-win on Windows without bash
|
|
33
|
+
```
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
`npm run tsc` deletes the compiled `.js` files and builds the package again. CI runs the same build on
|
|
36
|
+
every push.
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
To use the types locally in an application, add the line below as a dependency in your `package.json` file:
|
|
38
|
+
## Docs
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
- [Adding and changing types](docs/adding-types.md): where a type goes, naming, exports, and the
|
|
41
|
+
TypeScript 3.3 limit
|
|
42
|
+
- [Testing in a consumer before release](docs/local-development.md): `file:../SAM-types` and how to undo it
|
|
43
|
+
- [Releasing](docs/releasing.md): versioning, the GitHub release that publishes to npm, and bumping the
|
|
44
|
+
consumers
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
### Using yarn
|
|
39
|
-
To use the types locally you can use `yarn link`. See docs [here](https://yarnpkg.com/lang/en/docs/cli/link/).
|
|
46
|
+
## Branches
|
|
40
47
|
|
|
41
|
-
`
|
|
42
|
-
|
|
43
|
-
Then `cd` to your application and type `yarn link "sam-types"`. Now your application uses your local SAM-types project (using a symlink). To unlink, type `yarn unlink "sam-types"`
|
|
44
|
-
|
|
45
|
-
This means that you do not have to change anything in your `package.json` file.
|
|
46
|
-
|
|
47
|
-
### Regular dependency
|
|
48
|
-
To use SAM-types in a project, add the line below as a dependency in your `package.json` file:
|
|
49
|
-
|
|
50
|
-
`"sam-types": "OmniCar/SAM-types#0.0.1"`
|
|
51
|
-
|
|
52
|
-
If you need to target something other than a specific release, consider targeting a branch or a commit as shown below:
|
|
53
|
-
|
|
54
|
-
* `"sam-types": "OmniCar/SAM-types#4727d357ea"`
|
|
55
|
-
* `"sam-types": "OmniCar/SAM-types#feature\/branch"`
|
|
56
|
-
|
|
57
|
-
## Releasing
|
|
58
|
-
|
|
59
|
-
### Using GitHub
|
|
60
|
-
|
|
61
|
-
* Go to [releases](https://github.com/OmniCar/SAM-types/releases) on GitHub
|
|
62
|
-
* Press "Create a new release"
|
|
63
|
-
* Set the "Tag version" to the appropriate version number (see versioning above)
|
|
64
|
-
* Set the "Release title" to "Version <version_number>"
|
|
65
|
-
* Describe the changes. What's new? are there any breaking changes? etc.
|
|
66
|
-
* If you want you can see the changes on `master` compared to a release (for example version `0.0.1`) by typing: `git diff tags/0.0.1 master`
|
|
67
|
-
* Press "Publish release"
|
|
68
|
-
|
|
69
|
-
### Using [hub cli](https://github.com/github/hub)
|
|
70
|
-
|
|
71
|
-
If you have installed the hub cli (see link above), you can create a new release with the below command. Please note that it defaults to targeting the main (`master`) branch unless you use the `-t` option (more options [here](https://github.com/github/hub/blob/master/commands/release.go))
|
|
72
|
-
|
|
73
|
-
`git release create -o -m "Release 0.0.2" "0.0.2"`
|
|
74
|
-
|
|
75
|
-
If you did not set up the alias for `git = hub` you should write `hub` instead of `git` in the command above.
|
|
48
|
+
`fix/`, `feature/` or `backmerge/` plus a kebab-case description. PRs target `develop`.
|
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IContractHealth } from './../admin/contract/health'
|
|
2
|
+
import { TContractObject } from './../admin/product'
|
|
2
3
|
import { ContractState } from './../index'
|
|
4
|
+
import { IPaginatedQueryParams, IPaginatedResponse } from './../queryParams'
|
|
3
5
|
import { IContractFilterDate, IContractFilterOption } from './contractFilter'
|
|
4
6
|
|
|
5
7
|
export interface IContractListRecord {
|
|
@@ -51,3 +53,40 @@ export interface IWarrantyListRecord {
|
|
|
51
53
|
registrationNumber: string
|
|
52
54
|
sellerName: string
|
|
53
55
|
}
|
|
56
|
+
|
|
57
|
+
/** A contract-list row from the superadmin cross-provider search, tagged with its owning provider. */
|
|
58
|
+
export interface IContractCrossProviderSearchRecord extends IContractListRecord {
|
|
59
|
+
contractProviderId: number
|
|
60
|
+
contractProviderName: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface IContractCrossProviderSearchResponse {
|
|
64
|
+
result: IContractCrossProviderSearchRecord[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface IContractCrossProviderSearchParams {
|
|
68
|
+
search: string
|
|
69
|
+
limit?: number
|
|
70
|
+
includeInactiveProviders?: 'yes'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The provider-agnostic contract-list filters. Sellers, templates, options and sub dealers are
|
|
75
|
+
* vocabularies of a single provider and have no cross-provider meaning.
|
|
76
|
+
*/
|
|
77
|
+
export interface IContractCrossProviderFilterParams {
|
|
78
|
+
contractStates?: ContractState[]
|
|
79
|
+
created?: IContractFilterDate
|
|
80
|
+
expired?: IContractFilterDate
|
|
81
|
+
activeTypes?: TContractObject[]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface IContractCrossProviderListParams
|
|
85
|
+
extends IPaginatedQueryParams<ContractListOrderByType, IContractCrossProviderFilterParams> {
|
|
86
|
+
includeInactiveProviders?: 'yes'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type IContractCrossProviderListResponse = IPaginatedResponse<
|
|
90
|
+
IContractCrossProviderSearchRecord[],
|
|
91
|
+
ContractListOrderByType
|
|
92
|
+
>
|
package/types/outage.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TIsoCountry } from './country'
|
|
1
2
|
import { OutageSeverityLevel } from './index'
|
|
2
3
|
|
|
3
4
|
export interface IOutageResponse {
|
|
@@ -7,3 +8,68 @@ export interface IOutageResponse {
|
|
|
7
8
|
disabledPaths: string[] | null
|
|
8
9
|
severityLevel: OutageSeverityLevel | null
|
|
9
10
|
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Request body for creating or updating an outage (Superadmin). A null text or severity falls back to the
|
|
14
|
+
* template's default. Leave both iso_countries and provider_ids null for an outage that applies to everyone.
|
|
15
|
+
*/
|
|
16
|
+
export interface IOutageAdminRequest {
|
|
17
|
+
outageTemplateId: number | null
|
|
18
|
+
headerText: string | null
|
|
19
|
+
message: string | null
|
|
20
|
+
severityLevel: OutageSeverityLevel | null
|
|
21
|
+
/**
|
|
22
|
+
* Paths whose requests are refused while the outage is active. A path matches anywhere in the URL, in every app,
|
|
23
|
+
* so start it with its app: /admin/contracts, /my-page/invoices. '*' refuses every request.
|
|
24
|
+
*/
|
|
25
|
+
disabledPaths: string[] | null
|
|
26
|
+
isoCountries: TIsoCountry[] | null
|
|
27
|
+
providerIds: number[] | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An outage as Superadmin lists and edits it.
|
|
32
|
+
*/
|
|
33
|
+
export interface IOutageAdminResponse extends IOutageAdminRequest {
|
|
34
|
+
outageId: number
|
|
35
|
+
/**
|
|
36
|
+
* ISO date string (YYYY-MM-DD) of when the outage was created
|
|
37
|
+
*/
|
|
38
|
+
date: string
|
|
39
|
+
/**
|
|
40
|
+
* ISO date string (YYYY-MM-DD) of when the outage was archived; null while it is active
|
|
41
|
+
*/
|
|
42
|
+
archived: string | null
|
|
43
|
+
/**
|
|
44
|
+
* What users see: the outage's own text and severity, or the template's when those are null
|
|
45
|
+
*/
|
|
46
|
+
effectiveHeaderText: string
|
|
47
|
+
effectiveMessage: string
|
|
48
|
+
effectiveSeverityLevel: OutageSeverityLevel
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Request body for creating or updating an outage template (Superadmin). Updating changes what users see for every
|
|
53
|
+
* active outage that leaves these values empty.
|
|
54
|
+
*/
|
|
55
|
+
export interface IOutageTemplateRequest {
|
|
56
|
+
name: string
|
|
57
|
+
defaultHeaderText: string
|
|
58
|
+
defaultMessage: string
|
|
59
|
+
defaultSeverityLevel: OutageSeverityLevel
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* An outage template: the texts and severity a new outage can start from (Superadmin).
|
|
64
|
+
*/
|
|
65
|
+
export interface IOutageTemplateResponse extends IOutageTemplateRequest {
|
|
66
|
+
outageTemplateId: number
|
|
67
|
+
/**
|
|
68
|
+
* Outages using the template, archived ones included; a template can only be deleted while this is 0
|
|
69
|
+
*/
|
|
70
|
+
outageCount: number
|
|
71
|
+
/**
|
|
72
|
+
* Active outages using the template, whose text changes when the template is edited
|
|
73
|
+
*/
|
|
74
|
+
activeOutageCount: number
|
|
75
|
+
}
|