@nordcraft/core 1.0.77 → 1.0.79
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/dist/api/ToddleApiV2.d.ts +3 -3
- package/dist/api/apiTypes.d.ts +2 -2
- package/dist/component/component.types.d.ts +8 -1
- package/dist/component/component.types.js.map +1 -1
- package/dist/component/schemas/action-schema.d.ts +3 -0
- package/dist/component/schemas/action-schema.js +169 -0
- package/dist/component/schemas/action-schema.js.map +1 -0
- package/dist/component/schemas/api-schema.d.ts +3 -0
- package/dist/component/schemas/api-schema.js +174 -0
- package/dist/component/schemas/api-schema.js.map +1 -0
- package/dist/component/schemas/attribute-schema.d.ts +3 -0
- package/dist/component/schemas/attribute-schema.js +12 -0
- package/dist/component/schemas/attribute-schema.js.map +1 -0
- package/dist/component/schemas/component-schema.d.ts +6 -0
- package/dist/component/schemas/component-schema.js +132 -0
- package/dist/component/schemas/component-schema.js.map +1 -0
- package/dist/component/schemas/context-schema.d.ts +3 -0
- package/dist/component/schemas/context-schema.js +20 -0
- package/dist/component/schemas/context-schema.js.map +1 -0
- package/dist/component/schemas/event-schema.d.ts +4 -0
- package/dist/component/schemas/event-schema.js +25 -0
- package/dist/component/schemas/event-schema.js.map +1 -0
- package/dist/component/schemas/formula-schema.d.ts +5 -0
- package/dist/component/schemas/formula-schema.js +203 -0
- package/dist/component/schemas/formula-schema.js.map +1 -0
- package/dist/component/schemas/node-schema.d.ts +3 -0
- package/dist/component/schemas/node-schema.js +159 -0
- package/dist/component/schemas/node-schema.js.map +1 -0
- package/dist/component/schemas/route-schema.d.ts +3 -0
- package/dist/component/schemas/route-schema.js +88 -0
- package/dist/component/schemas/route-schema.js.map +1 -0
- package/dist/component/schemas/variable-schema.d.ts +3 -0
- package/dist/component/schemas/variable-schema.js +8 -0
- package/dist/component/schemas/variable-schema.js.map +1 -0
- package/dist/component/schemas/workflow-schema.d.ts +3 -0
- package/dist/component/schemas/workflow-schema.js +23 -0
- package/dist/component/schemas/workflow-schema.js.map +1 -0
- package/dist/component/schemas/zod-schemas.d.ts +26 -3
- package/dist/component/schemas/zod-schemas.js +4 -1077
- package/dist/component/schemas/zod-schemas.js.map +1 -1
- package/dist/styling/style.css.d.ts +3 -1
- package/dist/styling/style.css.js +124 -128
- package/dist/styling/style.css.js.map +1 -1
- package/dist/styling/theme.const.d.ts +2 -0
- package/dist/styling/theme.const.js +2 -0
- package/dist/styling/theme.const.js.map +1 -1
- package/dist/styling/theme.js +2 -2
- package/dist/styling/theme.js.map +1 -1
- package/dist/styling/variantSelector.d.ts +1 -8
- package/dist/styling/variantSelector.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/collections.d.ts +1 -1
- package/dist/utils/collections.js.map +1 -1
- package/package.json +6 -1
- package/src/api/apiTypes.ts +2 -2
- package/src/component/component.types.ts +9 -1
- package/src/component/schemas/action-schema.ts +258 -0
- package/src/component/schemas/api-schema.ts +255 -0
- package/src/component/schemas/attribute-schema.ts +15 -0
- package/src/component/schemas/component-schema.ts +174 -0
- package/src/component/schemas/context-schema.ts +21 -0
- package/src/component/schemas/event-schema.ts +35 -0
- package/src/component/schemas/formula-schema.ts +299 -0
- package/src/component/schemas/node-schema.ts +259 -0
- package/src/component/schemas/route-schema.ts +135 -0
- package/src/component/schemas/variable-schema.ts +11 -0
- package/src/component/schemas/workflow-schema.ts +30 -0
- package/src/component/schemas/zod-schemas.ts +4 -1489
- package/src/styling/style.css.test.ts +929 -0
- package/src/styling/style.css.ts +148 -152
- package/src/styling/theme.const.ts +3 -0
- package/src/styling/theme.test.ts +4 -4
- package/src/styling/theme.ts +2 -2
- package/src/styling/variantSelector.ts +1 -7
- package/src/types.ts +1 -1
- package/src/utils/collections.ts +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/utils/collections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEl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AAE,CAAC,MAAM,CAAM,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;YAC5D,GAAG,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YACnC,OAAO,GAAG,CAAA;QAAA,CACX,EAAE,EAAE,CAAC,CAAA;IACR,CAAC;IACD,OAAO,GAAG,CAAA;AAAA,CACX,CAAA"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://github.com/nordcraftengine/nordcraft",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nordcraftengine/nordcraft.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
6
11
|
"scripts": {
|
|
7
12
|
"build": "tsgo",
|
|
8
13
|
"npm-publish": "bun run build && bun publish --access public",
|
|
@@ -14,5 +19,5 @@
|
|
|
14
19
|
"zod": "4.2.1"
|
|
15
20
|
},
|
|
16
21
|
"main": "dist/index.js",
|
|
17
|
-
"version": "1.0.
|
|
22
|
+
"version": "1.0.79"
|
|
18
23
|
}
|
package/src/api/apiTypes.ts
CHANGED
|
@@ -77,7 +77,7 @@ export interface ApiRequest extends ApiBase {
|
|
|
77
77
|
method?: Nullable<ApiMethod>
|
|
78
78
|
body?: Nullable<Formula>
|
|
79
79
|
// inputs for an API request
|
|
80
|
-
inputs: Record<string, { formula
|
|
80
|
+
inputs: Record<string, { formula?: Nullable<Formula> }>
|
|
81
81
|
service?: Nullable<string>
|
|
82
82
|
servicePath?: Nullable<string>
|
|
83
83
|
server?: Nullable<{
|
|
@@ -103,7 +103,7 @@ export interface ApiRequest extends ApiBase {
|
|
|
103
103
|
// parserMode is used to determine how the response should be handled
|
|
104
104
|
// auto: The response will be handled based on the content type of the response
|
|
105
105
|
// stream: The response will be handled as a stream
|
|
106
|
-
parserMode
|
|
106
|
+
parserMode?: Nullable<ApiParserMode>
|
|
107
107
|
// Whether to include credentials (cookies) in the request or not. Default is 'same-origin'
|
|
108
108
|
credentials?: Nullable<'include' | 'same-origin' | 'omit'>
|
|
109
109
|
}>
|
|
@@ -39,6 +39,9 @@ export interface ComponentData {
|
|
|
39
39
|
Parameters?: Nullable<Record<string, unknown>>
|
|
40
40
|
Event?: Nullable<unknown>
|
|
41
41
|
ListItem?: Nullable<ListItem>
|
|
42
|
+
Page?: Nullable<{
|
|
43
|
+
Theme: string | null
|
|
44
|
+
}>
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
export interface AnimationKeyframe {
|
|
@@ -157,6 +160,7 @@ export type MediaQuery = {
|
|
|
157
160
|
'max-width'?: Nullable<string>
|
|
158
161
|
'min-height'?: Nullable<string>
|
|
159
162
|
'max-height'?: Nullable<string>
|
|
163
|
+
'prefers-reduced-motion'?: Nullable<'reduce' | 'no-preference'>
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
export interface Component {
|
|
@@ -233,6 +237,10 @@ export interface PageRoute extends RouteDeclaration {
|
|
|
233
237
|
info?: Nullable<{
|
|
234
238
|
// value for <html lang= > - defaults to 'en'
|
|
235
239
|
language?: Nullable<{ formula: Formula }>
|
|
240
|
+
|
|
241
|
+
// theme for <html data-nc-theme= > - defaults to read from cookie
|
|
242
|
+
theme?: Nullable<{ formula: Formula }>
|
|
243
|
+
|
|
236
244
|
// title (for <title>) - defaults to page name
|
|
237
245
|
title?: Nullable<{ formula: Formula }>
|
|
238
246
|
description?: Nullable<{ formula: Formula }>
|
|
@@ -323,7 +331,7 @@ export interface VariableActionModel {
|
|
|
323
331
|
export interface FetchActionModel {
|
|
324
332
|
type: 'Fetch'
|
|
325
333
|
api: string
|
|
326
|
-
inputs?: Nullable<Record<string, { formula
|
|
334
|
+
inputs?: Nullable<Record<string, { formula?: Nullable<Formula> }>>
|
|
327
335
|
onSuccess: ActionModelActions
|
|
328
336
|
onError: ActionModelActions
|
|
329
337
|
onMessage?: Nullable<ActionModelActions>
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type {
|
|
3
|
+
ActionModel,
|
|
4
|
+
CustomActionModel,
|
|
5
|
+
EventActionModel,
|
|
6
|
+
FetchActionModel,
|
|
7
|
+
SetMultiUrlParameterAction,
|
|
8
|
+
SetURLParameterAction,
|
|
9
|
+
SwitchActionModel,
|
|
10
|
+
VariableActionModel,
|
|
11
|
+
WorkflowActionModel,
|
|
12
|
+
} from '../component.types'
|
|
13
|
+
import { FormulaSchema } from './formula-schema'
|
|
14
|
+
|
|
15
|
+
// Action Models
|
|
16
|
+
const VariableActionModelSchema: z.ZodType<VariableActionModel> = z
|
|
17
|
+
.object({
|
|
18
|
+
type: z.literal('SetVariable'),
|
|
19
|
+
variable: z.string().describe('Name of the variable to be set.'),
|
|
20
|
+
data: FormulaSchema.describe(
|
|
21
|
+
'Formula evaluating to the new variable value.',
|
|
22
|
+
),
|
|
23
|
+
})
|
|
24
|
+
.describe('Model describing the action of setting a variable.')
|
|
25
|
+
|
|
26
|
+
const EventActionModelSchema: z.ZodType<EventActionModel> = z
|
|
27
|
+
.object({
|
|
28
|
+
type: z.literal('TriggerEvent'),
|
|
29
|
+
event: z.string().describe('Name of the event to be triggered.'),
|
|
30
|
+
data: FormulaSchema.describe('Data to pass to the event being triggered.'),
|
|
31
|
+
})
|
|
32
|
+
.describe(
|
|
33
|
+
'Model describing the action of triggering an event. This is only relevant on components as they are the only entities that can have events defined.',
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const SwitchActionModelSchema: z.ZodType<SwitchActionModel> = z
|
|
37
|
+
.object({
|
|
38
|
+
type: z.literal('Switch'),
|
|
39
|
+
cases: z
|
|
40
|
+
.array(
|
|
41
|
+
z.object({
|
|
42
|
+
condition: FormulaSchema.describe(
|
|
43
|
+
'Condition to evaluate for this case. If truthy the actions are executed.',
|
|
44
|
+
),
|
|
45
|
+
actions: z
|
|
46
|
+
.array(z.lazy(() => ActionModelSchema))
|
|
47
|
+
.describe('List of actions to execute if the condition is met.'),
|
|
48
|
+
}),
|
|
49
|
+
)
|
|
50
|
+
.describe(
|
|
51
|
+
'Cases for the switch action. Each case has a condition and actions.',
|
|
52
|
+
),
|
|
53
|
+
default: z
|
|
54
|
+
.object({
|
|
55
|
+
actions: z.array(z.lazy(() => ActionModelSchema)),
|
|
56
|
+
})
|
|
57
|
+
.describe('Actions to execute if no case conditions are met.'),
|
|
58
|
+
})
|
|
59
|
+
.describe(
|
|
60
|
+
'Model describing a switch action. A switch action allows branching logic based on conditions.',
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
const FetchActionModelSchema: z.ZodType<FetchActionModel> = z
|
|
64
|
+
.object({
|
|
65
|
+
type: z.literal('Fetch'),
|
|
66
|
+
api: z
|
|
67
|
+
.string()
|
|
68
|
+
.describe(
|
|
69
|
+
'Key of the API to fetch data from. This is the key defined in the APIs object in the file.',
|
|
70
|
+
),
|
|
71
|
+
inputs: z
|
|
72
|
+
.record(
|
|
73
|
+
z.string().describe('Name of the API input.'),
|
|
74
|
+
z.object({
|
|
75
|
+
formula: FormulaSchema.nullish().describe('Formula for the input.'),
|
|
76
|
+
}),
|
|
77
|
+
)
|
|
78
|
+
.describe(
|
|
79
|
+
'Inputs overriding the default input values for the API. Available inputs are defined as part of the API definition.',
|
|
80
|
+
),
|
|
81
|
+
onSuccess: z
|
|
82
|
+
.object({
|
|
83
|
+
actions: z.array(z.lazy(() => ActionModelSchema)),
|
|
84
|
+
})
|
|
85
|
+
.describe('Actions to execute when the fetch is successful.'),
|
|
86
|
+
onError: z
|
|
87
|
+
.object({
|
|
88
|
+
actions: z.array(z.lazy(() => ActionModelSchema)),
|
|
89
|
+
})
|
|
90
|
+
.describe('Actions to execute when the fetch fails.'),
|
|
91
|
+
onMessage: z
|
|
92
|
+
.object({
|
|
93
|
+
actions: z.array(z.lazy(() => ActionModelSchema)),
|
|
94
|
+
})
|
|
95
|
+
.nullish()
|
|
96
|
+
.describe(
|
|
97
|
+
'Actions to execute when a message is received during streaming.',
|
|
98
|
+
),
|
|
99
|
+
})
|
|
100
|
+
.describe('Model describing the action of fetching data from an API.')
|
|
101
|
+
|
|
102
|
+
const CustomActionModelSchema: z.ZodType<CustomActionModel> = z
|
|
103
|
+
.object({
|
|
104
|
+
type: z.literal('Custom'),
|
|
105
|
+
name: z.string().describe('Name of the custom action to be executed.'),
|
|
106
|
+
package: z
|
|
107
|
+
.string()
|
|
108
|
+
.nullish()
|
|
109
|
+
.describe(
|
|
110
|
+
'Package where the custom action is defined. Should not be set for local custom actions.',
|
|
111
|
+
),
|
|
112
|
+
arguments: z
|
|
113
|
+
.array(
|
|
114
|
+
z.object({
|
|
115
|
+
name: z.string().describe('Name of the argument.'),
|
|
116
|
+
formula: FormulaSchema.describe(
|
|
117
|
+
'Formula evaluating to the argument value.',
|
|
118
|
+
),
|
|
119
|
+
}),
|
|
120
|
+
)
|
|
121
|
+
.nullish()
|
|
122
|
+
.describe('Arguments to pass to the custom action.'),
|
|
123
|
+
events: z
|
|
124
|
+
.record(
|
|
125
|
+
z.string().describe('Name of the event.'),
|
|
126
|
+
z
|
|
127
|
+
.object({
|
|
128
|
+
actions: z
|
|
129
|
+
.array(z.lazy(() => ActionModelSchema))
|
|
130
|
+
.describe(
|
|
131
|
+
'List of actions to execute when the event is triggered.',
|
|
132
|
+
),
|
|
133
|
+
})
|
|
134
|
+
.describe(
|
|
135
|
+
'Record with one entry called "actions" which is a list of actions to execute when the event is triggered..',
|
|
136
|
+
),
|
|
137
|
+
)
|
|
138
|
+
.nullish()
|
|
139
|
+
.describe(
|
|
140
|
+
'Record of events defined in the custom action. Each event has a list of actions to execute when the event is emitted.',
|
|
141
|
+
),
|
|
142
|
+
version: z
|
|
143
|
+
.literal(2)
|
|
144
|
+
.nullish()
|
|
145
|
+
.describe('Version of the custom action model. This should always be 2.'),
|
|
146
|
+
})
|
|
147
|
+
.describe(
|
|
148
|
+
'Model describing the action of a custom action. A custom action is a user-defined action that can be reused across the project. A list of available custom actions has been provided as part of the system prompt.',
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
const BuiltInActionModelSchema: z.ZodType<CustomActionModel> = z
|
|
152
|
+
.object({
|
|
153
|
+
name: z
|
|
154
|
+
.string()
|
|
155
|
+
.describe(
|
|
156
|
+
'Name of the built-in action. This will always be prefixed with "@toddle/" and should match the action key in the system.',
|
|
157
|
+
),
|
|
158
|
+
arguments: z
|
|
159
|
+
.array(
|
|
160
|
+
z.object({
|
|
161
|
+
name: z.string().describe('Name of the argument.'),
|
|
162
|
+
formula: FormulaSchema.describe(
|
|
163
|
+
'Formula evaluating to the argument value.',
|
|
164
|
+
),
|
|
165
|
+
}),
|
|
166
|
+
)
|
|
167
|
+
.nullish()
|
|
168
|
+
.describe('Arguments to pass to the built-in action.'),
|
|
169
|
+
events: z
|
|
170
|
+
.record(
|
|
171
|
+
z.string().describe('Name of the event.'),
|
|
172
|
+
z
|
|
173
|
+
.object({
|
|
174
|
+
actions: z.array(z.lazy(() => ActionModelSchema)),
|
|
175
|
+
})
|
|
176
|
+
.describe('List of actions to execute when the event is triggered.'),
|
|
177
|
+
)
|
|
178
|
+
.nullish()
|
|
179
|
+
.describe(
|
|
180
|
+
'Events that can be triggered by the built-in action. Common events include onSuccess and onError.',
|
|
181
|
+
),
|
|
182
|
+
label: z
|
|
183
|
+
.string()
|
|
184
|
+
.describe(
|
|
185
|
+
'Label for the built-in action. This label will be used in the UI.',
|
|
186
|
+
),
|
|
187
|
+
})
|
|
188
|
+
.describe(
|
|
189
|
+
'Model describing a built-in action provided by the Nordcraft system. Built-in actions are pre-defined actions that can be used to perform common tasks within a Nordcraft project.',
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
const SetURLParameterActionSchema: z.ZodType<SetURLParameterAction> = z
|
|
193
|
+
.object({
|
|
194
|
+
type: z.literal('SetURLParameter'),
|
|
195
|
+
parameter: z.string(),
|
|
196
|
+
data: FormulaSchema,
|
|
197
|
+
historyMode: z.enum(['replace', 'push']).nullish(),
|
|
198
|
+
})
|
|
199
|
+
.describe(
|
|
200
|
+
'This model is deprecated. Instead refer to SetMultiUrlParameterActionSchema.',
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
const SetMultiUrlParameterActionSchema: z.ZodType<SetMultiUrlParameterAction> =
|
|
204
|
+
z
|
|
205
|
+
.object({
|
|
206
|
+
type: z.literal('SetURLParameters'),
|
|
207
|
+
parameters: z
|
|
208
|
+
.record(z.string(), FormulaSchema)
|
|
209
|
+
.describe(
|
|
210
|
+
'Record of URL parameters to set, where the key is the parameter name and the value is a formula evaluating to the parameter value.',
|
|
211
|
+
),
|
|
212
|
+
historyMode: z
|
|
213
|
+
.enum(['replace', 'push'])
|
|
214
|
+
.nullish()
|
|
215
|
+
.describe(
|
|
216
|
+
'This determines how the URL is updated in the browser history. Use "replace" to update the current history entry without adding a new one, or "push" to create a new history entry for the URL change. If not specified, the default behavior is to use "push".',
|
|
217
|
+
),
|
|
218
|
+
})
|
|
219
|
+
.describe(
|
|
220
|
+
'Model describing the action of setting multiple URL parameters. Use this action to update any number (1-*) of URL parameter(s) in one go.',
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
const WorkflowActionModelSchema: z.ZodType<WorkflowActionModel> = z
|
|
224
|
+
.object({
|
|
225
|
+
type: z.literal('TriggerWorkflow'),
|
|
226
|
+
workflow: z.string().describe('ID of the workflow to be triggered.'),
|
|
227
|
+
parameters: z
|
|
228
|
+
.record(
|
|
229
|
+
z.string().describe('Name of the workflow parameter.'),
|
|
230
|
+
z
|
|
231
|
+
.object({
|
|
232
|
+
formula: FormulaSchema,
|
|
233
|
+
})
|
|
234
|
+
.describe('Formula evaluating to the parameter value.'),
|
|
235
|
+
)
|
|
236
|
+
.describe('Parameters to pass to the workflow being triggered. '),
|
|
237
|
+
contextProvider: z
|
|
238
|
+
.string()
|
|
239
|
+
.nullish()
|
|
240
|
+
.describe(
|
|
241
|
+
'If the workflow being triggered is from a parent component and exposed via a context provider, this is the ID of that context provider.',
|
|
242
|
+
),
|
|
243
|
+
})
|
|
244
|
+
.describe('Model describing the action of triggering a workflow.')
|
|
245
|
+
|
|
246
|
+
export const ActionModelSchema: z.ZodType<ActionModel> = z.lazy(() =>
|
|
247
|
+
z.union([
|
|
248
|
+
VariableActionModelSchema,
|
|
249
|
+
EventActionModelSchema,
|
|
250
|
+
SwitchActionModelSchema,
|
|
251
|
+
FetchActionModelSchema,
|
|
252
|
+
CustomActionModelSchema,
|
|
253
|
+
SetURLParameterActionSchema,
|
|
254
|
+
SetMultiUrlParameterActionSchema,
|
|
255
|
+
WorkflowActionModelSchema,
|
|
256
|
+
BuiltInActionModelSchema,
|
|
257
|
+
]),
|
|
258
|
+
)
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type {
|
|
3
|
+
ApiParserMode,
|
|
4
|
+
ApiRequest,
|
|
5
|
+
ComponentAPI,
|
|
6
|
+
LegacyComponentAPI,
|
|
7
|
+
} from '../../api/apiTypes'
|
|
8
|
+
import { EventModelSchema } from './event-schema'
|
|
9
|
+
import { FormulaSchema } from './formula-schema'
|
|
10
|
+
import { MetadataSchema } from './zod-schemas'
|
|
11
|
+
|
|
12
|
+
// API Models
|
|
13
|
+
const ApiMethodSchema: z.ZodType<any> = z
|
|
14
|
+
.enum(['GET', 'POST', 'DELETE', 'PUT', 'PATCH', 'HEAD', 'OPTIONS'])
|
|
15
|
+
.describe('HTTP method for the API request.')
|
|
16
|
+
|
|
17
|
+
const ApiParserModeSchema: z.ZodType<ApiParserMode> = z
|
|
18
|
+
.enum(['auto', 'text', 'json', 'event-stream', 'json-stream', 'blob'])
|
|
19
|
+
.describe('Available modes for parsing API responses.')
|
|
20
|
+
|
|
21
|
+
const RedirectStatusCodes = {
|
|
22
|
+
'300': 300,
|
|
23
|
+
'301': 301,
|
|
24
|
+
'302': 302,
|
|
25
|
+
'303': 303,
|
|
26
|
+
'304': 304,
|
|
27
|
+
'307': 307,
|
|
28
|
+
'308': 308,
|
|
29
|
+
}
|
|
30
|
+
const RedirectStatusCodeSchema: z.ZodType<any> = z
|
|
31
|
+
.enum(RedirectStatusCodes)
|
|
32
|
+
.describe('HTTP status code to use for the redirect.')
|
|
33
|
+
|
|
34
|
+
const ApiRequestSchema: z.ZodType<ApiRequest> = z
|
|
35
|
+
.object({
|
|
36
|
+
'@nordcraft/metadata': MetadataSchema.nullish().describe(
|
|
37
|
+
'Metadata for the API request',
|
|
38
|
+
),
|
|
39
|
+
version: z
|
|
40
|
+
.literal(2)
|
|
41
|
+
.describe('Version of the API request schema. This should always be 2.'),
|
|
42
|
+
name: z.string().describe('Name of the API request.'),
|
|
43
|
+
type: z.enum(['http', 'ws']).describe('Type of the API request.'),
|
|
44
|
+
method: ApiMethodSchema.nullish().describe(
|
|
45
|
+
'HTTP method for the API request.',
|
|
46
|
+
),
|
|
47
|
+
url: FormulaSchema.nullish().describe(
|
|
48
|
+
'Base URL for the API request. Params and query strings are added when this API is called.',
|
|
49
|
+
),
|
|
50
|
+
service: z
|
|
51
|
+
.string()
|
|
52
|
+
.nullish()
|
|
53
|
+
.describe(
|
|
54
|
+
'Name of the service to use for the API request. Only Services defined in the project can be used here.',
|
|
55
|
+
),
|
|
56
|
+
servicePath: z
|
|
57
|
+
.string()
|
|
58
|
+
.nullish()
|
|
59
|
+
.describe(
|
|
60
|
+
'File path to the service definition. If service is defined, servicePath must also be defined.',
|
|
61
|
+
),
|
|
62
|
+
inputs: z
|
|
63
|
+
.record(
|
|
64
|
+
z.string().describe('Name of the input'),
|
|
65
|
+
z
|
|
66
|
+
.object({
|
|
67
|
+
formula: FormulaSchema.nullish(),
|
|
68
|
+
})
|
|
69
|
+
.describe('Formula evaluating to the input value.'),
|
|
70
|
+
)
|
|
71
|
+
.describe(
|
|
72
|
+
'Inputs to the API request. Inputs have a default value that can be overridden when the API is started from a workflow. Inputs can be used inside any Formula in the API request definition.',
|
|
73
|
+
),
|
|
74
|
+
path: z
|
|
75
|
+
.record(
|
|
76
|
+
z.string().describe('Name of the path segment'),
|
|
77
|
+
z.object({
|
|
78
|
+
formula: FormulaSchema.describe(
|
|
79
|
+
'Formula evaluating to the value of the path segment',
|
|
80
|
+
),
|
|
81
|
+
index: z
|
|
82
|
+
.number()
|
|
83
|
+
.describe('Index defining the order of the path segments.'),
|
|
84
|
+
}),
|
|
85
|
+
)
|
|
86
|
+
.nullish()
|
|
87
|
+
.describe('Path segments to include in the API request.'),
|
|
88
|
+
queryParams: z
|
|
89
|
+
.record(
|
|
90
|
+
z.string().describe('Name of the query parameter'),
|
|
91
|
+
z.object({
|
|
92
|
+
formula: FormulaSchema.describe(
|
|
93
|
+
'Formula evaluating to the value of the query parameter',
|
|
94
|
+
),
|
|
95
|
+
enabled: FormulaSchema.nullish().describe(
|
|
96
|
+
'Formula evaluating to whether the query parameter is included or not. If included it should evaluate to true.',
|
|
97
|
+
),
|
|
98
|
+
}),
|
|
99
|
+
)
|
|
100
|
+
.nullish()
|
|
101
|
+
.describe('Query parameters to include in the API request.'),
|
|
102
|
+
headers: z
|
|
103
|
+
.record(
|
|
104
|
+
z.string().describe('Name of the header'),
|
|
105
|
+
z.object({
|
|
106
|
+
formula: FormulaSchema.describe(
|
|
107
|
+
'Formula evaluating to the header value',
|
|
108
|
+
),
|
|
109
|
+
enabled: FormulaSchema.nullish().describe(
|
|
110
|
+
'Formula evaluating to whether the header is included or not. If included it should evaluate to true.',
|
|
111
|
+
),
|
|
112
|
+
}),
|
|
113
|
+
)
|
|
114
|
+
.nullish()
|
|
115
|
+
.describe('Headers to include in the API request.'),
|
|
116
|
+
body: FormulaSchema.nullish().describe('Body of the API request.'),
|
|
117
|
+
autoFetch: FormulaSchema.nullish().describe(
|
|
118
|
+
'Indicates if the API request should be automatically fetched when the component or page loads.',
|
|
119
|
+
),
|
|
120
|
+
client: z
|
|
121
|
+
.object({
|
|
122
|
+
parserMode: ApiParserModeSchema.describe(
|
|
123
|
+
'Defines how the API response should be parsed.',
|
|
124
|
+
),
|
|
125
|
+
credentials: z
|
|
126
|
+
.enum(['include', 'same-origin', 'omit'])
|
|
127
|
+
.nullish()
|
|
128
|
+
.describe(
|
|
129
|
+
'Indicates whether credentials such as cookies or authorization headers should be sent with the request.',
|
|
130
|
+
),
|
|
131
|
+
debounce: z
|
|
132
|
+
.object({ formula: FormulaSchema })
|
|
133
|
+
.nullish()
|
|
134
|
+
.describe(
|
|
135
|
+
'Debounce time in milliseconds for the API request. Useful for limiting the number of requests made when inputs change rapidly.',
|
|
136
|
+
),
|
|
137
|
+
onCompleted: EventModelSchema.nullish().describe(
|
|
138
|
+
'Event triggered when the API request completes successfully.',
|
|
139
|
+
),
|
|
140
|
+
onFailed: EventModelSchema.nullish().describe(
|
|
141
|
+
'Event triggered when the API request fails. This is also triggered when the isError formula evaluates to true.',
|
|
142
|
+
),
|
|
143
|
+
onMessage: EventModelSchema.nullish().describe(
|
|
144
|
+
'Event triggered when a message is received from the API. Only applicable for WebSocket and streaming APIs.',
|
|
145
|
+
),
|
|
146
|
+
})
|
|
147
|
+
.nullish()
|
|
148
|
+
.describe('Client-side settings for the API request.'),
|
|
149
|
+
server: z
|
|
150
|
+
.object({
|
|
151
|
+
proxy: z
|
|
152
|
+
.object({
|
|
153
|
+
enabled: z
|
|
154
|
+
.object({ formula: FormulaSchema })
|
|
155
|
+
.describe(
|
|
156
|
+
'Indicates if the API request should be proxied through the Nordcraft backend server. This is useful for avoiding CORS issues or hiding sensitive information in the request. It is also useful if the request needs access to http-only cookies.',
|
|
157
|
+
),
|
|
158
|
+
useTemplatesInBody: z
|
|
159
|
+
.object({ formula: FormulaSchema })
|
|
160
|
+
.nullish()
|
|
161
|
+
.describe(
|
|
162
|
+
'Indicates if templates in the body should be processed when proxying the request. A template could be a http-only cookie that needs to be included in the proxied request. Enabling this flag will ensure that templates in the body are processed before sending the proxied request.',
|
|
163
|
+
),
|
|
164
|
+
})
|
|
165
|
+
.nullish()
|
|
166
|
+
.describe('Proxy settings for the API request.'),
|
|
167
|
+
ssr: z
|
|
168
|
+
.object({
|
|
169
|
+
enabled: z
|
|
170
|
+
.object({ formula: FormulaSchema })
|
|
171
|
+
.nullish()
|
|
172
|
+
.describe(
|
|
173
|
+
'Indicates if server-side rendering is enabled for this API request. This means the API will be executed on the server during the initial page load. Note: This can have performance implications for the loading of a page on slow APIs.',
|
|
174
|
+
),
|
|
175
|
+
})
|
|
176
|
+
.nullish()
|
|
177
|
+
.describe('Server-side rendering settings.'),
|
|
178
|
+
})
|
|
179
|
+
.nullish()
|
|
180
|
+
.describe('Server-side settings for the API request.'),
|
|
181
|
+
timeout: z
|
|
182
|
+
.object({ formula: FormulaSchema })
|
|
183
|
+
.nullish()
|
|
184
|
+
.describe('Timeout for the API request in milliseconds.'),
|
|
185
|
+
hash: z.object({ formula: FormulaSchema }).nullish(),
|
|
186
|
+
isError: z
|
|
187
|
+
.object({ formula: FormulaSchema })
|
|
188
|
+
.nullish()
|
|
189
|
+
.describe(
|
|
190
|
+
'Indicates if the last API response was an error. Useful for forcing a response to be treated as an error even if status code is 200.',
|
|
191
|
+
),
|
|
192
|
+
redirectRules: z
|
|
193
|
+
.record(
|
|
194
|
+
z.string().describe('The key of the redirect rule.'),
|
|
195
|
+
z
|
|
196
|
+
.object({
|
|
197
|
+
formula: FormulaSchema.describe(
|
|
198
|
+
'Formula evaluating to the URL. If a URL is returned, the redirect will be triggered. If null is returned, no redirect will happen.',
|
|
199
|
+
),
|
|
200
|
+
index: z
|
|
201
|
+
.number()
|
|
202
|
+
.describe('Index defining the order of the redirect rules.'),
|
|
203
|
+
statusCode: RedirectStatusCodeSchema.nullish().describe(
|
|
204
|
+
'HTTP status code to use for the redirect.',
|
|
205
|
+
),
|
|
206
|
+
})
|
|
207
|
+
.describe('Defines a single redirect rule.'),
|
|
208
|
+
)
|
|
209
|
+
.nullish()
|
|
210
|
+
.describe(
|
|
211
|
+
'Rules for redirecting based on response data. The key is a unique identifier for the rule.',
|
|
212
|
+
),
|
|
213
|
+
})
|
|
214
|
+
.describe('Schema defining an API request from a component or a page.')
|
|
215
|
+
|
|
216
|
+
const LegacyComponentAPISchema: z.ZodType<LegacyComponentAPI> = z
|
|
217
|
+
.object({
|
|
218
|
+
type: z.literal('REST'),
|
|
219
|
+
name: z.string(),
|
|
220
|
+
method: z.enum(['GET', 'POST', 'DELETE', 'PUT']),
|
|
221
|
+
url: FormulaSchema.nullish(),
|
|
222
|
+
path: z.array(z.object({ formula: FormulaSchema })).nullish(),
|
|
223
|
+
queryParams: z
|
|
224
|
+
.record(
|
|
225
|
+
z.string(),
|
|
226
|
+
z.object({
|
|
227
|
+
name: z.string(),
|
|
228
|
+
formula: FormulaSchema,
|
|
229
|
+
}),
|
|
230
|
+
)
|
|
231
|
+
.nullish(),
|
|
232
|
+
headers: z
|
|
233
|
+
.union([z.record(z.string(), FormulaSchema), FormulaSchema])
|
|
234
|
+
.nullish(),
|
|
235
|
+
body: FormulaSchema.nullish(),
|
|
236
|
+
autoFetch: FormulaSchema.nullish(),
|
|
237
|
+
proxy: z.boolean().nullish(),
|
|
238
|
+
debounce: z.number().nullish(),
|
|
239
|
+
throttle: z.number().nullish(),
|
|
240
|
+
onCompleted: EventModelSchema.nullish(),
|
|
241
|
+
onFailed: EventModelSchema.nullish(),
|
|
242
|
+
auth: z
|
|
243
|
+
.object({
|
|
244
|
+
type: z.enum(['Bearer id_token', 'Bearer access_token']),
|
|
245
|
+
})
|
|
246
|
+
.nullish(),
|
|
247
|
+
})
|
|
248
|
+
.describe(
|
|
249
|
+
'Legacy API schema for backward compatibility. Never use this for new APIs.',
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
export const ComponentAPISchema: z.ZodType<ComponentAPI> = z.union([
|
|
253
|
+
LegacyComponentAPISchema,
|
|
254
|
+
ApiRequestSchema,
|
|
255
|
+
])
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { ComponentAttribute } from '../component.types'
|
|
3
|
+
import { MetadataSchema, SCHEMA_DESCRIPTIONS } from './zod-schemas'
|
|
4
|
+
|
|
5
|
+
export const ComponentAttributeSchema: z.ZodType<ComponentAttribute> = z
|
|
6
|
+
.object({
|
|
7
|
+
'@nordcraft/metadata': MetadataSchema.nullish().describe(
|
|
8
|
+
SCHEMA_DESCRIPTIONS.metadata('component attribute'),
|
|
9
|
+
),
|
|
10
|
+
name: z.string().describe('Name of the component attribute'),
|
|
11
|
+
testValue: z
|
|
12
|
+
.any()
|
|
13
|
+
.describe(SCHEMA_DESCRIPTIONS.testData('component attribute')),
|
|
14
|
+
})
|
|
15
|
+
.describe('Schema for a component attribute.')
|