@datasworn-community/build-tools 0.2.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 +17 -0
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +10 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/datasworn-build.d.ts +3 -0
- package/dist/cli/datasworn-build.d.ts.map +1 -0
- package/dist/cli/datasworn-build.js +33 -0
- package/dist/cli/datasworn-build.js.map +1 -0
- package/dist/cli/datasworn-migrate.d.ts +3 -0
- package/dist/cli/datasworn-migrate.d.ts.map +1 -0
- package/dist/cli/datasworn-migrate.js +26 -0
- package/dist/cli/datasworn-migrate.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/rules-package-builder.d.ts +22 -0
- package/dist/rules-package-builder.d.ts.map +1 -0
- package/dist/rules-package-builder.js +84 -0
- package/dist/rules-package-builder.js.map +1 -0
- package/dist/schema.d.ts +8 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +18 -0
- package/dist/schema.js.map +1 -0
- package/dist/validators.d.ts +8 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +35 -0
- package/dist/validators.js.map +1 -0
- package/package.json +60 -0
- package/schema-source/schema/Assets.ts +66 -0
- package/schema-source/schema/Atlas.ts +20 -0
- package/schema-source/schema/Defs.ts +126 -0
- package/schema-source/schema/DelveSites.ts +3 -0
- package/schema-source/schema/Entities.ts +1 -0
- package/schema-source/schema/Generic.ts +18 -0
- package/schema-source/schema/Moves.ts +1 -0
- package/schema-source/schema/Npcs.ts +80 -0
- package/schema-source/schema/Oracles.ts +20 -0
- package/schema-source/schema/Rarities.ts +36 -0
- package/schema-source/schema/Root.ts +94 -0
- package/schema-source/schema/Rules.ts +61 -0
- package/schema-source/schema/RulesPackages.ts +135 -0
- package/schema-source/schema/Symbols.ts +30 -0
- package/schema-source/schema/Truths.ts +53 -0
- package/schema-source/schema/Utils.ts +21 -0
- package/schema-source/schema/assets/Ability.ts +79 -0
- package/schema-source/schema/assets/Enhancement.ts +62 -0
- package/schema-source/schema/assets/Fields.ts +285 -0
- package/schema-source/schema/assets/common.ts +29 -0
- package/schema-source/schema/common/Fields.ts +327 -0
- package/schema-source/schema/common/Id.ts +64 -0
- package/schema-source/schema/common/Inputs.ts +374 -0
- package/schema-source/schema/common/Metadata.ts +142 -0
- package/schema-source/schema/common/Player.ts +17 -0
- package/schema-source/schema/common/Progress.ts +63 -0
- package/schema-source/schema/common/Range.ts +53 -0
- package/schema-source/schema/common/RollableValues.ts +152 -0
- package/schema-source/schema/common/Rolls.ts +108 -0
- package/schema-source/schema/common/Text.ts +95 -0
- package/schema-source/schema/common/index.ts +16 -0
- package/schema-source/schema/delve/DelveSite.ts +121 -0
- package/schema-source/schema/delve/DelveSiteDomain.ts +136 -0
- package/schema-source/schema/delve/DelveSiteTheme.ts +97 -0
- package/schema-source/schema/delve/common.ts +32 -0
- package/schema-source/schema/entities/EntityPrompt.ts +13 -0
- package/schema-source/schema/entities/index.ts +1 -0
- package/schema-source/schema/generic/CollectableNode.ts +75 -0
- package/schema-source/schema/generic/CollectionNode.ts +145 -0
- package/schema-source/schema/generic/Dictionary.ts +39 -0
- package/schema-source/schema/generic/EmbedOnlyNode.ts +19 -0
- package/schema-source/schema/generic/Enhance.ts +38 -0
- package/schema-source/schema/generic/IdNode.ts +40 -0
- package/schema-source/schema/generic/Mixin.ts +11 -0
- package/schema-source/schema/generic/NonCollectableNode.ts +38 -0
- package/schema-source/schema/generic/PrimaryTypeNode.ts +115 -0
- package/schema-source/schema/generic/SourcedNode.ts +51 -0
- package/schema-source/schema/index.ts +23 -0
- package/schema-source/schema/moves/ActionRoll.ts +152 -0
- package/schema-source/schema/moves/EmbeddedMove.ts +24 -0
- package/schema-source/schema/moves/Move.ts +26 -0
- package/schema-source/schema/moves/MoveCategory.ts +6 -0
- package/schema-source/schema/moves/MoveEnhancement.ts +29 -0
- package/schema-source/schema/moves/ProgressRoll.ts +184 -0
- package/schema-source/schema/moves/Trigger.ts +193 -0
- package/schema-source/schema/moves/common.ts +136 -0
- package/schema-source/schema/moves/index.ts +13 -0
- package/schema-source/schema/moves/utils.ts +132 -0
- package/schema-source/schema/object_type/ObjectType.ts +23 -0
- package/schema-source/schema/oracles/EmbeddedOracleRollable.ts +28 -0
- package/schema-source/schema/oracles/OracleCollection.ts +140 -0
- package/schema-source/schema/oracles/OracleRollable.ts +207 -0
- package/schema-source/schema/oracles/Table.ts +94 -0
- package/schema-source/schema/oracles/TableRow.ts +141 -0
- package/schema-source/schema/root/NiceSchema.ts +15 -0
- package/schema-source/schema/root/Root.ts +41 -0
- package/schema-source/schema/root/SchemaTransform.ts +89 -0
- package/schema-source/schema/root/SourceData.ts +151 -0
- package/schema-source/schema/rules/ConditionMeterRule.ts +25 -0
- package/schema-source/schema/rules/ImpactRule.ts +54 -0
- package/schema-source/schema/rules/SpecialTrackRule.ts +29 -0
- package/schema-source/schema/rules/StatRule.ts +23 -0
- package/schema-source/schema/rules/TagRule.ts +176 -0
- package/schema-source/schema/rules/TagSchema.ts +161 -0
- package/schema-source/schema/tags/canonicalTags.ts +29 -0
- package/schema-source/schema/tools/build/index.ts +48 -0
- package/schema-source/schema/tools/i18n/index.ts +9 -0
- package/schema-source/schema/utils/Computed.ts +82 -0
- package/schema-source/schema/utils/DiscriminatedUnion.ts +255 -0
- package/schema-source/schema/utils/EmbeddedNode.ts +172 -0
- package/schema-source/schema/utils/ExtractLiteralFromEnum.ts +22 -0
- package/schema-source/schema/utils/FlatIntersect.ts +107 -0
- package/schema-source/schema/utils/IfThen.ts +50 -0
- package/schema-source/schema/utils/MergeEnumSchemas.ts +16 -0
- package/schema-source/schema/utils/NonNullable.ts +6 -0
- package/schema-source/schema/utils/Nullable.ts +29 -0
- package/schema-source/schema/utils/ObjectLiteral.ts +16 -0
- package/schema-source/schema/utils/ObjectProperties.ts +4 -0
- package/schema-source/schema/utils/OmitMeta.ts +22 -0
- package/schema-source/schema/utils/OmitOptional.ts +27 -0
- package/schema-source/schema/utils/PartialExcept.ts +26 -0
- package/schema-source/schema/utils/SetNullable.ts +44 -0
- package/schema-source/schema/utils/SetOptional.ts +48 -0
- package/schema-source/schema/utils/UnionEnum.ts +82 -0
- package/schema-source/schema/utils/UnionEnumFromRecord.ts +36 -0
- package/schema-source/schema/utils/UnionOneOf.ts +80 -0
- package/schema-source/schema/utils/generateRulesetSchemas.ts +204 -0
- package/schema-source/schema/utils/string.ts +15 -0
- package/schema-source/schema/utils/typebox.ts +141 -0
- package/schema-source/scripts/const.ts +55 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ObjectOptions,
|
|
3
|
+
type Static,
|
|
4
|
+
type TLiteral,
|
|
5
|
+
type TObject,
|
|
6
|
+
type TRefUnsafe,
|
|
7
|
+
type TSchema,
|
|
8
|
+
Type
|
|
9
|
+
} from '@sinclair/typebox'
|
|
10
|
+
import { mapValues } from 'lodash-es'
|
|
11
|
+
import { Mapping } from '../Symbols.js'
|
|
12
|
+
import * as Utils from '../Utils.js'
|
|
13
|
+
import { Assign } from '../utils/FlatIntersect.js'
|
|
14
|
+
import * as Base from './Inputs.js'
|
|
15
|
+
import * as Metadata from './Metadata.js'
|
|
16
|
+
import { RollableValue } from './RollableValues.js'
|
|
17
|
+
|
|
18
|
+
export const EnhanceableProperties = Symbol('EnhanceableProperties')
|
|
19
|
+
|
|
20
|
+
/** The standard discriminator key for input fields. */
|
|
21
|
+
export const DISCRIMINATOR = 'field_type' as const
|
|
22
|
+
|
|
23
|
+
/** Wraps basic inputs with a descriminator and optional icon for use in discriminated union input fields. */
|
|
24
|
+
function InputField<T extends Base.TInput<TSchema>, V extends string>(
|
|
25
|
+
base: T,
|
|
26
|
+
type: V,
|
|
27
|
+
options: ObjectOptions = {}
|
|
28
|
+
) {
|
|
29
|
+
const { description, remarks } = base
|
|
30
|
+
|
|
31
|
+
const mixin = Type.Object({
|
|
32
|
+
[DISCRIMINATOR]: Type.Literal(type),
|
|
33
|
+
icon: Type.Optional(
|
|
34
|
+
Type.Ref(Metadata.SvgImageUrl, {
|
|
35
|
+
description: 'An icon associated with this input.'
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const result = Assign(base, mixin, {
|
|
41
|
+
description,
|
|
42
|
+
remarks,
|
|
43
|
+
[EnhanceableProperties]: [] as Array<keyof Static<T>>,
|
|
44
|
+
...options
|
|
45
|
+
}) as unknown as TInputField<T, V>
|
|
46
|
+
|
|
47
|
+
// const result = Generic.IdentifiedNode(
|
|
48
|
+
// id,
|
|
49
|
+
// Assign(base, mixin) as unknown as TObject<
|
|
50
|
+
// T['properties'] & {
|
|
51
|
+
// [DISCRIMINATOR]: TLiteral<Discriminator>
|
|
52
|
+
// _id:Id.TAnyId
|
|
53
|
+
// }
|
|
54
|
+
// >,
|
|
55
|
+
// {
|
|
56
|
+
// description,
|
|
57
|
+
// $comment,
|
|
58
|
+
// [EnhanceableProperties]: [] as Array<keyof Static<T>>,
|
|
59
|
+
// ...options
|
|
60
|
+
// }
|
|
61
|
+
// ) as unknown as TInputField<T, Discriminator>
|
|
62
|
+
|
|
63
|
+
return result
|
|
64
|
+
}
|
|
65
|
+
export type TInputField<
|
|
66
|
+
T extends Base.TInput<TSchema>,
|
|
67
|
+
Discriminator extends string
|
|
68
|
+
> = TObject<
|
|
69
|
+
// Generic.TIdentifiedNode<
|
|
70
|
+
T['properties'] & {
|
|
71
|
+
[DISCRIMINATOR]: TLiteral<Discriminator>
|
|
72
|
+
// _id:Id.TAnyId
|
|
73
|
+
}
|
|
74
|
+
> & {
|
|
75
|
+
// >
|
|
76
|
+
[EnhanceableProperties]: Array<keyof Static<T>>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ReturnType<typeof InputField<T, Discriminator>> & InputFieldOptions<T>
|
|
80
|
+
|
|
81
|
+
export type InputField<T extends Base.Input<any>, V extends string> = Assign<
|
|
82
|
+
T,
|
|
83
|
+
{
|
|
84
|
+
[DISCRIMINATOR]: V
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
|
|
88
|
+
export function isEnhanceable(
|
|
89
|
+
field: TInputField<Base.TInput<TSchema>, string>
|
|
90
|
+
) {
|
|
91
|
+
return !!field[EnhanceableProperties].length
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// export function CounterField(
|
|
95
|
+
// // _id:Id.TAnyId,
|
|
96
|
+
// options: ObjectOptions = {}
|
|
97
|
+
// ) {
|
|
98
|
+
// return InputField(
|
|
99
|
+
// Base.Counter,
|
|
100
|
+
// 'counter',
|
|
101
|
+
// // id,
|
|
102
|
+
// {
|
|
103
|
+
// [EnhanceableProperties]: ['max'],
|
|
104
|
+
// title: 'CounterField',
|
|
105
|
+
// ...options
|
|
106
|
+
// }
|
|
107
|
+
// )
|
|
108
|
+
// }
|
|
109
|
+
export const CounterField = InputField(Base.Counter, 'counter', {
|
|
110
|
+
[EnhanceableProperties]: ['max'],
|
|
111
|
+
$id: 'CounterField'
|
|
112
|
+
})
|
|
113
|
+
export type TCounterField = typeof CounterField
|
|
114
|
+
export type CounterField = Static<TCounterField>
|
|
115
|
+
|
|
116
|
+
// }
|
|
117
|
+
export const ClockField = InputField(Base.Clock, 'clock', {
|
|
118
|
+
[EnhanceableProperties]: ['max'],
|
|
119
|
+
$id: 'ClockField'
|
|
120
|
+
})
|
|
121
|
+
export type TClockField = typeof ClockField
|
|
122
|
+
export type ClockField = Static<TClockField>
|
|
123
|
+
|
|
124
|
+
export const ConditionMeterField = InputField(
|
|
125
|
+
Base.Meter(Type.Literal(true)),
|
|
126
|
+
'condition_meter',
|
|
127
|
+
{
|
|
128
|
+
[EnhanceableProperties]: ['max'],
|
|
129
|
+
$id: 'ConditionMeterField'
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
export type TConditionMeterField = typeof ConditionMeterField
|
|
133
|
+
export type ConditionMeterField = Static<TConditionMeterField>
|
|
134
|
+
|
|
135
|
+
function SelectField<
|
|
136
|
+
Choice extends TRefUnsafe<TObject>,
|
|
137
|
+
Discriminator extends string
|
|
138
|
+
>(choiceSchema: Choice, type: Discriminator, options: ObjectOptions = {}) {
|
|
139
|
+
return InputField(
|
|
140
|
+
Base.Select(choiceSchema),
|
|
141
|
+
type,
|
|
142
|
+
// id,
|
|
143
|
+
options
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function SelectFieldWithGroups<
|
|
148
|
+
Choice extends Base.TSelectChoice<TObject>,
|
|
149
|
+
Discriminator extends string
|
|
150
|
+
>(
|
|
151
|
+
choiceSchema: Choice,
|
|
152
|
+
choiceGroupSchema: Base.TSelectChoicesGroup<TRefUnsafe<Choice>>,
|
|
153
|
+
type: Discriminator,
|
|
154
|
+
// _id:Id.TAnyId,
|
|
155
|
+
options: ObjectOptions = {}
|
|
156
|
+
) {
|
|
157
|
+
return InputField(
|
|
158
|
+
Base.SelectWithGroups(choiceSchema, choiceGroupSchema),
|
|
159
|
+
type,
|
|
160
|
+
// id,
|
|
161
|
+
options
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const SelectValueFieldChoice = Utils.DiscriminatedUnion(
|
|
166
|
+
mapValues(RollableValue[Mapping], (v) => Base.SelectOption(v)),
|
|
167
|
+
'using',
|
|
168
|
+
{ $id: 'SelectValueFieldChoice' }
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
export type SelectValueFieldChoice = {
|
|
172
|
+
label: string
|
|
173
|
+
choice_type: 'choice'
|
|
174
|
+
}
|
|
175
|
+
export type TSelectValueFieldChoice = typeof SelectValueFieldChoice
|
|
176
|
+
|
|
177
|
+
// export function SelectValueField(
|
|
178
|
+
// // _id:Id.TAnyId,
|
|
179
|
+
// options: ObjectOptions = {}
|
|
180
|
+
// ) {
|
|
181
|
+
// return SelectField(
|
|
182
|
+
// Type.Ref(SelectValueFieldChoice),
|
|
183
|
+
// 'select_value',
|
|
184
|
+
// // id,
|
|
185
|
+
// {
|
|
186
|
+
// ...options
|
|
187
|
+
// }
|
|
188
|
+
// )
|
|
189
|
+
// }
|
|
190
|
+
|
|
191
|
+
export const SelectValueField = SelectField(
|
|
192
|
+
Type.Ref(SelectValueFieldChoice),
|
|
193
|
+
'select_value',
|
|
194
|
+
// id,
|
|
195
|
+
{
|
|
196
|
+
$id: 'SelectValueField'
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
export type TSelectValueField = typeof SelectValueField
|
|
200
|
+
export type SelectValueField = Static<TSelectValueField>
|
|
201
|
+
|
|
202
|
+
export const SelectEnhancementFieldChoice = Base.SelectOption(
|
|
203
|
+
Type.Partial(
|
|
204
|
+
Type.Object({
|
|
205
|
+
enhance_asset: Type.Ref('AssetEnhancement'),
|
|
206
|
+
// TODO
|
|
207
|
+
// enhance_player: Type.Object({}, { description: 'NYI' }),
|
|
208
|
+
enhance_moves: Type.Array(Type.Ref('MoveEnhancement'))
|
|
209
|
+
})
|
|
210
|
+
),
|
|
211
|
+
{ $id: 'SelectEnhancementFieldChoice' }
|
|
212
|
+
)
|
|
213
|
+
export const SelectEnhancementFieldChoiceGroup = Base.SelectChoicesGroup(
|
|
214
|
+
Type.Ref(SelectEnhancementFieldChoice),
|
|
215
|
+
{
|
|
216
|
+
$id: 'SelectEnhancementFieldChoiceGroup'
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
// export function SelectEnhancementField(
|
|
221
|
+
// // _id:Id.TAnyId,
|
|
222
|
+
// options: ObjectOptions = {}
|
|
223
|
+
// ) {
|
|
224
|
+
// return SelectFieldWithGroups(
|
|
225
|
+
// SelectEnhancementFieldChoice,
|
|
226
|
+
// SelectEnhancementFieldChoiceGroup,
|
|
227
|
+
// 'select_enhancement',
|
|
228
|
+
// // id,
|
|
229
|
+
// {
|
|
230
|
+
// description:
|
|
231
|
+
// 'Select from player and/or asset enhancements. Use it to describe modal abilities. For examples, see Ironclad (classic Ironsworn) and Windbinder (Sundered Isles).',
|
|
232
|
+
// ...options
|
|
233
|
+
// }
|
|
234
|
+
// )
|
|
235
|
+
// }
|
|
236
|
+
export const SelectEnhancementField = SelectFieldWithGroups(
|
|
237
|
+
SelectEnhancementFieldChoice,
|
|
238
|
+
SelectEnhancementFieldChoiceGroup,
|
|
239
|
+
'select_enhancement',
|
|
240
|
+
// id,
|
|
241
|
+
{
|
|
242
|
+
description:
|
|
243
|
+
'Select from player and/or asset enhancements. Use it to describe modal abilities. For examples, see Ironclad (classic Ironsworn) and Windbinder (Sundered Isles).',
|
|
244
|
+
$id: 'SelectEnhancementField'
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
export type TSelectEnhancementField = typeof SelectEnhancementField
|
|
248
|
+
export type SelectEnhancementField = Static<TSelectEnhancementField>
|
|
249
|
+
|
|
250
|
+
// export function CardFlipField(
|
|
251
|
+
// // _id:Id.TAnyId,
|
|
252
|
+
// options: ObjectOptions = {}
|
|
253
|
+
// ) {
|
|
254
|
+
// return InputField(
|
|
255
|
+
// Base.Input(
|
|
256
|
+
// Type.Boolean({ description: 'Is the card flipped over?', default: false })
|
|
257
|
+
// ),
|
|
258
|
+
// 'card_flip',
|
|
259
|
+
// // id,
|
|
260
|
+
// {
|
|
261
|
+
// title: 'CardFlipField',
|
|
262
|
+
// description: `When its value is set to \`true\` it means that the card is flipped over. Some assets use this to represent a 'broken' state (e.g. Starforged Module assets).`,
|
|
263
|
+
// ...options
|
|
264
|
+
// }
|
|
265
|
+
// )
|
|
266
|
+
// }
|
|
267
|
+
// export type TCardFlipField = ReturnType<typeof CardFlipField>
|
|
268
|
+
// export type CardFlipField = Static<TCardFlipField>
|
|
269
|
+
|
|
270
|
+
export const CardFlipField = InputField(
|
|
271
|
+
Base.Input(
|
|
272
|
+
Type.Boolean({ description: 'Is the card flipped over?', default: false })
|
|
273
|
+
),
|
|
274
|
+
'card_flip',
|
|
275
|
+
// id,
|
|
276
|
+
{
|
|
277
|
+
title: 'CardFlipField',
|
|
278
|
+
description: `When its value is set to \`true\` it means that the card is flipped over. Some assets use this to represent a 'broken' state (e.g. Starforged Module assets).`
|
|
279
|
+
// ...options
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
export type TCardFlipField = typeof CardFlipField
|
|
284
|
+
export type CardFlipField = Static<TCardFlipField>
|
|
285
|
+
|
|
286
|
+
// export function CheckboxField(
|
|
287
|
+
// // _id:Id.TAnyId,
|
|
288
|
+
// options: ObjectOptions = {}
|
|
289
|
+
// ) {
|
|
290
|
+
// return InputField(
|
|
291
|
+
// Base.Checkbox,
|
|
292
|
+
// 'checkbox',
|
|
293
|
+
// // id,
|
|
294
|
+
// {
|
|
295
|
+
// title: 'CheckboxField',
|
|
296
|
+
// ...options
|
|
297
|
+
// }
|
|
298
|
+
// )
|
|
299
|
+
// }
|
|
300
|
+
// export type TCheckboxField = ReturnType<typeof CheckboxField>
|
|
301
|
+
export const CheckboxField = InputField(Base.Checkbox, 'checkbox', {
|
|
302
|
+
$id: 'CheckboxField'
|
|
303
|
+
})
|
|
304
|
+
export type TCheckboxField = typeof CheckboxField
|
|
305
|
+
export type CheckboxField = Static<TCheckboxField>
|
|
306
|
+
|
|
307
|
+
// export function TextField(
|
|
308
|
+
// // _id:Id.TAnyId,
|
|
309
|
+
// options: ObjectOptions = {}
|
|
310
|
+
// ) {
|
|
311
|
+
// return InputField(
|
|
312
|
+
// Base.TextInput,
|
|
313
|
+
// 'text',
|
|
314
|
+
// // id,
|
|
315
|
+
// {
|
|
316
|
+
// title: 'TextField',
|
|
317
|
+
// ...options
|
|
318
|
+
// }
|
|
319
|
+
// )
|
|
320
|
+
// }
|
|
321
|
+
// export type TTextField = ReturnType<typeof TextField>
|
|
322
|
+
// export type TextField = Static<TTextField>
|
|
323
|
+
export const TextField = InputField(Base.TextInput, 'text', {
|
|
324
|
+
$id: 'TextField'
|
|
325
|
+
})
|
|
326
|
+
export type TTextField = typeof TextField
|
|
327
|
+
export type TextField = Static<TTextField>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Static,
|
|
3
|
+
type TRef,
|
|
4
|
+
type TRefUnsafe,
|
|
5
|
+
type TString,
|
|
6
|
+
type TUnion,
|
|
7
|
+
Type
|
|
8
|
+
} from '@sinclair/typebox'
|
|
9
|
+
|
|
10
|
+
import ids from '../../builders/IdBuilder.js'
|
|
11
|
+
import Pattern from '../../pkg-core/IdElements/Pattern.js'
|
|
12
|
+
import JtdType from '../../scripts/json-typedef/typedef.js'
|
|
13
|
+
import { JsonTypeDef } from '../Symbols.js'
|
|
14
|
+
|
|
15
|
+
export const RulesetId = Type.String({
|
|
16
|
+
$id: 'RulesetId',
|
|
17
|
+
examples: ['classic', 'starforged'],
|
|
18
|
+
pattern: Pattern.RulesPackageId.source,
|
|
19
|
+
description:
|
|
20
|
+
'The ID of standalone Datasworn package that describes its own ruleset.'
|
|
21
|
+
})
|
|
22
|
+
export type RulesetId = Static<typeof RulesetId>
|
|
23
|
+
|
|
24
|
+
export const ExpansionId = Type.String({
|
|
25
|
+
$id: 'ExpansionId',
|
|
26
|
+
examples: ['delve', 'sundered_isles'],
|
|
27
|
+
pattern: Pattern.RulesPackageId.source,
|
|
28
|
+
description:
|
|
29
|
+
'The ID of a Datasworn package that relies on an external package to provide its ruleset.'
|
|
30
|
+
})
|
|
31
|
+
export type ExpansionId = Static<typeof ExpansionId>
|
|
32
|
+
|
|
33
|
+
export const RulesPackageId = Type.Union(
|
|
34
|
+
[Type.Ref(RulesetId), Type.Ref(ExpansionId)],
|
|
35
|
+
{
|
|
36
|
+
$id: 'RulesPackageId',
|
|
37
|
+
[JsonTypeDef]: { schema: JtdType.String() }
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
export const DictKey = Type.String({
|
|
42
|
+
$id: 'DictKey',
|
|
43
|
+
pattern: Pattern.DictKey.source,
|
|
44
|
+
description: 'A `snake_case` key used in a Datasworn dictionary object.',
|
|
45
|
+
remarks:
|
|
46
|
+
"If you need to generate a key from a user-provided label, it's recommended to use a 'slugify' function/library, e.g. https://www.npmjs.com/package/slugify for NodeJS."
|
|
47
|
+
})
|
|
48
|
+
export type DictKey = Static<typeof DictKey>
|
|
49
|
+
|
|
50
|
+
const Id = {
|
|
51
|
+
RulesetId,
|
|
52
|
+
ExpansionId,
|
|
53
|
+
RulesPackageId,
|
|
54
|
+
DictKey,
|
|
55
|
+
...ids
|
|
56
|
+
} as const
|
|
57
|
+
|
|
58
|
+
export default Id
|
|
59
|
+
|
|
60
|
+
export type TAnyId =
|
|
61
|
+
| TRef<string>
|
|
62
|
+
| TRefUnsafe<TString>
|
|
63
|
+
| TRefUnsafe<TString | TUnion<TRef<string>[]>>
|
|
64
|
+
| TUnion<TRef<string>[]>
|