@vertikalx/vtx-backend-client 1.0.0-dev.2 → 1.0.0-dev.21
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/package.json +3 -2
- package/src/api/api-call-headers.d.ts +16 -0
- package/src/api/api-call-headers.js +20 -0
- package/src/api/api-call-headers.js.map +1 -0
- package/src/api/backend-response.d.ts +4 -0
- package/src/api/backend-response.js +3 -0
- package/src/api/backend-response.js.map +1 -0
- package/src/api/response-builder.d.ts +4 -0
- package/src/api/response-builder.js +63 -0
- package/src/api/response-builder.js.map +1 -0
- package/src/api/vtx-apikey-api.d.ts +6 -0
- package/src/api/vtx-apikey-api.js +19 -0
- package/src/api/vtx-apikey-api.js.map +1 -0
- package/src/api/vtx-base-api.d.ts +23 -0
- package/src/api/vtx-base-api.js +752 -0
- package/src/api/vtx-base-api.js.map +1 -0
- package/src/api/vtx-mobile-api.d.ts +6 -0
- package/src/api/vtx-mobile-api.js +27 -0
- package/src/api/vtx-mobile-api.js.map +1 -0
- package/src/api/vtx-web-browser-api.d.ts +7 -0
- package/src/api/vtx-web-browser-api.js +36 -0
- package/src/api/vtx-web-browser-api.js.map +1 -0
- package/src/api/vtx-web-server-api.d.ts +7 -0
- package/src/api/vtx-web-server-api.js +33 -0
- package/src/api/vtx-web-server-api.js.map +1 -0
- package/src/client/index.js.map +1 -0
- package/src/client/runtime/batcher.js.map +1 -0
- package/{runtime → src/client/runtime}/createClient.d.ts +4 -10
- package/src/client/runtime/createClient.js.map +1 -0
- package/src/client/runtime/error.js.map +1 -0
- package/src/client/runtime/fetcher.js.map +1 -0
- package/{runtime → src/client/runtime}/generateGraphqlOperation.d.ts +1 -1
- package/src/client/runtime/generateGraphqlOperation.js.map +1 -0
- package/src/client/runtime/index.js.map +1 -0
- package/src/client/runtime/linkTypeMap.js.map +1 -0
- package/src/client/runtime/typeSelection.js.map +1 -0
- package/src/client/runtime/types.js.map +1 -0
- package/src/client/schema.d.ts +985 -0
- package/src/client/schema.graphql +433 -0
- package/src/client/schema.js +235 -0
- package/src/client/schema.js.map +1 -0
- package/src/client/types.d.ts +499 -0
- package/src/client/types.js +1292 -0
- package/src/client/types.js.map +1 -0
- package/src/index.d.ts +9 -0
- package/src/index.js +26 -0
- package/src/index.js.map +1 -0
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/index.js.map +0 -1
- package/index.ts +0 -65
- package/runtime/batcher.js.map +0 -1
- package/runtime/batcher.ts +0 -275
- package/runtime/createClient.js.map +0 -1
- package/runtime/createClient.ts +0 -68
- package/runtime/error.js.map +0 -1
- package/runtime/error.ts +0 -29
- package/runtime/fetcher.js.map +0 -1
- package/runtime/fetcher.ts +0 -97
- package/runtime/generateGraphqlOperation.js.map +0 -1
- package/runtime/generateGraphqlOperation.ts +0 -225
- package/runtime/index.js.map +0 -1
- package/runtime/index.ts +0 -13
- package/runtime/linkTypeMap.js.map +0 -1
- package/runtime/linkTypeMap.ts +0 -156
- package/runtime/typeSelection.js.map +0 -1
- package/runtime/typeSelection.ts +0 -95
- package/runtime/types.js.map +0 -1
- package/runtime/types.ts +0 -69
- package/schema.d.ts +0 -406
- package/schema.graphql +0 -162
- package/schema.js +0 -109
- package/schema.js.map +0 -1
- package/schema.ts +0 -420
- package/types.d.ts +0 -207
- package/types.js +0 -518
- package/types.js.map +0 -1
- package/types.ts +0 -515
- /package/{index.d.ts → src/client/index.d.ts} +0 -0
- /package/{index.js → src/client/index.js} +0 -0
- /package/{runtime → src/client/runtime}/batcher.d.ts +0 -0
- /package/{runtime → src/client/runtime}/batcher.js +0 -0
- /package/{runtime → src/client/runtime}/createClient.js +0 -0
- /package/{runtime → src/client/runtime}/error.d.ts +0 -0
- /package/{runtime → src/client/runtime}/error.js +0 -0
- /package/{runtime → src/client/runtime}/fetcher.d.ts +0 -0
- /package/{runtime → src/client/runtime}/fetcher.js +0 -0
- /package/{runtime → src/client/runtime}/generateGraphqlOperation.js +0 -0
- /package/{runtime → src/client/runtime}/index.d.ts +0 -0
- /package/{runtime → src/client/runtime}/index.js +0 -0
- /package/{runtime → src/client/runtime}/linkTypeMap.d.ts +0 -0
- /package/{runtime → src/client/runtime}/linkTypeMap.js +0 -0
- /package/{runtime → src/client/runtime}/typeSelection.d.ts +0 -0
- /package/{runtime → src/client/runtime}/typeSelection.js +0 -0
- /package/{runtime → src/client/runtime}/types.d.ts +0 -0
- /package/{runtime → src/client/runtime}/types.js +0 -0
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import type { LinkedField, LinkedType } from './types'
|
|
3
|
-
|
|
4
|
-
export interface Args {
|
|
5
|
-
[arg: string]: any | undefined
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface Fields {
|
|
9
|
-
[field: string]: Request
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type Request = boolean | number | Fields
|
|
13
|
-
|
|
14
|
-
export interface Variables {
|
|
15
|
-
[name: string]: {
|
|
16
|
-
value: any
|
|
17
|
-
typing: [LinkedType, string]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface Context {
|
|
22
|
-
root: LinkedType
|
|
23
|
-
varCounter: number
|
|
24
|
-
variables: Variables
|
|
25
|
-
fragmentCounter: number
|
|
26
|
-
fragments: string[]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface GraphqlOperation {
|
|
30
|
-
query: string
|
|
31
|
-
variables?: { [name: string]: any }
|
|
32
|
-
operationName?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const parseRequest = (
|
|
36
|
-
request: Request | undefined,
|
|
37
|
-
ctx: Context,
|
|
38
|
-
path: string[],
|
|
39
|
-
): string => {
|
|
40
|
-
if (typeof request === 'object' && '__args' in request) {
|
|
41
|
-
const args: any = request.__args
|
|
42
|
-
let fields: Request | undefined = { ...request }
|
|
43
|
-
delete fields.__args
|
|
44
|
-
const argNames = Object.keys(args)
|
|
45
|
-
|
|
46
|
-
if (argNames.length === 0) {
|
|
47
|
-
return parseRequest(fields, ctx, path)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const field = getFieldFromPath(ctx.root, path)
|
|
51
|
-
|
|
52
|
-
const argStrings = argNames.map((argName) => {
|
|
53
|
-
ctx.varCounter++
|
|
54
|
-
const varName = `v${ctx.varCounter}`
|
|
55
|
-
|
|
56
|
-
const typing = field.args && field.args[argName] // typeMap used here, .args
|
|
57
|
-
|
|
58
|
-
if (!typing) {
|
|
59
|
-
throw new Error(
|
|
60
|
-
`no typing defined for argument \`${argName}\` in path \`${path.join(
|
|
61
|
-
'.',
|
|
62
|
-
)}\``,
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
ctx.variables[varName] = {
|
|
67
|
-
value: args[argName],
|
|
68
|
-
typing,
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return `${argName}:$${varName}`
|
|
72
|
-
})
|
|
73
|
-
return `(${argStrings})${parseRequest(fields, ctx, path)}`
|
|
74
|
-
} else if (typeof request === 'object' && Object.keys(request).length > 0) {
|
|
75
|
-
const fields = request
|
|
76
|
-
const fieldNames = Object.keys(fields).filter((k) => Boolean(fields[k]))
|
|
77
|
-
|
|
78
|
-
if (fieldNames.length === 0) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`field selection should not be empty: ${path.join('.')}`,
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const type =
|
|
85
|
-
path.length > 0 ? getFieldFromPath(ctx.root, path).type : ctx.root
|
|
86
|
-
const scalarFields = type.scalar
|
|
87
|
-
|
|
88
|
-
let scalarFieldsFragment: string | undefined
|
|
89
|
-
|
|
90
|
-
if (fieldNames.includes('__scalar')) {
|
|
91
|
-
const falsyFieldNames = new Set(
|
|
92
|
-
Object.keys(fields).filter((k) => !Boolean(fields[k])),
|
|
93
|
-
)
|
|
94
|
-
if (scalarFields?.length) {
|
|
95
|
-
ctx.fragmentCounter++
|
|
96
|
-
scalarFieldsFragment = `f${ctx.fragmentCounter}`
|
|
97
|
-
|
|
98
|
-
ctx.fragments.push(
|
|
99
|
-
`fragment ${scalarFieldsFragment} on ${
|
|
100
|
-
type.name
|
|
101
|
-
}{${scalarFields
|
|
102
|
-
.filter((f) => !falsyFieldNames.has(f))
|
|
103
|
-
.join(',')}}`,
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const fieldsSelection = fieldNames
|
|
109
|
-
.filter((f) => !['__scalar', '__name'].includes(f))
|
|
110
|
-
.map((f) => {
|
|
111
|
-
const parsed = parseRequest(fields[f], ctx, [...path, f])
|
|
112
|
-
|
|
113
|
-
if (f.startsWith('on_')) {
|
|
114
|
-
ctx.fragmentCounter++
|
|
115
|
-
const implementationFragment = `f${ctx.fragmentCounter}`
|
|
116
|
-
|
|
117
|
-
const typeMatch = f.match(/^on_(.+)/)
|
|
118
|
-
|
|
119
|
-
if (!typeMatch || !typeMatch[1])
|
|
120
|
-
throw new Error('match failed')
|
|
121
|
-
|
|
122
|
-
ctx.fragments.push(
|
|
123
|
-
`fragment ${implementationFragment} on ${typeMatch[1]}${parsed}`,
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
return `...${implementationFragment}`
|
|
127
|
-
} else {
|
|
128
|
-
return `${f}${parsed}`
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
.concat(scalarFieldsFragment ? [`...${scalarFieldsFragment}`] : [])
|
|
132
|
-
.join(',')
|
|
133
|
-
|
|
134
|
-
return `{${fieldsSelection}}`
|
|
135
|
-
} else {
|
|
136
|
-
return ''
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export const generateGraphqlOperation = (
|
|
141
|
-
operation: 'query' | 'mutation' | 'subscription',
|
|
142
|
-
root: LinkedType,
|
|
143
|
-
fields?: Fields,
|
|
144
|
-
): GraphqlOperation => {
|
|
145
|
-
const ctx: Context = {
|
|
146
|
-
root: root,
|
|
147
|
-
varCounter: 0,
|
|
148
|
-
variables: {},
|
|
149
|
-
fragmentCounter: 0,
|
|
150
|
-
fragments: [],
|
|
151
|
-
}
|
|
152
|
-
const result = parseRequest(fields, ctx, [])
|
|
153
|
-
|
|
154
|
-
const varNames = Object.keys(ctx.variables)
|
|
155
|
-
|
|
156
|
-
const varsString =
|
|
157
|
-
varNames.length > 0
|
|
158
|
-
? `(${varNames.map((v) => {
|
|
159
|
-
const variableType = ctx.variables[v].typing[1]
|
|
160
|
-
return `$${v}:${variableType}`
|
|
161
|
-
})})`
|
|
162
|
-
: ''
|
|
163
|
-
|
|
164
|
-
const operationName = fields?.__name || ''
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
query: [
|
|
168
|
-
`${operation} ${operationName}${varsString}${result}`,
|
|
169
|
-
...ctx.fragments,
|
|
170
|
-
].join(','),
|
|
171
|
-
variables: Object.keys(ctx.variables).reduce<{ [name: string]: any }>(
|
|
172
|
-
(r, v) => {
|
|
173
|
-
r[v] = ctx.variables[v].value
|
|
174
|
-
return r
|
|
175
|
-
},
|
|
176
|
-
{},
|
|
177
|
-
),
|
|
178
|
-
...(operationName ? { operationName: operationName.toString() } : {}),
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export const getFieldFromPath = (
|
|
183
|
-
root: LinkedType | undefined,
|
|
184
|
-
path: string[],
|
|
185
|
-
) => {
|
|
186
|
-
let current: LinkedField | undefined
|
|
187
|
-
|
|
188
|
-
if (!root) throw new Error('root type is not provided')
|
|
189
|
-
|
|
190
|
-
if (path.length === 0) throw new Error(`path is empty`)
|
|
191
|
-
|
|
192
|
-
path.forEach((f) => {
|
|
193
|
-
const type = current ? current.type : root
|
|
194
|
-
|
|
195
|
-
if (!type.fields)
|
|
196
|
-
throw new Error(`type \`${type.name}\` does not have fields`)
|
|
197
|
-
|
|
198
|
-
const possibleTypes = Object.keys(type.fields)
|
|
199
|
-
.filter((i) => i.startsWith('on_'))
|
|
200
|
-
.reduce(
|
|
201
|
-
(types, fieldName) => {
|
|
202
|
-
const field = type.fields && type.fields[fieldName]
|
|
203
|
-
if (field) types.push(field.type)
|
|
204
|
-
return types
|
|
205
|
-
},
|
|
206
|
-
[type],
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
let field: LinkedField | null = null
|
|
210
|
-
|
|
211
|
-
possibleTypes.forEach((type) => {
|
|
212
|
-
const found = type.fields && type.fields[f]
|
|
213
|
-
if (found) field = found
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
if (!field)
|
|
217
|
-
throw new Error(
|
|
218
|
-
`type \`${type.name}\` does not have a field \`${f}\``,
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
current = field
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
return current as LinkedField
|
|
225
|
-
}
|
package/runtime/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/vtx-backend-client/runtime/index.ts"],"names":[],"mappings":";;;AACA,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AAGrB,uEAAqE;AAA5D,oIAAA,wBAAwB,OAAA;AAEjC,6CAA2C;AAAlC,0GAAA,WAAW,OAAA;AAEpB,qCAAyC;AAAhC,wGAAA,aAAa,OAAA;AACtB,iCAAoC;AAA3B,mGAAA,UAAU,OAAA;AACN,QAAA,UAAU,GAAG;IACtB,QAAQ,EAAE,IAAI;CACjB,CAAA"}
|
package/runtime/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
export { createClient } from './createClient'
|
|
3
|
-
export type { ClientOptions } from './createClient'
|
|
4
|
-
export type { FieldsSelection } from './typeSelection'
|
|
5
|
-
export { generateGraphqlOperation } from './generateGraphqlOperation'
|
|
6
|
-
export type { GraphqlOperation } from './generateGraphqlOperation'
|
|
7
|
-
export { linkTypeMap } from './linkTypeMap'
|
|
8
|
-
// export { Observable } from 'zen-observable-ts'
|
|
9
|
-
export { createFetcher } from './fetcher'
|
|
10
|
-
export { GenqlError } from './error'
|
|
11
|
-
export const everything = {
|
|
12
|
-
__scalar: true,
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linkTypeMap.js","sourceRoot":"","sources":["../../../../libs/vtx-backend-client/runtime/linkTypeMap.ts"],"names":[],"mappings":";;;AAiBO,MAAM,WAAW,GAAG,CACvB,OAAkC,EACrB,EAAE;IACf,MAAM,WAAW,GAA2B,MAAM,CAAC,MAAM,CACrD,EAAE,EACF,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAC5D,CAAA;IAED,IAAI,mBAAmB,GAAG,MAAM,CAAC,MAAM,CACnC,EAAE,EACF,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CACnC,CAAC,CAAC,EAA8B,EAAE;QAC9B,MAAM,IAAI,GAAmB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,CAAA;QAC9C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAA;QACzB,OAAO;YACH,CAAC,CAAC,CAAC,EAAE;gBACD,IAAI,EAAE,CAAC;gBAEP,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;oBACrC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;oBAE9B,MAAM,QAAQ,GACV,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;oBAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACZ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Q,EAAE,CAAC;4BAC/B,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;gCAC3B,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;4BAChD,CAAC;4BAED,GAAG,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAE,CAAA;wBACrC,CAAC;oBACL,CAAC;gBACL,CAAC,CAAC,CAAA;YACN,CAAC;YAED,MAAM,QAAQ,GAAG,KAAK,CAAC,IAA2B,CAAA;YAElD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC3B,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;gBAChD,CAAC;gBAED,KAAK,CAAC,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAE,CAAA;YACzC,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,OAAO,aAAa,CAAA;AACxB,CAAC,CAAA;AA7CY,QAAA,oBAAoB,wBA6ChC"}
|
package/runtime/linkTypeMap.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import type {
|
|
3
|
-
CompressedType,
|
|
4
|
-
CompressedTypeMap,
|
|
5
|
-
LinkedArgMap,
|
|
6
|
-
LinkedField,
|
|
7
|
-
LinkedType,
|
|
8
|
-
LinkedTypeMap,
|
|
9
|
-
} from './types'
|
|
10
|
-
|
|
11
|
-
export interface PartialLinkedFieldMap {
|
|
12
|
-
[field: string]: {
|
|
13
|
-
type: string
|
|
14
|
-
args?: LinkedArgMap
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const linkTypeMap = (
|
|
19
|
-
typeMap: CompressedTypeMap<number>,
|
|
20
|
-
): LinkedTypeMap => {
|
|
21
|
-
const indexToName: Record<number, string> = Object.assign(
|
|
22
|
-
{},
|
|
23
|
-
...Object.keys(typeMap.types).map((k, i) => ({ [i]: k })),
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
let intermediaryTypeMap = Object.assign(
|
|
27
|
-
{},
|
|
28
|
-
...Object.keys(typeMap.types || {}).map(
|
|
29
|
-
(k): Record<string, LinkedType> => {
|
|
30
|
-
const type: CompressedType = typeMap.types[k]!
|
|
31
|
-
const fields = type || {}
|
|
32
|
-
return {
|
|
33
|
-
[k]: {
|
|
34
|
-
name: k,
|
|
35
|
-
// type scalar properties
|
|
36
|
-
scalar: Object.keys(fields).filter((f) => {
|
|
37
|
-
const [type] = fields[f] || []
|
|
38
|
-
|
|
39
|
-
const isScalar =
|
|
40
|
-
type && typeMap.scalars.includes(type)
|
|
41
|
-
if (!isScalar) {
|
|
42
|
-
return false
|
|
43
|
-
}
|
|
44
|
-
const args = fields[f]?.[1]
|
|
45
|
-
const argTypes = Object.values(args || {})
|
|
46
|
-
.map((x) => x?.[1])
|
|
47
|
-
.filter(Boolean)
|
|
48
|
-
|
|
49
|
-
const hasRequiredArgs = argTypes.some(
|
|
50
|
-
(str) => str && str.endsWith('!'),
|
|
51
|
-
)
|
|
52
|
-
if (hasRequiredArgs) {
|
|
53
|
-
return false
|
|
54
|
-
}
|
|
55
|
-
return true
|
|
56
|
-
}),
|
|
57
|
-
// fields with corresponding `type` and `args`
|
|
58
|
-
fields: Object.assign(
|
|
59
|
-
{},
|
|
60
|
-
...Object.keys(fields).map(
|
|
61
|
-
(f): PartialLinkedFieldMap => {
|
|
62
|
-
const [typeIndex, args] = fields[f] || []
|
|
63
|
-
if (typeIndex == null) {
|
|
64
|
-
return {}
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
[f]: {
|
|
68
|
-
// replace index with type name
|
|
69
|
-
type: indexToName[typeIndex],
|
|
70
|
-
args: Object.assign(
|
|
71
|
-
{},
|
|
72
|
-
...Object.keys(args || {}).map(
|
|
73
|
-
(k) => {
|
|
74
|
-
// if argTypeString == argTypeName, argTypeString is missing, need to readd it
|
|
75
|
-
if (!args || !args[k]) {
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
const [
|
|
79
|
-
argTypeName,
|
|
80
|
-
argTypeString,
|
|
81
|
-
] = args[k] as any
|
|
82
|
-
return {
|
|
83
|
-
[k]: [
|
|
84
|
-
indexToName[
|
|
85
|
-
argTypeName
|
|
86
|
-
],
|
|
87
|
-
argTypeString ||
|
|
88
|
-
indexToName[
|
|
89
|
-
argTypeName
|
|
90
|
-
],
|
|
91
|
-
],
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
),
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
),
|
|
100
|
-
),
|
|
101
|
-
},
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
),
|
|
105
|
-
)
|
|
106
|
-
const res = resolveConcreteTypes(intermediaryTypeMap)
|
|
107
|
-
return res
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// replace typename with concrete type
|
|
111
|
-
export const resolveConcreteTypes = (linkedTypeMap: LinkedTypeMap) => {
|
|
112
|
-
Object.keys(linkedTypeMap).forEach((typeNameFromKey) => {
|
|
113
|
-
const type: LinkedType = linkedTypeMap[typeNameFromKey]!
|
|
114
|
-
// type.name = typeNameFromKey
|
|
115
|
-
if (!type.fields) {
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const fields = type.fields
|
|
120
|
-
|
|
121
|
-
Object.keys(fields).forEach((f) => {
|
|
122
|
-
const field: LinkedField = fields[f]!
|
|
123
|
-
|
|
124
|
-
if (field.args) {
|
|
125
|
-
const args = field.args
|
|
126
|
-
Object.keys(args).forEach((key) => {
|
|
127
|
-
const arg = args[key]
|
|
128
|
-
|
|
129
|
-
if (arg) {
|
|
130
|
-
const [typeName] = arg
|
|
131
|
-
|
|
132
|
-
if (typeof typeName === 'string') {
|
|
133
|
-
if (!linkedTypeMap[typeName]) {
|
|
134
|
-
linkedTypeMap[typeName] = { name: typeName }
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
arg[0] = linkedTypeMap[typeName]!
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const typeName = field.type as LinkedType | string
|
|
144
|
-
|
|
145
|
-
if (typeof typeName === 'string') {
|
|
146
|
-
if (!linkedTypeMap[typeName]) {
|
|
147
|
-
linkedTypeMap[typeName] = { name: typeName }
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
field.type = linkedTypeMap[typeName]!
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
return linkedTypeMap
|
|
156
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeSelection.js","sourceRoot":"","sources":["../../../../libs/vtx-backend-client/runtime/typeSelection.ts"],"names":[],"mappings":""}
|
package/runtime/typeSelection.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
//////////////////////////////////////////////////
|
|
3
|
-
|
|
4
|
-
// SOME THINGS TO KNOW BEFORE DIVING IN
|
|
5
|
-
/*
|
|
6
|
-
0. DST is the request type, SRC is the response type
|
|
7
|
-
|
|
8
|
-
1. FieldsSelection uses an object because currently is impossible to make recursive types
|
|
9
|
-
|
|
10
|
-
2. FieldsSelection is a recursive type that makes a type based on request type and fields
|
|
11
|
-
|
|
12
|
-
3. HandleObject handles object types
|
|
13
|
-
|
|
14
|
-
4. Handle__scalar adds all scalar properties excluding non scalar props
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export type FieldsSelection<SRC extends Anify<DST> | undefined, DST> = {
|
|
18
|
-
scalar: SRC
|
|
19
|
-
union: Handle__isUnion<SRC, DST>
|
|
20
|
-
object: HandleObject<SRC, DST>
|
|
21
|
-
array: SRC extends Nil
|
|
22
|
-
? never
|
|
23
|
-
: SRC extends Array<infer T | null>
|
|
24
|
-
? Array<FieldsSelection<T, DST>>
|
|
25
|
-
: never
|
|
26
|
-
__scalar: Handle__scalar<SRC, DST>
|
|
27
|
-
never: never
|
|
28
|
-
}[DST extends Nil
|
|
29
|
-
? 'never'
|
|
30
|
-
: DST extends false | 0
|
|
31
|
-
? 'never'
|
|
32
|
-
: SRC extends Scalar
|
|
33
|
-
? 'scalar'
|
|
34
|
-
: SRC extends any[]
|
|
35
|
-
? 'array'
|
|
36
|
-
: SRC extends { __isUnion?: any }
|
|
37
|
-
? 'union'
|
|
38
|
-
: DST extends { __scalar?: any }
|
|
39
|
-
? '__scalar'
|
|
40
|
-
: DST extends {}
|
|
41
|
-
? 'object'
|
|
42
|
-
: 'never']
|
|
43
|
-
|
|
44
|
-
type HandleObject<SRC extends Anify<DST>, DST> = DST extends boolean
|
|
45
|
-
? SRC
|
|
46
|
-
: SRC extends Nil
|
|
47
|
-
? never
|
|
48
|
-
: Pick<
|
|
49
|
-
{
|
|
50
|
-
// using keyof SRC to maintain ?: relations of SRC type
|
|
51
|
-
[Key in keyof SRC]: Key extends keyof DST
|
|
52
|
-
? FieldsSelection<SRC[Key], NonNullable<DST[Key]>>
|
|
53
|
-
: SRC[Key]
|
|
54
|
-
},
|
|
55
|
-
Exclude<keyof DST, FieldsToRemove>
|
|
56
|
-
// {
|
|
57
|
-
// // remove falsy values
|
|
58
|
-
// [Key in keyof DST]: DST[Key] extends false | 0 ? never : Key
|
|
59
|
-
// }[keyof DST]
|
|
60
|
-
>
|
|
61
|
-
|
|
62
|
-
type Handle__scalar<SRC extends Anify<DST>, DST> = SRC extends Nil
|
|
63
|
-
? never
|
|
64
|
-
: Pick<
|
|
65
|
-
// continue processing fields that are in DST, directly pass SRC type if not in DST
|
|
66
|
-
{
|
|
67
|
-
[Key in keyof SRC]: Key extends keyof DST
|
|
68
|
-
? FieldsSelection<SRC[Key], DST[Key]>
|
|
69
|
-
: SRC[Key]
|
|
70
|
-
},
|
|
71
|
-
// remove fields that are not scalars or are not in DST
|
|
72
|
-
{
|
|
73
|
-
[Key in keyof SRC]: SRC[Key] extends Nil
|
|
74
|
-
? never
|
|
75
|
-
: Key extends FieldsToRemove
|
|
76
|
-
? never
|
|
77
|
-
: SRC[Key] extends Scalar
|
|
78
|
-
? Key
|
|
79
|
-
: Key extends keyof DST
|
|
80
|
-
? Key
|
|
81
|
-
: never
|
|
82
|
-
}[keyof SRC]
|
|
83
|
-
>
|
|
84
|
-
|
|
85
|
-
type Handle__isUnion<SRC extends Anify<DST>, DST> = SRC extends Nil
|
|
86
|
-
? never
|
|
87
|
-
: Omit<SRC, FieldsToRemove> // just return the union type
|
|
88
|
-
|
|
89
|
-
type Scalar = string | number | Date | boolean | null | undefined
|
|
90
|
-
|
|
91
|
-
type Anify<T> = { [P in keyof T]?: any }
|
|
92
|
-
|
|
93
|
-
type FieldsToRemove = '__isUnion' | '__scalar' | '__name' | '__args'
|
|
94
|
-
|
|
95
|
-
type Nil = undefined | null
|
package/runtime/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../libs/vtx-backend-client/runtime/types.ts"],"names":[],"mappings":""}
|
package/runtime/types.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
export interface ExecutionResult<TData = { [key: string]: any }> {
|
|
4
|
-
errors?: Array<Error>
|
|
5
|
-
data?: TData | null
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface ArgMap<keyType = number> {
|
|
9
|
-
[arg: string]: [keyType, string] | [keyType] | undefined
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type CompressedField<keyType = number> = [
|
|
13
|
-
type: keyType,
|
|
14
|
-
args?: ArgMap<keyType>,
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
export interface CompressedFieldMap<keyType = number> {
|
|
18
|
-
[field: string]: CompressedField<keyType> | undefined
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type CompressedType<keyType = number> = CompressedFieldMap<keyType>
|
|
22
|
-
|
|
23
|
-
export interface CompressedTypeMap<keyType = number> {
|
|
24
|
-
scalars: Array<keyType>
|
|
25
|
-
types: {
|
|
26
|
-
[type: string]: CompressedType<keyType> | undefined
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// normal types
|
|
31
|
-
export type Field<keyType = number> = {
|
|
32
|
-
type: keyType
|
|
33
|
-
args?: ArgMap<keyType>
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface FieldMap<keyType = number> {
|
|
37
|
-
[field: string]: Field<keyType> | undefined
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type Type<keyType = number> = FieldMap<keyType>
|
|
41
|
-
|
|
42
|
-
export interface TypeMap<keyType = number> {
|
|
43
|
-
scalars: Array<keyType>
|
|
44
|
-
types: {
|
|
45
|
-
[type: string]: Type<keyType> | undefined
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface LinkedArgMap {
|
|
50
|
-
[arg: string]: [LinkedType, string] | undefined
|
|
51
|
-
}
|
|
52
|
-
export interface LinkedField {
|
|
53
|
-
type: LinkedType
|
|
54
|
-
args?: LinkedArgMap
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface LinkedFieldMap {
|
|
58
|
-
[field: string]: LinkedField | undefined
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface LinkedType {
|
|
62
|
-
name: string
|
|
63
|
-
fields?: LinkedFieldMap
|
|
64
|
-
scalar?: string[]
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface LinkedTypeMap {
|
|
68
|
-
[type: string]: LinkedType | undefined
|
|
69
|
-
}
|