@openactive/models-ts 1.0.5 → 1.0.7

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.
@@ -4,50 +4,85 @@ on:
4
4
  workflow_dispatch:
5
5
  repository_dispatch:
6
6
  types: [data-models-update]
7
+ # Lets other repositories (e.g. models-lib pull requests) test the TypeScript models generated
8
+ # from a specific models-lib or data-models ref. In that case no pull request is created.
9
+ workflow_call:
10
+ inputs:
11
+ models-lib_ref:
12
+ required: false
13
+ type: string
14
+ data-models_ref:
15
+ required: false
16
+ type: string
17
+
18
+ permissions:
19
+ contents: read
7
20
 
8
21
  jobs:
9
22
  generate:
10
23
  runs-on: ubuntu-latest
11
24
 
12
25
  steps:
26
+ # The repository is named explicitly, as this workflow can be called from another repository
13
27
  - name: Checkout models-ts
14
- uses: actions/checkout@v2
28
+ uses: actions/checkout@v4
15
29
  with:
30
+ repository: openactive/models-ts
16
31
  ref: main
17
32
  path: models-ts
18
33
 
19
34
  - name: Checkout models-lib
20
- uses: actions/checkout@v2
35
+ uses: actions/checkout@v4
21
36
  with:
22
37
  repository: openactive/models-lib
38
+ ref: ${{ inputs.models-lib_ref }}
23
39
  path: models-lib
24
40
 
25
- - name: Setup Node.js 14.x
26
- uses: actions/setup-node@v1
41
+ - name: Setup Node.js 18.17.1
42
+ uses: actions/setup-node@v4
27
43
  with:
28
- node-version: 14.x
29
-
44
+ node-version: 18.17.1
45
+
30
46
  - name: Install models-lib
31
47
  run: npm install
32
48
  working-directory: ./models-lib/
33
-
49
+
34
50
  - name: Update models-lib with latest data-models
51
+ if: ${{ !inputs.data-models_ref }}
35
52
  run: npm update @openactive/data-models
36
53
  working-directory: ./models-lib/
37
54
 
55
+ - name: Install data-models ${{ inputs.data-models_ref }}
56
+ if: ${{ inputs.data-models_ref }}
57
+ env:
58
+ DATA_MODELS_REF: ${{ inputs.data-models_ref }}
59
+ run: npm install "github:openactive/data-models#$DATA_MODELS_REF"
60
+ working-directory: ./models-lib/
61
+
38
62
  - name: Run TypeScript models generator
39
63
  run: npm start -- generate TypeScript --destination ../models-ts/src/
40
64
  working-directory: ./models-lib/
41
-
65
+
42
66
  - name: Install models-ts
43
67
  run: npm install
44
68
  working-directory: ./models-ts/
45
-
69
+
70
+ # tsc never deletes output, so compiled files for removed models would otherwise stay in lib/.
71
+ # This only affects the runner's copy: if the build or tests fail, no pull request is created.
72
+ - name: Remove previous build
73
+ run: rm -rf lib
74
+ working-directory: ./models-ts/
75
+
46
76
  - name: Build models-ts types
47
77
  run: npm run build
48
78
  working-directory: ./models-ts/
49
79
 
80
+ - name: Test models-ts
81
+ run: npm test
82
+ working-directory: ./models-ts/
83
+
50
84
  - name: Generate GitHub App Token
85
+ if: ${{ !inputs.models-lib_ref && !inputs.data-models_ref }}
51
86
  uses: actions/create-github-app-token@v1
52
87
  id: generate-token
53
88
  with:
@@ -55,8 +90,9 @@ jobs:
55
90
  private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
56
91
 
57
92
  - name: Create Pull Request
93
+ if: ${{ !inputs.models-lib_ref && !inputs.data-models_ref }}
58
94
  id: cpr
59
- uses: peter-evans/create-pull-request@v4
95
+ uses: peter-evans/create-pull-request@v7
60
96
  with:
61
97
  path: ./models-ts/
62
98
  token: ${{ steps.generate-token.outputs.token }}
@@ -74,6 +110,10 @@ jobs:
74
110
  draft: false
75
111
 
76
112
  - name: Check outputs
113
+ if: ${{ !inputs.models-lib_ref && !inputs.data-models_ref }}
114
+ env:
115
+ PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
116
+ PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
77
117
  run: |
78
- echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
79
- echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
118
+ echo "Pull Request Number - $PR_NUMBER"
119
+ echo "Pull Request URL - $PR_URL"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openactive/models-ts",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "JavaScript/TypeScript implementation of OpenActive's data model",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",