declapract-typescript-ehmpathy 0.31.10 → 0.32.0

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.
@@ -0,0 +1,46 @@
1
+ name: .install
2
+
3
+ on:
4
+ workflow_call:
5
+ outputs:
6
+ node-modules-cache-key:
7
+ description: a max(stable) cache key to the node modules of this commit's dependencies
8
+ value: ${{ jobs.npm.outputs.node-modules-cache-key }}
9
+
10
+ jobs:
11
+ npm:
12
+ runs-on: ubuntu-20.04
13
+ outputs:
14
+ node-modules-cache-key: ${{ steps.cache.outputs.cache-primary-key }}
15
+ steps:
16
+ - name: checkout
17
+ uses: actions/checkout@v3
18
+
19
+ - name: set node-version
20
+ uses: actions/setup-node@v3
21
+ with:
22
+ node-version-file: '.nvmrc'
23
+
24
+ - name: node-modules deps hash
25
+ id: deps-hash
26
+ run: |
27
+ PACKAGE_DEPS_HASH=$(jq '.packages' package-lock.json | jq 'del(."".version)' | md5sum | awk '{print $1}');
28
+ echo "PACKAGE_DEPS_HASH=$PACKAGE_DEPS_HASH"
29
+ echo "package-deps-hash=$PACKAGE_DEPS_HASH" >> "$GITHUB_OUTPUT"
30
+ - name: node-modules cache get
31
+ uses: actions/cache/restore@v3
32
+ id: cache
33
+ with:
34
+ path: ./node_modules
35
+ key: ${{ runner.os }}-node-${{ steps.deps-hash.outputs.package-deps-hash }}
36
+
37
+ - name: node-modules cache miss install
38
+ if: steps.cache.outputs.cache-hit != 'true'
39
+ run: npm ci --ignore-scripts --prefer-offline --no-audit
40
+
41
+ - name: node-modules cache set
42
+ if: steps.cache.outputs.cache-hit != 'true'
43
+ uses: actions/cache/save@v3
44
+ with:
45
+ path: ./node_modules
46
+ key: ${{ steps.cache.outputs.cache-primary-key }}
@@ -20,38 +20,13 @@ on:
20
20
  description: required credentials to authenticate with aws the aws account against which to run the tests
21
21
 
22
22
  jobs:
23
+ # install the dependencies
23
24
  install:
24
- runs-on: ubuntu-latest
25
- steps:
26
- - name: checkout
27
- uses: actions/checkout@v3
28
-
29
- - name: set node-version
30
- uses: actions/setup-node@v3
31
- with:
32
- node-version-file: '.nvmrc'
33
-
34
- - name: node-modules cache get
35
- uses: actions/cache/restore@v3
36
- id: cache
37
- with:
38
- path: ./node_modules
39
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
40
-
41
- - name: node-modules cache miss install
42
- if: steps.cache.outputs.cache-hit != 'true'
43
- run: npm ci --ignore-scripts --prefer-offline --no-audit
44
-
45
- - name: node-modules cache set
46
- if: steps.cache.outputs.cache-hit != 'true'
47
- uses: actions/cache/save@v3
48
- with:
49
- path: ./node_modules
50
- key: ${{ steps.cache.outputs.cache-primary-key }}
25
+ uses: ./.github/workflows/.install.yml
51
26
 
52
27
  # run tests in parallel
53
28
  test-commits:
54
- runs-on: ubuntu-latest
29
+ runs-on: ubuntu-20.04
55
30
  needs: [install]
56
31
  steps:
57
32
  - name: checkout
@@ -68,13 +43,13 @@ jobs:
68
43
  uses: actions/cache/restore@v3
69
44
  with:
70
45
  path: ./node_modules
71
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
46
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
72
47
 
73
48
  - name: test:commits
74
49
  run: npm run test:commits
75
50
 
76
51
  test-types:
77
- runs-on: ubuntu-latest
52
+ runs-on: ubuntu-20.04
78
53
  needs: [install]
79
54
  steps:
80
55
  - name: checkout
@@ -89,13 +64,13 @@ jobs:
89
64
  uses: actions/cache/restore@v3
90
65
  with:
91
66
  path: ./node_modules
92
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
67
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
93
68
 
94
69
  - name: test:types
95
70
  run: npm run test:types
96
71
 
97
72
  test-format:
98
- runs-on: ubuntu-latest
73
+ runs-on: ubuntu-20.04
99
74
  needs: [install]
100
75
  steps:
101
76
  - name: checkout
@@ -110,13 +85,13 @@ jobs:
110
85
  uses: actions/cache/restore@v3
111
86
  with:
112
87
  path: ./node_modules
113
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
88
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
114
89
 
115
90
  - name: test:format
116
91
  run: npm run test:format
117
92
 
118
93
  test-lint:
119
- runs-on: ubuntu-latest
94
+ runs-on: ubuntu-20.04
120
95
  needs: [install]
121
96
  steps:
122
97
  - name: checkout
@@ -131,13 +106,13 @@ jobs:
131
106
  uses: actions/cache/restore@v3
132
107
  with:
133
108
  path: ./node_modules
134
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
109
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
135
110
 
136
111
  - name: test:lint
137
112
  run: npm run test:lint
138
113
 
139
114
  test-unit:
140
- runs-on: ubuntu-latest
115
+ runs-on: ubuntu-20.04
141
116
  needs: [install]
142
117
  steps:
143
118
  - name: checkout
@@ -152,13 +127,13 @@ jobs:
152
127
  uses: actions/cache/restore@v3
153
128
  with:
154
129
  path: ./node_modules
155
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
130
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
156
131
 
157
132
  - name: test:unit
158
133
  run: THOROUGH=true npm run test:unit
159
134
 
160
135
  test-integration:
161
- runs-on: ubuntu-latest
136
+ runs-on: ubuntu-20.04
162
137
  needs: [install]
163
138
  steps:
164
139
  - name: checkout
@@ -173,7 +148,7 @@ jobs:
173
148
  uses: actions/cache/restore@v3
174
149
  with:
175
150
  path: ./node_modules
176
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
151
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
177
152
 
178
153
  - name: configure aws credentials
179
154
  if: "${{ inputs.aws-account-id != '' }}"
@@ -198,7 +173,7 @@ jobs:
198
173
  run: THOROUGH=true npm run test:integration
199
174
 
200
175
  test-acceptance-locally:
201
- runs-on: ubuntu-latest
176
+ runs-on: ubuntu-20.04
202
177
  needs: [install]
203
178
  steps:
204
179
  - name: checkout
@@ -213,7 +188,7 @@ jobs:
213
188
  uses: actions/cache/restore@v3
214
189
  with:
215
190
  path: ./node_modules
216
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
191
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
217
192
 
218
193
  - name: configure aws credentials
219
194
  if: "${{ inputs.aws-account-id != '' }}"
@@ -8,8 +8,12 @@ on:
8
8
  description: required credentials to authenticate with the aws account under which to publish
9
9
 
10
10
  jobs:
11
+ install:
12
+ uses: ./.github/workflows/.install.yml
13
+
11
14
  publish:
12
15
  runs-on: ubuntu-20.04
16
+ needs: [install]
13
17
  steps:
14
18
  - name: checkout
15
19
  uses: actions/checkout@v3
@@ -25,7 +29,7 @@ jobs:
25
29
  id: cache
26
30
  with:
27
31
  path: ./node_modules
28
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
32
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
29
33
 
30
34
  - name: node-modules cache miss install
31
35
  if: steps.cache.outputs.cache-hit != 'true'
@@ -36,8 +36,12 @@ on:
36
36
  description: complete openvpn config required to enter the vpn, if needed
37
37
 
38
38
  jobs:
39
+ install:
40
+ uses: ./.github/workflows/.install.yml
41
+
39
42
  deploy:
40
- runs-on: ubuntu-latest
43
+ runs-on: ubuntu-20.04
44
+ needs: [install]
41
45
  steps:
42
46
  - name: checkout
43
47
  uses: actions/checkout@v3
@@ -66,7 +70,7 @@ jobs:
66
70
  id: cache
67
71
  with:
68
72
  path: ./node_modules
69
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
73
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
70
74
 
71
75
  - name: node-modules cache miss install
72
76
  if: steps.cache.outputs.cache-hit != 'true'
@@ -76,8 +80,8 @@ jobs:
76
80
  run: STAGE=${{ inputs.stage }} DEPLOYER_NAME=$GITHUB_ACTOR npm run deploy
77
81
 
78
82
  assure:
79
- runs-on: ubuntu-latest
80
- needs: [deploy]
83
+ runs-on: ubuntu-20.04
84
+ needs: [install, deploy]
81
85
  steps:
82
86
  - name: checkout
83
87
  uses: actions/checkout@v3
@@ -106,7 +110,7 @@ jobs:
106
110
  id: cache
107
111
  with:
108
112
  path: ./node_modules
109
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
113
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
110
114
 
111
115
  - name: node-modules cache miss install
112
116
  if: steps.cache.outputs.cache-hit != 'true'
@@ -140,8 +144,8 @@ jobs:
140
144
  run: sudo killall openvpn
141
145
 
142
146
  prune:
143
- runs-on: ubuntu-latest
144
- needs: [deploy]
147
+ runs-on: ubuntu-20.04
148
+ needs: [install, deploy]
145
149
  steps:
146
150
  - name: checkout
147
151
  uses: actions/checkout@v3
@@ -170,7 +174,7 @@ jobs:
170
174
  id: cache
171
175
  with:
172
176
  path: ./node_modules
173
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
177
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
174
178
 
175
179
  - name: node-modules cache miss install
176
180
  if: steps.cache.outputs.cache-hit != 'true'
@@ -32,8 +32,12 @@ on:
32
32
  description: complete openvpn config required to enter the vpn
33
33
 
34
34
  jobs:
35
+ install:
36
+ uses: ./.github/workflows/.install.yml
37
+
35
38
  plan:
36
- runs-on: ubuntu-latest
39
+ runs-on: ubuntu-20.04
40
+ needs: [install]
37
41
  outputs:
38
42
  has-changes-planned: ${{ steps.evaluate-plan.outputs.has-changes-planned }}
39
43
  steps:
@@ -50,7 +54,7 @@ jobs:
50
54
  id: cache
51
55
  with:
52
56
  path: ./node_modules
53
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
57
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
54
58
 
55
59
  - name: node-modules cache miss install
56
60
  if: steps.cache.outputs.cache-hit != 'true'
@@ -116,9 +120,9 @@ jobs:
116
120
  run: sudo killall openvpn
117
121
 
118
122
  apply:
119
- runs-on: ubuntu-latest
123
+ runs-on: ubuntu-20.04
120
124
  environment: ${{ inputs.github-environment }}
121
- needs: plan
125
+ needs: [install, plan]
122
126
  if: ${{ inputs.allow-apply == true && needs.plan.outputs.has-changes-planned == 'true' }}
123
127
  steps:
124
128
  - name: checkout
@@ -134,7 +138,7 @@ jobs:
134
138
  id: cache
135
139
  with:
136
140
  path: ./node_modules
137
- key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
141
+ key: ${{ needs.install.outputs.node-modules-cache-key }}
138
142
 
139
143
  - name: node-modules cache miss install
140
144
  if: steps.cache.outputs.cache-hit != 'true'
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
- "domain-objects": "@declapract{check.minVersion('0.10.3')}",
3
+ "domain-objects": "@declapract{check.minVersion('0.21.9')}",
4
4
  "joi": "@declapract{check.minVersion('17.4.0')}",
5
- "type-fns": "@declapract{check.minVersion('0.8.1')}"
5
+ "type-fns": "@declapract{check.minVersion('0.16.0')}"
6
6
  }
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { UnexpectedCodePathError } from '@ehmpathy/error-fns';
1
2
  import { createIsOfEnum } from 'type-fns';
2
3
 
3
4
  export enum Stage {
@@ -7,6 +8,22 @@ export enum Stage {
7
8
  }
8
9
  export const isOfStage = createIsOfEnum(Stage);
9
10
 
11
+ /**
12
+ * verify that the server is on UTC timezone
13
+ *
14
+ * why?
15
+ * - non UTC timezone usage causes problems and takes a while to track down
16
+ * - by failing fast if the server our code runs in is not in UTC, we avoid these issues
17
+ * =>
18
+ * - create a pit of success
19
+ */
20
+ const TIMEZONE = process.env.TZ;
21
+ if (TIMEZONE !== 'UTC')
22
+ throw new UnexpectedCodePathError(
23
+ 'env.TZ is not set to UTC. this can cause issues. please set the env var',
24
+ { found: TIMEZONE, desire: 'UTC' },
25
+ );
26
+
10
27
  /**
11
28
  * this allows us to infer what the stage should be in environments that do not have STAGE specified
12
29
  * - e.g., when running locally
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "simple-lambda-handlers": "@declapract{check.minVersion('0.9.0')}"
3
+ "simple-lambda-handlers": "@declapract{check.minVersion('0.9.1')}"
4
4
  },
5
5
  "devDependencies": {}
6
6
  }
@@ -43,5 +43,6 @@ module.exports = {
43
43
  '@typescript-eslint/lines-between-class-members': 'off',
44
44
  'no-return-await': 'off', // this does not help anything and actually leads to bugs if we subsequently wrap the return in a try catch without remembering to _then_ add await
45
45
  '@typescript-eslint/return-await': 'off',
46
+ '@typescript-eslint/no-unsafe-declaration-merging': 'off', // dobjs are built off of this
46
47
  },
47
48
  };
@@ -4,10 +4,10 @@
4
4
  "yesql": "@declapract{check.minVersion('3.2.2')}"
5
5
  },
6
6
  "devDependencies": {
7
- "sql-code-generator": "@declapract{check.minVersion('0.9.3')}",
8
- "sql-dao-generator": "@declapract{check.minVersion('0.4.0')}",
7
+ "sql-code-generator": "@declapract{check.minVersion('0.10.0')}",
8
+ "sql-dao-generator": "@declapract{check.minVersion('0.8.1')}",
9
9
  "sql-schema-control": "@declapract{check.minVersion('1.5.0')}",
10
- "sql-schema-generator": "@declapract{check.minVersion('0.23.0')}",
10
+ "sql-schema-generator": "@declapract{check.minVersion('0.25.0')}",
11
11
  "@types/yesql": "@declapract{check.minVersion('3.2.2')}",
12
12
  "@types/pg": "@declapract{check.minVersion('8.6.1')}"
13
13
  },
@@ -17,6 +17,7 @@ provider:
17
17
  environment: ${self:provider.stage}
18
18
  product: ${self:service}
19
19
  environment:
20
+ TZ: UTC # guarantee that utc timezone will be used explicitly, to facilitate a pit of success
20
21
  NODE_ENV: production # deploy with production optimizations of all resources, to make `dev` and `prod` stage deployments equivalent functionally (i.e., the same code paths in dev and prod)
21
22
  STAGE: ${self:provider.stage} # deploy specifying which stage we're targeting, to enable targeting the correct config + resources (e.g., hit dev db -vs- prod db)
22
23
  AWS_NODEJS_CONNECTION_REUSE_ENABLED: true # https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
@@ -58,7 +58,6 @@ resource "github_branch_protection" "main_branch" {
58
58
  required_status_checks {
59
59
  strict = true # branch must be up to date. otherwise, we dont know if it will really pass once it is merged
60
60
  contexts = [
61
- "suite / install",
62
61
  "suite / test-commits",
63
62
  "suite / test-types",
64
63
  "suite / test-format",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.31.10",
5
+ "version": "0.32.0",
6
6
  "main": "src/index.js",
7
7
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
8
8
  "homepage": "https://github.com/ehmpathy/declapract-typescript-ehmpathy",
@@ -38,6 +38,7 @@
38
38
  "postinstall": "[ -d .git ] && npx husky install || exit 0"
39
39
  },
40
40
  "dependencies": {
41
+ "@ehmpathy/error-fns": "1.3.1",
41
42
  "expect": "29.4.2",
42
43
  "flat": "5.0.2",
43
44
  "lodash.uniq": "4.5.0",