gs2-studio-dsl 2026.11.21 → 2026.12.1
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/LLM.md +52 -40
- package/README.md +2 -2
- package/REFERENCE.md +107 -77
- package/index.d.ts +19 -0
- package/package.json +1 -1
package/LLM.md
CHANGED
|
@@ -24,6 +24,7 @@ Instructions for an agent that writes or edits a GS2 Studio package DSL. Follow
|
|
|
24
24
|
id-ledger.json ids of the package; created by dsl build --write-ledger; keep it with index.ts
|
|
25
25
|
dependency-surface.json written by dsl build: what this package publishes to packages that depend on it
|
|
26
26
|
surfaces/<packageId>.json written by dsl surfaces: what each package of the project publishes
|
|
27
|
+
surfaces/<packageId>.md written by dsl surfaces: how to use a package that has usage notes
|
|
27
28
|
tsconfig.json the tsconfig from the README
|
|
28
29
|
package.json devDependencies: gs2-studio-dsl, typescript
|
|
29
30
|
```
|
|
@@ -46,6 +47,8 @@ commands below with the executable's path; the first build writes the ledger. It
|
|
|
46
47
|
the project with `dsl build`. The DSL cannot install packages.
|
|
47
48
|
2. If the package depends on other packages, write their surfaces (one file per package of the project):
|
|
48
49
|
`"<GS2 Studio>" dsl surfaces --dir <project> --out <dsl>/surfaces`
|
|
50
|
+
Before you use a dependency, read `<dsl>/surfaces/<packageId>.md` when it exists: the package's own notes on how
|
|
51
|
+
to use it in the DSL and in the game, and what to check.
|
|
49
52
|
3. Write or edit `<dsl>/index.ts`. When the package depends on other packages, declare the dependencies first and build
|
|
50
53
|
(steps 4 to 7): the build then names the types of the dependencies that need rows from this package.
|
|
51
54
|
4. Type-check: `npx tsc --noEmit -p <dsl>`. Fix every error before building.
|
|
@@ -88,38 +91,42 @@ MUST:
|
|
|
88
91
|
of its surface is not `[]` (`mountedBy` names the dependency's resources that mount it), or when your package mounts
|
|
89
92
|
its overlay of the type itself. A type gets one only when a user data resource, or a master data resource of a model
|
|
90
93
|
other than a namespace, mounts it.
|
|
91
|
-
-
|
|
92
|
-
|
|
94
|
+
- Before you use a dependency, read `surfaces/<packageId>.md` when it exists. It is the package's own usage notes:
|
|
95
|
+
which rows to author, which of its items and Handlers the game uses, and what to check.
|
|
96
|
+
- To use what a dependency does as it is (for example a dependency whose transforms are all the game needs), declare
|
|
97
|
+
the dependency and call its transforms; add rows, resources or UI only for what the surface or a build asks
|
|
93
98
|
for. The dependency's own UI components (`types.<Type>.uiComponents`) are generated with it, and the game places
|
|
94
|
-
the Handler that holds the row they show
|
|
99
|
+
the Handler that holds the row they show (its usage notes say which). See
|
|
95
100
|
[Rows in the game](REFERENCE.md#rows-in-the-game).
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- With `micro-shop-energy`, use its `EnergyProductBuyButton` (surface key `BuyButton` on `EnergyProduct`) instead of
|
|
104
|
-
writing a purchase button. One press charges the product's price and refills the stamina in one GS2 transaction, so
|
|
105
|
-
a refused charge refills nothing. The refill stops at the stamina's cap (its `overflowedMaximum` when the stamina sets
|
|
106
|
-
`useOverflow`), so a purchase at the cap still charges the full price.
|
|
107
|
-
- Show the time left until a timestamp (a stamina's next recovery) with a `UiItem.countdown`, or the one a dependency
|
|
108
|
-
lists in `types.<Type>.uiComponents` (`foundation-economy-energy`'s `NextRecoveryCountdown`), never with a hand-written
|
|
109
|
-
timer: it counts on the session's GS2 clock, which `DateTime.UtcNow` is not. See
|
|
101
|
+
- Use a button a dependency ships (`kind: "buttonAction"` in `types.<Type>.uiComponents`, with the `method` it calls)
|
|
102
|
+
instead of writing one that calls the same action.
|
|
103
|
+
- Show the time left until a timestamp (a row's next scheduled change) with a `UiItem.countdown`, or the one a dependency
|
|
104
|
+
lists in `types.<Type>.uiComponents` (`kind: "countdown"`), never with a hand-written timer: it counts on the
|
|
105
|
+
session's GS2 clock, which `DateTime.UtcNow` is not. See [UI components](REFERENCE.md#ui-components).
|
|
106
|
+
- Place an `activeToggle` on a GameObject that stays active below the type's Handler, with what it shows or hides as
|
|
107
|
+
its targets, never on a GameObject it hides: once hidden it stops listening and never shows it again. See
|
|
110
108
|
[UI components](REFERENCE.md#ui-components).
|
|
111
|
-
- Place an `activeToggle` such as `ProgressIdleActiveToggle` on a GameObject that stays active below the type's
|
|
112
|
-
Handler, with what it shows or hides as its targets, never on a GameObject it hides: once hidden it stops listening
|
|
113
|
-
and never shows it again. See [UI components](REFERENCE.md#ui-components).
|
|
114
109
|
- Before adding UI to a dependency's type, read `types.<Type>.uiComponents` of its surface. Its keys are the class
|
|
115
110
|
names items are declared with; the generated Unity class is the type's generated name followed by the key (surface
|
|
116
|
-
key `
|
|
117
|
-
[Item options](REFERENCE.md#item-options)).
|
|
118
|
-
|
|
111
|
+
key `OpenButton` on `example-gift-shop`'s `GiftBox` → generated class `GiftBoxOpenButton`; a rename of the type
|
|
112
|
+
changes the prefix, see [Item options](REFERENCE.md#item-options)). Each entry also gives what the item shows: a
|
|
113
|
+
`templateLabel`'s `template` (per locale when it has several), the `fallbackText` shown while its value is unset, and
|
|
114
|
+
the author's `description`. Reuse a listed item instead of adding one that shows the same, and give new items
|
|
115
|
+
unlisted class names: a listed one replaces that item. A new item may show the type's published properties too, as
|
|
116
|
+
their `bindingHint` in `propertyDetails` allows ([UI components](REFERENCE.md#ui-components)).
|
|
117
|
+
- A UI component, a delegated action, a `UiCond.rowElement` or a `UiSource.rowProp` on a dependency's type uses your overlay of that type when
|
|
118
|
+
you declare one, and otherwise one overlay they all share. They never fail with `duplicateOverlaySource`, which is two
|
|
119
|
+
`defineOverlayDomainType` of the same type. When you declare an overlay, give `defineUiComponent` its handle.
|
|
120
|
+
- Write the screens' fixed text in the DSL while you write their UI: headings, button captions and words around values
|
|
121
|
+
that the game shows in the player's language are `UiItem.templateLabel`s you add (no placeholders and `{}` sources
|
|
122
|
+
for fixed text, [Localized templates](REFERENCE.md#localized-templates)), and a dependency ships them only where its
|
|
123
|
+
surface lists one. Put each on a type whose `<Type>Handler` or `<Type>ListItemHandler` sits above that text in the
|
|
124
|
+
scene, such as the type of the row it heads. A `<Type>ListHandler` does not count: a heading over a list goes on the
|
|
125
|
+
type of a `<Type>Handler` above the list. Text that no such Handler sits above is the game's own.
|
|
119
126
|
- Give a single-entry type's row the type name in lower case as its id (`GameSettings` → `gamesettings`). The same id
|
|
120
127
|
is the row its Handler holds and the row id to pass to `UiSource.rowProp`. For a dependency's type, read it from
|
|
121
|
-
`types.<Type>.singleEntryRowId` of the surface, also when the surface lists no row (
|
|
122
|
-
|
|
128
|
+
`types.<Type>.singleEntryRowId` of the surface, also when the surface lists no row (a player's own data that nobody
|
|
129
|
+
authors); an overlay that renames the type keeps it. See
|
|
123
130
|
[Keys and identity](REFERENCE.md#keys-and-identity).
|
|
124
131
|
- Refer to anything of another package only through `dependencyPackage(surface)` built from a surface file that
|
|
125
132
|
`dsl surfaces` wrote (or, for a package you build yourself, the `dependency-surface.json` beside its ledger, which
|
|
@@ -161,10 +168,8 @@ MUST:
|
|
|
161
168
|
you leave out deploys as what `actionPropertyTransforms` add to it, or empty.
|
|
162
169
|
- A property or parameter of type `ref<<packageId>:<Type>>` takes a row of that package's type. Declare that package
|
|
163
170
|
as a dependency if it is not one yet (its own surface file and spec), author the row with
|
|
164
|
-
`instance(other.type("<Type>"), id, values)`, and give the row id as the value.
|
|
165
|
-
|
|
166
|
-
not on `Quest`, so put the quest in a quest collection of its own with an absolute `Schedule` row, and have the game
|
|
167
|
-
list that collection too. See [A row of another package's type](REFERENCE.md#a-row-of-another-packages-type).
|
|
171
|
+
`instance(other.type("<Type>"), id, values)`, and give the row id as the value. See
|
|
172
|
+
[A row of another package's type](REFERENCE.md#a-row-of-another-packages-type).
|
|
168
173
|
- Choose each property's binding hint by what reads its value, also for a property an overlay adds: the client, from
|
|
169
174
|
the rows you author (a UI component shows it) → `.assetDelivery()`; only an `actionPropertyTransforms` argument → no
|
|
170
175
|
hint; a field a master data resource of this package binds → `.masterData()`. See the table in
|
|
@@ -225,13 +230,16 @@ Names and ids:
|
|
|
225
230
|
only if asked, and then keep its id as above; only a kept id carries the generated script's GUID over, so scenes and
|
|
226
231
|
prefabs stay wired. See [The id ledger](REFERENCE.md#the-id-ledger).
|
|
227
232
|
- A row id is letters, digits, `_`, `.` and `-`, at most 128 characters; a resource that binds `id` to a GS2 name sends
|
|
228
|
-
it as that name (a
|
|
233
|
+
it as that name (a GS2 model name), and some GS2 fields take fewer.
|
|
229
234
|
- A row token contains the row id. Before you treat a "not current" + "missing" row token pair as a rename of a
|
|
230
235
|
composite-key row, check the new row id against the composite key rule below; a wrong id must be fixed in the DSL,
|
|
231
236
|
not moved in the ledger.
|
|
232
|
-
- A composite-key row id is its key values joined with `.` in ascending order of the key members' property ids in
|
|
233
|
-
|
|
234
|
-
read the ids, then add the rows.
|
|
237
|
+
- A composite-key row id is its key values joined with `.` in ascending order of the key members' property ids, not in
|
|
238
|
+
the order passed to `compositeKey`. For your own type the ids are in your ledger: build the type with
|
|
239
|
+
`--write-ledger` before adding its rows, read the ids, then add the rows. For a dependency's type, read the members
|
|
240
|
+
in that order from its surface's `types.<Type>.compositeKey`. A `ref` member's value is the id of the row it refers to; when that row is
|
|
241
|
+
itself composite-keyed, that is its composed id, `.` included. A wrong row id fails `dsl build`, which names each
|
|
242
|
+
row's id and the id to use (`"<id>" → "<id to use>"`). See [Keys and identity](REFERENCE.md#keys-and-identity).
|
|
235
243
|
|
|
236
244
|
## 5. API cheat sheet
|
|
237
245
|
|
|
@@ -248,7 +256,7 @@ Names and ids:
|
|
|
248
256
|
| Conditional requirement | `.requiredWhen(Cond.eq("limited", true))` | [Conditions](REFERENCE.md#conditions) |
|
|
249
257
|
| Identity and order | `singleEntry: true`, `compositeKey: [...]`, `sort: { key, direction? }` | [Keys and identity](REFERENCE.md#keys-and-identity) |
|
|
250
258
|
| Author rows | `instance(definition, id, values)` in `instances: [...]` | [Instances](REFERENCE.md#instances) |
|
|
251
|
-
| Rows a dependency's type needs from the project | `instance(dep.type("
|
|
259
|
+
| Rows a dependency's type needs from the project | `instance(dep.type("<Type>"), id, values)` in `instances: [...]` | [Instances](REFERENCE.md#instances) |
|
|
252
260
|
| Change a row a dependency ships | `overlayInstance(type, sourceInstanceId, { overrides?, suppressed? })` in `overlayInstances: [...]` | [Instances](REFERENCE.md#instances) |
|
|
253
261
|
| Extend a dependency's type | `defineOverlayDomainType(name, dep.overlay(name), { properties?, actionPropertyTransforms?, ... })` | [Overlay types](REFERENCE.md#overlay-types) |
|
|
254
262
|
| List of structured elements | `defineInlineElement(name, { properties, elementKey?, ... })`, `PT.listOf(PT.inlineElement(schema))`, `inlineElementOf(Host, "listProp")` | [Inline elements](REFERENCE.md#inline-elements) |
|
|
@@ -256,16 +264,17 @@ Names and ids:
|
|
|
256
264
|
| Map GS2 user data to properties | `defineUserDataResource({ model: GS2.svc.Model, linkedMaster?, mount?, bindings: {...}, children? })` | [User data resources](REFERENCE.md#user-data-resources) |
|
|
257
265
|
| Field values | `Bind.*`, `Source.direct(T, "prop")`, `Source.parent(...)`, `transactionSettingV2()` | [Bindings](REFERENCE.md#bindings) |
|
|
258
266
|
| Actions of an action entry | `ActionProgram.transform(transform, [Arg...])`; a dependency's: `dep.transformProgram(name, { count: { kind: "domainProperty", source: Source.parent(Source.direct(T, "count")) } })` | [Action programs and arguments](REFERENCE.md#action-programs-and-arguments) |
|
|
259
|
-
| Add a dependency's transform to an inherited action property | `actionPropertyTransforms: prop => [{ targetProperty, mode: "append", ...dep.transformCall(name, { count: prop("price") }) }]
|
|
260
|
-
| A row of another package's type (a `ref<pkg:Type>` value
|
|
267
|
+
| Add a dependency's transform to an inherited action property | `actionPropertyTransforms: prop => [{ targetProperty, mode: "append", ...dep.transformCall(name, { count: prop("price") }) }]`. One transform per property per overlay, whatever the mode: to add several actions, attach one transform of this package whose delegation outputs call them | [Overlay types](REFERENCE.md#overlay-types) |
|
|
268
|
+
| A row of another package's type (a `ref<pkg:Type>` value) | Declare that package too, `instance(other.type("<Type>"), id, values)`, pass the row id | [A row of another package's type](REFERENCE.md#a-row-of-another-packages-type) |
|
|
261
269
|
| Produce GS2 actions from parameters | `defineActionTransform(name, { category, parameters, outputs })` + `OutputMap.*` | [Action transforms](REFERENCE.md#action-transforms) |
|
|
262
270
|
| A method that runs a GS2 action | `delegatedActions: { Method: { targetActionKey, targetResource } }` on the type, or `definePackage({ delegatedActions: [{ target, methodName, action: { targetActionKey, targetResource } }] })` | [Delegated actions](REFERENCE.md#delegated-actions) |
|
|
263
271
|
| Generated UI | `defineUiComponent(T, { items: [UiItem.label(...), UiItem.buttonAction(...)] })`, `UiSource.*`, `UiCond.*` | [UI components](REFERENCE.md#ui-components) |
|
|
264
|
-
| Enable a button by another type's row (
|
|
272
|
+
| Enable a button by another type's row (the coins a player owns) | `UiItem.interactable("AffordableInteractable", UiCond.gte(UiSource.rowProp(inventory.type("Item"), "coin", "count"), UiSource.prop("price")))` | [Another type's row](REFERENCE.md#another-types-row) |
|
|
265
273
|
| Choose a UI item and its options | `label` shows text, `templateLabel` text around values, `countdown` the time left until a timestamp, `value` sends a typed value the game formats; a button never disables itself (add `interactable`). `{ name, description }` only label the item in GS2 Studio's editor; leave them out | [UI components](REFERENCE.md#ui-components), [Item options](REFERENCE.md#item-options) |
|
|
266
274
|
| Show every row in the game, in order | A UI component describes one row; the generated `<T>ListHandler` makes one instance of a prefab per row, in the order of `sort` (an overlay: the dependency's order unless it sets a `sort` other than id ascending) | [Rows in the game](REFERENCE.md#rows-in-the-game) |
|
|
267
275
|
| A button on a dependency's delegated action | `UiItem.buttonAction("ReceiveButton", "Receive", args, options)` (first check `types.<T>.uiComponents`, keyed by class name without the `<T>` prefix: a package may already ship the button); `args` takes only the names under `types.<T>.delegatedActions.Receive.parameters` of the surface and needs each `required: true` one; with none required it may be `undefined` | [Dependencies](REFERENCE.md#dependencies) |
|
|
268
276
|
| Code template | `codeTemplates: [{ outputFileName: "File.cs", templateSource: text }]` with a `?raw` import | [Code templates](REFERENCE.md#code-templates) |
|
|
277
|
+
| Tell the authors of dependent packages how to use yours | `usageNotes: text` with a `?raw` import of a `USAGE.md` | [Usage notes](REFERENCE.md#usage-notes) |
|
|
269
278
|
| Use another package of the project | `dependencyPackage(surface)`, `dependencies: { [dep.packageId]: spec }`; spec `"*"` (authored in the project), or for an installed package the spec the package that installed it declares, or for one only in `project-lock.json` the spec its entry gives (`"github:gs2io/gs2-studio-package"` for an official package) | [Dependencies](REFERENCE.md#dependencies) |
|
|
270
279
|
|
|
271
280
|
## 6. Common mistakes
|
|
@@ -307,12 +316,12 @@ Names and ids:
|
|
|
307
316
|
| `CLI_DSL_VALIDATION_FAILED` ... `No user data resource binds this property.` | A `.userData()` property no resource binds. | Bind it in a user data resource (`Bind.domainProperty` / `Bind.domainProperties` with `Source.direct(T, "prop")`), or remove the hint. |
|
|
308
317
|
| `CLI_DSL_VALIDATION_FAILED` ... `No Handler is generated for the target domain model` | A UI component on a type that gets no Handler (`generatedHandlers: []` in its surface). | Mount the type with a user data resource or a master data resource of a model other than a namespace, or remove the component. |
|
|
309
318
|
| `CLI_DSL_VALIDATION_FAILED` ... `the condition cannot read a value of another domain model's row` | A `UiSource.rowProp` of a type that gets no Handler. | Read a type whose `generatedHandlers` is not `[]`, or remove the item. |
|
|
310
|
-
| `CLI_DSL_VALIDATION_FAILED` ... `instance ids that no longer match their composite-key values` | Row ids not composed from key values in property-id order. |
|
|
319
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `instance ids that no longer match their composite-key values` | Row ids not composed from key values in property-id order. | Give each named row's `instance(...)` the id after `→`. If the line says rows would share an id, first change those rows' key values so each composes an id of its own. |
|
|
311
320
|
| `CLI_DSL_DEPENDENCY_NOT_INSTALLED` | `dependencies` names a package the project lacks. | A package authored in the project: build it with `dsl build` first. Another package: add it in GS2 Studio. |
|
|
312
321
|
| `CLI_DSL_PACKAGE_INVALID` ... `Invalid GitHub dependency spec: github:<owner>/<repo>/<dir>` | A subdirectory in a GitHub spec. | Use `github:<owner>/<repo>`; the project's lock records the directory. |
|
|
313
322
|
| `CLI_DSL_DEPENDENCY_SPEC_MISMATCH` | `dependencies` gives an installed package a spec that names another source than the one the project installed it from, such as `"*"`. | Declare it with the spec the message prints, then build again. |
|
|
314
|
-
| `CLI_DSL_VALIDATION_FAILED` ... `the parent <resource> resource has no row` ... `Add a row of "T"` | Rows of a dependency's type sit under a GS2 resource made from rows of `T`, which nobody authored. | Add a row of `T` with `instance(dep.type("T"), id, values)` and point your rows at it (
|
|
315
|
-
| `... is a dependency the DSL cannot change, so
|
|
323
|
+
| `CLI_DSL_VALIDATION_FAILED` ... `the parent <resource> resource has no row` ... `Add a row of "T"` | Rows of a dependency's type sit under a GS2 resource made from rows of `T`, which nobody authored. | Add a row of `T` with `instance(dep.type("T"), id, values)` and point your rows at it (the property of your rows that refers to it). |
|
|
324
|
+
| `... is a dependency whose own definitions the DSL cannot change, so the findings in them are fixed through the dependency that brings it in: ...` | A defect in the dependency's own definitions, not of this DSL; said once for the package. A finding about rows (rows to add, a row's values) is fixed in this DSL and is not covered by it. | If the message says to remove the dependency `"X"` from the DSL and the package does not need X, remove it and what refers to it. Otherwise tell the user: the project's owner updates or removes the dependency in GS2 Studio, as the message says. |
|
|
316
325
|
| A successful build prints `[warning] ... No master data is registered for domain model "T"` | A dependency's GS2 resource needs rows of `T` from the project; it is not deployed without them. | Add the row the message names, `instance(dep.type("T"), id, values)`, with the values it names, and build again. `dep.type("<Type>")` means the message names no type `dep.type()` takes: for an inline schema, add elements to the host type's list property with `dep.inlineElements(...)`; for an unresolved type, find it in the surfaces. |
|
|
317
326
|
| A successful build prints `[error] ... the required arguments (...) of action transform ... have no value for row "r"` | An `actionPropertyTransforms` argument reads a property row `r` has no value for. | Give the row the value; for a row a dependency ships, use `overlayInstance(type, "r", { overrides })`. |
|
|
318
327
|
| `CLI_DSL_VALIDATION_FAILED` ... `is not a UTC ISO 8601 timestamp` | A `PT.timestamp()` value in another form, such as with an offset (`+09:00`). The message says `In package "<your package>"` when the row is yours, even of a dependency's type. | Write it in UTC with `Z`, such as `"2026-11-30T15:00:00Z"`, in that `instance(...)` (see [Property types](REFERENCE.md#property-types)). |
|
|
@@ -492,6 +501,9 @@ The game signs in to GS2 with a client ID and a client secret. Take them from th
|
|
|
492
501
|
client has ApplicationAccess permission and is made to be embedded in the game, so the two values are low-sensitivity.
|
|
493
502
|
- Never create a GS2-Identifier user or client for the game, and never put the developer's GS2 sign-in (email,
|
|
494
503
|
password, credentials file) or any other management credential into the game.
|
|
504
|
+
- The one exception is a user a package's usage notes (`surfaces/<packageId>.md`) tell you to create, such as the
|
|
505
|
+
user a version check signs a passing player in as. Create it as those notes say, with no security policy and no
|
|
506
|
+
client.
|
|
495
507
|
- In Unity, they go into a `Gs2Environment` asset (Create > Game Server Services > Core > Environment) with `region`,
|
|
496
508
|
`clientId`, `clientSecret` and `name`. `Gs2ClientHolder` lists the asset under Environments, and its Active
|
|
497
509
|
Environment Name must equal the asset's `name` field, not its file name.
|
package/README.md
CHANGED
|
@@ -9,11 +9,11 @@ type-check; use these declarations in your editor and with `tsc --noEmit`.
|
|
|
9
9
|
- For LLM coding agents: [LLM.md](LLM.md)
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install --save-dev gs2-studio-dsl@2026.
|
|
12
|
+
npm install --save-dev gs2-studio-dsl@2026.12.1
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
The version is the GS2 Studio version whose DSL these declarations describe: a DSL written
|
|
16
|
-
against gs2-studio-dsl 2026.
|
|
16
|
+
against gs2-studio-dsl 2026.12.1 builds with GS2 Studio 2026.12.1 and later. Install the version that
|
|
17
17
|
matches the oldest GS2 Studio you build with.
|
|
18
18
|
|
|
19
19
|
```ts
|
package/REFERENCE.md
CHANGED
|
@@ -28,11 +28,12 @@ If you are an LLM coding agent, read [LLM.md](LLM.md) first.
|
|
|
28
28
|
16. [Delegated actions](#delegated-actions)
|
|
29
29
|
17. [UI components](#ui-components)
|
|
30
30
|
18. [Code templates](#code-templates)
|
|
31
|
-
19. [
|
|
32
|
-
20. [
|
|
33
|
-
21. [
|
|
34
|
-
22. [
|
|
35
|
-
23. [
|
|
31
|
+
19. [Usage notes](#usage-notes)
|
|
32
|
+
20. [Dependencies](#dependencies)
|
|
33
|
+
21. [The id ledger](#the-id-ledger)
|
|
34
|
+
22. [Building with dsl build](#building-with-dsl-build)
|
|
35
|
+
23. [Validation error kinds](#validation-error-kinds)
|
|
36
|
+
24. [Exported types](#exported-types)
|
|
36
37
|
|
|
37
38
|
## Concepts
|
|
38
39
|
|
|
@@ -64,7 +65,7 @@ Naming rules the build enforces:
|
|
|
64
65
|
| Package id | Segments of letters, digits, `_` and `-` joined by `/`, optionally starting with `@`. |
|
|
65
66
|
| Domain type name, inline element name | PascalCase: `^[A-Z][a-zA-Z0-9]*$`, at most 100 characters. |
|
|
66
67
|
| Property name | camelCase: `^[a-z][a-zA-Z0-9]*$`, at most 100 characters. `id` is reserved. |
|
|
67
|
-
| Instance id | Letters, digits, `_`, `.` and `-`, at most 128 characters (`instanceIdTooLong`), also a composite-key id no resource sends. A resource that binds `id` to a GS2 name sends the row id as that name
|
|
68
|
+
| Instance id | Letters, digits, `_`, `.` and `-`, at most 128 characters (`instanceIdTooLong`), also a composite-key id no resource sends. A resource that binds `id` to a GS2 name sends the row id as that name, such as a GS2 model name. The GS2 field it is bound to may take fewer characters (a Lottery prize id takes at most 36); deploy reports that. |
|
|
68
69
|
| UI component class name | PascalCase. |
|
|
69
70
|
|
|
70
71
|
## Modules and imports
|
|
@@ -111,6 +112,7 @@ import { GS2 } from "gs2-studio-dsl/gs2";
|
|
|
111
112
|
|
|
112
113
|
import inventorySurface from "./surfaces/example-inventory.json" with { type: "json" };
|
|
113
114
|
import giftShopTemplate from "./templates/GiftShop.cs.njk?raw";
|
|
115
|
+
import usageNotes from "./USAGE.md?raw";
|
|
114
116
|
```
|
|
115
117
|
|
|
116
118
|
## Packages
|
|
@@ -188,6 +190,7 @@ export const exampleInventory = definePackage({
|
|
|
188
190
|
| `actionTransforms?` | Action transform definitions made with `defineActionTransform` (see [Action transforms](#action-transforms)). |
|
|
189
191
|
| `uiComponents?` | UI component definitions made with `defineUiComponent` (see [UI components](#ui-components)). |
|
|
190
192
|
| `codeTemplates?` | `{ outputFileName, templateSource }[]` (see [Code templates](#code-templates)). |
|
|
193
|
+
| `usageNotes?` | Markdown that tells the authors of dependent packages how to use this one (see [Usage notes](#usage-notes)). |
|
|
191
194
|
|
|
192
195
|
`LocalizedDisplay` is `{ [locale: string]: { label?: string; description?: string; unit?: string } }`, for example
|
|
193
196
|
`{ en: { label: "Item", description: "An item a player can own." } }`.
|
|
@@ -273,7 +276,7 @@ the names `Source.idRef`, a `delegatedActions` parameter override, `UiCond.rowEl
|
|
|
273
276
|
name. In `sort`, `compositeKey`, `elementKey`, `localizedProperties`, `targetProperty`, a transform argument, a
|
|
274
277
|
row value key, `UiSource.prop`, a `delegatedActions` parameter override, `Source.direct` / `Source.idRef` and
|
|
275
278
|
`existenceProperty` it reports each place once, in the terms you wrote it (for example
|
|
276
|
-
`actionPropertyTransforms[0] (
|
|
279
|
+
`actionPropertyTransforms[0] (ConsumeItem → cost) argument "count"` or `Source.direct in "name"`), as
|
|
277
280
|
`<where>: "<name>" is not a property of "<Type>" (properties: ...)`.
|
|
278
281
|
|
|
279
282
|
To rename a property, rename it in `properties`, run `tsc --noEmit`, which lists every place that still uses the old
|
|
@@ -293,7 +296,7 @@ transform parameters.
|
|
|
293
296
|
| `PT.float32()`, `PT.float64()` | floating point | `number` |
|
|
294
297
|
| `PT.bool()` | boolean | `boolean` |
|
|
295
298
|
| `PT.timestamp()` | timestamp, sent to GS2 as Unix time in milliseconds | a UTC ISO 8601 `string` (see below), such as `"2026-11-30T15:00:00Z"` |
|
|
296
|
-
| `PT.localizedString()` | text per locale, delivered as an asset (only with `.assetDelivery()`) | `{ [locale]: string }`, such as `{ ja: "
|
|
299
|
+
| `PT.localizedString()` | text per locale, delivered as an asset (only with `.assetDelivery()`) | `{ [locale]: string }`, such as `{ ja: "剣", en: "Sword" }` |
|
|
297
300
|
| `PT.enum(...values)` | one of `values` | `string` |
|
|
298
301
|
| `PT.ref(target)` | a reference to a row of another type (`LocalDomainTypeDef`, `OverlayDomainTypeDef`, `DependencyDomainTypeRef`, or `() => target` for forward/self references) | the row id (`string`) |
|
|
299
302
|
| `PT.inline(target)` | a value of another domain type, embedded | an object |
|
|
@@ -389,7 +392,7 @@ Binding hints the build accepts for each shape:
|
|
|
389
392
|
### Localized text
|
|
390
393
|
|
|
391
394
|
A `PT.localizedString` property holds one text per locale on each row, for text the game shows in the player's
|
|
392
|
-
language, such as
|
|
395
|
+
language, such as an item's display name. Declare one property, not one per language:
|
|
393
396
|
|
|
394
397
|
```ts
|
|
395
398
|
displayName: PT.localizedString().assetDelivery(),
|
|
@@ -512,8 +515,8 @@ id is the name the type's first declaration gives it, in lower case, and an over
|
|
|
512
515
|
change it. The same id names the row in the game: the generated `<Type>Handler` of a single-entry type has no row id in
|
|
513
516
|
its Inspector and always holds that row, and it is the `rowId` that `UiSource.rowProp` takes for the type
|
|
514
517
|
([Another type's row](#another-types-row)). A dependency's surface gives the id as
|
|
515
|
-
`types.<Type>.singleEntryRowId`, beside `singleEntry: true`, whether or not a package ships the row: for
|
|
516
|
-
`
|
|
518
|
+
`types.<Type>.singleEntryRowId`, beside `singleEntry: true`, whether or not a package ships the row: for a dependency's
|
|
519
|
+
`GameSettings`, it is `"gamesettings"`. A surface written by
|
|
517
520
|
an older GS2 Studio lacks it: write the surface again with `dsl surfaces`, or lower-case the type's key in the surface
|
|
518
521
|
of its `canonicalPackageId`.
|
|
519
522
|
|
|
@@ -534,12 +537,18 @@ const GameSettings = defineDomainType("GameSettings", {
|
|
|
534
537
|
**Composite key.** `compositeKey: [first, ...rest]` makes each row id the members' values joined with `.`. Members must
|
|
535
538
|
be declared properties of type `string`, `int32`, `int64`, `bool`, `enum` or `ref`, with hint `masterData` or
|
|
536
539
|
`assetDelivery`; `id`, duplicates and unknown names fail with `invalidCompositeKey`. The parts are joined in the order of
|
|
537
|
-
the members' **property ids
|
|
540
|
+
the members' **property ids**, not in the order you pass them. A `ref` member's value is the id of the row it refers
|
|
541
|
+
to; when that row is itself composite-keyed, the part is its composed id, `.` included. Any other member value may not
|
|
538
542
|
contain `.`. A row id that differs from the composed id fails `dsl build` ("instance ids that no longer match their
|
|
539
|
-
composite-key values"),
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
+
composite-key values"), which names each such row's id and the id to give its `instance(...)`
|
|
544
|
+
(`"<id>" → "<id to use>"`). When that id would be another row's too, it asks you first to change the key values of
|
|
545
|
+
those rows so that each composes an id of its own. A failed build writes no ledger.
|
|
546
|
+
|
|
547
|
+
The member ids of your own type are random until the ledger records them, so author a composite-key type in two steps:
|
|
548
|
+
build it with `--write-ledger` before it has rows, read the members' `property:<Type>.<name>` ids in `id-ledger.json`,
|
|
549
|
+
then add the rows with their values in ascending id order and build again. A dependency's type takes its member ids
|
|
550
|
+
from the dependency, not from your ledger: read the members from its surface's `types.<Type>.compositeKey`, which
|
|
551
|
+
names them in the order their values join (their ids are under `types.<Type>.properties`).
|
|
543
552
|
|
|
544
553
|
```ts
|
|
545
554
|
const HeroLevel = defineDomainType("HeroLevel", {
|
|
@@ -646,13 +655,15 @@ Inherited properties are addressed by the names the dependency publishes, for ex
|
|
|
646
655
|
| `localizedProperties?` | Display metadata for added properties and `id`. An inherited property keeps its source's; a key naming one fails. |
|
|
647
656
|
| `sort?` | `{ key: propertyName \| null, direction?: "asc" \| "desc" }`. Without it, the overlay keeps the dependency's order, as does the overlay that `defineUiComponent`, `delegatedActions`, `UiCond.rowElement` and `UiSource.rowProp` create for a dependency type (`types.<Type>.sort` of the surface). It replaces that order; `{ key: null }` with `"asc"` is the same as no `sort`. |
|
|
648
657
|
| `compositeKey?` | `{ kind: "inherit" }`, `{ kind: "suppress" }`, or `{ kind: "override", members: [...names] }`. |
|
|
649
|
-
| `actionPropertyTransforms?` | Transform calls attached to an action property of the type: `{ targetProperty, mode?: "replace" \| "append", transform, arguments }` for a transform of this package (its `ActionTransformDef` or `() => transform`), or `{ targetProperty, mode?, transformPackageId, transformId, arguments }` for a dependency's. `mode` defaults to `"replace"`; `"append"` lets
|
|
658
|
+
| `actionPropertyTransforms?` | Transform calls attached to an action property of the type: `{ targetProperty, mode?: "replace" \| "append", transform, arguments }` for a transform of this package (its `ActionTransformDef` or `() => transform`), or `{ targetProperty, mode?, transformPackageId, transformId, arguments }` for a dependency's. `mode` defaults to `"replace"`; `"append"` lets each package that overlays the type add its own transform to the same action. One overlay attaches one transform per property in either mode (a second fails with `duplicateActionPropertyTransformTarget`): to add several actions, define one transform in this package whose delegation outputs call each of them ([Action transforms](#action-transforms)) and attach that one. `arguments` is `{ parameterName, source }[]`, where `source` is `{ kind: "static", value }`, `{ kind: "domainProperty", propertyName }`, `{ kind: "actionLiteral", value }`, `{ kind: "placeholder", value }` or a nested `{ kind: "actionTransformRef", invocation }`. For a dependency's transform, write `{ targetProperty, mode, ...dep.transformCall(name, { <parameter>: source }) }`. The field also takes a function of `prop` that returns the entries (`prop => [...]`); `prop("x")` is `{ kind: "domainProperty", propertyName: "x" }`, and `tsc` reports a wrong `"x"` on that literal ([Property names are type-checked](#property-names-are-type-checked)). `dsl build` refuses a top-level argument the transform does not declare, one named twice, and a missing required one. |
|
|
650
659
|
| `delegatedActions?` | `{ [methodName]: DelegatedActionDef }`, as [delegated actions](#delegated-actions). |
|
|
651
660
|
| `renamedInheritedProperties?` | `Record<string, string>`; not covered by this reference. |
|
|
652
661
|
|
|
653
662
|
Names in `sort`, `compositeKey`, `targetProperty` and a transform argument's `propertyName` resolve against the
|
|
654
663
|
overlay's own properties and the published ones; `tsc` refuses a name that resolves to neither, and so does `dsl build`
|
|
655
|
-
(`unresolvedPropertySlot`). Two overlays of the same source type fail with `duplicateOverlaySource`.
|
|
664
|
+
(`unresolvedPropertySlot`). Two overlays of the same source type fail with `duplicateOverlaySource`. The overlay that
|
|
665
|
+
`defineUiComponent`, `delegatedActions`, `UiCond.rowElement` and `UiSource.rowProp` create for a dependency type is not a
|
|
666
|
+
second one: they use your declared overlay of the type when there is one, and share one overlay otherwise.
|
|
656
667
|
|
|
657
668
|
`example-gift-sale` overlays `example-gift-shop`'s `GiftBox`, whose published `cost` is a `list<consumeAction>`. It adds
|
|
658
669
|
a `price` and appends `example-inventory`'s `ConsumeItem` to `cost`, so every box costs `price` coins. Each row of the type
|
|
@@ -1190,6 +1201,12 @@ the time left until a timestamp, and `value` for a value the game formats or use
|
|
|
1190
1201
|
apart from the table band sources of `gauge`; a condition also reads the parent row with `UiCond.rowElement` and one row
|
|
1191
1202
|
of any type with `UiSource.rowProp`.
|
|
1192
1203
|
|
|
1204
|
+
On a dependency's type, `UiSource.prop` reads the properties its surface publishes as well as those an overlay adds.
|
|
1205
|
+
Whether the client holds a value follows each property's `bindingHint` (`types.<Type>.propertyDetails` of the
|
|
1206
|
+
surface), as for your own properties ([Property modifiers](#property-modifiers)): an `assetDelivery` or `userData`
|
|
1207
|
+
value reaches the client, a `masterData` value does too unless code generation warns that it cannot read it back from
|
|
1208
|
+
the GS2 resource that holds it, and an item that shows a property with hint `none` shows its default.
|
|
1209
|
+
|
|
1193
1210
|
`UiCond` builds the conditions of `UiItem.activeToggle` and `UiItem.interactable`:
|
|
1194
1211
|
|
|
1195
1212
|
| Member | Holds when |
|
|
@@ -1234,10 +1251,10 @@ defineUiComponent(Item, {
|
|
|
1234
1251
|
|
|
1235
1252
|
### Another type's row
|
|
1236
1253
|
|
|
1237
|
-
`UiSource.rowProp(type, rowId, propertyName)` lets a condition read one row of another type, such as the player
|
|
1238
|
-
`
|
|
1239
|
-
type name in lower case, even when nobody authors the row ([Keys and identity](#keys-and-identity); `"
|
|
1240
|
-
|
|
1254
|
+
`UiSource.rowProp(type, rowId, propertyName)` lets a condition read one row of another type, such as the coins a player owns
|
|
1255
|
+
(`Item` row `"coin"`) while the component targets a gift box. `rowId` is the row's id; for a single-entry type, the
|
|
1256
|
+
type name in lower case, even when nobody authors the row ([Keys and identity](#keys-and-identity); `"gamesettings"`
|
|
1257
|
+
for `GameSettings`). For a single-entry type, `dsl build` refuses another id
|
|
1241
1258
|
(`uiComponentForeignRowSingleEntryIdMismatch`, whose `expectedId` names the id), as the type's handler can hold no
|
|
1242
1259
|
other row; it does so whenever it knows the id, which it does except for a dependency's type that a surface from an
|
|
1243
1260
|
older GS2 Studio re-exports. For another type it checks only that `rowId` is a valid row id, not that such a row exists.
|
|
@@ -1275,16 +1292,16 @@ under its class name, shows `name` as its display name when it differs from the
|
|
|
1275
1292
|
its problem messages, and shows `description` under it. Neither reaches the generated code or the game. Without `name`, the
|
|
1276
1293
|
item's name is the target type's name. Leave both out unless the editor's reader needs them.
|
|
1277
1294
|
|
|
1278
|
-
The class name is what the generated code uses: the item becomes the C# class `<Type><className>` (`
|
|
1279
|
-
for `buttonAction("
|
|
1295
|
+
The class name is what the generated code uses: the item becomes the C# class `<Type><className>` (`GiftBoxOpenButton`
|
|
1296
|
+
for `buttonAction("OpenButton", ...)` on `GiftBox`) in the namespace of the type's handler followed by `.UI`, listed in
|
|
1280
1297
|
Unity's Add Component menu under `GS2 Studio/DomainType/<Type>/<Kind>/<className>`. A surface lists a type's items by
|
|
1281
|
-
`className` alone (`types.
|
|
1298
|
+
`className` alone (`types.GiftBox.uiComponents.OpenButton`), so prefix `<Type>` to find the class in Unity.
|
|
1282
1299
|
|
|
1283
1300
|
`<Type>` is the type's generated name, the one its `<Type>Handler` has (see `types.<Type>.generatedHandlers` of a
|
|
1284
1301
|
surface): the type's name or, when an overlay in any package of the project renames the type, the overlay's name
|
|
1285
1302
|
(that of the overlay furthest from the type's declaration, when overlays that build on each other rename it). That
|
|
1286
1303
|
rename changes the classes of every item on the type, a dependency's included, also when the surface you read was
|
|
1287
|
-
written before it: if your package renames `
|
|
1304
|
+
written before it: if your package renames `GiftBox` to `Present`, `GiftBoxOpenButton` becomes `PresentOpenButton`.
|
|
1288
1305
|
An item on the elements of an inline element list (`inlineElementOf(Host, "listProp")`) puts the list property's name
|
|
1289
1306
|
in PascalCase between them: `<Host><ListProp><className>`; a nested list puts the name of each list on the path.
|
|
1290
1307
|
|
|
@@ -1324,48 +1341,25 @@ component and no `UiSource.rowProp`, unless your package mounts its overlay of t
|
|
|
1324
1341
|
|
|
1325
1342
|
| Generated class | Holds |
|
|
1326
1343
|
| --- | --- |
|
|
1327
|
-
| `<Type>Handler` | One row: the row whose id is set in its Inspector, with the scope ids the GS2 model needs (such as the
|
|
1344
|
+
| `<Type>Handler` | One row: the row whose id is set in its Inspector, with the scope ids the GS2 model needs (such as the group a row belongs to). It loads from these values alone, unless a GS2 key it reads cannot be derived from them, such as the trigger name of a schedule: such a handler waits until a script calls its `SetSdkKeys(...)` with that key, and the Unity project's `Assets/GS2Studio/AGENTS.md` lists these handlers and their keys. A single-entry type's handler has no row id to set: it holds the type's one row, whose id is the type name in lower case ([Keys and identity](#keys-and-identity)). |
|
|
1328
1345
|
| `<Type>ListHandler` | Every row GS2 returns for the scope set in its Inspector. For each row it instantiates `_itemPrefab`, a prefab with a `<Type>ListItemHandler` at its root and the item components below it, under `_contentParent`, and it adds and removes instances as rows come and go. When the type has both a master data and a user data model that can be listed, `_axis` picks one; it must be set, or the list loads nothing. Written only for a type that is not single entry and whose rows a GS2 master data or user data model lists. |
|
|
1329
|
-
| `<Type>ListBy<Property>Handler` | The same, for the rows whose `ref` property `<Property>` names the row of the nearest handler of the referenced type above it (for example the
|
|
1346
|
+
| `<Type>ListBy<Property>Handler` | The same, for the rows whose `ref` property `<Property>` names the row of the nearest handler of the referenced type above it (for example the gift boxes that hold one item, `GiftBoxListByItemHandler` below an `ItemHandler`). When the type has a scope, the scope is still set in its Inspector, and the handler above only narrows the rows of that scope. |
|
|
1330
1347
|
|
|
1331
|
-
A list follows the handler above it only for a type without a scope. To list the rows of a scope, such as the
|
|
1332
|
-
|
|
1333
|
-
|
|
1348
|
+
A list follows the handler above it only for a type without a scope. To list the rows of a scope, such as the rows of one
|
|
1349
|
+
group, set the scope on a `<Type>ListHandler` in its Inspector; to switch scopes while the game runs, such as a tab per
|
|
1350
|
+
group, call its `SetScope(...)` with the new scope.
|
|
1334
1351
|
|
|
1335
1352
|
A list shows the rows GS2 holds at run time (the deployed master data, or the player's user data), each with the values
|
|
1336
1353
|
of its asset-delivered properties.
|
|
1337
1354
|
|
|
1338
|
-
To show the time left until a timestamp of a row, such as
|
|
1355
|
+
To show the time left until a timestamp of a row, such as the end of a period, use a `UiItem.countdown` (or the one
|
|
1339
1356
|
the dependency lists in `types.<Type>.uiComponents`) instead of a hand-written timer: it counts on the session's GS2 clock,
|
|
1340
1357
|
which `DateTime.UtcNow` is not.
|
|
1341
1358
|
|
|
1342
1359
|
A dependency's own UI components are generated with it, so a dependency used as it is needs nothing in the DSL beyond
|
|
1343
|
-
the dependency and what its surface asks for
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
under `types.Wallet.uiComponents`; classes `WalletFreeBalanceLabel` and so on) below a `WalletHandler` whose Inspector
|
|
1347
|
-
field `_slot` is the wallet slot (`0` for slot 0, the `slot` the transforms take); its row id is that slot as a decimal
|
|
1348
|
-
string (`"0"`).
|
|
1349
|
-
|
|
1350
|
-
`micro-economy-quest` is another: its `Quest` item `StartButton` (class `QuestStartButton`, which calls `Start`) works
|
|
1351
|
-
below a quest list's item handler or a `QuestHandler` (whose Inspector fields `_id` and `_collection` are all it
|
|
1352
|
-
needs), and its `Progress` items `CompleteButton`, `IdleActiveToggle` and `RunningActiveToggle` (classes
|
|
1353
|
-
`ProgressCompleteButton`, `ProgressIdleActiveToggle`, `ProgressRunningActiveToggle`) work below a `ProgressHandler`.
|
|
1354
|
-
`Progress` is single entry, as a player has at most one quest in progress, so the `ProgressHandler` has no row id to
|
|
1355
|
-
set and holds the row `"progress"`. GS2 refuses every `Start` while a quest is in progress
|
|
1356
|
-
(the Console shows `quest.progress.progress.error.alreadyExists`), so gate the quest list's Start buttons with
|
|
1357
|
-
`ProgressIdleActiveToggle`: list the GameObject that holds them (the list's content parent, or a panel around the list)
|
|
1358
|
-
in its `_activeWhenTrue` and put the toggle on a GameObject that stays active, such as that panel's parent, never on the
|
|
1359
|
-
panel itself (see [UI components](#ui-components)). Or put one in the list's item prefab with that row's
|
|
1360
|
-
`QuestStartButton` in `_activeWhenTrue`, where it reads the `ProgressHandler` above the list. To disable Start instead
|
|
1361
|
-
of hiding it, add an `interactable` on `Quest` whose condition includes
|
|
1362
|
-
`UiCond.not(UiCond.truthy(UiSource.rowProp(quest.type("Progress"), "progress", "inProgress")))` (see
|
|
1363
|
-
[Another type's row](#another-types-row)). A player with no quest in progress, including one who never started any,
|
|
1364
|
-
has no GS2 progress, yet the `ProgressHandler` still holds the row, with `inProgress` `false` (the resource's
|
|
1365
|
-
`existenceProperty`): the condition is unknown only until the handler has loaded, and Start is enabled after that. Put
|
|
1366
|
-
what shows the quest in progress, with its `ProgressCompleteButton`, in the `_activeWhenTrue` of
|
|
1367
|
-
`ProgressRunningActiveToggle`, and put that toggle on a GameObject that stays active too, such as the parent of what it
|
|
1368
|
-
shows.
|
|
1360
|
+
the dependency and what its surface asks for: the game places the dependency's Handler and its items. Which Handler,
|
|
1361
|
+
which Inspector fields to set and which items to use are the package's own: read its usage notes,
|
|
1362
|
+
`surfaces/<packageId>.md`, when it has them ([Usage notes](#usage-notes)).
|
|
1369
1363
|
|
|
1370
1364
|
Every list of a type is in the order of the type's sort setting (`sort` on a local type in
|
|
1371
1365
|
[Keys and identity](#keys-and-identity), or on an overlay in [Overlay types](#overlay-types)). Rows whose keys are
|
|
@@ -1444,6 +1438,47 @@ namespace {{ namespacePrefix }}.GiftShop
|
|
|
1444
1438
|
}
|
|
1445
1439
|
```
|
|
1446
1440
|
|
|
1441
|
+
## Usage notes
|
|
1442
|
+
|
|
1443
|
+
`usageNotes` on `definePackage(...)` is Markdown that tells the authors of packages that depend on yours how to use it:
|
|
1444
|
+
which rows of its types to author, which of its transforms to call, which of its Handlers and items the game places
|
|
1445
|
+
and what to set on them, and what to check. Write it in a `USAGE.md` beside the entry and load it with a `?raw`
|
|
1446
|
+
import:
|
|
1447
|
+
|
|
1448
|
+
```ts
|
|
1449
|
+
import usageNotes from "./USAGE.md?raw";
|
|
1450
|
+
```
|
|
1451
|
+
|
|
1452
|
+
```ts
|
|
1453
|
+
usageNotes,
|
|
1454
|
+
```
|
|
1455
|
+
|
|
1456
|
+
`example-gift-shop`'s `USAGE.md`:
|
|
1457
|
+
|
|
1458
|
+
```text
|
|
1459
|
+
# example-gift-shop
|
|
1460
|
+
|
|
1461
|
+
Gift boxes that put items of `example-inventory` into the player's inventory.
|
|
1462
|
+
|
|
1463
|
+
## In the DSL
|
|
1464
|
+
|
|
1465
|
+
- Author each `GiftBox` row with the `Item` it holds and how many (`count`). Opening consumes its `cost`; leave `cost`
|
|
1466
|
+
out for a free box.
|
|
1467
|
+
|
|
1468
|
+
## In the game
|
|
1469
|
+
|
|
1470
|
+
- Place a `GiftBoxHandler` whose Inspector field `_id` is the gift box id, with `GiftBoxOpenButton` below it. Each press
|
|
1471
|
+
opens the box once and adds its items.
|
|
1472
|
+
```
|
|
1473
|
+
|
|
1474
|
+
The package keeps it as `usage.md`, and it reaches a dependent's author as `surfaces/<packageId>.md`, which
|
|
1475
|
+
`dsl surfaces` writes beside the package's surface, and as `usageNotes` in the surface. Notes that hold nothing but
|
|
1476
|
+
whitespace fail with `blankUsageNotes`; leave `usageNotes` out instead. A package with usage notes needs GS2 Studio
|
|
1477
|
+
2026.11.22 or later: its `package.json` says so in `engines.gs2studio`, and an older GS2 Studio refuses to load it.
|
|
1478
|
+
|
|
1479
|
+
Write what the surface does not say, short and concrete. The surface already gives names, property types, transform
|
|
1480
|
+
parameters and what each UI item shows.
|
|
1481
|
+
|
|
1447
1482
|
## Dependencies
|
|
1448
1483
|
|
|
1449
1484
|
A package can use what another package of the same project publishes: a package installed into the project, or a
|
|
@@ -1452,9 +1487,9 @@ project, so it learns the dependency's names and ids from the dependency's surfa
|
|
|
1452
1487
|
|
|
1453
1488
|
1. Put the dependency in the project: install it in GS2 Studio ("Add dependency" under a package's "Dependencies"), or
|
|
1454
1489
|
build it into the project with `dsl build` first.
|
|
1455
|
-
2. Run `dsl surfaces --dir <project> --out <dir>`; it writes `<dir>/<packageId>.json` for every package of the project
|
|
1456
|
-
|
|
1457
|
-
same content.
|
|
1490
|
+
2. Run `dsl surfaces --dir <project> --out <dir>`; it writes `<dir>/<packageId>.json` for every package of the project,
|
|
1491
|
+
and `<dir>/<packageId>.md` for a package with usage notes: read them before you use the package. For a package you
|
|
1492
|
+
build yourself, the `dependency-surface.json` that `dsl build` writes beside its ledger has the same content.
|
|
1458
1493
|
3. Import the JSON and pass it to `dependencyPackage(surface)`.
|
|
1459
1494
|
4. Declare the dependency in `definePackage({ dependencies: { [dep.packageId]: spec } })`.
|
|
1460
1495
|
|
|
@@ -1538,12 +1573,14 @@ Besides names and ids, the surface describes what a dependent needs to use them:
|
|
|
1538
1573
|
| `types.<Type>.delegatedActions.<Method>` | `targetResource`, `targetActionKey` and `parameters`: the parameters the generated method takes from its caller, which a button's `args` gives, by name with `type` (the GS2 catalog's spelling, such as `[]transaction::Config`) and `required`. The method fills every other parameter of the action itself: the namespace, the access token, the keys of the row, and those the delegated action's `parameterOverrides` set. Give `args` every `required: true` parameter; when none is, `args` may be `undefined`. A button binds only a parameter of a scalar type (a string, number or bool); one of another type, such as `config`, keeps its default. `Gs2Exchange:RateModel.Exchange` and `Gs2Showcase:DisplayItem.Buy` also take a required `storeProductId` string, which `parameters` does not list, when a master data resource of the packages that make up the type has `Gs2Money2:VerifyReceiptByUserId` (a paid product) among its actions, written directly, in a static binding, or produced by an action transform it uses. `parameters` is absent when the action does not resolve (an action the catalog lacks, or a target resource that does not mount the type) or code generation blocks it, for the delegated actions of inline schemas (`inlineSchemas.<list>.delegatedActions`), and from older surfaces: then the surface does not say what the method takes. |
|
|
1539
1574
|
| `types.<Type>.singleEntry` | `true` when the type has one row (see [Keys and identity](#keys-and-identity)). |
|
|
1540
1575
|
| `types.<Type>.singleEntryRowId` | The id of that one row, for a single-entry type: the name of the type's first declaration in lower case, also when an overlay renames the type. It is the id of a row you author of the type and the `rowId` to pass to `UiSource.rowProp`. Absent for other types, and from older surfaces. |
|
|
1576
|
+
| `types.<Type>.compositeKey` | The names of the composite key's members in ascending order of their property ids: join the members' values with `.` in this order to make a row id (see [Keys and identity](#keys-and-identity)). An overlay that renames a member lists it under its new name. Absent for a type without a composite key, and from older surfaces (write the surface again with `dsl surfaces`). |
|
|
1541
1577
|
| `types.<Type>.sort` | The order of the type's rows, `{ key, direction }` as an overlay's `sort` takes it (`key` is `null` for the id); absent when the rows are in ascending id order, and from older surfaces. |
|
|
1542
1578
|
| `types.<Type>.shippedRowIds` | The ids of the rows this package ships of the type, sorted; `[]` when it ships none. Each package lists only its own rows: the rows of a type are those of every surface entry with the same `canonicalPackageId` and `canonicalTypeId`, plus those every surface lists under `shippedRowsOfDependencyTypes."<canonicalPackageId>:<canonicalTypeId>"`. These rows are provided, so do not author them: a row you author with a listed id replaces the shipped row and all its values (change some values with `overlayInstance` instead). Rows with other ids are added beside them, except on a single-entry type, whose one row is the shipped one. A row an `overlayInstance` suppresses is still listed. When no surface lists a row and a build names the type in `No master data is registered for domain model "<Type>"`, the rows are yours to author. |
|
|
1543
|
-
| `types.<Type>.uiComponents.<className>` | The UI items on the type, the package's own and those of the packages it overlays (`{}` for none), by the class name the item was declared with, not the generated class: key `
|
|
1579
|
+
| `types.<Type>.uiComponents.<className>` | The UI items on the type, the package's own and those of the packages it overlays (`{}` for none), by the class name the item was declared with, not the generated class: key `OpenButton` on `GiftBox` is the generated class `GiftBoxOpenButton` (`<Type><className>`; see [Item options](#item-options)). Each gives `kind` (`label`, `buttonAction`, ...), `name` (the item's label in GS2 Studio's editor, which is not part of any class name), the declaring `packageId`, for a button the delegated action `method` it calls, for a `templateLabel` its `template` (one text, or one per locale keyed by tag; `{key}` names a source), for a `label`, `countdown` or `templateLabel` the `fallbackText` it shows while its value is unset (absent when it has none: then it shows empty text), and the item's `description` when it has one. An inline schema lists its items under `inlineSchemas.<list>.uiComponents`. Code generation gives the items of an overlay, renamed or not, the same generated classes as the type's, so an item you add with a listed class name replaces the listed item (`dsl build` warns about it). Reuse a listed item instead of adding one that shows the same. |
|
|
1544
1580
|
| `types.<Type>.generatedHandlers` | The classes Unity code generation writes for the rows of the type, judged on the package and its dependencies: `<Type>Handler`, and for a type whose rows a GS2 model lists, `<Type>ListHandler`, `<Type>ListItemHandler` and one `<Type>ListBy<Ref>Handler` per reference it can list by (see [Rows in the game](#rows-in-the-game)). `<Type>` is the type's one generated name, which also starts the class of each of its UI items; an overlay keeps it unless it renames the type ([Item options](#item-options)). `[]` when it writes none: a UI component on the type, or a `UiSource.rowProp` of it, then fails `dsl build` unless your package mounts its overlay of the type with a resource of its own. The element Handlers of an inline schema are not listed. Absent when code generation refuses the type. |
|
|
1545
1581
|
| `types.<Type>.mountedBy` | `masterData` and `userData`: the GS2 models (`<service>.<Model>`) of this package's own resources mounted on the type, sorted. A type mounted only by a namespace, such as `CurrencyStore` (`money2.Namespace`), gets no Handler. Other packages that overlay the type list their resources in their own surfaces. |
|
|
1546
1582
|
| `shippedRowsOfDependencyTypes` | The ids of the rows this package ships of a dependency's type it does not declare (`instance(dep.type("<Type>"), ...)`), keyed `<canonicalPackageId>:<canonicalTypeId>` of the type, as its surface entries publish them. |
|
|
1583
|
+
| `usageNotes` | The package's usage notes ([Usage notes](#usage-notes)); absent when it has none. `dsl surfaces` also writes them as `<dir>/<packageId>.md`. |
|
|
1547
1584
|
| `actionTransformSignatures.<Name>` | `category` (`acquire`, `consume` or `verify`) and `parameters`: per parameter in declaration order, `type`, `required` and, only when the parameter gives one, `description` (one text, not per locale). A `ref<T>` parameter takes a row id of `T`. |
|
|
1548
1585
|
|
|
1549
1586
|
A surface written by an older GS2 Studio has neither `propertyDetails` nor `actionTransformSignatures`; `transformCall` and `transformProgram` then fail to compile and
|
|
@@ -1589,7 +1626,8 @@ throw. Write it again with `dsl surfaces`.
|
|
|
1589
1626
|
"StockLabel": {
|
|
1590
1627
|
"kind": "templateLabel",
|
|
1591
1628
|
"name": "Item",
|
|
1592
|
-
"packageId": "example-inventory"
|
|
1629
|
+
"packageId": "example-inventory",
|
|
1630
|
+
"template": "{id} x{count}"
|
|
1593
1631
|
}
|
|
1594
1632
|
},
|
|
1595
1633
|
"properties": {
|
|
@@ -1674,18 +1712,7 @@ a type that package `<packageId>` declares, which need not be the package whose
|
|
|
1674
1712
|
2. Author the row with `instance(other.type("<Type>"), id, values)`, with the values its `propertyDetails` ask for.
|
|
1675
1713
|
3. Give that row id as the `ref` value.
|
|
1676
1714
|
|
|
1677
|
-
A
|
|
1678
|
-
`QuestCollection.schedule` is `ref<foundation-economy-schedule:Schedule>`, GS2's challenge period of the quest group,
|
|
1679
|
-
which holds for every quest in the collection. To limit one quest, give it a collection of its own: declare
|
|
1680
|
-
`foundation-economy-schedule` (`github:gs2io/gs2-studio-package` for the official package), author
|
|
1681
|
-
`instance(schedule.type("Schedule"), "winter_event", { scheduleType: "absolute", repeatType: "always", startAt:
|
|
1682
|
-
"2026-11-30T15:00:00Z", endAt: "2026-12-31T14:59:59Z" })` (1 to 31 December 2026 in Japan; timestamps are UTC, see
|
|
1683
|
-
[Property types](#property-types)) and `instance(quest.type("QuestCollection"), "winter_event", { schedule:
|
|
1684
|
-
"winter_event" })`, and give the quest's row `collection: "winter_event"`.
|
|
1685
|
-
|
|
1686
|
-
A game lists quests by collection (a `QuestListHandler` whose `_collection` is set to one collection; see
|
|
1687
|
-
[Rows in the game](#rows-in-the-game)), so a scene that lists the other collection does not show this quest: the game
|
|
1688
|
-
must list the new collection as well, with another list or by switching the list's scope with `SetScope(...)`.
|
|
1715
|
+
A dependency's usage notes give examples of such rows when it has them.
|
|
1689
1716
|
|
|
1690
1717
|
## The id ledger
|
|
1691
1718
|
|
|
@@ -1821,7 +1848,7 @@ warnings` when there is none (`--json`: `diagnostics` is `[]`):
|
|
|
1821
1848
|
| Line | Fix |
|
|
1822
1849
|
| --- | --- |
|
|
1823
1850
|
| `[warning] <dependency> / <Type>::id: ... No master data is registered for domain model "<Type>", so <resource> resource cannot be expanded.` | The dependency's GS2 resource needs rows of `<Type>` from the project. Add them with `instance(dep.type("<Type>"), id, values)`, with a value for each property `types.<Type>.propertyDetails` of the surface lists as `requirement: "always"`, except `id` (the row id), `userData` properties and action lists, and for each `conditional` one with `requiredWhenMet: true` unless the row's values rule out its `condition`. The line's remedy names that call and that surface key with the type's name; it keeps `<Type>` when the warning names an inline schema or an unresolved type rather than a type `dep.type()` takes. An inline schema's rows are elements of the host type's list property (`dep.inlineElements(...)`). |
|
|
1824
|
-
| `... is a dependency the DSL cannot change, so
|
|
1851
|
+
| `... is a dependency whose own definitions the DSL cannot change, so the findings in them are fixed through the dependency that brings it in: ...` | A defect in the dependency's own definitions, said once for the package; a finding about rows, which the DSL adds or overrides, is not among them. Remove the dependency the message names from the DSL when the package does not need it; the update or removal the message leaves to the project's owner is made in GS2 Studio. |
|
|
1825
1852
|
| `[error] ... the required arguments (...) of action transform "..." have no value for row "..."` | A transform argument reads a property the row has no value for. Give every row the value, also the dependency's rows (`overlayInstance`). |
|
|
1826
1853
|
| A line about another package that this DSL does not change | Leave it; tell the user about it instead of building again. |
|
|
1827
1854
|
| Any other line | Fix the DSL as the message says. Messages written for the editor name the editor's steps. |
|
|
@@ -1834,7 +1861,8 @@ These lines do not include what Unity code generation alone refuses: run `"<GS2
|
|
|
1834
1861
|
`CLI_DSL_PACKAGE_INVALID` prints each problem as a JSON object; its `kind` is one of these. The other fields name the
|
|
1835
1862
|
type, property, resource or component involved. A `restoreFailure` is printed as its plain message, and a property name
|
|
1836
1863
|
that resolves to nothing (`unresolvedPropertySlot`, `uiComponentUnknownProperty`) as
|
|
1837
|
-
`<where>: "<name>" is not a property of "<Type>" (properties: ...)`.
|
|
1864
|
+
`<where>: "<name>" is not a property of "<Type>" (properties: ...)`. `duplicateActionPropertyTransformTarget` is printed
|
|
1865
|
+
as a sentence that names the transforms and says how to combine them.
|
|
1838
1866
|
|
|
1839
1867
|
| Kind | Cause |
|
|
1840
1868
|
| --- | --- |
|
|
@@ -1844,6 +1872,7 @@ that resolves to nothing (`unresolvedPropertySlot`, `uiComponentUnknownProperty`
|
|
|
1844
1872
|
| `reservedPropertyName` | A property named `id`. |
|
|
1845
1873
|
| `duplicateDomainTypeName`, `duplicatePropertyName` | Two types, or two properties of one type, share a name. |
|
|
1846
1874
|
| `duplicateOverlaySource` | Two overlays of the same source type. |
|
|
1875
|
+
| `duplicateActionPropertyTransformTarget` | An overlay attaches two transforms to one property (`targetProperty`, `transformNames`), whatever their `mode`. Define one transform in this package whose delegation outputs call each of them and attach that one. |
|
|
1847
1876
|
| `domainTypeDefinitionNotRegistered` | A definition used without being listed in `domainTypes`; `context` says where it was used. |
|
|
1848
1877
|
| `invalidRefTarget` | `PT.ref(...)` names a type the package does not include. |
|
|
1849
1878
|
| `invalidInstanceType` | A row of a type the package does not declare. |
|
|
@@ -1880,6 +1909,7 @@ that resolves to nothing (`unresolvedPropertySlot`, `uiComponentUnknownProperty`
|
|
|
1880
1909
|
| `uiComponentTemplateLabelLocaleInvalid` | A template per locale with no locale, a tag that is no BCP 47 locale, one locale twice, or empty text (`issue.kind`). |
|
|
1881
1910
|
| `uiComponentTemplateLabelLocalePlaceholderMissing` | `locale`'s template leaves out `{key}`, which another locale's template uses. |
|
|
1882
1911
|
| `unsafeCodeTemplateOutputFileName` | A code template output name that cannot be written as a file. |
|
|
1912
|
+
| `blankUsageNotes` | `usageNotes` that is not text or holds nothing but whitespace. |
|
|
1883
1913
|
|
|
1884
1914
|
## Exported types
|
|
1885
1915
|
|
package/index.d.ts
CHANGED
|
@@ -5691,6 +5691,12 @@ interface PublishedUiComponentItem {
|
|
|
5691
5691
|
readonly name: string;
|
|
5692
5692
|
readonly packageId: string;
|
|
5693
5693
|
readonly method?: string;
|
|
5694
|
+
/** The description its author gave it. */
|
|
5695
|
+
readonly description?: string;
|
|
5696
|
+
/** A `templateLabel`'s text: one for every player, or one per locale keyed by BCP 47 tag, `{key}` naming a source. */
|
|
5697
|
+
readonly template?: string | Readonly<Record<string, string>>;
|
|
5698
|
+
/** What a `label`, `countdown` or `templateLabel` shows while its value is unset; absent when its author gave none. */
|
|
5699
|
+
readonly fallbackText?: string;
|
|
5694
5700
|
}
|
|
5695
5701
|
interface PublishedInlineElementSchema {
|
|
5696
5702
|
readonly properties: Readonly<Record<string, string>>;
|
|
@@ -5743,6 +5749,12 @@ interface DependencySurfaceType {
|
|
|
5743
5749
|
* it. Absent for other types and from older surfaces.
|
|
5744
5750
|
*/
|
|
5745
5751
|
readonly singleEntryRowId?: string;
|
|
5752
|
+
/**
|
|
5753
|
+
* The effective names of the composite key's members in ascending order of their property ids, the order their values join with
|
|
5754
|
+
* `.` into a row id. Absent for a type without a composite key, for one with a member that is not one of its properties, and
|
|
5755
|
+
* from older surfaces.
|
|
5756
|
+
*/
|
|
5757
|
+
readonly compositeKey?: readonly string[];
|
|
5746
5758
|
/** Preserve canonical identity across re-exporting overlays. */
|
|
5747
5759
|
readonly canonicalPackageId: string;
|
|
5748
5760
|
readonly canonicalTypeId: string;
|
|
@@ -5793,6 +5805,8 @@ export interface DependencySurface {
|
|
|
5793
5805
|
readonly actionTransformSignatures?: Readonly<Record<string, PublishedTransformSignature>>;
|
|
5794
5806
|
/** Use service.modelName coordinates to distinguish resources with the same model name in different services. */
|
|
5795
5807
|
readonly masterDataResources: Readonly<Record<string, string>>;
|
|
5808
|
+
/** The package's usage notes, Markdown telling an author how to use it. Absent when it has none and from older surfaces. */
|
|
5809
|
+
readonly usageNotes?: string;
|
|
5796
5810
|
}
|
|
5797
5811
|
interface DependencyOverlaySource {
|
|
5798
5812
|
readonly directSourcePackageId: string;
|
|
@@ -6247,6 +6261,11 @@ export interface PackageSpec {
|
|
|
6247
6261
|
readonly actionTransforms?: readonly ActionTransformDef[];
|
|
6248
6262
|
readonly uiComponents?: readonly UiComponentDef[];
|
|
6249
6263
|
readonly codeTemplates?: readonly CodeTemplateSnapshotDto[];
|
|
6264
|
+
/**
|
|
6265
|
+
* Markdown telling an author how to use the package, such as a `USAGE.md` beside the DSL imported with `?raw`. The package
|
|
6266
|
+
* ships it as `usage.md`, and `dsl surfaces` writes it beside the package's surface.
|
|
6267
|
+
*/
|
|
6268
|
+
readonly usageNotes?: string;
|
|
6250
6269
|
}
|
|
6251
6270
|
interface ScriptSettingShape {
|
|
6252
6271
|
readonly triggerScriptId?: string;
|