@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,374 @@
|
|
|
1
|
+
/** Abstract inputs that are used by option and control fields. */
|
|
2
|
+
import {
|
|
3
|
+
type ObjectOptions,
|
|
4
|
+
type Static,
|
|
5
|
+
type TInteger,
|
|
6
|
+
type TLiteral,
|
|
7
|
+
type TObject,
|
|
8
|
+
type TRefUnsafe,
|
|
9
|
+
type TSchema,
|
|
10
|
+
type TString,
|
|
11
|
+
Type
|
|
12
|
+
} from '@sinclair/typebox'
|
|
13
|
+
import JtdType from '../../scripts/json-typedef/typedef.js'
|
|
14
|
+
import * as Generic from '../Generic.js'
|
|
15
|
+
import { JsonTypeDef } from '../Symbols.js'
|
|
16
|
+
import * as Utils from '../Utils.js'
|
|
17
|
+
import { Assign } from '../utils/FlatIntersect.js'
|
|
18
|
+
import type { ObjectProperties } from '../utils/ObjectProperties.js'
|
|
19
|
+
import {
|
|
20
|
+
LiteralZero,
|
|
21
|
+
setDescriptions,
|
|
22
|
+
type TFuzzySchemaOf
|
|
23
|
+
} from '../utils/typebox.js'
|
|
24
|
+
import * as Text from './Text.js'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @abstract
|
|
28
|
+
*/
|
|
29
|
+
export function Input<Value extends TSchema>(
|
|
30
|
+
value: Value,
|
|
31
|
+
options: ObjectOptions = {}
|
|
32
|
+
) {
|
|
33
|
+
return Type.Object(
|
|
34
|
+
{
|
|
35
|
+
label: Type.Ref(Text.Label),
|
|
36
|
+
value: {
|
|
37
|
+
description: 'The current value of this input.',
|
|
38
|
+
...value
|
|
39
|
+
} as Value
|
|
40
|
+
},
|
|
41
|
+
options
|
|
42
|
+
) satisfies TInput<Value>
|
|
43
|
+
}
|
|
44
|
+
export type TInput<Value extends TSchema> = TObject<{
|
|
45
|
+
label: TRefUnsafe<TString>
|
|
46
|
+
value: Value
|
|
47
|
+
}>
|
|
48
|
+
export interface Input<Value> {
|
|
49
|
+
label: string
|
|
50
|
+
value: Value
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Represents a range of number values with a minimum and a maximum.
|
|
55
|
+
* @template Min The schema of the minimum value
|
|
56
|
+
* @template Max The schema of the maximum value
|
|
57
|
+
* @abstract
|
|
58
|
+
*/
|
|
59
|
+
export function Range<
|
|
60
|
+
Min extends TFuzzySchemaOf<number>,
|
|
61
|
+
Max extends TFuzzySchemaOf<number>
|
|
62
|
+
>({ min, max }: { min: Min; max: Max }, options: ObjectOptions = {}) {
|
|
63
|
+
return setDescriptions(
|
|
64
|
+
Type.Object({ min, max }, options),
|
|
65
|
+
{
|
|
66
|
+
min: 'The (inclusive) minimum value.',
|
|
67
|
+
max: 'The (inclusive) maximum value.'
|
|
68
|
+
},
|
|
69
|
+
false
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
export type TRange<
|
|
73
|
+
Min extends TFuzzySchemaOf<number> = TFuzzySchemaOf<number>,
|
|
74
|
+
Max extends TFuzzySchemaOf<number> = TFuzzySchemaOf<number>
|
|
75
|
+
> = TObject<{ min: Min; max: Max }>
|
|
76
|
+
export interface Range<
|
|
77
|
+
Min extends number | null = number | null,
|
|
78
|
+
Max extends number | null = number | null
|
|
79
|
+
> {
|
|
80
|
+
min: Min
|
|
81
|
+
max: Max
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function IntegerInput<
|
|
85
|
+
Min extends TFuzzySchemaOf<number>,
|
|
86
|
+
Max extends TFuzzySchemaOf<number>,
|
|
87
|
+
Rollable extends TLiteral<boolean>
|
|
88
|
+
>(
|
|
89
|
+
{ min, max, rollable }: { min: Min; max: Max; rollable: Rollable },
|
|
90
|
+
options: ObjectOptions = {}
|
|
91
|
+
) {
|
|
92
|
+
const mixin = Assign(
|
|
93
|
+
Input(
|
|
94
|
+
Type.Integer({ default: 0, [JsonTypeDef]: { schema: JtdType.Int8() } })
|
|
95
|
+
),
|
|
96
|
+
Range({
|
|
97
|
+
min: { [JsonTypeDef]: { schema: JtdType.Int8() }, ...min },
|
|
98
|
+
max: { [JsonTypeDef]: { schema: JtdType.Int8() }, ...max }
|
|
99
|
+
})
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return Assign(
|
|
103
|
+
mixin,
|
|
104
|
+
Type.Object({
|
|
105
|
+
rollable: {
|
|
106
|
+
[JsonTypeDef]: { schema: JtdType.Boolean() },
|
|
107
|
+
default: rollable.const,
|
|
108
|
+
...rollable
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
|
|
112
|
+
options
|
|
113
|
+
) as unknown as TIntegerInput<Min, Max, Rollable>
|
|
114
|
+
}
|
|
115
|
+
export type TIntegerInput<
|
|
116
|
+
Min extends TFuzzySchemaOf<number> = TFuzzySchemaOf<number>,
|
|
117
|
+
Max extends TFuzzySchemaOf<number> = TFuzzySchemaOf<number>,
|
|
118
|
+
Rollable extends TLiteral<boolean> = TLiteral<boolean>
|
|
119
|
+
> = TObject<{
|
|
120
|
+
label: TRefUnsafe<TString>
|
|
121
|
+
min: Min
|
|
122
|
+
max: Max
|
|
123
|
+
rollable: Rollable
|
|
124
|
+
value: TInteger
|
|
125
|
+
}>
|
|
126
|
+
|
|
127
|
+
// TInput<TInteger> &
|
|
128
|
+
// TRange<Min, Max>
|
|
129
|
+
|
|
130
|
+
export const Counter: TIntegerInput<
|
|
131
|
+
TInteger,
|
|
132
|
+
Utils.TNullable<TInteger>,
|
|
133
|
+
TLiteral<false>
|
|
134
|
+
> = IntegerInput(
|
|
135
|
+
{
|
|
136
|
+
min: Type.Integer({ default: 0 }),
|
|
137
|
+
max: Utils.Nullable(Type.Integer(), {
|
|
138
|
+
default: null,
|
|
139
|
+
description:
|
|
140
|
+
"The (inclusive) maximum value, or `null` if there's no maximum."
|
|
141
|
+
}),
|
|
142
|
+
rollable: Type.Literal(false)
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
description:
|
|
146
|
+
'A basic counter representing a non-rollable integer value. They usually start at 0, and may or may not have a maximum.',
|
|
147
|
+
remarks: 'Semantics are similar to `<input type="number" step="1">`'
|
|
148
|
+
}
|
|
149
|
+
) satisfies TInput<TInteger>
|
|
150
|
+
|
|
151
|
+
export type TCounter = typeof Counter
|
|
152
|
+
|
|
153
|
+
export type Counter = Static<TCounter>
|
|
154
|
+
|
|
155
|
+
// value: 'The current number of filled clock segments.',
|
|
156
|
+
export const Clock = IntegerInput(
|
|
157
|
+
{
|
|
158
|
+
min: {
|
|
159
|
+
...LiteralZero,
|
|
160
|
+
description:
|
|
161
|
+
'The minimum number of filled clock segments. This is always 0.'
|
|
162
|
+
} as TLiteral<0>,
|
|
163
|
+
max: Type.Integer({
|
|
164
|
+
title: 'ClockSize',
|
|
165
|
+
multipleOf: 2,
|
|
166
|
+
minimum: 2,
|
|
167
|
+
// examples: [4, 6, 8, 10],
|
|
168
|
+
description:
|
|
169
|
+
'The size of the clock -- in other words, the maximum number of filled clock segments. Standard clocks have 4, 6, 8, or 10 segments.'
|
|
170
|
+
}),
|
|
171
|
+
rollable: Type.Literal(false)
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
description: 'A clock with 4 or more segments.',
|
|
175
|
+
remarks:
|
|
176
|
+
'Semantics are similar to HTML `<input type="number">`, but rendered as a clock (a circle with equally sized wedges).'
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
export type TClock = typeof Clock
|
|
180
|
+
export type Clock = Static<typeof Clock>
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A meter with an integer value, bounded by a minimum and maximum
|
|
184
|
+
* @abstract
|
|
185
|
+
*/
|
|
186
|
+
export function Meter<Rollable extends TLiteral<boolean>>(
|
|
187
|
+
rollable: Rollable,
|
|
188
|
+
options: ObjectOptions = {}
|
|
189
|
+
) {
|
|
190
|
+
return setDescriptions(
|
|
191
|
+
IntegerInput(
|
|
192
|
+
{
|
|
193
|
+
min: Type.Integer({
|
|
194
|
+
default: 0,
|
|
195
|
+
description: 'The minimum value of this meter.'
|
|
196
|
+
}),
|
|
197
|
+
max: Type.Integer({ description: 'The maximum value of this meter.' }),
|
|
198
|
+
rollable: {
|
|
199
|
+
description:
|
|
200
|
+
"Is this meter's `value` usable as a stat in an action roll?",
|
|
201
|
+
...rollable
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
description:
|
|
206
|
+
'A meter with an integer value, bounded by a minimum and maximum.',
|
|
207
|
+
...options
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
{
|
|
211
|
+
value: 'The current value of this meter.'
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type TMeter<Rollable extends TLiteral<boolean> = TLiteral<boolean>> =
|
|
217
|
+
ReturnType<typeof Meter<Rollable>>
|
|
218
|
+
export type Meter<Rollable extends boolean = boolean> = Static<
|
|
219
|
+
TMeter<TLiteral<Rollable>>
|
|
220
|
+
>
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Represents a checkbox, similar to an HTML `<input type="checkbox">` element.
|
|
224
|
+
* @abstract
|
|
225
|
+
*/
|
|
226
|
+
export const Checkbox = Input(
|
|
227
|
+
Type.Boolean({ description: 'Is the box checked?', default: false }),
|
|
228
|
+
{
|
|
229
|
+
description: 'Represents a checkbox.',
|
|
230
|
+
remarks: 'Semantics are similar to the `<input type="checkbox">` element.'
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
export type Checkbox = Static<typeof Checkbox>
|
|
234
|
+
export type TCheckbox = typeof Checkbox
|
|
235
|
+
|
|
236
|
+
export const TextInput = Input(
|
|
237
|
+
Utils.Nullable(Type.String(), {
|
|
238
|
+
description: "The content of this text input, or `null` if it's empty",
|
|
239
|
+
default: null
|
|
240
|
+
}),
|
|
241
|
+
{
|
|
242
|
+
description: 'Represents an input that accepts plain text.',
|
|
243
|
+
remarks: 'Semantics are similar to the HTML `<input type="text">` element.'
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
export type TextInput = Static<typeof TextInput>
|
|
247
|
+
export type TTextInput = typeof TextInput
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Represents an option in a list of choices.
|
|
251
|
+
* @abstract
|
|
252
|
+
*/
|
|
253
|
+
const SelectOptionBase = Type.Object({
|
|
254
|
+
label: Type.Ref(Text.Label),
|
|
255
|
+
choice_type: Type.Literal('choice')
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
export function SelectOption<T extends TObject>(
|
|
259
|
+
schema: T,
|
|
260
|
+
options: ObjectOptions = {}
|
|
261
|
+
) {
|
|
262
|
+
return Assign(SelectOptionBase, schema, {
|
|
263
|
+
description: 'Represents an option in a list of choices.',
|
|
264
|
+
remarks: 'Semantics are similar to the HTML `<option>` element.',
|
|
265
|
+
...options
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
export type TSelectChoice<T extends TObject> = ReturnType<
|
|
269
|
+
typeof SelectOption<T>
|
|
270
|
+
>
|
|
271
|
+
export type SelectChoice<T extends object> = T & Static<typeof SelectOptionBase>
|
|
272
|
+
|
|
273
|
+
function Choices<T extends TSchema>(
|
|
274
|
+
choiceSchema: T,
|
|
275
|
+
options: ObjectOptions = {}
|
|
276
|
+
) {
|
|
277
|
+
return Type.Object(
|
|
278
|
+
{
|
|
279
|
+
choices: Generic.Dictionary(choiceSchema)
|
|
280
|
+
},
|
|
281
|
+
options
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
export type TChoices<T extends TSchema> = ReturnType<typeof Choices<T>>
|
|
285
|
+
export interface Choices<T> {
|
|
286
|
+
choices: Record<string, T>
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const SelectChoicesGroupBase = Type.Object({
|
|
290
|
+
name: Type.Ref(Text.Label, {
|
|
291
|
+
description: 'A label for this option group.'
|
|
292
|
+
}),
|
|
293
|
+
choice_type: Type.Literal('choice_group')
|
|
294
|
+
})
|
|
295
|
+
export function SelectChoicesGroup<
|
|
296
|
+
TOption extends TRefUnsafe<TSelectChoice<TObject>> | TSelectChoice<TObject>
|
|
297
|
+
>(optionSchema: TOption, options: ObjectOptions = {}) {
|
|
298
|
+
const mixin = Choices(optionSchema)
|
|
299
|
+
return Assign(SelectChoicesGroupBase, mixin, {
|
|
300
|
+
description: 'Represents a grouping of options in a list of choices.',
|
|
301
|
+
remarks: 'Semantics are similar to the HTML `<optgroup>` element.',
|
|
302
|
+
title: optionSchema.title ? `${optionSchema.title}Group` : undefined,
|
|
303
|
+
...options
|
|
304
|
+
}) as TObject<
|
|
305
|
+
ObjectProperties<typeof SelectChoicesGroupBase> &
|
|
306
|
+
ObjectProperties<typeof mixin>
|
|
307
|
+
>
|
|
308
|
+
}
|
|
309
|
+
export type TSelectChoicesGroup<
|
|
310
|
+
TOption extends TRefUnsafe<TSelectChoice<TObject>> | TSelectChoice<TObject>
|
|
311
|
+
> = ReturnType<typeof SelectChoicesGroup<TOption>>
|
|
312
|
+
|
|
313
|
+
export type SelectChoicesGroup<Option extends SelectChoice<any>> = Static<
|
|
314
|
+
typeof SelectChoicesGroupBase
|
|
315
|
+
> &
|
|
316
|
+
Choices<Option>
|
|
317
|
+
|
|
318
|
+
const SelectBase = Input(
|
|
319
|
+
Utils.Nullable(Type.Ref('DictKey'), {
|
|
320
|
+
description:
|
|
321
|
+
'The key of the currently selected choice from the `choices` property, or `null` if none is selected.',
|
|
322
|
+
default: null
|
|
323
|
+
})
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
export function SelectWithGroups<Option extends TSelectChoice<TObject>>(
|
|
327
|
+
choiceSchema: Option,
|
|
328
|
+
choicesGroupSchema: TSelectChoicesGroup<TRefUnsafe<Option> | Option>,
|
|
329
|
+
options: ObjectOptions = {}
|
|
330
|
+
) {
|
|
331
|
+
const mixin = Choices(
|
|
332
|
+
Utils.DiscriminatedUnion(
|
|
333
|
+
{
|
|
334
|
+
choice: choiceSchema,
|
|
335
|
+
choice_group: choicesGroupSchema
|
|
336
|
+
},
|
|
337
|
+
'choice_type'
|
|
338
|
+
)
|
|
339
|
+
)
|
|
340
|
+
return Assign(SelectBase, mixin, {
|
|
341
|
+
description: 'Represents a list of mutually exclusive choices.',
|
|
342
|
+
remarks: 'Semantics are similar to the HTML `<select>` element',
|
|
343
|
+
...options
|
|
344
|
+
}) as TObject<
|
|
345
|
+
ObjectProperties<typeof SelectBase> & ObjectProperties<typeof mixin>
|
|
346
|
+
>
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Represents a list of mutually exclusive choices.
|
|
351
|
+
* @remarks Semantics are similar to the HTML `<select>` element.
|
|
352
|
+
*/
|
|
353
|
+
export function Select<
|
|
354
|
+
Option extends TRefUnsafe<
|
|
355
|
+
| TSelectChoice<TObject>
|
|
356
|
+
| Utils.TDiscriminatedUnion<TSelectChoice<TObject>, string>
|
|
357
|
+
>
|
|
358
|
+
>(choiceSchema: Option, options: ObjectOptions = {}) {
|
|
359
|
+
const mixin = Choices(choiceSchema)
|
|
360
|
+
|
|
361
|
+
return Assign(SelectBase, mixin, {
|
|
362
|
+
description: 'Represents a list of mutually exclusive choices.',
|
|
363
|
+
remarks: 'Semantics are similar to the HTML `<select>` element',
|
|
364
|
+
...options
|
|
365
|
+
}) as TObject<
|
|
366
|
+
ObjectProperties<typeof SelectBase> & ObjectProperties<typeof mixin>
|
|
367
|
+
>
|
|
368
|
+
}
|
|
369
|
+
export type TSelect<Option extends TRefUnsafe<TSelectChoice<TObject>>> =
|
|
370
|
+
ReturnType<typeof Select<Option>>
|
|
371
|
+
export type Select<Option extends SelectChoice<any>> = Static<
|
|
372
|
+
typeof SelectBase
|
|
373
|
+
> &
|
|
374
|
+
Choices<Option>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { type Static, Type } from '@sinclair/typebox'
|
|
2
|
+
import JtdType from '../../scripts/json-typedef/typedef.js'
|
|
3
|
+
import { JsonTypeDef } from '../Symbols.js'
|
|
4
|
+
import { Nullable } from '../utils/Nullable.js'
|
|
5
|
+
import { Label } from './Text.js'
|
|
6
|
+
|
|
7
|
+
export const WebUrl = Type.String({
|
|
8
|
+
format: 'uri',
|
|
9
|
+
description: 'An absolute URL pointing to a website.',
|
|
10
|
+
$id: 'WebUrl'
|
|
11
|
+
})
|
|
12
|
+
export type WebUrl = Static<typeof WebUrl>
|
|
13
|
+
|
|
14
|
+
export const SvgImageUrl = Type.String({
|
|
15
|
+
pattern: /\.svg$/i.source,
|
|
16
|
+
$id: 'SvgImageUrl',
|
|
17
|
+
format: 'uri-reference',
|
|
18
|
+
description:
|
|
19
|
+
'A relative (local) URL pointing to a vector image in the SVG format.'
|
|
20
|
+
})
|
|
21
|
+
export type SvgImageUrl = Static<typeof SvgImageUrl>
|
|
22
|
+
export const WebpImageUrl = Type.String({
|
|
23
|
+
pattern: /\.webp$/i.source,
|
|
24
|
+
$id: 'WebpImageUrl',
|
|
25
|
+
format: 'uri-reference',
|
|
26
|
+
description:
|
|
27
|
+
'A relative (local) URL pointing to a raster image in the WEBP format.'
|
|
28
|
+
})
|
|
29
|
+
export type WebpImageUrl = Static<typeof WebpImageUrl>
|
|
30
|
+
export const CssColor = Type.String({
|
|
31
|
+
$id: 'CssColor',
|
|
32
|
+
remarks: 'See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value',
|
|
33
|
+
description: 'A CSS color value.'
|
|
34
|
+
})
|
|
35
|
+
export type CssColor = Static<typeof CssColor>
|
|
36
|
+
|
|
37
|
+
export const SemanticVersion = Type.String({
|
|
38
|
+
pattern:
|
|
39
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
40
|
+
.source,
|
|
41
|
+
$id: 'SemanticVersion'
|
|
42
|
+
})
|
|
43
|
+
export type SemanticVersion = Static<typeof SemanticVersion>
|
|
44
|
+
|
|
45
|
+
export const Email = Type.String({
|
|
46
|
+
format: 'email',
|
|
47
|
+
description: 'An email address.',
|
|
48
|
+
$id: 'Email'
|
|
49
|
+
})
|
|
50
|
+
export type Email = Static<typeof Email>
|
|
51
|
+
|
|
52
|
+
export const AuthorInfo = Type.Object(
|
|
53
|
+
{
|
|
54
|
+
name: Type.Ref(Label, {
|
|
55
|
+
description: 'The name of the author.',
|
|
56
|
+
examples: ['Shawn Tomkin']
|
|
57
|
+
}),
|
|
58
|
+
email: Type.Optional(
|
|
59
|
+
Type.Ref(Email, {
|
|
60
|
+
description: 'An optional email contact for the author'
|
|
61
|
+
})
|
|
62
|
+
),
|
|
63
|
+
url: Type.Optional(
|
|
64
|
+
Type.Ref(WebUrl, {
|
|
65
|
+
description: "An optional URL for the author's website."
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
examples: [{ name: 'Shawn Tomkin', url: 'https://ironswornrpg.com' }],
|
|
71
|
+
$id: 'AuthorInfo',
|
|
72
|
+
description: 'Information on the original creator of this material.'
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
export const PageNumber = Type.Integer({
|
|
77
|
+
minimum: 1,
|
|
78
|
+
description: 'Represents a page number in a book.',
|
|
79
|
+
$id: 'PageNumber',
|
|
80
|
+
[JsonTypeDef]: {
|
|
81
|
+
schema: Type.Optional(JtdType.Uint16())
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
export const SourceInfo = Type.Object(
|
|
86
|
+
{
|
|
87
|
+
title: Type.Ref(Label, {
|
|
88
|
+
description: 'The title of the source document.',
|
|
89
|
+
examples: [
|
|
90
|
+
'Ironsworn Rulebook',
|
|
91
|
+
'Ironsworn Assets Master Set',
|
|
92
|
+
'Ironsworn: Delve',
|
|
93
|
+
'Ironsworn: Starforged Rulebook',
|
|
94
|
+
'Ironsworn: Starforged Assets',
|
|
95
|
+
'Sundered Isles'
|
|
96
|
+
]
|
|
97
|
+
}),
|
|
98
|
+
page: Type.Optional(
|
|
99
|
+
Type.Ref(PageNumber, {
|
|
100
|
+
description: 'The page number where this content is described in full.'
|
|
101
|
+
})
|
|
102
|
+
),
|
|
103
|
+
authors: Type.Array(Type.Ref(AuthorInfo), {
|
|
104
|
+
minItems: 1,
|
|
105
|
+
description: 'Lists authors credited by the source material.'
|
|
106
|
+
}),
|
|
107
|
+
date: Type.String({
|
|
108
|
+
pattern: /[0-9]{4}-((0[0-9])|(1[0-2]))-(([0-2][0-9])|(3[0-1]))/.source,
|
|
109
|
+
format: 'date',
|
|
110
|
+
remarks: 'You may prefer to deserialize this as a Date object.',
|
|
111
|
+
[JsonTypeDef]: { schema: JtdType.String() },
|
|
112
|
+
description:
|
|
113
|
+
"The date of the source documents's last update, formatted YYYY-MM-DD. Required because it's used to determine whether the data needs updating."
|
|
114
|
+
}),
|
|
115
|
+
url: Type.Ref(WebUrl, {
|
|
116
|
+
description: 'A URL where the source document is available.',
|
|
117
|
+
examples: ['https://ironswornrpg.com']
|
|
118
|
+
}),
|
|
119
|
+
license: Nullable(Type.Ref(WebUrl), {
|
|
120
|
+
description:
|
|
121
|
+
"An URL pointing to the location where this content's license can be found.\n\nA `null` here indicates that the content provides __no__ license, and is not intended for redistribution.",
|
|
122
|
+
examples: [
|
|
123
|
+
'https://creativecommons.org/licenses/by/4.0',
|
|
124
|
+
'https://creativecommons.org/licenses/by-nc-sa/4.0'
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
description: 'Metadata describing the original source of this node',
|
|
130
|
+
$id: 'SourceInfo',
|
|
131
|
+
additionalProperties: true
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
export type SourceInfo = Static<typeof SourceInfo>
|
|
136
|
+
|
|
137
|
+
export const Suggestions = Type.Array(Type.Ref('AnyIdWildcard'), {
|
|
138
|
+
$id: 'Suggestions',
|
|
139
|
+
releaseStage: 'experimental'
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
export type Suggestions = Static<typeof Suggestions>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Static, Type } from '@sinclair/typebox'
|
|
2
|
+
import { DictKey } from './Id.js'
|
|
3
|
+
|
|
4
|
+
export const StatKey = Type.Ref(DictKey, {
|
|
5
|
+
examples: ['edge', 'heart', 'iron', 'shadow', 'wits'],
|
|
6
|
+
$id: 'StatKey',
|
|
7
|
+
description: 'A basic player character stat.'
|
|
8
|
+
})
|
|
9
|
+
export type StatKey = Static<typeof StatKey>
|
|
10
|
+
|
|
11
|
+
export const ConditionMeterKey = Type.Ref(DictKey, {
|
|
12
|
+
$id: 'ConditionMeterKey',
|
|
13
|
+
examples: ['health', 'spirit', 'supply'],
|
|
14
|
+
description:
|
|
15
|
+
'A basic, rollable player character resource specified by the ruleset.'
|
|
16
|
+
})
|
|
17
|
+
export type ConditionMeterKey = Static<typeof ConditionMeterKey>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Static, Type } from '@sinclair/typebox'
|
|
2
|
+
import * as Generic from '../Generic.js'
|
|
3
|
+
import { UnionEnumFromRecord } from '../utils/UnionEnumFromRecord.js'
|
|
4
|
+
import Id from './Id.js'
|
|
5
|
+
import * as Text from './Text.js'
|
|
6
|
+
|
|
7
|
+
export const ChallengeRank = UnionEnumFromRecord(
|
|
8
|
+
{
|
|
9
|
+
1: 'Troublesome',
|
|
10
|
+
2: 'Dangerous',
|
|
11
|
+
3: 'Formidable',
|
|
12
|
+
4: 'Extreme',
|
|
13
|
+
5: 'Epic'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
$id: 'ChallengeRank',
|
|
17
|
+
description:
|
|
18
|
+
'Challenge rank, represented as an integer from 1 (troublesome) to 5 (epic).'
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
|
+
export type ChallengeRank = Static<typeof ChallengeRank>
|
|
22
|
+
|
|
23
|
+
export const SpecialTrackType = Type.Ref(Id.DictKey, {
|
|
24
|
+
$id: 'SpecialTrackType',
|
|
25
|
+
examples: [
|
|
26
|
+
'bonds_track',
|
|
27
|
+
'failure_track',
|
|
28
|
+
'quests_legacy',
|
|
29
|
+
'bonds_legacy',
|
|
30
|
+
'discoveries_legacy'
|
|
31
|
+
],
|
|
32
|
+
description: `Special, ruleset-specific progress tracks. Usually, one exists per player character, and they persist through the life of the player character.
|
|
33
|
+
'Canonical' examples:
|
|
34
|
+
* \`bonds_track\`, described in the Ironsworn Rulebook. For the Starforged legacy track, use \`bonds_legacy\` instead.
|
|
35
|
+
* \`failure_track\`, described in Ironsworn: Delve
|
|
36
|
+
* \`quests_legacy\`, \`bonds_legacy\`, and \`discoveries_legacy\`, described Ironsworn: Starforged
|
|
37
|
+
|
|
38
|
+
`
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export type SpecialTrackType = Static<typeof SpecialTrackType>
|
|
42
|
+
export const ProgressTrackTypeInfo = Type.Object(
|
|
43
|
+
{
|
|
44
|
+
category: Type.Ref(Text.Label, {
|
|
45
|
+
description: 'A category label for progress tracks of this type.',
|
|
46
|
+
examples: [
|
|
47
|
+
'Vow',
|
|
48
|
+
'Journey',
|
|
49
|
+
'Combat',
|
|
50
|
+
'Scene Challenge',
|
|
51
|
+
'Expedition',
|
|
52
|
+
'Connection',
|
|
53
|
+
'Delve'
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
controls: Type.Optional(Generic.Dictionary(Type.Object({})))
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
$id: 'ProgressTrackTypeInfo',
|
|
60
|
+
description: 'Describes the features of a type of progress track.'
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
export type ProgressTrackTypeInfo = Static<typeof ProgressTrackTypeInfo>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Static, Type } from '@sinclair/typebox'
|
|
2
|
+
import { omit } from 'lodash-es'
|
|
3
|
+
import JtdType from '../../scripts/json-typedef/typedef.js'
|
|
4
|
+
import { JsonTypeDef } from '../Symbols.js'
|
|
5
|
+
|
|
6
|
+
// const IntegerRange = Type.Object({
|
|
7
|
+
// min: Type.Integer(),
|
|
8
|
+
// max: Type.Integer()
|
|
9
|
+
// })
|
|
10
|
+
// export type IntegerRange = Static<typeof IntegerRange>
|
|
11
|
+
|
|
12
|
+
const minOptions = {
|
|
13
|
+
description: 'Low end of the dice range.',
|
|
14
|
+
[JsonTypeDef]: {
|
|
15
|
+
schema: JtdType.Int16()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const maxOptions = {
|
|
19
|
+
description: 'High end of the dice range.',
|
|
20
|
+
[JsonTypeDef]: {
|
|
21
|
+
schema: JtdType.Int16()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const diceRangeOptions = {
|
|
26
|
+
description:
|
|
27
|
+
'Represents a range of dice roll results, bounded by `min` and `max` (inclusive).'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const DiceRange = Type.Object(
|
|
31
|
+
{
|
|
32
|
+
min: Type.Integer(minOptions),
|
|
33
|
+
max: Type.Integer(maxOptions)
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
$id: 'DiceRange',
|
|
37
|
+
...diceRangeOptions
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
export type DiceRange = Static<typeof DiceRange>
|
|
41
|
+
|
|
42
|
+
export function StaticDiceRange(min: number, max: number) {
|
|
43
|
+
return Type.Object(
|
|
44
|
+
{
|
|
45
|
+
min: Type.Const(min, omit(minOptions, ['description'])),
|
|
46
|
+
max: Type.Const(max, omit(maxOptions, ['description']))
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: 'DiceRangeStatic',
|
|
50
|
+
...omit(diceRangeOptions, ['description'])
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
}
|