@nordcraft/core 1.0.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.
- package/README.md +5 -0
- package/dist/api/LegacyToddleApi.d.ts +34 -0
- package/dist/api/LegacyToddleApi.js +178 -0
- package/dist/api/LegacyToddleApi.js.map +1 -0
- package/dist/api/ToddleApiV2.d.ts +77 -0
- package/dist/api/ToddleApiV2.js +271 -0
- package/dist/api/ToddleApiV2.js.map +1 -0
- package/dist/api/api.d.ts +49 -0
- package/dist/api/api.js +276 -0
- package/dist/api/api.js.map +1 -0
- package/dist/api/apiTypes.d.ts +125 -0
- package/dist/api/apiTypes.js +11 -0
- package/dist/api/apiTypes.js.map +1 -0
- package/dist/api/headers.d.ts +10 -0
- package/dist/api/headers.js +36 -0
- package/dist/api/headers.js.map +1 -0
- package/dist/api/template.d.ts +5 -0
- package/dist/api/template.js +7 -0
- package/dist/api/template.js.map +1 -0
- package/dist/component/ToddleComponent.d.ts +45 -0
- package/dist/component/ToddleComponent.js +373 -0
- package/dist/component/ToddleComponent.js.map +1 -0
- package/dist/component/actionUtils.d.ts +2 -0
- package/dist/component/actionUtils.js +56 -0
- package/dist/component/actionUtils.js.map +1 -0
- package/dist/component/component.types.d.ts +313 -0
- package/dist/component/component.types.js +9 -0
- package/dist/component/component.types.js.map +1 -0
- package/dist/component/isPageComponent.d.ts +2 -0
- package/dist/component/isPageComponent.js +3 -0
- package/dist/component/isPageComponent.js.map +1 -0
- package/dist/formula/ToddleFormula.d.ts +15 -0
- package/dist/formula/ToddleFormula.js +20 -0
- package/dist/formula/ToddleFormula.js.map +1 -0
- package/dist/formula/formula.d.ts +103 -0
- package/dist/formula/formula.js +186 -0
- package/dist/formula/formula.js.map +1 -0
- package/dist/formula/formulaTypes.d.ts +30 -0
- package/dist/formula/formulaTypes.js +2 -0
- package/dist/formula/formulaTypes.js.map +1 -0
- package/dist/formula/formulaUtils.d.ts +18 -0
- package/dist/formula/formulaUtils.js +240 -0
- package/dist/formula/formulaUtils.js.map +1 -0
- package/dist/styling/className.d.ts +2 -0
- package/dist/styling/className.js +52 -0
- package/dist/styling/className.js.map +1 -0
- package/dist/styling/style.css.d.ts +5 -0
- package/dist/styling/style.css.js +242 -0
- package/dist/styling/style.css.js.map +1 -0
- package/dist/styling/theme.const.d.ts +3 -0
- package/dist/styling/theme.const.js +381 -0
- package/dist/styling/theme.const.js.map +1 -0
- package/dist/styling/theme.d.ts +72 -0
- package/dist/styling/theme.js +200 -0
- package/dist/styling/theme.js.map +1 -0
- package/dist/styling/variantSelector.d.ts +123 -0
- package/dist/styling/variantSelector.js +25 -0
- package/dist/styling/variantSelector.js.map +1 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/collections.d.ts +21 -0
- package/dist/utils/collections.js +75 -0
- package/dist/utils/collections.js.map +1 -0
- package/dist/utils/customElements.d.ts +6 -0
- package/dist/utils/customElements.js +15 -0
- package/dist/utils/customElements.js.map +1 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +17 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/json.d.ts +5 -0
- package/dist/utils/json.js +16 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/sha1.d.ts +2 -0
- package/dist/utils/sha1.js +13 -0
- package/dist/utils/sha1.js.map +1 -0
- package/dist/utils/url.d.ts +5 -0
- package/dist/utils/url.js +27 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/util.d.ts +3 -0
- package/dist/utils/util.js +4 -0
- package/dist/utils/util.js.map +1 -0
- package/package.json +18 -0
- package/src/api/LegacyToddleApi.ts +205 -0
- package/src/api/ToddleApiV2.ts +331 -0
- package/src/api/api.test.ts +319 -0
- package/src/api/api.ts +414 -0
- package/src/api/apiTypes.ts +145 -0
- package/src/api/headers.ts +41 -0
- package/src/api/template.ts +10 -0
- package/src/component/ToddleComponent.actionReferences.test.ts +75 -0
- package/src/component/ToddleComponent.formulasInComponent.test.ts +234 -0
- package/src/component/ToddleComponent.ts +470 -0
- package/src/component/actionUtils.ts +61 -0
- package/src/component/component.types.ts +362 -0
- package/src/component/isPageComponent.ts +6 -0
- package/src/formula/ToddleFormula.ts +30 -0
- package/src/formula/formula.ts +355 -0
- package/src/formula/formulaTypes.ts +45 -0
- package/src/formula/formulaUtils.ts +287 -0
- package/src/styling/className.test.ts +19 -0
- package/src/styling/className.ts +73 -0
- package/src/styling/style.css.ts +309 -0
- package/src/styling/theme.const.ts +390 -0
- package/src/styling/theme.ts +339 -0
- package/src/styling/variantSelector.ts +168 -0
- package/src/types.ts +158 -0
- package/src/utils/collections.test.ts +57 -0
- package/src/utils/collections.ts +122 -0
- package/src/utils/customElements.test.ts +40 -0
- package/src/utils/customElements.ts +16 -0
- package/src/utils/hash.test.ts +32 -0
- package/src/utils/hash.ts +18 -0
- package/src/utils/json.ts +18 -0
- package/src/utils/sha1.test.ts +50 -0
- package/src/utils/sha1.ts +17 -0
- package/src/utils/url.test.ts +17 -0
- package/src/utils/url.ts +33 -0
- package/src/utils/util.ts +8 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { isFormula, type Formula } from '../formula/formula'
|
|
2
|
+
import type { GlobalFormulas } from '../formula/formulaTypes'
|
|
3
|
+
import {
|
|
4
|
+
getFormulasInAction,
|
|
5
|
+
getFormulasInFormula,
|
|
6
|
+
} from '../formula/formulaUtils'
|
|
7
|
+
import { isDefined } from '../utils/util'
|
|
8
|
+
import { type LegacyComponentAPI } from './apiTypes'
|
|
9
|
+
|
|
10
|
+
export class LegacyToddleApi<Handler> {
|
|
11
|
+
private api: LegacyComponentAPI
|
|
12
|
+
private key: string
|
|
13
|
+
private globalFormulas: GlobalFormulas<Handler>
|
|
14
|
+
private _apiReferences?: Set<string>
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
api: LegacyComponentAPI,
|
|
18
|
+
key: string,
|
|
19
|
+
globalFormulas: GlobalFormulas<Handler>,
|
|
20
|
+
) {
|
|
21
|
+
this.api = api
|
|
22
|
+
this.key = key
|
|
23
|
+
this.globalFormulas = globalFormulas
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get apiReferences(): Set<string> {
|
|
27
|
+
if (this._apiReferences) {
|
|
28
|
+
// Only compute apiReferences once
|
|
29
|
+
return this._apiReferences
|
|
30
|
+
}
|
|
31
|
+
const apis = new Set<string>()
|
|
32
|
+
const visitFormulaReference = (formula?: Formula | null) => {
|
|
33
|
+
if (!isDefined(formula)) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
switch (formula.type) {
|
|
37
|
+
case 'path':
|
|
38
|
+
if (formula.path[0] === 'Apis') {
|
|
39
|
+
apis.add(formula.path[1])
|
|
40
|
+
}
|
|
41
|
+
break
|
|
42
|
+
case 'value':
|
|
43
|
+
break
|
|
44
|
+
case 'record':
|
|
45
|
+
formula.entries.forEach((entry) =>
|
|
46
|
+
visitFormulaReference(entry.formula),
|
|
47
|
+
)
|
|
48
|
+
break
|
|
49
|
+
case 'function':
|
|
50
|
+
case 'array':
|
|
51
|
+
case 'or':
|
|
52
|
+
case 'and':
|
|
53
|
+
case 'apply':
|
|
54
|
+
case 'object':
|
|
55
|
+
formula.arguments?.forEach((arg) =>
|
|
56
|
+
visitFormulaReference(arg.formula),
|
|
57
|
+
)
|
|
58
|
+
break
|
|
59
|
+
case 'switch':
|
|
60
|
+
formula.cases.forEach((c) => {
|
|
61
|
+
visitFormulaReference(c.condition)
|
|
62
|
+
visitFormulaReference(c.formula)
|
|
63
|
+
})
|
|
64
|
+
break
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
visitFormulaReference(this.api.autoFetch)
|
|
68
|
+
visitFormulaReference(this.api.url)
|
|
69
|
+
Object.values(this.api.path ?? {}).forEach((p) =>
|
|
70
|
+
visitFormulaReference(p.formula),
|
|
71
|
+
)
|
|
72
|
+
Object.values(this.api.queryParams ?? {}).forEach((q) =>
|
|
73
|
+
visitFormulaReference(q.formula),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
// this is supporting a few legacy cases where the whole header object was set as a formula. This is no longer possible
|
|
77
|
+
if (isFormula(this.api.headers)) {
|
|
78
|
+
visitFormulaReference(this.api.headers)
|
|
79
|
+
} else {
|
|
80
|
+
Object.values(this.api.headers ?? {}).forEach((h) => {
|
|
81
|
+
visitFormulaReference(h)
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
visitFormulaReference(this.api.body)
|
|
85
|
+
this._apiReferences = apis
|
|
86
|
+
return apis
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get name() {
|
|
90
|
+
return this.api.name
|
|
91
|
+
}
|
|
92
|
+
get type() {
|
|
93
|
+
return this.api.type
|
|
94
|
+
}
|
|
95
|
+
get autoFetch() {
|
|
96
|
+
return this.api.autoFetch
|
|
97
|
+
}
|
|
98
|
+
get url() {
|
|
99
|
+
return this.api.url
|
|
100
|
+
}
|
|
101
|
+
get path() {
|
|
102
|
+
return this.api.path
|
|
103
|
+
}
|
|
104
|
+
get proxy() {
|
|
105
|
+
return this.api.proxy
|
|
106
|
+
}
|
|
107
|
+
get queryParams() {
|
|
108
|
+
return this.api.queryParams
|
|
109
|
+
}
|
|
110
|
+
get headers() {
|
|
111
|
+
return this.api.headers
|
|
112
|
+
}
|
|
113
|
+
get method() {
|
|
114
|
+
return this.api.method
|
|
115
|
+
}
|
|
116
|
+
get body() {
|
|
117
|
+
return this.api.body
|
|
118
|
+
}
|
|
119
|
+
get auth() {
|
|
120
|
+
return this.api.auth
|
|
121
|
+
}
|
|
122
|
+
get throttle() {
|
|
123
|
+
return this.api.throttle
|
|
124
|
+
}
|
|
125
|
+
get debounce() {
|
|
126
|
+
return this.api.debounce
|
|
127
|
+
}
|
|
128
|
+
get onCompleted() {
|
|
129
|
+
return this.api.onCompleted
|
|
130
|
+
}
|
|
131
|
+
get onFailed() {
|
|
132
|
+
return this.api.onFailed
|
|
133
|
+
}
|
|
134
|
+
*formulasInApi(): Generator<[(string | number)[], Formula]> {
|
|
135
|
+
const api = this.api
|
|
136
|
+
const apiKey = this.key
|
|
137
|
+
yield* getFormulasInFormula({
|
|
138
|
+
formula: api.autoFetch,
|
|
139
|
+
globalFormulas: this.globalFormulas,
|
|
140
|
+
path: ['apis', apiKey, 'autoFetch'],
|
|
141
|
+
})
|
|
142
|
+
yield* getFormulasInFormula({
|
|
143
|
+
formula: api.url,
|
|
144
|
+
globalFormulas: this.globalFormulas,
|
|
145
|
+
path: ['apis', apiKey, 'url'],
|
|
146
|
+
})
|
|
147
|
+
for (const [pathKey, path] of Object.entries(api.path ?? {})) {
|
|
148
|
+
yield* getFormulasInFormula({
|
|
149
|
+
formula: path.formula,
|
|
150
|
+
globalFormulas: this.globalFormulas,
|
|
151
|
+
path: ['apis', apiKey, 'path', pathKey, 'formula'],
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
for (const [queryParamKey, queryParam] of Object.entries(
|
|
155
|
+
api.queryParams ?? {},
|
|
156
|
+
)) {
|
|
157
|
+
yield* getFormulasInFormula({
|
|
158
|
+
formula: queryParam.formula,
|
|
159
|
+
globalFormulas: this.globalFormulas,
|
|
160
|
+
path: ['apis', apiKey, 'queryParams', queryParamKey, 'formula'],
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// this is supporting a few legacy cases where the whole header object was set as a formula. This is no longer possible
|
|
165
|
+
if (isFormula(api.headers)) {
|
|
166
|
+
yield* getFormulasInFormula({
|
|
167
|
+
formula: api.headers,
|
|
168
|
+
globalFormulas: this.globalFormulas,
|
|
169
|
+
path: ['apis', apiKey, 'headers'],
|
|
170
|
+
})
|
|
171
|
+
} else {
|
|
172
|
+
for (const [headerKey, header] of Object.entries(api.headers ?? {})) {
|
|
173
|
+
yield* getFormulasInFormula({
|
|
174
|
+
formula: header,
|
|
175
|
+
globalFormulas: this.globalFormulas,
|
|
176
|
+
path: ['apis', apiKey, 'headers', headerKey],
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
yield* getFormulasInFormula({
|
|
182
|
+
formula: api.body,
|
|
183
|
+
globalFormulas: this.globalFormulas,
|
|
184
|
+
path: ['apis', apiKey, 'body'],
|
|
185
|
+
})
|
|
186
|
+
for (const [actionKey, action] of Object.entries(
|
|
187
|
+
api.onCompleted?.actions ?? {},
|
|
188
|
+
)) {
|
|
189
|
+
yield* getFormulasInAction({
|
|
190
|
+
action,
|
|
191
|
+
globalFormulas: this.globalFormulas,
|
|
192
|
+
path: ['apis', apiKey, 'onCompleted', 'actions', actionKey],
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
for (const [actionKey, action] of Object.entries(
|
|
196
|
+
api.onFailed?.actions ?? {},
|
|
197
|
+
)) {
|
|
198
|
+
yield* getFormulasInAction({
|
|
199
|
+
action,
|
|
200
|
+
globalFormulas: this.globalFormulas,
|
|
201
|
+
path: ['apis', apiKey, 'onFailed', 'actions', actionKey],
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { getActionsInAction } from '../component/actionUtils'
|
|
2
|
+
import type { ActionModel } from '../component/component.types'
|
|
3
|
+
import { type Formula } from '../formula/formula'
|
|
4
|
+
import type { GlobalFormulas } from '../formula/formulaTypes'
|
|
5
|
+
import {
|
|
6
|
+
getFormulasInAction,
|
|
7
|
+
getFormulasInFormula,
|
|
8
|
+
} from '../formula/formulaUtils'
|
|
9
|
+
import { isDefined } from '../utils/util'
|
|
10
|
+
import type { ApiRequest } from './apiTypes'
|
|
11
|
+
|
|
12
|
+
export class ToddleApiV2<Handler> implements ApiRequest {
|
|
13
|
+
private api: ApiRequest
|
|
14
|
+
private _apiReferences?: Set<string>
|
|
15
|
+
private key: string
|
|
16
|
+
private globalFormulas: GlobalFormulas<Handler>
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
api: ApiRequest,
|
|
20
|
+
apiKey: string,
|
|
21
|
+
globalFormulas: GlobalFormulas<Handler>,
|
|
22
|
+
) {
|
|
23
|
+
this.api = api
|
|
24
|
+
this.key = apiKey
|
|
25
|
+
this.globalFormulas = globalFormulas
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get apiReferences(): Set<string> {
|
|
29
|
+
if (this._apiReferences) {
|
|
30
|
+
// Only compute apiReferences once
|
|
31
|
+
return this._apiReferences
|
|
32
|
+
}
|
|
33
|
+
const apis = new Set<string>()
|
|
34
|
+
const visitFormulaReference = (formula?: Formula | null) => {
|
|
35
|
+
if (!isDefined(formula)) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
switch (formula.type) {
|
|
39
|
+
case 'path':
|
|
40
|
+
if (formula.path[0] === 'Apis') {
|
|
41
|
+
apis.add(formula.path[1])
|
|
42
|
+
}
|
|
43
|
+
break
|
|
44
|
+
case 'value':
|
|
45
|
+
break
|
|
46
|
+
case 'record':
|
|
47
|
+
formula.entries.forEach((entry) =>
|
|
48
|
+
visitFormulaReference(entry.formula),
|
|
49
|
+
)
|
|
50
|
+
break
|
|
51
|
+
case 'function':
|
|
52
|
+
case 'array':
|
|
53
|
+
case 'or':
|
|
54
|
+
case 'and':
|
|
55
|
+
case 'apply':
|
|
56
|
+
case 'object':
|
|
57
|
+
formula.arguments?.forEach((arg) =>
|
|
58
|
+
visitFormulaReference(arg.formula),
|
|
59
|
+
)
|
|
60
|
+
break
|
|
61
|
+
case 'switch':
|
|
62
|
+
formula.cases.forEach((c) => {
|
|
63
|
+
visitFormulaReference(c.condition)
|
|
64
|
+
visitFormulaReference(c.formula)
|
|
65
|
+
})
|
|
66
|
+
break
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
visitFormulaReference(this.api.autoFetch)
|
|
70
|
+
visitFormulaReference(this.api.url)
|
|
71
|
+
Object.values(this.api.path ?? {}).forEach((p) =>
|
|
72
|
+
visitFormulaReference(p.formula),
|
|
73
|
+
)
|
|
74
|
+
Object.values(this.api.headers ?? {}).forEach((h) =>
|
|
75
|
+
visitFormulaReference(h.formula),
|
|
76
|
+
)
|
|
77
|
+
visitFormulaReference(this.api.body)
|
|
78
|
+
Object.values(this.api.inputs).forEach((arg) =>
|
|
79
|
+
visitFormulaReference(arg.formula),
|
|
80
|
+
)
|
|
81
|
+
Object.values(this.api.queryParams ?? {}).forEach((q) => {
|
|
82
|
+
visitFormulaReference(q.formula)
|
|
83
|
+
})
|
|
84
|
+
visitFormulaReference(this.api.server?.proxy?.enabled?.formula)
|
|
85
|
+
visitFormulaReference(this.api.server?.ssr?.enabled?.formula)
|
|
86
|
+
visitFormulaReference(this.api.client?.debounce?.formula)
|
|
87
|
+
Object.values(this.api.redirectRules ?? {}).forEach((rule) => {
|
|
88
|
+
visitFormulaReference(rule.formula)
|
|
89
|
+
})
|
|
90
|
+
visitFormulaReference(this.api.isError?.formula)
|
|
91
|
+
visitFormulaReference(this.api.timeout?.formula)
|
|
92
|
+
// Ensure self references are not included - for instance if an API references its
|
|
93
|
+
// own response in a redirect rule
|
|
94
|
+
apis.delete(this.key)
|
|
95
|
+
|
|
96
|
+
this._apiReferences = apis
|
|
97
|
+
return apis
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get version() {
|
|
101
|
+
return this.api.version
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get name() {
|
|
105
|
+
return this.api.name
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get type() {
|
|
109
|
+
return this.api.type
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get autoFetch() {
|
|
113
|
+
return this.api.autoFetch
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
get url() {
|
|
117
|
+
return this.api.url
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
get path() {
|
|
121
|
+
return this.api.path
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get headers() {
|
|
125
|
+
return this.api.headers
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
set headers(headers) {
|
|
129
|
+
this.api.headers = headers
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get method() {
|
|
133
|
+
return this.api.method
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get body() {
|
|
137
|
+
return this.api.body
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get inputs() {
|
|
141
|
+
return this.api.inputs
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get queryParams() {
|
|
145
|
+
return this.api.queryParams
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get server() {
|
|
149
|
+
return this.api.server
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get client() {
|
|
153
|
+
return this.api.client
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get redirectRules() {
|
|
157
|
+
return this.api.redirectRules
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get isError() {
|
|
161
|
+
return this.api.isError
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get timeout() {
|
|
165
|
+
return this.api.timeout
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
get '@toddle/metadata'() {
|
|
169
|
+
return this.api['@toddle/metadata']
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
*formulasInApi(): Generator<[(string | number)[], Formula]> {
|
|
173
|
+
const api = this.api
|
|
174
|
+
const apiKey = this.key
|
|
175
|
+
for (const [input, value] of Object.entries(this.api.inputs)) {
|
|
176
|
+
yield* getFormulasInFormula({
|
|
177
|
+
formula: value.formula,
|
|
178
|
+
globalFormulas: this.globalFormulas,
|
|
179
|
+
path: ['apis', apiKey, 'inputs', input, 'formula'],
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
yield* getFormulasInFormula({
|
|
183
|
+
formula: api.autoFetch,
|
|
184
|
+
globalFormulas: this.globalFormulas,
|
|
185
|
+
path: ['apis', apiKey, 'autoFetch'],
|
|
186
|
+
})
|
|
187
|
+
yield* getFormulasInFormula({
|
|
188
|
+
formula: api.url,
|
|
189
|
+
globalFormulas: this.globalFormulas,
|
|
190
|
+
path: ['apis', apiKey, 'url'],
|
|
191
|
+
})
|
|
192
|
+
for (const [pathKey, path] of Object.entries(api.path ?? {})) {
|
|
193
|
+
yield* getFormulasInFormula({
|
|
194
|
+
formula: path.formula,
|
|
195
|
+
globalFormulas: this.globalFormulas,
|
|
196
|
+
path: ['apis', apiKey, 'path', pathKey, 'formula'],
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
for (const [queryParamKey, queryParam] of Object.entries(
|
|
200
|
+
api.queryParams ?? {},
|
|
201
|
+
)) {
|
|
202
|
+
yield* getFormulasInFormula({
|
|
203
|
+
formula: queryParam.formula,
|
|
204
|
+
globalFormulas: this.globalFormulas,
|
|
205
|
+
path: ['apis', apiKey, 'queryParams', queryParamKey, 'formula'],
|
|
206
|
+
})
|
|
207
|
+
yield* getFormulasInFormula({
|
|
208
|
+
formula: queryParam.enabled,
|
|
209
|
+
globalFormulas: this.globalFormulas,
|
|
210
|
+
path: ['apis', apiKey, 'queryParams', queryParamKey, 'enabled'],
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
for (const [headerKey, header] of Object.entries(api.headers ?? {})) {
|
|
215
|
+
yield* getFormulasInFormula({
|
|
216
|
+
formula: header.formula,
|
|
217
|
+
globalFormulas: this.globalFormulas,
|
|
218
|
+
path: ['apis', apiKey, 'headers', headerKey, 'formula'],
|
|
219
|
+
})
|
|
220
|
+
yield* getFormulasInFormula({
|
|
221
|
+
formula: header.enabled,
|
|
222
|
+
globalFormulas: this.globalFormulas,
|
|
223
|
+
path: ['apis', apiKey, 'headers', headerKey, 'enabled'],
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
yield* getFormulasInFormula({
|
|
228
|
+
formula: api.body,
|
|
229
|
+
globalFormulas: this.globalFormulas,
|
|
230
|
+
path: ['apis', apiKey, 'body'],
|
|
231
|
+
})
|
|
232
|
+
for (const [actionKey, action] of Object.entries(
|
|
233
|
+
api.client?.onCompleted?.actions ?? {},
|
|
234
|
+
)) {
|
|
235
|
+
yield* getFormulasInAction({
|
|
236
|
+
action,
|
|
237
|
+
globalFormulas: this.globalFormulas,
|
|
238
|
+
path: ['apis', apiKey, 'client', 'onCompleted', 'actions', actionKey],
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
for (const [actionKey, action] of Object.entries(
|
|
242
|
+
api.client?.onFailed?.actions ?? {},
|
|
243
|
+
)) {
|
|
244
|
+
yield* getFormulasInAction({
|
|
245
|
+
action,
|
|
246
|
+
globalFormulas: this.globalFormulas,
|
|
247
|
+
path: ['apis', apiKey, 'client', 'onFailed', 'actions', actionKey],
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
yield* getFormulasInFormula({
|
|
251
|
+
formula: api.client?.debounce?.formula,
|
|
252
|
+
globalFormulas: this.globalFormulas,
|
|
253
|
+
path: ['apis', apiKey, 'client', 'debounce', 'formula'],
|
|
254
|
+
})
|
|
255
|
+
for (const [actionKey, action] of Object.entries(
|
|
256
|
+
api.client?.onMessage?.actions ?? {},
|
|
257
|
+
)) {
|
|
258
|
+
yield* getFormulasInAction({
|
|
259
|
+
action,
|
|
260
|
+
globalFormulas: this.globalFormulas,
|
|
261
|
+
path: ['apis', apiKey, 'client', 'onMessage', 'actions', actionKey],
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
for (const [rule, value] of Object.entries(api.redirectRules ?? {})) {
|
|
265
|
+
yield* getFormulasInFormula({
|
|
266
|
+
formula: value.formula,
|
|
267
|
+
globalFormulas: this.globalFormulas,
|
|
268
|
+
path: ['apis', apiKey, 'redirectRules', rule, 'formula'],
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
yield* getFormulasInFormula({
|
|
272
|
+
formula: api.isError?.formula,
|
|
273
|
+
globalFormulas: this.globalFormulas,
|
|
274
|
+
path: ['apis', apiKey, 'isError', 'formula'],
|
|
275
|
+
})
|
|
276
|
+
yield* getFormulasInFormula({
|
|
277
|
+
formula: api.timeout?.formula,
|
|
278
|
+
globalFormulas: this.globalFormulas,
|
|
279
|
+
path: ['apis', apiKey, 'timeout', 'formula'],
|
|
280
|
+
})
|
|
281
|
+
yield* getFormulasInFormula({
|
|
282
|
+
formula: api.server?.proxy?.enabled.formula,
|
|
283
|
+
globalFormulas: this.globalFormulas,
|
|
284
|
+
path: ['apis', apiKey, 'server', 'proxy', 'enabled', 'formula'],
|
|
285
|
+
})
|
|
286
|
+
yield* getFormulasInFormula({
|
|
287
|
+
formula: api.server?.ssr?.enabled?.formula,
|
|
288
|
+
globalFormulas: this.globalFormulas,
|
|
289
|
+
path: ['apis', apiKey, 'server', 'ssr', 'enabled', 'formula'],
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
*actionModelsInApi(): Generator<[(string | number)[], ActionModel]> {
|
|
294
|
+
for (const [actionKey, action] of Object.entries(
|
|
295
|
+
this.api.client?.onCompleted?.actions ?? {},
|
|
296
|
+
)) {
|
|
297
|
+
yield* getActionsInAction(action, [
|
|
298
|
+
'apis',
|
|
299
|
+
this.key,
|
|
300
|
+
'client',
|
|
301
|
+
'onCompleted',
|
|
302
|
+
'actions',
|
|
303
|
+
actionKey,
|
|
304
|
+
])
|
|
305
|
+
}
|
|
306
|
+
for (const [actionKey, action] of Object.entries(
|
|
307
|
+
this.api.client?.onFailed?.actions ?? {},
|
|
308
|
+
)) {
|
|
309
|
+
yield* getActionsInAction(action, [
|
|
310
|
+
'apis',
|
|
311
|
+
this.key,
|
|
312
|
+
'client',
|
|
313
|
+
'onFailed',
|
|
314
|
+
'actions',
|
|
315
|
+
actionKey,
|
|
316
|
+
])
|
|
317
|
+
}
|
|
318
|
+
for (const [actionKey, action] of Object.entries(
|
|
319
|
+
this.api.client?.onMessage?.actions ?? {},
|
|
320
|
+
)) {
|
|
321
|
+
yield* getActionsInAction(action, [
|
|
322
|
+
'apis',
|
|
323
|
+
this.key,
|
|
324
|
+
'client',
|
|
325
|
+
'onData',
|
|
326
|
+
'actions',
|
|
327
|
+
actionKey,
|
|
328
|
+
])
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|