@shakerquiz/contracts 0.0.0 → 0.0.1

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,30 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ pull_request:
5
+ types: [ closed ]
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ id-token: write
11
+ contents: read
12
+
13
+ jobs:
14
+ publish:
15
+ runs-on: ubuntu-latest
16
+ if: github.event.pull_request.merged == true
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: '20'
22
+ registry-url: 'https://registry.npmjs.org'
23
+ - run: git config user.name "github-actions[bot]"
24
+ - run: git config user.email "github-actions[bot]@users.noreply.github.com"
25
+ - name: Update npm
26
+ run: npm install -g npm@latest
27
+ - run: npm version patch
28
+ - run: npm ci
29
+ - run: npm publish
30
+ - run: git push --tags
package/generate.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Methods, Mode, Roles, Routes } from '@shakerquiz/utilities'
2
+ import { stat, writeFile } from 'node:fs/promises'
2
3
 
3
4
  let identifier = (method, route, role) => method + '_' + route.replaceAll('/', '_') + '_' + role
4
5
 
@@ -10,14 +11,15 @@ let pathnames = Methods
10
11
  .map(([method, route, role]) => ({ method, route, role }))
11
12
 
12
13
  Promise
13
- .all(pathnames.map(({ method, route, role }) =>
14
- Deno
15
- .lstat('./source/contracts/' + method + '/' + route + '/' + role + '.json')
16
- .then(() => ({ method, route, role }))
17
- .catch(() => null)
18
- ))
14
+ .all(
15
+ pathnames.map(({ method, route, role }) =>
16
+ stat('./source/contracts/' + method + '/' + route + '/' + role + '.json')
17
+ .then(() => ({ method, route, role }))
18
+ .catch(() => null)
19
+ ),
20
+ )
19
21
  .then(components =>
20
- Deno.writeTextFile(
22
+ writeFile(
21
23
  './source/index.js',
22
24
  ''
23
25
  + components
@@ -36,7 +38,7 @@ Promise
36
38
  + "with { type: 'json' }"
37
39
  + '\n', '')
38
40
  + '\n'
39
- + 'export const Schema = Object.freeze({'
41
+ + 'export const Contract = Object.freeze({'
40
42
  + '\n'
41
43
  + components
42
44
  .filter(Boolean)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/contracts",
4
- "version": "0.0.0",
4
+ "version": "0.0.1",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/shaker-quiz/contracts.git"
10
10
  },
11
11
  "scripts": {
12
- "prepublishOnly": "deno run -A ./generate.js"
12
+ "prepublishOnly": "node ./generate.js"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
@@ -20,4 +20,4 @@
20
20
  "devDependencies": {
21
21
  "@shakerquiz/utilities": "0.5.178"
22
22
  }
23
- }
23
+ }
package/source/index.js DELETED
@@ -1,83 +0,0 @@
1
- import POST_checkin_Unknown from'./contracts/POST/checkin/Unknown.json' with { type: 'json' }
2
- import POST_city_admin from'./contracts/POST/city/admin.json' with { type: 'json' }
3
- import POST_game_admin from'./contracts/POST/game/admin.json' with { type: 'json' }
4
- import POST_game_organizer from'./contracts/POST/game/organizer.json' with { type: 'json' }
5
- import POST_game_registrations_export_admin from'./contracts/POST/game/registrations/export/admin.json' with { type: 'json' }
6
- import POST_game_registrations_export_organizer from'./contracts/POST/game/registrations/export/organizer.json' with { type: 'json' }
7
- import POST_registration_Unknown from'./contracts/POST/registration/Unknown.json' with { type: 'json' }
8
- import POST_registration_mailing_admin from'./contracts/POST/registration/mailing/admin.json' with { type: 'json' }
9
- import POST_registration_mailing_organizer from'./contracts/POST/registration/mailing/organizer.json' with { type: 'json' }
10
- import POST_registrations_export_admin from'./contracts/POST/registrations/export/admin.json' with { type: 'json' }
11
- import POST_registrations_export_organizer from'./contracts/POST/registrations/export/organizer.json' with { type: 'json' }
12
- import POST_theme_admin from'./contracts/POST/theme/admin.json' with { type: 'json' }
13
- import POST_user_admin from'./contracts/POST/user/admin.json' with { type: 'json' }
14
- import POST_user_cities_admin from'./contracts/POST/user/cities/admin.json' with { type: 'json' }
15
- import POST_user_password_admin from'./contracts/POST/user/password/admin.json' with { type: 'json' }
16
- import POST_user_role_admin from'./contracts/POST/user/role/admin.json' with { type: 'json' }
17
- import POST_venue_admin from'./contracts/POST/venue/admin.json' with { type: 'json' }
18
- import POST_venue_organizer from'./contracts/POST/venue/organizer.json' with { type: 'json' }
19
- import PATCH_city_admin from'./contracts/PATCH/city/admin.json' with { type: 'json' }
20
- import PATCH_city_currency_admin from'./contracts/PATCH/city/currency/admin.json' with { type: 'json' }
21
- import PATCH_city_timezone_admin from'./contracts/PATCH/city/timezone/admin.json' with { type: 'json' }
22
- import PATCH_game_admin from'./contracts/PATCH/game/admin.json' with { type: 'json' }
23
- import PATCH_game_organizer from'./contracts/PATCH/game/organizer.json' with { type: 'json' }
24
- import PATCH_games_admin from'./contracts/PATCH/games/admin.json' with { type: 'json' }
25
- import PATCH_games_organizer from'./contracts/PATCH/games/organizer.json' with { type: 'json' }
26
- import PATCH_registration_admin from'./contracts/PATCH/registration/admin.json' with { type: 'json' }
27
- import PATCH_registration_organizer from'./contracts/PATCH/registration/organizer.json' with { type: 'json' }
28
- import PATCH_registration_Unknown from'./contracts/PATCH/registration/Unknown.json' with { type: 'json' }
29
- import PATCH_registration_cancellation_Unknown from'./contracts/PATCH/registration/cancellation/Unknown.json' with { type: 'json' }
30
- import PATCH_registration_channel_Unknown from'./contracts/PATCH/registration/channel/Unknown.json' with { type: 'json' }
31
- import PATCH_registration_confirmation_Unknown from'./contracts/PATCH/registration/confirmation/Unknown.json' with { type: 'json' }
32
- import PATCH_theme_admin from'./contracts/PATCH/theme/admin.json' with { type: 'json' }
33
- import PATCH_user_admin from'./contracts/PATCH/user/admin.json' with { type: 'json' }
34
- import PATCH_user_cities_admin from'./contracts/PATCH/user/cities/admin.json' with { type: 'json' }
35
- import PATCH_user_password_admin from'./contracts/PATCH/user/password/admin.json' with { type: 'json' }
36
- import PATCH_user_role_admin from'./contracts/PATCH/user/role/admin.json' with { type: 'json' }
37
- import PATCH_users_cities_admin from'./contracts/PATCH/users/cities/admin.json' with { type: 'json' }
38
- import PATCH_users_role_admin from'./contracts/PATCH/users/role/admin.json' with { type: 'json' }
39
- import PATCH_venue_admin from'./contracts/PATCH/venue/admin.json' with { type: 'json' }
40
- import PATCH_venue_organizer from'./contracts/PATCH/venue/organizer.json' with { type: 'json' }
41
-
42
- export const Schema = Object.freeze({
43
- 'POST/checkin/Unknown': POST_checkin_Unknown,
44
- 'POST/city/admin': POST_city_admin,
45
- 'POST/game/admin': POST_game_admin,
46
- 'POST/game/organizer': POST_game_organizer,
47
- 'POST/game/registrations/export/admin': POST_game_registrations_export_admin,
48
- 'POST/game/registrations/export/organizer': POST_game_registrations_export_organizer,
49
- 'POST/registration/Unknown': POST_registration_Unknown,
50
- 'POST/registration/mailing/admin': POST_registration_mailing_admin,
51
- 'POST/registration/mailing/organizer': POST_registration_mailing_organizer,
52
- 'POST/registrations/export/admin': POST_registrations_export_admin,
53
- 'POST/registrations/export/organizer': POST_registrations_export_organizer,
54
- 'POST/theme/admin': POST_theme_admin,
55
- 'POST/user/admin': POST_user_admin,
56
- 'POST/user/cities/admin': POST_user_cities_admin,
57
- 'POST/user/password/admin': POST_user_password_admin,
58
- 'POST/user/role/admin': POST_user_role_admin,
59
- 'POST/venue/admin': POST_venue_admin,
60
- 'POST/venue/organizer': POST_venue_organizer,
61
- 'PATCH/city/admin': PATCH_city_admin,
62
- 'PATCH/city/currency/admin': PATCH_city_currency_admin,
63
- 'PATCH/city/timezone/admin': PATCH_city_timezone_admin,
64
- 'PATCH/game/admin': PATCH_game_admin,
65
- 'PATCH/game/organizer': PATCH_game_organizer,
66
- 'PATCH/games/admin': PATCH_games_admin,
67
- 'PATCH/games/organizer': PATCH_games_organizer,
68
- 'PATCH/registration/admin': PATCH_registration_admin,
69
- 'PATCH/registration/organizer': PATCH_registration_organizer,
70
- 'PATCH/registration/Unknown': PATCH_registration_Unknown,
71
- 'PATCH/registration/cancellation/Unknown': PATCH_registration_cancellation_Unknown,
72
- 'PATCH/registration/channel/Unknown': PATCH_registration_channel_Unknown,
73
- 'PATCH/registration/confirmation/Unknown': PATCH_registration_confirmation_Unknown,
74
- 'PATCH/theme/admin': PATCH_theme_admin,
75
- 'PATCH/user/admin': PATCH_user_admin,
76
- 'PATCH/user/cities/admin': PATCH_user_cities_admin,
77
- 'PATCH/user/password/admin': PATCH_user_password_admin,
78
- 'PATCH/user/role/admin': PATCH_user_role_admin,
79
- 'PATCH/users/cities/admin': PATCH_users_cities_admin,
80
- 'PATCH/users/role/admin': PATCH_users_role_admin,
81
- 'PATCH/venue/admin': PATCH_venue_admin,
82
- 'PATCH/venue/organizer': PATCH_venue_organizer,
83
- })