shinkansen-transmission 2.2.210 → 2.2.212
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/eslint.config.mjs +75 -0
- package/index.d.mts +46 -0
- package/package.json +11 -10
- package/src/index.d.mts +0 -43
- package/src/transmission/common/index.d.mts +1 -1
- package/src/transmission/common/index.mjs +56 -56
@@ -0,0 +1,75 @@
|
|
1
|
+
import globals from 'globals'
|
2
|
+
import standard from '@sequencemedia/eslint-config-standard/configs/recommended/merge'
|
3
|
+
import typescript from '@sequencemedia/eslint-config-typescript/configs/recommended/merge'
|
4
|
+
|
5
|
+
export default [
|
6
|
+
/**
|
7
|
+
* Standard config
|
8
|
+
*/
|
9
|
+
standard({
|
10
|
+
files: [
|
11
|
+
'**/*.{mjs,cjs,mts,cts}'
|
12
|
+
],
|
13
|
+
ignores: [
|
14
|
+
'src',
|
15
|
+
'test'
|
16
|
+
],
|
17
|
+
languageOptions: {
|
18
|
+
globals: {
|
19
|
+
...globals.node
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}),
|
23
|
+
standard({
|
24
|
+
files: [
|
25
|
+
'src/**/*.{mjs,cjs,mts,cts}'
|
26
|
+
],
|
27
|
+
languageOptions: {
|
28
|
+
globals: {
|
29
|
+
...globals.browser
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}),
|
33
|
+
standard({
|
34
|
+
files: [
|
35
|
+
'test/**/*.{mjs,cjs,mts,cts}'
|
36
|
+
],
|
37
|
+
languageOptions: {
|
38
|
+
globals: {
|
39
|
+
...globals.mocha
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}),
|
43
|
+
/**
|
44
|
+
* TypeScript config
|
45
|
+
*/
|
46
|
+
typescript({
|
47
|
+
files: [
|
48
|
+
'**/*.{mts,cts}'
|
49
|
+
],
|
50
|
+
ignores: [
|
51
|
+
'src',
|
52
|
+
'test'
|
53
|
+
],
|
54
|
+
languageOptions: {
|
55
|
+
globals: {
|
56
|
+
...globals.node
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}),
|
60
|
+
typescript({
|
61
|
+
files: [
|
62
|
+
'src/**/*.{mts,cts}',
|
63
|
+
'test/**/*.{mts,cts}'
|
64
|
+
],
|
65
|
+
languageOptions: {
|
66
|
+
globals: {
|
67
|
+
...globals.browser,
|
68
|
+
Zashiki: 'readonly'
|
69
|
+
}
|
70
|
+
},
|
71
|
+
rules: {
|
72
|
+
'@typescript-eslint/max-params': ['error', { max: 5 }]
|
73
|
+
}
|
74
|
+
})
|
75
|
+
]
|
package/index.d.mts
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
declare global {
|
2
|
+
namespace Zashiki {
|
3
|
+
export type ObjectLiteralType = Record<PropertyKey, never>
|
4
|
+
export type ObjectType = Record<PropertyKey, unknown>
|
5
|
+
export type ArrayLiteralType = never[]
|
6
|
+
export type ArrayType = unknown[]
|
7
|
+
|
8
|
+
export interface SchemaType {
|
9
|
+
type: string
|
10
|
+
title?: string
|
11
|
+
description?: string
|
12
|
+
readOnly?: boolean
|
13
|
+
writeOnly?: boolean
|
14
|
+
const?: unknown
|
15
|
+
default?: unknown
|
16
|
+
enum?: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
17
|
+
anyOf?: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
18
|
+
oneOf?: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
19
|
+
allOf: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
20
|
+
minimum?: number
|
21
|
+
maximum?: number
|
22
|
+
minLength?: number
|
23
|
+
maxLength?: number
|
24
|
+
minItems?: number
|
25
|
+
maxItems?: number
|
26
|
+
hasUniqueItems?: boolean
|
27
|
+
minContains?: number
|
28
|
+
maxContains?: number
|
29
|
+
minProperties?: number
|
30
|
+
maxProperties?: number
|
31
|
+
isExclusiveMin?: boolean
|
32
|
+
isExclusiveMax?: boolean
|
33
|
+
multipleOf?: number
|
34
|
+
}
|
35
|
+
|
36
|
+
export type DocumentType = string | number | boolean | null | ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType | undefined
|
37
|
+
export type HashType = Record<PropertyKey, string> | Record<PropertyKey, never>
|
38
|
+
|
39
|
+
export interface ZashikiType {
|
40
|
+
meta: ObjectType | ObjectLiteralType
|
41
|
+
elements: ObjectType | ObjectLiteralType
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
export {}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shinkansen-transmission",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.212",
|
4
4
|
"description": "Shinkansen Transmission",
|
5
5
|
"keywords": [
|
6
6
|
"Shinkansen",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
],
|
12
12
|
"main": "./src/index.cjs",
|
13
13
|
"type": "module",
|
14
|
-
"types": "./
|
14
|
+
"types": "./index.d.mts",
|
15
15
|
"author": {
|
16
16
|
"name": "Jonathan Perry for Modern Poacher Limited",
|
17
17
|
"email": "modernpoacher@modernpoacher.com",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
},
|
28
28
|
"scripts": {
|
29
29
|
"coverage": "c8 --reporter html npm run test",
|
30
|
-
"lint": "eslint
|
30
|
+
"lint": "eslint",
|
31
31
|
"lint:fix": "npm run lint -- --fix",
|
32
32
|
"nvm": "bash nvm.sh",
|
33
33
|
"prelint": "npm run nvm",
|
@@ -41,19 +41,20 @@
|
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"@babel/core": "^7.26.0",
|
44
|
-
"@babel/eslint-parser": "^7.
|
44
|
+
"@babel/eslint-parser": "^7.26.5",
|
45
45
|
"@babel/preset-env": "^7.26.0",
|
46
46
|
"@babel/register": "^7.25.9",
|
47
|
-
"@
|
48
|
-
"@typescript
|
49
|
-
"
|
47
|
+
"@sequencemedia/eslint-config-standard": "^0.2.10",
|
48
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.15",
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
50
|
+
"@typescript-eslint/parser": "^8.19.1",
|
50
51
|
"c8": "^10.1.3",
|
51
52
|
"chai": "^5.1.2",
|
52
53
|
"core-js": "^3.40.0",
|
53
54
|
"cross-env": "^7.0.3",
|
54
|
-
"eslint": "
|
55
|
-
"eslint-
|
56
|
-
"
|
55
|
+
"eslint": "^9.17.0",
|
56
|
+
"eslint-import-resolver-babel-module": "^5.3.2",
|
57
|
+
"globals": "^15.14.0",
|
57
58
|
"husky": "^9.1.7",
|
58
59
|
"mocha": "^11.0.1",
|
59
60
|
"rimraf": "^6.0.1"
|
package/src/index.d.mts
CHANGED
@@ -1,46 +1,3 @@
|
|
1
|
-
declare namespace Zashiki {
|
2
|
-
export type ObjectLiteralType = Record<PropertyKey, never>
|
3
|
-
export type ObjectType = Record<PropertyKey, unknown>
|
4
|
-
export type ArrayLiteralType = never[]
|
5
|
-
export type ArrayType = unknown[]
|
6
|
-
|
7
|
-
export interface SchemaType {
|
8
|
-
type: string
|
9
|
-
title?: string
|
10
|
-
description?: string
|
11
|
-
readOnly?: boolean
|
12
|
-
writeOnly?: boolean
|
13
|
-
const?: unknown
|
14
|
-
default?: unknown
|
15
|
-
enum?: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
16
|
-
anyOf?: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
17
|
-
oneOf?: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
18
|
-
allOf: ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType
|
19
|
-
minimum?: number
|
20
|
-
maximum?: number
|
21
|
-
minLength?: number
|
22
|
-
maxLength?: number
|
23
|
-
minItems?: number
|
24
|
-
maxItems?: number
|
25
|
-
hasUniqueItems?: boolean
|
26
|
-
minContains?: number
|
27
|
-
maxContains?: number
|
28
|
-
minProperties?: number
|
29
|
-
maxProperties?: number
|
30
|
-
isExclusiveMin?: boolean
|
31
|
-
isExclusiveMax?: boolean
|
32
|
-
multipleOf?: number
|
33
|
-
}
|
34
|
-
|
35
|
-
export type DocumentType = string | number | boolean | null | ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType | ObjectLiteralType | undefined
|
36
|
-
export type HashType = Record<PropertyKey, string> | Record<PropertyKey, never>
|
37
|
-
|
38
|
-
export interface ZashikiType {
|
39
|
-
meta: ObjectType | ObjectLiteralType
|
40
|
-
elements: ObjectType | ObjectLiteralType
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
1
|
declare module '#transmission' {
|
45
2
|
export * as common from '#transmission/transmission/common'
|
46
3
|
export { default as fromDocumentToHash } from '#transmission/transmission/from-document-to-hash'
|
@@ -31,7 +31,7 @@ declare module '#transmission/transmission/common' {
|
|
31
31
|
export function hasMetaValue (values: ObjectType | ObjectLiteralType, uri: string | undefined, schema: SchemaType | undefined): boolean
|
32
32
|
export function getMetaValue (values: ObjectType | ObjectLiteralType, uri: string | undefined, schema: SchemaType | undefined): { value: string } | ObjectLiteralType
|
33
33
|
|
34
|
-
export function transformValue (schema: SchemaType): SchemaType |
|
34
|
+
export function transformValue (schema: SchemaType): SchemaType | ObjectType | ObjectLiteralType | ArrayType | ArrayLiteralType | undefined
|
35
35
|
|
36
36
|
export function findByKey (parentUri: string | undefined, uri: string | undefined): (key: string) => boolean
|
37
37
|
export function findByIndex (parentUri: string | undefined, uri: string | undefined): (schema: SchemaType, index: number) => boolean
|
@@ -51,14 +51,14 @@ export function getSelectedItems (values = {}, uri = '#') {
|
|
51
51
|
return isNaN(n)
|
52
52
|
? [v]
|
53
53
|
: [n]
|
54
|
-
} else {
|
55
|
-
return v.map((v) => {
|
56
|
-
const n = Number(v)
|
57
|
-
return isNaN(n)
|
58
|
-
? v
|
59
|
-
: n
|
60
|
-
})
|
61
54
|
}
|
55
|
+
|
56
|
+
return v.map((v) => {
|
57
|
+
const n = Number(v)
|
58
|
+
return isNaN(n)
|
59
|
+
? v
|
60
|
+
: n
|
61
|
+
})
|
62
62
|
}
|
63
63
|
|
64
64
|
// transformByKeyForEnum
|
@@ -120,12 +120,12 @@ export function hasMetaValue (values = {}, uri = '#', schema = {}) {
|
|
120
120
|
const value = Reflect.get(values, uri)
|
121
121
|
|
122
122
|
return isPrimitive(value)
|
123
|
-
}
|
124
|
-
if (Reflect.has(schema, 'const')) {
|
125
|
-
const constValue = Reflect.get(schema, 'const')
|
123
|
+
}
|
126
124
|
|
127
|
-
|
128
|
-
|
125
|
+
if (Reflect.has(schema, 'const')) {
|
126
|
+
const constValue = Reflect.get(schema, 'const')
|
127
|
+
|
128
|
+
return isPrimitive(constValue)
|
129
129
|
}
|
130
130
|
|
131
131
|
return false
|
@@ -138,13 +138,13 @@ export function getMetaValue (values = {}, uri = '#', schema = {}) {
|
|
138
138
|
if (isPrimitive(value)) {
|
139
139
|
return { value: String(value) }
|
140
140
|
}
|
141
|
-
}
|
142
|
-
|
143
|
-
|
141
|
+
}
|
142
|
+
|
143
|
+
if (Reflect.has(schema, 'const')) {
|
144
|
+
const constValue = Reflect.get(schema, 'const')
|
144
145
|
|
145
|
-
|
146
|
-
|
147
|
-
}
|
146
|
+
if (isPrimitive(constValue)) {
|
147
|
+
return { value: String(constValue) }
|
148
148
|
}
|
149
149
|
}
|
150
150
|
|
@@ -185,18 +185,18 @@ export function findByIndex (parentUri, uri) {
|
|
185
185
|
*/
|
186
186
|
if (hasEnum(schema)) {
|
187
187
|
return getUri(parentUri, index) === uri
|
188
|
-
}
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
188
|
+
}
|
189
|
+
|
190
|
+
if (hasAnyOf(schema)) {
|
191
|
+
const array = getAnyOf(schema)
|
192
|
+
|
193
|
+
return array.find(findByIndex(parentUri, uri))
|
194
|
+
}
|
195
|
+
|
196
|
+
if (hasOneOf(schema)) {
|
197
|
+
const array = getOneOf(schema)
|
198
|
+
|
199
|
+
return array.find(findByIndex(parentUri, uri))
|
200
200
|
}
|
201
201
|
|
202
202
|
return getUri(parentUri, index) === uri
|
@@ -320,12 +320,12 @@ export function hasValue (values = {}, uri = '#', schema = {}) {
|
|
320
320
|
const value = Reflect.get(values, uri)
|
321
321
|
|
322
322
|
return isPrimitive(value)
|
323
|
-
}
|
324
|
-
if (Reflect.has(schema, 'const')) {
|
325
|
-
const constValue = Reflect.get(schema, 'const')
|
323
|
+
}
|
326
324
|
|
327
|
-
|
328
|
-
|
325
|
+
if (Reflect.has(schema, 'const')) {
|
326
|
+
const constValue = Reflect.get(schema, 'const')
|
327
|
+
|
328
|
+
return isPrimitive(constValue)
|
329
329
|
}
|
330
330
|
|
331
331
|
return false
|
@@ -338,13 +338,13 @@ export function getValue (values = {}, uri = '#', schema = {}) {
|
|
338
338
|
if (isPrimitive(value)) {
|
339
339
|
return String(value)
|
340
340
|
}
|
341
|
-
}
|
342
|
-
|
343
|
-
|
341
|
+
}
|
342
|
+
|
343
|
+
if (Reflect.has(schema, 'const')) {
|
344
|
+
const constValue = Reflect.get(schema, 'const')
|
344
345
|
|
345
|
-
|
346
|
-
|
347
|
-
}
|
346
|
+
if (isPrimitive(constValue)) {
|
347
|
+
return String(constValue)
|
348
348
|
}
|
349
349
|
}
|
350
350
|
}
|
@@ -532,21 +532,21 @@ export function getElementsFieldValue (values = {}, uri = '#', schema = {}) {
|
|
532
532
|
if (isPrimitive(value)) {
|
533
533
|
return { value: String(value) }
|
534
534
|
}
|
535
|
-
}
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
}
|
542
|
-
}
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
}
|
535
|
+
}
|
536
|
+
|
537
|
+
if (Reflect.has(schema, 'const')) {
|
538
|
+
const constValue = Reflect.get(schema, 'const')
|
539
|
+
|
540
|
+
if (isPrimitive(constValue)) {
|
541
|
+
return { value: String(constValue) }
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
545
|
+
if (Reflect.has(schema, 'default')) {
|
546
|
+
const defaultValue = Reflect.get(schema, 'default')
|
547
|
+
|
548
|
+
if (isPrimitive(defaultValue)) {
|
549
|
+
return { value: String(defaultValue) }
|
550
550
|
}
|
551
551
|
}
|
552
552
|
|