@shakerquiz/utilities 4.0.0 → 4.0.2
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/.github/workflows/publish.yml +4 -3
- package/dprint.json +0 -3
- package/jsconfig.json +5 -8
- package/package.json +6 -2
- package/scripts/codegen.js +104 -0
- package/scripts/template.js +55 -0
- package/source/codegen/autogenerated.js +782 -0
- package/source/entities/key.js +6 -4
- package/source/entities/pattern.js +3 -3
- package/source/entities/{route.js → routes.js} +1 -7
- package/source/entities/runtimes.js +14 -0
- package/source/entities/segment.js +36 -4
- package/source/entities/service-runtime.js +2 -2
- package/source/entities/services.js +28 -0
- package/source/helpers/access.js +11 -13
- package/source/helpers/route-pathname.js +50 -0
- package/source/helpers/tag.js +55 -29
- package/source/index.js +5 -9
- package/scripts/route-cardinality.js +0 -23
- package/scripts/route-parameter.js +0 -29
- package/scripts/route-pathname.js +0 -37
- package/scripts/route-relation.js +0 -26
- package/scripts/route-service.js +0 -25
- package/scripts/templates/route-cardinality.js +0 -5
- package/scripts/templates/route-parameter.js +0 -5
- package/scripts/templates/route-pathname.js +0 -7
- package/scripts/templates/route-relation.js +0 -5
- package/scripts/templates/route-service.js +0 -7
- package/source/entities/route-cardinality.js +0 -149
- package/source/entities/route-parameter.js +0 -149
- package/source/entities/route-pathname.js +0 -223
- package/source/entities/route-relation.js +0 -149
- package/source/entities/route-service.js +0 -179
- package/source/entities/runtime.js +0 -6
- package/source/entities/service.js +0 -22
- package/source/helpers/hydrate-route-pathname.js +0 -29
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
name: Publish
|
|
1
|
+
name: Publish aquamarine
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
pull_request:
|
|
5
5
|
types: [ closed ]
|
|
6
6
|
branches:
|
|
7
|
-
-
|
|
7
|
+
- aquamarine
|
|
8
8
|
|
|
9
9
|
permissions:
|
|
10
10
|
id-token: write
|
|
@@ -27,5 +27,6 @@ jobs:
|
|
|
27
27
|
- run: git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
28
28
|
- run: npm version patch
|
|
29
29
|
- run: npm ci
|
|
30
|
-
- run: npm publish
|
|
30
|
+
- run: npm publish --tag aquamarine
|
|
31
|
+
- run: git commit -am "Commit autogenerated output" || true
|
|
31
32
|
- run: git push --follow-tags
|
package/dprint.json
CHANGED
package/jsconfig.json
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"baseUrl": ".",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
6
7
|
"allowJs": true,
|
|
7
|
-
"
|
|
8
|
-
"declaration": true,
|
|
8
|
+
"checkJs": true,
|
|
9
9
|
"paths": {
|
|
10
10
|
"source/": [
|
|
11
11
|
"./source/*"
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
|
-
}
|
|
15
|
-
"include": [
|
|
16
|
-
"source/**/*"
|
|
17
|
-
]
|
|
14
|
+
}
|
|
18
15
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@shakerquiz/utilities",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"author": "yurkimus <yurkimus@gmail.com>",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"repository": {
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"default": "./source/index.js"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"prepublishOnly": "bun
|
|
15
|
+
"prepublishOnly": "bun scripts/codegen.js && dprint fmt --includes-override source/codegen/autogenerated.js"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/bun": "1.3.6",
|
|
19
|
+
"dprint": "0.51.1"
|
|
16
20
|
}
|
|
17
21
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import template from './template.js' with { type: 'text' }
|
|
2
|
+
|
|
3
|
+
import { Routes } from '../source/entities/routes.js'
|
|
4
|
+
import { Segment, Segments } from '../source/entities/segment.js'
|
|
5
|
+
|
|
6
|
+
let pathname = route =>
|
|
7
|
+
route
|
|
8
|
+
.split('/')
|
|
9
|
+
.map(x => {
|
|
10
|
+
if (!Segment[x].pattern)
|
|
11
|
+
return x
|
|
12
|
+
else if (Segment[x].cardinality === '1')
|
|
13
|
+
return `${x}/:${x}`
|
|
14
|
+
else
|
|
15
|
+
return x
|
|
16
|
+
})
|
|
17
|
+
.join('/')
|
|
18
|
+
|
|
19
|
+
let parameters = pathname =>
|
|
20
|
+
pathname
|
|
21
|
+
.split('/')
|
|
22
|
+
.filter(x => x.includes(':'))
|
|
23
|
+
|
|
24
|
+
let breakdown = route =>
|
|
25
|
+
route
|
|
26
|
+
.split('/')
|
|
27
|
+
.map((x, i) => {
|
|
28
|
+
if (i > 0)
|
|
29
|
+
return x
|
|
30
|
+
else if (Segment[x].cardinality === '1')
|
|
31
|
+
return x
|
|
32
|
+
else
|
|
33
|
+
return Segment[x].relation
|
|
34
|
+
})
|
|
35
|
+
.join('/')
|
|
36
|
+
|
|
37
|
+
let service = route =>
|
|
38
|
+
route
|
|
39
|
+
.split('/')
|
|
40
|
+
.slice(0, 1)
|
|
41
|
+
.map(x => Segment[x].service)
|
|
42
|
+
.at(0)
|
|
43
|
+
|
|
44
|
+
let Route = Routes
|
|
45
|
+
.map(x => `'${x}': '${x}'`)
|
|
46
|
+
.join(',\n ')
|
|
47
|
+
|
|
48
|
+
let RouteCardinality = Routes
|
|
49
|
+
.map(route => [
|
|
50
|
+
route,
|
|
51
|
+
route.split('/').map(a => Segment[a].cardinality),
|
|
52
|
+
])
|
|
53
|
+
.map(([route, cardinalities]) => [
|
|
54
|
+
route,
|
|
55
|
+
cardinalities.length > 1
|
|
56
|
+
? cardinalities.at(0) + '/' + cardinalities.at(-1)
|
|
57
|
+
: cardinalities.at(0),
|
|
58
|
+
])
|
|
59
|
+
.map(([route, cardinality]) => `'${route}': '${cardinality}'`)
|
|
60
|
+
.join(',\n ')
|
|
61
|
+
|
|
62
|
+
let RoutePathname = Routes
|
|
63
|
+
.map(x => `'${x}': '${pathname(x)}'`)
|
|
64
|
+
.join(',\n ')
|
|
65
|
+
|
|
66
|
+
let PathnameRoute = Routes
|
|
67
|
+
.map(x => `'${pathname(x)}': '${x}'`)
|
|
68
|
+
.join(',\n ')
|
|
69
|
+
|
|
70
|
+
let PathnameParameters = Routes
|
|
71
|
+
.map(x => `'${pathname(x)}': ${JSON.stringify(parameters(pathname(x)), null, 2)}`)
|
|
72
|
+
.join(',\n ')
|
|
73
|
+
|
|
74
|
+
let ParameterPattern = Segments
|
|
75
|
+
.filter(x => x.pattern)
|
|
76
|
+
.map(x => `':${x.key}': '${x.pattern}'`)
|
|
77
|
+
.join(',\n ')
|
|
78
|
+
|
|
79
|
+
let RouteBreakdown = Routes
|
|
80
|
+
.map(x => `'${x}': '${breakdown(x)}'`)
|
|
81
|
+
.join(',\n ')
|
|
82
|
+
|
|
83
|
+
let RouteService = Routes
|
|
84
|
+
.map(x => `'${x}': '${service(x)}'`)
|
|
85
|
+
.join(',\n ')
|
|
86
|
+
|
|
87
|
+
let ServiceRoutes = Object
|
|
88
|
+
.entries(Object.groupBy(Routes, service))
|
|
89
|
+
.map(([service, routes]) => `'${service}': ${JSON.stringify(routes, null, 2)}`)
|
|
90
|
+
.join(',\n ')
|
|
91
|
+
|
|
92
|
+
Bun.write(
|
|
93
|
+
'./source/codegen/autogenerated.js',
|
|
94
|
+
template
|
|
95
|
+
.replace('/* route */', Route)
|
|
96
|
+
.replace('/* route -> cardinality */', RouteCardinality)
|
|
97
|
+
.replace('/* route -> pathname */', RoutePathname)
|
|
98
|
+
.replace('/* pathname -> route */', PathnameRoute)
|
|
99
|
+
.replace('/* pathname -> parameters */', PathnameParameters)
|
|
100
|
+
.replace('/* parameter -> pattern */', ParameterPattern)
|
|
101
|
+
.replace('/* route -> breakdown */', RouteBreakdown)
|
|
102
|
+
.replace('/* route -> service */', RouteService)
|
|
103
|
+
.replace('/* service -> routes */', ServiceRoutes),
|
|
104
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* --- Autogenerated --- */
|
|
2
|
+
|
|
3
|
+
export const Route = Object.freeze(
|
|
4
|
+
/** @type {const} */ ({
|
|
5
|
+
/* route */
|
|
6
|
+
}),
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
export const RouteCardinality = Object.freeze(
|
|
10
|
+
/** @type {const} */ ({
|
|
11
|
+
/* route -> cardinality */
|
|
12
|
+
}),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export const RoutePathname = Object.freeze(
|
|
16
|
+
/** @type {const} */ ({
|
|
17
|
+
/* route -> pathname */
|
|
18
|
+
}),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
export const PathnameRoute = Object.freeze(
|
|
22
|
+
/** @type {const} */ ({
|
|
23
|
+
/* pathname -> route */
|
|
24
|
+
}),
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export const PathnameParameters = Object.freeze(
|
|
28
|
+
/** @type {const} */ ({
|
|
29
|
+
/* pathname -> parameters */
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export const ParameterPattern = Object.freeze(
|
|
34
|
+
/** @type {const} */ ({
|
|
35
|
+
/* parameter -> pattern */
|
|
36
|
+
}),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export const RouteBreakdown = Object.freeze(
|
|
40
|
+
/** @type {const} */ ({
|
|
41
|
+
/* route -> breakdown */
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
export const RouteService = Object.freeze(
|
|
46
|
+
/** @type {const} */ ({
|
|
47
|
+
/* route -> service */
|
|
48
|
+
}),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
export const ServiceRoutes = Object.freeze(
|
|
52
|
+
/** @type {const} */ ({
|
|
53
|
+
/* service -> routes */
|
|
54
|
+
}),
|
|
55
|
+
)
|